I am trying to use heartlib to modify my bleedout script to trigger every 30s rather than every heartbeat which is obviously quite rapid. However, the heartbeat doesn’t seem to be being created properly when I have the player downed. How would I go about using heartlib in this way? I am almost assuredly doing it wrong, but the documentation is pretty thin.
i’m not at all familiar with heartlib (assuming it’s this one by nwshacker?), but if it simply manages the routing and you still have to write the handlers, it shouldn’t be too difficult. since you want the pc to bleed once every 30s and the game heartbeat occurs once every 6s, you want to ignore all but every 5th heartbeat. one way to do that is with the modulo operator. instead of taking a hp from the pc every heartbeat, you could do something along these lines :
int blood = GetLocalInt(pc, "bleeding") % 5; // every 5th hb
SetLocalInt(pc, "bleeding", blood + 1);
if (blood == 0)
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(1), pc);
(don’t forget to delete the local int if the pc stops bleeding out or, alternatively, delete it in your on-dying script the very first time it’s called.)
another (cleaner) alternative is to just process your own on-dying event and not go through the heartlib manager. then you don’t have to muck about w/temporary variables at all ; just call your on-dying routine recursively once every 30s using DelayCommand()
.
having said all that, although i haven’t seen him lately, nwshacker used to be quite active here, so sending a direct message might get you better results !
I figured out the issue is that when you create a function, the function it’s looking for is the name of a nwn script with a void main()
So for instance, having toud_bleedout
and then within void main(object oPC) { stuff }
I had incorrectly assumed from the nomenclature you could use a function, so I was trying to make it use a function called toud_bleedout, like
void toud_bleedout(object oPC) { stuff }
The nomenclature was a stumbling block but I got it figured out!
glad to hear you got it worked out.
1 Like