Core/Creatures: Reworked setting move types in database
Port From (https://github.com/TrinityCore/TrinityCore/commit/f8c03a90661610e289029c78d2055d7b73a5ad98)
This commit is contained in:
@@ -375,4 +375,22 @@ namespace Framework.Constants
|
||||
MembersAssistMember = (MembersAssistLeader | LeaderAssistsMember), // every member will assist if any member is attacked
|
||||
IdleInFormation = 0x200, // The member will follow the leader when pathing idly
|
||||
}
|
||||
|
||||
public enum CreatureGroundMovementType
|
||||
{
|
||||
None,
|
||||
Run,
|
||||
Hover,
|
||||
|
||||
Max
|
||||
}
|
||||
|
||||
public enum CreatureFlightMovementType
|
||||
{
|
||||
None,
|
||||
DisableGravity,
|
||||
CanFly,
|
||||
|
||||
Max
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1173,7 +1173,7 @@ namespace Framework.Constants
|
||||
BanAccountYoubannedmessageWorld = 11006,
|
||||
BanAccountYoupermbannedmessageWorld = 11007,
|
||||
|
||||
NpcinfoInhabitType = 11008,
|
||||
NpcinfoMovementData = 11008,
|
||||
NpcinfoFlagsExtra = 11009,
|
||||
InstanceLoginGamemasterException = 11010,
|
||||
|
||||
|
||||
@@ -76,7 +76,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, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, 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 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, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, VehicleId, mingold, maxgold, AIName, MovementType, ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, 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_");
|
||||
|
||||
@@ -121,5 +121,10 @@ namespace Framework.Database
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
public bool IsNull(int column)
|
||||
{
|
||||
return _currentRow[column] == DBNull.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Game.Chat
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoLevel, target.GetLevel());
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoEquipment, target.GetCurrentEquipmentId(), target.GetOriginalEquipmentId());
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoHealth, target.GetCreateHealth(), target.GetMaxHealth(), target.GetHealth());
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoInhabitType, cInfo.InhabitType);
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoMovementData, target.GetMovementTemplate().ToString());
|
||||
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoUnitFieldFlags, (uint)target.m_unitData.Flags);
|
||||
foreach (UnitFlags value in Enum.GetValues(typeof(UnitFlags)))
|
||||
|
||||
@@ -169,6 +169,15 @@ namespace Game.Chat
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("creature_movement_override", RBACPermissions.CommandReloadCreatureMovementOverride, true)]
|
||||
static bool HandleReloadCreatureMovementOverrideCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
Log.outInfo(LogFilter.Server, "Re-Loading Creature movement overrides...");
|
||||
Global.ObjectMgr.LoadCreatureMovementOverrides();
|
||||
handler.SendGlobalGMSysMessage("DB table `creature_movement_override` reloaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("creature_onkill_reputation", RBACPermissions.CommandReloadCreatureOnkillReputation, true)]
|
||||
static bool HandleReloadOnKillReputationCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
@@ -902,7 +911,7 @@ namespace Game.Chat
|
||||
handler.SendGlobalGMSysMessage("Vehicle templates reloaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
[Command("vehicle_template_accessory", RBACPermissions.CommandReloadVehicleTemplateAccessory, true)]
|
||||
static bool HandleReloadVehicleTemplateAccessoryCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
@@ -985,6 +994,7 @@ namespace Game.Chat
|
||||
HandleReloadCypherStringCommand(args, handler);
|
||||
HandleReloadGameTeleCommand(args, handler);
|
||||
|
||||
HandleReloadCreatureMovementOverrideCommand(args, handler);
|
||||
HandleReloadCreatureSummonGroupsCommand(args, handler);
|
||||
|
||||
HandleReloadVehicleAccessoryCommand(args, handler);
|
||||
@@ -1119,4 +1129,4 @@ namespace Game.Chat
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,7 +416,7 @@ namespace Game.Entities
|
||||
ApplySpellImmune(0, SpellImmunity.Effect, SpellEffectName.AttackMe, true);
|
||||
}
|
||||
|
||||
if (cInfo.InhabitType.HasAnyFlag(InhabitType.Root))
|
||||
if (GetMovementTemplate().IsRooted())
|
||||
SetControlled(true, UnitState.Root);
|
||||
|
||||
UpdateMovementFlags();
|
||||
@@ -2311,7 +2311,7 @@ namespace Game.Entities
|
||||
dist += GetCombatReach() + victim.GetCombatReach();
|
||||
|
||||
// to prevent creatures in air ignore attacks because distance is already too high...
|
||||
if (GetCreatureTemplate().InhabitType.HasAnyFlag(InhabitType.Air))
|
||||
if (GetMovementTemplate().IsFlightAllowed())
|
||||
return victim.IsInDist2d(m_homePosition, dist);
|
||||
else
|
||||
return victim.IsInDist(m_homePosition, dist);
|
||||
@@ -2356,7 +2356,7 @@ namespace Game.Entities
|
||||
//! Check using InhabitType as movement flags are assigned dynamically
|
||||
//! basing on whether the creature is in air or not
|
||||
//! Set MovementFlag_Hover. Otherwise do nothing.
|
||||
if (Convert.ToBoolean(m_unitData.AnimTier & (byte)UnitBytes1Flags.Hover) && !Convert.ToBoolean(GetCreatureTemplate().InhabitType & InhabitType.Air))
|
||||
if (CanHover())
|
||||
AddUnitMovementFlag(MovementFlag.Hover);
|
||||
}
|
||||
|
||||
@@ -2463,6 +2463,15 @@ namespace Game.Entities
|
||||
|
||||
bool IsSpawnedOnTransport() { return m_creatureData != null && m_creatureData.spawnPoint.GetMapId() != GetMapId(); }
|
||||
|
||||
public CreatureMovementData GetMovementTemplate()
|
||||
{
|
||||
CreatureMovementData movementOverride = Global.ObjectMgr.GetCreatureMovementOverride(m_spawnId);
|
||||
if (movementOverride != null)
|
||||
return movementOverride;
|
||||
|
||||
return GetCreatureTemplate().Movement;
|
||||
}
|
||||
|
||||
public void AllLootRemovedFromCorpse()
|
||||
{
|
||||
if (loot.loot_type != LootType.Skinning && !IsPet() && GetCreatureTemplate().SkinLootId != 0 && HasLootRecipient())
|
||||
@@ -2822,25 +2831,31 @@ namespace Game.Entities
|
||||
// Set the movement flags if the creature is in that mode. (Only fly if actually in air, only swim if in water, etc)
|
||||
float ground = GetFloorZ();
|
||||
|
||||
bool isInAir = (MathFunctions.fuzzyGt(GetPositionZ(), ground + MapConst.GroundHeightTolerance) || MathFunctions.fuzzyLt(GetPositionZ(), ground - MapConst.GroundHeightTolerance)); // Can be underground too, prevent the falling
|
||||
bool canHover = CanHover();
|
||||
bool isInAir = (MathFunctions.fuzzyGt(GetPositionZ(), ground + (canHover ? m_unitData.HoverHeight : 0.0f) + MapConst.GroundHeightTolerance) || MathFunctions.fuzzyLt(GetPositionZ(), ground - MapConst.GroundHeightTolerance)); // Can be underground too, prevent the falling
|
||||
|
||||
if (GetCreatureTemplate().InhabitType.HasAnyFlag(InhabitType.Air) && isInAir && !IsFalling())
|
||||
if (GetMovementTemplate().IsFlightAllowed() && isInAir && !IsFalling())
|
||||
{
|
||||
if (GetCreatureTemplate().InhabitType.HasAnyFlag(InhabitType.Ground))
|
||||
if (GetMovementTemplate().Flight == CreatureFlightMovementType.CanFly)
|
||||
SetCanFly(true);
|
||||
else
|
||||
SetDisableGravity(true);
|
||||
|
||||
if (!HasAuraType(AuraType.Hover))
|
||||
SetHover(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCanFly(false);
|
||||
SetDisableGravity(false);
|
||||
if (CanHover() || HasAuraType(AuraType.Hover))
|
||||
SetHover(true);
|
||||
}
|
||||
|
||||
if (!isInAir)
|
||||
SetFall(false);
|
||||
|
||||
SetSwim(GetCreatureTemplate().InhabitType.HasAnyFlag(InhabitType.Water) && IsInWater());
|
||||
SetSwim(GetMovementTemplate().IsSwimAllowed() && IsInWater());
|
||||
}
|
||||
|
||||
public override void SetObjectScale(float scale)
|
||||
@@ -3034,18 +3049,12 @@ namespace Game.Entities
|
||||
{
|
||||
return GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.Guard);
|
||||
}
|
||||
public bool CanWalk()
|
||||
{
|
||||
return GetCreatureTemplate().InhabitType.HasAnyFlag(InhabitType.Ground);
|
||||
}
|
||||
public override bool CanSwim()
|
||||
{
|
||||
return GetCreatureTemplate().InhabitType.HasAnyFlag(InhabitType.Water);
|
||||
}
|
||||
public override bool CanFly()
|
||||
{
|
||||
return GetCreatureTemplate().InhabitType.HasAnyFlag(InhabitType.Air);
|
||||
}
|
||||
|
||||
public bool CanWalk() { return GetMovementTemplate().IsGroundAllowed(); }
|
||||
public override bool CanSwim() { return GetMovementTemplate().IsSwimAllowed() || IsPet();}
|
||||
public override bool CanFly() { return GetMovementTemplate().IsFlightAllowed(); }
|
||||
bool CanHover() { return GetMovementTemplate().Ground == CreatureGroundMovementType.Hover; }
|
||||
|
||||
public bool IsDungeonBoss() { return (GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.DungeonBoss)); }
|
||||
public override bool IsAffectedByDiminishingReturns() { return base.IsAffectedByDiminishingReturns() || GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.AllDiminish); }
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Game.Entities
|
||||
public uint MaxGold;
|
||||
public string AIName;
|
||||
public uint MovementType;
|
||||
public InhabitType InhabitType;
|
||||
public CreatureMovementData Movement;
|
||||
public float HoverHeight;
|
||||
public float ModHealth;
|
||||
public float ModHealthExtra;
|
||||
@@ -347,6 +347,34 @@ namespace Game.Entities
|
||||
public CreatureData() : base(SpawnObjectType.Creature) { }
|
||||
}
|
||||
|
||||
public class CreatureMovementData
|
||||
{
|
||||
public CreatureGroundMovementType Ground;
|
||||
public CreatureFlightMovementType Flight;
|
||||
public bool Swim;
|
||||
public bool Rooted;
|
||||
|
||||
public CreatureMovementData()
|
||||
{
|
||||
Ground = CreatureGroundMovementType.Run;
|
||||
Flight = CreatureFlightMovementType.None;
|
||||
Swim = true;
|
||||
Rooted = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IsGroundAllowed() { return Ground != CreatureGroundMovementType.None; }
|
||||
bool IsSwimAllowed() { return Swim; }
|
||||
bool IsFlightAllowed() { return Flight != CreatureFlightMovementType.None; }
|
||||
bool IsRooted() { return Rooted; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Ground: {Ground}, Swim: {Swim}, Flight: {Flight} {(Rooted ? ", Rooted" : "")}";
|
||||
}
|
||||
}
|
||||
|
||||
public class CreatureModelInfo
|
||||
{
|
||||
public float BoundingRadius;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -616,6 +616,9 @@ namespace Game
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading Creature Addon Data...");
|
||||
Global.ObjectMgr.LoadCreatureAddons();
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading Creature Movement Overrides...");
|
||||
Global.ObjectMgr.LoadCreatureMovementOverrides(); // must be after LoadCreatures()
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading GameObjects...");
|
||||
Global.ObjectMgr.LoadGameObjects();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user