Skip to content

Commit

Permalink
Implement .freezplayer/.unfreezlayer command (#144)
Browse files Browse the repository at this point in the history
REQUIRES DB UPDATE : Rel22_01_010_freeze_gm_command.sql

This command will apply freeze aura (spellId:9454) :
- Player cannot more anymore or use any spell nor logout ;
- Effet does not disappear even if player quits game via ALT+F4.....Can only be removed by an GM using ".unfreezeplayer" command or .unaura command

A GM with lower security level cannot freeze another GM with a higher security level.
  • Loading branch information
Elmsroth authored Mar 6, 2021
1 parent 2a9c186 commit 3202c90
Show file tree
Hide file tree
Showing 7 changed files with 1,011 additions and 870 deletions.
33 changes: 0 additions & 33 deletions src/game/ChatCommands/CastAndAuraCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,36 +514,3 @@ bool ChatHandler::HandleUnAuraGroupCommand(char* args)
}
}

bool AddAuraToPlayer(const SpellEntry * spellInfo,Unit * target, WorldObject * caster)
{
// We assume the spellInfo has been checked and teh spell has aura effects
/*
if (!IsSpellAppliesAura(spellInfo, (1 << EFFECT_INDEX_0) | (1 << EFFECT_INDEX_1) | (1 << EFFECT_INDEX_2)) &&
!spellInfo->HasSpellEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA))
*/
if (!spellInfo)
{
return false;
}

SpellAuraHolder* holder = CreateSpellAuraHolder(spellInfo, target, caster);

for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{
uint8 eff = spellInfo->Effect[i];
if (eff >= TOTAL_SPELL_EFFECTS)
{
continue;
}
if (IsAreaAuraEffect(eff) ||
eff == SPELL_EFFECT_APPLY_AURA ||
eff == SPELL_EFFECT_PERSISTENT_AREA_AURA)
{
Aura* aur = CreateAura(spellInfo, SpellEffectIndex(i), NULL, holder, target);
holder->AddAura(aur, SpellEffectIndex(i));
}
}
target->AddSpellAuraHolder(holder);

return true;
}
125 changes: 124 additions & 1 deletion src/game/ChatCommands/GMCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ bool ChatHandler::HandleModifyStandStateCommand(char* args)
return true;
}


bool ChatHandler::HandleChangeWeatherCommand(char* args)
{
// Weather is OFF
Expand Down Expand Up @@ -428,3 +427,127 @@ bool ChatHandler::HandleChangeWeatherCommand(char* args)

return true;
}

// Internal shortcut function to freeze a player
bool freezePlayer(Player* player, WorldObject* caster)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(SPELL_GM_FREEZE);
return AddAuraToPlayer(spellInfo, player, caster);
}

// Internal shortcut function to freeze a player
void unFreezePlayer(Player* player)
{
player->RemoveAurasDueToSpell(SPELL_GM_FREEZE);
}


bool ChatHandler::HandleFreezePlayerCommand(char* args)
{
Player* targetPlayer = nullptr;

// 1. Try to extract player name from args if not empty
if (*args)
{
char* playerName = ExtractLiteralArg(&args);

if (!ExtractPlayerTarget(&playerName, &targetPlayer))
{
SendSysMessage(LANG_COMMAND_FREEZE_PLAYER_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
}

// 2. If arg is empty, gets the current selected target (returns current player if no unit selected)
if (!targetPlayer)
{
Unit* selectedTtarget = getSelectedPlayer();

if (!selectedTtarget)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
return false;
}
targetPlayer = (Player*)selectedTtarget;
}


const char* targetName = targetPlayer->GetName();
Player * currentGM = m_session->GetPlayer();

// Prevent freezing yourself !
if (targetPlayer == currentGM)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
SendSysMessage(LANG_COMMAND_FREEZE_PLAYER_CANNOT_FREEZE_YOURSELF);
SetSentErrorMessage(true);
return false;
}

// Check if target can be freezed
if (targetPlayer->GetSession()->GetSecurity() > m_session->GetSecurity())
{
PSendSysMessage(LANG_COMMAND_FREEZE_PLAYER_CANNOT_FREEZE_HIGHER_SECLEVEL, targetName);
SetSentErrorMessage(true);
return false;
}

freezePlayer(targetPlayer, currentGM);

// Notif GM
PSendSysMessage(LANG_COMMAND_FREEZE_PLAYER, targetName);

// Send message to player to prevent he has been frozen
ChatHandler(targetPlayer).SendSysMessage(LANG_COMMAND_FREEZE_PLAYER_YOU_HAVE_BEEN_FROZEN);

return true;
}


bool ChatHandler::HandleUnfreezePlayerCommand(char* args)
{

Player* targetPlayer = nullptr;

// 1. Try to extract player name from args if not empty
if (*args)
{
char* playerName = ExtractLiteralArg(&args);

if (!ExtractPlayerTarget(&playerName, &targetPlayer))
{
SendSysMessage(LANG_COMMAND_UNFREEZE_PLAYER_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
}

// 2. If arg is empty, gets the current selected target (returns current player if no unit selected)
if (!targetPlayer)
{
Unit* selectedTtarget = getSelectedPlayer();

if (!selectedTtarget)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
return false;
}
targetPlayer = (Player*)selectedTtarget;
}

unFreezePlayer(targetPlayer);

// Notif GM
PSendSysMessage(LANG_COMMAND_UNFREEZE_PLAYER, targetPlayer->GetName());

// Send message to player to prevent he has been unfrozen
ChatHandler(targetPlayer).SendSysMessage(LANG_COMMAND_FREEZE_PLAYER_YOU_HAVE_BEEN_UNFROZEN);

return true;
}



1 change: 1 addition & 0 deletions src/game/Server/SharedDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -2625,6 +2625,7 @@ enum SpellEntriesConsts
SPELL_FILLING_EMPTY_JAR__CURSED_OOZE = 15698,
SPELL_FILLING_EMPTY_JAR__TAINTED_OOZE = 15699,
SPELL_FILLING_EMPTY_JAR__PURE_OOZE = 15702, // (Works on Primal, Muculent and Glutonous Ooze)
SPELL_GM_FREEZE = 9454,
};

#endif
Loading

0 comments on commit 3202c90

Please sign in to comment.