Scripts/World: update guard scripts

Port From (https://github.com/TrinityCore/TrinityCore/commit/92026abee10325beedede84b07d5154a5a995b52)
This commit is contained in:
hondacrx
2021-02-18 12:45:47 -05:00
parent da273c3a06
commit 077c965c51
3 changed files with 3 additions and 101 deletions
+1 -3
View File
@@ -58,9 +58,7 @@ namespace Game.AI
me.GetThreatManager().ClearAllThreat();
me.CombatStop(true);
// Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead
if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Chase)
me.GetMotionMaster().MoveTargetedHome();
me.GetMotionMaster().MoveTargetedHome();
}
public override void JustDied(Unit killer)
-98
View File
@@ -1941,104 +1941,6 @@ namespace Game.Entities
return Convert.ToBoolean(GetCreatureTemplate().TypeFlags & CreatureTypeFlags.BossMob);
}
public SpellInfo ReachWithSpellAttack(Unit victim)
{
if (victim == null)
return null;
for (uint i = 0; i < SharedConst.MaxCreatureSpells; ++i)
{
if (m_spells[i] == 0)
continue;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(m_spells[i], GetMap().GetDifficultyID());
if (spellInfo == null)
{
Log.outError(LogFilter.Unit, "WORLD: unknown spell id {0}", m_spells[i]);
continue;
}
bool bcontinue = true;
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
{
if (effect != null && ((effect.Effect == SpellEffectName.SchoolDamage) || (effect.Effect == SpellEffectName.Instakill)
|| (effect.Effect == SpellEffectName.EnvironmentalDamage) || (effect.Effect == SpellEffectName.HealthLeech)))
{
bcontinue = false;
break;
}
}
if (bcontinue)
continue;
var costs = spellInfo.CalcPowerCost(this, spellInfo.SchoolMask);
var m = costs.Find(cost => cost.Power == PowerType.Mana);
if (m != null)
if (m.Amount > GetPower(PowerType.Mana))
continue;
float range = spellInfo.GetMaxRange(false);
float minrange = spellInfo.GetMinRange(false);
float dist = GetDistance(victim);
if (dist > range || dist < minrange)
continue;
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Silence) && HasUnitFlag(UnitFlags.Silenced))
continue;
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Pacify) && HasUnitFlag(UnitFlags.Pacified))
continue;
return spellInfo;
}
return null;
}
SpellInfo ReachWithSpellCure(Unit victim)
{
if (victim == null)
return null;
for (uint i = 0; i < SharedConst.MaxCreatureSpells; ++i)
{
if (m_spells[i] == 0)
continue;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(m_spells[i], GetMap().GetDifficultyID());
if (spellInfo == null)
{
Log.outError(LogFilter.Unit, "WORLD: unknown spell id {0}", m_spells[i]);
continue;
}
bool bcontinue = true;
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
{
if (effect != null && effect.Effect == SpellEffectName.Heal)
{
bcontinue = false;
break;
}
}
if (bcontinue)
continue;
var costs = spellInfo.CalcPowerCost(this, spellInfo.SchoolMask);
var m = costs.Find(cost => cost.Power == PowerType.Mana);
if (m != null)
if (m.Amount > GetPower(PowerType.Mana))
continue;
float range = spellInfo.GetMaxRange(true);
float minrange = spellInfo.GetMinRange(true);
float dist = GetDistance(victim);
if (dist > range || dist < minrange)
continue;
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Silence) && HasUnitFlag(UnitFlags.Silenced))
continue;
if (spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Pacify) && HasUnitFlag(UnitFlags.Pacified))
continue;
return spellInfo;
}
return null;
}
// select nearest hostile unit within the given distance (regardless of threat list).
public Unit SelectNearestTarget(float dist = 0)
{
@@ -0,0 +1,2 @@
UPDATE `creature_template` SET `ScriptName` = 'npc_guard_generic' WHERE `ScriptName` = 'guard_generic';
UPDATE `creature_template` SET `ScriptName` = 'npc_guard_shattrath_faction' WHERE `ScriptName` IN ('guard_shattrath_scryer', 'guard_shattrath_aldor');