Core/Spells: Implement SPELL_EFFECT_ACTIVATE_OBJECT.

Port From (https://github.com/TrinityCore/TrinityCore/commit/e9cf3828bad44cf193d6c9717b392de7346157a5)
This commit is contained in:
hondacrx
2022-02-28 14:04:49 -05:00
parent 561b5a528d
commit ce4851a33a
8 changed files with 222 additions and 11 deletions
+136 -4
View File
@@ -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)]