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:
@@ -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; }
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user