Updated to 8.2.0.31429 (scripts disabled atm, they still need updated)
Code Port from TrinityCore https://github.com/TrinityCore/TrinityCore Casc from WoW-Tools https://github.com/WoW-Tools/CASCExplorer
This commit is contained in:
@@ -70,7 +70,7 @@ namespace Game.AI
|
||||
return new VehicleAI(creature);
|
||||
else if (creature.HasUnitTypeMask(UnitTypeMask.ControlableGuardian) && ((Guardian)creature).GetOwner().IsTypeId(TypeId.Player))
|
||||
return new PetAI(creature);
|
||||
else if (creature.HasFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick))
|
||||
else if (creature.HasNpcFlag(NPCFlags.SpellClick))
|
||||
return new NullCreatureAI(creature);
|
||||
else if (creature.IsGuard())
|
||||
return new GuardAI(creature);
|
||||
|
||||
@@ -333,9 +333,9 @@ namespace Game.AI
|
||||
if (point)
|
||||
{
|
||||
point.SetObjectScale(SharedConst.BoundaryVisualizeCreatureScale);
|
||||
point.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.Stunned | UnitFlags.ImmuneToNpc);
|
||||
point.AddUnitFlag(UnitFlags.ImmuneToPc | UnitFlags.Stunned | UnitFlags.ImmuneToNpc);
|
||||
if (!hasOutOfBoundsNeighbor)
|
||||
point.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable);
|
||||
point.AddUnitFlag(UnitFlags.NotSelectable);
|
||||
}
|
||||
Q.Remove(front);
|
||||
}
|
||||
|
||||
@@ -65,14 +65,14 @@ namespace Game.AI
|
||||
public override void JustDied(Unit unit)
|
||||
{
|
||||
// We died while possessed, disable our loot
|
||||
me.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Lootable);
|
||||
me.RemoveDynamicFlag(UnitDynFlags.Lootable);
|
||||
}
|
||||
|
||||
public override void KilledUnit(Unit victim)
|
||||
{
|
||||
// We killed a creature, disable victim's loot
|
||||
if (victim.IsTypeId(TypeId.Unit))
|
||||
victim.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Lootable);
|
||||
me.RemoveDynamicFlag(UnitDynFlags.Lootable);
|
||||
}
|
||||
|
||||
public override void OnCharmed(bool apply)
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace Game.AI
|
||||
public PlayerAI(Player player) : base(player)
|
||||
{
|
||||
me = player;
|
||||
_selfSpec = player.GetUInt32Value(PlayerFields.CurrentSpecId);
|
||||
_selfSpec = player.GetPrimarySpecialization();
|
||||
_isSelfHealer = IsPlayerHealer(player);
|
||||
_isSelfRangedAttacker = IsPlayerRangedAttacker(player);
|
||||
}
|
||||
@@ -414,15 +414,15 @@ namespace Game.AI
|
||||
default:
|
||||
return false;
|
||||
case Class.Paladin:
|
||||
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.PaladinHoly;
|
||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.PaladinHoly;
|
||||
case Class.Priest:
|
||||
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.PriestDiscipline || who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.PriestHoly;
|
||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.PriestDiscipline || who.GetPrimarySpecialization() == (uint)TalentSpecialization.PriestHoly;
|
||||
case Class.Shaman:
|
||||
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.ShamanRestoration;
|
||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.ShamanRestoration;
|
||||
case Class.Monk:
|
||||
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.MonkMistweaver;
|
||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.MonkMistweaver;
|
||||
case Class.Druid:
|
||||
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.DruidRestoration;
|
||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.DruidRestoration;
|
||||
}
|
||||
}
|
||||
bool IsPlayerRangedAttacker(Player who)
|
||||
@@ -454,11 +454,11 @@ namespace Game.AI
|
||||
return false;
|
||||
}
|
||||
case Class.Priest:
|
||||
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.PriestShadow;
|
||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.PriestShadow;
|
||||
case Class.Shaman:
|
||||
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.ShamanElemental;
|
||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.ShamanElemental;
|
||||
case Class.Druid:
|
||||
return who.GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.DruidBalance;
|
||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.DruidBalance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -659,7 +659,7 @@ namespace Game.AI
|
||||
return (!who || who == me) ? _isSelfHealer : IsPlayerHealer(who);
|
||||
}
|
||||
public bool IsRangedAttacker(Player who = null) { return (!who || who == me) ? _isSelfRangedAttacker : IsPlayerRangedAttacker(who); }
|
||||
uint GetSpec(Player who = null) { return (!who || who == me) ? _selfSpec : who.GetUInt32Value(PlayerFields.CurrentSpecId); }
|
||||
uint GetSpec(Player who = null) { return (!who || who == me) ? _selfSpec : who.GetPrimarySpecialization(); }
|
||||
void SetIsRangedAttacker(bool state) { _isSelfRangedAttacker = state; } // this allows overriding of the default ranged attacker detection
|
||||
|
||||
public virtual Unit SelectAttackTarget() { return me.GetCharmer() ? me.GetCharmer().GetVictim() : null; }
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Game.AI
|
||||
return null;
|
||||
|
||||
//Silenced so we can't cast
|
||||
if (me.HasFlag(UnitFields.Flags, UnitFlags.Silenced))
|
||||
if (me.HasUnitFlag(UnitFlags.Silenced))
|
||||
return null;
|
||||
|
||||
//Using the extended script system we first create a list of viable spells
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace Game.AI
|
||||
//add a small delay before going to first waypoint, normal in near all cases
|
||||
m_uiWPWaitTimer = 1000;
|
||||
|
||||
if (me.getFaction() != me.GetCreatureTemplate().Faction)
|
||||
if (me.GetFaction() != me.GetCreatureTemplate().Faction)
|
||||
me.RestoreFaction();
|
||||
|
||||
Reset();
|
||||
@@ -162,7 +162,7 @@ namespace Game.AI
|
||||
{
|
||||
me.GetMotionMaster().MoveTargetedHome();
|
||||
if (HasImmuneToNPCFlags)
|
||||
me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToNpc);
|
||||
me.AddUnitFlag(UnitFlags.ImmuneToNpc);
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
@@ -463,11 +463,12 @@ namespace Game.AI
|
||||
}
|
||||
|
||||
//disable npcflags
|
||||
me.SetUInt64Value(UnitFields.NpcFlags, (ulong)NPCFlags.None);
|
||||
if (me.HasFlag(UnitFields.Flags, UnitFlags.ImmuneToNpc))
|
||||
me.SetNpcFlags(NPCFlags.None);
|
||||
me.SetNpcFlags2(NPCFlags2.None);
|
||||
if (me.HasUnitFlag(UnitFlags.ImmuneToNpc))
|
||||
{
|
||||
HasImmuneToNPCFlags = true;
|
||||
me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToNpc);
|
||||
me.RemoveUnitFlag(UnitFlags.ImmuneToNpc);
|
||||
}
|
||||
|
||||
Log.outDebug(LogFilter.Scripts, $"EscortAI started. ActiveAttacker = {m_bIsActiveAttacker}, Run = {m_bIsRunning}, PlayerGUID = {m_uiPlayerGUID.ToString()}");
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace Game.AI
|
||||
if (!IsCombatMovementAllowed())
|
||||
SetCombatMovement(true);
|
||||
|
||||
if (me.getFaction() != me.GetCreatureTemplate().Faction)
|
||||
if (me.GetFaction() != me.GetCreatureTemplate().Faction)
|
||||
me.SetFaction(me.GetCreatureTemplate().Faction);
|
||||
|
||||
Reset();
|
||||
@@ -318,7 +318,8 @@ namespace Game.AI
|
||||
Log.outDebug(LogFilter.Scripts, "FollowerAI start with WAYPOINT_MOTION_TYPE, set to MoveIdle.");
|
||||
}
|
||||
|
||||
me.SetUInt64Value(UnitFields.NpcFlags, (uint)NPCFlags.None);
|
||||
me.SetNpcFlags(NPCFlags.None);
|
||||
me.SetNpcFlags2(NPCFlags2.None);
|
||||
|
||||
AddFollowState(eFollowState.Inprogress);
|
||||
|
||||
|
||||
@@ -131,8 +131,8 @@ namespace Game.AI
|
||||
|
||||
if (invoker && invoker.GetTypeId() == TypeId.Player)
|
||||
{
|
||||
mEscortNPCFlags = me.GetUInt32Value(UnitFields.NpcFlags);
|
||||
me.SetFlag(UnitFields.NpcFlags, 0);
|
||||
mEscortNPCFlags = me.m_unitData.NpcFlags[0];
|
||||
me.SetNpcFlags(NPCFlags.None);
|
||||
}
|
||||
|
||||
GetScript().ProcessEventsFor(SmartEvents.WaypointStart, null, mCurrentWPID, GetScript().GetPathId());
|
||||
@@ -227,7 +227,7 @@ namespace Game.AI
|
||||
|
||||
if (mEscortNPCFlags != 0)
|
||||
{
|
||||
me.SetFlag(UnitFields.NpcFlags, mEscortNPCFlags);
|
||||
me.SetNpcFlags((NPCFlags)mEscortNPCFlags);
|
||||
mEscortNPCFlags = 0;
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ namespace Game.AI
|
||||
mDespawnState = 0;
|
||||
mEscortState = SmartEscortState.None;
|
||||
me.SetVisible(true);
|
||||
if (me.getFaction() != me.GetCreatureTemplate().Faction)
|
||||
if (me.GetFaction() != me.GetCreatureTemplate().Faction)
|
||||
me.RestoreFaction();
|
||||
mJustReset = true;
|
||||
JustReachedHome();
|
||||
@@ -646,7 +646,7 @@ namespace Game.AI
|
||||
public override void AttackStart(Unit who)
|
||||
{
|
||||
// dont allow charmed npcs to act on their own
|
||||
if (me.HasFlag(UnitFields.Flags, UnitFlags.PlayerControlled))
|
||||
if (me.HasUnitFlag(UnitFlags.PlayerControlled))
|
||||
{
|
||||
if (who && mCanAutoAttack)
|
||||
me.Attack(who, true);
|
||||
|
||||
@@ -1715,7 +1715,7 @@ namespace Game.AI
|
||||
[FieldOffset(16)]
|
||||
public Raw raw;
|
||||
|
||||
[FieldOffset(32)]
|
||||
[FieldOffset(40)]
|
||||
public string param_string;
|
||||
|
||||
#region Structs
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace Game.AI
|
||||
CreatureTemplate ci = Global.ObjectMgr.GetCreatureTemplate(obj.ToCreature().GetEntry());
|
||||
if (ci != null)
|
||||
{
|
||||
if (obj.ToCreature().getFaction() != ci.Faction)
|
||||
if (obj.ToCreature().GetFaction() != ci.Faction)
|
||||
{
|
||||
obj.ToCreature().SetFaction(ci.Faction);
|
||||
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SET_FACTION: Creature entry {0}, GuidLow {1} set faction to {2}",
|
||||
@@ -647,7 +647,7 @@ namespace Game.AI
|
||||
{
|
||||
if (IsUnit(obj))
|
||||
{
|
||||
obj.ToUnit().SetUInt32Value(UnitFields.NpcEmotestate, e.Action.emote.emoteId);
|
||||
obj.ToUnit().SetEmoteState((Emote)e.Action.emote.emoteId);
|
||||
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SET_EMOTE_STATE. Unit {0} set emotestate to {1}",
|
||||
obj.GetGUID().ToString(), e.Action.emote.emoteId);
|
||||
}
|
||||
@@ -668,13 +668,13 @@ namespace Game.AI
|
||||
{
|
||||
if (e.Action.unitFlag.type == 0)
|
||||
{
|
||||
obj.ToUnit().SetFlag(UnitFields.Flags, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().AddUnitFlag((UnitFlags)e.Action.unitFlag.flag);
|
||||
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SET_UNIT_FLAG. Unit {0} added flag {1} to UNIT_FIELD_FLAGS",
|
||||
obj.GetGUID().ToString(), e.Action.unitFlag.flag);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.ToUnit().SetFlag(UnitFields.Flags2, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().AddUnitFlag2((UnitFlags2)e.Action.unitFlag.flag);
|
||||
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_SET_UNIT_FLAG. Unit {0} added flag {1} to UNIT_FIELD_FLAGS_2",
|
||||
obj.GetGUID().ToString(), e.Action.unitFlag.flag);
|
||||
}
|
||||
@@ -696,13 +696,13 @@ namespace Game.AI
|
||||
{
|
||||
if (e.Action.unitFlag.type == 0)
|
||||
{
|
||||
obj.ToUnit().RemoveFlag(UnitFields.Flags2, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().RemoveUnitFlag((UnitFlags)e.Action.unitFlag.flag);
|
||||
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_REMOVE_UNIT_FLAG. Unit {0} removed flag {1} to UNIT_FIELD_FLAGS",
|
||||
obj.GetGUID().ToString(), e.Action.unitFlag.flag);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.ToUnit().RemoveFlag(UnitFields.Flags2, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().RemoveUnitFlag2((UnitFlags2)e.Action.unitFlag.flag);
|
||||
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_REMOVE_UNIT_FLAG. Unit {0} removed flag {1} to UNIT_FIELD_FLAGS_2",
|
||||
obj.GetGUID().ToString(), e.Action.unitFlag.flag);
|
||||
}
|
||||
@@ -1756,7 +1756,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsUnit(obj))
|
||||
obj.ToUnit().SetUInt64Value(UnitFields.NpcFlags, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().SetNpcFlags((NPCFlags)e.Action.unitFlag.flag);
|
||||
break;
|
||||
}
|
||||
case SmartActions.AddNpcFlag:
|
||||
@@ -1767,7 +1767,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsUnit(obj))
|
||||
obj.ToUnit().SetFlag64(UnitFields.NpcFlags, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().AddNpcFlag((NPCFlags)e.Action.unitFlag.flag);
|
||||
break;
|
||||
}
|
||||
case SmartActions.RemoveNpcFlag:
|
||||
@@ -1778,7 +1778,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsUnit(obj))
|
||||
obj.ToUnit().RemoveFlag64(UnitFields.NpcFlags, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().RemoveNpcFlag((NPCFlags)e.Action.unitFlag.flag);
|
||||
break;
|
||||
}
|
||||
case SmartActions.CrossCast:
|
||||
@@ -1937,7 +1937,25 @@ namespace Game.AI
|
||||
break;
|
||||
foreach (var obj in targets)
|
||||
if (IsUnit(obj))
|
||||
obj.ToUnit().SetByteFlag(UnitFields.Bytes1, (byte)e.Action.setunitByte.type, e.Action.setunitByte.byte1);
|
||||
{
|
||||
switch (e.Action.setunitByte.type)
|
||||
{
|
||||
case 0:
|
||||
obj.ToUnit().SetStandState((UnitStandStateType)e.Action.setunitByte.byte1);
|
||||
break;
|
||||
case 1:
|
||||
// pet talent points
|
||||
break;
|
||||
case 2:
|
||||
obj.ToUnit().AddVisFlags((UnitVisFlags)e.Action.setunitByte.byte1);
|
||||
break;
|
||||
case 3:
|
||||
// this is totally wrong to maintain compatibility with existing scripts
|
||||
// TODO: fix with animtier overhaul
|
||||
obj.ToUnit().SetAnimTier((UnitBytes1Flags)(obj.ToUnit().m_unitData.AnimTier | e.Action.setunitByte.byte1), false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SmartActions.RemoveUnitFieldBytes1:
|
||||
@@ -1948,7 +1966,23 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsUnit(obj))
|
||||
obj.ToUnit().RemoveByteFlag(UnitFields.Bytes1, (byte)e.Action.delunitByte.type, e.Action.delunitByte.byte1);
|
||||
{
|
||||
switch (e.Action.setunitByte.type)
|
||||
{
|
||||
case 0:
|
||||
obj.ToUnit().SetStandState(UnitStandStateType.Stand);
|
||||
break;
|
||||
case 1:
|
||||
// pet talent points
|
||||
break;
|
||||
case 2:
|
||||
obj.ToUnit().RemoveVisFlags((UnitVisFlags)e.Action.setunitByte.byte1);
|
||||
break;
|
||||
case 3:
|
||||
obj.ToUnit().SetAnimTier((UnitBytes1Flags)(obj.ToUnit().m_unitData.AnimTier & ~e.Action.setunitByte.byte1), false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SmartActions.InterruptSpell:
|
||||
@@ -1981,7 +2015,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsUnit(obj))
|
||||
obj.ToUnit().SetUInt32Value(ObjectFields.DynamicFlags, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().SetDynamicFlags((UnitDynFlags)e.Action.unitFlag.flag);
|
||||
break;
|
||||
}
|
||||
case SmartActions.AddDynamicFlag:
|
||||
@@ -1992,7 +2026,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsUnit(obj))
|
||||
obj.ToUnit().SetFlag(ObjectFields.DynamicFlags, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().AddDynamicFlag((UnitDynFlags)e.Action.unitFlag.flag);
|
||||
break;
|
||||
}
|
||||
case SmartActions.RemoveDynamicFlag:
|
||||
@@ -2003,7 +2037,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsUnit(obj))
|
||||
obj.ToUnit().RemoveFlag(ObjectFields.DynamicFlags, e.Action.unitFlag.flag);
|
||||
obj.ToUnit().RemoveDynamicFlag((UnitDynFlags)e.Action.unitFlag.flag);
|
||||
break;
|
||||
}
|
||||
case SmartActions.JumpToPos:
|
||||
@@ -2163,7 +2197,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsGameObject(obj))
|
||||
obj.ToGameObject().SetUInt32Value(GameObjectFields.Flags, e.Action.goFlag.flag);
|
||||
obj.ToGameObject().SetFlags((GameObjectFlags)e.Action.goFlag.flag);
|
||||
break;
|
||||
}
|
||||
case SmartActions.AddGoFlag:
|
||||
@@ -2174,7 +2208,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsGameObject(obj))
|
||||
obj.ToGameObject().SetFlag(GameObjectFields.Flags, e.Action.goFlag.flag);
|
||||
obj.ToGameObject().AddFlag((GameObjectFlags)e.Action.goFlag.flag);
|
||||
break;
|
||||
}
|
||||
case SmartActions.RemoveGoFlag:
|
||||
@@ -2185,7 +2219,7 @@ namespace Game.AI
|
||||
|
||||
foreach (var obj in targets)
|
||||
if (IsGameObject(obj))
|
||||
obj.ToGameObject().RemoveFlag(GameObjectFields.Flags, e.Action.goFlag.flag);
|
||||
obj.ToGameObject().RemoveFlag((GameObjectFlags)e.Action.goFlag.flag);
|
||||
break;
|
||||
}
|
||||
case SmartActions.SummonCreatureGroup:
|
||||
|
||||
Reference in New Issue
Block a user