fix(Core/Creature): Use proper name for wander distance (#2858)

* Change from spawndist to wander_distance

Co-Authored-By: ratkosrb <ratkosrb@users.noreply.github.com>

* fix sql error

Co-Authored-By: ratkosrb <ratkosrb@users.noreply.github.com>

* Let's see if this fixes eluna :)

* Revert "Let's see if this fixes eluna :)"

This reverts commit be675bf83fc6a02f3347ea76408152d623d374bf.

* fix indent

* Revert "fix indent"

This reverts commit f4cb3d2d9fa908445d342b6f2e6dda9d52fd4665.

* Revert "Revert "fix indent""

This reverts commit 48527cfd2f9031f95bdf6e0d7b90111a3c0dc0f2.

Co-authored-by: ratkosrb <ratkosrb@users.noreply.github.com>
This commit is contained in:
Kitzunu
2020-04-11 11:20:02 +02:00
committed by GitHub
parent 50287c05f0
commit 8a1eab2c23
14 changed files with 75 additions and 64 deletions

View File

@@ -325,9 +325,9 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type)
|| (cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3)))
{
CreatureData &data = sObjectMgr->NewOrExistCreatureData(creature->GetDBTableGUIDLow());
data.spawndist = 5;
data.wander_distance = 5;
}
//else spawndist will be 15, so creatures move maximum=10
//else wander_distance will be 15, so creatures move maximum=10
//creature->SetDefaultMovementType(RANDOM_MOTION_TYPE);
creature->GetMotionMaster()->Initialize();
creature->setDeathState(JUST_DIED);

View File

@@ -160,7 +160,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
}
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipient(0), m_lootRecipientGroup(0),
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f),
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f),
m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE),
m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false),
@@ -387,7 +387,7 @@ bool Creature::InitEntry(uint32 Entry, const CreatureData* data)
// checked at loading
m_defaultMovementType = MovementGeneratorType(cinfo->MovementType);
if (!m_respawnradius && m_defaultMovementType == RANDOM_MOTION_TYPE)
if (!m_wanderDistance && m_defaultMovementType == RANDOM_MOTION_TYPE)
m_defaultMovementType = IDLE_MOTION_TYPE;
for (uint8 i=0; i < CREATURE_MAX_SPELLS; ++i)
@@ -1072,12 +1072,12 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.spawntimesecs = m_respawnDelay;
// prevent add data integrity problems
data.spawndist = GetDefaultMovementType() == IDLE_MOTION_TYPE ? 0.0f : m_respawnradius;
data.wander_distance = GetDefaultMovementType() == IDLE_MOTION_TYPE ? 0.0f : m_wanderDistance;
data.currentwaypoint = 0;
data.curhealth = GetHealth();
data.curmana = GetPower(POWER_MANA);
// prevent add data integrity problems
data.movementType = !m_respawnradius && GetDefaultMovementType() == RANDOM_MOTION_TYPE
data.movementType = !m_wanderDistance && GetDefaultMovementType() == RANDOM_MOTION_TYPE
? IDLE_MOTION_TYPE : GetDefaultMovementType();
data.spawnMask = spawnMask;
data.npcflag = npcflag;
@@ -1106,7 +1106,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
stmt->setFloat(index++, GetPositionZ());
stmt->setFloat(index++, GetOrientation());
stmt->setUInt32(index++, m_respawnDelay);
stmt->setFloat(index++, m_respawnradius);
stmt->setFloat(index++, m_wanderDistance);
stmt->setUInt32(index++, 0);
stmt->setUInt32(index++, GetHealth());
stmt->setUInt32(index++, GetPower(POWER_MANA));
@@ -1345,7 +1345,7 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gri
//We should set first home position, because then AI calls home movement
SetHomePosition(data->posX, data->posY, data->posZ, data->orientation);
m_respawnradius = data->spawndist;
m_wanderDistance = data->wander_distance;
m_respawnDelay = data->spawntimesecs;
m_deathState = ALIVE;
@@ -2408,7 +2408,7 @@ void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, floa
if (ori)
*ori = data->orientation;
if (dist)
*dist = data->spawndist;
*dist = data->wander_distance;
return;
}

View File

