Jump to content

Why is this script randomly crashing the game?


KiCHo666

Recommended Posts

Hello!

I'm working (well, more testing out the possibilities) on a mod that should make criticals more gory (like in FO1/2).

I had an idea to "simulate" burst critical by blowing left and right arm and head.

So this is the script:

 

scn BurstFireEffectScript

float Timer
short DoOnce

short LimbState

Begin ScriptEffectStart
	
	if (GetIsCreature == 0) || (GetCreatureType == 4) || (GetCreatureType == 5)
		if GetHitLocation == 0
			Set Timer To 0.4
			Set DoOnce To 1
			Set LimbState To 0
		endif
	endif

end

Begin ScriptEffectUpdate

    if DoOnce == 1

		if (Timer <= 0.3) && (LimbState == 0)
          	DismemberLimb 1 1	
			Set LimbState To 1

		elseif Timer <= 0.2 && (LimbState == 1)
           	DismemberLimb 3 1
			Set LimbState To 2

		elseif Timer <= 0.1 && (LimbState == 2)
          	DismemberLimb 5 1
			Set LimbState To 3

		elseif Timer <= 0 && (LimbState == 3)
         		Set DoOnce To 0
			
           	dispel BurstFireCrit

		else

		Set Timer To (Timer - ScriptEffectElapsedSeconds)

		Endif
	Endif

end

 



What it does is:

- when critical "On Death" occurs, it checks if the target is NPC, Super mutant or Ghoul

- Then it checks if the hit location is "Torso"

- Sets the timer to 0.4

- First it explodes the head after 0.1 second

 

- Explodes the left arm after 0.2 seconds

 

- Explodes the right arm after 0.3 seconds

 

- At 0.4 seconds, it removes the spell because Actor Effect was set not to dispel after death, so I have to remove it manually.


Now the problem, it randomly crashes the game if that critical effect occurs.
Sometimes it might crash after just killing one enemy, sometimes it won't crash if I kill 4 enemies, but will crash on 5th, etc, etc....

Tried putting the code in GameMode instead, but same thing happens.

Help would be appreciated.


Thanks in advance!

Link to comment
Share on other sites

A "crash" is usually the result of attempting to do something the engine is not prepared to cope with, and has no idea how to handle. What happens if you attempt to "dismember" a limb that has already be "dismembered"? Your code is assuming each of those limbs still is attached.

 

-Dubious-

Link to comment
Share on other sites

That's why I used LimbState to make sure the same limbs don't get dismembered. Besides, if the script it wrong, then it should crash always, not sometimes.

I managed to fix the crashing. I think the problem is with JIP's DismemberLimb function flag that makes the limb explode instead of dismembering. I used vanilla KillActor for that.

Link to comment
Share on other sites

Probably unrelated to your crash, but a dispel often doesn't take effect from the very moment you call it. There's also a risk that the spell will stick on any creature for which the code doesn't apply (depending on what type of duration you've set on the actor effect ofc).

If I were you, I'd add

else
  set DoOnce to 2
endif

at the end of your ScriptEffectStart block

 

and

if DoOnce == 2
  dispel BurstFireCrit
  return
endif

at the top of your ScriptEffectUpdate block.

And remove the dispel line you have, and change the one above to "set doonce to 2".

 

That's just a good-practice trick for scripted spells to keep in mind for the future.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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