Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(Core/Scripting): Add new hook CanPlayerResurrect to simplify HardCore mod etc. #21272

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4491,6 +4491,9 @@ void Player::BuildPlayerRepop()

void Player::ResurrectPlayer(float restore_percent, bool applySickness)
{
if (!sScriptMgr->CanPlayerResurrect(this))
return;

WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4 * 4); // remove spirit healer position
data << uint32(-1);
data << float(0);
Expand Down
5 changes: 5 additions & 0 deletions src/server/game/Scripting/ScriptDefines/PlayerScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,11 @@ bool ScriptMgr::AnticheatCheckMovementInfo(Player* player, MovementInfo const& m
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ANTICHEAT_CHECK_MOVEMENT_INFO, !script->AnticheatCheckMovementInfo(player, movementInfo, mover, jump));
}

bool ScriptMgr::CanPlayerResurrect(Player* player)
{
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_RESURRECT, !script->CanPlayerResurrect(player));
}

PlayerScript::PlayerScript(const char* name, std::vector<uint16> enabledHooks)
: ScriptObject(name, PLAYERHOOK_END)
{
Expand Down
10 changes: 10 additions & 0 deletions src/server/game/Scripting/ScriptDefines/PlayerScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ enum PlayerHook
PLAYERHOOK_CAN_SEND_ERROR_ALREADY_LOOTED,
PLAYERHOOK_ON_AFTER_CREATURE_LOOT,
PLAYERHOOK_ON_AFTER_CREATURE_LOOT_MONEY,
PLAYERHOOK_CAN_RESURRECT,
PLAYERHOOK_END
};

Expand Down Expand Up @@ -765,6 +766,15 @@ class PlayerScript : public ScriptObject
* @param player Contains information about the Player
*/
virtual void OnAfterCreatureLootMoney(Player* /*player*/) { }

/**
* @brief This hook is called, to avoid player resurrect
*
* @param player Contains information about the Player
*
* @return true if player is authorized to resurect
*/
virtual bool CanPlayerResurrect(Player* /*player*/) { return true; }
};

#endif
1 change: 1 addition & 0 deletions src/server/game/Scripting/ScriptMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ class ScriptMgr
void OnAfterCreatureLoot(Player* player);
void OnAfterCreatureLootMoney(Player* player);
bool OnCanPlayerFlyInZone(Player* player, uint32 mapId, uint32 zoneId, SpellInfo const* bySpell);
bool CanPlayerResurrect(Player* player);

// Anti cheat
void AnticheatSetCanFlybyServer(Player* player, bool apply);
Expand Down
Loading