Jump to content

Need some help debugging some scripts. Any help useful


Recommended Posts

Hey I'm working on an idea for a new Medic Power Armor idea. The part of the script I'm having trouble with is this part:

 

If Player.GetHealthPercentage <= 0.25

 

set injured to 1

 

endif

 

If Injured == 1 && timer == 0

 

player.additem ZStimpak 1 1

player.equipitem ZStimpak 0 1

 

set timer to (timer + GetSecondsPassed)

 

endif

 

if timer >= 20 && injured == 1

 

set timer to 0

 

endif

 

If player.gethealthpercentage > 0.25 && equipped == 1

 

set injured to 0

 

endif

 

This should, when your health is at or bellow 25%, inject you with a stimpak once every 20 seconds, however not informing you that it did. However, it keeps infinitely making the sound of the injection of the stimpak, causing the game to run incredibly slowly and laggy. What shoulld I fix?

 

 

 

The second one is quite simple, but a very odd result:

 

scn ZPsychoRemoteScript

 

Begin ScriptEffectStart

 

player.additem ZPsycho 1 1

player.equipitem ZPsycho 0 1

player.additem ZPsychoRemote 1 1

showmessage ZPsychoMessage

 

End

 

This simply re-adds the Psycho Injector into your inventory after using, while applying the normal effects of Psycho. However, for some reason, upon using it, the entire game exits out, without even informing me that something went wrong, or that it stopepd responding. WTF is up with this one too???

Link to comment
Share on other sites

If Player.GetHealthPercentage <= 0.25
set injured to 1
else
set injured to 0
endif

if timer <= 0
If Injured == 1
	player.additem ZStimpak 1 1
	player.equipitem ZStimpak 0 1
	set timer to 20
endif
else
set timer to (timer - GetSecondsPassed)
endif

 

Not sure about your second problem. The script looks ok to me.

Link to comment
Share on other sites

Hey I looked over your script, and it worked just fine, except the sound file still exists. I think I have a solution:

Every day, it will supply you with a counter that allows you to only use 10 stims a day. So like every 24 hours, you can use 10 stims. Here's what it looks like:

 

If Player.GetHealthPercentage <= 0.25

set injured to 1

set day to GetDayofWeek

else

set injured to 0

endif

 

if timer <= 0

If Injured == 1 && StimSupply >= 0

 

player.additem ZStimpak 1 1

player.equipitem ZStimpak 0 1

set timer to 20

set StimSupply to (StimSupply - 1)

endif

else

set timer to (timer - GetSecondsPassed)

endif

 

if Day != GetDayofWeek

 

set StimSupply to 10

 

endif

 

Does this look alright?

Link to comment
Share on other sites

I don't know why the stimpak sound would be repeating - but health gain doesn't? Maybe a bug. Try equipping without the 0 1 flags. Is ZStimpak an exact copy of StimPak? Maybe a workaround would be to use cios and playsound.

You can use two variables CurrentDay and PreviousDay to track when a day has changed.

 

set Currentday to GetDayofWeek

If Player.GetHealthPercentage <= 0.25
set injured to 1
else
set injured to 0
endif

if timer <= 0
If Injured == 1 && StimSupply >= 0
	player.cios ZStimpak
	player.PlaySound NPCHumanUsingStimpak
	set timer to 20
	set StimSupply to (StimSupply - 1)
endif
else
set timer to (timer - GetSecondsPassed)
endif

if PreviousDay != CurrentDay
set StimSupply to 10
set PreviousDay to CurrentDay
endif 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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