Some refactoring of code. and some cleanups
This commit is contained in:
@@ -99,7 +99,7 @@ namespace Game.AI
|
||||
|
||||
public static IMovementGenerator SelectMovementAI(Creature creature)
|
||||
{
|
||||
switch (creature.m_defaultMovementType)
|
||||
switch (creature.DefaultMovementType)
|
||||
{
|
||||
case MovementGeneratorType.Random:
|
||||
return new RandomMovementGenerator();
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Game.AI
|
||||
Unit summoner = creature.ToTempSummon().GetSummoner();
|
||||
if (summoner != null)
|
||||
{
|
||||
Unit target = summoner.getAttackerForHelper();
|
||||
Unit target = summoner.GetAttackerForHelper();
|
||||
if (target == null && summoner.CanHaveThreatList() && !summoner.GetThreatManager().isThreatListEmpty())
|
||||
target = summoner.GetThreatManager().getHostilTarget();
|
||||
if (target != null && (creature.IsFriendlyTo(summoner) || creature.IsHostileTo(target)))
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Game.AI
|
||||
|
||||
public override bool CanSeeAlways(WorldObject obj)
|
||||
{
|
||||
if (!obj.isTypeMask(TypeMask.Unit))
|
||||
if (!obj.IsTypeMask(TypeMask.Unit))
|
||||
return false;
|
||||
|
||||
var threatList = me.GetThreatManager().getThreatList();
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Game.AI
|
||||
|
||||
public override void UpdateAI(uint diff)
|
||||
{
|
||||
if (me.IsInCombat() && me.getAttackers().Empty())
|
||||
if (me.IsInCombat() && me.GetAttackers().Empty())
|
||||
EnterEvadeMode(EvadeReason.NoHostiles);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Game.AI
|
||||
me.GetMotionMaster().Clear();
|
||||
me.GetMotionMaster().MoveIdle();
|
||||
me.CombatStop();
|
||||
me.getHostileRefManager().deleteReferences();
|
||||
me.GetHostileRefManager().deleteReferences();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -163,9 +163,9 @@ namespace Game.AI
|
||||
|
||||
// Some spells can target enemy or friendly (DK Ghoul's Leap)
|
||||
// Check for enemy first (pet then owner)
|
||||
Unit target = me.getAttackerForHelper();
|
||||
Unit target = me.GetAttackerForHelper();
|
||||
if (!target && owner)
|
||||
target = owner.getAttackerForHelper();
|
||||
target = owner.GetAttackerForHelper();
|
||||
|
||||
if (target)
|
||||
{
|
||||
@@ -372,7 +372,7 @@ namespace Game.AI
|
||||
return null;
|
||||
|
||||
// Check pet attackers first so we don't drag a bunch of targets to the owner
|
||||
Unit myAttacker = me.getAttackerForHelper();
|
||||
Unit myAttacker = me.GetAttackerForHelper();
|
||||
if (myAttacker)
|
||||
if (!myAttacker.HasBreakableByDamageCrowdControlAura())
|
||||
return myAttacker;
|
||||
@@ -382,7 +382,7 @@ namespace Game.AI
|
||||
return null;
|
||||
|
||||
// Check owner attackers
|
||||
Unit ownerAttacker = me.GetCharmerOrOwner().getAttackerForHelper();
|
||||
Unit ownerAttacker = me.GetCharmerOrOwner().GetAttackerForHelper();
|
||||
if (ownerAttacker)
|
||||
if (!ownerAttacker.HasBreakableByDamageCrowdControlAura())
|
||||
return ownerAttacker;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Game.AI
|
||||
Unit victim = !i_victimGuid.IsEmpty() ? Global.ObjAccessor.GetUnit(me, i_victimGuid) : null;
|
||||
|
||||
// Search victim if no, not attackable, or out of range, or friendly (possible in case duel end)
|
||||
if (victim == null || !victim.isTargetableForAttack() || !me.IsWithinDistInMap(victim, max_range) ||
|
||||
if (victim == null || !victim.IsTargetableForAttack() || !me.IsWithinDistInMap(victim, max_range) ||
|
||||
me.IsFriendlyTo(victim) || !me.CanSeeOrDetect(victim))
|
||||
{
|
||||
var u_check = new NearestAttackableUnitInObjectRangeCheck(me, me.GetCharmerOrOwnerOrSelf(), max_range);
|
||||
|
||||
@@ -73,22 +73,22 @@ namespace Game.AI
|
||||
return;
|
||||
|
||||
//Make sure our attack is ready and we aren't currently casting before checking distance
|
||||
if (me.isAttackReady())
|
||||
if (me.IsAttackReady())
|
||||
{
|
||||
me.AttackerStateUpdate(victim);
|
||||
me.resetAttackTimer();
|
||||
me.ResetAttackTimer();
|
||||
}
|
||||
|
||||
if (me.haveOffhandWeapon() && me.isAttackReady(WeaponAttackType.OffAttack))
|
||||
if (me.HaveOffhandWeapon() && me.IsAttackReady(WeaponAttackType.OffAttack))
|
||||
{
|
||||
me.AttackerStateUpdate(victim, WeaponAttackType.OffAttack);
|
||||
me.resetAttackTimer(WeaponAttackType.OffAttack);
|
||||
me.ResetAttackTimer(WeaponAttackType.OffAttack);
|
||||
}
|
||||
}
|
||||
|
||||
public bool DoSpellAttackIfReady(uint spell)
|
||||
{
|
||||
if (me.HasUnitState(UnitState.Casting) || !me.isAttackReady())
|
||||
if (me.HasUnitState(UnitState.Casting) || !me.IsAttackReady())
|
||||
return true;
|
||||
|
||||
var spellInfo = Global.SpellMgr.GetSpellInfo(spell);
|
||||
@@ -97,7 +97,7 @@ namespace Game.AI
|
||||
if (me.IsWithinCombatRange(me.GetVictim(), spellInfo.GetMaxRange(false)))
|
||||
{
|
||||
me.CastSpell(me.GetVictim(), spellInfo, TriggerCastFlags.None);
|
||||
me.resetAttackTimer();
|
||||
me.ResetAttackTimer();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -507,7 +507,7 @@ namespace Game.AI
|
||||
minRange += rangeMod;
|
||||
}
|
||||
|
||||
if (_caster.isMoving() && target.isMoving() && !_caster.IsWalking() && !target.IsWalking() &&
|
||||
if (_caster.IsMoving() && target.IsMoving() && !_caster.IsWalking() && !target.IsWalking() &&
|
||||
(_spellInfo.RangeEntry.Flags.HasAnyFlag(SpellRangeFlag.Melee) || target.IsTypeId(TypeId.Player)))
|
||||
rangeMod += 8.0f / 3.0f;
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ namespace Game.AI
|
||||
if (me.HasUnitState(UnitState.Casting))
|
||||
return;
|
||||
|
||||
if (!me.isAttackReady(WeaponAttackType.RangedAttack))
|
||||
if (!me.IsAttackReady(WeaponAttackType.RangedAttack))
|
||||
return;
|
||||
|
||||
Unit victim = me.GetVictim();
|
||||
@@ -610,7 +610,7 @@ namespace Game.AI
|
||||
return;
|
||||
|
||||
me.CastSpell(victim, rangedAttackSpell, TriggerCastFlags.CastDirectly);
|
||||
me.resetAttackTimer(WeaponAttackType.RangedAttack);
|
||||
me.ResetAttackTimer(WeaponAttackType.RangedAttack);
|
||||
}
|
||||
|
||||
public void DoAutoAttackIfReady()
|
||||
|
||||
@@ -475,7 +475,7 @@ namespace Game.AI
|
||||
}
|
||||
|
||||
me.SetCombatPulseDelay(5);
|
||||
me.setActive(true);
|
||||
me.SetActive(true);
|
||||
DoZoneInCombat();
|
||||
ScheduleTasks();
|
||||
}
|
||||
@@ -565,7 +565,7 @@ namespace Game.AI
|
||||
|
||||
public override bool CanAIAttack(Unit victim) { return CheckBoundary(victim); }
|
||||
|
||||
public void _JustReachedHome() { me.setActive(false); }
|
||||
public void _JustReachedHome() { me.SetActive(false); }
|
||||
|
||||
public InstanceScript instance;
|
||||
public SummonList summons;
|
||||
|
||||
@@ -21,8 +21,6 @@ using Game.Groups;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Game.Movement;
|
||||
using Game.Maps;
|
||||
|
||||
namespace Game.AI
|
||||
{
|
||||
@@ -101,7 +99,7 @@ namespace Game.AI
|
||||
|
||||
public override void MoveInLineOfSight(Unit who)
|
||||
{
|
||||
if (me.HasReactState(ReactStates.Aggressive) && !me.HasUnitState(UnitState.Stunned) && who.isTargetableForAttack() && who.isInAccessiblePlaceFor(me))
|
||||
if (me.HasReactState(ReactStates.Aggressive) && !me.HasUnitState(UnitState.Stunned) && who.IsTargetableForAttack() && who.IsInAccessiblePlaceFor(me))
|
||||
{
|
||||
if (HasEscortState(eEscortState.Escorting) && AssistPlayerInCombatAgainst(who))
|
||||
return;
|
||||
@@ -256,7 +254,7 @@ namespace Game.AI
|
||||
|
||||
if (m_bCanInstantRespawn)
|
||||
{
|
||||
me.setDeathState(DeathState.JustDied);
|
||||
me.SetDeathState(DeathState.JustDied);
|
||||
me.Respawn();
|
||||
}
|
||||
else
|
||||
@@ -296,7 +294,7 @@ namespace Game.AI
|
||||
|
||||
if (m_bCanInstantRespawn)
|
||||
{
|
||||
me.setDeathState(DeathState.JustDied);
|
||||
me.SetDeathState(DeathState.JustDied);
|
||||
me.Respawn();
|
||||
}
|
||||
else
|
||||
@@ -409,7 +407,7 @@ namespace Game.AI
|
||||
}
|
||||
|
||||
/// todo get rid of this many variables passed in function.
|
||||
public void Start(bool isActiveAttacker = true, bool run = false, ObjectGuid playerGUID = default(ObjectGuid), Quest quest = null, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true)
|
||||
public void Start(bool isActiveAttacker = true, bool run = false, ObjectGuid playerGUID = default, Quest quest = null, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true)
|
||||
{
|
||||
if (me.GetVictim())
|
||||
{
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Game.AI
|
||||
|
||||
public override void MoveInLineOfSight(Unit who)
|
||||
{
|
||||
if (me.HasReactState(ReactStates.Aggressive) && !me.HasUnitState(UnitState.Stunned) && who.isTargetableForAttack() && who.isInAccessiblePlaceFor(me))
|
||||
if (me.HasReactState(ReactStates.Aggressive) && !me.HasUnitState(UnitState.Stunned) && who.IsTargetableForAttack() && who.IsInAccessiblePlaceFor(me))
|
||||
{
|
||||
if (HasFollowState(eFollowState.Inprogress) && AssistPlayerInCombatAgainst(who))
|
||||
return;
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
using Framework.Constants;
|
||||
using Game.Entities;
|
||||
using Game.Groups;
|
||||
using Game.Maps;
|
||||
using Game.Movement;
|
||||
using Game.Scripting;
|
||||
using Game.Spells;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -1065,7 +1062,7 @@ namespace Game.AI
|
||||
{
|
||||
GetScript().OnInitialize(go);
|
||||
// do not call respawn event if go is not spawned
|
||||
if (go.isSpawned())
|
||||
if (go.IsSpawned())
|
||||
GetScript().ProcessEventsFor(SmartEvents.Respawn);
|
||||
}
|
||||
|
||||
|
||||
@@ -1272,7 +1272,7 @@ namespace Game.AI
|
||||
break;
|
||||
|
||||
foreach (var obj in targets)
|
||||
obj.setActive(e.Action.active.state != 0);
|
||||
obj.SetActive(e.Action.active.state != 0);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1635,7 +1635,7 @@ namespace Game.AI
|
||||
else if (IsGameObject(obj))
|
||||
{
|
||||
// do not modify respawndelay of already spawned gameobjects
|
||||
if (obj.ToGameObject().isSpawnedByDefault())
|
||||
if (obj.ToGameObject().IsSpawnedByDefault())
|
||||
obj.ToGameObject().Respawn();
|
||||
else
|
||||
obj.ToGameObject().SetRespawnTime((int)e.Action.respawnTarget.goRespawnTime);
|
||||
@@ -2256,7 +2256,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsCreature(obj))
|
||||
obj.ToCreature().setRegeneratingHealth(e.Action.setHealthRegen.regenHealth != 0 ? true : false);
|
||||
obj.ToCreature().SetRegeneratingHealth(e.Action.setHealthRegen.regenHealth != 0 ? true : false);
|
||||
break;
|
||||
}
|
||||
case SmartActions.SetRoot:
|
||||
|
||||
Reference in New Issue
Block a user