Core/Refactor: Part 5
This commit is contained in:
@@ -239,6 +239,7 @@ namespace Game.AI
|
||||
me.m_CombatDistance = spellInfo != null ? spellInfo.GetMaxRange(false) : 0;
|
||||
me.m_SightDistance = me.m_CombatDistance;
|
||||
}
|
||||
|
||||
public override bool CanAIAttack(Unit victim)
|
||||
{
|
||||
// todo use one function to replace it
|
||||
@@ -247,11 +248,13 @@ namespace Game.AI
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void AttackStart(Unit victim)
|
||||
{
|
||||
if (victim != null)
|
||||
me.Attack(victim, false);
|
||||
}
|
||||
|
||||
public override void UpdateAI(uint diff)
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
@@ -292,6 +295,10 @@ namespace Game.AI
|
||||
}
|
||||
}
|
||||
|
||||
public override void MoveInLineOfSight(Unit who) { }
|
||||
|
||||
public override void AttackStart(Unit victim) { }
|
||||
|
||||
public override void OnCharmed(bool apply)
|
||||
{
|
||||
if (!me.GetVehicleKit().IsVehicleInUse() && !apply && m_HasConditions)//was used and has conditions
|
||||
@@ -350,6 +357,8 @@ namespace Game.AI
|
||||
{
|
||||
public ReactorAI(Creature c) : base(c) { }
|
||||
|
||||
public override void MoveInLineOfSight(Unit who) { }
|
||||
|
||||
public override void UpdateAI(uint diff)
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
|
||||
@@ -65,5 +65,7 @@ namespace Game.AI
|
||||
public class NullGameObjectAI : GameObjectAI
|
||||
{
|
||||
public NullGameObjectAI(GameObject g) : base(g) { }
|
||||
|
||||
public override void UpdateAI(uint diff) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,9 +343,6 @@ namespace Game.AI
|
||||
// Called when spell hits a target
|
||||
public override void SpellHitTarget(Unit target, SpellInfo spell) { }
|
||||
|
||||
//Called at waypoint reached or PointMovement end
|
||||
public override void MovementInform(MovementGeneratorType type, uint id) { }
|
||||
|
||||
// Called when AI is temporarily replaced or put back when possess is applied or removed
|
||||
public virtual void OnPossess(bool apply) { }
|
||||
|
||||
|
||||
@@ -1449,7 +1449,7 @@ namespace Game.AI
|
||||
break;
|
||||
|
||||
uint delay = e.Action.wpPause.delay;
|
||||
((SmartAI)me.GetAI()).PausePath(delay, e.GetEventType() == SmartEvents.WaypointReached ? false : true);
|
||||
((SmartAI)me.GetAI()).PausePath(delay, e.GetEventType() != SmartEvents.WaypointReached);
|
||||
break;
|
||||
}
|
||||
case SmartActions.WpStop:
|
||||
@@ -2695,7 +2695,7 @@ namespace Game.AI
|
||||
}
|
||||
case SmartTargets.ClosestCreature:
|
||||
{
|
||||
Creature target = baseObject.FindNearestCreature(e.Target.closest.entry, e.Target.closest.dist != 0 ? e.Target.closest.dist : 100, e.Target.closest.dead != 0 ? false : true);
|
||||
Creature target = baseObject.FindNearestCreature(e.Target.closest.entry, e.Target.closest.dist != 0 ? e.Target.closest.dist : 100, e.Target.closest.dead == 0);
|
||||
if (target)
|
||||
l.Add(target);
|
||||
break;
|
||||
@@ -3431,7 +3431,7 @@ namespace Game.AI
|
||||
}
|
||||
// min/max was checked at loading!
|
||||
e.timer = RandomHelper.URand(min, max);
|
||||
e.active = e.timer != 0 ? false : true;
|
||||
e.active = e.timer == 0;
|
||||
}
|
||||
|
||||
void UpdateTimer(SmartScriptHolder e, uint diff)
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace Game
|
||||
stmt.AddValue(0, accountId);
|
||||
stmt.AddValue(1, CalculateShaPassHash(username, password));
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
return result.IsEmpty() ? false : true;
|
||||
return !result.IsEmpty();
|
||||
}
|
||||
|
||||
public bool CheckEmail(uint accountId, string newEmail)
|
||||
|
||||
@@ -802,7 +802,7 @@ namespace Game.BattleGrounds.Zones
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void CaptureGraveyard(int i, Player Source)
|
||||
@@ -900,7 +900,7 @@ namespace Game.BattleGrounds.Zones
|
||||
default:
|
||||
//ABORT();
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void TitanRelicActivated(Player clicker)
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Game.Chat.Commands
|
||||
return false;
|
||||
|
||||
string all = args.NextString();
|
||||
bool allRanks = !string.IsNullOrEmpty(all) ? all == "all" : false;
|
||||
bool allRanks = !string.IsNullOrEmpty(all) && all == "all";
|
||||
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell);
|
||||
if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo, handler.GetSession().GetPlayer()))
|
||||
@@ -325,7 +325,7 @@ namespace Game.Chat.Commands
|
||||
return false;
|
||||
|
||||
string allStr = args.NextString();
|
||||
bool allRanks = !string.IsNullOrEmpty(allStr) ? allStr == "all" : false;
|
||||
bool allRanks = !string.IsNullOrEmpty(allStr) && allStr == "all";
|
||||
|
||||
Player target = handler.getSelectedPlayer();
|
||||
if (!target)
|
||||
|
||||
@@ -4023,7 +4023,7 @@ namespace Game.Entities
|
||||
if (keepDays == 0)
|
||||
return;
|
||||
|
||||
Player.DeleteOldCharacters(keepDays);
|
||||
DeleteOldCharacters(keepDays);
|
||||
}
|
||||
|
||||
public static void DeleteOldCharacters(int keepDays)
|
||||
|
||||
@@ -6276,7 +6276,7 @@ namespace Game.Entities
|
||||
if (groupRules)
|
||||
group.UpdateLooterGuid(go, true);
|
||||
|
||||
loot.FillLoot(lootid, LootManager.Gameobject, this, !groupRules, false, go.GetLootMode());
|
||||
loot.FillLoot(lootid, LootStorage.Gameobject, this, !groupRules, false, go.GetLootMode());
|
||||
|
||||
// get next RR player (for next loot)
|
||||
if (groupRules)
|
||||
|
||||
@@ -1973,7 +1973,7 @@ namespace Game.Entities
|
||||
PlayerSpell spell = m_spells.LookupByKey(spellId);
|
||||
|
||||
bool disabled = (spell != null) ? spell.Disabled : false;
|
||||
bool active = disabled ? spell.Active : true;
|
||||
bool active = !disabled || spell.Active;
|
||||
|
||||
bool learning = AddSpell(spellId, active, true, dependent, false, false, fromSkill);
|
||||
|
||||
@@ -2525,7 +2525,7 @@ namespace Game.Entities
|
||||
|
||||
// needs to be when spell is already learned, to prevent infinite recursion crashes
|
||||
if (Global.DB2Mgr.GetMount(spellId) != null)
|
||||
GetSession().GetCollectionMgr().AddMount(spellId, MountStatusFlags.None, false, IsInWorld ? false : true);
|
||||
GetSession().GetCollectionMgr().AddMount(spellId, MountStatusFlags.None, false, !IsInWorld);
|
||||
|
||||
// need to add Battle pets automatically into pet journal
|
||||
foreach (BattlePetSpeciesRecord entry in CliDB.BattlePetSpeciesStorage.Values)
|
||||
|
||||
@@ -5204,6 +5204,9 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
//Target
|
||||
// Used for serverside target changes, does not apply to players
|
||||
public override void SetTarget(ObjectGuid guid) { }
|
||||
|
||||
public void SetSelection(ObjectGuid guid)
|
||||
{
|
||||
SetGuidValue(UnitFields.Target, guid);
|
||||
|
||||
@@ -1403,7 +1403,7 @@ namespace Game.Entities
|
||||
loot.clear();
|
||||
uint lootid = creature.GetCreatureTemplate().LootId;
|
||||
if (lootid != 0)
|
||||
loot.FillLoot(lootid, LootManager.Creature, looter, false, false, creature.GetLootMode());
|
||||
loot.FillLoot(lootid, LootStorage.Creature, looter, false, false, creature.GetLootMode());
|
||||
|
||||
loot.generateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold);
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Game
|
||||
charInfo.HairColor = 0;
|
||||
charInfo.FacialHair = 0;
|
||||
|
||||
if (!(charInfo.CustomizationFlag == CharacterCustomizeFlags.Customize))
|
||||
if (charInfo.CustomizationFlag != CharacterCustomizeFlags.Customize)
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_ADD_AT_LOGIN_FLAG);
|
||||
stmt.AddValue(0, (ushort)AtLoginFlags.Customize);
|
||||
|
||||
@@ -724,7 +724,7 @@ namespace Game.Loots
|
||||
|
||||
if (item.reference > 0) // References processing
|
||||
{
|
||||
LootTemplate Referenced = LootManager.Reference.GetLootFor(item.reference);
|
||||
LootTemplate Referenced = LootStorage.Reference.GetLootFor(item.reference);
|
||||
if (Referenced == null)
|
||||
continue; // Error message already printed at loading stage
|
||||
|
||||
@@ -849,8 +849,8 @@ namespace Game.Loots
|
||||
{
|
||||
if (item.reference > 0)
|
||||
{
|
||||
if (LootManager.Reference.GetLootFor(item.reference) == null)
|
||||
LootManager.Reference.ReportNonExistingId(item.reference, item.itemid);
|
||||
if (LootStorage.Reference.GetLootFor(item.reference) == null)
|
||||
LootStorage.Reference.ReportNonExistingId(item.reference, item.itemid);
|
||||
else if (ref_set != null)
|
||||
ref_set.Remove(item.reference);
|
||||
}
|
||||
@@ -1005,8 +1005,8 @@ namespace Game.Loots
|
||||
{
|
||||
if (item.reference > 0)
|
||||
{
|
||||
if (LootManager.Reference.GetLootFor(item.reference) == null)
|
||||
LootManager.Reference.ReportNonExistingId(item.reference, item.itemid);
|
||||
if (LootStorage.Reference.GetLootFor(item.reference) == null)
|
||||
LootStorage.Reference.ReportNonExistingId(item.reference, item.itemid);
|
||||
else if (ref_set != null)
|
||||
ref_set.Remove(item.reference);
|
||||
}
|
||||
@@ -1016,8 +1016,8 @@ namespace Game.Loots
|
||||
{
|
||||
if (item.reference > 0)
|
||||
{
|
||||
if (LootManager.Reference.GetLootFor(item.reference) == null)
|
||||
LootManager.Reference.ReportNonExistingId(item.reference, item.itemid);
|
||||
if (LootStorage.Reference.GetLootFor(item.reference) == null)
|
||||
LootStorage.Reference.ReportNonExistingId(item.reference, item.itemid);
|
||||
else if (ref_set != null)
|
||||
ref_set.Remove(item.reference);
|
||||
}
|
||||
|
||||
@@ -826,14 +826,11 @@ namespace Game
|
||||
DespawnObject(spawns);
|
||||
|
||||
// recycle minimal amount of quests if possible count is lower than limit
|
||||
if (limit > newQuests.Count && !currentQuests.Empty())
|
||||
while (limit > newQuests.Count && !currentQuests.Empty())
|
||||
{
|
||||
do
|
||||
{
|
||||
ulong questId = currentQuests.SelectRandom();
|
||||
newQuests.Add(questId);
|
||||
currentQuests.Remove(questId);
|
||||
} while (newQuests.Count < limit && !currentQuests.Empty()); // failsafe
|
||||
ulong questId = currentQuests.SelectRandom();
|
||||
newQuests.Add(questId);
|
||||
currentQuests.Remove(questId);
|
||||
}
|
||||
|
||||
if (newQuests.Empty())
|
||||
|
||||
@@ -675,9 +675,7 @@ namespace Game
|
||||
Values[WorldCfg.ThreatRadius] = GetDefaultValue("ThreatRadius", 60.0f);
|
||||
|
||||
// always use declined names in the russian client
|
||||
Values[WorldCfg.DeclinedNamesUsed] =
|
||||
|
||||
((RealmZones)Values[WorldCfg.RealmZone] == RealmZones.Russian) ? true : GetDefaultValue("DeclinedNames", false);
|
||||
Values[WorldCfg.DeclinedNamesUsed] = (RealmZones)Values[WorldCfg.RealmZone] == RealmZones.Russian || GetDefaultValue("DeclinedNames", false);
|
||||
|
||||
Values[WorldCfg.ListenRangeSay] = GetDefaultValue("ListenRange.Say", 25.0f);
|
||||
Values[WorldCfg.ListenRangeTextemote] = GetDefaultValue("ListenRange.TextEmote", 25.0f);
|
||||
|
||||
+28
-30
@@ -1254,12 +1254,12 @@ namespace Game.Spells
|
||||
case SpellEffectName.SummonPlayer:
|
||||
if (m_caster.IsTypeId(TypeId.Player) && !m_caster.GetTarget().IsEmpty())
|
||||
{
|
||||
WorldObject target1 = Global.ObjAccessor.FindPlayer(m_caster.GetTarget());
|
||||
WorldObject rafTarget = Global.ObjAccessor.FindPlayer(m_caster.GetTarget());
|
||||
|
||||
CallScriptObjectTargetSelectHandlers(ref target1, effIndex, new SpellImplicitTargetInfo());
|
||||
CallScriptObjectTargetSelectHandlers(ref rafTarget, effIndex, new SpellImplicitTargetInfo());
|
||||
|
||||
if (target1 != null && target1.IsTypeId(TypeId.Player))
|
||||
AddUnitTarget(target1.ToUnit(), (uint)(1 << (int)effIndex), false);
|
||||
if (rafTarget != null && rafTarget.IsTypeId(TypeId.Player))
|
||||
AddUnitTarget(rafTarget.ToUnit(), (uint)(1 << (int)effIndex), false);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
@@ -4765,8 +4765,8 @@ namespace Game.Spells
|
||||
if (!m_caster.IsTypeId(TypeId.Player))
|
||||
return SpellCastResult.DontReport;
|
||||
|
||||
Unit target1 = m_targets.GetUnitTarget();
|
||||
if (target1 == null || !target1.IsFriendlyTo(m_caster) || target1.getAttackers().Empty())
|
||||
Unit target = m_targets.GetUnitTarget();
|
||||
if (target == null || !target.IsFriendlyTo(m_caster) || target.getAttackers().Empty())
|
||||
return SpellCastResult.BadTargets;
|
||||
|
||||
}
|
||||
@@ -4819,7 +4819,6 @@ namespace Game.Spells
|
||||
return SpellCastResult.BadTargets;
|
||||
|
||||
SpellInfo learn_spellproto = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell);
|
||||
|
||||
if (learn_spellproto == null)
|
||||
return SpellCastResult.NotKnown;
|
||||
|
||||
@@ -4919,9 +4918,9 @@ namespace Game.Spells
|
||||
// Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects)
|
||||
if (m_caster.IsTypeId(TypeId.Player))
|
||||
{
|
||||
Unit target1 = m_targets.GetUnitTarget();
|
||||
if (target1 != null)
|
||||
if (target1 != m_caster && unitTarget.GetPowerType() != (PowerType)effect.MiscValue)
|
||||
Unit target = m_targets.GetUnitTarget();
|
||||
if (target != null)
|
||||
if (target != m_caster && unitTarget.GetPowerType() != (PowerType)effect.MiscValue)
|
||||
return SpellCastResult.BadTargets;
|
||||
}
|
||||
break;
|
||||
@@ -4933,31 +4932,31 @@ namespace Game.Spells
|
||||
|
||||
if (GetSpellInfo().NeedsExplicitUnitTarget())
|
||||
{
|
||||
Unit target1 = m_targets.GetUnitTarget();
|
||||
if (target1 == null)
|
||||
Unit target = m_targets.GetUnitTarget();
|
||||
if (target == null)
|
||||
return SpellCastResult.DontReport;
|
||||
|
||||
|
||||
float objSize = target1.GetObjectSize();
|
||||
float objSize = target.GetObjectSize();
|
||||
float range = m_spellInfo.GetMaxRange(true, m_caster, this) * 1.5f + objSize; // can't be overly strict
|
||||
|
||||
m_preGeneratedPath.SetPathLengthLimit(range);
|
||||
//first try with raycast, if it fails fall back to normal path
|
||||
float targetObjectSize = Math.Min(target1.GetObjectSize(), 4.0f);
|
||||
bool result = m_preGeneratedPath.CalculatePath(target1.GetPositionX(), target1.GetPositionY(), target1.GetPositionZ() + targetObjectSize, false, true);
|
||||
float targetObjectSize = Math.Min(target.GetObjectSize(), 4.0f);
|
||||
bool result = m_preGeneratedPath.CalculatePath(target.GetPositionX(), target.GetPositionY(), target.GetPositionZ() + targetObjectSize, false, true);
|
||||
if (m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.Short))
|
||||
return SpellCastResult.OutOfRange;
|
||||
else if (!result || m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.NoPath | PathType.Incomplete))
|
||||
{
|
||||
result = m_preGeneratedPath.CalculatePath(target1.GetPositionX(), target1.GetPositionY(), target1.GetPositionZ() + targetObjectSize, false, false);
|
||||
result = m_preGeneratedPath.CalculatePath(target.GetPositionX(), target.GetPositionY(), target.GetPositionZ() + targetObjectSize, false, false);
|
||||
if (m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.Short))
|
||||
return SpellCastResult.OutOfRange;
|
||||
else if (!result || m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.NoPath | PathType.Incomplete))
|
||||
return SpellCastResult.NoPath;
|
||||
else if (m_preGeneratedPath.IsInvalidDestinationZ(target1)) // Check position z, if not in a straight line
|
||||
else if (m_preGeneratedPath.IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
|
||||
return SpellCastResult.NoPath;
|
||||
}
|
||||
else if (m_preGeneratedPath.IsInvalidDestinationZ(target1)) // Check position z, if in a straight line
|
||||
else if (m_preGeneratedPath.IsInvalidDestinationZ(target)) // Check position z, if in a straight line
|
||||
return SpellCastResult.NoPath;
|
||||
|
||||
m_preGeneratedPath.ReducePathLenghtByDist(objSize); //move back
|
||||
@@ -5152,10 +5151,9 @@ namespace Game.Spells
|
||||
if (playerCaster.GetTarget().IsEmpty())
|
||||
return SpellCastResult.BadTargets;
|
||||
|
||||
Player target1 = Global.ObjAccessor.FindPlayer(playerCaster.GetTarget());
|
||||
|
||||
if (target1 == null ||
|
||||
!(target1.GetSession().GetRecruiterId() == playerCaster.GetSession().GetAccountId() || target1.GetSession().GetAccountId() == playerCaster.GetSession().GetRecruiterId()))
|
||||
Player target = Global.ObjAccessor.FindPlayer(playerCaster.GetTarget());
|
||||
if (target == null ||
|
||||
!(target.GetSession().GetRecruiterId() == playerCaster.GetSession().GetAccountId() || target.GetSession().GetAccountId() == playerCaster.GetSession().GetRecruiterId()))
|
||||
return SpellCastResult.BadTargets;
|
||||
|
||||
break;
|
||||
@@ -5291,23 +5289,23 @@ namespace Game.Spells
|
||||
return SpellCastResult.AlreadyHaveCharm;
|
||||
}
|
||||
|
||||
Unit target1 = m_targets.GetUnitTarget();
|
||||
if (target1 != null)
|
||||
Unit target = m_targets.GetUnitTarget();
|
||||
if (target != null)
|
||||
{
|
||||
if (target1.IsTypeId(TypeId.Unit) && target1.ToCreature().IsVehicle())
|
||||
if (target.IsTypeId(TypeId.Unit) && target.ToCreature().IsVehicle())
|
||||
return SpellCastResult.BadImplicitTargets;
|
||||
|
||||
if (target1.IsMounted())
|
||||
if (target.IsMounted())
|
||||
return SpellCastResult.CantBeCharmed;
|
||||
|
||||
if (!target1.GetCharmerGUID().IsEmpty())
|
||||
if (!target.GetCharmerGUID().IsEmpty())
|
||||
return SpellCastResult.Charmed;
|
||||
|
||||
if (target1.GetOwner() != null && target1.GetOwner().IsTypeId(TypeId.Player))
|
||||
if (target.GetOwner() != null && target.GetOwner().IsTypeId(TypeId.Player))
|
||||
return SpellCastResult.TargetIsPlayerControlled;
|
||||
|
||||
int damage = CalculateDamage(effect.EffectIndex, target1);
|
||||
if (damage != 0 && target1.GetLevelForTarget(m_caster) > damage)
|
||||
int damage = CalculateDamage(effect.EffectIndex, target);
|
||||
if (damage != 0 && target.GetLevelForTarget(m_caster) > damage)
|
||||
return SpellCastResult.Highlevel;
|
||||
}
|
||||
|
||||
|
||||
@@ -1147,7 +1147,7 @@ namespace Game.Spells
|
||||
him, because it would be it's passenger, there's no such case where this gets to fail legitimacy, this problem
|
||||
cannot be solved from within the check in other way since target type cannot be called for the spell currently
|
||||
Spell examples: [ID - 52864 Devour Water, ID - 52862 Devour Wind, ID - 49370 Wyrmrest Defender: Destabilize Azure Dragonshrine Effect] */
|
||||
if (!caster.IsVehicle() && !(caster.GetCharmerOrOwner() == target))
|
||||
if (!caster.IsVehicle() && caster.GetCharmerOrOwner() != target)
|
||||
{
|
||||
if (TargetAuraState != 0 && !unitTarget.HasAuraState(TargetAuraState, this, caster))
|
||||
return SpellCastResult.TargetAurastate;
|
||||
|
||||
Reference in New Issue
Block a user