MoveTo converted to xyz_heading

This commit is contained in:
Arthur Ice 2014-11-30 16:30:09 -08:00
parent e6d23228e5
commit 0570722b3b
5 changed files with 18 additions and 17 deletions

View File

@ -2430,7 +2430,7 @@ void command_spawn(Client *c, const Seperator *sep)
LogFile->write(EQEMuLog::Debug,"#spawn Spawning:"); LogFile->write(EQEMuLog::Debug,"#spawn Spawning:");
#endif #endif
NPC* npc = NPC::SpawnNPC(sep->argplus[1], c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(), c); NPC* npc = NPC::SpawnNPC(sep->argplus[1], c->GetPosition(), c);
if (!npc) { if (!npc) {
c->Message(0, "Format: #spawn name race level material hp gender class priweapon secweapon merchantid bodytype - spawns a npc those parameters."); c->Message(0, "Format: #spawn name race level material hp gender class priweapon secweapon merchantid bodytype - spawns a npc those parameters.");
c->Message(0, "Name Format: NPCFirstname_NPCLastname - All numbers in a name are stripped and \"_\" characters become a space."); c->Message(0, "Name Format: NPCFirstname_NPCLastname - All numbers in a name are stripped and \"_\" characters become a space.");

View File

@ -773,7 +773,7 @@ bool NPC::DatabaseCastAccepted(int spell_id) {
return false; return false;
} }
NPC* NPC::SpawnNPC(const char* spawncommand, float in_x, float in_y, float in_z, float in_heading, Client* client) { NPC* NPC::SpawnNPC(const char* spawncommand, const xyz_heading& position, Client* client) {
if(spawncommand == 0 || spawncommand[0] == 0) { if(spawncommand == 0 || spawncommand[0] == 0) {
return 0; return 0;
} }
@ -932,7 +932,7 @@ NPC* NPC::SpawnNPC(const char* spawncommand, float in_x, float in_y, float in_z,
npc_type->prim_melee_type = 28; npc_type->prim_melee_type = 28;
npc_type->sec_melee_type = 28; npc_type->sec_melee_type = 28;
NPC* npc = new NPC(npc_type, 0, in_x, in_y, in_z, in_heading/8, FlyMode3); NPC* npc = new NPC(npc_type, 0, position.m_X, position.m_Y, position.m_Z, position.m_Heading, FlyMode3);
npc->GiveNPCTypeData(npc_type); npc->GiveNPCTypeData(npc_type);
entity_list.AddNPC(npc); entity_list.AddNPC(npc);

View File

@ -94,7 +94,7 @@ class AA_SwarmPetInfo;
class NPC : public Mob class NPC : public Mob
{ {
public: public:
static NPC* SpawnNPC(const char* spawncommand, float in_x, float in_y, float in_z, float in_heading = 0, Client* client = 0); static NPC* SpawnNPC(const char* spawncommand, const xyz_heading& position, Client* client = 0);
static int8 GetAILevel(bool iForceReRead = false); static int8 GetAILevel(bool iForceReRead = false);
NPC(const NPCType* data, Spawn2* respawn, float x, float y, float z, float heading, int iflymode, bool IsCorpse = false); NPC(const NPCType* data, Spawn2* respawn, float x, float y, float z, float heading, int iflymode, bool IsCorpse = false);

View File

@ -1558,7 +1558,8 @@ void QuestManager::moveto(float x, float y, float z, float h, bool saveguardspot
if (!owner || !owner->IsNPC()) if (!owner || !owner->IsNPC())
return; return;
owner->CastToNPC()->MoveTo(x, y, z, h, saveguardspot); auto position = xyz_heading(x,y,z,h);
owner->CastToNPC()->MoveTo(position, saveguardspot);
} }
void QuestManager::resume() { void QuestManager::resume() {

View File

@ -161,7 +161,7 @@ void NPC::PauseWandering(int pausetime)
return; return;
} }
void NPC::MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot) void NPC::MoveTo(const xyz_heading& position, bool saveguardspot)
{ // makes mob walk to specified location { // makes mob walk to specified location
if (IsNPC() && GetGrid() != 0) if (IsNPC() && GetGrid() != 0)
{ // he is on a grid { // he is on a grid
@ -176,29 +176,29 @@ void NPC::MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot)
save_wp=cur_wp; // save the current waypoint save_wp=cur_wp; // save the current waypoint
cur_wp=-1; // flag this move as quest controlled cur_wp=-1; // flag this move as quest controlled
} }
mlog(AI__WAYPOINTS, "MoveTo (%.3f, %.3f, %.3f), pausing regular grid wandering. Grid %d, save_wp %d", mtx, mty, mtz, -GetGrid(), save_wp); mlog(AI__WAYPOINTS, "MoveTo %s, pausing regular grid wandering. Grid %d, save_wp %d",to_string(static_cast<xyz_location>(position)).c_str(), -GetGrid(), save_wp);
} }
else else
{ // not on a grid { // not on a grid
roamer=true; roamer=true;
save_wp=0; save_wp=0;
cur_wp=-2; // flag as quest controlled w/no grid cur_wp=-2; // flag as quest controlled w/no grid
mlog(AI__WAYPOINTS, "MoveTo (%.3f, %.3f, %.3f) without a grid.", mtx, mty, mtz); mlog(AI__WAYPOINTS, "MoveTo %s without a grid.", to_string(static_cast<xyz_location>(position)).c_str());
} }
if (saveguardspot) if (saveguardspot)
{ {
m_GuardPoint = xyz_heading(mtx, mty, mtz, mth); m_GuardPoint = position;
if(m_GuardPoint.m_Heading == 0) if(m_GuardPoint.m_Heading == 0)
m_GuardPoint.m_Heading = 0.0001; //hack to make IsGuarding simpler m_GuardPoint.m_Heading = 0.0001; //hack to make IsGuarding simpler
if(m_GuardPoint.m_Heading == -1) if(m_GuardPoint.m_Heading == -1)
m_GuardPoint.m_Heading = this->CalculateHeadingToTarget(mtx, mty); m_GuardPoint.m_Heading = this->CalculateHeadingToTarget(position.m_X, position.m_Y);
mlog(AI__WAYPOINTS, "Setting guard position to %s", to_string(static_cast<xyz_location>(m_GuardPoint)).c_str()); mlog(AI__WAYPOINTS, "Setting guard position to %s", to_string(static_cast<xyz_location>(m_GuardPoint)).c_str());
} }
m_CurrentWayPoint = xyz_heading(mtx, mty, mtz, mth); m_CurrentWayPoint = position;
cur_wp_pause = 0; cur_wp_pause = 0;
pLastFightingDelayMoving = 0; pLastFightingDelayMoving = 0;
if(AIwalking_timer->Enabled()) if(AIwalking_timer->Enabled())