some code logic discussion
in Attack.cpp at method NPC::Attack ~line 1900 you see
Code:
float calcheading=CalculateHeadingToTarget(target->GetX(), target->GetY()); CalculateHeadingToTarget() in waypoints.cpp has some heavy calculations that you don't want to call too often. Code:
sint8 Mob::CalculateHeadingToTarget(float in_x, float in_y) { Mob.h ~line 771 Code:
void SetHeading(float iHeading) { if (heading != iHeading) { pLastChange = Timer::GetCurrentTime(); heading = iHeading; } } in Mob.cpp ~line 1928 is Mob::FaceTarget() Code:
void Mob::FaceTarget(Mob* MobToFace, bool update) { calc heading to target if not facing target set heading to face target calc heading to target again update all(800 * 800 is a long ways) clients in zone of graphical heading change don't update pLastChange even if bool is set to true To clean this code up, I'm suggesting this: calc heading to target if not facing target set heading to face target if heading changed send graphical update to clients by changing: Code:
float calcheading=CalculateHeadingToTarget(target->GetX(), target->GetY()); Code:
FaceTarget(target); mob.h Code:
void FaceTarget(Mob* MobToFace = 0); Code:
void Mob::FaceTarget(Mob* MobToFace) { |
It seems CalculateHeadingToTarget() returns a sint8
Everywhere it is used as a float though since heading is a float. Also, in FaceTarget() heading is getting updated regardless of it needing to be updated or not because it is getting set directly since it is not a private or protected variable so here's an additional change for FaceTarget() Code:
void Mob::FaceTarget(Mob* MobToFace) { waypoints.cpp Code:
sint8 Mob::CalculateHeadingToTarget(float in_x, float in_y) { Code:
float Mob::CalculateHeadingToTarget(float in_x, float in_y) { Code:
return (sint8) (256*(360-angle)/360.0f); Code:
return (256*(360-angle)/360.0f); |
the only place that seems to do some kind of calc to determine if true or false should be sent to FaceTarget() method is in perl_mob.cpp
Code:
XS(XS_Mob_FaceTarget); /* prototype to pass -Wmissing-prototypes */ |
That looks like a quest object, as apposed to a normal quest:: command.
$mob->FaceTarget(MobToFace= 0, update= false) Quest Objects http://www.eqemulator.net/wiki/wikka...a=QuestObjects Quest Commands http://www.eqemulator.net/wiki/wikka...=QuestTutorial |
Trev is right it's a Mob object exported to perl. I don't see any problems with what's posted so far.
|
The confusing thing is that the update portion is to force the update of the pLastChange variable but this variable seems to be only used by Clients and not NPCs. Not sure why it's even needed for $mob-> except for the target facing part.
|
All times are GMT -4. The time now is 07:29 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.