mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 19:51:29 +00:00
Sanity check added before calculating distance.
This commit is contained in:
parent
94a0cb3522
commit
ac0933719a
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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<uint16>(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<uint16>(hit);
|
||||
}
|
||||
}
|
||||
|
||||
if (ProjectileAtk[i].hit_increment <= ProjectileAtk[i].increment){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user