Fix issues with NPC's ghosting who path for long distances, this should wrap up the small remainder of ghosting edge cases

This commit is contained in:
Akkadius 2017-11-21 21:25:20 -06:00
parent 52d31a6846
commit b03e9af597
3 changed files with 88 additions and 74 deletions

View File

@ -269,8 +269,17 @@ bool Client::Process() {
} }
} }
if (force_spawn_updates && mob != this && distance <= client_update_range) if (force_spawn_updates && mob != this) {
mob->SendPositionUpdateToClient(this);
if (mob->is_distance_roamer) {
Log(Logs::General, Logs::Debug, "Updating distance roamer %s", mob->GetCleanName());
mob->SendPositionUpdateToClient(this);
continue;
}
if (distance <= client_update_range)
mob->SendPositionUpdateToClient(this);
}
} }
} }

View File

@ -75,7 +75,6 @@ Mob::Mob(const char* in_name,
uint32 in_drakkin_tattoo, uint32 in_drakkin_tattoo,
uint32 in_drakkin_details, uint32 in_drakkin_details,
EQEmu::TintProfile in_armor_tint, EQEmu::TintProfile in_armor_tint,
uint8 in_aa_title, uint8 in_aa_title,
uint8 in_see_invis, // see through invis/ivu uint8 in_see_invis, // see through invis/ivu
uint8 in_see_invis_undead, uint8 in_see_invis_undead,
@ -91,24 +90,24 @@ Mob::Mob(const char* in_name,
uint8 in_handtexture, uint8 in_handtexture,
uint8 in_legtexture, uint8 in_legtexture,
uint8 in_feettexture uint8 in_feettexture
) : ) :
attack_timer(2000), attack_timer(2000),
attack_dw_timer(2000), attack_dw_timer(2000),
ranged_timer(2000), ranged_timer(2000),
tic_timer(6000), tic_timer(6000),
mana_timer(2000), mana_timer(2000),
spellend_timer(0), spellend_timer(0),
rewind_timer(30000), //Timer used for determining amount of time between actual player position updates for /rewind. rewind_timer(30000),
bindwound_timer(10000), bindwound_timer(10000),
stunned_timer(0), stunned_timer(0),
spun_timer(0), spun_timer(0),
bardsong_timer(6000), bardsong_timer(6000),
gravity_timer(1000), gravity_timer(1000),
viral_timer(0), viral_timer(0),
m_FearWalkTarget(-999999.0f,-999999.0f,-999999.0f), m_FearWalkTarget(-999999.0f, -999999.0f, -999999.0f),
m_TargetLocation(glm::vec3()), m_TargetLocation(glm::vec3()),
m_TargetV(glm::vec3()), m_TargetV(glm::vec3()),
flee_timer(FLEE_CHECK_TIMER), flee_timer(FLEE_CHECK_TIMER),
m_Position(position), m_Position(position),
tmHidden(-1), tmHidden(-1),
mitigation_ac(0), mitigation_ac(0),
@ -119,47 +118,48 @@ Mob::Mob(const char* in_name,
position_update_melee_push_timer(1000) position_update_melee_push_timer(1000)
{ {
targeted = 0; targeted = 0;
tar_ndx=0; tar_ndx = 0;
tar_vector=0; tar_vector = 0;
currently_fleeing = false; currently_fleeing = false;
last_z = 0; last_z = 0;
last_major_update_position = m_Position; last_major_update_position = m_Position;
is_distance_roamer = false;
AI_Init(); AI_Init();
SetMoving(false); SetMoving(false);
moved=false; moved = false;
m_RewindLocation = glm::vec3(); m_RewindLocation = glm::vec3();
_egnode = nullptr; _egnode = nullptr;
name[0]=0; name[0] = 0;
orig_name[0]=0; orig_name[0] = 0;
clean_name[0]=0; clean_name[0] = 0;
lastname[0]=0; lastname[0] = 0;
if(in_name) { if (in_name) {
strn0cpy(name,in_name,64); strn0cpy(name, in_name, 64);
strn0cpy(orig_name,in_name,64); strn0cpy(orig_name, in_name, 64);
} }
if(in_lastname) if (in_lastname)
strn0cpy(lastname,in_lastname,64); strn0cpy(lastname, in_lastname, 64);
cur_hp = in_cur_hp; cur_hp = in_cur_hp;
max_hp = in_max_hp; max_hp = in_max_hp;
base_hp = in_max_hp; base_hp = in_max_hp;
gender = in_gender; gender = in_gender;
race = in_race; race = in_race;
base_gender = in_gender; base_gender = in_gender;
base_race = in_race; base_race = in_race;
class_ = in_class; class_ = in_class;
bodytype = in_bodytype; bodytype = in_bodytype;
orig_bodytype = in_bodytype; orig_bodytype = in_bodytype;
deity = in_deity; deity = in_deity;
level = in_level; level = in_level;
orig_level = in_level; orig_level = in_level;
npctype_id = in_npctype_id; npctype_id = in_npctype_id;
size = in_size; size = in_size;
base_size = size; base_size = size;
runspeed = in_runspeed; runspeed = in_runspeed;
// neotokyo: sanity check // neotokyo: sanity check
if (runspeed < 0 || runspeed > 20) if (runspeed < 0 || runspeed > 20)
runspeed = 1.25f; runspeed = 1.25f;
@ -172,7 +172,8 @@ Mob::Mob(const char* in_name,
fearspeed = 0.625f; fearspeed = 0.625f;
base_fearspeed = 25; base_fearspeed = 25;
// npcs // npcs
} else { }
else {
base_walkspeed = base_runspeed * 100 / 265; base_walkspeed = base_runspeed * 100 / 265;
walkspeed = ((float)base_walkspeed) * 0.025f; walkspeed = ((float)base_walkspeed) * 0.025f;
base_fearspeed = base_runspeed * 100 / 127; base_fearspeed = base_runspeed * 100 / 127;
@ -184,7 +185,7 @@ Mob::Mob(const char* in_name,
current_speed = base_runspeed; current_speed = base_runspeed;
m_PlayerState = 0; m_PlayerState = 0;
// sanity check // sanity check
@ -196,8 +197,8 @@ Mob::Mob(const char* in_name,
m_Light.Type[EQEmu::lightsource::LightActive] = m_Light.Type[EQEmu::lightsource::LightInnate]; m_Light.Type[EQEmu::lightsource::LightActive] = m_Light.Type[EQEmu::lightsource::LightInnate];
m_Light.Level[EQEmu::lightsource::LightActive] = m_Light.Level[EQEmu::lightsource::LightInnate]; m_Light.Level[EQEmu::lightsource::LightActive] = m_Light.Level[EQEmu::lightsource::LightInnate];
texture = in_texture; texture = in_texture;
helmtexture = in_helmtexture; helmtexture = in_helmtexture;
armtexture = in_armtexture; armtexture = in_armtexture;
bracertexture = in_bracertexture; bracertexture = in_bracertexture;
handtexture = in_handtexture; handtexture = in_handtexture;
@ -205,21 +206,21 @@ Mob::Mob(const char* in_name,
feettexture = in_feettexture; feettexture = in_feettexture;
multitexture = (armtexture || bracertexture || handtexture || legtexture || feettexture); multitexture = (armtexture || bracertexture || handtexture || legtexture || feettexture);
haircolor = in_haircolor; haircolor = in_haircolor;
beardcolor = in_beardcolor; beardcolor = in_beardcolor;
eyecolor1 = in_eyecolor1; eyecolor1 = in_eyecolor1;
eyecolor2 = in_eyecolor2; eyecolor2 = in_eyecolor2;
hairstyle = in_hairstyle; hairstyle = in_hairstyle;
luclinface = in_luclinface; luclinface = in_luclinface;
beard = in_beard; beard = in_beard;
drakkin_heritage = in_drakkin_heritage; drakkin_heritage = in_drakkin_heritage;
drakkin_tattoo = in_drakkin_tattoo; drakkin_tattoo = in_drakkin_tattoo;
drakkin_details = in_drakkin_details; drakkin_details = in_drakkin_details;
attack_speed = 0; attack_speed = 0;
attack_delay = 0; attack_delay = 0;
slow_mitigation = 0; slow_mitigation = 0;
findable = false; findable = false;
trackable = true; trackable = true;
has_shieldequiped = false; has_shieldequiped = false;
has_twohandbluntequiped = false; has_twohandbluntequiped = false;
has_twohanderequipped = false; has_twohanderequipped = false;
@ -230,19 +231,19 @@ Mob::Mob(const char* in_name,
SpellPowerDistanceMod = 0; SpellPowerDistanceMod = 0;
last_los_check = false; last_los_check = false;
if(in_aa_title>0) if (in_aa_title > 0)
aa_title = in_aa_title; aa_title = in_aa_title;
else else
aa_title =0xFF; aa_title = 0xFF;
AC = in_ac; AC = in_ac;
ATK = in_atk; ATK = in_atk;
STR = in_str; STR = in_str;
STA = in_sta; STA = in_sta;
DEX = in_dex; DEX = in_dex;
AGI = in_agi; AGI = in_agi;
INT = in_int; INT = in_int;
WIS = in_wis; WIS = in_wis;
CHA = in_cha; CHA = in_cha;
MR = CR = FR = DR = PR = Corrup = 0; MR = CR = FR = DR = PR = Corrup = 0;
ExtraHaste = 0; ExtraHaste = 0;
@ -263,8 +264,8 @@ Mob::Mob(const char* in_name,
hidden = false; hidden = false;
improved_hidden = false; improved_hidden = false;
invulnerable = false; invulnerable = false;
IsFullHP = (cur_hp == max_hp); IsFullHP = (cur_hp == max_hp);
qglobal=0; qglobal = 0;
spawned = false; spawned = false;
InitializeBuffSlots(); InitializeBuffSlots();
@ -305,7 +306,7 @@ Mob::Mob(const char* in_name,
logging_enabled = false; logging_enabled = false;
isgrouped = false; isgrouped = false;
israidgrouped = false; israidgrouped = false;
IsHorse = false; IsHorse = false;
entity_id_being_looted = 0; entity_id_being_looted = 0;
@ -376,13 +377,13 @@ Mob::Mob(const char* in_name,
} }
destructibleobject = false; destructibleobject = false;
wandertype=0; wandertype = 0;
pausetype=0; pausetype = 0;
cur_wp = 0; cur_wp = 0;
m_CurrentWayPoint = glm::vec4(); m_CurrentWayPoint = glm::vec4();
cur_wp_pause = 0; cur_wp_pause = 0;
patrol=0; patrol = 0;
follow=0; follow = 0;
follow_dist = 100; // Default Distance for Follow follow_dist = 100; // Default Distance for Follow
no_target_hotkey = false; no_target_hotkey = false;
flee_mode = false; flee_mode = false;
@ -396,7 +397,7 @@ Mob::Mob(const char* in_name,
rooted = false; rooted = false;
charmed = false; charmed = false;
has_virus = false; has_virus = false;
for (i=0; i<MAX_SPELL_TRIGGER*2; i++) { for (i = 0; i < MAX_SPELL_TRIGGER * 2; i++) {
viral_spells[i] = 0; viral_spells[i] = 0;
} }
pStandingPetOrder = SPO_Follow; pStandingPetOrder = SPO_Follow;
@ -427,7 +428,7 @@ Mob::Mob(const char* in_name,
nimbus_effect3 = 0; nimbus_effect3 = 0;
m_targetable = true; m_targetable = true;
m_TargetRing = glm::vec3(); m_TargetRing = glm::vec3();
flymode = FlyMode3; flymode = FlyMode3;
// Pathing // Pathing
@ -444,7 +445,7 @@ Mob::Mob(const char* in_name,
m_AllowBeneficial = false; m_AllowBeneficial = false;
m_DisableMelee = false; m_DisableMelee = false;
for (int i = 0; i < EQEmu::skills::HIGHEST_SKILL + 2; i++) { SkillDmgTaken_Mod[i] = 0; } for (int i = 0; i < EQEmu::skills::HIGHEST_SKILL + 2; i++) { SkillDmgTaken_Mod[i] = 0; }
for (int i = 0; i < HIGHEST_RESIST+2; i++) { Vulnerability_Mod[i] = 0; } for (int i = 0; i < HIGHEST_RESIST + 2; i++) { Vulnerability_Mod[i] = 0; }
emoteid = 0; emoteid = 0;
endur_upkeep = false; endur_upkeep = false;
@ -1447,6 +1448,7 @@ void Mob::SendPosition() {
if (DistanceSquared(last_major_update_position, m_Position) >= (100 * 100)) { if (DistanceSquared(last_major_update_position, m_Position) >= (100 * 100)) {
entity_list.QueueClients(this, app, true, true); entity_list.QueueClients(this, app, true, true);
last_major_update_position = m_Position; last_major_update_position = m_Position;
is_distance_roamer = true;
} }
else { else {
entity_list.QueueCloseClients(this, app, true, RuleI(Range, MobPositionUpdates), nullptr, false); entity_list.QueueCloseClients(this, app, true, RuleI(Range, MobPositionUpdates), nullptr, false);

View File

@ -162,6 +162,8 @@ public:
inline virtual bool IsMob() const { return true; } inline virtual bool IsMob() const { return true; }
inline virtual bool InZone() const { return true; } inline virtual bool InZone() const { return true; }
bool is_distance_roamer;
//Somewhat sorted: needs documenting! //Somewhat sorted: needs documenting!
//Attack //Attack
@ -954,7 +956,7 @@ public:
void SendTo(float new_x, float new_y, float new_z); void SendTo(float new_x, float new_y, float new_z);
void SendToFixZ(float new_x, float new_y, float new_z); void SendToFixZ(float new_x, float new_y, float new_z);
float GetZOffset() const; float GetZOffset() const;
void FixZ(int32 z_find_offset = 5); void FixZ(int32 z_find_offset = 5);
void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false); void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false);
inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; } inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; }
inline uint32 DontBuffMeBefore() const { return pDontBuffMeBefore; } inline uint32 DontBuffMeBefore() const { return pDontBuffMeBefore; }
@ -1225,7 +1227,8 @@ protected:
uint32 npctype_id; uint32 npctype_id;
glm::vec4 m_Position; glm::vec4 m_Position;
/* Used to determine when an NPC has traversed so many units - to send a zone wide pos update */ /* Used to determine when an NPC has traversed so many units - to send a zone wide pos update */
glm::vec4 last_major_update_position; glm::vec4 last_major_update_position;
int animation; // this is really what MQ2 calls SpeedRun just packed like (int)(SpeedRun * 40.0f) int animation; // this is really what MQ2 calls SpeedRun just packed like (int)(SpeedRun * 40.0f)
float base_size; float base_size;
float size; float size;