Skip to content

Commit

Permalink
Chat/GM: Add unkillable command
Browse files Browse the repository at this point in the history
  • Loading branch information
insunaa committed Apr 15, 2024
1 parent 05820e3 commit 53a3801
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/game/Chat/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ ChatCommand* ChatHandler::getCommandTable()
{
{ "chat", SEC_ADMINISTRATOR, false, &ChatHandler::HandleGMChatCommand, "", nullptr },
{ "fly", SEC_ADMINISTRATOR, false, &ChatHandler::HandleGMFlyCommand, "", nullptr },
{ "unkillable", SEC_ADMINISTRATOR, false, &ChatHandler::HandleGMUnkillableCommand, "", nullptr },
{ "ingame", SEC_ADMINISTRATOR, true, &ChatHandler::HandleGMListIngameCommand, "", nullptr },
{ "list", SEC_ADMINISTRATOR, true, &ChatHandler::HandleGMListFullCommand, "", nullptr },
{ "mountup", SEC_ADMINISTRATOR, false, &ChatHandler::HandleGMMountUpCommand, "", nullptr },
Expand Down
1 change: 1 addition & 0 deletions src/game/Chat/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ class ChatHandler
bool HandleGMCommand(char* args);
bool HandleGMChatCommand(char* args);
bool HandleGMFlyCommand(char* args);
bool HandleGMUnkillableCommand(char* args);
bool HandleGMListFullCommand(char* args);
bool HandleGMListIngameCommand(char* args);
bool HandleGMMountUpCommand(char* args);
Expand Down
15 changes: 15 additions & 0 deletions src/game/Chat/Level3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5587,6 +5587,21 @@ bool ChatHandler::HandleGMFlyCommand(char* args)
return true;
}

bool ChatHandler::HandleGMUnkillableCommand(char* args)
{
bool value;
if (!ExtractOnOff(&args, value))
{
SendSysMessage(LANG_USE_BOL);
SetSentErrorMessage(true);
return false;
}
Player* target = m_session->GetPlayer();
target->SetDeathPrevention(value);
PSendSysMessage("GM Unkillability %s.", value ? "enabled" : "disabled");
return true;
}

bool ChatHandler::HandlePDumpLoadCommand(char* args)
{
char* file = ExtractQuotedOrLiteralArg(&args);
Expand Down
19 changes: 19 additions & 0 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21965,6 +21965,25 @@ void Player::SendLootError(ObjectGuid guid, LootError error) const
SendDirectMessage(data);
}

void Player::SetDeathPrevention(bool enable)
{
if (enable)
m_ExtraFlags |= PLAYER_EXTRA_GM_UNKILLABLE;
else
m_ExtraFlags &= ~PLAYER_EXTRA_GM_UNKILLABLE;
}

bool Player::IsPreventingDeath() const
{
return m_ExtraFlags & PLAYER_EXTRA_GM_UNKILLABLE;
}

void Player::ResetDeathTimer()

This comment has been minimized.

Copy link
@insunaa

insunaa Apr 15, 2024

Author Contributor

ah crap I messed up the cherry-pick
I think this has to go?

This comment has been minimized.

Copy link
@insunaa

insunaa Apr 15, 2024

Author Contributor

I have an appointment, I'll fix this in an hour. sorry for the inconvenience

{
// 6 minutes until repop at graveyard
m_deathTimer = 6 * MINUTE * IN_MILLISECONDS;
}

void Player::AddGCD(SpellEntry const& spellEntry, uint32 /*forcedDuration = 0*/, bool updateClient /*= false*/)
{
int32 gcdDuration = spellEntry.StartRecoveryTime;
Expand Down
6 changes: 6 additions & 0 deletions src/game/Entities/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ enum PlayerExtraFlags
// other states
PLAYER_EXTRA_PVP_DEATH = 0x0100, // store PvP death status until corpse creating.
PLAYER_EXTRA_WHISP_RESTRICTION = 0x0200,

// death prevention
PLAYER_EXTRA_GM_UNKILLABLE = 0x0400,
};

// 2^n values
Expand Down Expand Up @@ -2294,6 +2297,9 @@ class Player : public Unit

void SendLootError(ObjectGuid guid, LootError error) const;

void SetDeathPrevention(bool enable);
bool IsPreventingDeath() const override;

// cooldown system
virtual void AddGCD(SpellEntry const& spellEntry, uint32 forcedDuration = 0, bool updateClient = false) override;
virtual void AddCooldown(SpellEntry const& spellEntry, ItemPrototype const* itemProto = nullptr, bool permanent = false, uint32 forcedDuration = 0, bool ignoreCat = false) override;
Expand Down

0 comments on commit 53a3801

Please sign in to comment.