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

@ -963,7 +963,7 @@ uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) {
spells[curspell].skill != 52 && spells[curspell].skill != 52 &&
( !RuleB(Spells, UseCHAScribeHack) || spells[curspell].effectid[EFFECT_COUNT - 1] != 10 ) ( !RuleB(Spells, UseCHAScribeHack) || spells[curspell].effectid[EFFECT_COUNT - 1] != 10 )
) )
{ {
if(IsDiscipline(curspell)){ if(IsDiscipline(curspell)){
//we may want to come up with a function like Client::GetNextAvailableSpellBookSlot() to help speed this up a little //we may want to come up with a function like Client::GetNextAvailableSpellBookSlot() to help speed this up a little
for(uint32 r = 0; r < MAX_PP_DISCIPLINES; r++) { for(uint32 r = 0; r < MAX_PP_DISCIPLINES; r++) {
@ -977,12 +977,12 @@ uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) {
SpellGlobalCheckResult = initiator->SpellGlobalCheck(curspell, Char_ID); SpellGlobalCheckResult = initiator->SpellGlobalCheck(curspell, Char_ID);
if (SpellGlobalCheckResult) { if (SpellGlobalCheckResult) {
initiator->GetPP().disciplines.values[r] = curspell; initiator->GetPP().disciplines.values[r] = curspell;
database.SaveCharacterDisc(Char_ID, r, curspell); database.SaveCharacterDisc(Char_ID, r, curspell);
initiator->SendDisciplineUpdate(); initiator->SendDisciplineUpdate();
initiator->Message(0, "You have learned a new discipline!"); initiator->Message(0, "You have learned a new discipline!");
count++; //success counter count++; //success counter
} }
break; //continue the 1st loop break; //continue the 1st loop
} }
else { else {
initiator->GetPP().disciplines.values[r] = curspell; initiator->GetPP().disciplines.values[r] = curspell;
@ -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() {
@ -2926,7 +2927,7 @@ void QuestManager::CrossZoneSignalPlayerByName(const char *CharName, uint32 data
CZSC->data = data; CZSC->data = data;
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);
} }
void QuestManager::CrossZoneMessagePlayerByName(uint32 Type, const char *CharName, const char *Message){ void QuestManager::CrossZoneMessagePlayerByName(uint32 Type, const char *CharName, const char *Message){
uint32 message_len = strlen(CharName) + 1; uint32 message_len = strlen(CharName) + 1;
@ -2936,7 +2937,7 @@ void QuestManager::CrossZoneMessagePlayerByName(uint32 Type, const char *CharNam
CZSC->Type = Type; CZSC->Type = Type;
strn0cpy(CZSC->CharName, CharName, 64); strn0cpy(CZSC->CharName, CharName, 64);
strn0cpy(CZSC->Message, Message, 512); strn0cpy(CZSC->Message, Message, 512);
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);
} }
@ -2946,7 +2947,7 @@ void QuestManager::CrossZoneSetEntityVariableByNPCTypeID(uint32 npctype_id, cons
ServerPacket* pack = new ServerPacket(ServerOP_CZSetEntityVariableByNPCTypeID, sizeof(CZSetEntVarByNPCTypeID_Struct) + message_len + message_len2); ServerPacket* pack = new ServerPacket(ServerOP_CZSetEntityVariableByNPCTypeID, sizeof(CZSetEntVarByNPCTypeID_Struct) + message_len + message_len2);
CZSetEntVarByNPCTypeID_Struct* CZSNBYNID = (CZSetEntVarByNPCTypeID_Struct*)pack->pBuffer; CZSetEntVarByNPCTypeID_Struct* CZSNBYNID = (CZSetEntVarByNPCTypeID_Struct*)pack->pBuffer;
CZSNBYNID->npctype_id = npctype_id; CZSNBYNID->npctype_id = npctype_id;
strn0cpy(CZSNBYNID->id, id, 256); strn0cpy(CZSNBYNID->id, id, 256);
strn0cpy(CZSNBYNID->m_var, m_var, 256); strn0cpy(CZSNBYNID->m_var, m_var, 256);
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);

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())