Core/Creature: Add new db field InteractionPauseTimer
Port From (https://github.com/TrinityCore/TrinityCore/commit/5180abfb19b9c1c4f2df2fbfa918a62f1c4ae995)
This commit is contained in:
@@ -75,7 +75,7 @@ namespace Framework.Database
|
||||
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.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_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_");
|
||||
|
||||
@@ -354,6 +354,7 @@ namespace Game.Entities
|
||||
public bool Rooted;
|
||||
public CreatureChaseMovementType Chase;
|
||||
public CreatureRandomMovementType Random;
|
||||
public uint InteractionPauseTimer;
|
||||
|
||||
public CreatureMovementData()
|
||||
{
|
||||
@@ -361,6 +362,9 @@ namespace Game.Entities
|
||||
Flight = CreatureFlightMovementType.None;
|
||||
Swim = true;
|
||||
Rooted = false;
|
||||
Chase = CreatureChaseMovementType.Run;
|
||||
Random = CreatureRandomMovementType.Walk;
|
||||
InteractionPauseTimer = WorldConfig.GetIntValue(WorldCfg.CreatureStopForPlayer);
|
||||
}
|
||||
|
||||
public bool IsGroundAllowed() { return Ground != CreatureGroundMovementType.None; }
|
||||
@@ -371,9 +375,11 @@ namespace Game.Entities
|
||||
public CreatureChaseMovementType GetChase() { return Chase; }
|
||||
public CreatureRandomMovementType GetRandom() { return Random; }
|
||||
|
||||
public uint GetInteractionPauseTimer() { return InteractionPauseTimer; }
|
||||
|
||||
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}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1841,24 +1841,27 @@ namespace Game
|
||||
if (!fields.IsNull(51))
|
||||
creature.Movement.Random = (CreatureRandomMovementType)fields.Read<byte>(51);
|
||||
|
||||
creature.HoverHeight = fields.Read<float>(52);
|
||||
creature.ModHealth = fields.Read<float>(53);
|
||||
creature.ModHealthExtra = fields.Read<float>(54);
|
||||
creature.ModMana = fields.Read<float>(55);
|
||||
creature.ModManaExtra = fields.Read<float>(56);
|
||||
creature.ModArmor = fields.Read<float>(57);
|
||||
creature.ModDamage = fields.Read<float>(58);
|
||||
creature.ModExperience = fields.Read<float>(59);
|
||||
creature.RacialLeader = fields.Read<bool>(60);
|
||||
creature.MovementId = fields.Read<uint>(61);
|
||||
creature.CreatureDifficultyID = fields.Read<int>(62);
|
||||
creature.WidgetSetID = fields.Read<int>(63);
|
||||
creature.WidgetSetUnitConditionID = fields.Read<int>(64);
|
||||
creature.RegenHealth = fields.Read<bool>(65);
|
||||
creature.MechanicImmuneMask = fields.Read<uint>(66);
|
||||
creature.SpellSchoolImmuneMask = fields.Read<uint>(67);
|
||||
creature.FlagsExtra = (CreatureFlagsExtra)fields.Read<uint>(68);
|
||||
creature.ScriptID = GetScriptId(fields.Read<string>(69));
|
||||
if (!fields.IsNull(52))
|
||||
creature.Movement.InteractionPauseTimer = fields.Read<uint>(52);
|
||||
|
||||
creature.HoverHeight = fields.Read<float>(53);
|
||||
creature.ModHealth = fields.Read<float>(54);
|
||||
creature.ModHealthExtra = fields.Read<float>(55);
|
||||
creature.ModMana = fields.Read<float>(56);
|
||||
creature.ModManaExtra = fields.Read<float>(57);
|
||||
creature.ModArmor = fields.Read<float>(58);
|
||||
creature.ModDamage = fields.Read<float>(59);
|
||||
creature.ModExperience = fields.Read<float>(60);
|
||||
creature.RacialLeader = fields.Read<bool>(61);
|
||||
creature.MovementId = fields.Read<uint>(62);
|
||||
creature.CreatureDifficultyID = fields.Read<int>(63);
|
||||
creature.WidgetSetID = fields.Read<int>(64);
|
||||
creature.WidgetSetUnitConditionID = fields.Read<int>(65);
|
||||
creature.RegenHealth = fields.Read<bool>(66);
|
||||
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;
|
||||
}
|
||||
@@ -2346,7 +2349,10 @@ namespace Game
|
||||
|
||||
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())
|
||||
{
|
||||
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();
|
||||
movement.Ground = (CreatureGroundMovementType)result.Read<byte>(1);
|
||||
movement.Swim = result.Read<bool>(2);
|
||||
movement.Flight = (CreatureFlightMovementType)result.Read<byte>(3);
|
||||
movement.Rooted = result.Read<bool>(4);
|
||||
movement.Chase = (CreatureChaseMovementType)result.Read<byte>(5);
|
||||
movement.Random = (CreatureRandomMovementType)result.Read<byte>(6);
|
||||
if (!result.IsNull(1))
|
||||
movement.Ground = (CreatureGroundMovementType)result.Read<byte>(1);
|
||||
if (!result.IsNull(2))
|
||||
movement.Swim = result.Read<bool>(2);
|
||||
if (!result.IsNull(3))
|
||||
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);
|
||||
|
||||
|
||||
@@ -39,7 +39,9 @@ namespace Game
|
||||
return;
|
||||
|
||||
// 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());
|
||||
|
||||
BattlegroundTypeId bgTypeId = Global.BattlegroundMgr.GetBattleMasterBG(unit.GetEntry());
|
||||
|
||||
@@ -144,7 +144,9 @@ namespace Game
|
||||
GetPlayer().RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Interacting);
|
||||
|
||||
// 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());
|
||||
|
||||
// If spiritguide, no need for gossip menu, just put player into resurrect queue
|
||||
@@ -601,7 +603,9 @@ namespace Game
|
||||
GetPlayer().RemoveAurasByType(AuraType.FeignDeath);
|
||||
|
||||
// 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());
|
||||
|
||||
VendorItemData vendorItems = vendor.GetVendorItems();
|
||||
|
||||
@@ -73,7 +73,9 @@ namespace Game
|
||||
GetPlayer().RemoveAurasByType(AuraType.FeignDeath);
|
||||
|
||||
// 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());
|
||||
|
||||
_player.PlayerTalkClass.ClearMenus();
|
||||
|
||||
Reference in New Issue
Block a user