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:
@@ -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;
|
||||||
@@ -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_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_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_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_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_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);
|
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_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_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_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_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_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);
|
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);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ enum WorldDatabaseStatements
|
|||||||
WORLD_UPD_CREATURE_FACTION,
|
WORLD_UPD_CREATURE_FACTION,
|
||||||
WORLD_UPD_CREATURE_NPCFLAG,
|
WORLD_UPD_CREATURE_NPCFLAG,
|
||||||
WORLD_UPD_CREATURE_POSITION,
|
WORLD_UPD_CREATURE_POSITION,
|
||||||
WORLD_UPD_CREATURE_SPAWN_DISTANCE,
|
WORLD_UPD_CREATURE_WANDER_DISTANCE,
|
||||||
WORLD_UPD_CREATURE_SPAWN_TIME_SECS,
|
WORLD_UPD_CREATURE_SPAWN_TIME_SECS,
|
||||||
WORLD_INS_CREATURE_FORMATION,
|
WORLD_INS_CREATURE_FORMATION,
|
||||||
WORLD_INS_WAYPOINT_DATA,
|
WORLD_INS_WAYPOINT_DATA,
|
||||||
|
|||||||
@@ -325,9 +325,9 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type)
|
|||||||
|| (cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3)))
|
|| (cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3)))
|
||||||
{
|
{
|
||||||
CreatureData &data = sObjectMgr->NewOrExistCreatureData(creature->GetDBTableGUIDLow());
|
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->SetDefaultMovementType(RANDOM_MOTION_TYPE);
|
||||||
creature->GetMotionMaster()->Initialize();
|
creature->GetMotionMaster()->Initialize();
|
||||||
creature->setDeathState(JUST_DIED);
|
creature->setDeathState(JUST_DIED);
|
||||||
|
|||||||
@@ -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),
|
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_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_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),
|
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
|
// checked at loading
|
||||||
m_defaultMovementType = MovementGeneratorType(cinfo->MovementType);
|
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;
|
m_defaultMovementType = IDLE_MOTION_TYPE;
|
||||||
|
|
||||||
for (uint8 i=0; i < CREATURE_MAX_SPELLS; ++i)
|
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;
|
data.spawntimesecs = m_respawnDelay;
|
||||||
// prevent add data integrity problems
|
// 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.currentwaypoint = 0;
|
||||||
data.curhealth = GetHealth();
|
data.curhealth = GetHealth();
|
||||||
data.curmana = GetPower(POWER_MANA);
|
data.curmana = GetPower(POWER_MANA);
|
||||||
// prevent add data integrity problems
|
// 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();
|
? IDLE_MOTION_TYPE : GetDefaultMovementType();
|
||||||
data.spawnMask = spawnMask;
|
data.spawnMask = spawnMask;
|
||||||
data.npcflag = npcflag;
|
data.npcflag = npcflag;
|
||||||
@@ -1106,7 +1106,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||||||
stmt->setFloat(index++, GetPositionZ());
|
stmt->setFloat(index++, GetPositionZ());
|
||||||
stmt->setFloat(index++, GetOrientation());
|
stmt->setFloat(index++, GetOrientation());
|
||||||
stmt->setUInt32(index++, m_respawnDelay);
|
stmt->setUInt32(index++, m_respawnDelay);
|
||||||
stmt->setFloat(index++, m_respawnradius);
|
stmt->setFloat(index++, m_wanderDistance);
|
||||||
stmt->setUInt32(index++, 0);
|
stmt->setUInt32(index++, 0);
|
||||||
stmt->setUInt32(index++, GetHealth());
|
stmt->setUInt32(index++, GetHealth());
|
||||||
stmt->setUInt32(index++, GetPower(POWER_MANA));
|
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
|
//We should set first home position, because then AI calls home movement
|
||||||
SetHomePosition(data->posX, data->posY, data->posZ, data->orientation);
|
SetHomePosition(data->posX, data->posY, data->posZ, data->orientation);
|
||||||
|
|
||||||
m_respawnradius = data->spawndist;
|
m_wanderDistance = data->wander_distance;
|
||||||
|
|
||||||
m_respawnDelay = data->spawntimesecs;
|
m_respawnDelay = data->spawntimesecs;
|
||||||
m_deathState = ALIVE;
|
m_deathState = ALIVE;
|
||||||
@@ -2408,7 +2408,7 @@ void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, floa
|
|||||||
if (ori)
|
if (ori)
|
||||||
*ori = data->orientation;
|
*ori = data->orientation;
|
||||||
if (dist)
|
if (dist)
|
||||||
*dist = data->spawndist;
|
*dist = data->wander_distance;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ struct CreatureData
|
|||||||
{
|
{
|
||||||
CreatureData() : id(0), mapid(0), phaseMask(0), displayid(0), equipmentId(0),
|
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),
|
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) { }
|
spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), dbData(true), overwrittenZ(false) { }
|
||||||
uint32 id; // entry in creature_template
|
uint32 id; // entry in creature_template
|
||||||
uint16 mapid;
|
uint16 mapid;
|
||||||
@@ -265,7 +265,7 @@ struct CreatureData
|
|||||||
float posZ;
|
float posZ;
|
||||||
float orientation;
|
float orientation;
|
||||||
uint32 spawntimesecs;
|
uint32 spawntimesecs;
|
||||||
float spawndist;
|
float wander_distance;
|
||||||
uint32 currentwaypoint;
|
uint32 currentwaypoint;
|
||||||
uint32 curhealth;
|
uint32 curhealth;
|
||||||
uint32 curmana;
|
uint32 curmana;
|
||||||
@@ -640,8 +640,8 @@ class Creature : public Unit, public GridObject<Creature>, public MovableMapObje
|
|||||||
uint32 GetRespawnDelay() const { return m_respawnDelay; }
|
uint32 GetRespawnDelay() const { return m_respawnDelay; }
|
||||||
void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
|
void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
|
||||||
|
|
||||||
float GetRespawnRadius() const { return m_respawnradius; }
|
float GetWanderDistance() const { return m_wanderDistance; }
|
||||||
void SetRespawnRadius(float dist) { m_respawnradius = dist; }
|
void SetWanderDistance(float dist) { m_wanderDistance = dist; }
|
||||||
|
|
||||||
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
||||||
uint32 lootingGroupLowGUID; // used to find group which is looting corpse
|
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
|
time_t m_respawnTime; // (secs) time of next respawn
|
||||||
uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
|
uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
|
||||||
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
|
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
|
||||||
float m_respawnradius;
|
float m_wanderDistance;
|
||||||
uint16 m_transportCheckTimer;
|
uint16 m_transportCheckTimer;
|
||||||
uint32 lootPickPocketRestoreTime;
|
uint32 lootPickPocketRestoreTime;
|
||||||
|
|
||||||
|
|||||||
@@ -1647,7 +1647,7 @@ void ObjectMgr::LoadCreatures()
|
|||||||
uint32 oldMSTime = getMSTime();
|
uint32 oldMSTime = getMSTime();
|
||||||
|
|
||||||
// 0 1 2 3 4 5 6 7 8 9 10
|
// 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
|
// 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 "
|
"currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags "
|
||||||
"FROM creature "
|
"FROM creature "
|
||||||
@@ -1695,8 +1695,8 @@ void ObjectMgr::LoadCreatures()
|
|||||||
data.posZ = fields[7].GetFloat();
|
data.posZ = fields[7].GetFloat();
|
||||||
data.orientation = fields[8].GetFloat();
|
data.orientation = fields[8].GetFloat();
|
||||||
data.spawntimesecs = fields[9].GetUInt32();
|
data.spawntimesecs = fields[9].GetUInt32();
|
||||||
data.spawndist = fields[10].GetFloat();
|
data.wander_distance = fields[10].GetFloat();
|
||||||
data.currentwaypoint= fields[11].GetUInt32();
|
data.currentwaypoint = fields[11].GetUInt32();
|
||||||
data.curhealth = fields[12].GetUInt32();
|
data.curhealth = fields[12].GetUInt32();
|
||||||
data.curmana = fields[13].GetUInt32();
|
data.curmana = fields[13].GetUInt32();
|
||||||
data.movementType = fields[14].GetUInt8();
|
data.movementType = fields[14].GetUInt8();
|
||||||
@@ -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);
|
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);
|
sLog->outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `wander_distance`< 0, set to 0.", guid, data.id);
|
||||||
data.spawndist = 0.0f;
|
data.wander_distance = 0.0f;
|
||||||
}
|
}
|
||||||
else if (data.movementType == RANDOM_MOTION_TYPE)
|
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;
|
data.movementType = IDLE_MOTION_TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (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);
|
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.spawndist = 0.0f;
|
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.posZ = z;
|
||||||
data.orientation = o;
|
data.orientation = o;
|
||||||
data.spawntimesecs = spawntimedelay;
|
data.spawntimesecs = spawntimedelay;
|
||||||
data.spawndist = 0;
|
data.wander_distance = 0;
|
||||||
data.currentwaypoint = 0;
|
data.currentwaypoint = 0;
|
||||||
data.curhealth = stats->GenerateHealth(cInfo);
|
data.curhealth = stats->GenerateHealth(cInfo);
|
||||||
data.curmana = stats->GenerateMana(cInfo);
|
data.curmana = stats->GenerateMana(cInfo);
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ enum ScriptCommands
|
|||||||
SCRIPT_COMMAND_MODEL = 32, // source = Creature, datalong = model id
|
SCRIPT_COMMAND_MODEL = 32, // source = Creature, datalong = model id
|
||||||
SCRIPT_COMMAND_CLOSE_GOSSIP = 33, // source = Player
|
SCRIPT_COMMAND_CLOSE_GOSSIP = 33, // source = Player
|
||||||
SCRIPT_COMMAND_PLAYMOVIE = 34, // source = Player, datalong = movie id
|
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)
|
// Benchmarked: Faster than std::unordered_map (insert/find)
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ enum AcoreStrings
|
|||||||
// TICKET STRINGS NEED REWRITE // 288-296 FREE
|
// TICKET STRINGS NEED REWRITE // 288-296 FREE
|
||||||
|
|
||||||
// END
|
// END
|
||||||
LANG_COMMAND_SPAWNDIST = 297,
|
LANG_COMMAND_WANDER_DISTANCE = 297,
|
||||||
LANG_COMMAND_SPAWNTIME = 298,
|
LANG_COMMAND_SPAWNTIME = 298,
|
||||||
LANG_COMMAND_MODIFY_HONOR = 299,
|
LANG_COMMAND_MODIFY_HONOR = 299,
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ void MotionMaster::MoveIdle()
|
|||||||
Mutate(&si_idleMovement, MOTION_SLOT_IDLE);
|
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
|
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, 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)
|
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||||
sLog->outStaticDebug("Creature (GUID: %u) start moving random", _owner->GetGUIDLow());
|
sLog->outStaticDebug("Creature (GUID: %u) start moving random", _owner->GetGUIDLow());
|
||||||
#endif
|
#endif
|
||||||
Mutate(new RandomMovementGenerator<Creature>(spawndist), MOTION_SLOT_IDLE);
|
Mutate(new RandomMovementGenerator<Creature>(wanderDistance), MOTION_SLOT_IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class MotionMaster //: private std::stack<MovementGenerator *>
|
|||||||
|
|
||||||
void MoveIdle();
|
void MoveIdle();
|
||||||
void MoveTargetedHome();
|
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 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 MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f);
|
||||||
void MoveConfused();
|
void MoveConfused();
|
||||||
|
|||||||
@@ -202,10 +202,10 @@ void RandomMovementGenerator<Creature>::DoInitialize(Creature* creature)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!_wanderDistance)
|
if (!_wanderDistance)
|
||||||
_wanderDistance = creature->GetRespawnRadius();
|
_wanderDistance = creature->GetWanderDistance();
|
||||||
|
|
||||||
_nextMoveTime.Reset(creature->GetDBTableGUIDLow() && creature->GetRespawnRadius() == _wanderDistance ? urand(1, 5000) : 0);
|
_nextMoveTime.Reset(creature->GetDBTableGUIDLow() && creature->GetWanderDistance() == _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);
|
_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))
|
if (G3D::fuzzyEq(_initialPosition.GetExactDist2d(0.0f, 0.0f), 0.0f))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ template<class T>
|
|||||||
class RandomMovementGenerator : public MovementGeneratorMedium< T, RandomMovementGenerator<T> >
|
class RandomMovementGenerator : public MovementGeneratorMedium< T, RandomMovementGenerator<T> >
|
||||||
{
|
{
|
||||||
public:
|
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);
|
_initialPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
_destinationPoints.reserve(RANDOM_POINTS_NUMBER);
|
_destinationPoints.reserve(RANDOM_POINTS_NUMBER);
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public:
|
|||||||
{ "model", SEC_ADMINISTRATOR, false, &HandleNpcSetModelCommand, "" },
|
{ "model", SEC_ADMINISTRATOR, false, &HandleNpcSetModelCommand, "" },
|
||||||
{ "movetype", SEC_ADMINISTRATOR, false, &HandleNpcSetMoveTypeCommand, "" },
|
{ "movetype", SEC_ADMINISTRATOR, false, &HandleNpcSetMoveTypeCommand, "" },
|
||||||
{ "phase", SEC_ADMINISTRATOR, false, &HandleNpcSetPhaseCommand, "" },
|
{ "phase", SEC_ADMINISTRATOR, false, &HandleNpcSetPhaseCommand, "" },
|
||||||
{ "spawndist", SEC_ADMINISTRATOR, false, &HandleNpcSetSpawnDistCommand, "" },
|
{ "wanderdistance", SEC_ADMINISTRATOR, false, &HandleNpcSetWanderDistanceCommand, "" },
|
||||||
{ "spawntime", SEC_ADMINISTRATOR, false, &HandleNpcSetSpawnTimeCommand, "" },
|
{ "spawntime", SEC_ADMINISTRATOR, false, &HandleNpcSetSpawnTimeCommand, "" },
|
||||||
{ "data", SEC_ADMINISTRATOR, false, &HandleNpcSetDataCommand, "" },
|
{ "data", SEC_ADMINISTRATOR, false, &HandleNpcSetDataCommand, "" },
|
||||||
//{ TODO: fix or remove these commands
|
//{ TODO: fix or remove these commands
|
||||||
@@ -935,7 +935,7 @@ public:
|
|||||||
* Valid movement types are:
|
* Valid movement types are:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li> stay - NPC wont move </li>
|
* <li> stay - NPC wont move </li>
|
||||||
* <li> random - NPC will move randomly according to the spawndist </li>
|
* <li> random - NPC will move randomly according to the wander_distance </li>
|
||||||
* <li> way - NPC will move with given waypoints set </li>
|
* <li> way - NPC will move with given waypoints set </li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* additional parameter: NODEL - so no waypoints are deleted, if you
|
* additional parameter: NODEL - so no waypoints are deleted, if you
|
||||||
@@ -1107,7 +1107,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set spawn dist of creature
|
//set spawn dist of creature
|
||||||
static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, const char* args)
|
static bool HandleNpcSetWanderDistanceCommand(ChatHandler* handler, const char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
if (!*args)
|
||||||
return false;
|
return false;
|
||||||
@@ -1131,7 +1131,7 @@ public:
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
creature->SetRespawnRadius((float)option);
|
creature->SetWanderDistance((float)option);
|
||||||
creature->SetDefaultMovementType(mtype);
|
creature->SetDefaultMovementType(mtype);
|
||||||
creature->GetMotionMaster()->Initialize();
|
creature->GetMotionMaster()->Initialize();
|
||||||
if (creature->IsAlive()) // dead creature will reset movement generator at respawn
|
if (creature->IsAlive()) // dead creature will reset movement generator at respawn
|
||||||
@@ -1140,7 +1140,7 @@ public:
|
|||||||
creature->Respawn();
|
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->setFloat(0, option);
|
||||||
stmt->setUInt8(1, uint8(mtype));
|
stmt->setUInt8(1, uint8(mtype));
|
||||||
@@ -1148,7 +1148,7 @@ public:
|
|||||||
|
|
||||||
WorldDatabase.Execute(stmt);
|
WorldDatabase.Execute(stmt);
|
||||||
|
|
||||||
handler->PSendSysMessage(LANG_COMMAND_SPAWNDIST, option);
|
handler->PSendSysMessage(LANG_COMMAND_WANDER_DISTANCE, option);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user