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();
|
||||
|
||||
|
||||
@@ -1198,6 +1198,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
|
||||
(196,870),
|
||||
(196,871),
|
||||
(196,872),
|
||||
(196,873),
|
||||
(196,881),
|
||||
(197,232),
|
||||
(197,236),
|
||||
@@ -2130,6 +2131,7 @@ INSERT INTO `rbac_permissions` VALUES
|
||||
(870,'Command: debug threatinfo'),
|
||||
(871,'Command: debug instancespawn'),
|
||||
(872,'Command: server debug'),
|
||||
(873,'Command: reload creature_movement_override'),
|
||||
(881,'Command: reload vehicle_template');
|
||||
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
@@ -2347,6 +2349,7 @@ INSERT INTO `updates` VALUES
|
||||
('2018_02_18_00_auth.sql','8489DD3EFFE14A7486B593435F0BA2BC69B6EABF','ARCHIVED','2018-02-18 16:35:55',0),
|
||||
('2018_02_19_00_auth.sql','07CE658C5EF88693D3C047EF8E724F94ADA74C15','ARCHIVED','2018-02-19 22:33:32',0),
|
||||
('2018_02_28_00_auth.sql','E92EF4ABF7FA0C66649E1633DD0459F44C09EB83','ARCHIVED','2018-02-28 23:07:59',0),
|
||||
('2018_03_08_00_auth.sql','624C58A07E0B4DDC4C1347E8BA8EFEEFD5B43DA7','RELEASED','2018-01-12 15:10:11',0),
|
||||
('2018_03_14_00_auth.sql','2D71E93DF7419A30D0D21D8A80CF05698302575A','ARCHIVED','2018-03-14 23:07:59',0),
|
||||
('2018_04_06_00_auth.sql','D8416F0C4751763202B1997C81423F6EE2FCF9A6','ARCHIVED','2018-04-06 18:00:32',0),
|
||||
('2018_05_13_00_auth.sql','A9E20F2EB1E2FDBB982DB6B00DB7301852B27CD4','ARCHIVED','2018-05-13 20:22:32',0),
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
DELETE FROM `rbac_permissions` WHERE `id` = 873;
|
||||
INSERT INTO `rbac_permissions` (`id`,`name`) VALUES
|
||||
(873, 'Command: reload creature_movement_override');
|
||||
|
||||
DELETE FROM `rbac_linked_permissions` WHERE `linkedId` = 873;
|
||||
INSERT INTO `rbac_linked_permissions` (`id`,`linkedId`) VALUES
|
||||
(196, 873);
|
||||
@@ -0,0 +1,34 @@
|
||||
DROP TABLE IF EXISTS `creature_template_movement`;
|
||||
CREATE TABLE `creature_template_movement` (
|
||||
`CreatureId` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`Ground` tinyint(3) unsigned NOT NULL DEFAULT '1',
|
||||
`Swim` tinyint(3) unsigned NOT NULL DEFAULT '1',
|
||||
`Flight` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`Rooted` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`CreatureId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `creature_movement_override`;
|
||||
CREATE TABLE `creature_movement_override` (
|
||||
`SpawnId` bigint(20) unsigned NOT NULL DEFAULT '0',
|
||||
`Ground` tinyint(3) unsigned NOT NULL DEFAULT '1',
|
||||
`Swim` tinyint(3) unsigned NOT NULL DEFAULT '1',
|
||||
`Flight` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`Rooted` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`SpawnId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `creature_template_movement` SELECT `entry`,0,0,0,0 FROM `creature_template` WHERE `InhabitType`!=3;
|
||||
UPDATE `creature_template_movement` SET `Ground`=1 WHERE `CreatureId` IN (SELECT `entry` FROM `creature_template` WHERE `InhabitType` & 1);
|
||||
UPDATE `creature_template_movement` SET `Swim`=1 WHERE `CreatureId` IN (SELECT `entry` FROM `creature_template` WHERE `InhabitType` & 2);
|
||||
UPDATE `creature_template_movement` SET `Flight`=1 WHERE `CreatureId` IN (SELECT `entry` FROM `creature_template` WHERE (`InhabitType` & 5) = 4);
|
||||
UPDATE `creature_template_movement` SET `Flight`=2 WHERE `CreatureId` IN (SELECT `entry` FROM `creature_template` WHERE (`InhabitType` & 5) = 5);
|
||||
UPDATE `creature_template_movement` SET `Rooted`=1 WHERE `CreatureId` IN (SELECT `entry` FROM `creature_template` WHERE `InhabitType` & 8);
|
||||
|
||||
ALTER TABLE `creature_template` DROP `InhabitType`;
|
||||
|
||||
UPDATE `trinity_string` SET `content_default`='Movement type: %s' WHERE `entry`=11008;
|
||||
|
||||
DELETE FROM `command` WHERE `name`='reload creature_movement_override';
|
||||
INSERT INTO `command` (`name`,`permission`,`help`) VALUES
|
||||
('reload creature_movement_override',873,'Syntax: .reload creature_movement_override\nReload creature_movement_override table.');
|
||||
Reference in New Issue
Block a user