Core/Creature: Add new db field InteractionPauseTimer

Port From (https://github.com/TrinityCore/TrinityCore/commit/5180abfb19b9c1c4f2df2fbfa918a62f1c4ae995)
This commit is contained in:
hondacrx
2022-05-24 19:13:45 -04:00
parent 678c657f7d
commit 820eea5949
6 changed files with 59 additions and 31 deletions
@@ -75,7 +75,7 @@ namespace Framework.Database
PrepareStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_ID_BY_GUID, "SELECT id FROM waypoint_scripts WHERE guid = ?"); PrepareStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_ID_BY_GUID, "SELECT id FROM waypoint_scripts WHERE guid = ?");
PrepareStatement(WorldStatements.DEL_CREATURE, "DELETE FROM creature WHERE guid = ?"); PrepareStatement(WorldStatements.DEL_CREATURE, "DELETE FROM creature WHERE guid = ?");
PrepareStatement(WorldStatements.SEL_COMMANDS, "SELECT name, permission, help FROM command"); PrepareStatement(WorldStatements.SEL_COMMANDS, "SELECT name, permission, help FROM command");
PrepareStatement(WorldStatements.SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, name, femaleName, subname, TitleAlt, IconName, gossip_menu_id, minlevel, maxlevel, HealthScalingExpansion, RequiredExpansion, VignetteID, faction, npcflag, speed_walk, speed_run, scale, `rank`, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, unit_flags3, dynamicflags, family, trainer_class, type, type_flags, type_flags2, lootid, pickpocketloot, skinloot, VehicleId, mingold, maxgold, AIName, MovementType, ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, movementId, CreatureDifficultyID, WidgetSetID, WidgetSetUnitConditionID, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, flags_extra, ScriptName FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId WHERE entry = ? OR 1 = ?"); PrepareStatement(WorldStatements.SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, name, femaleName, subname, TitleAlt, IconName, gossip_menu_id, minlevel, maxlevel, HealthScalingExpansion, RequiredExpansion, VignetteID, faction, npcflag, speed_walk, speed_run, scale, `rank`, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, unit_flags3, dynamicflags, family, trainer_class, type, type_flags, type_flags2, lootid, pickpocketloot, skinloot, VehicleId, mingold, maxgold, AIName, MovementType, ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, ctm.InteractionPauseTimer, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, movementId, CreatureDifficultyID, WidgetSetID, WidgetSetUnitConditionID, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, flags_extra, ScriptName FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId WHERE entry = ? OR 1 = ?");
PrepareStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?"); PrepareStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?");
PrepareStatement(WorldStatements.SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?"); PrepareStatement(WorldStatements.SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?");
PrepareStatement(WorldStatements.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)) <= ? ORDER BY order_"); PrepareStatement(WorldStatements.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)) <= ? ORDER BY order_");
@@ -354,6 +354,7 @@ namespace Game.Entities
public bool Rooted; public bool Rooted;
public CreatureChaseMovementType Chase; public CreatureChaseMovementType Chase;
public CreatureRandomMovementType Random; public CreatureRandomMovementType Random;
public uint InteractionPauseTimer;
public CreatureMovementData() public CreatureMovementData()
{ {
@@ -361,6 +362,9 @@ namespace Game.Entities
Flight = CreatureFlightMovementType.None; Flight = CreatureFlightMovementType.None;
Swim = true; Swim = true;
Rooted = false; Rooted = false;
Chase = CreatureChaseMovementType.Run;
Random = CreatureRandomMovementType.Walk;
InteractionPauseTimer = WorldConfig.GetIntValue(WorldCfg.CreatureStopForPlayer);
} }
public bool IsGroundAllowed() { return Ground != CreatureGroundMovementType.None; } public bool IsGroundAllowed() { return Ground != CreatureGroundMovementType.None; }
@@ -371,9 +375,11 @@ namespace Game.Entities
public CreatureChaseMovementType GetChase() { return Chase; } public CreatureChaseMovementType GetChase() { return Chase; }
public CreatureRandomMovementType GetRandom() { return Random; } public CreatureRandomMovementType GetRandom() { return Random; }
public uint GetInteractionPauseTimer() { return InteractionPauseTimer; }
public override string ToString() public override string ToString()
{ {
return $"Ground: {Ground}, Swim: {Swim}, Flight: {Flight} {(Rooted ? ", Rooted" : "")}, Chase: {Chase}, Random: {Random}"; return $"Ground: {Ground}, Swim: {Swim}, Flight: {Flight} {(Rooted ? ", Rooted" : "")}, Chase: {Chase}, Random: {Random}, InteractionPauseTimer: {InteractionPauseTimer}";
} }
} }
+39 -25
View File
@@ -1841,24 +1841,27 @@ namespace Game
if (!fields.IsNull(51)) if (!fields.IsNull(51))
creature.Movement.Random = (CreatureRandomMovementType)fields.Read<byte>(51); creature.Movement.Random = (CreatureRandomMovementType)fields.Read<byte>(51);
creature.HoverHeight = fields.Read<float>(52); if (!fields.IsNull(52))
creature.ModHealth = fields.Read<float>(53); creature.Movement.InteractionPauseTimer = fields.Read<uint>(52);
creature.ModHealthExtra = fields.Read<float>(54);
creature.ModMana = fields.Read<float>(55); creature.HoverHeight = fields.Read<float>(53);
creature.ModManaExtra = fields.Read<float>(56); creature.ModHealth = fields.Read<float>(54);
creature.ModArmor = fields.Read<float>(57); creature.ModHealthExtra = fields.Read<float>(55);
creature.ModDamage = fields.Read<float>(58); creature.ModMana = fields.Read<float>(56);
creature.ModExperience = fields.Read<float>(59); creature.ModManaExtra = fields.Read<float>(57);
creature.RacialLeader = fields.Read<bool>(60); creature.ModArmor = fields.Read<float>(58);
creature.MovementId = fields.Read<uint>(61); creature.ModDamage = fields.Read<float>(59);
creature.CreatureDifficultyID = fields.Read<int>(62); creature.ModExperience = fields.Read<float>(60);
creature.WidgetSetID = fields.Read<int>(63); creature.RacialLeader = fields.Read<bool>(61);
creature.WidgetSetUnitConditionID = fields.Read<int>(64); creature.MovementId = fields.Read<uint>(62);
creature.RegenHealth = fields.Read<bool>(65); creature.CreatureDifficultyID = fields.Read<int>(63);
creature.MechanicImmuneMask = fields.Read<uint>(66); creature.WidgetSetID = fields.Read<int>(64);
creature.SpellSchoolImmuneMask = fields.Read<uint>(67); creature.WidgetSetUnitConditionID = fields.Read<int>(65);
creature.FlagsExtra = (CreatureFlagsExtra)fields.Read<uint>(68); creature.RegenHealth = fields.Read<bool>(66);
creature.ScriptID = GetScriptId(fields.Read<string>(69)); creature.MechanicImmuneMask = fields.Read<uint>(67);
creature.SpellSchoolImmuneMask = fields.Read<uint>(68);
creature.FlagsExtra = (CreatureFlagsExtra)fields.Read<uint>(69);
creature.ScriptID = GetScriptId(fields.Read<string>(70));
creatureTemplateStorage[entry] = creature; creatureTemplateStorage[entry] = creature;
} }
@@ -2346,7 +2349,10 @@ namespace Game
creatureMovementOverrides.Clear(); creatureMovementOverrides.Clear();
SQLResult result = DB.World.Query("SELECT SpawnId, Ground, Swim, Flight, Rooted, Chase, Random from creature_movement_override"); // Load the data from creature_movement_override and if NULL fallback to creature_template_movement
SQLResult result = DB.World.Query("SELECT cmo.SpawnId,COALESCE(cmo.Ground, ctm.Ground),COALESCE(cmo.Swim, ctm.Swim),COALESCE(cmo.Flight, ctm.Flight),COALESCE(cmo.Rooted, ctm.Rooted),COALESCE(cmo.Chase, ctm.Chase),COALESCE(cmo.Random, ctm.Random)," +
"COALESCE(cmo.InteractionPauseTimer, ctm.InteractionPauseTimer) FROM creature_movement_override AS cmo LEFT JOIN creature AS c ON c.guid = cmo.SpawnId LEFT JOIN creature_template_movement AS ctm ON ctm.CreatureId = c.id");
if (result.IsEmpty()) if (result.IsEmpty())
{ {
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 creature movement overrides. DB table `creature_movement_override` is empty!"); Log.outInfo(LogFilter.ServerLoading, "Loaded 0 creature movement overrides. DB table `creature_movement_override` is empty!");
@@ -2363,12 +2369,20 @@ namespace Game
} }
CreatureMovementData movement = new(); CreatureMovementData movement = new();
movement.Ground = (CreatureGroundMovementType)result.Read<byte>(1); if (!result.IsNull(1))
movement.Swim = result.Read<bool>(2); movement.Ground = (CreatureGroundMovementType)result.Read<byte>(1);
movement.Flight = (CreatureFlightMovementType)result.Read<byte>(3); if (!result.IsNull(2))
movement.Rooted = result.Read<bool>(4); movement.Swim = result.Read<bool>(2);
movement.Chase = (CreatureChaseMovementType)result.Read<byte>(5); if (!result.IsNull(3))
movement.Random = (CreatureRandomMovementType)result.Read<byte>(6); movement.Flight = (CreatureFlightMovementType)result.Read<byte>(3);
if (!result.IsNull(4))
movement.Rooted = result.Read<bool>(4);
if (!result.IsNull(5))
movement.Chase = (CreatureChaseMovementType)result.Read<byte>(5);
if (!result.IsNull(6))
movement.Random = (CreatureRandomMovementType)result.Read<byte>(6);
if (!result.IsNull(7))
movement.InteractionPauseTimer = result.Read<uint>(7);
CheckCreatureMovement("creature_movement_override", spawnId, movement); CheckCreatureMovement("creature_movement_override", spawnId, movement);
+3 -1
View File
@@ -39,7 +39,9 @@ namespace Game
return; return;
// Stop the npc if moving // Stop the npc if moving
unit.PauseMovement(WorldConfig.GetUIntValue(WorldCfg.CreatureStopForPlayer)); uint pause = unit.GetMovementTemplate().GetInteractionPauseTimer();
if (pause != 0)
unit.PauseMovement(pause);
unit.SetHomePosition(unit.GetPosition()); unit.SetHomePosition(unit.GetPosition());
BattlegroundTypeId bgTypeId = Global.BattlegroundMgr.GetBattleMasterBG(unit.GetEntry()); BattlegroundTypeId bgTypeId = Global.BattlegroundMgr.GetBattleMasterBG(unit.GetEntry());
+6 -2
View File
@@ -144,7 +144,9 @@ namespace Game
GetPlayer().RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Interacting); GetPlayer().RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Interacting);
// Stop the npc if moving // Stop the npc if moving
unit.PauseMovement(WorldConfig.GetUIntValue(WorldCfg.CreatureStopForPlayer)); uint pause = unit.GetMovementTemplate().GetInteractionPauseTimer();
if (pause != 0)
unit.PauseMovement(pause);
unit.SetHomePosition(unit.GetPosition()); unit.SetHomePosition(unit.GetPosition());
// If spiritguide, no need for gossip menu, just put player into resurrect queue // If spiritguide, no need for gossip menu, just put player into resurrect queue
@@ -601,7 +603,9 @@ namespace Game
GetPlayer().RemoveAurasByType(AuraType.FeignDeath); GetPlayer().RemoveAurasByType(AuraType.FeignDeath);
// Stop the npc if moving // Stop the npc if moving
vendor.PauseMovement(WorldConfig.GetUIntValue(WorldCfg.CreatureStopForPlayer)); uint pause = vendor.GetMovementTemplate().GetInteractionPauseTimer();
if (pause != 0)
vendor.PauseMovement(pause);
vendor.SetHomePosition(vendor.GetPosition()); vendor.SetHomePosition(vendor.GetPosition());
VendorItemData vendorItems = vendor.GetVendorItems(); VendorItemData vendorItems = vendor.GetVendorItems();
+3 -1
View File
@@ -73,7 +73,9 @@ namespace Game
GetPlayer().RemoveAurasByType(AuraType.FeignDeath); GetPlayer().RemoveAurasByType(AuraType.FeignDeath);
// Stop the npc if moving // Stop the npc if moving
creature.PauseMovement(WorldConfig.GetUIntValue(WorldCfg.CreatureStopForPlayer)); uint pause = creature.GetMovementTemplate().GetInteractionPauseTimer();
if (pause != 0)
creature.PauseMovement(pause);
creature.SetHomePosition(creature.GetPosition()); creature.SetHomePosition(creature.GetPosition());
_player.PlayerTalkClass.ClearMenus(); _player.PlayerTalkClass.ClearMenus();