feat(Commands): Added cheat commands (#1412)

This commit is contained in:
Nefertumm
2019-02-24 14:35:08 -03:00
committed by Francesco Borzì
parent e659ca5fe9
commit 40f68ab026
10 changed files with 293 additions and 80 deletions
@@ -912,6 +912,8 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
SetPendingBind(0, 0);
_activeCheats = CHEAT_NONE;
m_achievementMgr = new AchievementMgr(this);
m_reputationMgr = new ReputationMgr(this);
+17
View File
@@ -899,6 +899,16 @@ enum AdditionalSaving
ADDITIONAL_SAVING_QUEST_STATUS = 0x02,
};
enum PlayerCommandStates
{
CHEAT_NONE = 0x00,
CHEAT_GOD = 0x01,
CHEAT_CASTTIME = 0x02,
CHEAT_COOLDOWN = 0x04,
CHEAT_POWER = 0x08,
CHEAT_WATERWALK = 0x10
};
class PlayerTaxi
{
public:
@@ -1177,6 +1187,11 @@ class Player : public Unit, public GridObject<Player>
void InitStatsForLevel(bool reapplyMods = false);
// .cheat command related
bool GetCommandStatus(uint32 command) const { return _activeCheats & command; }
void SetCommandStatusOn(uint32 command) { _activeCheats |= command; }
void SetCommandStatusOff(uint32 command) { _activeCheats &= ~command; }
// Played Time Stuff
time_t m_logintime;
time_t m_Last_tick;
@@ -2938,6 +2953,8 @@ class Player : public Unit, public GridObject<Player>
uint32 _pendingBindId;
uint32 _pendingBindTimer;
uint32 _activeCheats;
// duel health and mana reset attributes
uint32 healthBeforeDuel;
uint32 manaBeforeDuel;
+4
View File
@@ -696,6 +696,10 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage
// Signal to pets that their owner was attacked
Pet* pet = victim->ToPlayer()->GetPet();
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->ToPlayer()->GetCommandStatus(CHEAT_GOD))
return 0;
if (pet && pet->IsAlive())
pet->AI()->OwnerAttackedBy(attacker);
}
+17
View File
@@ -3414,6 +3414,10 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
m_casttime = (_triggeredCastFlags & TRIGGERED_CAST_DIRECTLY) ? 0 : m_spellInfo->CalcCastTime(m_caster, this);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME))
m_casttime = 0;
// don't allow channeled spells / spells with cast time to be casted while moving
// (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in)
if ((m_spellInfo->IsChanneled() || m_casttime) && m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->isMoving() && m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT && !IsTriggered())
@@ -3832,6 +3836,10 @@ void Spell::_cast(bool skipCheck)
if (GetDelayMoment() > 0 && !m_caster->IsFriendlyTo(target) && !m_spellInfo->HasAura(SPELL_AURA_BIND_SIGHT) && (!m_spellInfo->IsPositive() || m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL)))
m_caster->CombatStartOnCast(target, !m_spellInfo->HasAttribute(SPELL_ATTR3_NO_INITIAL_AGGRO), GetDelayMoment() + 500); // xinef: increase this time so we dont leave and enter combat in a moment
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true);
SetExecutedCurrently(false);
}
@@ -4951,6 +4959,11 @@ void Spell::TakePower()
if (m_CastItem || m_triggeredByAuraSpell)
return;
//Don't take power if the spell is cast while .cheat power is enabled.
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_POWER))
return;
Powers powerType = Powers(m_spellInfo->PowerType);
bool hit = true;
if (m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -8300,6 +8313,10 @@ void Spell::TriggerGlobalCooldown()
return;
}
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
return;
// Global cooldown can't leave range 1..1.5 secs
// There are some spells (mostly not casted directly by player) that have < 1 sec and > 1.5 sec global cooldowns
// but as tests show are not affected by any spell mods.
+4
View File
@@ -276,6 +276,10 @@ void Spell::EffectInstaKill(SpellEffIndex /*effIndex*/)
if (!unitTarget || !unitTarget->IsAlive() || unitTarget->HasAura(27827)) // Spirit of redemption doesn't make you death, but can cause infinite loops
return;
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
if (unitTarget->ToPlayer()->GetCommandStatus(CHEAT_GOD))
return;
if (m_caster == unitTarget) // prevent interrupt message
finish();