This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: Passive Spell Scripting  (Read 2355 times)

Caedes

  • Registred Member
  • MS Paint Freak
  • *****
  • Posts: 4
    • View Profile
Passive Spell Scripting
« 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.
« Last Edit: August 23, 2017, 09:15:29 pm by Caedes »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: Passive Spell Scripting
« Reply #1 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();
}

Caedes

  • Registred Member
  • MS Paint Freak
  • *****
  • Posts: 4
    • View Profile
Re: Passive Spell Scripting
« Reply #2 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.