Jump to content

Getting a script to run a line only once per activation


Maniac3020

Recommended Posts

I'm trying to further modify SirMcDufus's Personal Shield Generator Mod http://fallout3.nexusmods.com/mods/8513/?tab=2&navtag=/ajax/modimages/?user=0|:|id=8513 for my own personal tastes. I want the shield raise my DR, instead of absorbing all damage. I'm almost there, I've got the DR working, and it no longer absorbs damage. However, there's one last detail I haven't been able to figure out. Since the mechanic for the shields taking damage is directly linked to my characters health points, I've encountered a bit of a problem. I'm pretty sure I've figured out what I need to do to get it to work the way I want, but I can't figure out how to do that.

 

If Active >= 1
	Set HBase to Player.GetAV Health
	Set HCurrent to Player.GetAV Health		
	If HCurrent < HBase
		Set Counter to HBase - HCurrent

 

I need a way to run the line Set HBase to Player.GetAV Health once, every time the shield is activated.

 

Here's the full Overlord script, as it stands now:

 

scn ZzShieldOverlordScript


Short Active
;-------Health-------
Short HBase
Short HCurrent
Short HHeal
Short HReset
;------Shields------
Short Counter
Short CounterMax
Short ShieldDisplay
Short ShieldDisplay2
Short Auto
;-Shield Regen-
Float Timer
Short Interval

Begin GameMode

If Player.GetItemCount ZzShieldModule > 0
Set CounterMax to ((Player.GetAV Science / 5) * (Player.GetAV Intelligence))
Else
Set CounterMax to ((Player.GetAV Science / 10) * (Player.GetAV Intelligence))
Endif
Set ShieldDisplay to (CounterMax - Counter)
Set ShieldDisplay2 to ((ShieldDisplay / CounterMax) * 100)

If Auto == 1
If Active < 1
	If ShieldDisplay2 >= 20
			Set Active to 1
	Endif
Endif
Endif

If Player.GetItemCount ZzShieldModule > 0
	If CounterMax < 20
		Set CounterMax to 20
	Endif
Else
	If CounterMax < 10
		Set CounterMax to 10
	Endif
Endif

If Active >= 1
	Set HBase to Player.GetPermAV Health
	Set HCurrent to Player.GetAV Health		
	If HCurrent < HBase
		Set Counter to HBase - HCurrent
		If (Counter / CounterMax) <= 0.5
			If Player.GetItemCount ZzShieldModule > 0
				Player.PMS ZzShieldHitShader21
			Else
				Player.PMS ZzShieldHitShader11
			Endif
		Elseif (Counter / CounterMax) <= 0.75
			Player.PMS ZzShieldHitShader12
		Elseif (Counter / CounterMax) <= 1
			Player.PMS ZzShieldHitShader13
		Endif
	Endif

	If Counter >= CounterMax
		Set Counter to CounterMax
		Set Active to -1
	Endif
Endif

If Active == -1
	Set Active to -2
Endif

If Active == -2
	Endif
Endif

End


;##############Shield Regenerates Quickly While Resting##############

Begin MenuMode

If IsTimePassing
	Set Counter to Counter - ((Player.GetAV Science / 25) * (Player.GetAV Intelligence))
Endif

End

;##############################################################


 

With the script as it is now, the shield is always damaged when my character isn't at full health, by how much I'm missing

Link to comment
Share on other sites

Nvm that, reread the post and realized I was off. However, if this is still useful to you or anyone.

 

You can use the FOSE function getGameRestarted. Put it in an If block and run whatever needs to be done inside that If.

if getGameRestarted == 0
   return
endif

Just replace the Return with whatever needs to be done once. Alternatively, put that block as is at the top of a script to make it only run once each time the game is restarted.

Link to comment
Share on other sites

No, no, no. I'm not going to be restarting the game every time I need to raise the shields, that would be a nightmare. That would be like restarting the game every time I need to use a stimpak.

 

Besides, I was just about to complete an edit asking for this thread to be deleted, since I realized a few minutes after posting it, that what I'm trying to do wouldn't work the way I want it anyway. (Basically, the title of the thread is wrong, I wanted to start a new thread, since I can't change the title)

 

What I really need is a way for the script to detect that my hp has gone down, and damage the shield accordingly, but not prevent the recharge script from "healing" it at the same time. Currently, my HP and Shield Points are directly linked.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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