Some refactoring of code. and some cleanups

This commit is contained in:
hondacrx
2019-09-21 12:11:16 -04:00
parent 7c405230cc
commit 35c06c09fd
214 changed files with 1235 additions and 1341 deletions
+2 -2
View File
@@ -310,9 +310,9 @@ namespace Game.Entities
public void SaveStayPosition()
{
//! At this point a new spline destination is enabled because of Unit.StopMoving()
Vector3 stayPos = _unit.moveSpline.FinalDestination();
Vector3 stayPos = _unit.MoveSpline.FinalDestination();
if (_unit.moveSpline.onTransport)
if (_unit.MoveSpline.onTransport)
{
float o = 0;
ITransport transport = _unit.GetDirectTransport();
+49 -49
View File
@@ -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))
+14 -14
View File
@@ -41,7 +41,7 @@ namespace Game.Entities
//Movement
protected float[] m_speed_rate = new float[(int)UnitMoveType.Max];
RefManager<Unit, TargetedMovementGeneratorBase> m_FollowingRefManager;
public MoveSpline moveSpline { get; set; }
public MoveSpline MoveSpline { get; set; }
MotionMaster i_motionMaster;
public uint m_movementCounter; //< Incrementing counter used in movement packets
TimeTrackerSmall movesplineTimer;
@@ -59,18 +59,18 @@ namespace Game.Entities
protected uint[] m_attackTimer = new uint[(int)WeaponAttackType.Max];
ThreatManager threatManager;
HostileRefManager m_HostileRefManager;
HostileRefManager hostileRefManager;
RedirectThreatInfo _redirectThreatInfo;
protected Unit m_attacking;
protected Unit attacking;
public float m_modMeleeHitChance { get; set; }
public float m_modRangedHitChance { get; set; }
public float m_modSpellHitChance { get; set; }
public float ModMeleeHitChance { get; set; }
public float ModRangedHitChance { get; set; }
public float ModSpellHitChance { get; set; }
bool m_canDualWield;
public int m_baseSpellCritChance { get; set; }
public uint m_regenTimer { get; set; }
uint m_CombatTimer;
public uint m_extraAttacks { get; set; }
public int BaseSpellCritChance { get; set; }
public uint RegenTimer { get; set; }
uint combatTimer;
public uint ExtraAttacks { get; set; }
//Charm
public List<Unit> m_Controlled = new List<Unit>();
@@ -119,14 +119,14 @@ namespace Game.Entities
public ObjectGuid[] m_SummonSlot = new ObjectGuid[7];
public ObjectGuid[] m_ObjectSlot = new ObjectGuid[4];
public EventSystem m_Events = new EventSystem();
public UnitTypeMask m_unitTypeMask { get; set; }
public UnitTypeMask UnitTypeMask { get; set; }
UnitState m_state;
protected LiquidTypeRecord _lastLiquid;
protected DeathState m_deathState;
public Vehicle m_vehicle { get; set; }
public Vehicle m_vehicleKit { get; set; }
public Vehicle VehicleKit { get; set; }
bool canModifyStats;
public uint m_lastSanctuaryTime { get; set; }
public uint LastSanctuaryTime { get; set; }
uint m_transform;
bool m_cleanupDone; // lock made to not add stuff after cleanup before delete
bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world
@@ -449,7 +449,7 @@ namespace Game.Entities
public class SpellNonMeleeDamage
{
public SpellNonMeleeDamage(Unit _attacker, Unit _target, uint _SpellID, uint _SpellXSpellVisualID, SpellSchoolMask _schoolMask, ObjectGuid _castId = default(ObjectGuid))
public SpellNonMeleeDamage(Unit _attacker, Unit _target, uint _SpellID, uint _SpellXSpellVisualID, SpellSchoolMask _schoolMask, ObjectGuid _castId = default)
{
target = _target;
attacker = _attacker;
+25 -28
View File
@@ -39,17 +39,14 @@ namespace Game.Entities
return m_movementInfo.HasMovementFlag(MovementFlag.Walking);
}
bool IsHovering() { return m_movementInfo.HasMovementFlag(MovementFlag.Hover); }
public bool isStopped()
{
return !(HasUnitState(UnitState.Moving));
}
public bool isMoving() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskMoving); }
public bool isTurning() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskTurning); }
public bool IsStopped() { return !HasUnitState(UnitState.Moving); }
public bool IsMoving() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskMoving); }
public bool IsTurning() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskTurning); }
public virtual bool CanFly() { return false; }
public bool IsFlying() { return m_movementInfo.HasMovementFlag(MovementFlag.Flying | MovementFlag.DisableGravity); }
public bool IsFalling()
{
return m_movementInfo.HasMovementFlag(MovementFlag.Falling | MovementFlag.FallingFar) || moveSpline.isFalling();
return m_movementInfo.HasMovementFlag(MovementFlag.Falling | MovementFlag.FallingFar) || MoveSpline.isFalling();
}
public virtual bool CanSwim()
{
@@ -71,7 +68,7 @@ namespace Game.Entities
return GetMap().IsUnderWater(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ());
}
void propagateSpeedChange() { GetMotionMaster().propagateSpeedChange(); }
void PropagateSpeedChange() { GetMotionMaster().propagateSpeedChange(); }
public float GetSpeed(UnitMoveType mtype)
{
@@ -92,7 +89,7 @@ namespace Game.Entities
m_speed_rate[(int)mtype] = rate;
propagateSpeedChange();
PropagateSpeedChange();
// Spline packets are for creatures and move_update are for players
ServerOpcodes[,] moveTypeToOpcode = new ServerOpcodes[(int)UnitMoveType.Max, 3]
@@ -154,7 +151,7 @@ namespace Game.Entities
ClearUnitState(UnitState.Moving);
// not need send any packets if not in world or not moving
if (!IsInWorld || moveSpline.Finalized())
if (!IsInWorld || MoveSpline.Finalized())
return;
MoveSplineInit init = new MoveSplineInit(this);
@@ -608,7 +605,7 @@ namespace Game.Entities
if (combat_reach < 0.1f)
combat_reach = SharedConst.DefaultCombatReach;
int attacker_number = getAttackers().Count;
int attacker_number = GetAttackers().Count;
if (attacker_number > 0)
--attacker_number;
GetNearPoint(obj, out x, out y, out z, obj.GetCombatReach(), distance2dMin + (distance2dMax - distance2dMin) * (float)RandomHelper.NextDouble()
@@ -1014,16 +1011,16 @@ namespace Game.Entities
return distsq < maxdist * maxdist;
}
public bool isInFrontInMap(Unit target, float distance, float arc = MathFunctions.PI)
public bool IsInFrontInMap(Unit target, float distance, float arc = MathFunctions.PI)
{
return IsWithinDistInMap(target, distance) && HasInArc(arc, target);
}
public bool isInBackInMap(Unit target, float distance, float arc = MathFunctions.PI)
public bool IsInBackInMap(Unit target, float distance, float arc = MathFunctions.PI)
{
return IsWithinDistInMap(target, distance) && !HasInArc(MathFunctions.TwoPi - arc, target);
}
public bool isInAccessiblePlaceFor(Creature c)
public bool IsInAccessiblePlaceFor(Creature c)
{
if (IsInWater())
return c.CanSwim();
@@ -1220,7 +1217,7 @@ namespace Game.Entities
if (!fearAuras.Empty())
caster = Global.ObjAccessor.GetUnit(this, fearAuras[0].GetCasterGUID());
if (caster == null)
caster = getAttackerForHelper();
caster = GetAttackerForHelper();
GetMotionMaster().MoveFleeing(caster, (uint)(fearAuras.Empty() ? WorldConfig.GetIntValue(WorldCfg.CreatureFamilyFleeDelay) : 0)); // caster == NULL processed in MoveFleeing
}
else
@@ -1370,9 +1367,9 @@ namespace Game.Entities
if (vehInfo == null)
return false;
m_vehicleKit = new Vehicle(this, vehInfo, creatureEntry);
VehicleKit = new Vehicle(this, vehInfo, creatureEntry);
m_updateFlag.Vehicle = true;
m_unitTypeMask |= UnitTypeMask.Vehicle;
UnitTypeMask |= UnitTypeMask.Vehicle;
if (!loading)
SendSetVehicleRecId(id);
@@ -1382,18 +1379,18 @@ namespace Game.Entities
public void RemoveVehicleKit(bool onRemoveFromWorld = false)
{
if (m_vehicleKit == null)
if (VehicleKit == null)
return;
if (!onRemoveFromWorld)
SendSetVehicleRecId(0);
m_vehicleKit.Uninstall();
VehicleKit.Uninstall();
m_vehicleKit = null;
VehicleKit = null;
m_updateFlag.Vehicle = false;
m_unitTypeMask &= ~UnitTypeMask.Vehicle;
UnitTypeMask &= ~UnitTypeMask.Vehicle;
RemoveNpcFlag(NPCFlags.SpellClick | NPCFlags.PlayerVehicle);
}
@@ -1630,17 +1627,17 @@ namespace Game.Entities
//Spline
public bool IsSplineEnabled()
{
return moveSpline.Initialized() && !moveSpline.Finalized();
return MoveSpline.Initialized() && !MoveSpline.Finalized();
}
void UpdateSplineMovement(uint diff)
{
int positionUpdateDelay = 400;
if (moveSpline.Finalized())
if (MoveSpline.Finalized())
return;
moveSpline.updateState((int)diff);
bool arrived = moveSpline.Finalized();
MoveSpline.updateState((int)diff);
bool arrived = MoveSpline.Finalized();
if (arrived)
DisableSpline();
@@ -1649,13 +1646,13 @@ namespace Game.Entities
if (movesplineTimer.Passed() || arrived)
{
movesplineTimer.Reset(positionUpdateDelay);
Vector4 loc = moveSpline.ComputePosition();
Vector4 loc = MoveSpline.ComputePosition();
float x = loc.X;
float y = loc.Y;
float z = loc.Z;
float o = loc.W;
if (moveSpline.onTransport)
if (MoveSpline.onTransport)
{
m_movementInfo.transport.pos.Relocate(x, y, z, o);
@@ -1672,7 +1669,7 @@ namespace Game.Entities
public void DisableSpline()
{
m_movementInfo.RemoveMovementFlag(MovementFlag.Forward);
moveSpline.Interrupt();
MoveSpline.Interrupt();
}
//Transport
+5 -5
View File
@@ -88,7 +88,7 @@ namespace Game.Entities
if (IsCharmed())
{
i_disabledAI = i_AI;
if (isPossessed() || IsVehicle())
if (IsPossessed() || IsVehicle())
i_AI = new PossessedAI(ToCreature());
else
i_AI = new PetAI(ToCreature());
@@ -381,7 +381,7 @@ namespace Game.Entities
Player player = ToPlayer();
if (player)
{
if (player.isAFK())
if (player.IsAFK())
player.ToggleAFK();
if (charmer.IsTypeId(TypeId.Unit)) // we are charmed by a creature
@@ -477,7 +477,7 @@ namespace Game.Entities
CastStop();
CombatStop(); // @todo CombatStop(true) may cause crash (interrupt spells)
getHostileRefManager().deleteReferences();
GetHostileRefManager().deleteReferences();
DeleteThreatList();
if (_oldFactionId != 0)
@@ -760,7 +760,7 @@ namespace Game.Entities
if (!pet.CreateBaseAtCreature(creatureTarget))
return null;
uint level = creatureTarget.GetLevelForTarget(this) + 5 < getLevel() ? (getLevel() - 5) : creatureTarget.GetLevelForTarget(this);
uint level = creatureTarget.GetLevelForTarget(this) + 5 < GetLevel() ? (GetLevel() - 5) : creatureTarget.GetLevelForTarget(this);
InitTamedPet(pet, level, spell_id);
@@ -778,7 +778,7 @@ namespace Game.Entities
Pet pet = new Pet(ToPlayer(), PetType.Hunter);
if (!pet.CreateBaseAtCreatureInfo(creatureInfo, this) || !InitTamedPet(pet, getLevel(), spell_id))
if (!pet.CreateBaseAtCreatureInfo(creatureInfo, this) || !InitTamedPet(pet, GetLevel(), spell_id))
return null;
return pet;
+46 -48
View File
@@ -648,7 +648,7 @@ namespace Game.Entities
else if (IsTypeId(TypeId.Player))
crit_chance = ToPlayer().m_activePlayerData.SpellCritPercentage;
else
crit_chance = m_baseSpellCritChance;
crit_chance = BaseSpellCritChance;
// taken
if (victim)
@@ -703,7 +703,7 @@ namespace Game.Entities
// Spell crit suppression
if (victim.GetTypeId() == TypeId.Unit)
{
int levelDiff = (int)(victim.GetLevelForTarget(this) - getLevel());
int levelDiff = (int)(victim.GetLevelForTarget(this) - GetLevel());
crit_chance -= levelDiff * 1.0f;
}
}
@@ -1019,7 +1019,7 @@ namespace Game.Entities
return SpellMissInfo.None;
}
public void CastSpell(SpellCastTargets targets, SpellInfo spellInfo, Dictionary<SpellValueMod, int> values, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastSpell(SpellCastTargets targets, SpellInfo spellInfo, Dictionary<SpellValueMod, int> values, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
if (spellInfo == null)
{
@@ -1036,11 +1036,11 @@ namespace Game.Entities
spell.m_CastItem = castItem;
spell.prepare(targets, triggeredByAura);
}
public void CastSpell(Unit victim, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastSpell(Unit victim, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
CastSpell(victim, spellId, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
}
public void CastSpell(Unit victim, uint spellId, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastSpell(Unit victim, uint spellId, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
if (spellInfo == null)
@@ -1051,17 +1051,17 @@ namespace Game.Entities
CastSpell(victim, spellInfo, triggerFlags, castItem, triggeredByAura, originalCaster);
}
public void CastSpell(Unit victim, SpellInfo spellInfo, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastSpell(Unit victim, SpellInfo spellInfo, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
CastSpell(victim, spellInfo, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
}
public void CastSpell(Unit victim, SpellInfo spellInfo, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastSpell(Unit victim, SpellInfo spellInfo, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
SpellCastTargets targets = new SpellCastTargets();
targets.SetUnitTarget(victim);
CastSpell(targets, spellInfo, null, triggerFlags, castItem, triggeredByAura, originalCaster);
}
public void CastSpell(float x, float y, float z, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastSpell(float x, float y, float z, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
if (spellInfo == null)
@@ -1074,7 +1074,7 @@ namespace Game.Entities
CastSpell(targets, spellInfo, null, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
}
public void CastSpell(GameObject go, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastSpell(GameObject go, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
if (spellInfo == null)
@@ -1088,7 +1088,7 @@ namespace Game.Entities
CastSpell(targets, spellInfo, null, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
}
public void CastCustomSpell(Unit target, uint spellId, int bp0, int bp1, int bp2, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastCustomSpell(Unit target, uint spellId, int bp0, int bp1, int bp2, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
Dictionary<SpellValueMod, int> values = new Dictionary<SpellValueMod, int>();
if (bp0 != 0)
@@ -1099,19 +1099,19 @@ namespace Game.Entities
values.Add(SpellValueMod.BasePoint2, bp2);
CastCustomSpell(spellId, values, target, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
}
public void CastCustomSpell(uint spellId, SpellValueMod mod, int value, Unit target, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastCustomSpell(uint spellId, SpellValueMod mod, int value, Unit target, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
Dictionary<SpellValueMod, int> values = new Dictionary<SpellValueMod, int>();
values.Add(mod, value);
CastCustomSpell(spellId, values, target, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
}
public void CastCustomSpell(uint spellId, SpellValueMod mod, int value, Unit target = null, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastCustomSpell(uint spellId, SpellValueMod mod, int value, Unit target = null, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
Dictionary<SpellValueMod, int> values = new Dictionary<SpellValueMod, int>();
values.Add(mod, value);
CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster);
}
public void CastCustomSpell(uint spellId, Dictionary<SpellValueMod, int> values, Unit victim = null, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default(ObjectGuid))
public void CastCustomSpell(uint spellId, Dictionary<SpellValueMod, int> values, Unit victim = null, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
if (spellInfo == null)
@@ -1273,7 +1273,7 @@ namespace Game.Entities
public SpellHistory GetSpellHistory() { return _spellHistory; }
public static ProcFlagsHit createProcHitMask(SpellNonMeleeDamage damageInfo, SpellMissInfo missCondition)
public static ProcFlagsHit CreateProcHitMask(SpellNonMeleeDamage damageInfo, SpellMissInfo missCondition)
{
ProcFlagsHit hitMask = ProcFlagsHit.None;
// Check victim state
@@ -1501,7 +1501,7 @@ namespace Game.Entities
int overEnergize = damage - gain;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId);
victim.getHostileRefManager().threatAssist(this, damage * 0.5f, spellInfo);
victim.GetHostileRefManager().threatAssist(this, damage * 0.5f, spellInfo);
SendEnergizeSpellLog(victim, spellId, damage, overEnergize, powerType);
}
@@ -1997,7 +1997,7 @@ namespace Game.Entities
public ushort GetMaxSkillValueForLevel(Unit target = null)
{
return (ushort)(target != null ? GetLevelForTarget(target) : getLevel() * 5);
return (ushort)(target != null ? GetLevelForTarget(target) : GetLevel() * 5);
}
public Player GetSpellModOwner()
{
@@ -2044,7 +2044,7 @@ namespace Game.Entities
InterruptSpell(CurrentSpellTypes.AutoRepeat);
m_AutoRepeatFirstCast = true;
}
if (pSpell.m_spellInfo.CalcCastTime(getLevel()) > 0)
if (pSpell.m_spellInfo.CalcCastTime(GetLevel()) > 0)
AddUnitState(UnitState.Casting);
break;
@@ -2163,7 +2163,7 @@ namespace Game.Entities
return (uint)crit_bonus;
}
bool isSpellBlocked(Unit victim, SpellInfo spellProto, WeaponAttackType attackType = WeaponAttackType.BaseAttack)
bool IsSpellBlocked(Unit victim, SpellInfo spellProto, WeaponAttackType attackType = WeaponAttackType.BaseAttack)
{
// These spells can't be blocked
if (spellProto != null && (spellProto.HasAttribute(SpellAttr0.ImpossibleDodgeParryBlock) || spellProto.HasAttribute(SpellAttr3.IgnoreHitResult)))
@@ -2190,15 +2190,13 @@ namespace Game.Entities
}
}
public uint getTransForm() { return m_transform; }
public bool HasStealthAura() { return HasAuraType(AuraType.ModStealth); }
public bool HasInvisibilityAura() { return HasAuraType(AuraType.ModInvisibility); }
public bool isFeared() { return HasAuraType(AuraType.ModFear); }
public bool isFrozen() { return HasAuraState(AuraStateType.Frozen); }
public bool IsFeared() { return HasAuraType(AuraType.ModFear); }
public bool IsFrozen() { return HasAuraState(AuraStateType.Frozen); }
public bool IsPolymorphed()
{
uint transformId = getTransForm();
uint transformId = GetTransForm();
if (transformId == 0)
return false;
@@ -2359,7 +2357,7 @@ namespace Game.Entities
if (!spellInfo.HasAttribute(SpellAttr3.BlockableSpell))
{
// Get blocked status
blocked = isSpellBlocked(victim, spellInfo, attackType);
blocked = IsSpellBlocked(victim, spellInfo, attackType);
}
}
@@ -2387,7 +2385,7 @@ namespace Game.Entities
{
// double blocked amount if block is critical
uint value = victim.GetBlockPercent();
if (victim.isBlockCritical())
if (victim.IsBlockCritical())
value *= 2; // double blocked percent
damageInfo.blocked = (uint)MathFunctions.CalculatePct(damage, value);
if (damage <= damageInfo.blocked)
@@ -3008,13 +3006,13 @@ namespace Game.Entities
return result;
}
public bool HasAura(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), ObjectGuid itemCasterGUID = default(ObjectGuid), uint reqEffMask = 0)
public bool HasAura(uint spellId, ObjectGuid casterGUID = default, ObjectGuid itemCasterGUID = default, uint reqEffMask = 0)
{
if (GetAuraApplication(spellId, casterGUID, itemCasterGUID, reqEffMask) != null)
return true;
return false;
}
public bool HasAuraEffect(uint spellId, uint effIndex, ObjectGuid casterGUID = default(ObjectGuid))
public bool HasAuraEffect(uint spellId, uint effIndex, ObjectGuid casterGUID = default)
{
var range = m_appliedAuras.LookupByKey(spellId);
if (!range.Empty())
@@ -3103,17 +3101,17 @@ namespace Game.Entities
return false;
}
public bool HasNegativeAuraWithInterruptFlag(SpellAuraInterruptFlags flag, ObjectGuid guid = default(ObjectGuid))
public bool HasNegativeAuraWithInterruptFlag(SpellAuraInterruptFlags flag, ObjectGuid guid = default)
{
return HasNegativeAuraWithInterruptFlag((uint)flag, 0, guid);
}
public bool HasNegativeAuraWithInterruptFlag(SpellAuraInterruptFlags2 flag, ObjectGuid guid = default(ObjectGuid))
public bool HasNegativeAuraWithInterruptFlag(SpellAuraInterruptFlags2 flag, ObjectGuid guid = default)
{
return HasNegativeAuraWithInterruptFlag((uint)flag, 1, guid);
}
public bool HasNegativeAuraWithInterruptFlag(uint flag, int index, ObjectGuid guid = default(ObjectGuid))
public bool HasNegativeAuraWithInterruptFlag(uint flag, int index, ObjectGuid guid = default)
{
if (!Convert.ToBoolean(m_interruptMask[index] & flag))
return false;
@@ -3126,7 +3124,7 @@ namespace Game.Entities
}
return false;
}
bool HasNegativeAuraWithAttribute(SpellAttr0 flag, ObjectGuid guid = default(ObjectGuid))
bool HasNegativeAuraWithAttribute(SpellAttr0 flag, ObjectGuid guid = default)
{
foreach (var list in GetAppliedAuras())
{
@@ -3151,12 +3149,12 @@ namespace Game.Entities
return count;
}
public Aura GetAuraOfRankedSpell(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), ObjectGuid itemCasterGUID = default(ObjectGuid), uint reqEffMask = 0)
public Aura GetAuraOfRankedSpell(uint spellId, ObjectGuid casterGUID = default, ObjectGuid itemCasterGUID = default, uint reqEffMask = 0)
{
var aurApp = GetAuraApplicationOfRankedSpell(spellId, casterGUID, itemCasterGUID, reqEffMask);
return aurApp?.GetBase();
}
AuraApplication GetAuraApplicationOfRankedSpell(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), ObjectGuid itemCasterGUID = default(ObjectGuid), uint reqEffMask = 0, AuraApplication except = null)
AuraApplication GetAuraApplicationOfRankedSpell(uint spellId, ObjectGuid casterGUID = default, ObjectGuid itemCasterGUID = default, uint reqEffMask = 0, AuraApplication except = null)
{
uint rankSpell = Global.SpellMgr.GetFirstSpellInChain(spellId);
while (rankSpell != 0)
@@ -3358,7 +3356,7 @@ namespace Game.Entities
}
}
}
public void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID = default(ObjectGuid), Aura except = null, bool negative = true, bool positive = true)
public void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID = default, Aura except = null, bool negative = true, bool positive = true)
{
var list = m_modAuras[auraType];
for (var i = 0; i < list.Count; i++)
@@ -3427,7 +3425,7 @@ namespace Game.Entities
aura._Remove(removeMode);
}
public void RemoveOwnedAura(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), uint reqEffMask = 0, AuraRemoveMode removeMode = AuraRemoveMode.Default)
public void RemoveOwnedAura(uint spellId, ObjectGuid casterGUID = default, uint reqEffMask = 0, AuraRemoveMode removeMode = AuraRemoveMode.Default)
{
foreach (var pair in GetOwnedAuras())
{
@@ -3467,7 +3465,7 @@ namespace Game.Entities
Cypher.Assert(false);
}
public void RemoveAurasDueToSpell(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), uint reqEffMask = 0, AuraRemoveMode removeMode = AuraRemoveMode.Default)
public void RemoveAurasDueToSpell(uint spellId, ObjectGuid casterGUID = default, uint reqEffMask = 0, AuraRemoveMode removeMode = AuraRemoveMode.Default)
{
foreach (var pair in GetAppliedAuras())
{
@@ -3507,7 +3505,7 @@ namespace Game.Entities
}
}
}
public void RemoveAuraFromStack(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), AuraRemoveMode removeMode = AuraRemoveMode.Default, ushort num = 1)
public void RemoveAuraFromStack(uint spellId, ObjectGuid casterGUID = default, AuraRemoveMode removeMode = AuraRemoveMode.Default, ushort num = 1)
{
var range = m_ownedAuras.LookupByKey(spellId);
foreach (var aura in range)
@@ -3531,7 +3529,7 @@ namespace Game.Entities
if (aura.GetOwner() == this)
aura.Remove(mode);
}
public void RemoveAura(uint spellId, ObjectGuid caster = default(ObjectGuid), uint reqEffMask = 0, AuraRemoveMode removeMode = AuraRemoveMode.Default)
public void RemoveAura(uint spellId, ObjectGuid caster = default, uint reqEffMask = 0, AuraRemoveMode removeMode = AuraRemoveMode.Default)
{
var range = m_appliedAuras.LookupByKey(spellId);
foreach (var iter in range)
@@ -3685,7 +3683,7 @@ namespace Game.Entities
foreach (var pair in GetOwnedAuras())
{
var appMap = pair.Value.GetApplicationMap();
foreach (var aurApp in appMap.Values)
foreach (var aurApp in appMap.Values.ToList())
{
Unit target = aurApp.GetTarget();
if (target == this)
@@ -3951,7 +3949,7 @@ namespace Game.Entities
if (aurApp.GetRemoveMode() == AuraRemoveMode.Expire && IsTypeId(TypeId.Unit) && IsTotem())
{
if (ToTotem().GetSpell() == aura.GetId() && ToTotem().GetTotemType() == TotemType.Passive)
ToTotem().setDeathState(DeathState.JustDied);
ToTotem().SetDeathState(DeathState.JustDied);
}
// Remove aurastates only if were not found
@@ -3980,7 +3978,7 @@ namespace Game.Entities
Cypher.Assert(false);
}
public AuraEffect GetAuraEffect(uint spellId, uint effIndex, ObjectGuid casterGUID = default(ObjectGuid))
public AuraEffect GetAuraEffect(uint spellId, uint effIndex, ObjectGuid casterGUID = default)
{
var range = m_appliedAuras.LookupByKey(spellId);
if (!range.Empty())
@@ -3996,7 +3994,7 @@ namespace Game.Entities
}
return null;
}
public AuraEffect GetAuraEffectOfRankedSpell(uint spellId, uint effIndex, ObjectGuid casterGUID = default(ObjectGuid))
public AuraEffect GetAuraEffectOfRankedSpell(uint spellId, uint effIndex, ObjectGuid casterGUID = default)
{
uint rankSpell = Global.SpellMgr.GetFirstSpellInChain(spellId);
while (rankSpell != 0)
@@ -4010,7 +4008,7 @@ namespace Game.Entities
}
// spell mustn't have familyflags
public AuraEffect GetAuraEffect(AuraType type, SpellFamilyNames family, FlagArray128 familyFlag, ObjectGuid casterGUID = default(ObjectGuid))
public AuraEffect GetAuraEffect(AuraType type, SpellFamilyNames family, FlagArray128 familyFlag, ObjectGuid casterGUID = default)
{
var auras = GetAuraEffectsByType(type);
foreach (var aura in auras)
@@ -4027,7 +4025,7 @@ namespace Game.Entities
}
public AuraApplication GetAuraApplication(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), ObjectGuid itemCasterGUID = default(ObjectGuid), uint reqEffMask = 0, AuraApplication except = null)
public AuraApplication GetAuraApplication(uint spellId, ObjectGuid casterGUID = default, ObjectGuid itemCasterGUID = default, uint reqEffMask = 0, AuraApplication except = null)
{
var range = m_appliedAuras.LookupByKey(spellId);
if (!range.Empty())
@@ -4044,7 +4042,7 @@ namespace Game.Entities
}
return null;
}
public Aura GetAura(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), ObjectGuid itemCasterGUID = default(ObjectGuid), uint reqEffMask = 0)
public Aura GetAura(uint spellId, ObjectGuid casterGUID = default, ObjectGuid itemCasterGUID = default, uint reqEffMask = 0)
{
AuraApplication aurApp = GetAuraApplication(spellId, casterGUID, itemCasterGUID, reqEffMask);
return aurApp?.GetBase();
@@ -4144,7 +4142,7 @@ namespace Game.Entities
}
}
}
public Aura _TryStackingOrRefreshingExistingAura(SpellInfo newAura, uint effMask, Unit caster, int[] baseAmount = null, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1)
public Aura _TryStackingOrRefreshingExistingAura(SpellInfo newAura, uint effMask, Unit caster, int[] baseAmount = null, Item castItem = null, ObjectGuid casterGUID = default, bool resetPeriodicTimer = true, ObjectGuid castItemGuid = default, int castItemLevel = -1)
{
Cypher.Assert(!casterGUID.IsEmpty() || caster);
@@ -4323,7 +4321,7 @@ namespace Game.Entities
return true;
}
public Aura GetOwnedAura(uint spellId, ObjectGuid casterGUID = default(ObjectGuid), ObjectGuid itemCasterGUID = default(ObjectGuid), uint reqEffMask = 0, Aura except = null)
public Aura GetOwnedAura(uint spellId, ObjectGuid casterGUID = default, ObjectGuid itemCasterGUID = default, uint reqEffMask = 0, Aura except = null)
{
var range = m_ownedAuras.LookupByKey(spellId);
foreach (var aura in range)
@@ -4574,7 +4572,7 @@ namespace Game.Entities
else if (IsPet())
{
Pet pet = ToPet();
if (pet.isControlled())
if (pet.IsControlled())
pet.SetGroupUpdateFlag(GroupUpdatePetFlags.Auras);
}
}
+59 -62
View File
@@ -18,7 +18,6 @@
using Framework.Constants;
using Framework.Dynamic;
using Framework.GameMath;
using Framework.IO;
using Game.AI;
using Game.BattleGrounds;
using Game.Chat;
@@ -39,16 +38,16 @@ namespace Game.Entities
{
public Unit(bool isWorldObject) : base(isWorldObject)
{
moveSpline = new MoveSpline();
MoveSpline = new MoveSpline();
i_motionMaster = new MotionMaster(this);
threatManager = new ThreatManager(this);
m_unitTypeMask = UnitTypeMask.None;
m_HostileRefManager = new HostileRefManager(this);
UnitTypeMask = UnitTypeMask.None;
hostileRefManager = new HostileRefManager(this);
_spellHistory = new SpellHistory(this);
m_FollowingRefManager = new RefManager<Unit, TargetedMovementGeneratorBase>();
objectTypeId = TypeId.Unit;
objectTypeMask |= TypeMask.Unit;
ObjectTypeId = TypeId.Unit;
ObjectTypeMask |= TypeMask.Unit;
m_updateFlag.MovementUpdate = true;
m_modAttackSpeedPct = new float[] { 1.0f, 1.0f, 1.0f };
@@ -70,11 +69,11 @@ namespace Game.Entities
if (IsTypeId(TypeId.Player))
{
m_modMeleeHitChance = 7.5f;
m_modRangedHitChance = 7.5f;
m_modSpellHitChance = 15.0f;
ModMeleeHitChance = 7.5f;
ModRangedHitChance = 7.5f;
ModSpellHitChance = 15.0f;
}
m_baseSpellCritChance = 5;
BaseSpellCritChance = 5;
for (byte i = 0; i < (int)SpellSchools.Max; ++i)
m_threatModifier[i] = 1.0f;
@@ -111,7 +110,7 @@ namespace Game.Entities
//i_motionMaster = null;
m_charmInfo = null;
moveSpline = null;
MoveSpline = null;
_spellHistory = null;
/*ASSERT(!m_duringRemoveFromWorld);
@@ -152,24 +151,24 @@ namespace Game.Entities
// Check UNIT_STATE_MELEE_ATTACKING or UNIT_STATE_CHASE (without UNIT_STATE_FOLLOW in this case) so pets can reach far away
// targets without stopping half way there and running off.
// These flags are reset after target dies or another command is given.
if (m_HostileRefManager.IsEmpty())
if (hostileRefManager.IsEmpty())
{
// m_CombatTimer set at aura start and it will be freeze until aura removing
if (m_CombatTimer <= diff)
if (combatTimer <= diff)
ClearInCombat();
else
m_CombatTimer -= diff;
combatTimer -= diff;
}
}
uint att;
// not implemented before 3.0.2
if ((att = getAttackTimer(WeaponAttackType.BaseAttack)) != 0)
setAttackTimer(WeaponAttackType.BaseAttack, (diff >= att ? 0 : att - diff));
if ((att = getAttackTimer(WeaponAttackType.RangedAttack)) != 0)
setAttackTimer(WeaponAttackType.RangedAttack, (diff >= att ? 0 : att - diff));
if ((att = getAttackTimer(WeaponAttackType.OffAttack)) != 0)
setAttackTimer(WeaponAttackType.OffAttack, (diff >= att ? 0 : att - diff));
if ((att = GetAttackTimer(WeaponAttackType.BaseAttack)) != 0)
SetAttackTimer(WeaponAttackType.BaseAttack, (diff >= att ? 0 : att - diff));
if ((att = GetAttackTimer(WeaponAttackType.RangedAttack)) != 0)
SetAttackTimer(WeaponAttackType.RangedAttack, (diff >= att ? 0 : att - diff));
if ((att = GetAttackTimer(WeaponAttackType.OffAttack)) != 0)
SetAttackTimer(WeaponAttackType.OffAttack, (diff >= att ? 0 : att - diff));
// update abilities available only for fraction of time
UpdateReactives(diff);
@@ -227,7 +226,7 @@ namespace Game.Entities
for (var i = 0; i < m_gameObj.Count; ++i)
{
GameObject go = m_gameObj[i];
if (!go.isSpawned())
if (!go.IsSpawned())
{
go.SetOwnerGUID(ObjectGuid.Empty);
go.SetRespawnTime(0);
@@ -256,12 +255,12 @@ namespace Game.Entities
public bool IsInDisallowedMountForm()
{
return IsDisallowedMountForm(getTransForm(), GetShapeshiftForm(), GetDisplayId());
return IsDisallowedMountForm(GetTransForm(), GetShapeshiftForm(), GetDisplayId());
}
public bool IsDisallowedMountForm(uint spellId, ShapeShiftForm form, uint displayId)
{
SpellInfo transformSpellInfo = Global.SpellMgr.GetSpellInfo(getTransForm());
SpellInfo transformSpellInfo = Global.SpellMgr.GetSpellInfo(GetTransForm());
if (transformSpellInfo != null)
if (transformSpellInfo.HasAttribute(SpellAttr0.CastableWhileMounted))
return false;
@@ -313,7 +312,7 @@ namespace Game.Entities
{
if (m_sharedVision.Empty())
{
setActive(true);
SetActive(true);
SetWorldObject(true);
}
m_sharedVision.Add(player);
@@ -325,7 +324,7 @@ namespace Game.Entities
m_sharedVision.Remove(player);
if (m_sharedVision.Empty())
{
setActive(false);
SetActive(false);
SetWorldObject(false);
}
}
@@ -485,7 +484,7 @@ namespace Game.Entities
m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map.RemoveAllObjectsInRemoveList
CombatStop();
DeleteThreatList();
getHostileRefManager().deleteReferences();
GetHostileRefManager().deleteReferences();
GetMotionMaster().Clear(false); // remove different non-standard movement generators.
}
public override void CleanupsBeforeDelete(bool finalCleanup = true)
@@ -495,10 +494,10 @@ namespace Game.Entities
base.CleanupsBeforeDelete(finalCleanup);
}
public void setTransForm(uint spellid) { m_transform = spellid; }
public void SetTransForm(uint spellid) { m_transform = spellid; }
public uint GetTransForm() { return m_transform; }
public Vehicle GetVehicleKit() { return m_vehicleKit; }
public Vehicle GetVehicleKit() { return VehicleKit; }
public Vehicle GetVehicle() { return m_vehicle; }
public void SetVehicle(Vehicle vehicle) { m_vehicle = vehicle; }
public Unit GetVehicleBase()
@@ -965,8 +964,8 @@ namespace Game.Entities
if (HasUnitTypeMask(UnitTypeMask.Accessory))
{
// Vehicle just died, we die too
if (vehicle.GetBase().getDeathState() == DeathState.JustDied)
setDeathState(DeathState.JustDied);
if (vehicle.GetBase().GetDeathState() == DeathState.JustDied)
SetDeathState(DeathState.JustDied);
// If for other reason we as minion are exiting the vehicle (ejected, master dismounted) - unsummon
else
ToTempSummon().UnSummon(2000); // Approximation
@@ -1083,11 +1082,11 @@ namespace Game.Entities
public UnitAI GetAI() { return i_AI; }
void SetAI(UnitAI newAI) { i_AI = newAI; }
public bool isPossessing()
public bool IsPossessing()
{
Unit u = GetCharm();
if (u != null)
return u.isPossessed();
return u.IsPossessed();
else
return false;
}
@@ -1107,9 +1106,9 @@ namespace Game.Entities
return null;
}
public bool IsCharmed() { return !GetCharmerGUID().IsEmpty(); }
public bool isPossessed() { return HasUnitState(UnitState.Possessed); }
public bool IsPossessed() { return HasUnitState(UnitState.Possessed); }
public HostileRefManager getHostileRefManager() { return m_HostileRefManager; }
public HostileRefManager GetHostileRefManager() { return hostileRefManager; }
public void OnPhaseChange()
{
@@ -1118,7 +1117,7 @@ namespace Game.Entities
if (IsTypeId(TypeId.Unit) || !ToPlayer().GetSession().PlayerLogout())
{
HostileRefManager refManager = getHostileRefManager();
HostileRefManager refManager = GetHostileRefManager();
HostileReference refe = refManager.getFirst();
while (refe != null)
@@ -1149,7 +1148,7 @@ namespace Game.Entities
{
Unit unit = host.getTarget();
if (unit != null)
unit.getHostileRefManager().setOnlineOfflineState(ToCreature(), unit.IsInPhase(this));
unit.GetHostileRefManager().setOnlineOfflineState(ToCreature(), unit.IsInPhase(this));
}
}
}
@@ -1595,7 +1594,7 @@ namespace Game.Entities
public Totem ToTotem() { return IsTotem() ? (this as Totem) : null; }
public TempSummon ToTempSummon() { return IsSummon() ? (this as TempSummon) : null; }
public virtual void setDeathState(DeathState s)
public virtual void SetDeathState(DeathState s)
{
// Death state needs to be updated before RemoveAllAurasOnDeath() is called, to prevent entering combat
m_deathState = s;
@@ -1604,7 +1603,7 @@ namespace Game.Entities
{
CombatStop();
DeleteThreatList();
getHostileRefManager().deleteReferences();
GetHostileRefManager().deleteReferences();
if (IsNonMeleeSpellCast(false))
InterruptNonMeleeSpells(false);
@@ -1829,7 +1828,7 @@ namespace Game.Entities
// check "realtime" interrupts
// don't cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect
if (((IsTypeId(TypeId.Player) && ToPlayer().isMoving()) || IsNonMeleeSpellCast(false, false, true, autoRepeatSpellInfo.Id == 75)) &&
if (((IsTypeId(TypeId.Player) && ToPlayer().IsMoving()) || IsNonMeleeSpellCast(false, false, true, autoRepeatSpellInfo.Id == 75)) &&
!HasAuraTypeWithAffectMask(AuraType.CastWhileWalking, autoRepeatSpellInfo))
{
// cancel wand shoot
@@ -1840,12 +1839,12 @@ namespace Game.Entities
}
// apply delay (Auto Shot (spellID 75) not affected)
if (m_AutoRepeatFirstCast && getAttackTimer(WeaponAttackType.RangedAttack) < 500 && autoRepeatSpellInfo.Id != 75)
setAttackTimer(WeaponAttackType.RangedAttack, 500);
if (m_AutoRepeatFirstCast && GetAttackTimer(WeaponAttackType.RangedAttack) < 500 && autoRepeatSpellInfo.Id != 75)
SetAttackTimer(WeaponAttackType.RangedAttack, 500);
m_AutoRepeatFirstCast = false;
// castroutine
if (isAttackReady(WeaponAttackType.RangedAttack))
if (IsAttackReady(WeaponAttackType.RangedAttack))
{
// Check if able to cast
SpellCastResult result = m_currentSpells[CurrentSpellTypes.AutoRepeat].CheckCast(true);
@@ -1864,7 +1863,7 @@ namespace Game.Entities
spell.prepare(m_currentSpells[CurrentSpellTypes.AutoRepeat].m_targets);
// all went good, reset attack
resetAttackTimer(WeaponAttackType.RangedAttack);
ResetAttackTimer(WeaponAttackType.RangedAttack);
}
}
@@ -1914,7 +1913,7 @@ namespace Game.Entities
Pet pet = ToPet();
if (pet)
{
if (pet.getPetType() == PetType.Hunter) // Hunter pets have focus
if (pet.GetPetType() == PetType.Hunter) // Hunter pets have focus
displayPower = PowerType.Focus;
else if (pet.IsPetGhoul() || pet.IsPetAbomination()) // DK pets have energy
displayPower = PowerType.Energy;
@@ -1961,11 +1960,11 @@ namespace Game.Entities
public bool IsCharmedOwnedByPlayerOrPlayer() { return GetCharmerOrOwnerOrOwnGUID().IsPlayer(); }
public void addFollower(FollowerReference pRef)
public void AddFollower(FollowerReference pRef)
{
m_FollowingRefManager.InsertFirst(pRef);
}
public void removeFollower(FollowerReference pRef) { } //nothing to do yet
public void RemoveFollower(FollowerReference pRef) { } //nothing to do yet
public uint GetCreatureTypeMask()
{
@@ -2088,15 +2087,15 @@ namespace Game.Entities
Global.CharacterCacheStorage.UpdateCharacterLevel(ToPlayer().GetGUID(), (byte)lvl);
}
}
public uint getLevel() { return m_unitData.Level; }
public override uint GetLevelForTarget(WorldObject target) { return getLevel(); }
public uint GetLevel() { return m_unitData.Level; }
public override uint GetLevelForTarget(WorldObject target) { return GetLevel(); }
public Race GetRace() { return (Race)(byte)m_unitData.Race; }
public void SetRace(Race race) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Race), (byte)race); }
public ulong getRaceMask() { return 1ul << ((int)GetRace() - 1); }
public ulong GetRaceMask() { return 1ul << ((int)GetRace() - 1); }
public Class GetClass() { return (Class)(byte)m_unitData.ClassId; }
public void SetClass(Class classId) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ClassId), (byte)classId); }
public uint getClassMask() { return (uint)(1 << ((int)GetClass() - 1)); }
public uint GetClassMask() { return (uint)(1 << ((int)GetClass() - 1)); }
public Gender GetGender() { return (Gender)(byte)m_unitData.Sex; }
public void SetGender(Gender sex) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Sex), (byte)sex); }
@@ -2289,7 +2288,7 @@ namespace Game.Entities
public SheathState GetSheath() { return (SheathState)(byte)m_unitData.SheatheState; }
public void SetSheath(SheathState sheathed) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.SheatheState), (byte)sheathed); }
public uint GetCombatTimer() { return m_CombatTimer; }
public uint GetCombatTimer() { return combatTimer; }
public UnitPVPStateFlags GetPvpFlags() { return (UnitPVPStateFlags)(byte)m_unitData.PvpFlags; }
public bool HasPvpFlag(UnitPVPStateFlags flags) { return (m_unitData.PvpFlags & (uint)flags) != 0; }
public void AddPvpFlag(UnitPVPStateFlags flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.PvpFlags), (byte)flags); }
@@ -2342,20 +2341,18 @@ namespace Game.Entities
SetDisplayId(GetNativeDisplayId());
}
public bool IsStopped() { return !HasUnitState(UnitState.Moving); }
public bool HasUnitTypeMask(UnitTypeMask mask) { return Convert.ToBoolean(mask & m_unitTypeMask); }
public void AddUnitTypeMask(UnitTypeMask mask) { m_unitTypeMask |= mask; }
public bool HasUnitTypeMask(UnitTypeMask mask) { return Convert.ToBoolean(mask & UnitTypeMask); }
public void AddUnitTypeMask(UnitTypeMask mask) { UnitTypeMask |= mask; }
public bool IsAlive() { return m_deathState == DeathState.Alive; }
public bool IsDying() { return m_deathState == DeathState.JustDied; }
public bool IsDead() { return (m_deathState == DeathState.Dead || m_deathState == DeathState.Corpse); }
public bool IsSummon() { return m_unitTypeMask.HasAnyFlag(UnitTypeMask.Summon); }
public bool IsGuardian() { return m_unitTypeMask.HasAnyFlag(UnitTypeMask.Guardian); }
public bool IsPet() { return m_unitTypeMask.HasAnyFlag(UnitTypeMask.Pet); }
public bool IsHunterPet() { return m_unitTypeMask.HasAnyFlag(UnitTypeMask.HunterPet); }
public bool IsTotem() { return m_unitTypeMask.HasAnyFlag(UnitTypeMask.Totem); }
public bool IsVehicle() { return m_unitTypeMask.HasAnyFlag(UnitTypeMask.Vehicle); }
public bool IsSummon() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.Summon); }
public bool IsGuardian() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.Guardian); }
public bool IsPet() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.Pet); }
public bool IsHunterPet() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.HunterPet); }
public bool IsTotem() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.Totem); }
public bool IsVehicle() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.Vehicle); }
public void AddUnitState(UnitState f)
{
@@ -2541,7 +2538,7 @@ namespace Game.Entities
public void RestoreFaction()
{
if (IsTypeId(TypeId.Player))
ToPlayer().setFactionForRace(GetRace());
ToPlayer().SetFactionForRace(GetRace());
else
{
if (HasUnitTypeMask(UnitTypeMask.Minion))