Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Broken OnMagicEffectHit?


ZuTheSkunk
 Share

Recommended Posts

I just encountered a most bizarre problem.
 
In short, I wanted to make an activator that, when hit with a specific spell, moves the player to its parent XMarkerHeading. But for some reason, the game ends up putting the player in an endless loop where he's constantly moved to the XMarkerHeading. Casting other spells at the activator does nothing, and neither does adding a DoOnce condition.
 
Help, please?
 
scriptname ZUDoTUsageBlockPurpleSCRIPT

ref MyParent
ref MySelf

Begin OnMagicEffectHit WKNW

	set MyParent to GetParentREF
	set MySelf to GetSelf
	player.moveto MyParent
	playsound SPLAlterationCast		
	player.pms ZUDoTEffectPurple
	MySelf.pms ZUDoTEffectPurple

End
Edited by ZuTheSkunk
Link to comment
Share on other sites

I think I might be able to help here, although my experience relates to the OnTrigger block. I had a problem just about like this and found that it was not an engine bug, but rather an engine quirk. I suspect strongly that Bethesda's internals for OnTrigger may be the same as for On....  other things. :-)

 

In my case, the symptom was that I had a dungeon cell that worked perfectly for months. Then, suddenly, I would hang the game every time I did a "coc" to that cell for testing. If I walked into it normally, no problem. Finally I found the issue. There is a trigger zone in the cell that looks for a particular creature which is supposed to never enter a certain area, and usually doesn't. But because of some Havok weirdness, occasionally the creature passes through a solid obstacle and gets into that area anyway. No problem....trigger zone, detect that actor, move them to an XMarker outside the forbidden area.

 

It turns out that if you have a MoveTo of an actor within an OnTrigger block, the MoveTo works as planned but the trigger detection does not stop until the *next* frame after the move. The Havok bug doesn't happen during normal gameplay; it only seems to occur during the cell loading process when it is settling mobile objects. So if the creature was in the forbidden zone exactly when I "coc" into the cell....zap! Hung game!

 

I beat my head against this for hours, then stumbled upon the note at the bottom of the OnTrigger wiki page. May the Divines bless whoever posted that little note!

 

Solution: Don't do the MoveTo of an actor directly in the detection block. Instead, set a variable in your object script from zero to one during the hit detection. Then do the MoveTo from the GameMode block, and clear the variable to zero when you do the move. IMPORTANT: Make sure the OnGame block is *before* the OnMagicEffectHit block in your code, so the OnGame code will interpret on the *next* frame.

 

No guarantees this is the problem, but coders tend to reuse logic once it's tested, and I think there's a good chance Bethesda did that here. Hope this helps!

Link to comment
Share on other sites

Your find is very interesting and will certainly come in handy in the future, but alas, it did nothing to fix the issue. I tried moving the player.moveto part (and everything related) to a GameMode block before the OnMagicEffectHit, but the result was still the same: an endless loop of being constantly moved to the XMarkerHeading. Then I tried something crazier: getting rid of player.moveto from the activator's script entirely and moving it over to a quest script. All it accomplished was making it so that my character is moved every five seconds, rather than every millisecond.

 

My guess is that the hit detection is glitched and the activator, when hit once, gets permanently stuck with the magic effect applied to it, which forces the OnMagicEffectHit block to run endlessly. But the truly bizarre part is that, if this really was the case, then in addition to being moved, I would also hear a neverending wave of the sound effect I included being played over and over again - but that doesn't happen. The game seems to freak out solely on the player.moveto part, while everything else goes perfectly fine.

 

EDIT: I ultimately managed to bypass the problem entirely by simply removing any scripts from the activators and adding a scripted effect to the staff which checks whether the object hit is the ID of the activator. Why didn't I do this sooner?

Edited by ZuTheSkunk
Link to comment
Share on other sites

It is kind of well known (I hope) that using MoveTo prevents any further script from running in that frame. My theory is that MoveTo is bugged and, somehow, silently crashes the script execution part of the engine, without cleaning up whatever has to be cleaned. 

 

The next frame the engine, somehow, detects the failure and attempts to re-execute the same script again.

 

This is my theory and it fits what you describe and my previous experience with MoveTo. It has nothing to do, particularly,  with the TriggerBoxes or On<whatever>.

 

If you use Player.MoveTo from a token in the player inventory, the effect is the same: loop!

If you use Player.MoveTo from an item that is moved with the player, the effect is the same: loop!

 

But (if memory serves), if you use Player.MoveTo from an item that stays behind, it works, because the next frame, the item is 'out-of-scope', so its script does not get executed anymore.

 

The solution is what  syscrusher mentioned: use a variable to make sure MoveTo does not run in two consecutive frames.

 

 

 

 
 

 

 

Link to comment
Share on other sites

I didn't attempt to use the OnMagicEffectHit thing again, since I already figured out an easier solution... but I did a very similar thing with a OnTrigger using a trigger zone, and after making sure to follow your suggestions, it works flawlessly now. Thank you very much!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...