Jump to content

SetGhost and Spell Effects


Brianide

Recommended Posts

I'm not new to modding or programming in general, but I am new to Papyrus. I've been working on a fairly simple mod that would introduce two werewolf perks: one that makes the player immune to damage while transforming, and another that causes the player (in human form) to automatically transform when his health reaches zero, once per day. I believe I have the latter mostly working, aside from some caveats that need to be addressed. I'm running into some frustrations with the damage immunity perk, though.

 

I don't want to modify the WerewolfChangeEffect script at all, so I'm currently running a ReferenceAlias script on the player that reacts when WerewolfChangeEffect is applied:

 

event onMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect)
if(akEffect == WerewolfEffect)
	getActorReference().setGhost(true)
endif
endEvent

event onRaceSwitchComplete()
Actor player = Game.getPlayer()
if(player.getRace() == WerewolfRace)
	player.setGhost(false)
endif
endEvent

 

The problem is, the onMagicEffectApply block triggers before the effect is actually applied, which means that setGhost prevents the effect from actually being applied. That's what appears to be happening, at least.

 

I suppose I could throw in a Utility.wait(0.5) before setGhost, but that seems a bit hacky and unreliable on slow hardware. Is there a different and/or better way to go about this that is immediately apparent to anyone?

Edited by Brianide
Link to comment
Share on other sites

I'd say go for wait(0.5). If Wait() is implemented the way I think it is, simply divide 1.0 with your FPS to find out the maximum difference in actual wait time. With 20 fps, the wait time reaches 0.55. Really, using wait doesn't hurt as much as you think it does.
Link to comment
Share on other sites

I'd say go for wait(0.5). If Wait() is implemented the way I think it is, simply divide 1.0 with your FPS to find out the maximum difference in actual wait time. With 20 fps, the wait time reaches 0.55. Really, using wait doesn't hurt as much as you think it does.

In all honesty you're right, it probably would work fine, but I had some bad experiences with GetSecondsPassed in Fallout 3 (namely, hiccups in the framerate causing time-sensitive bits of the script to get skipped over), so I'd just prefer to stay out of the practice of relying on realtime wait functions wherever possible.

 

I managed to fix the problem, anyway. Rather that waiting for the WerewolfChange effect, I simply changed it to wait for WerewolfChangeFX (which is a second spell that actually handles the transformation animation; SetGhost was blocking it). The OnMagicEffectApply block does appear to run after the effect itself is applied. Good to know, I guess.

Edited by Brianide
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...