@@ -253,7 +253,7 @@ struct CreatureData
{
CreatureData() : id(0), mapid(0), phaseMask(0), displayid(0), equipmentId(0),
posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
spawndist(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0),
wander_distance(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0),
spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), dbData(true), overwrittenZ(false) { }
uint32 id; // entry in creature_template
uint16 mapid;
@@ -265,7 +265,7 @@ struct CreatureData
float posZ;
float orientation;
uint32 spawntimesecs;
float spawndist;
float wander_distance;
uint32 currentwaypoint;
uint32 curhealth;
uint32 curmana;
@@ -640,8 +640,8 @@ class Creature : public Unit, public GridObject<Creature>, public MovableMapObje
uint32 GetRespawnDelay() const { return m_respawnDelay; }
void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
float GetRespawnRadius() const { return m_respawnradius; }
void SetRespawnRadius(float dist) { m_respawnradius = dist; }
float GetWanderDistance() const { return m_wanderDistance; }
void SetWanderDistance(float dist) { m_wanderDistance = dist; }
uint32 m_groupLootTimer; // (msecs)timer used for group loot
uint32 lootingGroupLowGUID; // used to find group which is looting corpse
@@ -735,7 +735,7 @@ class Creature : public Unit, public GridObject<Creature>, public MovableMapObje
time_t m_respawnTime; // (secs) time of next respawn
uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
float m_respawnradius;
float m_wanderDistance;
uint16 m_transportCheckTimer;
uint32 lootPickPocketRestoreTime;

View File

@@ -1647,7 +1647,7 @@ void ObjectMgr::LoadCreatures()
uint32 oldMSTime = getMSTime();
// 0 1 2 3 4 5 6 7 8 9 10
QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, "
QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, "
// 11 12 13 14 15 16 17 18 19 20 21
"currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags "
"FROM creature "
@@ -1685,28 +1685,28 @@ void ObjectMgr::LoadCreatures()
continue;
}
CreatureData& data = _creatureDataStore[guid];
data.id = entry;
data.mapid = fields[2].GetUInt16();
data.displayid = fields[3].GetUInt32();
data.equipmentId = fields[4].GetInt8();
data.posX = fields[5].GetFloat();
data.posY = fields[6].GetFloat();
data.posZ = fields[7].GetFloat();
data.orientation = fields[8].GetFloat();
data.spawntimesecs = fields[9].GetUInt32();
data.spawndist = fields[10].GetFloat();
data.currentwaypoint= fields[11].GetUInt32();
data.curhealth = fields[12].GetUInt32();
data.curmana = fields[13].GetUInt32();
data.movementType = fields[14].GetUInt8();
data.spawnMask = fields[15].GetUInt8();
data.phaseMask = fields[16].GetUInt32();
int16 gameEvent = fields[17].GetInt8();
uint32 PoolId = fields[18].GetUInt32();
data.npcflag = fields[19].GetUInt32();
data.unit_flags = fields[20].GetUInt32();
data.dynamicflags = fields[21].GetUInt32();
CreatureData& data = _creatureDataStore[guid];
data.id = entry;
data.mapid = fields[2].GetUInt16();
data.displayid = fields[3].GetUInt32();
data.equipmentId = fields[4].GetInt8();
data.posX = fields[5].GetFloat();
data.posY = fields[6].GetFloat();
data.posZ = fields[7].GetFloat();
data.orientation = fields[8].GetFloat();
data.spawntimesecs = fields[9].GetUInt32();
data.wander_distance = fields[10].GetFloat();
data.currentwaypoint = fields[11].GetUInt32();
data.curhealth = fields[12].GetUInt32();
data.curmana = fields[13].GetUInt32();
data.movementType = fields[14].GetUInt8();
data.spawnMask = fields[15].GetUInt8();
data.phaseMask = fields[16].GetUInt32();
int16 gameEvent = fields[17].GetInt8();
uint32 PoolId = fields[18].GetUInt32();
data.npcflag = fields[19].GetUInt32();
data.unit_flags = fields[20].GetUInt32();
data.dynamicflags = fields[21].GetUInt32();
MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
if (!mapEntry)
@@ -1752,25 +1752,25 @@ void ObjectMgr::LoadCreatures()
sLog->outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.", guid, data.id);
}
if (data.spawndist < 0.0f)
if (data.wander_distance < 0.0f)
{
sLog->outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.", guid, data.id);
data.spawndist = 0.0f;
sLog->outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `wander_distance`< 0, set to 0.", guid, data.id);
data.wander_distance = 0.0f;
}
else if (data.movementType == RANDOM_MOTION_TYPE)
{
if (data.spawndist == 0.0f)
if (data.wander_distance == 0.0f)
{
sLog->outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).", guid, data.id);
sLog->outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).", guid, data.id);
data.movementType = IDLE_MOTION_TYPE;
}
}
else if (data.movementType == IDLE_MOTION_TYPE)
{
if (data.spawndist != 0.0f)
if (data.wander_distance != 0.0f)
{
sLog->outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.", guid, data.id);
data.spawndist = 0.0f;
sLog->outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.", guid, data.id);
data.wander_distance = 0.0f;
}
}
@@ -1939,7 +1939,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 mapId, float x, float y, float
data.posZ = z;
data.orientation = o;
data.spawntimesecs = spawntimedelay;
data.spawndist = 0;
data.wander_distance = 0;
data.currentwaypoint = 0;
data.curhealth = stats->GenerateHealth(cInfo);
data.curmana = stats->GenerateMana(cInfo);

