Modcraft - The community dedicated to quality WoW modding!

Legion- / WoD- / Mop- / Cata-Modding => Serverside Modding => Topic started by: Caedes on August 23, 2017, 04:28:00 pm

Title: Passive Spell Scripting
Post by: Caedes on August 23, 2017, 04:28:00 pm
Hey, I'm trying to script Twist of Fate on the 'newest' Trinity 6.2.4 core (took the last source before they merged legion into 6.x) and my hook doesn't seem to work.
Code: [Select]
class spell_pri_twist_of_fate_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_twist_of_fate_AuraScript);

bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_TWIST_OF_FATE))
return false;
return true;
}

bool CheckProc(ProcEventInfo& eventInfo)
{
sWorld->SendServerMessage(SERVER_MSG_STRING, "bool CheckProc got called.");
if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
if (eventInfo.GetActionTarget()->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellInfo, eventInfo.GetActor()))
sWorld->SendServerMessage(SERVER_MSG_STRING, "'If' returns true.");
return true;
sWorld->SendServerMessage(SERVER_MSG_STRING, "'If' returns false.");
return false;
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_pri_twist_of_fate_AuraScript::CheckProc);
}

The spell gets called by 109.142 (that's the Twist of Fate passive you get from choosing the talent) in the DB and I checked the number & script name a hundred times already. None of the server messages are sent when used and the passive procs the healing bonus whenever I heal without checking the health of my target (which is also how it works when I completely remove the script).

What I've tried to do to fix this:
- I've tried changing hooks (from DoCheckProc to OnEffectProc and others), but the script still doesn't get called. I've also made sure that the core doesn't 'unapply' the script on loading due to faulty dbc data by checking the server log output.
- There also don't seem to be any warnings while compiling.
Title: Re: Passive Spell Scripting
Post by: schlumpf on August 24, 2017, 01:11:39 am
No idea about why it isn't called, but note that C++ isn't python. Indentation ≠ a block.

Code: [Select]
if (x)
  a();
  b();

will execute b even if !x. Always use braces:

Code: [Select]
if (x)
{
  a();
  b();
}
Title: Re: Passive Spell Scripting
Post by: Caedes on August 24, 2017, 05:16:00 pm
Oh, thanks for the input!

I've fixed the problem. It was indeed a spelling error (but not where I thought it would be). /facepalm.