mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 07:48:02 +00:00
chore(Core/ScriptMgr): Hooks used in mod-aoe-loot (#16589)
* Creating the necessary hooks for the loot aoe * update hook * Typing error * Method name and add documentation * codestyle * Misc. fixes
This commit is contained in:
@@ -13442,7 +13442,10 @@ LootItem* Player::StoreLootItem(uint8 lootSlot, Loot* loot, InventoryResult& msg
|
|||||||
LootItem* item = loot->LootItemInSlot(lootSlot, this, &qitem, &ffaitem, &conditem);
|
LootItem* item = loot->LootItemInSlot(lootSlot, this, &qitem, &ffaitem, &conditem);
|
||||||
if (!item || item->is_looted)
|
if (!item || item->is_looted)
|
||||||
{
|
{
|
||||||
SendEquipError(EQUIP_ERR_ALREADY_LOOTED, nullptr, nullptr);
|
if (!sScriptMgr->CanSendErrorAlreadyLooted(this))
|
||||||
|
{
|
||||||
|
SendEquipError(EQUIP_ERR_ALREADY_LOOTED, nullptr, nullptr);
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData)
|
|||||||
loot = &creature->loot;
|
loot = &creature->loot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sScriptMgr->OnAfterCreatureLoot(player);
|
||||||
|
|
||||||
InventoryResult msg;
|
InventoryResult msg;
|
||||||
LootItem* lootItem = player->StoreLootItem(lootSlot, loot, msg);
|
LootItem* lootItem = player->StoreLootItem(lootSlot, loot, msg);
|
||||||
if (msg != EQUIP_ERR_OK && lguid.IsItem() && loot->loot_type != LOOT_CORPSE)
|
if (msg != EQUIP_ERR_OK && lguid.IsItem() && loot->loot_type != LOOT_CORPSE)
|
||||||
@@ -209,6 +211,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
sScriptMgr->OnAfterCreatureLootMoney(player);
|
||||||
player->ModifyMoney(loot->gold);
|
player->ModifyMoney(loot->gold);
|
||||||
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, loot->gold);
|
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, loot->gold);
|
||||||
|
|
||||||
|
|||||||
@@ -905,6 +905,37 @@ bool ScriptMgr::CanSendMail(Player* player, ObjectGuid receiverGuid, ObjectGuid
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptMgr::CanSendErrorAlreadyLooted(Player* player)
|
||||||
|
{
|
||||||
|
auto ret = IsValidBoolScript<PlayerScript>([&](PlayerScript* script)
|
||||||
|
{
|
||||||
|
return !script->CanSendErrorAlreadyLooted(player);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ret && *ret)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnAfterCreatureLoot(Player* player)
|
||||||
|
{
|
||||||
|
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
||||||
|
{
|
||||||
|
script->OnAfterCreatureLoot(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnAfterCreatureLootMoney(Player* player)
|
||||||
|
{
|
||||||
|
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
||||||
|
{
|
||||||
|
script->OnAfterCreatureLootMoney(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptMgr::PetitionBuy(Player* player, Creature* creature, uint32& charterid, uint32& cost, uint32& type)
|
void ScriptMgr::PetitionBuy(Player* player, Creature* creature, uint32& charterid, uint32& cost, uint32& type)
|
||||||
{
|
{
|
||||||
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
||||||
|
|||||||
@@ -1481,6 +1481,30 @@ public:
|
|||||||
virtual void AnticheatUpdateMovementInfo(Player* /*player*/, MovementInfo const& /*movementInfo*/) { }
|
virtual void AnticheatUpdateMovementInfo(Player* /*player*/, MovementInfo const& /*movementInfo*/) { }
|
||||||
[[nodiscard]] virtual bool AnticheatHandleDoubleJump(Player* /*player*/, Unit* /*mover*/) { return true; }
|
[[nodiscard]] virtual bool AnticheatHandleDoubleJump(Player* /*player*/, Unit* /*mover*/) { return true; }
|
||||||
[[nodiscard]] virtual bool AnticheatCheckMovementInfo(Player* /*player*/, MovementInfo const& /*movementInfo*/, Unit* /*mover*/, bool /*jump*/) { return true; }
|
[[nodiscard]] virtual bool AnticheatCheckMovementInfo(Player* /*player*/, MovementInfo const& /*movementInfo*/, Unit* /*mover*/, bool /*jump*/) { return true; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This hook is called, to avoid displaying the error message that the body has already been stripped
|
||||||
|
*
|
||||||
|
* @param player Contains information about the Player
|
||||||
|
*
|
||||||
|
* @return true Avoiding displaying the error message that the loot has already been taken.
|
||||||
|
*/
|
||||||
|
virtual bool CanSendErrorAlreadyLooted(Player* /*player*/) { return true; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief It is used when an item is taken from a creature.
|
||||||
|
*
|
||||||
|
* @param player Contains information about the Player
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void OnAfterCreatureLoot(Player* /*player*/) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief After a creature's money is taken
|
||||||
|
*
|
||||||
|
* @param player Contains information about the Player
|
||||||
|
*/
|
||||||
|
virtual void OnAfterCreatureLootMoney(Player* /*player*/) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class AccountScript : public ScriptObject
|
class AccountScript : public ScriptObject
|
||||||
@@ -2406,6 +2430,9 @@ public: /* PlayerScript */
|
|||||||
void OnPlayerEnterCombat(Player* player, Unit* enemy);
|
void OnPlayerEnterCombat(Player* player, Unit* enemy);
|
||||||
void OnPlayerLeaveCombat(Player* player);
|
void OnPlayerLeaveCombat(Player* player);
|
||||||
void OnQuestAbandon(Player* player, uint32 questId);
|
void OnQuestAbandon(Player* player, uint32 questId);
|
||||||
|
bool CanSendErrorAlreadyLooted(Player* player);
|
||||||
|
void OnAfterCreatureLoot(Player* player);
|
||||||
|
void OnAfterCreatureLootMoney(Player* player);
|
||||||
|
|
||||||
// Anti cheat
|
// Anti cheat
|
||||||
void AnticheatSetSkipOnePacketForASH(Player* player, bool apply);
|
void AnticheatSetSkipOnePacketForASH(Player* player, bool apply);
|
||||||
|
|||||||
Reference in New Issue
Block a user