mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-20 06:59:46 -04:00
Core/Scripts: Added CalcCastTime spell script hook
This commit is contained in:
@@ -2333,7 +2333,9 @@ void WorldObject::ModSpellCastTime(SpellInfo const* spellInfo, int32& castTime,
|
||||
if (!unitCaster)
|
||||
return;
|
||||
|
||||
if (!(spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_IS_TRADESKILL) || spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_CASTER_MODIFIERS)) &&
|
||||
if (unitCaster->IsPlayer() && unitCaster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME))
|
||||
castTime = 0;
|
||||
else if (!(spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_IS_TRADESKILL) || spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_CASTER_MODIFIERS)) &&
|
||||
((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT))
|
||||
castTime = unitCaster->CanInstantCast() ? 0 : int32(float(castTime) * unitCaster->m_unitData->ModCastingSpeed);
|
||||
else if (spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTO_REPEAT))
|
||||
|
||||
@@ -3377,18 +3377,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const& targets, AuraEffect const
|
||||
// Prepare data for triggers
|
||||
prepareDataForTriggerSystem();
|
||||
|
||||
if (Player* player = m_caster->ToPlayer())
|
||||
{
|
||||
if (!player->GetCommandStatus(CHEAT_CASTTIME))
|
||||
{
|
||||
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
|
||||
m_casttime = m_spellInfo->CalcCastTime(this);
|
||||
}
|
||||
else
|
||||
m_casttime = 0; // Set cast time to 0 if .cheat casttime is enabled.
|
||||
}
|
||||
else
|
||||
m_casttime = m_spellInfo->CalcCastTime(this);
|
||||
m_casttime = CallScriptCalcCastTimeHandlers(m_spellInfo->CalcCastTime(this));
|
||||
|
||||
if (m_caster->IsUnit() && m_caster->ToUnit()->isMoving())
|
||||
{
|
||||
@@ -8432,6 +8421,17 @@ SpellCastResult Spell::CallScriptCheckCastHandlers()
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int32 Spell::CallScriptCalcCastTimeHandlers(int32 castTime)
|
||||
{
|
||||
for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
|
||||
{
|
||||
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CALC_CAST_TIME);
|
||||
castTime = (*scritr)->CalcCastTime(castTime);
|
||||
(*scritr)->_FinishScriptCall();
|
||||
}
|
||||
return castTime;
|
||||
}
|
||||
|
||||
bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMode mode)
|
||||
{
|
||||
// execute script effect handler hooks and check if effects was prevented
|
||||
|
||||
@@ -823,6 +823,7 @@ class TC_GAME_API Spell
|
||||
void CallScriptOnCastHandlers();
|
||||
void CallScriptAfterCastHandlers();
|
||||
SpellCastResult CallScriptCheckCastHandlers();
|
||||
int32 CallScriptCalcCastTimeHandlers(int32 originalCastTime);
|
||||
bool CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMode mode);
|
||||
void CallScriptSuccessfulDispel(SpellEffIndex effIndex);
|
||||
void CallScriptBeforeHitHandlers(SpellMissInfo missInfo);
|
||||
|
||||
@@ -217,6 +217,7 @@ enum SpellScriptHookType
|
||||
SPELL_SCRIPT_HOOK_AFTER_CAST,
|
||||
SPELL_SCRIPT_HOOK_CALC_CRIT_CHANCE,
|
||||
SPELL_SCRIPT_HOOK_ON_PRECAST,
|
||||
SPELL_SCRIPT_HOOK_CALC_CAST_TIME,
|
||||
};
|
||||
|
||||
#define HOOK_SPELL_HIT_START SPELL_SCRIPT_HOOK_EFFECT_HIT
|
||||
@@ -415,6 +416,7 @@ class TC_GAME_API SpellScript : public _SpellScript
|
||||
|
||||
#define PrepareSpellScript(CLASSNAME) SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME)
|
||||
public:
|
||||
SpellScript() : m_spell(nullptr), m_hitPreventEffectMask(0), m_hitPreventDefaultEffectMask(0) { }
|
||||
bool _Validate(SpellInfo const* entry) override;
|
||||
bool _Load(Spell* spell);
|
||||
void _InitHit();
|
||||
@@ -436,7 +438,7 @@ class TC_GAME_API SpellScript : public _SpellScript
|
||||
//
|
||||
// SpellScript interface
|
||||
//
|
||||
// example: void OnPrecast override { }
|
||||
// example: void OnPrecast() override { }
|
||||
virtual void OnPrecast() { }
|
||||
//
|
||||
// hooks to which you can attach your functions
|
||||
@@ -454,6 +456,9 @@ class TC_GAME_API SpellScript : public _SpellScript
|
||||
HookList<CheckCastHandler> OnCheckCast;
|
||||
#define SpellCheckCastFn(F) CheckCastHandlerFunction(&F)
|
||||
|
||||
// example: int32 CalcCastTime(int32 castTime) override { return 1500; }
|
||||
virtual int32 CalcCastTime(int32 castTime) { return castTime; }
|
||||
|
||||
// example: OnCalculateResistAbsorb += SpellOnResistAbsorbCalculateFn(class::function);
|
||||
// where function is void function(DamageInfo const& damageInfo, uint32& resistAmount, int32& absorbAmount)
|
||||
HookList<OnCalculateResistAbsorbHandler> OnCalculateResistAbsorb;
|
||||
|
||||
Reference in New Issue
Block a user