Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2025-02-11 22:35:57 +08:00
62 changed files with 1532 additions and 1969 deletions
+4 -1
View File
@@ -806,7 +806,10 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
return nullptr;
}
creature->SetFaction(BattlefieldFactions[teamId]);
// no need to set faction for neutral team
if (teamId == TEAM_ALLIANCE || teamId == TEAM_HORDE)
creature->SetFaction(BattlefieldFactions[teamId]);
creature->SetHomePosition(x, y, z, o);
// force using DB speeds -- do we really need this?
+11 -17
View File
@@ -525,7 +525,7 @@ bool Creature::InitEntry(uint32 Entry, const CreatureData* data)
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, cinfo->HoverHeight);
SetCanDualWield(cinfo->flags_extra & CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK);
SetCanDualWield(cinfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK));
// checked at loading
m_defaultMovementType = MovementGeneratorType(cinfo->MovementType);
@@ -556,7 +556,7 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele
uint32 npcflag, unit_flags, dynamicflags;
ObjectMgr::ChooseCreatureFlags(cInfo, npcflag, unit_flags, dynamicflags, data);
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_WORLDEVENT)
if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_WORLDEVENT))
ReplaceAllNpcFlags(NPCFlags(npcflag | sGameEventMgr->GetNPCFlag(this)));
else
ReplaceAllNpcFlags(NPCFlags(npcflag));
@@ -571,7 +571,7 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele
ReplaceAllDynamicFlags(dynamicflags);
SetCanDualWield(cInfo->flags_extra & CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK);
SetCanDualWield(cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK));
SetAttackTime(BASE_ATTACK, cInfo->BaseAttackTime);
SetAttackTime(OFF_ATTACK, cInfo->BaseAttackTime);
@@ -637,7 +637,7 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele
InitializeReactState();
if (!IsPet() && cInfo->flags_extra & CREATURE_FLAG_EXTRA_NO_TAUNT)
if (!IsPet() && cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_TAUNT))
{
ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
@@ -1200,7 +1200,7 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, u
LastUsedScriptID = GetScriptId();
if (IsSpiritHealer() || IsSpiritGuide() || (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GHOST_VISIBILITY))
if (IsSpiritHealer() || IsSpiritGuide() || HasFlagsExtra(CREATURE_FLAG_EXTRA_GHOST_VISIBILITY))
{
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
@@ -1213,7 +1213,7 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, u
if (Entry == VISUAL_WAYPOINT)
SetVisible(false);
if (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_IGNORE_PATHFINDING)
if (HasFlagsExtra(CREATURE_FLAG_EXTRA_IGNORE_PATHFINDING))
AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);
return true;
@@ -2175,12 +2175,8 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer)
RemoveCorpse(true);
if (forceRespawnTimer > Seconds::zero())
{
if (GetMap())
{
GetMap()->ScheduleCreatureRespawn(GetGUID(), forceRespawnTimer);
}
}
}
void Creature::DespawnOrUnsummon(Milliseconds msTimeToDespawn /*= 0*/, Seconds forcedRespawnTimer)
@@ -2203,7 +2199,7 @@ void Creature::DespawnOnEvade(Seconds respawnDelay)
if (TempSummon* whoSummon = ToTempSummon())
{
LOG_WARN("entities.unit", "DespawnOnEvade called on a temporary summon.");
GetMap()->ScheduleCreatureRespawn(GetGUID(), respawnDelay, GetHomePosition());
whoSummon->UnSummon();
return;
}
@@ -3184,8 +3180,7 @@ bool Creature::IsDungeonBoss() const
if (GetOwnerGUID().IsPlayer())
return false;
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry());
return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS);
return HasFlagsExtra(CREATURE_FLAG_EXTRA_DUNGEON_BOSS);
}
bool Creature::IsImmuneToKnockback() const
@@ -3193,8 +3188,7 @@ bool Creature::IsImmuneToKnockback() const
if (GetOwnerGUID().IsPlayer())
return false;
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry());
return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK);
return HasFlagsExtra(CREATURE_FLAG_EXTRA_IMMUNITY_KNOCKBACK);
}
bool Creature::HasWeapon(WeaponAttackType type) const
@@ -3464,7 +3458,7 @@ void Creature::UpdateMovementFlags()
return;
// Creatures with CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE should control MovementFlags in your own scripts
if (info->flags_extra & CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE)
if (info->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE))
return;
float ground = GetFloorZ();
@@ -3820,7 +3814,7 @@ void Creature::ModifyThreatPercentTemp(Unit* victim, int32 percent, Milliseconds
bool Creature::IsDamageEnoughForLootingAndReward() const
{
return (m_creatureInfo->flags_extra & CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ) || (_playerDamageReq == 0 && _damagedByPlayer);
return m_creatureInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ) || (_playerDamageReq == 0 && _damagedByPlayer);
}
void Creature::LowerPlayerDamageReq(uint32 unDamage, bool damagedByPlayer /*= true*/)
+6 -5
View File
@@ -70,10 +70,11 @@ public:
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
void SetCorpseRemoveTime(uint32 delay);
[[nodiscard]] uint32 GetCorpseDelay() const { return m_corpseDelay; }
[[nodiscard]] bool HasFlagsExtra(uint32 flag) const { return GetCreatureTemplate()->HasFlagsExtra(flag); }
[[nodiscard]] bool IsRacialLeader() const { return GetCreatureTemplate()->RacialLeader; }
[[nodiscard]] bool IsCivilian() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
[[nodiscard]] bool IsTrigger() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; }
[[nodiscard]] bool IsGuard() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; }
[[nodiscard]] bool IsCivilian() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_CIVILIAN); }
[[nodiscard]] bool IsTrigger() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_TRIGGER); }
[[nodiscard]] bool IsGuard() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_GUARD); }
CreatureMovementData const& GetMovementTemplate() const;
[[nodiscard]] bool CanWalk() const { return GetMovementTemplate().IsGroundAllowed(); }
[[nodiscard]] bool CanSwim() const override;
@@ -127,7 +128,7 @@ public:
[[nodiscard]] bool IsDungeonBoss() const;
[[nodiscard]] bool IsImmuneToKnockback() const;
[[nodiscard]] bool IsAvoidingAOE() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_AVOID_AOE; }
[[nodiscard]] bool IsAvoidingAOE() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_AVOID_AOE); }
uint8 getLevelForTarget(WorldObject const* target) const override; // overwrite Unit::getLevelForTarget for boss level support
@@ -272,7 +273,7 @@ public:
bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; }
bool CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction = true) const;
bool _IsTargetAcceptable(Unit const* target) const;
[[nodiscard]] bool CanIgnoreFeignDeath() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_IGNORE_FEIGN_DEATH) != 0; }
[[nodiscard]] bool CanIgnoreFeignDeath() const { return HasFlagsExtra(CREATURE_FLAG_EXTRA_IGNORE_FEIGN_DEATH); }
// pussywizard: Updated at faction change, disable move in line of sight if actual faction is not hostile to anyone
void UpdateMoveInLineOfSightState();
@@ -310,13 +310,9 @@ void TempSummon::UnSummon(uint32 msTime)
if (WorldObject* owner = GetSummoner())
{
if (owner->IsCreature() && owner->ToCreature()->IsAIEnabled)
{
owner->ToCreature()->AI()->SummonedCreatureDespawn(this);
}
else if (owner->IsGameObject() && owner->ToGameObject()->AI())
{
owner->ToGameObject()->AI()->SummonedCreatureDespawn(this);
}
}
AddObjectToRemoveList();
+1 -7
View File
@@ -12721,17 +12721,11 @@ bool Player::isHonorOrXPTarget(Unit* victim) const
// Victim level less gray level
if (v_level <= k_grey)
{
return false;
}
if (victim->IsCreature())
{
if (victim->IsTotem() || victim->IsCritter() || victim->IsPet() || (victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP))
{
if (victim->IsTotem() || victim->IsCritter() || victim->IsPet() || victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_XP))
return false;
}
}
return true;
}
+1 -1
View File
@@ -1375,7 +1375,7 @@ public:
[[nodiscard]] Player* GetTrader() const { return m_trade ? m_trade->GetTrader() : nullptr; }
[[nodiscard]] TradeData* GetTradeData() const { return m_trade; }
void TradeCancel(bool sendback);
void TradeCancel(bool sendback, TradeStatus status = TRADE_STATUS_TRADE_CANCELED);
CinematicMgr* GetCinematicMgr() const { return _cinematicMgr; }
@@ -4085,7 +4085,7 @@ void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid,
GetSession()->SendPacket(&data);
}
void Player::TradeCancel(bool sendback)
void Player::TradeCancel(bool sendback, TradeStatus status /*= TRADE_STATUS_TRADE_CANCELED*/)
{
if (m_trade)
{
@@ -4093,9 +4093,9 @@ void Player::TradeCancel(bool sendback)
// send yellow "Trade canceled" message to both traders
if (sendback)
GetSession()->SendCancelTrade();
GetSession()->SendCancelTrade(status);
trader->GetSession()->SendCancelTrade();
trader->GetSession()->SendCancelTrade(status);
// cleanup
delete m_trade;
@@ -6066,7 +6066,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3
GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList();
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
{
if (uint32(events[*itr].holiday_id) == proto->HolidayId)
if (uint32(events[*itr].HolidayId) == proto->HolidayId)
{
remove = false;
break;
@@ -6724,7 +6724,7 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, target_map, this))
{
GetSession()->SendAreaTriggerMessage("{}", GetSession()->GetAcoreString(LANG_INSTANCE_CLOSED));
GetSession()->SendAreaTriggerMessage(LANG_INSTANCE_CLOSED);
return false;
}
@@ -6862,11 +6862,11 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map
{
ObjectMgr::GetLocaleString(il->Name, loc_idx, name);
}
GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_LEVEL_MINREQUIRED_AND_ITEM), ar->levelMin, name.c_str());
GetSession()->SendAreaTriggerMessage(LANG_LEVEL_MINREQUIRED_AND_ITEM, ar->levelMin, name);
}
else if (LevelMin)
{
GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_LEVEL_MINREQUIRED), LevelMin);
GetSession()->SendAreaTriggerMessage(LANG_LEVEL_MINREQUIRED, LevelMin);
}
else if (ilvlRequirementNotMet)
{
@@ -6924,11 +6924,11 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map
if (LevelMin)
{
GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_LEVEL_MINREQUIRED), LevelMin);
GetSession()->SendAreaTriggerMessage(LANG_LEVEL_MINREQUIRED, LevelMin);
}
else if (LevelMax)
{
GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_ACCESS_REQUIREMENT_MAX_LEVEL), LevelMax);
GetSession()->SendAreaTriggerMessage(LANG_ACCESS_REQUIREMENT_MAX_LEVEL, LevelMax);
}
else if (mapDiff->hasErrorMessage && !errorAlreadyPrinted)
{
@@ -980,9 +980,7 @@ void Player::UpdateWeaponSkill(Unit* victim, WeaponAttackType attType, Item* ite
if (GetShapeshiftForm() == FORM_TREE)
return; // use weapon but not skill up
if (victim->IsCreature() &&
(victim->ToCreature()->GetCreatureTemplate()->flags_extra &
CREATURE_FLAG_EXTRA_NO_SKILL_GAINS))
if (victim->IsCreature() && victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_SKILL_GAINS))
return;
uint32 weapon_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_WEAPON);
@@ -1168,7 +1166,7 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation,
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
if (GetTrader() && !IsWithinDistInMap(GetTrader(), INTERACTION_DISTANCE))
GetSession()->SendCancelTrade();
GetSession()->SendCancelTrade(TRADE_STATUS_TRADE_CANCELED);
CheckAreaExploreAndOutdoor();
@@ -582,7 +582,22 @@ void MotionTransport::DelayedTeleportTransport()
float destX, destY, destZ, destO;
obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
if (!obj->ToPlayer()->TeleportTo(newMapId, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
Player* player = obj->ToPlayer();
// Vehicle passengers are dropped in the middle of nowhere, so lets try to eject them, add to the transport and teleport
// this needs to be revisited to properly restore vehicles with passengers after transport teleportation
if (player->IsVehicle())
if (Vehicle* vehicleKit = player->GetVehicleKit())
for (SeatMap::iterator itr = vehicleKit->Seats.begin(); itr != vehicleKit->Seats.end(); ++itr)
if (Player* passenger = ObjectAccessor::GetPlayer(*player, itr->second.Passenger.Guid))
{
passenger->ExitVehicle();
AddPassenger(passenger, true);
if (!passenger->TeleportTo(newMapId, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
_passengers.erase(passenger);
}
if (!player->TeleportTo(newMapId, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
_passengers.erase(obj);
}
break;
+13 -20
View File
@@ -2856,7 +2856,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy
//LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: attack came from behind and victim was a player.");
}
// Xinef: do not allow to dodge with CREATURE_FLAG_EXTRA_NO_DODGE flag
else if (victim->IsPlayer() || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_DODGE))
else if (victim->IsPlayer() || !(victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_DODGE)))
{
// Reduce dodge chance by attacker expertise rating
if (IsPlayer())
@@ -2898,7 +2898,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy
else
parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
if (victim->IsPlayer() || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY))
if (victim->IsPlayer() || !(victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_PARRY)))
{
tmp = parry_chance;
@@ -2915,7 +2915,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy
}
}
if (victim->IsPlayer() || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK))
if (victim->IsPlayer() || !(victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_BLOCK)))
{
tmp = block_chance;
@@ -2957,7 +2957,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy
if (getLevelForTarget(victim) >= victim->getLevelForTarget(this) + 4 &&
// can be from by creature (if can) or from controlled player that considered as creature
!IsControlledByPlayer() &&
!(IsCreature() && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSHING_BLOWS))
!(IsCreature() && ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_CRUSHING_BLOWS)))
{
// when their weapon skill is 15 or more above victim's defense skill
tmp = victimDefenseSkill;
@@ -2984,10 +2984,8 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy
if (tmp > 0 && roll < (sum += tmp))
{
LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRIT <{}, {})", sum - tmp, sum);
if (IsCreature() && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT))
{
if (IsCreature() && (ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_CRIT)))
LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRIT DISABLED)");
}
else
return MELEE_HIT_CRIT;
}
@@ -3122,7 +3120,7 @@ bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttac
{
// Check creatures flags_extra for disable block
if (victim->IsCreature() &&
victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)
victim->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_BLOCK))
return false;
float blockChance = victim->GetUnitBlockChance();
@@ -10453,10 +10451,9 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
creature->SendAIReaction(AI_REACTION_HOSTILE);
/// @todo: Implement aggro range, detection range and assistance range templates
if (!(creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_DONT_CALL_ASSISTANCE))
{
if (!(creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_CALL_ASSISTANCE)))
creature->CallAssistance();
}
creature->SetAssistanceTimer(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_PERIOD));
SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
@@ -15144,7 +15141,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration,
Unit const* source = casterOwner ? casterOwner : caster;
if ((target->IsPlayer()
|| target->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH)
|| target->ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_ALL_DIMINISH))
&& source->IsPlayer())
duration = limitduration;
}
@@ -15153,7 +15150,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration,
if (group == DIMINISHING_TAUNT)
{
if (IsCreature() && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_OBEYS_TAUNT_DIMINISHING_RETURNS))
if (IsCreature() && (ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_OBEYS_TAUNT_DIMINISHING_RETURNS)))
{
DiminishingLevels diminish = Level;
switch (diminish)
@@ -15180,7 +15177,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration,
// Some diminishings applies to mobs too (for example, Stun)
else if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER
&& ((targetOwner ? (targetOwner->IsPlayer()) : (IsPlayer()))
|| (IsCreature() && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH)))
|| (IsCreature() && ToCreature()->HasFlagsExtra(CREATURE_FLAG_EXTRA_ALL_DIMINISH))))
|| GetDiminishingReturnsGroupType(group) == DRTYPE_ALL)
{
DiminishingLevels diminish = Level;
@@ -18057,7 +18054,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
if (instanceMap->IsDungeon() && player)
if (instanceMap->IsRaidOrHeroicDungeon())
if (creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
if (creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND))
instanceMap->ToInstanceMap()->PermBindAllPlayers();
}
}
@@ -20997,16 +20994,12 @@ void Unit::PatchValuesUpdate(ByteBuffer& valuesUpdateBuf, BuildValuesCachePosPoi
break;
}
if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
if (cinfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_TRIGGER))
{
if (target->IsGameMaster() && target->GetSession()->IsGMAccount())
{
displayId = cinfo->GetFirstVisibleModel()->CreatureDisplayID;
}
else
{
displayId = cinfo->GetFirstInvisibleModel()->CreatureDisplayID;
}
}
}
File diff suppressed because it is too large Load Diff
+86 -72
View File
@@ -38,17 +38,17 @@ enum GameEventState
struct GameEventFinishCondition
{
float reqNum; // required number // use float, since some events use percent
float done; // done number
uint32 max_world_state; // max resource count world state update id
uint32 done_world_state; // done resource count world state update id
float ReqNum; // required number // use float, since some events use percent
float Done; // done number
uint32 MaxWorldState; // max resource count world state update id
uint32 DoneWorldState; // done resource count world state update id
};
struct GameEventQuestToEventConditionNum
{
uint16 event_id;
uint32 condition;
float num;
uint16 EventId;
uint32 Condition;
float Num;
};
typedef std::map<uint32 /*condition id*/, GameEventFinishCondition> GameEventConditionMap;
@@ -56,37 +56,37 @@ typedef std::map<uint32 /*condition id*/, GameEventFinishCondition> GameEventCon
struct GameEventData
{
GameEventData() = default;
uint32 eventId;
time_t start{1}; // occurs after this time
time_t end{0}; // occurs before this time
time_t nextstart{0}; // after this time the follow-up events count this phase completed
uint32 occurence{0}; // time between end and start
uint32 length{0}; // length of the event (minutes) after finishing all conditions
HolidayIds holiday_id{HOLIDAY_NONE};
uint8 holidayStage;
GameEventState state{GAMEEVENT_NORMAL}; // state of the game event, these are saved into the game_event table on change!
GameEventConditionMap conditions; // conditions to finish
std::set<uint16 /*gameevent id*/> prerequisite_events; // events that must be completed before starting this event
std::string description;
uint8 announce; // if 0 dont announce, if 1 announce, if 2 take config value
uint32 EventId;
time_t Start{1}; // occurs after this time
time_t End{0}; // occurs before this time
time_t NextStart{0}; // after this time the follow-up events count this phase completed
uint32 Occurence{0}; // time between end and start
uint32 Length{0}; // length of the event (minutes) after finishing all conditions
HolidayIds HolidayId{HOLIDAY_NONE};
uint8 HolidayStage;
GameEventState State{GAMEEVENT_NORMAL}; // state of the game event, these are saved into the game_event table on change!
GameEventConditionMap Conditions; // conditions to finish
std::set<uint16 /*gameevent id*/> PrerequisiteEvents; // events that must be completed before starting this event
std::string Description;
uint8 Announce; // if 0 dont announce, if 1 announce, if 2 take config value
[[nodiscard]] bool isValid() const { return length > 0 || state > GAMEEVENT_NORMAL; }
[[nodiscard]] bool isValid() const { return Length > 0 || State > GAMEEVENT_NORMAL; }
};
struct ModelEquip
{
uint32 modelid;
uint32 modelid_prev;
uint8 equipment_id;
uint8 equipement_id_prev;
uint32 ModelId;
uint32 ModelIdPrev;
uint8 EquipmentId;
uint8 EquipementIdPrev;
};
struct NPCVendorEntry
{
uint32 entry; // creature entry
uint32 item; // item id
int32 maxcount; // 0 for infinite
uint32 incrtime; // time for restore items amount if maxcount != 0
uint32 Entry; // creature entry
uint32 Item; // item id
int32 MaxCount; // 0 for infinite
uint32 Incrtime; // time for restore items amount if maxcount != 0
uint32 ExtendedCost;
};
@@ -105,46 +105,62 @@ public:
typedef std::set<uint16> ActiveEvents;
typedef std::vector<GameEventData> GameEventDataMap;
[[nodiscard]] ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; }
[[nodiscard]] GameEventDataMap const& GetEventMap() const { return mGameEvent; }
[[nodiscard]] ActiveEvents const& GetActiveEventList() const { return _activeEvents; }
[[nodiscard]] GameEventDataMap const& GetEventMap() const { return _gameEvent; }
[[nodiscard]] bool CheckOneGameEvent(uint16 entry) const;
[[nodiscard]] uint32 NextCheck(uint16 entry) const;
void LoadFromDB();
void LoadHolidayDates();
uint32 Update();
bool IsActiveEvent(uint16 event_id) { return (m_ActiveEvents.find(event_id) != m_ActiveEvents.end()); }
bool IsActiveEvent(uint16 eventId) { return (_activeEvents.find(eventId) != _activeEvents.end()); }
uint32 StartSystem();
void Initialize();
void StartArenaSeason();
void StartInternalEvent(uint16 event_id);
bool StartEvent(uint16 event_id, bool overwrite = false);
void StopEvent(uint16 event_id, bool overwrite = false);
void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions
void StartInternalEvent(uint16 eventId);
bool StartEvent(uint16 eventId, bool overwrite = false);
void StopEvent(uint16 eventId, bool overwrite = false);
void HandleQuestComplete(uint32 questId); // called on world event type quest completions
uint32 GetNPCFlag(Creature* cr);
// Load the game event npc vendor table from the DB
void LoadEventVendors();
[[nodiscard]] uint32 GetHolidayEventId(uint32 holidayId) const;
private:
void SendWorldStateUpdate(Player* player, uint16 event_id);
void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }
void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); }
void ApplyNewEvent(uint16 event_id);
void UnApplyEvent(uint16 event_id);
void GameEventSpawn(int16 event_id);
void GameEventUnspawn(int16 event_id);
void ChangeEquipOrModel(int16 event_id, bool activate);
void UpdateEventQuests(uint16 event_id, bool activate);
void UpdateWorldStates(uint16 event_id, bool Activate);
void UpdateEventNPCFlags(uint16 event_id);
void UpdateEventNPCVendor(uint16 event_id, bool activate);
void LoadEvents();
void LoadEventSaveData();
void LoadEventPrerequisiteData();
void LoadEventCreatureData();
void LoadEventGameObjectData();
void LoadEventModelEquipmentChangeData();
void LoadEventQuestData();
void LoadEventGameObjectQuestData();
void LoadEventQuestConditionData();
void LoadEventConditionData();
void LoadEventConditionSaveData();
void LoadEventNPCFlags();
void LoadEventSeasonalQuestRelations();
void LoadEventBattlegroundData();
void LoadEventPoolData();
void SendWorldStateUpdate(Player* player, uint16 eventId);
void AddActiveEvent(uint16 eventId) { _activeEvents.insert(eventId); }
void RemoveActiveEvent(uint16 eventId) { _activeEvents.erase(eventId); }
void ApplyNewEvent(uint16 eventId);
void UnApplyEvent(uint16 eventId);
void GameEventSpawn(int16 eventId);
void GameEventUnspawn(int16 eventId);
void ChangeEquipOrModel(int16 eventId, bool activate);
void UpdateEventQuests(uint16 eventId, bool activate);
void UpdateWorldStates(uint16 eventId, bool Activate);
void UpdateEventNPCFlags(uint16 eventId);
void UpdateEventNPCVendor(uint16 eventId, bool activate);
void UpdateBattlegroundSettings();
void RunSmartAIScripts(uint16 event_id, bool activate); //! Runs SMART_EVENT_GAME_EVENT_START/_END SAI
bool CheckOneGameEventConditions(uint16 event_id);
void SaveWorldEventStateToDB(uint16 event_id);
bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id);
bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id);
bool hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id);
bool hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id);
void RunSmartAIScripts(uint16 eventId, bool activate); //! Runs SMART_EVENT_GAME_EVENT_START/_END SAI
bool CheckOneGameEventConditions(uint16 eventId);
void SaveWorldEventStateToDB(uint16 eventId);
bool HasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 eventId);
bool HasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 eventId);
bool HasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 eventId);
bool HasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 eventId);
void SetHolidayEventTime(GameEventData& event);
typedef std::list<ObjectGuid::LowType> GuidLowList;
@@ -165,29 +181,27 @@ private:
typedef std::vector<NPCFlagList> GameEventNPCFlagMap;
typedef std::vector<uint32> GameEventBitmask;
typedef std::unordered_map<uint32, std::vector<uint32>> GameEventSeasonalQuestsMap;
GameEventQuestMap mGameEventCreatureQuests;
GameEventQuestMap mGameEventGameObjectQuests;
GameEventNPCVendorMap mGameEventVendors;
GameEventModelEquipMap mGameEventModelEquip;
//GameEventGuidMap mGameEventCreatureGuids;
//GameEventGuidMap mGameEventGameobjectGuids;
GameEventIdMap mGameEventPoolIds;
GameEventDataMap mGameEvent;
GameEventBitmask mGameEventBattlegroundHolidays;
QuestIdToEventConditionMap mQuestToEventConditions;
GameEventNPCFlagMap mGameEventNPCFlags;
ActiveEvents m_ActiveEvents;
bool isSystemInit;
GameEventQuestMap _gameEventCreatureQuests;
GameEventQuestMap _gameEventGameObjectQuests;
GameEventNPCVendorMap _gameEventVendors;
GameEventModelEquipMap _gameEventModelEquip;
GameEventIdMap _gameEventPoolIds;
GameEventDataMap _gameEvent;
GameEventBitmask _gameEventBattlegroundHolidays;
QuestIdToEventConditionMap _questToEventConditions;
GameEventNPCFlagMap _gameEventNPCFlags;
ActiveEvents _activeEvents;
bool _isSystemInit;
GameEventSeasonalQuestsMap _gameEventSeasonalQuestsMap;
public:
GameEventGuidMap mGameEventCreatureGuids;
GameEventGuidMap mGameEventGameobjectGuids;
std::vector<uint32> modifiedHolidays;
GameEventGuidMap GameEventCreatureGuids;
GameEventGuidMap GameEventGameobjectGuids;
std::vector<uint32> ModifiedHolidays;
};
#define sGameEventMgr GameEventMgr::instance()
bool IsHolidayActive(HolidayIds id);
bool IsEventActive(uint16 event_id);
bool IsEventActive(uint16 eventId);
#endif
+2 -2
View File
@@ -1651,7 +1651,7 @@ CreatureModel const* ObjectMgr::ChooseDisplayId(CreatureTemplate const* cinfo, C
if (CreatureModel const* model = cinfo->GetModelWithDisplayId(data->displayid))
return model;
if (!(cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER))
if (!cinfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_TRIGGER))
if (CreatureModel const* model = cinfo->GetRandomValidModel())
return model;
@@ -2233,7 +2233,7 @@ void ObjectMgr::LoadCreatures()
data.equipmentId = 0;
}
}
if ((cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id2 && cInfo2->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id3 && cInfo3->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND))
if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id2 && cInfo2->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND)) || (data.id3 && cInfo3->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND)))
{
if (!mapEntry->IsDungeon())
LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with a `creature_template`.`flags_extra` in one or more entries including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.",
+2 -2
View File
@@ -153,8 +153,8 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
data.append(dataBuffer);
/// @todo: Fix this, how we do know how many and what holidays to send?
data << uint32(sGameEventMgr->modifiedHolidays.size());
for (uint32 entry : sGameEventMgr->modifiedHolidays)
data << uint32(sGameEventMgr->ModifiedHolidays.size());
for (uint32 entry : sGameEventMgr->ModifiedHolidays)
{
HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(entry);
+1 -1
View File
@@ -743,7 +743,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
return;
}
if ((creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_SELL_VENDOR) != 0)
if (creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_SELL_VENDOR))
{
_player->SendSellError(SELL_ERR_CANT_SELL_TO_THIS_MERCHANT, creature, itemguid, 0);
return;
+4 -12
View File
@@ -70,14 +70,12 @@ void WorldSession::SendTradeStatus(TradeStatus status)
void WorldSession::HandleIgnoreTradeOpcode(WorldPacket& /*recvPacket*/)
{
LOG_DEBUG("network", "WORLD: Ignore Trade {}", _player->GetGUID().ToString());
// recvPacket.print_storage();
_player->TradeCancel(true, TRADE_STATUS_IGNORE_YOU);
}
void WorldSession::HandleBusyTradeOpcode(WorldPacket& /*recvPacket*/)
{
LOG_DEBUG("network", "WORLD: Busy Trade {}", _player->GetGUID().ToString());
// recvPacket.print_storage();
_player->TradeCancel(true, TRADE_STATUS_BUSY);
}
void WorldSession::SendUpdateTrade(bool trader_data /*= true*/)
@@ -526,12 +524,12 @@ void WorldSession::HandleBeginTradeOpcode(WorldPacket& /*recvPacket*/)
SendTradeStatus(TRADE_STATUS_OPEN_WINDOW);
}
void WorldSession::SendCancelTrade()
void WorldSession::SendCancelTrade(TradeStatus status)
{
if (PlayerRecentlyLoggedOut() || PlayerLogout())
return;
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
SendTradeStatus(status);
}
void WorldSession::HandleCancelTradeOpcode(WorldPacket& /*recvPacket*/)
@@ -620,12 +618,6 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
return;
}
if (pOther->GetSocial()->HasIgnore(GetPlayer()->GetGUID()))
{
SendTradeStatus(TRADE_STATUS_IGNORE_YOU);
return;
}
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_TRADE) && pOther->GetTeamId() != _player->GetTeamId())
{
SendTradeStatus(TRADE_STATUS_WRONG_FACTION);
+4 -4
View File
@@ -3724,14 +3724,14 @@ void Map::RemoveOldCorpses()
}
}
void Map::ScheduleCreatureRespawn(ObjectGuid creatureGuid, Milliseconds respawnTimer)
void Map::ScheduleCreatureRespawn(ObjectGuid creatureGuid, Milliseconds respawnTimer, Position pos)
{
_creatureRespawnScheduler.Schedule(respawnTimer, [this, creatureGuid](TaskContext)
_creatureRespawnScheduler.Schedule(respawnTimer, [this, creatureGuid, pos](TaskContext)
{
if (Creature* creature = GetCreature(creatureGuid))
{
creature->Respawn();
}
else
SummonCreature(creatureGuid.GetEntry(), pos);
});
}
+1 -1
View File
@@ -596,7 +596,7 @@ public:
TaskScheduler _creatureRespawnScheduler;
void ScheduleCreatureRespawn(ObjectGuid /*creatureGuid*/, Milliseconds /*respawnTimer*/);
void ScheduleCreatureRespawn(ObjectGuid /*creatureGuid*/, Milliseconds /*respawnTimer*/, Position pos = Position());
void LoadCorpseData();
void DeleteCorpseData();
+1 -1
View File
@@ -167,7 +167,7 @@ Map::EnterState MapMgr::PlayerCannotEnter(uint32 mapid, Player* player, bool log
{
// probably there must be special opcode, because client has this string constant in GlobalStrings.lua
/// @todo: this is not a good place to send the message
player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetAcoreString(LANG_INSTANCE_RAID_GROUP_ONLY), mapName);
player->GetSession()->SendAreaTriggerMessage(LANG_INSTANCE_RAID_GROUP_ONLY, mapName);
LOG_DEBUG("maps", "MAP: Player '{}' must be in a raid group to enter instance '{}'", player->GetName(), mapName);
return Map::CANNOT_ENTER_NOT_IN_RAID;
}
+1 -1
View File
@@ -74,7 +74,7 @@ uint32 Acore::XP::Gain(Player* player, Unit* unit, bool isBattleGround /*= false
uint32 gain = 0;
if (!creature || (!creature->IsTotem() && !creature->IsPet() && !creature->IsCritter() &&
!(creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP)))
!creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_XP)))
{
float xpMod = 1.0f;
+2 -2
View File
@@ -372,7 +372,7 @@ public:
void SendAreaTriggerMessage(std::string_view str);
template<typename... Args>
void SendAreaTriggerMessage(std::string fmt, Args&&... args)
void SendAreaTriggerMessage(char const* fmt, Args&&... args)
{
if (!m_playerLoading)
SendAreaTriggerMessage(Acore::StringFormat(fmt, std::forward<Args>(args)...));
@@ -466,7 +466,7 @@ public:
void SendTradeStatus(TradeStatus status);
void SendUpdateTrade(bool trader_data = true);
void SendCancelTrade();
void SendCancelTrade(TradeStatus status);
void SendPetitionQueryOpcode(ObjectGuid petitionguid);
@@ -3107,6 +3107,7 @@ void SpellMgr::LoadSpellInfoCorrections()
// Tail Smash (Sindragosa)
ApplySpellFix({ 71077 }, [](SpellInfo* spellInfo)
{
spellInfo->AttributesEx2 |= SPELL_ATTR2_IGNORE_LINE_OF_SIGHT;
spellInfo->Effects[EFFECT_0].TargetA = SpellImplicitTargetInfo(TARGET_DEST_CASTER_BACK);
spellInfo->Effects[EFFECT_0].TargetB = SpellImplicitTargetInfo(TARGET_UNIT_DEST_AREA_ENEMY);
spellInfo->Effects[EFFECT_1].TargetA = SpellImplicitTargetInfo(TARGET_DEST_CASTER_BACK);
+3 -3
View File
@@ -881,9 +881,9 @@ std::string WorldState::GetSunsReachPrintout()
}
};
output += "Sunwell Plateau Gate Phase " + std::to_string(m_sunsReachData.m_gate) + " (" + formatGatePhase(m_sunsReachData.m_gate) + ")" + ":\n";
output += " 0. Gate 1 (Agamath): " + std::string(m_sunsReachData.m_gate >= SUNWELL_AGAMATH_GATE1_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_sunsReachReclamationCounters[COUNTER_AGAMATH_THE_FIRST_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_ALL_GATES_CLOSED)) + "%)\n";
output += " 1. Gate 2 (Rohendor): " + std::string(m_sunsReachData.m_gate >= SUNWELL_ROHENDOR_GATE2_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_sunsReachReclamationCounters[COUNTER_ROHENDOR_THE_SECOND_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_AGAMATH_GATE1_OPEN)) + "%)\n";
output += " 2. Gate 3 (Archonisus): " + std::string(m_sunsReachData.m_gate >= SUNWELL_ARCHONISUS_GATE3_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_sunsReachReclamationCounters[COUNTER_ARCHONISUS_THE_FINAL_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_ROHENDOR_GATE2_OPEN)) + "%)\n";
output += " 0. Gate 1 (Agamath): " + std::string(m_sunsReachData.m_gate >= SUNWELL_AGAMATH_GATE1_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_gateCounters[COUNTER_AGAMATH_THE_FIRST_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_ALL_GATES_CLOSED)) + "%)\n";
output += " 1. Gate 2 (Rohendor): " + std::string(m_sunsReachData.m_gate >= SUNWELL_ROHENDOR_GATE2_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_gateCounters[COUNTER_ROHENDOR_THE_SECOND_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_AGAMATH_GATE1_OPEN)) + "%)\n";
output += " 2. Gate 3 (Archonisus): " + std::string(m_sunsReachData.m_gate >= SUNWELL_ARCHONISUS_GATE3_OPEN ? "Open " : "Closed ") + std::to_string(m_sunsReachData.m_gateCounters[COUNTER_ARCHONISUS_THE_FINAL_GATE]) + " (" + std::to_string(m_sunsReachData.GetSunwellGatePercentage(SUNWELL_ROHENDOR_GATE2_OPEN)) + "%)\n";
return output;
}