mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 16:43:47 +00:00
Merge branch 'azerothcore:master' into Playerbot
This commit is contained in:
@@ -573,10 +573,18 @@ bool BattlegroundQueue::CheckPremadeMatch(BattlegroundBracketId bracket_id, uint
|
||||
// this method tries to create battleground or arena with MinPlayersPerTeam against MinPlayersPerTeam
|
||||
bool BattlegroundQueue::CheckNormalMatch(Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers)
|
||||
{
|
||||
if (sScriptMgr->IsCheckNormalMatch(this, bgTemplate, bracket_id, minPlayers, maxPlayers))
|
||||
auto CanStartMatch = [this, bgTemplate, minPlayers]()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//allow 1v0 if debug bg
|
||||
if (sBattlegroundMgr->isTesting() && bgTemplate->isBattleground() && (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_HORDE].GetPlayerCount()))
|
||||
return true;
|
||||
|
||||
//return true if there are enough players in selection pools - enable to work .debug bg command correctly
|
||||
return m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers;
|
||||
};
|
||||
|
||||
if (sScriptMgr->IsCheckNormalMatch(this, bgTemplate, bracket_id, minPlayers, maxPlayers))
|
||||
return CanStartMatch();
|
||||
|
||||
GroupsQueueType::const_iterator itr_team[PVP_TEAMS_COUNT];
|
||||
for (uint32 i = 0; i < PVP_TEAMS_COUNT; i++)
|
||||
@@ -615,12 +623,7 @@ bool BattlegroundQueue::CheckNormalMatch(Battleground* bgTemplate, BattlegroundB
|
||||
return false;
|
||||
}
|
||||
|
||||
//allow 1v0 if debug bg
|
||||
if (sBattlegroundMgr->isTesting() && bgTemplate->isBattleground() && (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_HORDE].GetPlayerCount()))
|
||||
return true;
|
||||
|
||||
//return true if there are enough players in selection pools - enable to work .debug bg command correctly
|
||||
return m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers;
|
||||
return CanStartMatch();
|
||||
}
|
||||
|
||||
// this method will check if we can invite players to same faction skirmish match
|
||||
|
||||
@@ -1535,7 +1535,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
oldmap->RemovePlayerFromMap(this, false);
|
||||
|
||||
// xinef: do this before setting fall information!
|
||||
if (IsMounted() && (!GetMap()->GetEntry()->IsDungeon() && !GetMap()->GetEntry()->IsBattlegroundOrArena()))
|
||||
if (IsMounted() && (!GetMap()->GetEntry()->IsDungeon() && !GetMap()->GetEntry()->IsBattlegroundOrArena()) && !m_transport)
|
||||
{
|
||||
AuraEffectList const& auras = GetAuraEffectsByType(SPELL_AURA_MOUNTED);
|
||||
if (!auras.empty())
|
||||
|
||||
@@ -18592,8 +18592,11 @@ float Unit::MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, i
|
||||
//calculate miss chance
|
||||
float missChance = victim->GetUnitMissChance(attType);
|
||||
|
||||
if (!spellId && haveOffhandWeapon())
|
||||
// Check if dual wielding, add additional miss penalty - when mainhand has on next swing spell, offhand doesnt suffer penalty
|
||||
if (!spellId && (attType != RANGED_ATTACK) && haveOffhandWeapon() && (!m_currentSpells[CURRENT_MELEE_SPELL] || !m_currentSpells[CURRENT_MELEE_SPELL]->IsNextMeleeSwingSpell()))
|
||||
{
|
||||
missChance += 19;
|
||||
}
|
||||
|
||||
// bonus from skills is 0.04%
|
||||
//miss_chance -= skillDiff * 0.04f;
|
||||
@@ -19546,6 +19549,11 @@ bool Unit::CanSwim() const
|
||||
return HasUnitFlag(UNIT_FLAG_RENAME | UNIT_FLAG_SWIMMING);
|
||||
}
|
||||
|
||||
void Unit::NearTeleportTo(Position& pos, bool casting /*= false*/, bool vehicleTeleport /*= false*/, bool withPet /*= false*/, bool removeTransport /*= false*/)
|
||||
{
|
||||
NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), casting, vehicleTeleport, withPet, removeTransport);
|
||||
}
|
||||
|
||||
void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/, bool vehicleTeleport /*= false*/, bool withPet /*= false*/, bool removeTransport /*= false*/)
|
||||
{
|
||||
DisableSpline();
|
||||
|
||||
@@ -1733,6 +1733,7 @@ public:
|
||||
void SendSpellDamageResist(Unit* target, uint32 spellId);
|
||||
void SendSpellDamageImmune(Unit* target, uint32 spellId);
|
||||
|
||||
void NearTeleportTo(Position& pos, bool casting = false, bool vehicleTeleport = false, bool withPet = false, bool removeTransport = false);
|
||||
void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false, bool vehicleTeleport = false, bool withPet = false, bool removeTransport = false);
|
||||
void SendTameFailure(uint8 result);
|
||||
void SendTeleportPacket(Position& pos);
|
||||
|
||||
@@ -403,6 +403,12 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->GetCharmGUID() || _player->IsInCombat())
|
||||
{
|
||||
_player->GetSession()->SendNotification(LANG_YOU_IN_COMBAT);
|
||||
return;
|
||||
}
|
||||
|
||||
// get BattlegroundQueue for received
|
||||
BattlegroundTypeId bgTypeId = BattlegroundTypeId(bgTypeId_);
|
||||
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenaType);
|
||||
|
||||
@@ -233,16 +233,19 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
}
|
||||
}
|
||||
|
||||
if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))// wrapped?
|
||||
if (sScriptMgr->OnBeforeOpenItem(pUser, item))
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM);
|
||||
stmt->SetData(0, item->GetGUID().GetCounter());
|
||||
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt)
|
||||
.WithPreparedCallback(std::bind(&WorldSession::HandleOpenWrappedItemCallback, this, bagIndex, slot, item->GetGUID().GetCounter(), std::placeholders::_1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
pUser->SendLoot(item->GetGUID(), LOOT_CORPSE);
|
||||
if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))// wrapped?
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM);
|
||||
stmt->SetData(0, item->GetGUID().GetCounter());
|
||||
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt)
|
||||
.WithPreparedCallback(std::bind(&WorldSession::HandleOpenWrappedItemCallback, this, bagIndex, slot, item->GetGUID().GetCounter(), std::placeholders::_1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
pUser->SendLoot(item->GetGUID(), LOOT_CORPSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1946,11 +1946,11 @@ inline LiquidData const GridMap::GetLiquidData(float x, float y, float z, float
|
||||
{
|
||||
// Get water level
|
||||
float liquid_level = _liquidMap ? _liquidMap[lx_int * _liquidWidth + ly_int] : _liquidLevel;
|
||||
// Get ground level (sub 0.2 for fix some errors)
|
||||
// Get ground level
|
||||
float ground_level = getHeight(x, y);
|
||||
|
||||
// Check water level and ground level
|
||||
if (liquid_level >= ground_level && z >= ground_level)
|
||||
// Check water level and ground level (sub 0.2 for fix some errors)
|
||||
if (liquid_level >= ground_level && z >= ground_level - 0.2f)
|
||||
{
|
||||
// All ok in water -> store data
|
||||
liquidData.Entry = entry;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Log.h"
|
||||
#include "MapMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
Graveyard* Graveyard::instance()
|
||||
{
|
||||
@@ -95,6 +96,13 @@ GraveyardStruct const* Graveyard::GetDefaultGraveyard(TeamId teamId)
|
||||
|
||||
GraveyardStruct const* Graveyard::GetClosestGraveyard(Player* player, TeamId teamId, bool nearCorpse)
|
||||
{
|
||||
uint32 graveyardOverride = 0;
|
||||
sScriptMgr->OnBeforeChooseGraveyard(player, teamId, nearCorpse, graveyardOverride);
|
||||
if (graveyardOverride)
|
||||
{
|
||||
return sGraveyard->GetGraveyard(graveyardOverride);
|
||||
}
|
||||
|
||||
WorldLocation loc = player->GetWorldLocation();
|
||||
|
||||
if (nearCorpse)
|
||||
|
||||
@@ -606,6 +606,21 @@ void ScriptMgr::OnGroupRollRewardItem(Player* player, Item* item, uint32 count,
|
||||
});
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnBeforeOpenItem(Player* player, Item* item)
|
||||
{
|
||||
auto ret = IsValidBoolScript<PlayerScript>([&](PlayerScript* script)
|
||||
{
|
||||
return !script->OnBeforeOpenItem(player, item);
|
||||
});
|
||||
|
||||
if (ret && *ret)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScriptMgr::OnFirstLogin(Player* player)
|
||||
{
|
||||
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
||||
@@ -1357,6 +1372,14 @@ void ScriptMgr::OnPlayerResurrect(Player* player, float restore_percent, bool ap
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnBeforeChooseGraveyard(Player* player, TeamId teamId, bool nearCorpse, uint32& graveyardOverride)
|
||||
{
|
||||
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
||||
{
|
||||
script->OnBeforeChooseGraveyard(player, teamId, nearCorpse, graveyardOverride);
|
||||
});
|
||||
}
|
||||
|
||||
bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg)
|
||||
{
|
||||
auto ret = IsValidBoolScript<PlayerScript>([&](PlayerScript* script)
|
||||
|
||||
@@ -1178,6 +1178,9 @@ public:
|
||||
// After receiving item as a group roll reward
|
||||
virtual void OnGroupRollRewardItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/, RollVote /*voteType*/, Roll* /*roll*/) { }
|
||||
|
||||
//Before opening an item
|
||||
[[nodiscard]] virtual bool OnBeforeOpenItem(Player* /*player*/, Item* /*item*/) { return true; }
|
||||
|
||||
// After completed a quest
|
||||
[[nodiscard]] virtual bool OnBeforeQuestComplete(Player* /*player*/, uint32 /*quest_id*/) { return true; }
|
||||
|
||||
@@ -1318,6 +1321,9 @@ public:
|
||||
|
||||
virtual void OnPlayerResurrect(Player* /*player*/, float /*restore_percent*/, bool /*applySickness*/) { }
|
||||
|
||||
// Called before selecting the graveyard when releasing spirit
|
||||
virtual void OnBeforeChooseGraveyard(Player* /*player*/, TeamId /*teamId*/, bool /*nearCorpse*/, uint32& /*graveyardOverride*/) { }
|
||||
|
||||
/**
|
||||
* @brief This hook called before player sending message in default chat
|
||||
*
|
||||
@@ -2290,6 +2296,7 @@ public: /* PlayerScript */
|
||||
void OnCreateItem(Player* player, Item* item, uint32 count);
|
||||
void OnQuestRewardItem(Player* player, Item* item, uint32 count);
|
||||
void OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll);
|
||||
bool OnBeforeOpenItem(Player* player, Item* item);
|
||||
bool OnBeforePlayerQuestComplete(Player* player, uint32 quest_id);
|
||||
void OnQuestComputeXP(Player* player, Quest const* quest, uint32& xpValue);
|
||||
void OnBeforePlayerDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank);
|
||||
@@ -2358,6 +2365,7 @@ public: /* PlayerScript */
|
||||
void OnSetServerSideVisibility(Player* player, ServerSideVisibilityType& type, AccountTypes& sec);
|
||||
void OnSetServerSideVisibilityDetect(Player* player, ServerSideVisibilityType& type, AccountTypes& sec);
|
||||
void OnPlayerResurrect(Player* player, float restore_percent, bool applySickness);
|
||||
void OnBeforeChooseGraveyard(Player* player, TeamId teamId, bool nearCorpse, uint32& graveyardOverride);
|
||||
bool CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg);
|
||||
bool CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Player* receiver);
|
||||
bool CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Group* group);
|
||||
|
||||
Reference in New Issue
Block a user