Skip to content

Add visual effects to player on item use

Still very new at this, but I'm making a stone of recall following this guide (https://nwnlexicon.com/index.php?title=Grimlar_-_Guide_To_The_Stone_Of_Recall)

I got everything working and was even able to figure out how to add a 10 sec delay (yay me!)

I'm looking at adding a visual effect. When the item is activated I want to add a aura to the user after 5 sec, that lasts for 5 sec.

The error I'm getting is nw_it_recall.nss(40): ERROR: INCORRECT VARIABLE STATE LEFT ON STACK

#include "x2_inc_switches"
#include "nw_i0_plot"
void StoneOfRecall()
{
int nEvent =GetUserDefinedItemEventNumber();

// * This code runs when the Unique Power property of the item is used
// * Note that this event fires PCs only
if (nEvent == X2_ITEM_EVENT_ACTIVATE)
{
//IsRecall is defined in nw_i0_plot
IsRecall();
}
}

void main()
{
DelayCommand(10.0, StoneOfRecall());

//Status messages and Visual effects
int nEvent =GetUserDefinedItemEventNumber();

// * This code runs when the Unique Power property of the item is used
// * Note that this event fires PCs only
if (nEvent == X2_ITEM_EVENT_ACTIVATE)

//Apply Visual effect to PC after 5 sec
effect eEffect = EffectVisualEffect(VFX_DUR_AURA_PULSE_CYAN_WHITE);
location lPC = GetLocation(GetItemActivator());
DelayCommand(5.0, ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eEffect, lPC, 5.0));

//Display countdown messages in Combat log
SendMessageToPC(GetItemActivator(), "The Stone of Recall glows softly as it begins charging (10s left)");
DelayCommand(2.0, SendMessageToPC(GetItemActivator(), "The Stone of Recall continues to glow as it charges(8)"));
DelayCommand(4.0, SendMessageToPC(GetItemActivator(), "The Stone of Recall continues to glow as it charges (6)"));
DelayCommand(6.0, SendMessageToPC(GetItemActivator(), "The Stone of Recall glows Brighter (4)"));
DelayCommand(8.0, SendMessageToPC(GetItemActivator(), "The Stone of Recall glows Brighter (2)"));
DelayCommand(9.5, SendMessageToPC(GetItemActivator(), "The Stone of Recall flashes brilliantly!"));

}

Comments

  • PaphjortPaphjort Member Posts: 25
    Hi NyteLock
    With VFX_DUR_AURA_PULSE_CYAN_WHITE I think you need to ApplyEffectToObject instead of location. (at work, so can't check it right now)
    You can see the effects here: https://nwnlexicon.com/index.php?title=Vfx_dur
  • NytelockNytelock Member Posts: 23
    Thanks, that was it
  • meaglynmeaglyn Member Posts: 151
    Good stuff. A couple of points that might help you:

    That delay is not going to work long term. By the time it runs there is no guarantee the last item event is ACTIVATE.
    Might consider putting that delay inside the block discussed below and taking out the nEvent check in the StoneOfRecall function.

    Also the if (nEvent == X2_ITEM_EVENT_ACTIVATE) in main should be followed by { and an another closing } at the end.

    Fwiw,
    meaglyn
Sign In or Register to comment.