Core/Spells: Implement SPELL_EFFECT_ACTIVATE_OBJECT.
Port From (https://github.com/TrinityCore/TrinityCore/commit/e9cf3828bad44cf193d6c9717b392de7346157a5)
This commit is contained in:
@@ -143,6 +143,7 @@ namespace Game.DataStorage
|
||||
FactionTemplateStorage = ReadDB2<FactionTemplateRecord>("FactionTemplate.db2", HotfixStatements.SEL_FACTION_TEMPLATE);
|
||||
FriendshipRepReactionStorage = ReadDB2<FriendshipRepReactionRecord>("FriendshipRepReaction.db2", HotfixStatements.SEL_FRIENDSHIP_REP_REACTION, HotfixStatements.SEL_FRIENDSHIP_REP_REACTION_LOCALE);
|
||||
FriendshipReputationStorage = ReadDB2<FriendshipReputationRecord>("FriendshipReputation.db2", HotfixStatements.SEL_FRIENDSHIP_REPUTATION, HotfixStatements.SEL_FRIENDSHIP_REPUTATION_LOCALE);
|
||||
GameObjectArtKitStorage = ReadDB2<GameObjectArtKitRecord>("GameObjectArtKit.db2", HotfixStatements.SEL_GAMEOBJECT_ART_KIT);
|
||||
GameObjectDisplayInfoStorage = ReadDB2<GameObjectDisplayInfoRecord>("GameObjectDisplayInfo.db2", HotfixStatements.SEL_GAMEOBJECT_DISPLAY_INFO);
|
||||
GameObjectsStorage = ReadDB2<GameObjectsRecord>("GameObjects.db2", HotfixStatements.SEL_GAMEOBJECTS, HotfixStatements.SEL_GAMEOBJECTS_LOCALE);
|
||||
GarrAbilityStorage = ReadDB2<GarrAbilityRecord>("GarrAbility.db2", HotfixStatements.SEL_GARR_ABILITY, HotfixStatements.SEL_GARR_ABILITY_LOCALE);
|
||||
@@ -533,8 +534,9 @@ namespace Game.DataStorage
|
||||
public static DB6Storage<FactionTemplateRecord> FactionTemplateStorage;
|
||||
public static DB6Storage<FriendshipRepReactionRecord> FriendshipRepReactionStorage;
|
||||
public static DB6Storage<FriendshipReputationRecord> FriendshipReputationStorage;
|
||||
public static DB6Storage<GameObjectsRecord> GameObjectsStorage;
|
||||
public static DB6Storage<GameObjectArtKitRecord> GameObjectArtKitStorage;
|
||||
public static DB6Storage<GameObjectDisplayInfoRecord> GameObjectDisplayInfoStorage;
|
||||
public static DB6Storage<GameObjectsRecord> GameObjectsStorage;
|
||||
public static DB6Storage<GarrAbilityRecord> GarrAbilityStorage;
|
||||
public static DB6Storage<GarrBuildingRecord> GarrBuildingStorage;
|
||||
public static DB6Storage<GarrBuildingPlotInstRecord> GarrBuildingPlotInstStorage;
|
||||
|
||||
@@ -20,6 +20,13 @@ using System.Numerics;
|
||||
|
||||
namespace Game.DataStorage
|
||||
{
|
||||
public sealed class GameObjectArtKitRecord
|
||||
{
|
||||
public uint Id;
|
||||
public int AttachModelFileID;
|
||||
public int[] TextureVariationFileID = new int[3];
|
||||
}
|
||||
|
||||
public sealed class GameObjectDisplayInfoRecord
|
||||
{
|
||||
public uint Id;
|
||||
|
||||
@@ -2880,7 +2880,7 @@ namespace Game.Entities
|
||||
SendMessageToSet(activateAnimKit, true);
|
||||
}
|
||||
|
||||
void SetSpellVisualId(uint spellVisualId, ObjectGuid activatorGuid = default)
|
||||
public void SetSpellVisualId(uint spellVisualId, ObjectGuid activatorGuid = default)
|
||||
{
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.SpellVisualID), spellVisualId);
|
||||
|
||||
|
||||
@@ -1410,6 +1410,7 @@ namespace Game.Entities
|
||||
{
|
||||
public uint Mingold;
|
||||
public uint Maxgold;
|
||||
public uint[] ArtKits = new uint[5];
|
||||
public uint WorldEffectID;
|
||||
public uint AIAnimKitID;
|
||||
}
|
||||
|
||||
@@ -4072,8 +4072,8 @@ namespace Game
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// 0 1 2 3 4 5 6
|
||||
SQLResult result = DB.World.Query("SELECT entry, faction, flags, mingold, maxgold, WorldEffectID, AIAnimKitID FROM gameobject_template_addon");
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11
|
||||
SQLResult result = DB.World.Query("SELECT entry, faction, flags, mingold, maxgold, artkit0, artkit1, artkit2, artkit3, artkit4, WorldEffectID, AIAnimKitID FROM gameobject_template_addon");
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 gameobject template addon definitions. DB table `gameobject_template_addon` is empty.");
|
||||
@@ -4097,8 +4097,23 @@ namespace Game
|
||||
gameObjectAddon.Flags = (GameObjectFlags)result.Read<uint>(2);
|
||||
gameObjectAddon.Mingold = result.Read<uint>(3);
|
||||
gameObjectAddon.Maxgold = result.Read<uint>(4);
|
||||
gameObjectAddon.WorldEffectID = result.Read<uint>(5);
|
||||
gameObjectAddon.AIAnimKitID = result.Read<uint>(6);
|
||||
gameObjectAddon.WorldEffectID = result.Read<uint>(10);
|
||||
gameObjectAddon.AIAnimKitID = result.Read<uint>(11);
|
||||
|
||||
for (int i = 0; i < gameObjectAddon.ArtKits.Length; ++i)
|
||||
{
|
||||
uint artKitID = result.Read<uint>(5 + i);
|
||||
if (artKitID == 0)
|
||||
continue;
|
||||
|
||||
if (!CliDB.GameObjectArtKitStorage.ContainsKey(artKitID))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"GameObject (Entry: {entry}) has invalid `artkit{i}` ({artKitID}) defined, set to zero instead.");
|
||||
continue;
|
||||
}
|
||||
|
||||
gameObjectAddon.ArtKits[i] = artKitID;
|
||||
}
|
||||
|
||||
// checks
|
||||
if (gameObjectAddon.Faction != 0 && !CliDB.FactionTemplateStorage.ContainsKey(gameObjectAddon.Faction))
|
||||
|
||||
@@ -3020,12 +3020,144 @@ namespace Game.Spells
|
||||
if (gameObjTarget == null)
|
||||
return;
|
||||
|
||||
ScriptInfo activateCommand = new();
|
||||
activateCommand.command = ScriptCommands.ActivateObject;
|
||||
GameObjectActions action = (GameObjectActions)effectInfo.MiscValue;
|
||||
|
||||
// int unk = effectInfo.MiscValue; // This is set for EffectActivateObject spells; needs research
|
||||
switch (action)
|
||||
{
|
||||
case GameObjectActions.AnimateCustom0:
|
||||
case GameObjectActions.AnimateCustom1:
|
||||
case GameObjectActions.AnimateCustom2:
|
||||
case GameObjectActions.AnimateCustom3:
|
||||
gameObjTarget.SendCustomAnim((uint)(action - GameObjectActions.AnimateCustom0));
|
||||
break;
|
||||
case GameObjectActions.Disturb: // What's the difference with Open?
|
||||
case GameObjectActions.Open:
|
||||
{
|
||||
Unit unitCaster = m_caster.ToUnit();
|
||||
if (unitCaster != null)
|
||||
gameObjTarget.Use(unitCaster);
|
||||
break;
|
||||
}
|
||||
case GameObjectActions.OpenAndUnlock:
|
||||
{
|
||||
Unit unitCaster = m_caster.ToUnit();
|
||||
if (unitCaster != null)
|
||||
gameObjTarget.UseDoorOrButton(0, false, unitCaster);
|
||||
|
||||
gameObjTarget.GetMap().ScriptCommandStart(activateCommand, 0, m_caster, gameObjTarget);
|
||||
gameObjTarget.RemoveFlag(GameObjectFlags.Locked);
|
||||
break;
|
||||
}
|
||||
case GameObjectActions.Unlock:
|
||||
gameObjTarget.RemoveFlag(GameObjectFlags.Locked);
|
||||
break;
|
||||
case GameObjectActions.Lock:
|
||||
gameObjTarget.AddFlag(GameObjectFlags.Locked);
|
||||
break;
|
||||
case GameObjectActions.Close:
|
||||
case GameObjectActions.Rebuild:
|
||||
gameObjTarget.ResetDoorOrButton();
|
||||
break;
|
||||
case GameObjectActions.Despawn:
|
||||
gameObjTarget.DespawnOrUnsummon();
|
||||
break;
|
||||
case GameObjectActions.MakeInert:
|
||||
gameObjTarget.AddFlag(GameObjectFlags.NotSelectable);
|
||||
break;
|
||||
case GameObjectActions.MakeActive:
|
||||
gameObjTarget.RemoveFlag(GameObjectFlags.NotSelectable);
|
||||
break;
|
||||
case GameObjectActions.CloseAndLock:
|
||||
gameObjTarget.ResetDoorOrButton();
|
||||
gameObjTarget.AddFlag(GameObjectFlags.Locked);
|
||||
break;
|
||||
case GameObjectActions.Destroy:
|
||||
{
|
||||
Unit unitCaster = m_caster.ToUnit();
|
||||
if (unitCaster != null)
|
||||
gameObjTarget.UseDoorOrButton(0, true, unitCaster);
|
||||
break;
|
||||
}
|
||||
case GameObjectActions.UseArtKit0:
|
||||
case GameObjectActions.UseArtKit1:
|
||||
case GameObjectActions.UseArtKit2:
|
||||
case GameObjectActions.UseArtKit3:
|
||||
case GameObjectActions.UseArtKit4:
|
||||
{
|
||||
GameObjectTemplateAddon templateAddon = gameObjTarget.GetTemplateAddon();
|
||||
|
||||
uint artKitIndex = action != GameObjectActions.UseArtKit4 ? (uint)(action - GameObjectActions.UseArtKit0) : 4;
|
||||
uint artKitValue = 0;
|
||||
if (templateAddon != null)
|
||||
artKitValue = templateAddon.ArtKits[artKitIndex];
|
||||
|
||||
if (artKitValue == 0)
|
||||
Log.outError(LogFilter.Sql, $"GameObject {gameObjTarget.GetEntry()} hit by spell {m_spellInfo.Id} needs `artkit{artKitIndex}` in `gameobject_template_addon`");
|
||||
else
|
||||
gameObjTarget.SetGoArtKit((byte)artKitValue);
|
||||
|
||||
break;
|
||||
}
|
||||
case GameObjectActions.GoTo1stFloor:
|
||||
case GameObjectActions.GoTo2ndFloor:
|
||||
case GameObjectActions.GoTo3rdFloor:
|
||||
case GameObjectActions.GoTo4thFloor:
|
||||
case GameObjectActions.GoTo5thFloor:
|
||||
case GameObjectActions.GoTo6thFloor:
|
||||
case GameObjectActions.GoTo7thFloor:
|
||||
case GameObjectActions.GoTo8thFloor:
|
||||
case GameObjectActions.GoTo9thFloor:
|
||||
case GameObjectActions.GoTo10thFloor:
|
||||
if (gameObjTarget.GetGoType() == GameObjectTypes.Transport)
|
||||
gameObjTarget.SetTransportState(GameObjectState.TransportStopped, (uint)(action - GameObjectActions.GoTo1stFloor));
|
||||
else
|
||||
Log.outError(LogFilter.Spells, $"Spell {m_spellInfo.Id} targeted non-transport gameobject for transport only action \"Go to Floor\" {action} in effect {effectInfo.EffectIndex}");
|
||||
break;
|
||||
case GameObjectActions.PlayAnimKit:
|
||||
gameObjTarget.SetAnimKitId((ushort)effectInfo.MiscValueB, false);
|
||||
break;
|
||||
case GameObjectActions.OpenAndPlayAnimKit:
|
||||
{
|
||||
Unit unitCaster = m_caster.ToUnit();
|
||||
if (unitCaster != null)
|
||||
gameObjTarget.UseDoorOrButton(0, false, unitCaster);
|
||||
gameObjTarget.SetAnimKitId((ushort)effectInfo.MiscValueB, false);
|
||||
break;
|
||||
}
|
||||
case GameObjectActions.CloseAndPlayAnimKit:
|
||||
gameObjTarget.ResetDoorOrButton();
|
||||
gameObjTarget.SetAnimKitId((ushort)effectInfo.MiscValueB, false);
|
||||
break;
|
||||
case GameObjectActions.PlayOneShotAnimKit:
|
||||
gameObjTarget.SetAnimKitId((ushort)effectInfo.MiscValueB, true);
|
||||
break;
|
||||
case GameObjectActions.StopAnimKit:
|
||||
gameObjTarget.SetAnimKitId(0, false);
|
||||
break;
|
||||
case GameObjectActions.OpenAndStopAnimKit:
|
||||
{
|
||||
Unit unitCaster = m_caster.ToUnit();
|
||||
if (unitCaster != null)
|
||||
gameObjTarget.UseDoorOrButton(0, false, unitCaster);
|
||||
gameObjTarget.SetAnimKitId(0, false);
|
||||
break;
|
||||
}
|
||||
case GameObjectActions.CloseAndStopAnimKit:
|
||||
gameObjTarget.ResetDoorOrButton();
|
||||
gameObjTarget.SetAnimKitId(0, false);
|
||||
break;
|
||||
case GameObjectActions.PlaySpellVisual:
|
||||
gameObjTarget.SetSpellVisualId((ushort)effectInfo.MiscValueB, m_originalCasterGUID);
|
||||
break;
|
||||
case GameObjectActions.StopSpellVisual:
|
||||
gameObjTarget.SetSpellVisualId(0);
|
||||
break;
|
||||
case GameObjectActions.None:
|
||||
Log.outFatal(LogFilter.Spells, $"Spell {m_spellInfo.Id} has action type NONE in effect {effectInfo.EffectIndex}");
|
||||
break;
|
||||
default:
|
||||
Log.outFatal(LogFilter.Spells, $"Spell {m_spellInfo.Id} has unhandled action {action} in effect {effectInfo.EffectIndex}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[SpellEffectHandler(SpellEffectName.ApplyGlyph)]
|
||||
|
||||
Reference in New Issue
Block a user