Spells/Auras: Implement SPELL_AURA_ACT_AS_CONTROL_ZONE
Port From (https://github.com/TrinityCore/TrinityCore/commit/66abfd1c530e81f24856825f7ebe5a1c1ba8c58e)
This commit is contained in:
@@ -408,7 +408,7 @@ namespace Framework.Constants
|
|||||||
BattleGroundPlayerPosition = 398,
|
BattleGroundPlayerPosition = 398,
|
||||||
ModTimeRate = 399,
|
ModTimeRate = 399,
|
||||||
ModSkill2 = 400,
|
ModSkill2 = 400,
|
||||||
Unk401 = 401,
|
ActAsControlZone = 401,
|
||||||
ModOverridePowerDisplay = 402,
|
ModOverridePowerDisplay = 402,
|
||||||
OverrideSpellVisual = 403,
|
OverrideSpellVisual = 403,
|
||||||
OverrideAttackPowerBySpPct = 404,
|
OverrideAttackPowerBySpPct = 404,
|
||||||
|
|||||||
@@ -4697,7 +4697,7 @@ namespace Game.Entities
|
|||||||
if (Math.Abs(delta) < minSuperiority)
|
if (Math.Abs(delta) < minSuperiority)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
float slope = ((float)minTime - maxTime) / (maxSuperiority - minSuperiority);
|
float slope = ((float)minTime - maxTime) / Math.Max(maxSuperiority - minSuperiority, 1);
|
||||||
float intercept = maxTime - slope * minSuperiority;
|
float intercept = maxTime - slope * minSuperiority;
|
||||||
float timeNeeded = slope * Math.Abs(delta) + intercept;
|
float timeNeeded = slope * Math.Abs(delta) + intercept;
|
||||||
float percentageIncrease = 100.0f / timeNeeded;
|
float percentageIncrease = 100.0f / timeNeeded;
|
||||||
|
|||||||
@@ -689,6 +689,14 @@ namespace Game.Entities
|
|||||||
GetMap().PlayerRelocation(ToPlayer(), x, y, z, orientation);
|
GetMap().PlayerRelocation(ToPlayer(), x, y, z, orientation);
|
||||||
else
|
else
|
||||||
GetMap().CreatureRelocation(ToCreature(), x, y, z, orientation);
|
GetMap().CreatureRelocation(ToCreature(), x, y, z, orientation);
|
||||||
|
|
||||||
|
var controlZoneAuras = GetAuraEffectsByType(AuraType.ActAsControlZone);
|
||||||
|
foreach (AuraEffect auraEffect in controlZoneAuras)
|
||||||
|
{
|
||||||
|
GameObject controlZone = GetGameObject(auraEffect.GetSpellInfo().Id);
|
||||||
|
if (controlZone != null)
|
||||||
|
GetMap().GameObjectRelocation(controlZone, x, y, z, orientation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (turn)
|
else if (turn)
|
||||||
UpdateOrientation(orientation);
|
UpdateOrientation(orientation);
|
||||||
|
|||||||
@@ -6063,6 +6063,43 @@ namespace Game.Spells
|
|||||||
|
|
||||||
playerTarget.UpdatePositionData();
|
playerTarget.UpdatePositionData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AuraEffectHandler(AuraType.ActAsControlZone)]
|
||||||
|
void HandleAuraActAsControlZone(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
|
||||||
|
{
|
||||||
|
if (!mode.HasAnyFlag(AuraEffectHandleModes.Real))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Unit auraOwner = aurApp.GetTarget();
|
||||||
|
if (!apply)
|
||||||
|
{
|
||||||
|
auraOwner.RemoveGameObject(GetSpellInfo().Id, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObjectTemplate gameobjectTemplate = Global.ObjectMgr.GetGameObjectTemplate((uint)GetMiscValue());
|
||||||
|
if (gameobjectTemplate == null)
|
||||||
|
{
|
||||||
|
Log.outWarn(LogFilter.Spells, $"AuraEffect::HanldeAuraActAsControlZone: Spell {GetId()} [EffectIndex: {GetEffIndex()}] does not have an existing gameobject template.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameobjectTemplate.type != GameObjectTypes.ControlZone)
|
||||||
|
{
|
||||||
|
Log.outWarn(LogFilter.Spells, $"AuraEffect::HanldeAuraActAsControlZone: Spell {GetId()} [EffectIndex: {GetEffIndex()}] has a gameobject template ({gameobjectTemplate.entry}) that is not a control zone.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameobjectTemplate.displayId != 0)
|
||||||
|
{
|
||||||
|
Log.outWarn(LogFilter.Spells, $"AuraEffect::HanldeAuraActAsControlZone: Spell {GetId()} [EffectIndex: {GetEffIndex()}] has a gameobject template ({gameobjectTemplate.entry}) that has a display id. Only invisible gameobjects are supported.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObject controlZone = auraOwner.SummonGameObject(gameobjectTemplate.entry, auraOwner.GetPosition(), Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(aurApp.GetTarget().GetOrientation(), 0.0f, 0.0f)), TimeSpan.FromHours(24), GameObjectSummonType.TimedOrCorpseDespawn);
|
||||||
|
if (controlZone != null)
|
||||||
|
controlZone.SetSpellId(GetSpellInfo().Id);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user