Core/Battlegrounds: Move to scripts And a lot of misc commits i couldn't recover.

Port From (https://github.com/TrinityCore/TrinityCore/commit/d0d5d309bb5877dc2fcb27f6cb123707a31ec1e8)
This commit is contained in:
Hondacrx
2024-08-04 15:18:22 -04:00
parent bca02a24b0
commit e9b21a91be
139 changed files with 8322 additions and 8700 deletions
@@ -285,7 +285,7 @@ namespace Game.Entities
public class AreaTriggerSpawn : SpawnData
{
public AreaTriggerId Id;
public new AreaTriggerId Id;
public uint? SpellForVisuals;
public AreaTriggerSpawn() : base(SpawnObjectType.AreaTrigger) { }
+7 -3
View File
@@ -2588,11 +2588,15 @@ namespace Game.Entities
// Send a message to LocalDefense channel for players opposition team in the zone
public void SendZoneUnderAttackMessage(Player attacker)
{
Team enemy_team = attacker.GetTeam();
ZoneUnderAttack packet = new();
packet.AreaID = (int)GetAreaId();
Global.WorldMgr.SendGlobalMessage(packet, null, (enemy_team == Team.Alliance ? Team.Horde : Team.Alliance));
packet.Write();
Team enemyTeam = attacker.GetTeam();
if (enemyTeam != Team.Alliance)
Global.WorldMgr.SendGlobalMessage(packet, null, Team.Alliance);
if (enemyTeam != Team.Horde)
Global.WorldMgr.SendGlobalMessage(packet, null, Team.Horde);
}
public void SetCanMelee(bool canMelee, bool fleeFromMelee = false)
+71 -125
View File
@@ -290,9 +290,10 @@ namespace Game.Entities
m_goValue.FishingHole.MaxOpens = RandomHelper.URand(GetGoInfo().FishingHole.minRestock, GetGoInfo().FishingHole.maxRestock);
break;
case GameObjectTypes.DestructibleBuilding:
m_goValue.Building.Health = 20000;//goinfo.DestructibleBuilding.intactNumHits + goinfo.DestructibleBuilding.damagedNumHits;
m_goValue.Building.MaxHealth = m_goValue.Building.Health;
m_goValue.Building.DestructibleHitpoint = Global.ObjectMgr.GetDestructibleHitpoint(GetGoInfo().DestructibleBuilding.HealthRec);
m_goValue.Building.Health = m_goValue.Building.DestructibleHitpoint != null ? m_goValue.Building.DestructibleHitpoint.GetMaxHealth() : 0;
SetGoAnimProgress(255);
// yes, even after the updatefield rewrite this garbage hack is still in client
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.ParentRotation), new Quaternion(goInfo.DestructibleBuilding.DestructibleModelRec, 0f, 0f, 0f));
break;
@@ -1366,13 +1367,24 @@ namespace Game.Entities
}
}
public bool CanActivateForPlayer(Player target)
{
if (!MeetsInteractCondition(target))
return false;
if (!ActivateToQuest(target))
return false;
return true;
}
public bool ActivateToQuest(Player target)
{
if (target.HasQuestForGO((int)GetEntry()))
return true;
if (!Global.ObjectMgr.IsGameObjectForQuests(GetEntry()))
return false;
return true;
switch (GetGoType())
{
@@ -1393,9 +1405,6 @@ namespace Game.Entities
|| LootStorage.Gameobject.HaveQuestLootForPlayer(GetGoInfo().Chest.chestPersonalLoot, target)
|| LootStorage.Gameobject.HaveQuestLootForPlayer(GetGoInfo().Chest.chestPushLoot, target))
{
Battleground bg = target.GetBattleground();
if (bg != null)
return bg.CanActivateGO((int)GetEntry(), (uint)bg.GetPlayerTeam(target.GetGUID()));
return true;
}
break;
@@ -1406,6 +1415,12 @@ namespace Game.Entities
return true;
break;
}
case GameObjectTypes.SpellFocus:
{
if (target.GetQuestStatus(GetGoInfo().SpellFocus.questID) == QuestStatus.Incomplete)
return true;
break;
}
case GameObjectTypes.Goober:
{
if (target.GetQuestStatus(GetGoInfo().Goober.questID) == QuestStatus.Incomplete)
@@ -1701,10 +1716,6 @@ namespace Game.Entities
if (player == null)
return;
Battleground bg = player.GetBattleground();
if (bg != null && !bg.CanActivateGO((int)GetEntry(), (uint)bg.GetPlayerTeam(user.GetGUID())))
return;
GameObjectTemplate info = GetGoInfo();
if (loot == null && info.GetLootId() != 0)
{
@@ -2250,7 +2261,6 @@ namespace Game.Entities
break;
}
case GameObjectTypes.FlagStand: // 24
{
if (!user.IsTypeId(TypeId.Player))
@@ -2260,29 +2270,15 @@ namespace Game.Entities
if (player.CanUseBattlegroundObject(this))
{
// in Battlegroundcheck
Battleground bg = player.GetBattleground();
if (bg == null)
return;
if (player.GetVehicle() != null)
return;
player.RemoveAurasByType(AuraType.ModStealth);
player.RemoveAurasByType(AuraType.ModInvisibility);
// BG flag click
// AB:
// 15001
// 15002
// 15003
// 15004
// 15005
bg.EventPlayerClickedOnFlag(player, this);
return; //we don;t need to delete flag ... it is despawned!
}
break;
}
case GameObjectTypes.FishingHole: // 25
{
if (!user.IsTypeId(TypeId.Player))
@@ -2290,7 +2286,7 @@ namespace Game.Entities
Player player = user.ToPlayer();
Loot loot = new Loot(GetMap(), GetGUID(), LootType.Fishinghole, null);
Loot loot = new(GetMap(), GetGUID(), LootType.Fishinghole, null);
loot.FillLoot(GetGoInfo().GetLootId(), LootStorage.Gameobject, player, true, false, LootModes.Default, ItemBonusMgr.GetContextForPlayer(GetMap().GetMapDifficulty(), player));
m_personalLoot[player.GetGUID()] = loot;
@@ -2298,7 +2294,6 @@ namespace Game.Entities
player.UpdateCriteria(CriteriaType.CatchFishInFishingHole, GetGoInfo().entry);
return;
}
case GameObjectTypes.FlagDrop: // 26
{
if (!user.IsTypeId(TypeId.Player))
@@ -2308,11 +2303,6 @@ namespace Game.Entities
if (player.CanUseBattlegroundObject(this))
{
// in Battlegroundcheck
Battleground bg = player.GetBattleground();
if (bg == null)
return;
if (player.GetVehicle() != null)
return;
@@ -2325,24 +2315,8 @@ namespace Game.Entities
// EotS:
// 184142 - Netherstorm Flag
GameObjectTemplate info = GetGoInfo();
if (info != null)
{
switch (info.entry)
{
case 179785: // Silverwing Flag
case 179786: // Warsong Flag
if (bg.GetTypeID() == BattlegroundTypeId.WS)
bg.EventPlayerClickedOnFlag(player, this);
break;
case 184142: // Netherstorm Flag
if (bg.GetTypeID() == BattlegroundTypeId.EY)
bg.EventPlayerClickedOnFlag(player, this);
break;
}
if (info.FlagDrop.eventID != 0)
GameEvents.Trigger(info.FlagDrop.eventID, player, this);
}
if (info != null && info.FlagDrop.eventID != 0)
GameEvents.Trigger(info.FlagDrop.eventID, player, this);
//this cause to call return, all flags must be deleted here!!
spellId = 0;
Delete();
@@ -2462,10 +2436,9 @@ namespace Game.Entities
return;
Player player = user.ToPlayer();
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(info.ItemForge.conditionID1);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(player, playerCondition))
return;
if (!MeetsInteractCondition(player))
return;
switch (info.ItemForge.ForgeType)
{
@@ -2743,7 +2716,7 @@ namespace Game.Entities
public void SetLocalRotation(float qx, float qy, float qz, float qw)
{
Quaternion rotation = new Quaternion(qx, qy, qz, qw);
Quaternion rotation = new(qx, qy, qz, qw);
rotation = Quaternion.Multiply(rotation, 1.0f / MathF.Sqrt(Quaternion.Dot(rotation, rotation)));
m_localRotation.X = rotation.X;
@@ -2880,7 +2853,7 @@ namespace Game.Entities
public void ModifyHealth(int change, WorldObject attackerOrHealer = null, uint spellId = 0)
{
if (m_goValue.Building.MaxHealth == 0 || change == 0)
if (m_goValue.Building.DestructibleHitpoint == null || change == 0)
return;
// prevent double destructions of the same object
@@ -2889,13 +2862,13 @@ namespace Game.Entities
if (m_goValue.Building.Health + change <= 0)
m_goValue.Building.Health = 0;
else if (m_goValue.Building.Health + change >= m_goValue.Building.MaxHealth)
m_goValue.Building.Health = m_goValue.Building.MaxHealth;
else if (m_goValue.Building.Health + change >= m_goValue.Building.DestructibleHitpoint.GetMaxHealth())
m_goValue.Building.Health = m_goValue.Building.DestructibleHitpoint.GetMaxHealth();
else
m_goValue.Building.Health += (uint)change;
// Set the health bar, value = 255 * healthPct;
SetGoAnimProgress(m_goValue.Building.Health * 255 / m_goValue.Building.MaxHealth);
SetGoAnimProgress(m_goValue.Building.Health * 255 / m_goValue.Building.DestructibleHitpoint.GetMaxHealth());
// dealing damage, send packet
Player player = attackerOrHealer != null ? attackerOrHealer.GetCharmerOrOwnerPlayerOrPlayerItself() : null;
@@ -2917,9 +2890,9 @@ namespace Game.Entities
if (m_goValue.Building.Health == 0)
newState = GameObjectDestructibleState.Destroyed;
else if (m_goValue.Building.Health < m_goValue.Building.MaxHealth / 2)
else if (m_goValue.Building.Health < m_goValue.Building.DestructibleHitpoint.DamagedNumHits)
newState = GameObjectDestructibleState.Damaged;
else if (m_goValue.Building.Health == m_goValue.Building.MaxHealth)
else if (m_goValue.Building.Health == m_goValue.Building.DestructibleHitpoint.GetMaxHealth())
newState = GameObjectDestructibleState.Intact;
if (newState == GetDestructibleState())
@@ -2938,9 +2911,9 @@ namespace Game.Entities
case GameObjectDestructibleState.Intact:
RemoveFlag(GameObjectFlags.Damaged | GameObjectFlags.Destroyed);
SetDisplayId(m_goInfo.displayId);
if (setHealth)
if (setHealth && m_goValue.Building.DestructibleHitpoint != null)
{
m_goValue.Building.Health = m_goValue.Building.MaxHealth;
m_goValue.Building.Health = m_goValue.Building.DestructibleHitpoint.GetMaxHealth();
SetGoAnimProgress(255);
}
EnableCollision(true);
@@ -2959,12 +2932,13 @@ namespace Game.Entities
if (modelData != null)
if (modelData.State1Wmo != 0)
modelId = modelData.State1Wmo;
SetDisplayId(modelId);
if (setHealth)
if (setHealth && m_goValue.Building.DestructibleHitpoint != null)
{
m_goValue.Building.Health = 10000;//m_goInfo.DestructibleBuilding.damagedNumHits;
uint maxHealth = m_goValue.Building.MaxHealth;
m_goValue.Building.Health = m_goValue.Building.DestructibleHitpoint.DamagedNumHits;
uint maxHealth = m_goValue.Building.DestructibleHitpoint.GetMaxHealth();
// in this case current health is 0 anyway so just prevent crashing here
if (maxHealth == 0)
maxHealth = 1;
@@ -2978,14 +2952,6 @@ namespace Game.Entities
GameEvents.Trigger(GetGoInfo().DestructibleBuilding.DestroyedEvent, attackerOrHealer, this);
GetAI().Destroyed(attackerOrHealer, m_goInfo.DestructibleBuilding.DestroyedEvent);
Player player = attackerOrHealer != null ? attackerOrHealer.GetCharmerOrOwnerPlayerOrPlayerItself() : null;
if (player != null)
{
Battleground bg = player.GetBattleground();
if (bg != null)
bg.DestroyGate(player, this);
}
RemoveFlag(GameObjectFlags.Damaged);
SetFlag(GameObjectFlags.Destroyed);
@@ -2994,6 +2960,7 @@ namespace Game.Entities
if (modelData != null)
if (modelData.State2Wmo != 0)
modelId = modelData.State2Wmo;
SetDisplayId(modelId);
if (setHealth)
@@ -3018,9 +2985,9 @@ namespace Game.Entities
SetDisplayId(modelId);
// restores to full health
if (setHealth)
if (setHealth & m_goValue.Building.DestructibleHitpoint != null)
{
m_goValue.Building.Health = m_goValue.Building.MaxHealth;
m_goValue.Building.Health = m_goValue.Building.DestructibleHitpoint.GetMaxHealth();
SetGoAnimProgress(255);
}
EnableCollision(true);
@@ -3318,8 +3285,7 @@ namespace Game.Entities
public List<uint> GetPauseTimes()
{
GameObjectType.Transport transport = m_goTypeImpl as GameObjectType.Transport;
if (transport != null)
if (m_goTypeImpl is GameObjectType.Transport transport)
return transport.GetPauseTimes();
return null;
@@ -3655,8 +3621,7 @@ namespace Game.Entities
if (GetGoType() != GameObjectTypes.NewFlag)
return 0;
GameObjectType.NewFlag newFlag = m_goTypeImpl as GameObjectType.NewFlag;
if (newFlag == null)
if (m_goTypeImpl is not GameObjectType.NewFlag newFlag)
return 0;
return newFlag.GetState();
@@ -3667,8 +3632,7 @@ namespace Game.Entities
if (GetGoType() != GameObjectTypes.NewFlag)
return ObjectGuid.Empty;
GameObjectType.NewFlag newFlag = m_goTypeImpl as GameObjectType.NewFlag;
if (newFlag == null)
if (m_goTypeImpl is not GameObjectType.NewFlag newFlag)
return ObjectGuid.Empty;
return newFlag.GetCarrierGUID();
@@ -3679,8 +3643,7 @@ namespace Game.Entities
if (GetGoType() != GameObjectTypes.NewFlag)
return 0;
GameObjectType.NewFlag newFlag = m_goTypeImpl as GameObjectType.NewFlag;
if (newFlag == null)
if (m_goTypeImpl is not GameObjectType.NewFlag newFlag)
return 0;
return newFlag.GetTakenFromBaseTime();
@@ -3688,8 +3651,7 @@ namespace Game.Entities
public List<ObjectGuid> GetInsidePlayers()
{
ControlZone controlZone = m_goTypeImpl as ControlZone;
if (controlZone != null)
if (m_goTypeImpl is ControlZone controlZone)
return controlZone.GetInsidePlayers();
return null;
@@ -3697,15 +3659,7 @@ namespace Game.Entities
public bool MeetsInteractCondition(Player user)
{
if (m_goInfo.GetConditionID1() == 0)
return true;
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(m_goInfo.GetConditionID1());
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(user, playerCondition))
return false;
return true;
return ConditionManager.IsPlayerMeetingCondition(user, m_goInfo.GetConditionID1());
}
PerPlayerState GetOrCreatePerPlayerStates(ObjectGuid guid)
@@ -3797,17 +3751,17 @@ namespace Game.Entities
public GameObjectTypes GetGoType() { return (GameObjectTypes)(sbyte)m_gameObjectData.TypeID; }
public void SetGoType(GameObjectTypes type) { SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.TypeID), (sbyte)type); }
public GameObjectState GetGoState() { return (GameObjectState)(sbyte)m_gameObjectData.State; }
uint GetGoArtKit() { return m_gameObjectData.ArtKit; }
byte GetGoAnimProgress() { return m_gameObjectData.PercentHealth; }
public uint GetGoArtKit() { return m_gameObjectData.ArtKit; }
public byte GetGoAnimProgress() { return m_gameObjectData.PercentHealth; }
public void SetGoAnimProgress(uint animprogress) { SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.PercentHealth), (byte)animprogress); }
public LootState GetLootState() { return m_lootState; }
public LootModes GetLootMode() { return m_LootMode; }
bool HasLootMode(LootModes lootMode) { return Convert.ToBoolean(m_LootMode & lootMode); }
void SetLootMode(LootModes lootMode) { m_LootMode = lootMode; }
void AddLootMode(LootModes lootMode) { m_LootMode |= lootMode; }
void RemoveLootMode(LootModes lootMode) { m_LootMode &= ~lootMode; }
void ResetLootMode() { m_LootMode = LootModes.Default; }
public bool HasLootMode(LootModes lootMode) { return Convert.ToBoolean(m_LootMode & lootMode); }
public void SetLootMode(LootModes lootMode) { m_LootMode = lootMode; }
public void AddLootMode(LootModes lootMode) { m_LootMode |= lootMode; }
public void RemoveLootMode(LootModes lootMode) { m_LootMode &= ~lootMode; }
public void ResetLootMode() { m_LootMode = LootModes.Default; }
public void AddToSkillupList(ObjectGuid PlayerGuid) { m_SkillupList.Add(PlayerGuid); }
public bool IsInSkillupList(ObjectGuid PlayerGuid)
@@ -3818,17 +3772,17 @@ namespace Game.Entities
return false;
}
void ClearSkillupList() { m_SkillupList.Clear(); }
public void ClearSkillupList() { m_SkillupList.Clear(); }
public void AddUse() { ++m_usetimes; }
public uint GetUseCount() { return m_usetimes; }
uint GetUniqueUseCount() { return (uint)m_unique_users.Count; }
public uint GetUniqueUseCount() { return (uint)m_unique_users.Count; }
List<ObjectGuid> GetTapList() { return m_tapList; }
void SetTapList(List<ObjectGuid> tapList) { m_tapList = tapList; }
public List<ObjectGuid> GetTapList() { return m_tapList; }
public void SetTapList(List<ObjectGuid> tapList) { m_tapList = tapList; }
bool HasLootRecipient() { return !m_tapList.Empty(); }
public bool HasLootRecipient() { return !m_tapList.Empty(); }
public override uint GetLevelForTarget(WorldObject target)
{
@@ -4006,14 +3960,9 @@ namespace Game.Entities
}
// Base class for GameObject type specific implementations
public class GameObjectTypeBase
public class GameObjectTypeBase(GameObject owner)
{
protected GameObject _owner;
public GameObjectTypeBase(GameObject owner)
{
_owner = owner;
}
protected GameObject _owner = owner;
public virtual void Update(uint diff) { }
public virtual void OnStateChanged(GameObjectState oldState, GameObjectState newState) { }
@@ -4057,7 +4006,7 @@ namespace Game.Entities
public struct building
{
public uint Health;
public uint MaxHealth;
public DestructibleHitpoint DestructibleHitpoint;
}
//42 GAMEOBJECT_TYPE_CAPTURE_POINT
public struct capturePoint
@@ -4149,12 +4098,12 @@ namespace Game.Entities
uint now = GameTime.GetGameTimeMS();
uint period = GetTransportPeriod();
uint newProgress = 0;
uint newProgress;
if (_stopFrames.Empty())
newProgress = now % period;
else
{
int stopTargetTime = 0;
int stopTargetTime;
if (_owner.GetGoState() == GameObjectState.TransportActive)
stopTargetTime = 0;
else
@@ -4179,7 +4128,7 @@ namespace Game.Entities
progressPct = pathPctBetweenStops * timeSinceStopProgressPct + stopSourcePathPct;
if (progressPct > 1.0f)
progressPct = progressPct - 1.0f;
progressPct = -1.0f;
}
else
{
@@ -4379,8 +4328,7 @@ namespace Game.Entities
{
foreach (WorldObject passenger in _passengers)
{
float x, y, z, o;
passenger.m_movementInfo.transport.pos.GetPosition(out x, out y, out z, out o);
passenger.m_movementInfo.transport.pos.GetPosition(out float x, out float y, out float z, out float o);
CalculatePassengerPosition(ref x, ref y, ref z, ref o);
ITransport.UpdatePassengerPosition(this, _owner.GetMap(), passenger, x, y, z, o, true);
}
@@ -4529,7 +4477,7 @@ namespace Game.Entities
public long GetTakenFromBaseTime() { return _takenFromBaseTime; }
}
class SetNewFlagState : GameObjectTypeBase.CustomCommand
public class SetNewFlagState : GameObjectTypeBase.CustomCommand
{
FlagState _state;
Player _player;
@@ -4542,8 +4490,7 @@ namespace Game.Entities
public override void Execute(GameObjectTypeBase type)
{
NewFlag newFlag = type as NewFlag;
if (newFlag != null)
if (type is NewFlag newFlag)
newFlag.SetState(_state, _player);
}
}
@@ -4793,8 +4740,7 @@ namespace Game.Entities
public override void Execute(GameObjectTypeBase type)
{
ControlZone controlZone = type as ControlZone;
if (controlZone != null)
if (type is ControlZone controlZone)
{
uint value = controlZone.GetStartingValue();
if (_value.HasValue)
@@ -267,6 +267,15 @@ namespace Game.Entities
}
}
public uint GetQuestID() => type switch
{
GameObjectTypes.Chest => Chest.questID,
GameObjectTypes.Generic => Generic.questID,
GameObjectTypes.SpellFocus => SpellFocus.questID,
GameObjectTypes.Goober => Goober.questID,
_ => 0
};
public uint GetConditionID1() => type switch
{
GameObjectTypes.Door => Door.conditionID1,
@@ -1648,4 +1657,13 @@ namespace Game.Entities
public GameObjectData() : base(SpawnObjectType.GameObject) { }
}
public class DestructibleHitpoint
{
public uint Id;
public uint IntactNumHits;
public uint DamagedNumHits;
public uint GetMaxHealth() { return IntactNumHits + DamagedNumHits; }
}
}
+1 -5
View File
@@ -296,11 +296,7 @@ namespace Game.Entities
public bool CanUseEssences()
{
PlayerConditionRecord condition = CliDB.PlayerConditionStorage.LookupByKey(PlayerConst.PlayerConditionIdUnlockedAzeriteEssences);
if (condition != null)
return ConditionManager.IsPlayerMeetingCondition(GetOwner(), condition);
return false;
return ConditionManager.IsPlayerMeetingCondition(GetOwner(), PlayerConst.PlayerConditionIdUnlockedAzeriteEssences);
}
public bool HasUnlockedEssenceSlot(byte slot)
+15 -22
View File
@@ -72,10 +72,8 @@ namespace Game.Entities
if (itemProto.GetArtifactID() != artifactAppearanceSet.ArtifactID)
continue;
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(artifactAppearance.UnlockPlayerConditionID);
if (playerCondition != null)
if (owner == null || !ConditionManager.IsPlayerMeetingCondition(owner, playerCondition))
continue;
if (owner == null || !ConditionManager.IsPlayerMeetingCondition(owner, artifactAppearance.UnlockPlayerConditionID))
continue;
SetModifier(ItemModifier.ArtifactAppearanceId, artifactAppearance.Id);
SetAppearanceModId(artifactAppearance.ItemAppearanceModifierID);
@@ -591,13 +589,9 @@ namespace Game.Entities
if (_bonusData.GemRelicType[e - EnchantmentSlot.Sock1] != -1)
{
ArtifactPowerPickerRecord artifactPowerPicker = CliDB.ArtifactPowerPickerStorage.LookupByKey(enchant.EffectArg[i]);
if (artifactPowerPicker != null)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(artifactPowerPicker.PlayerConditionID);
if (playerCondition == null || (owner != null && ConditionManager.IsPlayerMeetingCondition(owner, playerCondition)))
if (artifactPower.Label == _bonusData.GemRelicType[e - EnchantmentSlot.Sock1])
power.CurrentRankWithBonus += (byte)enchant.EffectPointsMin[i];
}
if (artifactPowerPicker != null && owner != null && ConditionManager.IsPlayerMeetingCondition(owner, artifactPowerPicker.PlayerConditionID))
if (artifactPower.Label == _bonusData.GemRelicType[e - EnchantmentSlot.Sock1])
power.CurrentRankWithBonus += (byte)enchant.EffectPointsMin[i];
}
break;
default:
@@ -793,7 +787,7 @@ namespace Game.Entities
return !IsInBag() && (m_slot < EquipmentSlot.End
|| (m_slot >= ProfessionSlots.Start && m_slot < ProfessionSlots.End));
}
public bool CanBeTraded(bool mail = false, bool trade = false)
{
if (m_lootGenerated)
@@ -876,7 +870,7 @@ namespace Game.Entities
return cost;
}
bool HasEnchantRequiredSkill(Player player)
{
// Check all enchants for required skill
@@ -995,11 +989,11 @@ namespace Game.Entities
{
var oldEnchant = CliDB.SpellItemEnchantmentStorage.LookupByKey(GetEnchantmentId(slot));
if (oldEnchant != null && !oldEnchant.HasFlag(SpellItemEnchantmentFlags.DoNotLog))
owner.GetSession().SendEnchantmentLog(GetOwnerGUID(), ObjectGuid.Empty, GetGUID(), GetEntry(), oldEnchant.Id, (uint)slot);
owner.GetSession().SendEnchantmentLog(GetOwnerGUID(), ObjectGuid.Empty, GetGUID(), GetEntry(), oldEnchant.Id, (uint)slot);
var newEnchant = CliDB.SpellItemEnchantmentStorage.LookupByKey(id);
if (newEnchant != null && !newEnchant.HasFlag(SpellItemEnchantmentFlags.DoNotLog))
owner.GetSession().SendEnchantmentLog(GetOwnerGUID(), caster, GetGUID(), GetEntry(), id, (uint)slot);
owner.GetSession().SendEnchantmentLog(GetOwnerGUID(), caster, GetGUID(), GetEntry(), id, (uint)slot);
}
ApplyArtifactPowerEnchantmentBonuses(slot, GetEnchantmentId(slot), false, owner);
@@ -2059,7 +2053,7 @@ namespace Game.Entities
return itemModifiedAppearanceId;
}
public uint GetVisibleSecondaryModifiedAppearanceId(Player owner)
{
uint itemModifiedAppearanceId = GetModifier(ItemConst.SecondaryAppearanceModifierSlotBySpec[owner.GetActiveTalentGroup()]);
@@ -2068,7 +2062,7 @@ namespace Game.Entities
return itemModifiedAppearanceId;
}
public uint GetVisibleEnchantmentId(Player owner)
{
uint enchantmentId = GetModifier(ItemConst.IllusionModifierSlotBySpec[owner.GetActiveTalentGroup()]);
@@ -2290,8 +2284,7 @@ namespace Game.Entities
ArtifactPowerPickerRecord artifactPowerPicker = CliDB.ArtifactPowerPickerStorage.LookupByKey(enchant.EffectArg[i]);
if (artifactPowerPicker != null)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(artifactPowerPicker.PlayerConditionID);
if (playerCondition == null || ConditionManager.IsPlayerMeetingCondition(owner, playerCondition))
if (ConditionManager.IsPlayerMeetingCondition(owner, artifactPowerPicker.PlayerConditionID))
{
for (int artifactPowerIndex = 0; artifactPowerIndex < m_itemData.ArtifactPowers.Size(); ++artifactPowerIndex)
{
@@ -2413,7 +2406,7 @@ namespace Game.Entities
{
return $"{base.GetDebugInfo()}\nOwner: {GetOwnerGUID()} Count: {GetCount()} BagSlot: {GetBagSlot()} Slot: {GetSlot()} Equipped: {IsEquipped()}";
}
public static Item NewItemOrBag(ItemTemplate proto)
{
if (proto.GetInventoryType() == InventoryType.Bag)
@@ -2685,8 +2678,8 @@ namespace Game.Entities
public void SetChildItem(ObjectGuid childItem) { m_childItem = childItem; }
public ItemEffectRecord[] GetEffects() { return _bonusData.Effects[0.._bonusData.EffectCount]; }
public override Loot GetLootForPlayer(Player player) { return loot; }
public override Loot GetLootForPlayer(Player player) { return loot; }
//Static
public static bool ItemCanGoIntoBag(ItemTemplate pProto, ItemTemplate pBagProto)
@@ -50,6 +50,9 @@ namespace Game.Entities
public static ItemContext GetContextForPlayer(MapDifficultyRecord mapDifficulty, Player player)
{
if (mapDifficulty == null)
return ItemContext.None;
ItemContext evalContext(ItemContext currentContext, ItemContext newContext)
{
if (newContext == ItemContext.None)
@@ -81,11 +84,7 @@ namespace Game.Entities
bool meetsPlayerCondition = false;
if (player != null)
{
var playerCondition = CliDB.PlayerConditionStorage.LookupByKey(itemContextPickerEntry.PlayerConditionID);
if (playerCondition != null)
meetsPlayerCondition = ConditionManager.IsPlayerMeetingCondition(player, playerCondition);
}
meetsPlayerCondition = ConditionManager.IsPlayerMeetingCondition(player, itemContextPickerEntry.PlayerConditionID);
if ((itemContextPickerEntry.Flags & 0x1) != 0)
meetsPlayerCondition = !meetsPlayerCondition;
@@ -112,29 +112,33 @@ namespace Game.Entities
ushort pathProgress = 0xFFFF;
switch (gameObject.GetGoType())
{
case GameObjectTypes.Button:
case GameObjectTypes.Goober:
if (gameObject.GetGoInfo().GetQuestID() != 0 || gameObject.GetGoInfo().GetConditionID1() != 0)
{
if (gameObject.CanActivateForPlayer(receiver))
{
dynFlags |= GameObjectDynamicLowFlags.Highlight;
if (gameObject.GetGoStateFor(receiver.GetGUID()) != GameObjectState.Active)
dynFlags |= GameObjectDynamicLowFlags.Activate;
}
}
break;
case GameObjectTypes.QuestGiver:
if (gameObject.ActivateToQuest(receiver))
if (gameObject.CanActivateForPlayer(receiver))
dynFlags |= GameObjectDynamicLowFlags.Activate;
break;
case GameObjectTypes.Chest:
if (gameObject.ActivateToQuest(receiver))
if (gameObject.CanActivateForPlayer(receiver))
dynFlags |= GameObjectDynamicLowFlags.Activate | GameObjectDynamicLowFlags.Sparkle | GameObjectDynamicLowFlags.Highlight;
else if (receiver.IsGameMaster())
dynFlags |= GameObjectDynamicLowFlags.Activate;
break;
case GameObjectTypes.Goober:
if (gameObject.ActivateToQuest(receiver))
{
dynFlags |= GameObjectDynamicLowFlags.Highlight;
if (gameObject.GetGoStateFor(receiver.GetGUID()) != GameObjectState.Active)
dynFlags |= GameObjectDynamicLowFlags.Activate;
}
else if (receiver.IsGameMaster())
dynFlags |= GameObjectDynamicLowFlags.Activate;
dynFlags |= GameObjectDynamicLowFlags.Activate | GameObjectDynamicLowFlags.Sparkle;
break;
case GameObjectTypes.Generic:
if (gameObject.ActivateToQuest(receiver))
dynFlags |= GameObjectDynamicLowFlags.Sparkle | GameObjectDynamicLowFlags.Highlight;
case GameObjectTypes.SpellFocus:
if (gameObject.GetGoInfo().GetQuestID() != 0 || gameObject.GetGoInfo().GetConditionID1() != 0)
if (gameObject.CanActivateForPlayer(receiver))
dynFlags |= GameObjectDynamicLowFlags.Sparkle | GameObjectDynamicLowFlags.Highlight;
break;
case GameObjectTypes.Transport:
case GameObjectTypes.MapObjTransport:
@@ -150,7 +154,7 @@ namespace Game.Entities
dynFlags &= ~GameObjectDynamicLowFlags.NoInterract;
break;
case GameObjectTypes.GatheringNode:
if (gameObject.ActivateToQuest(receiver))
if (gameObject.CanActivateForPlayer(receiver))
dynFlags |= GameObjectDynamicLowFlags.Activate | GameObjectDynamicLowFlags.Sparkle | GameObjectDynamicLowFlags.Highlight;
if (gameObject.GetGoStateFor(receiver.GetGUID()) == GameObjectState.Active)
dynFlags |= GameObjectDynamicLowFlags.Depleted;
@@ -159,7 +163,7 @@ namespace Game.Entities
break;
}
if (!gameObject.MeetsInteractCondition(receiver))
if (!receiver.IsGameMaster() && !gameObject.MeetsInteractCondition(receiver))
dynFlags |= GameObjectDynamicLowFlags.NoInterract;
unitDynFlags = ((uint)pathProgress << 16) | (uint)dynFlags;
@@ -2789,22 +2793,25 @@ namespace Game.Entities
public UpdateField<uint> HonorLevel = new(0, 30);
public UpdateField<long> LogoutTime = new(0, 31);
public UpdateFieldString Name = new(32, 33);
public UpdateField<int> Field_B0 = new(32, 34);
public UpdateField<int> Field_B4 = new(32, 35);
public UpdateField<int> Field_1AC = new(32, 34);
public UpdateField<int> Field_1B0 = new(32, 35);
public UpdateField<int> CurrentBattlePetSpeciesID = new(32, 36);
public UpdateField<CTROptions> CtrOptions = new(32, 37);
public UpdateField<int> CovenantID = new(32, 38);
public UpdateField<int> SoulbindID = new(32, 39);
public UpdateField<DungeonScoreSummary> DungeonScore = new(32, 40);
public OptionalUpdateField<DeclinedNames> DeclinedNames = new(32, 41);
public UpdateField<CustomTabardInfo> PersonalTabard = new(32, 42);
public UpdateFieldArray<byte> PartyType = new(2, 43, 44);
public UpdateFieldArray<QuestLog> QuestLog = new(175, 46, 47);
public UpdateFieldArray<VisibleItem> VisibleItems = new(19, 222, 223);
public UpdateFieldArray<float> AvgItemLevel = new(6, 242, 243);
public UpdateFieldArray<uint> Field_3120 = new(19, 249, 250);
public UpdateField<ObjectGuid> SpectateTarget = new(32, 41);
public UpdateField<int> Field_200 = new(32, 42);
public OptionalUpdateField<DeclinedNames> DeclinedNames = new(32, 43);
public UpdateField<CustomTabardInfo> PersonalTabard = new(32, 44);
public UpdateFieldArray<byte> PartyType = new(2, 45, 46);
public UpdateFieldArray<QuestLog> QuestLog = new(175, 48, 49);
public UpdateFieldArray<VisibleItem> VisibleItems = new(19, 224, 225);
public UpdateFieldArray<float> AvgItemLevel = new(6, 244, 245);
public UpdateFieldArray<ItemInstance> VisibleEquipableSpells = new(16, 251, 252);
public UpdateFieldArray<uint> Field_3120 = new(19, 268, 269);
public PlayerData() : base(0, TypeId.Player, 269) { }
public PlayerData() : base(0, TypeId.Player, 288) { }
public void WriteCreate(WorldPacket data, UpdateFieldFlag fieldVisibilityFlags, Player owner, Player receiver)
{
@@ -2854,12 +2861,14 @@ namespace Game.Entities
data.WriteUInt32(HonorLevel);
data.WriteInt64(LogoutTime);
data.WriteInt32(ArenaCooldowns.Size());
data.WriteInt32(Field_B0);
data.WriteInt32(Field_B4);
data.WriteInt32(Field_1AC);
data.WriteInt32(Field_1B0);
data.WriteInt32(CurrentBattlePetSpeciesID);
((CTROptions)CtrOptions).WriteCreate(data, owner, receiver);
data.WriteInt32(CovenantID);
data.WriteInt32(SoulbindID);
data.WritePackedGuid(SpectateTarget);
data.WriteInt32(Field_200);
data.WriteInt32(VisualItemReplacements.Size());
for (int i = 0; i < 19; ++i)
{
@@ -2899,6 +2908,10 @@ namespace Game.Entities
data.WriteBits(DeclinedNames.HasValue(), 1);
DungeonScore._value.Write(data);
data.WriteString(Name);
for (int i = 0; i < 16; ++i)
{
VisibleEquipableSpells[i].Write(data);
}
if (DeclinedNames.HasValue())
{
DeclinedNames.GetValue().WriteCreate(data, owner, receiver);
@@ -2908,7 +2921,7 @@ namespace Game.Entities
public void WriteUpdate(WorldPacket data, UpdateFieldFlag fieldVisibilityFlags, Player owner, Player receiver)
{
UpdateMask allowedMaskForTarget = new(269, [0xFFFFFFDDu, 0x00003FFFu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0xC0000000u, 0xFFFFFFFFu, 0x00001FFFu]);
UpdateMask allowedMaskForTarget = new(288, [0xFFFFFFDDu, 0x0000FFFFu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0xFFFFFFFFu, 0xFFFFFFFFu]);
AppendAllowedFieldsMaskForFlag(allowedMaskForTarget, fieldVisibilityFlags);
WriteUpdate(data, _changesMask & allowedMaskForTarget, false, owner, receiver);
}
@@ -2916,12 +2929,12 @@ namespace Game.Entities
public void AppendAllowedFieldsMaskForFlag(UpdateMask allowedMaskForTarget, UpdateFieldFlag fieldVisibilityFlags)
{
if (fieldVisibilityFlags.HasFlag(UpdateFieldFlag.PartyMember))
allowedMaskForTarget.OR(new UpdateMask(269, new[] { 0x00000022u, 0xFFFFC000u, 0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu, 0x3FFFFFFFu, 0x00000000u, 0x00000000u }));
allowedMaskForTarget.OR(new UpdateMask(288, [0x00000022u, 0xFFFF0000u, 0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu, 0x00000000u, 0x00000000u]));
}
public void FilterDisallowedFieldsMaskForFlag(UpdateMask changesMask, UpdateFieldFlag fieldVisibilityFlags)
{
UpdateMask allowedMaskForTarget = new(269, new[] { 0xFFFFFFDDu, 0x00003FFFu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0xC0000000u, 0xFFFFFFFFu, 0x00001FFFu });
UpdateMask allowedMaskForTarget = new(288, [0xFFFFFFDDu, 0x0000FFFFu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0xFFFFFFFFu, 0xFFFFFFFFu]);
AppendAllowedFieldsMaskForFlag(allowedMaskForTarget, fieldVisibilityFlags);
changesMask.AND(allowedMaskForTarget);
}
@@ -3137,11 +3150,11 @@ namespace Game.Entities
{
if (changesMask[34])
{
data.WriteInt32(Field_B0);
data.WriteInt32(Field_1AC);
}
if (changesMask[35])
{
data.WriteInt32(Field_B4);
data.WriteInt32(Field_1B0);
}
if (changesMask[36])
{
@@ -3159,13 +3172,21 @@ namespace Game.Entities
{
data.WriteInt32(SoulbindID);
}
if (changesMask[41])
{
data.WritePackedGuid(SpectateTarget);
}
if (changesMask[42])
{
data.WriteInt32(Field_200);
}
if (changesMask[44])
{
PersonalTabard.GetValue().WriteUpdate(data, ignoreNestedChangesMask, owner, receiver);
}
if (changesMask[33])
{
data.WriteBits(Name.GetValue().GetByteCount(), 32);
data.WriteBits(Name.GetValue().GetByteCount(), 6);
}
data.WriteBits(DeclinedNames.HasValue(), 1);
data.FlushBits();
@@ -3177,7 +3198,7 @@ namespace Game.Entities
{
data.WriteString(Name);
}
if (changesMask[41])
if (changesMask[43])
{
if (DeclinedNames.HasValue())
{
@@ -3185,21 +3206,21 @@ namespace Game.Entities
}
}
}
if (changesMask[43])
if (changesMask[45])
{
for (int i = 0; i < 2; ++i)
{
if (changesMask[44 + i])
if (changesMask[46 + i])
{
data.WriteUInt8(PartyType[i]);
}
}
}
if (changesMask[46])
if (changesMask[48])
{
for (int i = 0; i < 175; ++i)
{
if (changesMask[47 + i])
if (changesMask[49 + i])
{
if (noQuestLogChangesMask)
QuestLog[i].WriteCreate(data, owner, receiver);
@@ -3208,36 +3229,46 @@ namespace Game.Entities
}
}
}
if (changesMask[222])
if (changesMask[224])
{
for (int i = 0; i < 19; ++i)
{
if (changesMask[223 + i])
if (changesMask[225 + i])
{
VisibleItems[i].WriteUpdate(data, ignoreNestedChangesMask, owner, receiver);
}
}
}
if (changesMask[242])
if (changesMask[244])
{
for (int i = 0; i < 6; ++i)
{
if (changesMask[243 + i])
if (changesMask[245 + i])
{
data.WriteFloat(AvgItemLevel[i]);
}
}
}
if (changesMask[249])
if (changesMask[268])
{
for (int i = 0; i < 19; ++i)
{
if (changesMask[250 + i])
if (changesMask[269 + i])
{
data.WriteUInt32(Field_3120[i]);
}
}
}
if (changesMask[251])
{
for (int i = 0; i < 16; ++i)
{
if (changesMask[252 + i])
{
VisibleEquipableSpells[i].Write(data);
}
}
}
data.FlushBits();
}
@@ -3275,19 +3306,22 @@ namespace Game.Entities
ClearChangesMask(HonorLevel);
ClearChangesMask(LogoutTime);
ClearChangesMask(Name);
ClearChangesMask(Field_B0);
ClearChangesMask(Field_B4);
ClearChangesMask(Field_1AC);
ClearChangesMask(Field_1B0);
ClearChangesMask(CurrentBattlePetSpeciesID);
ClearChangesMask(CtrOptions);
ClearChangesMask(CovenantID);
ClearChangesMask(SoulbindID);
ClearChangesMask(DungeonScore);
ClearChangesMask(SpectateTarget);
ClearChangesMask(Field_200);
ClearChangesMask(DeclinedNames);
ClearChangesMask(PersonalTabard);
ClearChangesMask(PartyType);
ClearChangesMask(QuestLog);
ClearChangesMask(VisibleItems);
ClearChangesMask(AvgItemLevel);
ClearChangesMask(VisibleEquipableSpells);
ClearChangesMask(Field_3120);
_changesMask.ResetAll();
}
+7 -2
View File
@@ -451,13 +451,14 @@ namespace Game.Entities
bool hasMoveCurveID = createProperties != null && createProperties.MoveCurveId != 0;
bool hasAreaTriggerSphere = shape.IsSphere();
bool hasAreaTriggerBox = shape.IsBox();
bool hasAreaTriggerPolygon = createProperties != null && shape.IsPolygon();
bool hasAreaTriggerPolygon = shape.IsPolygon();
bool hasAreaTriggerCylinder = shape.IsCylinder();
bool hasDisk = shape.IsDisk();
bool hasBoundedPlane = shape.IsBoundedPlane();
bool hasAreaTriggerSpline = areaTrigger.HasSplines();
bool hasOrbit = areaTrigger.HasOrbit();
bool hasMovementScript = false;
bool hasPositionalSoundKitID = false;
data.WriteBit(hasAbsoluteOrientation);
data.WriteBit(hasDynamicShape);
@@ -471,6 +472,7 @@ namespace Game.Entities
data.WriteBit(hasMorphCurveID);
data.WriteBit(hasFacingCurveID);
data.WriteBit(hasMoveCurveID);
data.WriteBit(hasPositionalSoundKitID);
data.WriteBit(hasAreaTriggerSphere);
data.WriteBit(hasAreaTriggerBox);
data.WriteBit(hasAreaTriggerPolygon);
@@ -506,6 +508,9 @@ namespace Game.Entities
if (hasMoveCurveID)
data.WriteUInt32(createProperties.MoveCurveId);
if (hasPositionalSoundKitID)
data.WriteUInt32(0);
if (hasAreaTriggerSphere)
{
data.WriteFloat(shape.SphereDatas.Radius);
@@ -1522,7 +1527,7 @@ namespace Game.Entities
BattlegroundMap bgMap = map.ToBattlegroundMap();
if (bgMap != null)
return (ZoneScript)bgMap.GetBG();
return (ZoneScript)bgMap.GetBattlegroundScript();
if (!map.IsBattlegroundOrArena())
{
@@ -233,7 +233,7 @@ namespace Game.Entities
{
return _heirlooms.ContainsKey(itemId);
}
public void UpgradeHeirloom(uint itemId, uint castItem)
{
Player player = _owner.GetPlayer();
@@ -386,12 +386,8 @@ namespace Game.Entities
_mounts[spellId] = flags;
// Mount condition only applies to using it, should still learn it.
if (mount.PlayerConditionID != 0)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(mount.PlayerConditionID);
if (playerCondition != null && !ConditionManager.IsPlayerMeetingCondition(player, playerCondition))
return false;
}
if (!ConditionManager.IsPlayerMeetingCondition(player, mount.PlayerConditionID))
return false;
if (!learned)
{
@@ -859,7 +855,7 @@ namespace Game.Entities
} while (knownTransmogIllusions.NextRow());
}
_transmogIllusions = new(blocks);
// Static illusions known by every player
@@ -919,7 +915,7 @@ namespace Game.Entities
{
return transmogIllusionId < _transmogIllusions.Count && _transmogIllusions.Get((int)transmogIllusionId);
}
public bool HasToy(uint itemId) { return _toys.ContainsKey(itemId); }
public Dictionary<uint, ToyFlags> GetAccountToys() { return _toys; }
public Dictionary<uint, HeirloomData> GetAccountHeirlooms() { return _heirlooms; }
+1 -1
View File
@@ -457,7 +457,7 @@ namespace Game.Entities
case DuelCompleteType.Fled:
// if initiator and opponent are on the same team
// or initiator and opponent are not PvP enabled, forcibly stop attacking
if (GetTeam() == opponent.GetTeam())
if (GetEffectiveTeam() == opponent.GetEffectiveTeam())
{
AttackStop();
opponent.AttackStop();
+2 -4
View File
@@ -3612,10 +3612,8 @@ namespace Game.Entities
if (GetSession().GetCollectionMgr().HasTransmogIllusion(transmogIllusion.Id))
continue;
var playerCondition = CliDB.PlayerConditionStorage.LookupByKey(transmogIllusion.UnlockConditionID);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
continue;
if (!ConditionManager.IsPlayerMeetingCondition(this, (uint)transmogIllusion.UnlockConditionID))
continue;
GetSession().GetCollectionMgr().AddTransmogIllusion(transmogIllusion.Id);
}
+1 -1
View File
@@ -252,7 +252,7 @@ namespace Game.Entities
case 1:
return IsInSameRaidWith(p);
case 2:
return GetTeam() == p.GetTeam();
return GetEffectiveTeam() == p.GetEffectiveTeam();
case 3:
return false;
}
+5 -10
View File
@@ -2865,8 +2865,7 @@ namespace Game.Entities
var limitConditions = Global.DB2Mgr.GetItemLimitCategoryConditions(limitEntry.Id);
foreach (ItemLimitCategoryConditionRecord limitCondition in limitConditions)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(limitCondition.PlayerConditionID);
if (playerCondition == null || ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
if (ConditionManager.IsPlayerMeetingCondition(this, limitCondition.PlayerConditionID))
limit += (byte)limitCondition.AddQuantity;
}
@@ -3273,14 +3272,10 @@ namespace Game.Entities
return false;
}
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(crItem.PlayerConditionId);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(this, crItem.PlayerConditionId))
{
if (!ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
{
SendEquipError(InventoryResult.ItemLocked);
return false;
}
SendEquipError(InventoryResult.ItemLocked);
return false;
}
// check current item amount if it limited
@@ -6130,7 +6125,7 @@ namespace Game.Entities
Guild guild = GetGuild();
if (guild != null)
guild.AddGuildNews(GuildNews.ItemLooted, GetGUID(), 0, item.itemid);
}
}
// if aeLooting then we must delay sending out item so that it appears properly stacked in chat
if (aeResult == null || newitem == null)
+1 -1
View File
@@ -370,7 +370,7 @@ namespace Game.Entities
var mapDifficultyConditions = Global.DB2Mgr.GetMapDifficultyConditions(mapDiff.Id);
foreach (var pair in mapDifficultyConditions)
{
if (!ConditionManager.IsPlayerMeetingCondition(this, pair.Item2))
if (!ConditionManager.IsPlayerMeetingCondition(this, pair.Item2.Id))
{
failedMapDifficultyXCondition = pair.Item1;
break;
+29 -18
View File
@@ -1174,10 +1174,8 @@ namespace Game.Entities
{
foreach (QuestRewardDisplaySpell displaySpell in quest.RewardDisplaySpell)
{
var playerCondition = CliDB.PlayerConditionStorage.LookupByKey(displaySpell.PlayerConditionId);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
continue;
if (!ConditionManager.IsPlayerMeetingCondition(this, displaySpell.PlayerConditionId))
continue;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(displaySpell.SpellId, GetMap().GetDifficultyID());
Unit caster = this;
@@ -1588,7 +1586,7 @@ namespace Game.Entities
return true;
}
public bool SatisfyQuestReputation(Quest qInfo, bool msg)
public bool SatisfyQuestMinReputation(Quest qInfo, bool msg)
{
uint fIdMin = qInfo.RequiredMinRepFaction; //Min required rep
if (fIdMin != 0 && GetReputationMgr().GetReputation(fIdMin) < qInfo.RequiredMinRepValue)
@@ -1601,6 +1599,11 @@ namespace Game.Entities
return false;
}
return true;
}
public bool SatisfyQuestMaxReputation(Quest qInfo, bool msg)
{
uint fIdMax = qInfo.RequiredMaxRepFaction; //Max required rep
if (fIdMax != 0 && GetReputationMgr().GetReputation(fIdMax) >= qInfo.RequiredMaxRepValue)
{
@@ -1615,6 +1618,11 @@ namespace Game.Entities
return true;
}
bool SatisfyQuestReputation(Quest qInfo, bool msg)
{
return SatisfyQuestMinReputation(qInfo, msg) && SatisfyQuestMaxReputation(qInfo, msg);
}
public bool SatisfyQuestStatus(Quest qInfo, bool msg)
{
if (GetQuestStatus(qInfo.Id) == QuestStatus.Rewarded)
@@ -3297,21 +3305,24 @@ namespace Game.Entities
ObjectFieldData objMask = new();
GameObjectFieldData goMask = new();
if (m_questObjectiveStatus.ContainsKey((QuestObjectiveType.GameObject, (int)gameObject.GetEntry())))
if (m_questObjectiveStatus.ContainsKey((QuestObjectiveType.GameObject, (int)gameObject.GetEntry())) || gameObject.GetGoInfo().GetConditionID1() != 0)
objMask.MarkChanged(gameObject.m_objectData.DynamicFlags);
switch (gameObject.GetGoType())
else
{
case GameObjectTypes.QuestGiver:
case GameObjectTypes.Chest:
case GameObjectTypes.Goober:
case GameObjectTypes.Generic:
case GameObjectTypes.GatheringNode:
if (Global.ObjectMgr.IsGameObjectForQuests(gameObject.GetEntry()))
objMask.MarkChanged(gameObject.m_objectData.DynamicFlags);
break;
default:
break;
switch (gameObject.GetGoType())
{
case GameObjectTypes.QuestGiver:
case GameObjectTypes.Chest:
case GameObjectTypes.Generic:
case GameObjectTypes.SpellFocus:
case GameObjectTypes.Goober:
case GameObjectTypes.GatheringNode:
if (Global.ObjectMgr.IsGameObjectForQuests(gameObject.GetEntry()))
objMask.MarkChanged(gameObject.m_objectData.DynamicFlags);
break;
default:
break;
}
}
if (objMask.GetUpdateMask().IsAnySet() || goMask.GetUpdateMask().IsAnySet())
@@ -256,7 +256,7 @@ namespace Game.Entities
{
return CliDB.ChrSpecializationStorage.LookupByKey((uint)GetPrimarySpecialization());
}
public byte GetActiveTalentGroup() { return _specializationInfo.ActiveGroup; }
void SetActiveTalentGroup(byte group) { _specializationInfo.ActiveGroup = group; }
@@ -742,10 +742,8 @@ namespace Game.Entities
if (HasPvpTalent(talentID, GetActiveTalentGroup()))
return TalentLearnResult.FailedUnknown;
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(talentInfo.PlayerConditionID);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
return TalentLearnResult.FailedCantDoThatRightNow;
if (!ConditionManager.IsPlayerMeetingCondition(this, (uint)talentInfo.PlayerConditionID))
return TalentLearnResult.FailedCantDoThatRightNow;
PvpTalentRecord talent = CliDB.PvpTalentStorage.LookupByKey(GetPvpTalentMap(GetActiveTalentGroup())[slot]);
if (talent != null)
+14 -44
View File
@@ -1327,11 +1327,8 @@ namespace Game.Entities
// Check award condition
if (currency.AwardConditionID != 0)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(currency.AwardConditionID);
if (playerCondition != null && !ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
if (!ConditionManager.IsPlayerMeetingCondition(this, (uint)currency.AwardConditionID))
return;
}
bool isGainOnRefund = false;
@@ -2446,12 +2443,6 @@ namespace Game.Entities
// stop taxi flight at summon
FinishTaxiFlight();
// drop flag at summon
// this code can be reached only when GM is summoning player who carries flag, because player should be immune to summoning spells when he carries flag
Battleground bg = GetBattleground();
if (bg != null)
bg.EventPlayerDroppedFlag(this);
m_summon_expire = 0;
UpdateCriteria(CriteriaType.AcceptSummon, 1);
@@ -4250,13 +4241,6 @@ namespace Game.Entities
UpdateZone(newzone, newarea);
OutdoorPvPMgr.HandlePlayerResurrects(this, newzone);
if (InBattleground())
{
Battleground bg = GetBattleground();
if (bg != null)
bg.HandlePlayerResurrect(this);
}
// update visibility
UpdateObjectVisibility();
@@ -4454,22 +4438,14 @@ namespace Game.Entities
}
WorldSafeLocsEntry closestGrave = null;
// Special handle for Battlegroundmaps
Battleground bg = GetBattleground();
if (bg != null)
closestGrave = bg.GetClosestGraveyard(this);
var bf = BattleFieldMgr.GetBattlefieldToZoneId(GetMap(), GetZoneId());
if (bf != null)
closestGrave = bf.GetClosestGraveyard(this);
else
{
var bf = BattleFieldMgr.GetBattlefieldToZoneId(GetMap(), GetZoneId());
if (bf != null)
closestGrave = bf.GetClosestGraveyard(this);
else
{
InstanceScript instance = GetInstanceScript();
if (instance != null)
closestGrave = ObjectMgr.GetWorldSafeLoc(instance.GetEntranceLocation());
}
InstanceScript instance = GetInstanceScript();
if (instance != null)
closestGrave = ObjectMgr.GetWorldSafeLoc(instance.GetEntranceLocation());
}
if (closestGrave == null)
@@ -4985,12 +4961,7 @@ namespace Game.Entities
public bool MeetPlayerCondition(uint conditionId)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(conditionId);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
return false;
return true;
return ConditionManager.IsPlayerMeetingCondition(this, conditionId);
}
bool IsInFriendlyArea()
@@ -5143,6 +5114,8 @@ namespace Game.Entities
return Team.Alliance;
case 1:
return Team.Horde;
case 2:
return Team.PandariaNeutral;
}
return Team.Alliance;
@@ -5157,10 +5130,10 @@ namespace Game.Entities
return BattleGroundTeamId.Neutral;
}
public Team GetTeam() { return m_team; }
public int GetTeamId() { return m_team == Team.Alliance ? BattleGroundTeamId.Alliance : BattleGroundTeamId.Horde; }
public int GetTeamId() { return SharedConst.GetTeamIdForTeam(m_team); }
public Team GetEffectiveTeam() { return HasPlayerFlagEx(PlayerFlagsEx.MercenaryMode) ? (GetTeam() == Team.Alliance ? Team.Horde : Team.Alliance) : GetTeam(); }
public int GetEffectiveTeamId() { return GetEffectiveTeam() == Team.Alliance ? BattleGroundTeamId.Alliance : BattleGroundTeamId.Horde; }
public Team GetEffectiveTeam() { return HasPlayerFlagEx(PlayerFlagsEx.MercenaryMode) ? SharedConst.GetOtherTeam(GetTeam()) : GetTeam(); }
public int GetEffectiveTeamId() { return SharedConst.GetTeamIdForTeam(GetEffectiveTeam()); }
//Money
public ulong GetMoney() { return m_activePlayerData.Coinage; }
@@ -6318,11 +6291,8 @@ namespace Game.Entities
// Check award condition
if (currencyRecord.AwardConditionID != 0)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(currencyRecord.AwardConditionID);
if (playerCondition != null && !ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
if (!ConditionManager.IsPlayerMeetingCondition(this, (uint)currencyRecord.AwardConditionID))
continue;
}
SetupCurrency.Record record = new();
record.Type = currencyRecord.Id;
+36 -40
View File
@@ -363,7 +363,7 @@ namespace Game.Entities
break;
}
}
public virtual void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, out float minDamage, out float maxDamage)
{
minDamage = 0f;
@@ -802,7 +802,7 @@ namespace Game.Entities
return damage;
}
// player or player's pet resilience (-1%)
uint GetDamageReduction(uint damage) { return GetCombatRatingDamageReduction(CombatRating.ResiliencePlayerDamage, 1.0f, 100.0f, damage); }
@@ -946,7 +946,7 @@ namespace Game.Entities
float chance = GetUnitCriticalChanceDone(attackType);
return victim.GetUnitCriticalChanceTaken(this, attackType, chance);
}
float GetUnitDodgeChance(WeaponAttackType attType, Unit victim)
{
int levelDiff = (int)(victim.GetLevelForTarget(this) - GetLevelForTarget(victim));
@@ -1085,7 +1085,7 @@ namespace Game.Entities
}
return Math.Max(resistMech, 0);
}
public void ApplyModManaCostMultiplier(float manaCostMultiplier, bool apply) { ApplyModUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ManaCostMultiplier), manaCostMultiplier, apply); }
public void ApplyModManaCostModifier(SpellSchools school, int mod, bool apply) { ApplyModUpdateFieldValue(ref m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ManaCostModifier, (int)school), mod, apply); }
@@ -1545,34 +1545,34 @@ namespace Game.Entities
case CombatRating.HasteMelee:
case CombatRating.HasteRanged:
case CombatRating.HasteSpell:
{
// explicit affected values
float multiplier = GetRatingMultiplier(cr);
float oldVal = ApplyRatingDiminishing(cr, oldRating * multiplier);
float newVal = ApplyRatingDiminishing(cr, amount * multiplier);
switch (cr)
{
// explicit affected values
float multiplier = GetRatingMultiplier(cr);
float oldVal = ApplyRatingDiminishing(cr, oldRating * multiplier);
float newVal = ApplyRatingDiminishing(cr, amount * multiplier);
switch (cr)
{
case CombatRating.HasteMelee:
ApplyAttackTimePercentMod(WeaponAttackType.BaseAttack, oldVal, false);
ApplyAttackTimePercentMod(WeaponAttackType.OffAttack, oldVal, false);
ApplyAttackTimePercentMod(WeaponAttackType.BaseAttack, newVal, true);
ApplyAttackTimePercentMod(WeaponAttackType.OffAttack, newVal, true);
if (GetClass() == Class.Deathknight)
UpdateAllRunesRegen();
break;
case CombatRating.HasteRanged:
ApplyAttackTimePercentMod(WeaponAttackType.RangedAttack, oldVal, false);
ApplyAttackTimePercentMod(WeaponAttackType.RangedAttack, newVal, true);
break;
case CombatRating.HasteSpell:
ApplyCastTimePercentMod(oldVal, false);
ApplyCastTimePercentMod(newVal, true);
break;
default:
break;
}
break;
case CombatRating.HasteMelee:
ApplyAttackTimePercentMod(WeaponAttackType.BaseAttack, oldVal, false);
ApplyAttackTimePercentMod(WeaponAttackType.OffAttack, oldVal, false);
ApplyAttackTimePercentMod(WeaponAttackType.BaseAttack, newVal, true);
ApplyAttackTimePercentMod(WeaponAttackType.OffAttack, newVal, true);
if (GetClass() == Class.Deathknight)
UpdateAllRunesRegen();
break;
case CombatRating.HasteRanged:
ApplyAttackTimePercentMod(WeaponAttackType.RangedAttack, oldVal, false);
ApplyAttackTimePercentMod(WeaponAttackType.RangedAttack, newVal, true);
break;
case CombatRating.HasteSpell:
ApplyCastTimePercentMod(oldVal, false);
ApplyCastTimePercentMod(newVal, true);
break;
default:
break;
}
break;
}
case CombatRating.Expertise:
if (affectStats)
{
@@ -1667,14 +1667,10 @@ namespace Game.Entities
continue;
}
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(corruptionEffect.PlayerConditionID);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(this, (uint)corruptionEffect.PlayerConditionID))
{
if (!ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
{
RemoveAura(corruptionEffect.Aura);
continue;
}
RemoveAura(corruptionEffect.Aura);
continue;
}
CastSpell(this, corruptionEffect.Aura, true);
@@ -1766,7 +1762,7 @@ namespace Game.Entities
}
SetUpdateFieldStatValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.ParryPercentage), value);
}
float[] dodge_cap =
{
65.631440f, // Warrior
@@ -1997,7 +1993,7 @@ namespace Game.Entities
return Stats.Intellect;
}
public override void UpdateMaxHealth()
{
UnitMods unitMod = UnitMods.Health;
@@ -2112,7 +2108,7 @@ namespace Game.Entities
return base.GetCreatePowerValue(power);
}
public override bool UpdateStats(Stats stat)
{
return true;
+10 -6
View File
@@ -154,14 +154,18 @@ namespace Game.Entities
foreach (var edge in path)
{
var To = m_nodesByVertex[(int)edge.To];
TaxiNodeFlags requireFlag = (player.GetTeam() == Team.Alliance) ? TaxiNodeFlags.ShowOnAllianceMap : TaxiNodeFlags.ShowOnHordeMap;
if (!To.HasFlag(requireFlag))
bool isVisibleForFaction = player.GetTeam() switch
{
Team.Horde => To.HasFlag(TaxiNodeFlags.ShowOnHordeMap),
Team.Alliance => To.HasFlag(TaxiNodeFlags.ShowOnAllianceMap),
_ => false
};
if (!isVisibleForFaction)
continue;
PlayerConditionRecord condition = CliDB.PlayerConditionStorage.LookupByKey(To.ConditionID);
if (condition != null)
if (!ConditionManager.IsPlayerMeetingCondition(player, condition))
continue;
if (!ConditionManager.IsPlayerMeetingCondition(player, To.ConditionID))
continue;
shortestPath.Add(GetNodeIDFromVertexID(edge.To));
}
+2 -7
View File
@@ -868,13 +868,8 @@ namespace Game.Entities
continue;
Player thisPlayer = ToPlayer();
if (thisPlayer != null)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(mountCapability.PlayerConditionID);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(thisPlayer, playerCondition))
continue;
}
if (thisPlayer != null && !ConditionManager.IsPlayerMeetingCondition(thisPlayer, (uint)mountCapability.PlayerConditionID))
continue;
return mountCapability;
}
+1 -2
View File
@@ -110,8 +110,7 @@ namespace Game.Entities
if (player.IsQuestRewarded(vignette.Data.VisibleTrackingQuestID))
return false;
var playerCondition = CliDB.PlayerConditionStorage.LookupByKey(vignette.Data.PlayerConditionID);
if (playerCondition != null && !ConditionManager.IsPlayerMeetingCondition(player, playerCondition))
if (!ConditionManager.IsPlayerMeetingCondition(player, vignette.Data.PlayerConditionID))
return false;
return true;
-5
View File
@@ -672,11 +672,6 @@ namespace Game.Entities
Player player = Passenger.ToPlayer();
if (player != null)
{
// drop flag
Battleground bg = player.GetBattleground();
if (bg != null)
bg.EventPlayerDroppedFlag(player);
player.StopCastingCharm();
player.StopCastingBindSight();
player.SendOnCancelExpectedVehicleRideAura();