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:");
#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) {
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.");

View File

@ -773,7 +773,7 @@ bool NPC::DatabaseCastAccepted(int spell_id) {
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) {
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->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);
entity_list.AddNPC(npc);

View File

@ -94,7 +94,7 @@ class AA_SwarmPetInfo;
class NPC : public Mob
{
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);
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 &&
( !RuleB(Spells, UseCHAScribeHack) || spells[curspell].effectid[EFFECT_COUNT - 1] != 10 )
)
{
{
if(IsDiscipline(curspell)){
//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++) {
@ -977,12 +977,12 @@ uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) {
SpellGlobalCheckResult = initiator->SpellGlobalCheck(curspell, Char_ID);
if (SpellGlobalCheckResult) {
initiator->GetPP().disciplines.values[r] = curspell;
database.SaveCharacterDisc(Char_ID, r, curspell);
database.SaveCharacterDisc(Char_ID, r, curspell);
initiator->SendDisciplineUpdate();
initiator->Message(0, "You have learned a new discipline!");
count++; //success counter
}
break; //continue the 1st loop
break; //continue the 1st loop
}
else {
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())
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() {
@ -2926,7 +2927,7 @@ void QuestManager::CrossZoneSignalPlayerByName(const char *CharName, uint32 data
CZSC->data = data;
worldserver.SendPacket(pack);
safe_delete(pack);
}
}
void QuestManager::CrossZoneMessagePlayerByName(uint32 Type, const char *CharName, const char *Message){
uint32 message_len = strlen(CharName) + 1;
@ -2936,7 +2937,7 @@ void QuestManager::CrossZoneMessagePlayerByName(uint32 Type, const char *CharNam
CZSC->Type = Type;
strn0cpy(CZSC->CharName, CharName, 64);
strn0cpy(CZSC->Message, Message, 512);
worldserver.SendPacket(pack);
worldserver.SendPacket(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);
CZSetEntVarByNPCTypeID_Struct* CZSNBYNID = (CZSetEntVarByNPCTypeID_Struct*)pack->pBuffer;
CZSNBYNID->npctype_id = npctype_id;
strn0cpy(CZSNBYNID->id, id, 256);
strn0cpy(CZSNBYNID->id, id, 256);
strn0cpy(CZSNBYNID->m_var, m_var, 256);
worldserver.SendPacket(pack);
safe_delete(pack);

View File

@ -161,7 +161,7 @@ void NPC::PauseWandering(int pausetime)
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
if (IsNPC() && GetGrid() != 0)
{ // 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
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
{ // not on a grid
roamer=true;
save_wp=0;
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)
{
m_GuardPoint = xyz_heading(mtx, mty, mtz, mth);
m_GuardPoint = position;
if(m_GuardPoint.m_Heading == 0)
m_GuardPoint.m_Heading = 0.0001; //hack to make IsGuarding simpler
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());
}
m_CurrentWayPoint = xyz_heading(mtx, mty, mtz, mth);
m_CurrentWayPoint = position;
cur_wp_pause = 0;
pLastFightingDelayMoving = 0;
if(AIwalking_timer->Enabled())