View File

@@ -110,7 +110,7 @@ enum ScriptCommands
SCRIPT_COMMAND_MODEL = 32, // source = Creature, datalong = model id
SCRIPT_COMMAND_CLOSE_GOSSIP = 33, // source = Player
SCRIPT_COMMAND_PLAYMOVIE = 34, // source = Player, datalong = movie id
SCRIPT_COMMAND_MOVEMENT = 35 // soucre = Creature, datalong = MovementType, datalong2 = MovementDistance (spawndist f.ex.), dataint = pathid
SCRIPT_COMMAND_MOVEMENT = 35 // soucre = Creature, datalong = MovementType, datalong2 = MovementDistance (wander_distance f.ex.), dataint = pathid
};
// Benchmarked: Faster than std::unordered_map (insert/find)

View File

@@ -294,7 +294,7 @@ enum AcoreStrings
// TICKET STRINGS NEED REWRITE // 288-296 FREE
// END
LANG_COMMAND_SPAWNDIST = 297,
LANG_COMMAND_WANDER_DISTANCE = 297,
LANG_COMMAND_SPAWNTIME = 298,
LANG_COMMAND_MODIFY_HONOR = 299,

View File

@@ -217,7 +217,7 @@ void MotionMaster::MoveIdle()
Mutate(&si_idleMovement, MOTION_SLOT_IDLE);
}
void MotionMaster::MoveRandom(float spawndist)
void MotionMaster::MoveRandom(float wanderDistance)
{
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
@@ -228,7 +228,7 @@ void MotionMaster::MoveRandom(float spawndist)
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outStaticDebug("Creature (GUID: %u) start moving random", _owner->GetGUIDLow());
#endif
Mutate(new RandomMovementGenerator<Creature>(spawndist), MOTION_SLOT_IDLE);
Mutate(new RandomMovementGenerator<Creature>(wanderDistance), MOTION_SLOT_IDLE);
}
}

View File

@@ -162,7 +162,7 @@ class MotionMaster //: private std::stack<MovementGenerator *>
void MoveIdle();
void MoveTargetedHome();
void MoveRandom(float spawndist = 0.0f);
void MoveRandom(float wanderDistance = 0.0f);
void MoveFollow(Unit* target, float dist, float angle, MovementSlot slot = MOTION_SLOT_ACTIVE);
void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f);
void MoveConfused();

View File

@@ -202,10 +202,10 @@ void RandomMovementGenerator<Creature>::DoInitialize(Creature* creature)
return;
if (!_wanderDistance)
_wanderDistance = creature->GetRespawnRadius();
_wanderDistance = creature->GetWanderDistance();
_nextMoveTime.Reset(creature->GetDBTableGUIDLow() && creature->GetRespawnRadius() == _wanderDistance ? urand(1, 5000) : 0);
_wanderDistance = std::max((creature->GetRespawnRadius() == _wanderDistance && creature->GetInstanceId() == 0) ? (creature->CanFly() ? MIN_WANDER_DISTANCE_AIR : MIN_WANDER_DISTANCE_GROUND) : 0.0f, _wanderDistance);
_nextMoveTime.Reset(creature->GetDBTableGUIDLow() && creature->GetWanderDistance() == _wanderDistance ? urand(1, 5000) : 0);
_wanderDistance = std::max((creature->GetWanderDistance() == _wanderDistance && creature->GetInstanceId() == 0) ? (creature->CanFly() ? MIN_WANDER_DISTANCE_AIR : MIN_WANDER_DISTANCE_GROUND) : 0.0f, _wanderDistance);
if (G3D::fuzzyEq(_initialPosition.GetExactDist2d(0.0f, 0.0f), 0.0f))
{

View File

@@ -18,7 +18,7 @@ template<class T>
class RandomMovementGenerator : public MovementGeneratorMedium< T, RandomMovementGenerator<T> >
{
public:
RandomMovementGenerator(float spawnDist = 0.0f) : _nextMoveTime(0), _moveCount(0), _wanderDistance(spawnDist), _pathGenerator(NULL), _currentPoint(RANDOM_POINTS_NUMBER)
RandomMovementGenerator(float wanderDistance = 0.0f) : _nextMoveTime(0), _moveCount(0), _wanderDistance(wanderDistance), _pathGenerator(NULL), _currentPoint(RANDOM_POINTS_NUMBER)
{
_initialPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
_destinationPoints.reserve(RANDOM_POINTS_NUMBER);