From 8a1eab2c2330537a36e1f1fdae56ea9ad40b5e43 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Sat, 11 Apr 2020 11:20:02 +0200 Subject: [PATCH] fix(Core/Creature): Use proper name for wander distance (#2858) * Change from spawndist to wander_distance Co-Authored-By: ratkosrb * fix sql error Co-Authored-By: ratkosrb * 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 --- .../rev_1586420115016794500.sql | 11 ++++ .../Database/Implementation/WorldDatabase.cpp | 4 +- .../Database/Implementation/WorldDatabase.h | 2 +- .../Battlegrounds/Zones/BattlegroundAV.cpp | 4 +- .../game/Entities/Creature/Creature.cpp | 14 ++-- src/server/game/Entities/Creature/Creature.h | 10 +-- src/server/game/Globals/ObjectMgr.cpp | 64 +++++++++---------- src/server/game/Globals/ObjectMgr.h | 2 +- src/server/game/Miscellaneous/Language.h | 2 +- src/server/game/Movement/MotionMaster.cpp | 4 +- src/server/game/Movement/MotionMaster.h | 2 +- .../RandomMovementGenerator.cpp | 6 +- .../RandomMovementGenerator.h | 2 +- src/server/scripts/Commands/cs_npc.cpp | 12 ++-- 14 files changed, 75 insertions(+), 64 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1586420115016794500.sql diff --git a/data/sql/updates/pending_db_world/rev_1586420115016794500.sql b/data/sql/updates/pending_db_world/rev_1586420115016794500.sql new file mode 100644 index 000000000..6eacc458c --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1586420115016794500.sql @@ -0,0 +1,11 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1586420115016794500'); + +ALTER TABLE `creature` + CHANGE COLUMN `spawndist` `wander_distance` FLOAT NOT NULL DEFAULT '0' AFTER `spawntimesecs`; + +DELETE FROM `command` WHERE `name` IN ('npc set spawndist', 'npc set wanderdistance'); +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('npc set wanderdistance', 3, 'Syntax: .npc set wanderdistance #dist\r\n\r\nAdjust wander distance of selected creature to dist.'); + +-- Loc3 = German Google Translate +UPDATE `acore_string` SET `content_default`='Wander distance changed to: %f', `content_loc3` = 'Wanderentfernung wurde auf %f abgeändert' WHERE `entry`=297; diff --git a/src/common/Database/Implementation/WorldDatabase.cpp b/src/common/Database/Implementation/WorldDatabase.cpp index 34698d5ff..8c31b0ef8 100644 --- a/src/common/Database/Implementation/WorldDatabase.cpp +++ b/src/common/Database/Implementation/WorldDatabase.cpp @@ -30,7 +30,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_UPD_CREATURE_FACTION, "UPDATE creature_template SET faction = ? WHERE entry = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_UPD_CREATURE_NPCFLAG, "UPDATE creature_template SET npcflag = ? WHERE entry = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_UPD_CREATURE_POSITION, "UPDATE creature SET position_x = ?, position_y = ?, position_z = ?, orientation = ? WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(WORLD_UPD_CREATURE_SPAWN_DISTANCE, "UPDATE creature SET spawndist = ?, MovementType = ? WHERE guid = ?", CONNECTION_ASYNC); + PrepareStatement(WORLD_UPD_CREATURE_WANDER_DISTANCE, "UPDATE creature SET wander_distance = ?, MovementType = ? WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_UPD_CREATURE_SPAWN_TIME_SECS, "UPDATE creature SET spawntimesecs = ? WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_INS_CREATURE_FORMATION, "INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(WORLD_INS_WAYPOINT_DATA, "INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC); @@ -71,7 +71,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_CREATURE_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH); - PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id , map, spawnMask, phaseMask, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id , map, spawnMask, phaseMask, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_INS_GAMEOBJECT, "INSERT INTO gameobject (guid, id, map, spawnMask, phaseMask, position_x, position_y, position_z, orientation, rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); diff --git a/src/common/Database/Implementation/WorldDatabase.h b/src/common/Database/Implementation/WorldDatabase.h index 5d122fffa..09ac41485 100644 --- a/src/common/Database/Implementation/WorldDatabase.h +++ b/src/common/Database/Implementation/WorldDatabase.h @@ -50,7 +50,7 @@ enum WorldDatabaseStatements WORLD_UPD_CREATURE_FACTION, WORLD_UPD_CREATURE_NPCFLAG, WORLD_UPD_CREATURE_POSITION, - WORLD_UPD_CREATURE_SPAWN_DISTANCE, + WORLD_UPD_CREATURE_WANDER_DISTANCE, WORLD_UPD_CREATURE_SPAWN_TIME_SECS, WORLD_INS_CREATURE_FORMATION, WORLD_INS_WAYPOINT_DATA, diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 5b3d4286e..cbd1e41f3 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -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); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 2703390b7..f91703d7d 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -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; } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index f4fc7476e..59a309e2a 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -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, 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, 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; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 4cc6b3fc1..0b612f98e 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -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); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index cd6e4a082..77e7c6876 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -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) diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 415d16b4a..6cb7b489b 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -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, diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index d681dcff3..b3096f677 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -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(spawndist), MOTION_SLOT_IDLE); + Mutate(new RandomMovementGenerator(wanderDistance), MOTION_SLOT_IDLE); } } diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 8fc1c71f2..95b97c12e 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -162,7 +162,7 @@ class MotionMaster //: private std::stack 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(); diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index 21b3486c0..bba4667ce 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -202,10 +202,10 @@ void RandomMovementGenerator::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)) { diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h index 59cc020c3..52e280c8f 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h @@ -18,7 +18,7 @@ template class RandomMovementGenerator : public MovementGeneratorMedium< T, RandomMovementGenerator > { 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); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index acda91fea..fe94b73fc 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -149,7 +149,7 @@ public: { "model", SEC_ADMINISTRATOR, false, &HandleNpcSetModelCommand, "" }, { "movetype", SEC_ADMINISTRATOR, false, &HandleNpcSetMoveTypeCommand, "" }, { "phase", SEC_ADMINISTRATOR, false, &HandleNpcSetPhaseCommand, "" }, - { "spawndist", SEC_ADMINISTRATOR, false, &HandleNpcSetSpawnDistCommand, "" }, + { "wanderdistance", SEC_ADMINISTRATOR, false, &HandleNpcSetWanderDistanceCommand, "" }, { "spawntime", SEC_ADMINISTRATOR, false, &HandleNpcSetSpawnTimeCommand, "" }, { "data", SEC_ADMINISTRATOR, false, &HandleNpcSetDataCommand, "" }, //{ TODO: fix or remove these commands @@ -935,7 +935,7 @@ public: * Valid movement types are: *
    *
  • stay - NPC wont move
  • - *
  • random - NPC will move randomly according to the spawndist
  • + *
  • random - NPC will move randomly according to the wander_distance
  • *
  • way - NPC will move with given waypoints set
  • *
* additional parameter: NODEL - so no waypoints are deleted, if you @@ -1107,7 +1107,7 @@ public: } //set spawn dist of creature - static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetWanderDistanceCommand(ChatHandler* handler, const char* args) { if (!*args) return false; @@ -1131,7 +1131,7 @@ public: else return false; - creature->SetRespawnRadius((float)option); + creature->SetWanderDistance((float)option); creature->SetDefaultMovementType(mtype); creature->GetMotionMaster()->Initialize(); if (creature->IsAlive()) // dead creature will reset movement generator at respawn @@ -1140,7 +1140,7 @@ public: creature->Respawn(); } - PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_DISTANCE); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_WANDER_DISTANCE); stmt->setFloat(0, option); stmt->setUInt8(1, uint8(mtype)); @@ -1148,7 +1148,7 @@ public: WorldDatabase.Execute(stmt); - handler->PSendSysMessage(LANG_COMMAND_SPAWNDIST, option); + handler->PSendSysMessage(LANG_COMMAND_WANDER_DISTANCE, option); return true; }