From ad2fd9e4d5415f89b4baa17dc1a4029216af4c03 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Sat, 29 Nov 2014 21:10:51 -0500 Subject: [PATCH] update to projectile move check --- zone/common.h | 3 ++- zone/mob.cpp | 3 ++- zone/special_attacks.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/zone/common.h b/zone/common.h index 267831368..ddb7b4b0a 100644 --- a/zone/common.h +++ b/zone/common.h @@ -468,7 +468,8 @@ typedef struct float origin_x; float origin_y; float origin_z; - float sanitycheck; + float tlast_x; + float tlast_y; uint32 ranged_id; uint32 ammo_id; int ammo_slot; diff --git a/zone/mob.cpp b/zone/mob.cpp index 7261aeb46..58aafa1cb 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -297,7 +297,8 @@ 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].tlast_x = 0.0f; + ProjectileAtk[i].tlast_y = 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 c73a2cb11..0ba5ebe09 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -1077,11 +1077,10 @@ void Mob::ProjectileAttack() Mob* target = entity_list.GetMobID(ProjectileAtk[i].target_id); if (target && target->IsMoving()){ //Only recalculate hit increment if target moving - //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. - float _sanitycheck = target->GetX() * target->GetY(); - if (ProjectileAtk[i].sanitycheck != _sanitycheck){ - ProjectileAtk[i].sanitycheck = _sanitycheck; + if (ProjectileAtk[i].tlast_x != target->GetX() || ProjectileAtk[i].tlast_y != target->GetY()){ + ProjectileAtk[i].tlast_x = target->GetX(); + ProjectileAtk[i].tlast_y = 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); @@ -1103,7 +1102,8 @@ void Mob::ProjectileAttack() 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].tlast_x = 0.0f; + ProjectileAtk[i].tlast_y = 0.0f; ProjectileAtk[i].ranged_id = 0; ProjectileAtk[i].ammo_id = 0; ProjectileAtk[i].ammo_slot = 0;