Some refactoring of code. and some cleanups
This commit is contained in:
@@ -95,7 +95,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
var attackers = getAttackers();
|
||||
var attackers = GetAttackers();
|
||||
for (var i = 0; i < attackers.Count;)
|
||||
{
|
||||
var unit = attackers[i];
|
||||
@@ -108,7 +108,7 @@ namespace Game.Entities
|
||||
++i;
|
||||
}
|
||||
|
||||
getHostileRefManager().deleteReferencesForFaction(factionId);
|
||||
GetHostileRefManager().deleteReferencesForFaction(factionId);
|
||||
|
||||
foreach (var control in m_Controlled)
|
||||
control.StopAttackFaction(factionId);
|
||||
@@ -116,10 +116,10 @@ namespace Game.Entities
|
||||
|
||||
public void HandleProcExtraAttackFor(Unit victim)
|
||||
{
|
||||
while (m_extraAttacks != 0)
|
||||
while (ExtraAttacks != 0)
|
||||
{
|
||||
AttackerStateUpdate(victim, WeaponAttackType.BaseAttack, true);
|
||||
--m_extraAttacks;
|
||||
--ExtraAttacks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Game.Entities
|
||||
{
|
||||
// iterate attackers
|
||||
List<Unit> toRemove = new List<Unit>();
|
||||
foreach (Unit attacker in getAttackers())
|
||||
foreach (Unit attacker in GetAttackers())
|
||||
if (!attacker.IsValidAttackTarget(this))
|
||||
toRemove.Add(attacker);
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace Game.Entities
|
||||
}
|
||||
public void ClearInCombat()
|
||||
{
|
||||
m_CombatTimer = 0;
|
||||
combatTimer = 0;
|
||||
RemoveUnitFlag(UnitFlags.InCombat);
|
||||
|
||||
// Player's state will be cleared in Player.UpdateContestedPvP
|
||||
@@ -316,11 +316,11 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public void addHatedBy(HostileReference pHostileReference)
|
||||
public void AddHatedBy(HostileReference pHostileReference)
|
||||
{
|
||||
m_HostileRefManager.InsertFirst(pHostileReference);
|
||||
hostileRefManager.InsertFirst(pHostileReference);
|
||||
}
|
||||
public void removeHatedBy(HostileReference pHostileReference) { } //nothing to do yet
|
||||
public void RemoveHatedBy(HostileReference pHostileReference) { } //nothing to do yet
|
||||
|
||||
public void AddThreat(Unit victim, float fThreat, SpellSchoolMask schoolMask = SpellSchoolMask.Normal, SpellInfo threatSpell = null)
|
||||
{
|
||||
@@ -338,7 +338,7 @@ namespace Game.Entities
|
||||
return fThreat * m_threatModifier[(int)school];
|
||||
}
|
||||
|
||||
public bool isTargetableForAttack(bool checkFakeDeath = true)
|
||||
public bool IsTargetableForAttack(bool checkFakeDeath = true)
|
||||
{
|
||||
if (!IsAlive())
|
||||
return false;
|
||||
@@ -352,7 +352,7 @@ namespace Game.Entities
|
||||
return !HasUnitState(UnitState.Unattackable) && (!checkFakeDeath || !HasUnitState(UnitState.Died));
|
||||
}
|
||||
|
||||
public DeathState getDeathState()
|
||||
public DeathState GetDeathState()
|
||||
{
|
||||
return m_deathState;
|
||||
}
|
||||
@@ -392,9 +392,9 @@ namespace Game.Entities
|
||||
if (HasAuraType(AuraType.ModUnattackable))
|
||||
RemoveAurasByType(AuraType.ModUnattackable);
|
||||
|
||||
if (m_attacking != null)
|
||||
if (attacking != null)
|
||||
{
|
||||
if (m_attacking == victim)
|
||||
if (attacking == victim)
|
||||
{
|
||||
// switch to melee attack from ranged/magic
|
||||
if (meleeAttack)
|
||||
@@ -421,11 +421,11 @@ namespace Game.Entities
|
||||
ClearUnitState(UnitState.MeleeAttacking);
|
||||
}
|
||||
|
||||
if (m_attacking != null)
|
||||
m_attacking._removeAttacker(this);
|
||||
if (attacking != null)
|
||||
attacking._removeAttacker(this);
|
||||
|
||||
m_attacking = victim;
|
||||
m_attacking._addAttacker(this);
|
||||
attacking = victim;
|
||||
attacking._addAttacker(this);
|
||||
|
||||
// Set our target
|
||||
SetTarget(victim.GetGUID());
|
||||
@@ -450,8 +450,8 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// delay offhand weapon attack to next attack time
|
||||
if (haveOffhandWeapon() && GetTypeId() != TypeId.Player)
|
||||
resetAttackTimer(WeaponAttackType.OffAttack);
|
||||
if (HaveOffhandWeapon() && GetTypeId() != TypeId.Player)
|
||||
ResetAttackTimer(WeaponAttackType.OffAttack);
|
||||
|
||||
if (meleeAttack)
|
||||
SendMeleeAttackStart(victim);
|
||||
@@ -488,13 +488,13 @@ namespace Game.Entities
|
||||
public virtual void SetTarget(ObjectGuid guid) { }
|
||||
public bool AttackStop()
|
||||
{
|
||||
if (m_attacking == null)
|
||||
if (attacking == null)
|
||||
return false;
|
||||
|
||||
Unit victim = m_attacking;
|
||||
Unit victim = attacking;
|
||||
|
||||
m_attacking._removeAttacker(this);
|
||||
m_attacking = null;
|
||||
attacking._removeAttacker(this);
|
||||
attacking = null;
|
||||
|
||||
// Clear our target
|
||||
SetTarget(ObjectGuid.Empty);
|
||||
@@ -529,9 +529,9 @@ namespace Game.Entities
|
||||
}
|
||||
public Unit GetVictim()
|
||||
{
|
||||
return m_attacking;
|
||||
return attacking;
|
||||
}
|
||||
public Unit getAttackerForHelper()
|
||||
public Unit GetAttackerForHelper()
|
||||
{
|
||||
if (GetVictim() != null)
|
||||
return GetVictim();
|
||||
@@ -541,7 +541,7 @@ namespace Game.Entities
|
||||
|
||||
return null;
|
||||
}
|
||||
public List<Unit> getAttackers()
|
||||
public List<Unit> GetAttackers()
|
||||
{
|
||||
return attackerList;
|
||||
}
|
||||
@@ -551,26 +551,26 @@ namespace Game.Entities
|
||||
public float GetBoundingRadius() { return m_unitData.BoundingRadius; }
|
||||
public void SetBoundingRadius(float boundingRadius) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.BoundingRadius), boundingRadius); }
|
||||
|
||||
public bool haveOffhandWeapon()
|
||||
public bool HaveOffhandWeapon()
|
||||
{
|
||||
if (IsTypeId(TypeId.Player))
|
||||
return ToPlayer().GetWeaponForAttack(WeaponAttackType.OffAttack, true) != null;
|
||||
else
|
||||
return m_canDualWield;
|
||||
}
|
||||
public void resetAttackTimer(WeaponAttackType type = WeaponAttackType.BaseAttack)
|
||||
public void ResetAttackTimer(WeaponAttackType type = WeaponAttackType.BaseAttack)
|
||||
{
|
||||
m_attackTimer[(int)type] = (uint)(GetBaseAttackTime(type) * m_modAttackSpeedPct[(int)type]);
|
||||
}
|
||||
public void setAttackTimer(WeaponAttackType type, uint time)
|
||||
public void SetAttackTimer(WeaponAttackType type, uint time)
|
||||
{
|
||||
m_attackTimer[(int)type] = time;
|
||||
}
|
||||
public uint getAttackTimer(WeaponAttackType type)
|
||||
public uint GetAttackTimer(WeaponAttackType type)
|
||||
{
|
||||
return m_attackTimer[(int)type];
|
||||
}
|
||||
public bool isAttackReady(WeaponAttackType type = WeaponAttackType.BaseAttack)
|
||||
public bool IsAttackReady(WeaponAttackType type = WeaponAttackType.BaseAttack)
|
||||
{
|
||||
return m_attackTimer[(int)type] == 0;
|
||||
}
|
||||
@@ -803,19 +803,19 @@ namespace Game.Entities
|
||||
(!IsTypeId(TypeId.Unit) || !ToCreature().GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.NoParryHasten)))
|
||||
{
|
||||
// Get attack timers
|
||||
float offtime = victim.getAttackTimer(WeaponAttackType.OffAttack);
|
||||
float basetime = victim.getAttackTimer(WeaponAttackType.BaseAttack);
|
||||
float offtime = victim.GetAttackTimer(WeaponAttackType.OffAttack);
|
||||
float basetime = victim.GetAttackTimer(WeaponAttackType.BaseAttack);
|
||||
// Reduce attack time
|
||||
if (victim.haveOffhandWeapon() && offtime < basetime)
|
||||
if (victim.HaveOffhandWeapon() && offtime < basetime)
|
||||
{
|
||||
float percent20 = victim.GetBaseAttackTime(WeaponAttackType.OffAttack) * 0.20f;
|
||||
float percent60 = 3.0f * percent20;
|
||||
if (offtime > percent20 && offtime <= percent60)
|
||||
victim.setAttackTimer(WeaponAttackType.OffAttack, (uint)percent20);
|
||||
victim.SetAttackTimer(WeaponAttackType.OffAttack, (uint)percent20);
|
||||
else if (offtime > percent60)
|
||||
{
|
||||
offtime -= 2.0f * percent20;
|
||||
victim.setAttackTimer(WeaponAttackType.OffAttack, (uint)offtime);
|
||||
victim.SetAttackTimer(WeaponAttackType.OffAttack, (uint)offtime);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -823,11 +823,11 @@ namespace Game.Entities
|
||||
float percent20 = victim.GetBaseAttackTime(WeaponAttackType.BaseAttack) * 0.20f;
|
||||
float percent60 = 3.0f * percent20;
|
||||
if (basetime > percent20 && basetime <= percent60)
|
||||
victim.setAttackTimer(WeaponAttackType.BaseAttack, (uint)percent20);
|
||||
victim.SetAttackTimer(WeaponAttackType.BaseAttack, (uint)percent20);
|
||||
else if (basetime > percent60)
|
||||
{
|
||||
basetime -= 2.0f * percent20;
|
||||
victim.setAttackTimer(WeaponAttackType.BaseAttack, (uint)basetime);
|
||||
victim.SetAttackTimer(WeaponAttackType.BaseAttack, (uint)basetime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -839,14 +839,14 @@ namespace Game.Entities
|
||||
// If this is a creature and it attacks from behind it has a probability to daze it's victim
|
||||
if ((damageInfo.hitOutCome == MeleeHitOutcome.Crit || damageInfo.hitOutCome == MeleeHitOutcome.Crushing || damageInfo.hitOutCome == MeleeHitOutcome.Normal || damageInfo.hitOutCome == MeleeHitOutcome.Glancing) &&
|
||||
!IsTypeId(TypeId.Player) && !ToCreature().IsControlledByPlayer() && !victim.HasInArc(MathFunctions.PI, this)
|
||||
&& (victim.IsTypeId(TypeId.Player) || !victim.ToCreature().isWorldBoss()) && !victim.IsVehicle())
|
||||
&& (victim.IsTypeId(TypeId.Player) || !victim.ToCreature().IsWorldBoss()) && !victim.IsVehicle())
|
||||
{
|
||||
// -probability is between 0% and 40%
|
||||
// 20% base chance
|
||||
float Probability = 20.0f;
|
||||
|
||||
// there is a newbie protection, at level 10 just 7% base chance; assuming linear function
|
||||
if (victim.getLevel() < 30)
|
||||
if (victim.GetLevel() < 30)
|
||||
Probability = 0.65f * victim.GetLevelForTarget(this) + 0.5f;
|
||||
|
||||
uint VictimDefense = victim.GetMaxSkillValueForLevel(this);
|
||||
@@ -1076,7 +1076,7 @@ namespace Game.Entities
|
||||
}
|
||||
else if (!victim.IsControlledByPlayer() || victim.IsVehicle())
|
||||
{
|
||||
if (!victim.ToCreature().hasLootRecipient())
|
||||
if (!victim.ToCreature().HasLootRecipient())
|
||||
victim.ToCreature().SetLootRecipient(this);
|
||||
|
||||
if (IsControlledByPlayer())
|
||||
@@ -1352,7 +1352,7 @@ namespace Game.Entities
|
||||
|
||||
if (PvP)
|
||||
{
|
||||
m_CombatTimer = 5000;
|
||||
combatTimer = 5000;
|
||||
Player me = ToPlayer();
|
||||
if (me)
|
||||
me.EnablePvpRules(true);
|
||||
@@ -1519,7 +1519,7 @@ namespace Game.Entities
|
||||
player.UpdateCriteria(CriteriaTypes.GetKillingBlows, 1, 0, 0, victim);
|
||||
|
||||
Log.outDebug(LogFilter.Unit, "SET JUST_DIED");
|
||||
victim.setDeathState(DeathState.JustDied);
|
||||
victim.SetDeathState(DeathState.JustDied);
|
||||
|
||||
// Inform pets (if any) when player kills target)
|
||||
// MUST come after victim.setDeathState(JUST_DIED); or pet next target
|
||||
@@ -1527,7 +1527,7 @@ namespace Game.Entities
|
||||
if (player != null)
|
||||
{
|
||||
Pet pet = player.GetPet();
|
||||
if (pet != null && pet.IsAlive() && pet.isControlled())
|
||||
if (pet != null && pet.IsAlive() && pet.IsControlled())
|
||||
pet.GetAI().KilledUnit(victim);
|
||||
}
|
||||
|
||||
@@ -1975,7 +1975,7 @@ namespace Game.Entities
|
||||
damageInfo.HitInfo |= HitInfo.Block;
|
||||
damageInfo.originalDamage = damageInfo.damage;
|
||||
// 30% damage blocked, double blocked amount if block is critical
|
||||
damageInfo.blocked_amount = MathFunctions.CalculatePct(damageInfo.damage, damageInfo.target.isBlockCritical() ? damageInfo.target.GetBlockPercent() * 2 : damageInfo.target.GetBlockPercent());
|
||||
damageInfo.blocked_amount = MathFunctions.CalculatePct(damageInfo.damage, damageInfo.target.IsBlockCritical() ? damageInfo.target.GetBlockPercent() * 2 : damageInfo.target.GetBlockPercent());
|
||||
damageInfo.damage -= damageInfo.blocked_amount;
|
||||
damageInfo.cleanDamage += damageInfo.blocked_amount;
|
||||
break;
|
||||
@@ -1983,7 +1983,7 @@ namespace Game.Entities
|
||||
damageInfo.HitInfo |= HitInfo.Glancing;
|
||||
damageInfo.TargetState = VictimState.Hit;
|
||||
damageInfo.originalDamage = damageInfo.damage;
|
||||
int leveldif = (int)victim.getLevel() - (int)getLevel();
|
||||
int leveldif = (int)victim.GetLevel() - (int)GetLevel();
|
||||
if (leveldif > 3)
|
||||
leveldif = 3;
|
||||
|
||||
@@ -2207,7 +2207,7 @@ namespace Game.Entities
|
||||
}
|
||||
public float GetWeaponDamageRange(WeaponAttackType attType, WeaponDamageRange type)
|
||||
{
|
||||
if (attType == WeaponAttackType.OffAttack && !haveOffhandWeapon())
|
||||
if (attType == WeaponAttackType.OffAttack && !HaveOffhandWeapon())
|
||||
return 0.0f;
|
||||
|
||||
return m_weaponDamage[(int)attType][(int)type];
|
||||
@@ -2972,7 +2972,7 @@ namespace Game.Entities
|
||||
return (uint)Math.Max(tmpDamage, 0.0f);
|
||||
}
|
||||
|
||||
bool isBlockCritical()
|
||||
bool IsBlockCritical()
|
||||
{
|
||||
if (RandomHelper.randChance(GetTotalAuraModifier(AuraType.ModBlockCritChance)))
|
||||
return true;
|
||||
@@ -3056,7 +3056,7 @@ namespace Game.Entities
|
||||
|
||||
// visibility checks
|
||||
// skip visibility check for GO casts, needs removal when go cast is implemented. Also ignore for gameobject and dynauras
|
||||
if (GetEntry() != SharedConst.WorldTrigger && (!obj || !obj.isTypeMask(TypeMask.GameObject | TypeMask.DynamicObject)))
|
||||
if (GetEntry() != SharedConst.WorldTrigger && (!obj || !obj.IsTypeMask(TypeMask.GameObject | TypeMask.DynamicObject)))
|
||||
{
|
||||
// can't attack invisible
|
||||
if (bySpell == null || !bySpell.HasAttribute(SpellAttr6.CanTargetInvisible))
|
||||
|
||||
Reference in New Issue
Block a user