It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
I have a script for a custom passive feat. It is supposed to start passive regeneration of 1 hit point every 18 seconds. However instead of healing one hit point every 18 seconds it heals the 1st hit point after 18 seconds and then the next one second later. Then it waits another 18 seconds for the next and 1 second for the next. Here is a copy of the script:

void main()
{
object oPC = GetLastPCRested();
object oTarget = OBJECT_SELF;
int iSWhisp = GetLevelByClass(64, OBJECT_SELF);
int iSWarr = GetLevelByClass(67,OBJECT_SELF);
int iCaster = iSWhisp+iSWarr;
int iBonus;
float fDur = 18.0f;

if (iCaster >=14)
{
iBonus = 2;
}
else
{
iBonus = 1;
}

effect eEff = EffectRegenerate(iBonus, fDur);
effect eEff1 = EffectImmunity(IMMUNITY_TYPE_FEAR);
effect eEffect1 = EffectLinkEffects(eEff,eEff1);

if (iCaster >= 7)
{
eEffect1 = SupernaturalEffect(eEffect1);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect1, oTarget, HoursToSeconds(72));
SetEffectSpellId(eEffect1, 71639);
return;
}
else
{
eEff1 = SupernaturalEffect(eEff1);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEff1, oTarget, HoursToSeconds(72));
SetEffectSpellId(eEff1, 71639);
return;
}
}

Can anyone tell me why it is behaving like this and how I can get it to heal only once every 18 seconds?

Thank you in advance.
No posts in this topic were marked as the solution yet. If you can help, add your reply
It's a while since i scripted for this game, however for something like this o would suggest to use "Extraordinary Effect" command (check out the script about correct syntax), with a permanent effect application

With extraordinary effect your "spell" would not be dispelled and only rest will remove it, simply recast it once after resting, many native ability in NWN work the same way

You could optimize the script by using the object_self call only once while getting the "caster" and reuse that instead of recalling object_self every time

Why the return command? Let the script end properly and conclude on it's own in this case

No need to use regeneration either as it's function are harcoded in the engine, just use a delayed healing effect of 3 turns to apply your healing, the script will just "cast" a delay of 3 turns every 3 turns to heal of the specified quantity, you could also use a recursive effect, i think melf acid arrow is a good example of it

Sorry can't help more, too long since made a script for this game, if i remember more I'll see to it
Sounds like you might be calling it twice. How are you triggering this script? Regenerate effects stack.
avatar
MagicalMaster: Sounds like you might be calling it twice. How are you triggering this script? Regenerate effects stack.
I am having the effects removed and the script fired again every time the character rests.
avatar
DClark101: -snip-
just some advice
nothing against gog but best place to get advice would be vault where most people still doing development for game hang

https://neverwintervault.org/forums/neverwinter-nights-1/nwn1-scripting

other common place for development help can be found on nwnx forums

http://nwnx.org/phpBB2/

Covering everything from asm/cpp plugins to scripting and databases.

This is just more general information place on gog.
Post edited December 04, 2016 by Regals
avatar
DClark101: I am having the effects removed and the script fired again every time the character rests.
Do me a favor and add in a command to make the person receiving the effect say "I GOT THE REGEN EFFECT" or something. See if he says it once or twice.

(Let me know if you need help figuring that out)
Post edited December 04, 2016 by MagicalMaster
avatar
DClark101: -snip-
avatar
Regals: just some advice
nothing against gog but best place to get advice would be vault where most people still doing development for game hang

https://neverwintervault.org/forums/neverwinter-nights-1/nwn1-scripting

other common place for development help can be found on nwnx forums

http://nwnx.org/phpBB2/

Covering everything from asm/cpp plugins to scripting and databases.

This is just more general information place on gog.
Thanks, I have not been able to find script help since Bioware took down their website.
avatar
DClark101: I am having the effects removed and the script fired again every time the character rests.
avatar
MagicalMaster: Do me a favor and add in a command to make the person receiving the effect say "I GOT THE REGEN EFFECT" or something. See if he says it once or twice.

(Let me know if you need help figuring that out)
It seems to be firing only once on rest but it also seems to fire again when the character transitions from one area to another.
How exactly are you calling this script in the first place? What other script(s) is firing it?
avatar
MagicalMaster: How exactly are you calling this script in the first place? What other script(s) is firing it?
It is a passive feat script that fires when the character rests.
Post the rest script(s), please.
avatar
MagicalMaster: Post the rest script(s), please.
#include "nw_i0_spells"
void main()
{
object oPC = GetLastPCRested();
object oTarget = OBJECT_SELF;
switch (GetLastRestEventType())
{
case REST_EVENTTYPE_REST_STARTED:
break;

case REST_EVENTTYPE_REST_CANCELLED:
break;

case REST_EVENTTYPE_REST_FINISHED:
if(GetHasFeat(2807, oTarget))
{
RemoveEffectsFromSpell(oTarget, 71639);
ExecuteScript("spirit_broken", oTarget);
}
break;
}
I got this working now thanks to some help from Neverwintervault.org forums.