heading, x_pos, y_pos, and z_pos replaced with m_Position in Mob

This commit is contained in:
Arthur Ice 2014-11-25 20:16:04 -08:00
parent 640aea24bc
commit 53602e3c61
13 changed files with 318 additions and 319 deletions

View File

@ -58,10 +58,10 @@ Beacon::Beacon(Mob *at_mob, int lifetime)
caster_id = 0; caster_id = 0;
// copy location // copy location
x_pos = at_mob->GetX(); m_Position.m_X = at_mob->GetX();
y_pos = at_mob->GetY(); m_Position.m_Y = at_mob->GetY();
z_pos = at_mob->GetZ(); m_Position.m_Z = at_mob->GetZ();
heading = at_mob->GetHeading(); m_Position.m_Heading = at_mob->GetHeading();
if(lifetime) if(lifetime)
{ {

View File

@ -4122,9 +4122,9 @@ void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) {
this->GetBotOwner()->CastToClient()->Message(13, "%s save failed!", this->GetCleanName()); this->GetBotOwner()->CastToClient()->Message(13, "%s save failed!", this->GetCleanName());
// Spawn the bot at the bow owner's loc // Spawn the bot at the bow owner's loc
this->x_pos = botCharacterOwner->GetX(); this->m_Position.m_X = botCharacterOwner->GetX();
this->y_pos = botCharacterOwner->GetY(); this->m_Position.m_Y = botCharacterOwner->GetY();
this->z_pos = botCharacterOwner->GetZ(); this->m_Position.m_Z = botCharacterOwner->GetZ();
// Make the bot look at the bot owner // Make the bot look at the bot owner
FaceTarget(botCharacterOwner); FaceTarget(botCharacterOwner);

View File

@ -399,9 +399,9 @@ Client::~Client() {
{ {
m_pp.zone_id = m_pp.binds[0].zoneId; m_pp.zone_id = m_pp.binds[0].zoneId;
m_pp.zoneInstance = m_pp.binds[0].instance_id; m_pp.zoneInstance = m_pp.binds[0].instance_id;
x_pos = m_pp.binds[0].x; m_Position.m_X = m_pp.binds[0].x;
y_pos = m_pp.binds[0].y; m_Position.m_Y = m_pp.binds[0].y;
z_pos = m_pp.binds[0].z; m_Position.m_Z = m_pp.binds[0].z;
} }
// we save right now, because the client might be zoning and the world // we save right now, because the client might be zoning and the world
@ -525,11 +525,11 @@ bool Client::Save(uint8 iCommitNow) {
return false; return false;
/* Wrote current basics to PP for saves */ /* Wrote current basics to PP for saves */
m_pp.x = x_pos; m_pp.x = m_Position.m_X;
m_pp.y = y_pos; m_pp.y = m_Position.m_Y;
m_pp.z = z_pos; m_pp.z = m_Position.m_Z;
m_pp.guildrank = guildrank; m_pp.guildrank = guildrank;
m_pp.heading = heading; m_pp.heading = m_Position.m_Heading;
/* Mana and HP */ /* Mana and HP */
if (GetHP() <= 0) { if (GetHP() <= 0) {

View File

@ -1472,10 +1472,10 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
/* Set Mob variables for spawn */ /* Set Mob variables for spawn */
class_ = m_pp.class_; class_ = m_pp.class_;
level = m_pp.level; level = m_pp.level;
x_pos = m_pp.x; m_Position.m_X = m_pp.x;
y_pos = m_pp.y; m_Position.m_Y = m_pp.y;
z_pos = m_pp.z; m_Position.m_Z = m_pp.z;
heading = m_pp.heading; m_Position.m_Heading = m_pp.heading;
race = m_pp.race; race = m_pp.race;
base_race = m_pp.race; base_race = m_pp.race;
gender = m_pp.gender; gender = m_pp.gender;
@ -4380,9 +4380,9 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
float dist = 0; float dist = 0;
float tmp; float tmp;
tmp = x_pos - ppu->x_pos; tmp = m_Position.m_X - ppu->x_pos;
dist += tmp*tmp; dist += tmp*tmp;
tmp = y_pos - ppu->y_pos; tmp = m_Position.m_Y - ppu->y_pos;
dist += tmp*tmp; dist += tmp*tmp;
dist = sqrt(dist); dist = sqrt(dist);
@ -4534,9 +4534,9 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
//If the player has moved more than units for x or y, then we'll store //If the player has moved more than units for x or y, then we'll store
//his pre-PPU x and y for /rewind, in case he gets stuck. //his pre-PPU x and y for /rewind, in case he gets stuck.
if ((rewind_x_diff > 750) || (rewind_y_diff > 750)) { if ((rewind_x_diff > 750) || (rewind_y_diff > 750)) {
rewind_x = x_pos; rewind_x = m_Position.m_X;
rewind_y = y_pos; rewind_y = m_Position.m_Y;
rewind_z = z_pos; rewind_z = m_Position.m_Z;
} }
//If the PPU was a large jump, such as a cross zone gate or Call of Hero, //If the PPU was a large jump, such as a cross zone gate or Call of Hero,
@ -4563,13 +4563,13 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
delta_z = ppu->delta_z; delta_z = ppu->delta_z;
delta_heading = ppu->delta_heading; delta_heading = ppu->delta_heading;
if(IsTracking() && ((x_pos!=ppu->x_pos) || (y_pos!=ppu->y_pos))){ if(IsTracking() && ((m_Position.m_X!=ppu->x_pos) || (m_Position.m_Y!=ppu->y_pos))){
if(MakeRandomFloat(0, 100) < 70)//should be good if(MakeRandomFloat(0, 100) < 70)//should be good
CheckIncreaseSkill(SkillTracking, nullptr, -20); CheckIncreaseSkill(SkillTracking, nullptr, -20);
} }
// Break Hide if moving without sneaking and set rewind timer if moved // Break Hide if moving without sneaking and set rewind timer if moved
if(ppu->y_pos != y_pos || ppu->x_pos != x_pos){ if(ppu->y_pos != m_Position.m_Y || ppu->x_pos != m_Position.m_X){
if((hidden || improved_hidden) && !sneaking){ if((hidden || improved_hidden) && !sneaking){
hidden = false; hidden = false;
improved_hidden = false; improved_hidden = false;
@ -4589,13 +4589,14 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
// Outgoing client packet // Outgoing client packet
float tmpheading = EQ19toFloat(ppu->heading); float tmpheading = EQ19toFloat(ppu->heading);
if (!FCMP(ppu->y_pos, y_pos) || !FCMP(ppu->x_pos, x_pos) || !FCMP(tmpheading, heading) || ppu->animation != animation) if (!FCMP(ppu->y_pos, m_Position.m_Y) || !FCMP(ppu->x_pos, m_Position.m_X) || !FCMP(tmpheading, m_Position.m_Heading) || ppu->animation != animation)
{ {
x_pos = ppu->x_pos; m_Position.m_X = ppu->x_pos;
y_pos = ppu->y_pos; m_Position.m_Y = ppu->y_pos;
z_pos = ppu->z_pos; m_Position.m_Z = ppu->z_pos;
animation = ppu->animation; m_Position.m_Heading = tmpheading;
heading = tmpheading; animation = ppu->animation;
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); EQApplicationPacket* outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
PlayerPositionUpdateServer_Struct* ppu = (PlayerPositionUpdateServer_Struct*)outapp->pBuffer; PlayerPositionUpdateServer_Struct* ppu = (PlayerPositionUpdateServer_Struct*)outapp->pBuffer;
@ -4609,7 +4610,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
if(zone->watermap) if(zone->watermap)
{ {
if(zone->watermap->InLiquid(x_pos, y_pos, z_pos)) if(zone->watermap->InLiquid(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))
{ {
CheckIncreaseSkill(SkillSwimming, nullptr, -17); CheckIncreaseSkill(SkillSwimming, nullptr, -17);
} }

View File

@ -2144,9 +2144,9 @@ void Client::HandleRespawnFromHover(uint32 Option)
if (corpse) if (corpse)
{ {
x_pos = corpse->GetX(); m_Position.m_X = corpse->GetX();
y_pos = corpse->GetY(); m_Position.m_Y = corpse->GetY();
z_pos = corpse->GetZ(); m_Position.m_Z = corpse->GetZ();
} }
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ZonePlayerToBind, sizeof(ZonePlayerToBind_Struct) + 10); EQApplicationPacket* outapp = new EQApplicationPacket(OP_ZonePlayerToBind, sizeof(ZonePlayerToBind_Struct) + 10);
@ -2199,10 +2199,10 @@ void Client::HandleRespawnFromHover(uint32 Option)
SetMana(GetMaxMana()); SetMana(GetMaxMana());
SetEndurance(GetMaxEndurance()); SetEndurance(GetMaxEndurance());
x_pos = chosen->x; m_Position.m_X = chosen->x;
y_pos = chosen->y; m_Position.m_Y = chosen->y;
z_pos = chosen->z; m_Position.m_Z = chosen->z;
heading = chosen->heading; m_Position.m_Heading = chosen->heading;
ClearHover(); ClearHover();
entity_list.RefreshClientXTargets(this); entity_list.RefreshClientXTargets(this);

View File

@ -597,11 +597,11 @@ bool Corpse::Save() {
/* Create New Corpse*/ /* Create New Corpse*/
if (corpse_db_id == 0) { if (corpse_db_id == 0) {
corpse_db_id = database.SaveCharacterCorpse(char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, x_pos, y_pos, z_pos, heading); corpse_db_id = database.SaveCharacterCorpse(char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_Position.m_Heading);
} }
/* Update Corpse Data */ /* Update Corpse Data */
else{ else{
corpse_db_id = database.UpdateCharacterCorpse(corpse_db_id, char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, x_pos, y_pos, z_pos, heading, IsRezzed()); corpse_db_id = database.UpdateCharacterCorpse(corpse_db_id, char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_Position.m_Heading, IsRezzed());
} }
safe_delete_array(dbpc); safe_delete_array(dbpc);

View File

@ -225,15 +225,15 @@ bool Client::CanFish() {
HeadingDegrees = (int) ((GetHeading()*360)/256); HeadingDegrees = (int) ((GetHeading()*360)/256);
HeadingDegrees = HeadingDegrees % 360; HeadingDegrees = HeadingDegrees % 360;
RodX = x_pos + RodLength * sin(HeadingDegrees * M_PI/180.0f); RodX = m_Position.m_X + RodLength * sin(HeadingDegrees * M_PI/180.0f);
RodY = y_pos + RodLength * cos(HeadingDegrees * M_PI/180.0f); RodY = m_Position.m_Y + RodLength * cos(HeadingDegrees * M_PI/180.0f);
// Do BestZ to find where the line hanging from the rod intersects the water (if it is water). // Do BestZ to find where the line hanging from the rod intersects the water (if it is water).
// and go 1 unit into the water. // and go 1 unit into the water.
Map::Vertex dest; Map::Vertex dest;
dest.x = RodX; dest.x = RodX;
dest.y = RodY; dest.y = RodY;
dest.z = z_pos+10; dest.z = m_Position.m_Z+10;
RodZ = zone->zonemap->FindBestZ(dest, nullptr) + 4; RodZ = zone->zonemap->FindBestZ(dest, nullptr) + 4;
bool in_lava = zone->watermap->InLava(RodX, RodY, RodZ); bool in_lava = zone->watermap->InLava(RodX, RodY, RodZ);
@ -243,7 +243,7 @@ bool Client::CanFish() {
Message_StringID(MT_Skills, FISHING_LAVA); //Trying to catch a fire elemental or something? Message_StringID(MT_Skills, FISHING_LAVA); //Trying to catch a fire elemental or something?
return false; return false;
} }
if((!in_water) || (z_pos-RodZ)>LineLength) { //Didn't hit the water OR the water is too far below us if((!in_water) || (m_Position.m_Z-RodZ)>LineLength) { //Didn't hit the water OR the water is too far below us
Message_StringID(MT_Skills, FISHING_LAND); //Trying to catch land sharks perhaps? Message_StringID(MT_Skills, FISHING_LAND); //Trying to catch land sharks perhaps?
return false; return false;
} }

View File

@ -157,10 +157,10 @@ Mob::Mob(const char* in_name,
if (runspeed < 0 || runspeed > 20) if (runspeed < 0 || runspeed > 20)
runspeed = 1.25f; runspeed = 1.25f;
heading = in_heading; m_Position.m_Heading = in_heading;
x_pos = in_x_pos; m_Position.m_X = in_x_pos;
y_pos = in_y_pos; m_Position.m_Y = in_y_pos;
z_pos = in_z_pos; m_Position.m_Z = in_z_pos;
light = in_light; light = in_light;
texture = in_texture; texture = in_texture;
helmtexture = in_helmtexture; helmtexture = in_helmtexture;
@ -882,10 +882,10 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
strn0cpy(ns->spawn.lastName, lastname, sizeof(ns->spawn.lastName)); strn0cpy(ns->spawn.lastName, lastname, sizeof(ns->spawn.lastName));
} }
ns->spawn.heading = FloatToEQ19(heading); ns->spawn.heading = FloatToEQ19(m_Position.m_Heading);
ns->spawn.x = FloatToEQ19(x_pos);//((int32)x_pos)<<3; ns->spawn.x = FloatToEQ19(m_Position.m_X);//((int32)x_pos)<<3;
ns->spawn.y = FloatToEQ19(y_pos);//((int32)y_pos)<<3; ns->spawn.y = FloatToEQ19(m_Position.m_Y);//((int32)y_pos)<<3;
ns->spawn.z = FloatToEQ19(z_pos);//((int32)z_pos)<<3; ns->spawn.z = FloatToEQ19(m_Position.m_Z);//((int32)z_pos)<<3;
ns->spawn.spawnId = GetID(); ns->spawn.spawnId = GetID();
ns->spawn.curHp = static_cast<uint8>(GetHPRatio()); ns->spawn.curHp = static_cast<uint8>(GetHPRatio());
ns->spawn.max_hp = 100; //this field needs a better name ns->spawn.max_hp = 100; //this field needs a better name
@ -1211,13 +1211,13 @@ void Mob::SendPosUpdate(uint8 iSendToSelf) {
void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){ void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){
memset(spu,0xff,sizeof(PlayerPositionUpdateServer_Struct)); memset(spu,0xff,sizeof(PlayerPositionUpdateServer_Struct));
spu->spawn_id = GetID(); spu->spawn_id = GetID();
spu->x_pos = FloatToEQ19(x_pos); spu->x_pos = FloatToEQ19(m_Position.m_X);
spu->y_pos = FloatToEQ19(y_pos); spu->y_pos = FloatToEQ19(m_Position.m_Y);
spu->z_pos = FloatToEQ19(z_pos); spu->z_pos = FloatToEQ19(m_Position.m_Z);
spu->delta_x = NewFloatToEQ13(0); spu->delta_x = NewFloatToEQ13(0);
spu->delta_y = NewFloatToEQ13(0); spu->delta_y = NewFloatToEQ13(0);
spu->delta_z = NewFloatToEQ13(0); spu->delta_z = NewFloatToEQ13(0);
spu->heading = FloatToEQ19(heading); spu->heading = FloatToEQ19(m_Position.m_Heading);
spu->animation = 0; spu->animation = 0;
spu->delta_heading = NewFloatToEQ13(0); spu->delta_heading = NewFloatToEQ13(0);
spu->padding0002 =0; spu->padding0002 =0;
@ -1230,13 +1230,13 @@ void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){
// this is for SendPosUpdate() // this is for SendPosUpdate()
void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) { void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) {
spu->spawn_id = GetID(); spu->spawn_id = GetID();
spu->x_pos = FloatToEQ19(x_pos); spu->x_pos = FloatToEQ19(m_Position.m_X);
spu->y_pos = FloatToEQ19(y_pos); spu->y_pos = FloatToEQ19(m_Position.m_Y);
spu->z_pos = FloatToEQ19(z_pos); spu->z_pos = FloatToEQ19(m_Position.m_Z);
spu->delta_x = NewFloatToEQ13(delta_x); spu->delta_x = NewFloatToEQ13(delta_x);
spu->delta_y = NewFloatToEQ13(delta_y); spu->delta_y = NewFloatToEQ13(delta_y);
spu->delta_z = NewFloatToEQ13(delta_z); spu->delta_z = NewFloatToEQ13(delta_z);
spu->heading = FloatToEQ19(heading); spu->heading = FloatToEQ19(m_Position.m_Heading);
spu->padding0002 =0; spu->padding0002 =0;
spu->padding0006 =7; spu->padding0006 =7;
spu->padding0014 =0x7f; spu->padding0014 =0x7f;
@ -1361,11 +1361,11 @@ void Mob::GMMove(float x, float y, float z, float heading, bool SendUpdate) {
entity_list.ProcessMove(CastToNPC(), x, y, z); entity_list.ProcessMove(CastToNPC(), x, y, z);
} }
x_pos = x; m_Position.m_X = x;
y_pos = y; m_Position.m_Y = y;
z_pos = z; m_Position.m_Z = z;
if (heading != 0.01) if (m_Position.m_Heading != 0.01)
this->heading = heading; this->m_Position.m_Heading = heading;
if(IsNPC()) if(IsNPC())
CastToNPC()->SaveGuardSpot(true); CastToNPC()->SaveGuardSpot(true);
if(SendUpdate) if(SendUpdate)
@ -2062,9 +2062,9 @@ bool Mob::CanThisClassBlock(void) const
} }
float Mob::Dist(const Mob &other) const { float Mob::Dist(const Mob &other) const {
float xDiff = other.x_pos - x_pos; float xDiff = other.m_Position.m_X - m_Position.m_X;
float yDiff = other.y_pos - y_pos; float yDiff = other.m_Position.m_Y - m_Position.m_Y;
float zDiff = other.z_pos - z_pos; float zDiff = other.m_Position.m_Z - m_Position.m_Z;
return sqrtf( (xDiff * xDiff) return sqrtf( (xDiff * xDiff)
+ (yDiff * yDiff) + (yDiff * yDiff)
@ -2072,17 +2072,17 @@ float Mob::Dist(const Mob &other) const {
} }
float Mob::DistNoZ(const Mob &other) const { float Mob::DistNoZ(const Mob &other) const {
float xDiff = other.x_pos - x_pos; float xDiff = other.m_Position.m_X - m_Position.m_X;
float yDiff = other.y_pos - y_pos; float yDiff = other.m_Position.m_Y - m_Position.m_Y;
return sqrtf( (xDiff * xDiff) return sqrtf( (xDiff * xDiff)
+ (yDiff * yDiff) ); + (yDiff * yDiff) );
} }
float Mob::DistNoRoot(const Mob &other) const { float Mob::DistNoRoot(const Mob &other) const {
float xDiff = other.x_pos - x_pos; float xDiff = other.m_Position.m_X - m_Position.m_X;
float yDiff = other.y_pos - y_pos; float yDiff = other.m_Position.m_Y - m_Position.m_Y;
float zDiff = other.z_pos - z_pos; float zDiff = other.m_Position.m_Z - m_Position.m_Z;
return ( (xDiff * xDiff) return ( (xDiff * xDiff)
+ (yDiff * yDiff) + (yDiff * yDiff)
@ -2090,9 +2090,9 @@ float Mob::DistNoRoot(const Mob &other) const {
} }
float Mob::DistNoRoot(float x, float y, float z) const { float Mob::DistNoRoot(float x, float y, float z) const {
float xDiff = x - x_pos; float xDiff = x - m_Position.m_X;
float yDiff = y - y_pos; float yDiff = y - m_Position.m_Y;
float zDiff = z - z_pos; float zDiff = z - m_Position.m_Z;
return ( (xDiff * xDiff) return ( (xDiff * xDiff)
+ (yDiff * yDiff) + (yDiff * yDiff)
@ -2100,15 +2100,15 @@ float Mob::DistNoRoot(float x, float y, float z) const {
} }
float Mob::DistNoRootNoZ(float x, float y) const { float Mob::DistNoRootNoZ(float x, float y) const {
float xDiff = x - x_pos; float xDiff = x - m_Position.m_X;
float yDiff = y - y_pos; float yDiff = y - m_Position.m_Y;
return ( (xDiff * xDiff) + (yDiff * yDiff) ); return ( (xDiff * xDiff) + (yDiff * yDiff) );
} }
float Mob::DistNoRootNoZ(const Mob &other) const { float Mob::DistNoRootNoZ(const Mob &other) const {
float xDiff = other.x_pos - x_pos; float xDiff = other.m_Position.m_X - m_Position.m_X;
float yDiff = other.y_pos - y_pos; float yDiff = other.m_Position.m_Y - m_Position.m_Y;
return ( (xDiff * xDiff) + (yDiff * yDiff) ); return ( (xDiff * xDiff) + (yDiff * yDiff) );
} }
@ -2253,7 +2253,7 @@ bool Mob::HateSummon() {
entity_list.MessageClose(this, true, 500, MT_Say, "%s says,'You will not evade me, %s!' ", GetCleanName(), target->GetCleanName() ); entity_list.MessageClose(this, true, 500, MT_Say, "%s says,'You will not evade me, %s!' ", GetCleanName(), target->GetCleanName() );
if (target->IsClient()) { if (target->IsClient()) {
target->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), x_pos, y_pos, z_pos, target->GetHeading(), 0, SummonPC); target->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, target->GetHeading(), 0, SummonPC);
} }
else { else {
#ifdef BOTS #ifdef BOTS
@ -2266,7 +2266,7 @@ bool Mob::HateSummon() {
} }
#endif //BOTS #endif //BOTS
target->GMMove(x_pos, y_pos, z_pos, target->GetHeading()); target->GMMove(m_Position.m_X, m_Position.m_Y, m_Position.m_Z, target->GetHeading());
} }
return true; return true;
@ -2614,9 +2614,9 @@ void Mob::Warp( float x, float y, float z )
entity_list.ProcessMove(CastToNPC(), x, y, z); entity_list.ProcessMove(CastToNPC(), x, y, z);
} }
x_pos = x; m_Position.m_X = x;
y_pos = y; m_Position.m_Y = y;
z_pos = z; m_Position.m_Z = z;
Mob* target = GetTarget(); Mob* target = GetTarget();
if (target) { if (target) {
@ -2829,9 +2829,9 @@ float Mob::FindGroundZ(float new_x, float new_y, float z_offset)
if (zone->zonemap != nullptr) if (zone->zonemap != nullptr)
{ {
Map::Vertex me; Map::Vertex me;
me.x = new_x; me.x = m_Position.m_X;
me.y = new_y; me.y = m_Position.m_Y;
me.z = z_pos+z_offset; me.z = m_Position.m_Z + z_offset;
Map::Vertex hit; Map::Vertex hit;
float best_z = zone->zonemap->FindBestZ(me, &hit); float best_z = zone->zonemap->FindBestZ(me, &hit);
if (best_z != -999999) if (best_z != -999999)
@ -2849,9 +2849,9 @@ float Mob::GetGroundZ(float new_x, float new_y, float z_offset)
if (zone->zonemap != 0) if (zone->zonemap != 0)
{ {
Map::Vertex me; Map::Vertex me;
me.x = new_x; me.x = m_Position.m_X;
me.y = new_y; me.y = m_Position.m_Y;
me.z = z_pos+z_offset; me.z = m_Position.m_Z+z_offset;
Map::Vertex hit; Map::Vertex hit;
float best_z = zone->zonemap->FindBestZ(me, &hit); float best_z = zone->zonemap->FindBestZ(me, &hit);
if (best_z != -999999) if (best_z != -999999)

View File

@ -23,6 +23,7 @@
#include "entity.h" #include "entity.h"
#include "hate_list.h" #include "hate_list.h"
#include "pathing.h" #include "pathing.h"
#include "position.h"
#include <set> #include <set>
#include <vector> #include <vector>
#include <string> #include <string>
@ -392,10 +393,10 @@ public:
((static_cast<float>(cur_mana) / max_mana) * 100); } ((static_cast<float>(cur_mana) / max_mana) * 100); }
virtual int32 CalcMaxMana(); virtual int32 CalcMaxMana();
uint32 GetNPCTypeID() const { return npctype_id; } uint32 GetNPCTypeID() const { return npctype_id; }
inline const float GetX() const { return x_pos; } inline const float GetX() const { return m_Position.m_X; }
inline const float GetY() const { return y_pos; } inline const float GetY() const { return m_Position.m_Y; }
inline const float GetZ() const { return z_pos; } inline const float GetZ() const { return m_Position.m_Z; }
inline const float GetHeading() const { return heading; } inline const float GetHeading() const { return m_Position.m_Heading; }
inline const float GetSize() const { return size; } inline const float GetSize() const { return size; }
inline const float GetBaseSize() const { return base_size; } inline const float GetBaseSize() const { return base_size; }
inline const float GetTarX() const { return tarx; } inline const float GetTarX() const { return tarx; }
@ -437,8 +438,8 @@ public:
void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu); void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu);
void SendPosition(); void SendPosition();
void SetFlyMode(uint8 flymode); void SetFlyMode(uint8 flymode);
inline void Teleport(Map::Vertex NewPosition) { x_pos = NewPosition.x; y_pos = NewPosition.y; inline void Teleport(Map::Vertex NewPosition) { m_Position.m_X = NewPosition.x; m_Position.m_Y = NewPosition.y;
z_pos = NewPosition.z; }; m_Position.m_Z = NewPosition.z; };
//AI //AI
static uint32 GetLevelCon(uint8 mylevel, uint8 iOtherLevel); static uint32 GetLevelCon(uint8 mylevel, uint8 iOtherLevel);
@ -459,8 +460,8 @@ public:
bool IsEngaged() { return(!hate_list.IsEmpty()); } bool IsEngaged() { return(!hate_list.IsEmpty()); }
bool HateSummon(); bool HateSummon();
void FaceTarget(Mob* MobToFace = 0); void FaceTarget(Mob* MobToFace = 0);
void SetHeading(float iHeading) { if(heading != iHeading) { pLastChange = Timer::GetCurrentTime(); void SetHeading(float iHeading) { if(m_Position.m_Heading != iHeading) { pLastChange = Timer::GetCurrentTime();
heading = iHeading; } } m_Position.m_Heading = iHeading; } }
void WipeHateList(); void WipeHateList();
void AddFeignMemory(Client* attacker); void AddFeignMemory(Client* attacker);
void RemoveFromFeignMemory(Client* attacker); void RemoveFromFeignMemory(Client* attacker);
@ -806,7 +807,7 @@ public:
void SetDontCureMeBefore(uint32 time) { pDontCureMeBefore = time; } void SetDontCureMeBefore(uint32 time) { pDontCureMeBefore = time; }
// calculate interruption of spell via movement of mob // calculate interruption of spell via movement of mob
void SaveSpellLoc() {spell_x = x_pos; spell_y = y_pos; spell_z = z_pos; } void SaveSpellLoc() {spell_x = m_Position.m_X; spell_y = m_Position.m_Y; spell_z = m_Position.m_Z; }
inline float GetSpellX() const {return spell_x;} inline float GetSpellX() const {return spell_x;}
inline float GetSpellY() const {return spell_y;} inline float GetSpellY() const {return spell_y;}
inline float GetSpellZ() const {return spell_z;} inline float GetSpellZ() const {return spell_z;}
@ -998,10 +999,7 @@ protected:
uint8 level; uint8 level;
uint8 orig_level; uint8 orig_level;
uint32 npctype_id; uint32 npctype_id;
float x_pos; xyz_heading m_Position;
float y_pos;
float z_pos;
float heading;
uint16 animation; uint16 animation;
float base_size; float base_size;
float size; float size;

View File

@ -1792,7 +1792,7 @@ void NPC::AI_DoMovement() {
CP2Moved = CalculateNewPosition2(guard_x, guard_y, guard_z, walksp); CP2Moved = CalculateNewPosition2(guard_x, guard_y, guard_z, walksp);
else else
{ {
if(!((x_pos == guard_x) && (y_pos == guard_y) && (z_pos == guard_z))) if(!((m_Position.m_X == guard_x) && (m_Position.m_Y == guard_y) && (m_Position.m_Z == guard_z)))
{ {
bool WaypointChanged, NodeReached; bool WaypointChanged, NodeReached;
Map::Vertex Goal = UpdatePath(guard_x, guard_y, guard_z, walksp, WaypointChanged, NodeReached); Map::Vertex Goal = UpdatePath(guard_x, guard_y, guard_z, walksp, WaypointChanged, NodeReached);

View File

@ -3831,9 +3831,9 @@ void Corpse::CastRezz(uint16 spellid, Mob* Caster)
rezz->zone_id = zone->GetZoneID(); rezz->zone_id = zone->GetZoneID();
rezz->instance_id = zone->GetInstanceID(); rezz->instance_id = zone->GetInstanceID();
rezz->spellid = spellid; rezz->spellid = spellid;
rezz->x = this->x_pos; rezz->x = this->m_Position.m_X;
rezz->y = this->y_pos; rezz->y = this->m_Position.m_Y;
rezz->z = this->z_pos; rezz->z = this->m_Position.m_Z;
rezz->unknown000 = 0x00000000; rezz->unknown000 = 0x00000000;
rezz->unknown020 = 0x00000000; rezz->unknown020 = 0x00000000;
rezz->unknown088 = 0x00000000; rezz->unknown088 = 0x00000000;

View File

@ -437,10 +437,10 @@ void NPC::SaveGuardSpot(bool iClearGuardSpot) {
guard_heading = 0; guard_heading = 0;
} }
else { else {
guard_x = x_pos; guard_x = m_Position.m_X;
guard_y = y_pos; guard_y = m_Position.m_Y;
guard_z = z_pos; guard_z = m_Position.m_Z;
guard_heading = heading; guard_heading = m_Position.m_Heading;
if(guard_heading == 0) if(guard_heading == 0)
guard_heading = 0.0001; //hack to make IsGuarding simpler guard_heading = 0.0001; //hack to make IsGuarding simpler
mlog(AI__WAYPOINTS, "Setting guard position to (%.3f, %.3f, %.3f)", guard_x, guard_y, guard_z); mlog(AI__WAYPOINTS, "Setting guard position to (%.3f, %.3f, %.3f)", guard_x, guard_y, guard_z);
@ -452,7 +452,7 @@ void NPC::NextGuardPosition() {
SetHeading(guard_heading); SetHeading(guard_heading);
mlog(AI__WAYPOINTS, "Unable to move to next guard position. Probably rooted."); mlog(AI__WAYPOINTS, "Unable to move to next guard position. Probably rooted.");
} }
else if((x_pos == guard_x) && (y_pos == guard_y) && (z_pos == guard_z)) else if((m_Position.m_X == guard_x) && (m_Position.m_Y == guard_y) && (m_Position.m_Z == guard_z))
{ {
if(moved) if(moved)
{ {
@ -480,7 +480,7 @@ void Mob::SaveSpawnSpot() {
}*/ }*/
float Mob::CalculateDistance(float x, float y, float z) { float Mob::CalculateDistance(float x, float y, float z) {
return (float)sqrtf( ((x_pos-x)*(x_pos-x)) + ((y_pos-y)*(y_pos-y)) + ((z_pos-z)*(z_pos-z)) ); return (float)sqrtf( ((m_Position.m_X-x)*(m_Position.m_X-x)) + ((m_Position.m_Y-y)*(m_Position.m_Y-y)) + ((m_Position.m_Z-z)*(m_Position.m_Z-z)) );
} }
/* /*
@ -491,13 +491,13 @@ uint8 NPC::CalculateHeadingToNextWaypoint() {
float Mob::CalculateHeadingToTarget(float in_x, float in_y) { float Mob::CalculateHeadingToTarget(float in_x, float in_y) {
float angle; float angle;
if (in_x-x_pos > 0) if (in_x-m_Position.m_X > 0)
angle = - 90 + atan((float)(in_y-y_pos) / (float)(in_x-x_pos)) * 180 / M_PI; angle = - 90 + atan((float)(in_y-m_Position.m_Y) / (float)(in_x-m_Position.m_X)) * 180 / M_PI;
else if (in_x-x_pos < 0) else if (in_x-m_Position.m_X < 0)
angle = + 90 + atan((float)(in_y-y_pos) / (float)(in_x-x_pos)) * 180 / M_PI; angle = + 90 + atan((float)(in_y-m_Position.m_Y) / (float)(in_x-m_Position.m_X)) * 180 / M_PI;
else // Added? else // Added?
{ {
if (in_y-y_pos > 0) if (in_y-m_Position.m_Y > 0)
angle = 0; angle = 0;
else else
angle = 180; angle = 180;
@ -513,16 +513,16 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
if(GetID()==0) if(GetID()==0)
return true; return true;
if ((x_pos-x == 0) && (y_pos-y == 0)) {//spawn is at target coords if ((m_Position.m_X-x == 0) && (m_Position.m_Y-y == 0)) {//spawn is at target coords
if(z_pos-z != 0) { if(m_Position.m_Z-z != 0) {
z_pos = z; m_Position.m_Z = z;
mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f): Jumping pure Z.", x, y, z); mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f): Jumping pure Z.", x, y, z);
return true; return true;
} }
mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f) inWater=%d: We are there.", x, y, z, inWater); mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f) inWater=%d: We are there.", x, y, z, inWater);
return false; return false;
} }
else if ((ABS(x_pos - x) < 0.1) && (ABS(y_pos - y) < 0.1)) else if ((ABS(m_Position.m_X - x) < 0.1) && (ABS(m_Position.m_Y - y) < 0.1))
{ {
mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f): X/Y difference <0.1, Jumping to target.", x, y, z); mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f): X/Y difference <0.1, Jumping to target.", x, y, z);
@ -530,25 +530,25 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
entity_list.ProcessMove(CastToNPC(), x, y, z); entity_list.ProcessMove(CastToNPC(), x, y, z);
} }
x_pos = x; m_Position.m_X = x;
y_pos = y; m_Position.m_Y = y;
z_pos = z; m_Position.m_Z = z;
return true; return true;
} }
int compare_steps = IsBoat() ? 1 : 20; int compare_steps = IsBoat() ? 1 : 20;
if(tar_ndx < compare_steps && tarx==x && tary==y) { if(tar_ndx < compare_steps && tarx==x && tary==y) {
float new_x = x_pos + tar_vx*tar_vector; float new_x = m_Position.m_X + tar_vx*tar_vector;
float new_y = y_pos + tar_vy*tar_vector; float new_y = m_Position.m_Y + tar_vy*tar_vector;
float new_z = z_pos + tar_vz*tar_vector; float new_z = m_Position.m_Z + tar_vz*tar_vector;
if(IsNPC()) { if(IsNPC()) {
entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z);
} }
x_pos = new_x; m_Position.m_X = new_x;
y_pos = new_y; m_Position.m_Y = new_y;
z_pos = new_z; m_Position.m_Z = new_z;
mlog(AI__WAYPOINTS, "Calculating new position2 to (%.3f, %.3f, %.3f), old vector (%.3f, %.3f, %.3f)", x, y, z, tar_vx, tar_vy, tar_vz); mlog(AI__WAYPOINTS, "Calculating new position2 to (%.3f, %.3f, %.3f), old vector (%.3f, %.3f, %.3f)", x, y, z, tar_vx, tar_vy, tar_vz);
@ -563,25 +563,25 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving))
{ {
if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() ||
(zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
{ {
Map::Vertex dest(x_pos, y_pos, z_pos); Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f;
mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z);
if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check.
{ {
if((ABS(x - x_pos) < 0.5) && (ABS(y - y_pos) < 0.5)) if((ABS(x - m_Position.m_X) < 0.5) && (ABS(y - m_Position.m_Y) < 0.5))
{ {
if(ABS(z-z_pos) <= RuleR(Map, FixPathingZMaxDeltaMoving)) if(ABS(z-m_Position.m_Z) <= RuleR(Map, FixPathingZMaxDeltaMoving))
z_pos = z; m_Position.m_Z = z;
else else
z_pos = newz + 1; m_Position.m_Z = newz + 1;
} }
else else
z_pos = newz + 1; m_Position.m_Z = newz + 1;
} }
} }
} }
@ -600,9 +600,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
tary=y; tary=y;
tarz=z; tarz=z;
float nx = this->x_pos; float nx = this->m_Position.m_X;
float ny = this->y_pos; float ny = this->m_Position.m_Y;
float nz = this->z_pos; float nz = this->m_Position.m_Z;
// float nh = this->heading; // float nh = this->heading;
tar_vx = x - nx; tar_vx = x - nx;
@ -635,19 +635,19 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
tar_vy = tar_vy/numsteps; tar_vy = tar_vy/numsteps;
tar_vz = tar_vz/numsteps; tar_vz = tar_vz/numsteps;
float new_x = x_pos + tar_vx; float new_x = m_Position.m_X + tar_vx;
float new_y = y_pos + tar_vy; float new_y = m_Position.m_Y + tar_vy;
float new_z = z_pos + tar_vz; float new_z = m_Position.m_Z + tar_vz;
if(IsNPC()) { if(IsNPC()) {
entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z);
} }
x_pos = new_x; m_Position.m_X = new_x;
y_pos = new_y; m_Position.m_Y = new_y;
z_pos = new_z; m_Position.m_Z = new_z;
m_Position.m_Heading = CalculateHeadingToTarget(x, y);
tar_ndx=22-numsteps; tar_ndx=22-numsteps;
heading = CalculateHeadingToTarget(x, y); mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", m_Position.m_X, m_Position.m_Y, m_Position.m_Z, numsteps);
mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", x_pos, y_pos, z_pos, numsteps);
} }
else else
{ {
@ -655,9 +655,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
entity_list.ProcessMove(CastToNPC(), x, y, z); entity_list.ProcessMove(CastToNPC(), x, y, z);
} }
x_pos = x; m_Position.m_X = x;
y_pos = y; m_Position.m_Y = y;
z_pos = z; m_Position.m_Z = z;
mlog(AI__WAYPOINTS, "Only a single step to get there... jumping."); mlog(AI__WAYPOINTS, "Only a single step to get there... jumping.");
@ -667,18 +667,18 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
else { else {
tar_vector/=20; tar_vector/=20;
float new_x = x_pos + tar_vx*tar_vector; float new_x = m_Position.m_X + tar_vx*tar_vector;
float new_y = y_pos + tar_vy*tar_vector; float new_y = m_Position.m_Y + tar_vy*tar_vector;
float new_z = z_pos + tar_vz*tar_vector; float new_z = m_Position.m_Z + tar_vz*tar_vector;
if(IsNPC()) { if(IsNPC()) {
entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z);
} }
x_pos = new_x; m_Position.m_X = new_x;
y_pos = new_y; m_Position.m_Y = new_y;
z_pos = new_z; m_Position.m_Z = new_z;
heading = CalculateHeadingToTarget(x, y); m_Position.m_Heading = CalculateHeadingToTarget(x, y);
mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", x_pos, y_pos, z_pos, numsteps); mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", m_Position.m_X, m_Position.m_Y, m_Position.m_Z, numsteps);
} }
uint8 NPCFlyMode = 0; uint8 NPCFlyMode = 0;
@ -692,25 +692,25 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) {
if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() ||
(zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
{ {
Map::Vertex dest(x_pos, y_pos, z_pos); Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
float newz = zone->zonemap->FindBestZ(dest, nullptr); + 2.0f; float newz = zone->zonemap->FindBestZ(dest, nullptr); + 2.0f;
mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z);
if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check.
{ {
if(ABS(x - x_pos) < 0.5 && ABS(y - y_pos) < 0.5) if(ABS(x - m_Position.m_X) < 0.5 && ABS(y - m_Position.m_Y) < 0.5)
{ {
if(ABS(z - z_pos) <= RuleR(Map, FixPathingZMaxDeltaMoving)) if(ABS(z - m_Position.m_Z) <= RuleR(Map, FixPathingZMaxDeltaMoving))
z_pos = z; m_Position.m_Z = z;
else else
z_pos = newz + 1; m_Position.m_Z = newz + 1;
} }
else else
z_pos = newz+1; m_Position.m_Z = newz+1;
} }
} }
} }
@ -718,9 +718,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
SetMoving(true); SetMoving(true);
moved=true; moved=true;
delta_x=x_pos-nx; delta_x=m_Position.m_X-nx;
delta_y=y_pos-ny; delta_y=m_Position.m_Y-ny;
delta_z=z_pos-nz; delta_z=m_Position.m_Z-nz;
delta_heading=0; delta_heading=0;
if (IsClient()) if (IsClient())
@ -746,9 +746,9 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec
if(GetID()==0) if(GetID()==0)
return true; return true;
float nx = x_pos; float nx = m_Position.m_X;
float ny = y_pos; float ny = m_Position.m_Y;
float nz = z_pos; float nz = m_Position.m_Z;
// if NPC is rooted // if NPC is rooted
if (speed == 0.0) { if (speed == 0.0) {
@ -780,30 +780,30 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
test_vector=sqrtf (x*x + y*y + z*z); test_vector=sqrtf (x*x + y*y + z*z);
tar_vector = speed / sqrtf (tar_vx*tar_vx + tar_vy*tar_vy + tar_vz*tar_vz); tar_vector = speed / sqrtf (tar_vx*tar_vx + tar_vy*tar_vy + tar_vz*tar_vz);
heading = CalculateHeadingToTarget(x, y); m_Position.m_Heading = CalculateHeadingToTarget(x, y);
if (tar_vector >= 1.0) { if (tar_vector >= 1.0) {
if(IsNPC()) { if(IsNPC()) {
entity_list.ProcessMove(CastToNPC(), x, y, z); entity_list.ProcessMove(CastToNPC(), x, y, z);
} }
x_pos = x; m_Position.m_X = x;
y_pos = y; m_Position.m_Y = y;
z_pos = z; m_Position.m_Z = z;
mlog(AI__WAYPOINTS, "Close enough, jumping to waypoint"); mlog(AI__WAYPOINTS, "Close enough, jumping to waypoint");
} }
else { else {
float new_x = x_pos + tar_vx*tar_vector; float new_x = m_Position.m_X + tar_vx*tar_vector;
float new_y = y_pos + tar_vy*tar_vector; float new_y = m_Position.m_Y + tar_vy*tar_vector;
float new_z = z_pos + tar_vz*tar_vector; float new_z = m_Position.m_Z + tar_vz*tar_vector;
if(IsNPC()) { if(IsNPC()) {
entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z);
} }
x_pos = new_x; m_Position.m_X = new_x;
y_pos = new_y; m_Position.m_Y = new_y;
z_pos = new_z; m_Position.m_Z = new_z;
mlog(AI__WAYPOINTS, "Next position (%.3f, %.3f, %.3f)", x_pos, y_pos, z_pos); mlog(AI__WAYPOINTS, "Next position (%.3f, %.3f, %.3f)", m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
} }
uint8 NPCFlyMode = 0; uint8 NPCFlyMode = 0;
@ -817,25 +817,25 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec
if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving))
{ {
if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() ||
(zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
{ {
Map::Vertex dest(x_pos, y_pos, z_pos); Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f;
mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z);
if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check.
{ {
if(ABS(x - x_pos) < 0.5 && ABS(y - y_pos) < 0.5) if(ABS(x - m_Position.m_X) < 0.5 && ABS(y - m_Position.m_Y) < 0.5)
{ {
if(ABS(z - z_pos) <= RuleR(Map, FixPathingZMaxDeltaMoving)) if(ABS(z - m_Position.m_Z) <= RuleR(Map, FixPathingZMaxDeltaMoving))
z_pos = z; m_Position.m_Z = z;
else else
z_pos = newz + 1; m_Position.m_Z = newz + 1;
} }
else else
z_pos = newz+1; m_Position.m_Z = newz+1;
} }
} }
} }
@ -845,9 +845,9 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec
tar_ndx=0; tar_ndx=0;
this->SetMoving(true); this->SetMoving(true);
moved=true; moved=true;
delta_x=(x_pos-nx); delta_x=(m_Position.m_X-nx);
delta_y=(y_pos-ny); delta_y=(m_Position.m_Y-ny);
delta_z=(z_pos-nz); delta_z=(m_Position.m_Z-nz);
delta_heading=0;//(heading-nh)*8; delta_heading=0;//(heading-nh)*8;
SendPosUpdate(); SendPosUpdate();
} }
@ -948,9 +948,9 @@ void Mob::SendTo(float new_x, float new_y, float new_z) {
entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z);
} }
x_pos = new_x; m_Position.m_X = new_x;
y_pos = new_y; m_Position.m_Y = new_y;
z_pos = new_z; m_Position.m_Z = new_z;
mlog(AI__WAYPOINTS, "Sent To (%.3f, %.3f, %.3f)", new_x, new_y, new_z); mlog(AI__WAYPOINTS, "Sent To (%.3f, %.3f, %.3f)", new_x, new_y, new_z);
if(flymode == FlyMode1) if(flymode == FlyMode1)
@ -961,20 +961,20 @@ void Mob::SendTo(float new_x, float new_y, float new_z) {
if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo) ) if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo) )
{ {
if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() ||
(zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
{ {
Map::Vertex dest(x_pos, y_pos, z_pos); Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
float newz = zone->zonemap->FindBestZ(dest, nullptr); float newz = zone->zonemap->FindBestZ(dest, nullptr);
mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z);
if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check. if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check.
z_pos = newz + 1; m_Position.m_Z = newz + 1;
} }
} }
else else
z_pos += 0.1; m_Position.m_Z += 0.1;
} }
void Mob::SendToFixZ(float new_x, float new_y, float new_z) { void Mob::SendToFixZ(float new_x, float new_y, float new_z) {
@ -982,9 +982,9 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) {
entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z + 0.1); entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z + 0.1);
} }
x_pos = new_x; m_Position.m_X = new_x;
y_pos = new_y; m_Position.m_Y = new_y;
z_pos = new_z + 0.1; m_Position.m_Z = new_z + 0.1;
//fix up pathing Z, this shouldent be needed IF our waypoints //fix up pathing Z, this shouldent be needed IF our waypoints
//are corrected instead //are corrected instead
@ -992,16 +992,16 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) {
if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo)) if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo))
{ {
if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() ||
(zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)))
{ {
Map::Vertex dest(x_pos, y_pos, z_pos); Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
float newz = zone->zonemap->FindBestZ(dest, nullptr); float newz = zone->zonemap->FindBestZ(dest, nullptr);
mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z);
if( (newz > -2000) && ABS(newz-dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check. if( (newz > -2000) && ABS(newz-dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check.
z_pos = newz + 1; m_Position.m_Z = newz + 1;
} }
} }
} }

View File

@ -347,10 +347,10 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc
//set the player's coordinates in the new zone so they have them //set the player's coordinates in the new zone so they have them
//when they zone into it //when they zone into it
x_pos = dest_x; //these coordinates will now be saved when ~client is called m_Position.m_X = dest_x; //these coordinates will now be saved when ~client is called
y_pos = dest_y; m_Position.m_Y = dest_y;
z_pos = dest_z; m_Position.m_Z = dest_z;
heading = dest_h; // Cripp: fix for zone heading m_Position.m_Heading = dest_h; // Cripp: fix for zone heading
m_pp.heading = dest_h; m_pp.heading = dest_h;
m_pp.zone_id = zone_id; m_pp.zone_id = zone_id;
m_pp.zoneInstance = instance_id; m_pp.zoneInstance = instance_id;
@ -500,9 +500,9 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
SetHeading(heading); SetHeading(heading);
break; break;
case GMSummon: case GMSummon:
zonesummon_x = x_pos = x; zonesummon_x = m_Position.m_X = x;
zonesummon_y = y_pos = y; zonesummon_y = m_Position.m_Y = y;
zonesummon_z = z_pos = z; zonesummon_z = m_Position.m_Z = z;
SetHeading(heading); SetHeading(heading);
zonesummon_id = zoneID; zonesummon_id = zoneID;
@ -518,31 +518,31 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
zonesummon_ignorerestrictions = ignorerestrictions; zonesummon_ignorerestrictions = ignorerestrictions;
break; break;
case GateToBindPoint: case GateToBindPoint:
x = x_pos = m_pp.binds[0].x; x = m_Position.m_X = m_pp.binds[0].x;
y = y_pos = m_pp.binds[0].y; y = m_Position.m_Y = m_pp.binds[0].y;
z = z_pos = m_pp.binds[0].z; z = m_Position.m_Z = m_pp.binds[0].z;
heading = m_pp.binds[0].heading; heading = m_pp.binds[0].heading;
break; break;
case ZoneToBindPoint: case ZoneToBindPoint:
x = x_pos = m_pp.binds[0].x; x = m_Position.m_X = m_pp.binds[0].x;
y = y_pos = m_pp.binds[0].y; y = m_Position.m_Y = m_pp.binds[0].y;
z = z_pos = m_pp.binds[0].z; z = m_Position.m_Z = m_pp.binds[0].z;
heading = m_pp.binds[0].heading; heading = m_pp.binds[0].heading;
zonesummon_ignorerestrictions = 1; zonesummon_ignorerestrictions = 1;
LogFile->write(EQEMuLog::Debug, "Player %s has died and will be zoned to bind point in zone: %s at LOC x=%f, y=%f, z=%f, heading=%f", GetName(), pZoneName, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, m_pp.binds[0].heading); LogFile->write(EQEMuLog::Debug, "Player %s has died and will be zoned to bind point in zone: %s at LOC x=%f, y=%f, z=%f, heading=%f", GetName(), pZoneName, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, m_pp.binds[0].heading);
break; break;
case SummonPC: case SummonPC:
zonesummon_x = x_pos = x; zonesummon_x = m_Position.m_X = x;
zonesummon_y = y_pos = y; zonesummon_y = m_Position.m_Y = y;
zonesummon_z = z_pos = z; zonesummon_z = m_Position.m_Z = z;
SetHeading(heading); SetHeading(heading);
break; break;
case Rewind: case Rewind:
LogFile->write(EQEMuLog::Debug, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), x_pos, y_pos, z_pos, rewind_x, rewind_y, rewind_z, zone->GetShortName()); LogFile->write(EQEMuLog::Debug, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, rewind_x, rewind_y, rewind_z, zone->GetShortName());
zonesummon_x = x_pos = x; zonesummon_x = m_Position.m_X = x;
zonesummon_y = y_pos = y; zonesummon_y = m_Position.m_Y = y;
zonesummon_z = z_pos = z; zonesummon_z = m_Position.m_Z = z;
SetHeading(heading); SetHeading(heading);
break; break;
default: default:
@ -652,10 +652,10 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
else { else {
if(zoneID == GetZoneID()) { if(zoneID == GetZoneID()) {
//properly handle proximities //properly handle proximities
entity_list.ProcessMove(this, x_pos, y_pos, z_pos); entity_list.ProcessMove(this, m_Position.m_X, m_Position.m_Y, m_Position.m_Z);
proximity_x = x_pos; proximity_x = m_Position.m_X;
proximity_y = y_pos; proximity_y = m_Position.m_Y;
proximity_z = z_pos; proximity_z = m_Position.m_Z;
//send out updates to people in zone. //send out updates to people in zone.
SendPosition(); SendPosition();
@ -723,9 +723,9 @@ void Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y
if (to_zone == -1) { if (to_zone == -1) {
m_pp.binds[0].zoneId = zone->GetZoneID(); m_pp.binds[0].zoneId = zone->GetZoneID();
m_pp.binds[0].instance_id = (zone->GetInstanceID() != 0 && zone->IsInstancePersistent()) ? zone->GetInstanceID() : 0; m_pp.binds[0].instance_id = (zone->GetInstanceID() != 0 && zone->IsInstancePersistent()) ? zone->GetInstanceID() : 0;
m_pp.binds[0].x = x_pos; m_pp.binds[0].x = m_Position.m_X;
m_pp.binds[0].y = y_pos; m_pp.binds[0].y = m_Position.m_Y;
m_pp.binds[0].z = z_pos; m_pp.binds[0].z = m_Position.m_Z;
} }
else { else {
m_pp.binds[0].zoneId = to_zone; m_pp.binds[0].zoneId = to_zone;