Core/Refactor: Part 5

This commit is contained in:
hondacrx
2018-07-05 10:57:42 -04:00
parent badf6c2714
commit 7255455b22
24 changed files with 109 additions and 85 deletions
+13 -1
View File
@@ -28,6 +28,7 @@ public class Log
static Log() static Log()
{ {
m_logsDir = AppContext.BaseDirectory + ConfigMgr.GetDefaultValue("LogsDir", ""); m_logsDir = AppContext.BaseDirectory + ConfigMgr.GetDefaultValue("LogsDir", "");
lowestLogLevel = LogLevel.Fatal;
foreach (var appenderName in ConfigMgr.GetKeysByString("Appender.")) foreach (var appenderName in ConfigMgr.GetKeysByString("Appender."))
{ {
@@ -66,11 +67,15 @@ public class Log
outInfo(LogFilter.Server, @" \/___/ `/___/> \ \ \/ \/_/\/_/\/____/ \/_/ "); outInfo(LogFilter.Server, @" \/___/ `/___/> \ \ \/ \/_/\/_/\/____/ \/_/ ");
outInfo(LogFilter.Server, @" /\___/\ \_\ "); outInfo(LogFilter.Server, @" /\___/\ \_\ ");
outInfo(LogFilter.Server, @" \/__/ \/_/ Core"); outInfo(LogFilter.Server, @" \/__/ \/_/ Core");
outInfo(LogFilter.Server, "\r"); outInfo(LogFilter.Server, "https://github.com/CypherCore/CypherCore \r\n");
} }
static bool ShouldLog(LogFilter type, LogLevel level) static bool ShouldLog(LogFilter type, LogLevel level)
{ {
// Don't even look for a logger if the LogLevel is lower than lowest log levels across all loggers
if (level < lowestLogLevel)
return false;
Logger logger = GetLoggerByType(type); Logger logger = GetLoggerByType(type);
if (logger == null) if (logger == null)
return false; return false;
@@ -256,6 +261,9 @@ public class Log
return; return;
} }
if (level < lowestLogLevel)
lowestLogLevel = level;
Logger logger = new Logger(name, level); Logger logger = new Logger(name, level);
int i = 0; int i = 0;
@@ -316,6 +324,8 @@ public class Log
if (logger.getName() == name) if (logger.getName() == name)
{ {
logger.setLogLevel(newLevel); logger.setLogLevel(newLevel);
if (newLevel != LogLevel.Disabled && newLevel < lowestLogLevel)
lowestLogLevel = newLevel;
return true; return true;
} }
} }
@@ -345,6 +355,8 @@ public class Log
static Dictionary<LogFilter, Logger> loggers = new Dictionary<LogFilter, Logger>(); static Dictionary<LogFilter, Logger> loggers = new Dictionary<LogFilter, Logger>();
static string m_logsDir; static string m_logsDir;
static byte AppenderId; static byte AppenderId;
static LogLevel lowestLogLevel;
} }
enum AppenderType enum AppenderType
@@ -177,12 +177,12 @@ namespace System.Collections.Generic
} }
} }
public interface ICheck<T> public interface ICheck<in T>
{ {
bool Invoke(T obj); bool Invoke(T obj);
} }
public interface IDoWork<T> public interface IDoWork<in T>
{ {
void Invoke(T obj); void Invoke(T obj);
} }
+9
View File
@@ -239,6 +239,7 @@ namespace Game.AI
me.m_CombatDistance = spellInfo != null ? spellInfo.GetMaxRange(false) : 0; me.m_CombatDistance = spellInfo != null ? spellInfo.GetMaxRange(false) : 0;
me.m_SightDistance = me.m_CombatDistance; me.m_SightDistance = me.m_CombatDistance;
} }
public override bool CanAIAttack(Unit victim) public override bool CanAIAttack(Unit victim)
{ {
// todo use one function to replace it // todo use one function to replace it
@@ -247,11 +248,13 @@ namespace Game.AI
return false; return false;
return true; return true;
} }
public override void AttackStart(Unit victim) public override void AttackStart(Unit victim)
{ {
if (victim != null) if (victim != null)
me.Attack(victim, false); me.Attack(victim, false);
} }
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
if (!UpdateVictim()) 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) public override void OnCharmed(bool apply)
{ {
if (!me.GetVehicleKit().IsVehicleInUse() && !apply && m_HasConditions)//was used and has conditions 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 ReactorAI(Creature c) : base(c) { }
public override void MoveInLineOfSight(Unit who) { }
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
if (!UpdateVictim()) if (!UpdateVictim())
+2
View File
@@ -65,5 +65,7 @@ namespace Game.AI
public class NullGameObjectAI : GameObjectAI public class NullGameObjectAI : GameObjectAI
{ {
public NullGameObjectAI(GameObject g) : base(g) { } public NullGameObjectAI(GameObject g) : base(g) { }
public override void UpdateAI(uint diff) { }
} }
} }
-3
View File
@@ -343,9 +343,6 @@ namespace Game.AI
// Called when spell hits a target // Called when spell hits a target
public override void SpellHitTarget(Unit target, SpellInfo spell) { } 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 // Called when AI is temporarily replaced or put back when possess is applied or removed
public virtual void OnPossess(bool apply) { } public virtual void OnPossess(bool apply) { }
+3 -3
View File
@@ -1449,7 +1449,7 @@ namespace Game.AI
break; break;
uint delay = e.Action.wpPause.delay; 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; break;
} }
case SmartActions.WpStop: case SmartActions.WpStop:
@@ -2695,7 +2695,7 @@ namespace Game.AI
} }
case SmartTargets.ClosestCreature: 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) if (target)
l.Add(target); l.Add(target);
break; break;
@@ -3431,7 +3431,7 @@ namespace Game.AI
} }
// min/max was checked at loading! // min/max was checked at loading!
e.timer = RandomHelper.URand(min, max); e.timer = RandomHelper.URand(min, max);
e.active = e.timer != 0 ? false : true; e.active = e.timer == 0;
} }
void UpdateTimer(SmartScriptHolder e, uint diff) void UpdateTimer(SmartScriptHolder e, uint diff)
+1 -1
View File
@@ -289,7 +289,7 @@ namespace Game
stmt.AddValue(0, accountId); stmt.AddValue(0, accountId);
stmt.AddValue(1, CalculateShaPassHash(username, password)); stmt.AddValue(1, CalculateShaPassHash(username, password));
SQLResult result = DB.Login.Query(stmt); SQLResult result = DB.Login.Query(stmt);
return result.IsEmpty() ? false : true; return !result.IsEmpty();
} }
public bool CheckEmail(uint accountId, string newEmail) public bool CheckEmail(uint accountId, string newEmail)
@@ -802,7 +802,7 @@ namespace Game.BattleGrounds.Zones
break; break;
default: default:
return; return;
}; }
} }
void CaptureGraveyard(int i, Player Source) void CaptureGraveyard(int i, Player Source)
@@ -900,7 +900,7 @@ namespace Game.BattleGrounds.Zones
default: default:
//ABORT(); //ABORT();
break; break;
}; }
} }
void TitanRelicActivated(Player clicker) void TitanRelicActivated(Player clicker)
+2 -2
View File
@@ -45,7 +45,7 @@ namespace Game.Chat.Commands
return false; return false;
string all = args.NextString(); 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); SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell);
if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo, handler.GetSession().GetPlayer())) if (spellInfo == null || !Global.SpellMgr.IsSpellValid(spellInfo, handler.GetSession().GetPlayer()))
@@ -325,7 +325,7 @@ namespace Game.Chat.Commands
return false; return false;
string allStr = args.NextString(); string allStr = args.NextString();
bool allRanks = !string.IsNullOrEmpty(allStr) ? allStr == "all" : false; bool allRanks = !string.IsNullOrEmpty(allStr) && allStr == "all";
Player target = handler.getSelectedPlayer(); Player target = handler.getSelectedPlayer();
if (!target) if (!target)
+1 -1
View File
@@ -4023,7 +4023,7 @@ namespace Game.Entities
if (keepDays == 0) if (keepDays == 0)
return; return;
Player.DeleteOldCharacters(keepDays); DeleteOldCharacters(keepDays);
} }
public static void DeleteOldCharacters(int keepDays) public static void DeleteOldCharacters(int keepDays)
+1 -1
View File
@@ -6276,7 +6276,7 @@ namespace Game.Entities
if (groupRules) if (groupRules)
group.UpdateLooterGuid(go, true); 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) // get next RR player (for next loot)
if (groupRules) if (groupRules)
+2 -2
View File
@@ -1973,7 +1973,7 @@ namespace Game.Entities
PlayerSpell spell = m_spells.LookupByKey(spellId); PlayerSpell spell = m_spells.LookupByKey(spellId);
bool disabled = (spell != null) ? spell.Disabled : false; 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); 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 // needs to be when spell is already learned, to prevent infinite recursion crashes
if (Global.DB2Mgr.GetMount(spellId) != null) 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 // need to add Battle pets automatically into pet journal
foreach (BattlePetSpeciesRecord entry in CliDB.BattlePetSpeciesStorage.Values) foreach (BattlePetSpeciesRecord entry in CliDB.BattlePetSpeciesStorage.Values)
+3
View File
@@ -5204,6 +5204,9 @@ namespace Game.Entities
} }
//Target //Target
// Used for serverside target changes, does not apply to players
public override void SetTarget(ObjectGuid guid) { }
public void SetSelection(ObjectGuid guid) public void SetSelection(ObjectGuid guid)
{ {
SetGuidValue(UnitFields.Target, guid); SetGuidValue(UnitFields.Target, guid);
+1 -1
View File
@@ -1403,7 +1403,7 @@ namespace Game.Entities
loot.clear(); loot.clear();
uint lootid = creature.GetCreatureTemplate().LootId; uint lootid = creature.GetCreatureTemplate().LootId;
if (lootid != 0) 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); loot.generateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold);
+1 -1
View File
@@ -83,7 +83,7 @@ namespace Game
charInfo.HairColor = 0; charInfo.HairColor = 0;
charInfo.FacialHair = 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); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_ADD_AT_LOGIN_FLAG);
stmt.AddValue(0, (ushort)AtLoginFlags.Customize); stmt.AddValue(0, (ushort)AtLoginFlags.Customize);
+7 -7
View File
@@ -724,7 +724,7 @@ namespace Game.Loots
if (item.reference > 0) // References processing if (item.reference > 0) // References processing
{ {
LootTemplate Referenced = LootManager.Reference.GetLootFor(item.reference); LootTemplate Referenced = LootStorage.Reference.GetLootFor(item.reference);
if (Referenced == null) if (Referenced == null)
continue; // Error message already printed at loading stage continue; // Error message already printed at loading stage
@@ -849,8 +849,8 @@ namespace Game.Loots
{ {
if (item.reference > 0) if (item.reference > 0)
{ {
if (LootManager.Reference.GetLootFor(item.reference) == null) if (LootStorage.Reference.GetLootFor(item.reference) == null)
LootManager.Reference.ReportNonExistingId(item.reference, item.itemid); LootStorage.Reference.ReportNonExistingId(item.reference, item.itemid);
else if (ref_set != null) else if (ref_set != null)
ref_set.Remove(item.reference); ref_set.Remove(item.reference);
} }
@@ -1005,8 +1005,8 @@ namespace Game.Loots
{ {
if (item.reference > 0) if (item.reference > 0)
{ {
if (LootManager.Reference.GetLootFor(item.reference) == null) if (LootStorage.Reference.GetLootFor(item.reference) == null)
LootManager.Reference.ReportNonExistingId(item.reference, item.itemid); LootStorage.Reference.ReportNonExistingId(item.reference, item.itemid);
else if (ref_set != null) else if (ref_set != null)
ref_set.Remove(item.reference); ref_set.Remove(item.reference);
} }
@@ -1016,8 +1016,8 @@ namespace Game.Loots
{ {
if (item.reference > 0) if (item.reference > 0)
{ {
if (LootManager.Reference.GetLootFor(item.reference) == null) if (LootStorage.Reference.GetLootFor(item.reference) == null)
LootManager.Reference.ReportNonExistingId(item.reference, item.itemid); LootStorage.Reference.ReportNonExistingId(item.reference, item.itemid);
else if (ref_set != null) else if (ref_set != null)
ref_set.Remove(item.reference); ref_set.Remove(item.reference);
} }
+4 -7
View File
@@ -826,14 +826,11 @@ namespace Game
DespawnObject(spawns); DespawnObject(spawns);
// recycle minimal amount of quests if possible count is lower than limit // 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);
ulong questId = currentQuests.SelectRandom(); currentQuests.Remove(questId);
newQuests.Add(questId);
currentQuests.Remove(questId);
} while (newQuests.Count < limit && !currentQuests.Empty()); // failsafe
} }
if (newQuests.Empty()) if (newQuests.Empty())
+1 -3
View File
@@ -675,9 +675,7 @@ namespace Game
Values[WorldCfg.ThreatRadius] = GetDefaultValue("ThreatRadius", 60.0f); Values[WorldCfg.ThreatRadius] = GetDefaultValue("ThreatRadius", 60.0f);
// always use declined names in the russian client // always use declined names in the russian client
Values[WorldCfg.DeclinedNamesUsed] = Values[WorldCfg.DeclinedNamesUsed] = (RealmZones)Values[WorldCfg.RealmZone] == RealmZones.Russian || GetDefaultValue("DeclinedNames", false);
((RealmZones)Values[WorldCfg.RealmZone] == RealmZones.Russian) ? true : GetDefaultValue("DeclinedNames", false);
Values[WorldCfg.ListenRangeSay] = GetDefaultValue("ListenRange.Say", 25.0f); Values[WorldCfg.ListenRangeSay] = GetDefaultValue("ListenRange.Say", 25.0f);
Values[WorldCfg.ListenRangeTextemote] = GetDefaultValue("ListenRange.TextEmote", 25.0f); Values[WorldCfg.ListenRangeTextemote] = GetDefaultValue("ListenRange.TextEmote", 25.0f);
+28 -30
View File
@@ -1254,12 +1254,12 @@ namespace Game.Spells
case SpellEffectName.SummonPlayer: case SpellEffectName.SummonPlayer:
if (m_caster.IsTypeId(TypeId.Player) && !m_caster.GetTarget().IsEmpty()) 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)) if (rafTarget != null && rafTarget.IsTypeId(TypeId.Player))
AddUnitTarget(target1.ToUnit(), (uint)(1 << (int)effIndex), false); AddUnitTarget(rafTarget.ToUnit(), (uint)(1 << (int)effIndex), false);
} }
return; return;
default: default:
@@ -4765,8 +4765,8 @@ namespace Game.Spells
if (!m_caster.IsTypeId(TypeId.Player)) if (!m_caster.IsTypeId(TypeId.Player))
return SpellCastResult.DontReport; return SpellCastResult.DontReport;
Unit target1 = m_targets.GetUnitTarget(); Unit target = m_targets.GetUnitTarget();
if (target1 == null || !target1.IsFriendlyTo(m_caster) || target1.getAttackers().Empty()) if (target == null || !target.IsFriendlyTo(m_caster) || target.getAttackers().Empty())
return SpellCastResult.BadTargets; return SpellCastResult.BadTargets;
} }
@@ -4819,7 +4819,6 @@ namespace Game.Spells
return SpellCastResult.BadTargets; return SpellCastResult.BadTargets;
SpellInfo learn_spellproto = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell); SpellInfo learn_spellproto = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell);
if (learn_spellproto == null) if (learn_spellproto == null)
return SpellCastResult.NotKnown; 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) // 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)) if (m_caster.IsTypeId(TypeId.Player))
{ {
Unit target1 = m_targets.GetUnitTarget(); Unit target = m_targets.GetUnitTarget();
if (target1 != null) if (target != null)
if (target1 != m_caster && unitTarget.GetPowerType() != (PowerType)effect.MiscValue) if (target != m_caster && unitTarget.GetPowerType() != (PowerType)effect.MiscValue)
return SpellCastResult.BadTargets; return SpellCastResult.BadTargets;
} }
break; break;
@@ -4933,31 +4932,31 @@ namespace Game.Spells
if (GetSpellInfo().NeedsExplicitUnitTarget()) if (GetSpellInfo().NeedsExplicitUnitTarget())
{ {
Unit target1 = m_targets.GetUnitTarget(); Unit target = m_targets.GetUnitTarget();
if (target1 == null) if (target == null)
return SpellCastResult.DontReport; 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 float range = m_spellInfo.GetMaxRange(true, m_caster, this) * 1.5f + objSize; // can't be overly strict
m_preGeneratedPath.SetPathLengthLimit(range); m_preGeneratedPath.SetPathLengthLimit(range);
//first try with raycast, if it fails fall back to normal path //first try with raycast, if it fails fall back to normal path
float targetObjectSize = Math.Min(target1.GetObjectSize(), 4.0f); float targetObjectSize = Math.Min(target.GetObjectSize(), 4.0f);
bool result = m_preGeneratedPath.CalculatePath(target1.GetPositionX(), target1.GetPositionY(), target1.GetPositionZ() + targetObjectSize, false, true); bool result = m_preGeneratedPath.CalculatePath(target.GetPositionX(), target.GetPositionY(), target.GetPositionZ() + targetObjectSize, false, true);
if (m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.Short)) if (m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.Short))
return SpellCastResult.OutOfRange; return SpellCastResult.OutOfRange;
else if (!result || m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.NoPath | PathType.Incomplete)) 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)) if (m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.Short))
return SpellCastResult.OutOfRange; return SpellCastResult.OutOfRange;
else if (!result || m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.NoPath | PathType.Incomplete)) else if (!result || m_preGeneratedPath.GetPathType().HasAnyFlag(PathType.NoPath | PathType.Incomplete))
return SpellCastResult.NoPath; 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; 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; return SpellCastResult.NoPath;
m_preGeneratedPath.ReducePathLenghtByDist(objSize); //move back m_preGeneratedPath.ReducePathLenghtByDist(objSize); //move back
@@ -5152,10 +5151,9 @@ namespace Game.Spells
if (playerCaster.GetTarget().IsEmpty()) if (playerCaster.GetTarget().IsEmpty())
return SpellCastResult.BadTargets; return SpellCastResult.BadTargets;
Player target1 = Global.ObjAccessor.FindPlayer(playerCaster.GetTarget()); Player target = Global.ObjAccessor.FindPlayer(playerCaster.GetTarget());
if (target == null ||
if (target1 == null || !(target.GetSession().GetRecruiterId() == playerCaster.GetSession().GetAccountId() || target.GetSession().GetAccountId() == playerCaster.GetSession().GetRecruiterId()))
!(target1.GetSession().GetRecruiterId() == playerCaster.GetSession().GetAccountId() || target1.GetSession().GetAccountId() == playerCaster.GetSession().GetRecruiterId()))
return SpellCastResult.BadTargets; return SpellCastResult.BadTargets;
break; break;
@@ -5291,23 +5289,23 @@ namespace Game.Spells
return SpellCastResult.AlreadyHaveCharm; return SpellCastResult.AlreadyHaveCharm;
} }
Unit target1 = m_targets.GetUnitTarget(); Unit target = m_targets.GetUnitTarget();
if (target1 != null) if (target != null)
{ {
if (target1.IsTypeId(TypeId.Unit) && target1.ToCreature().IsVehicle()) if (target.IsTypeId(TypeId.Unit) && target.ToCreature().IsVehicle())
return SpellCastResult.BadImplicitTargets; return SpellCastResult.BadImplicitTargets;
if (target1.IsMounted()) if (target.IsMounted())
return SpellCastResult.CantBeCharmed; return SpellCastResult.CantBeCharmed;
if (!target1.GetCharmerGUID().IsEmpty()) if (!target.GetCharmerGUID().IsEmpty())
return SpellCastResult.Charmed; return SpellCastResult.Charmed;
if (target1.GetOwner() != null && target1.GetOwner().IsTypeId(TypeId.Player)) if (target.GetOwner() != null && target.GetOwner().IsTypeId(TypeId.Player))
return SpellCastResult.TargetIsPlayerControlled; return SpellCastResult.TargetIsPlayerControlled;
int damage = CalculateDamage(effect.EffectIndex, target1); int damage = CalculateDamage(effect.EffectIndex, target);
if (damage != 0 && target1.GetLevelForTarget(m_caster) > damage) if (damage != 0 && target.GetLevelForTarget(m_caster) > damage)
return SpellCastResult.Highlevel; return SpellCastResult.Highlevel;
} }
+1 -1
View File
@@ -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 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 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] */ 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)) if (TargetAuraState != 0 && !unitTarget.HasAuraState(TargetAuraState, this, caster))
return SpellCastResult.TargetAurastate; return SpellCastResult.TargetAurastate;
@@ -564,10 +564,10 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion
{ {
me.InterruptNonMeleeSpells(true); me.InterruptNonMeleeSpells(true);
Unit target1 = Global.ObjAccessor.GetUnit(me, uiTargetGUID); Unit uiTarget = Global.ObjAccessor.GetUnit(me, uiTargetGUID);
if (target1 && me.IsInRange(target1, 5.0f, 30.0f, false)) if (uiTarget && me.IsInRange(uiTarget, 5.0f, 30.0f, false))
{ {
DoCast(target1, TrialOfChampionSpells.MULTI_SHOT); DoCast(uiTarget, TrialOfChampionSpells.MULTI_SHOT);
} }
else else
{ {
@@ -1091,10 +1091,12 @@ namespace Scripts.Northrend.IcecrownCitadel
switch (eventId) switch (eventId)
{ {
case EventTypes.ArnathFlashHeal: case EventTypes.ArnathFlashHeal:
Creature target = FindFriendlyCreature(); {
if (target) Creature target = FindFriendlyCreature();
DoCast(target, InstanceSpells.SpellFlashHeal(IsUndead)); if (target)
_events.ScheduleEvent(EventTypes.ArnathFlashHeal, RandomHelper.URand(6000, 9000)); DoCast(target, InstanceSpells.SpellFlashHeal(IsUndead));
_events.ScheduleEvent(EventTypes.ArnathFlashHeal, RandomHelper.URand(6000, 9000));
}
break; break;
case EventTypes.ArnathPwShield: case EventTypes.ArnathPwShield:
{ {
@@ -1108,10 +1110,12 @@ namespace Scripts.Northrend.IcecrownCitadel
_events.ScheduleEvent(EventTypes.ArnathSmite, RandomHelper.URand(4000, 7000)); _events.ScheduleEvent(EventTypes.ArnathSmite, RandomHelper.URand(4000, 7000));
break; break;
case EventTypes.ArnathDominateMind: case EventTypes.ArnathDominateMind:
Unit target1 = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); {
if (target1) Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true);
DoCast(target1, InstanceSpells.DominateMind); if (target)
_events.ScheduleEvent(EventTypes.ArnathDominateMind, RandomHelper.URand(28000, 37000)); DoCast(target, InstanceSpells.DominateMind);
_events.ScheduleEvent(EventTypes.ArnathDominateMind, RandomHelper.URand(28000, 37000));
}
break; break;
default: default:
break; break;
@@ -145,9 +145,9 @@ namespace Scripts.Northrend.IcecrownCitadel
public const uint FlashHealUndead = 71782; public const uint FlashHealUndead = 71782;
public const uint PowerWordShieldUndead = 71780; public const uint PowerWordShieldUndead = 71780;
public const uint SmiteUndead = 71778; public const uint SmiteUndead = 71778;
public static uint SpellFlashHeal(bool isUndead) { return isUndead ? InstanceSpells.FlashHealUndead : InstanceSpells.FlashHealNormal; } public static uint SpellFlashHeal(bool isUndead) { return isUndead ? FlashHealUndead : FlashHealNormal; }
public static uint SpellPowerWordShield(bool isUndead) { return isUndead ? InstanceSpells.PowerWordShieldUndead : InstanceSpells.PowerWordShieldNormal; } public static uint SpellPowerWordShield(bool isUndead) { return isUndead ? PowerWordShieldUndead : PowerWordShieldNormal; }
public static uint SpellSmite(bool isUndead) { return isUndead ? InstanceSpells.SmiteUndead : InstanceSpells.SmiteNormal; } public static uint SpellSmite(bool isUndead) { return isUndead ? SmiteUndead : SmiteNormal; }
// Captain Brandon // Captain Brandon
public const uint CrusaderStrike = 71549; public const uint CrusaderStrike = 71549;
@@ -168,9 +168,9 @@ namespace Scripts.Northrend.IcecrownCitadel
public const uint FelIronBombUndead = 71787; public const uint FelIronBombUndead = 71787;
public const uint MachineGunUndead = 71788; public const uint MachineGunUndead = 71788;
public const uint RocketLaunchUndead = 71786; public const uint RocketLaunchUndead = 71786;
public static uint SpellFelIronBomb(bool isUndead) { return isUndead ? InstanceSpells.FelIronBombUndead : InstanceSpells.FelIronBombNormal; } public static uint SpellFelIronBomb(bool isUndead) { return isUndead ? FelIronBombUndead : FelIronBombNormal; }
public static uint SpellMachineGun(bool isUndead) { return isUndead ? InstanceSpells.MachineGunUndead : InstanceSpells.MachineGunNormal; } public static uint SpellMachineGun(bool isUndead) { return isUndead ? MachineGunUndead : MachineGunNormal; }
public static uint SpellRocketLaunch(bool isUndead) { return isUndead ? InstanceSpells.RocketLaunchUndead : InstanceSpells.RocketLaunchNormal; } public static uint SpellRocketLaunch(bool isUndead) { return isUndead ? RocketLaunchUndead : RocketLaunchNormal; }
// Invisible Stalker (Float; Uninteractible; Largeaoi) // Invisible Stalker (Float; Uninteractible; Largeaoi)
public const uint SoulMissile = 72585; public const uint SoulMissile = 72585;
@@ -0,0 +1,4 @@
-- The Stonecore normal donjon portal
DELETE FROM `gameobject` WHERE `guid`=200868;
INSERT INTO `gameobject` (`guid`, `id`, `map`, `zoneId`, `areaId`, `spawnMask`, `phaseUseFlags`, `PhaseId`, `PhaseGroup`, `terrainSwapMap`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation0`, `rotation1`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`, `ScriptName`, `VerifiedBuild`) VALUES
(200868, 207897, 646, 5042, 5303, 1, 0, 169, 0, -1, 1029.14, 618.686, 155.706, 1.77533, 0, 0, 0.775599, 0.631225, 120, 255, 1, "", 26365);