diff --git a/zone/common.h b/zone/common.h index c4f643525..267831368 100644 --- a/zone/common.h +++ b/zone/common.h @@ -468,6 +468,7 @@ typedef struct float origin_x; float origin_y; float origin_z; + float sanitycheck; uint32 ranged_id; uint32 ammo_id; int ammo_slot; diff --git a/zone/mob.cpp b/zone/mob.cpp index 398bffd3d..b4645b115 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -297,6 +297,7 @@ Mob::Mob(const char* in_name, ProjectileAtk[i].origin_x = 0.0f; ProjectileAtk[i].origin_y = 0.0f; ProjectileAtk[i].origin_z = 0.0f; + ProjectileAtk[i].sanitycheck = 0.0f; ProjectileAtk[i].ranged_id = 0; ProjectileAtk[i].ammo_id = 0; ProjectileAtk[i].ammo_slot = 0; diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 04f2b199a..5f8373cac 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -1075,9 +1075,14 @@ void Mob::ProjectileAttack() Mob* target = entity_list.GetMobID(ProjectileAtk[i].target_id); if (target && target->IsMoving()){ //Only recalculate hit increment if target moving - float distance = target->CalculateDistance(ProjectileAtk[i].origin_x, ProjectileAtk[i].origin_y, ProjectileAtk[i].origin_z); - float hit = 60.0f + (distance / 1.8f); //Calcuation: 60 = Animation Lag, 1.8 = Speed modifier for speed of (4) - ProjectileAtk[i].hit_increment = static_cast(hit); + + //Due to frequency that we need to check increment the targets position variables may not be updated even if moving. Do a simple check before calculating distance. + if (ProjectileAtk[i].sanitycheck != target->GetX() * target->GetY()){ + ProjectileAtk[i].sanitycheck = target->GetX() * target->GetY(); + float distance = target->CalculateDistance(ProjectileAtk[i].origin_x, ProjectileAtk[i].origin_y, ProjectileAtk[i].origin_z); + float hit = 60.0f + (distance / 1.8f); //Calcuation: 60 = Animation Lag, 1.8 = Speed modifier for speed of (4) + ProjectileAtk[i].hit_increment = static_cast(hit); + } } if (ProjectileAtk[i].hit_increment <= ProjectileAtk[i].increment){