Jump to content

Timer scripts


xchargerfanx

Recommended Posts

I'm kinda new to scripting and I'm trying to create a mod that uses the Call of Duty based health regeneration system. Basically, when I am shot, the game will wait about 5 seconds and I will be healed fully. However, if I get shot again while I am waiting to regenerate health, the timer resets immediately and I will have to wait another 5 seconds before I will start to heal. So far, I wrote a simple script that works somewhat, but the timer fails to reset if I get shot. Here it is:

 

scn CoDHealthRegenScript

 

float timer

 

begin GameMode

 

if player.GetAttacked == 1

set timer to timer + GetSecondsPassed

if timer > 5

player.addspell CoDHealthRegen ; <-- (defined as +15hp/sec)

endif

else

player.removespell CoDHealthRegen

endif

 

end

 

I believe the cause of the timer not resetting could also be due to the "GetAttacked" function. This seems to be the only function that is the most relative of what I intend to do, but the function literally means that when I am attacked, the function continues to stay 1 until I am out of combat. Therefore, the timer will not reset until I am out of combat, rather than getting hit by each individual shot. If anybody can offer advice as to how I can get this working, or some alternatives to scripting, it would be greatly appreciated.

Link to comment
Share on other sites

Yes - I think GetAttacked is ls limited that way. You may have better luck monitoring the player's health.

 

scn CoDHealthRegenScript

float timer
short iPlayerHealth
short iPlayerHealthPrevious
float fPlayerHealthPerc


begin GameMode


set iPlayerHealth to Player.GetAV Health
set fPlayerHealthPerc to Player.GetHealthPercentage

if (iPlayerHealth < iPlayerHealthPrevious)	;reset timer
	set timer to 0
	set iPlayerHealthPrevious to iPlayerHealth
	return
endif

set timer to timer + GetSecondsPassed

if timer > 5
	if (fPlayerHealthPerc < 1)
		if (player.IsSpellTarget CoDHealthRegen == 0)
			player.addspell CoDHealthRegen ; <-- (defined as +15hp/sec)
		endif
	else
		if (player.IsSpellTarget CoDHealthRegen == 1)
			player.removespell CoDHealthRegen
		endif
	endif
endif

set iPlayerHealthPrevious to iPlayerHealth

end	

Link to comment
Share on other sites

Alright thank you very much for your guys' input. I'll test this script out and see if I find any problems.

 

Cipscis you are correct - the script works much better than before, however the 5 second timer will only occur when my health reaches 100%, so it will not occur if I am damaged while my health is regenerating. I'll try to find a way to implement your suggestion into the script.

 

And on a side note, every time the "spell" comes into effect during gameplay, an annoying message comes up at the top left of the screen saying "added." I really don't want this message to pop up every time I regenerate health. Any ideas how to remove this notification from coming up?

Edited by xchargerfanx
Link to comment
Share on other sites

I got it to work!!! I'll be uploading the file on nexus very soon. Thank you guys so much for your help I really appreciate it; kudos to both of you and I'll make sure to give you guys credit in my mod for your help.

 

EDIT: The file is now up! Download it here and check it out!

http://fallout3nexus.com/downloads/file.php?id=16907

 

P.S. Still having issues with that annoying "added" message when the healing effect is activated :wallbash: if anyone has an idea on how to remove this, please reply as soon as you can. Thanks!

Edited by xchargerfanx
Link to comment
Share on other sites

P.S. Still having issues with that annoying "added" message when the healing effect is activated :wallbash: if anyone has an idea on how to remove this, please reply as soon as you can. Thanks!

FOSE has AddSpellNS, that doesn't generate the messages.

Link to comment
Share on other sites

...

 

P.S. Still having issues with that annoying "added" message when the healing effect is activated :wallbash: if anyone has an idea on how to remove this, please reply as soon as you can. Thanks!

 

Make your "Spell" an Actor Effect and use player.CastImmediateOnSelf to add it and player.Dispel to remove it. (Non-FOSE).

 

Checking off the Script Effect Always Applies, Disable Absorb/Reflect flags maybe optional, but I do think you will need to give it a very long Duration so it doesn't expire (and I mean ridiculously long - a 1000 days, for example).

 

That *should* work.

 

~Xeph'

Link to comment
Share on other sites

Make your "Spell" an Actor Effect and use player.CastImmediateOnSelf to add it and player.Dispel to remove it. (Non-FOSE).Checking off the Script Effect Always Applies, Disable Absorb/Reflect flags maybe optional, but I do think you will need to give it a very long Duration so it doesn't expire (and I mean ridiculously long - a 1000 days, for example).That *should* work.~Xeph'

 

This worked perfectly Xepha537, thanks a ton. I'll make sure to give you credit in my mod for correcting this issue.

 

iFSS, thanks for the tip; I had no idea FOSE offered a function like that. But for some reason, I can't get the FOSE editor to run with GECK, so I was not able to use this function unfortunately :sad:

Link to comment
Share on other sites

iFSS, thanks for the tip; I had no idea FOSE offered a function like that. But for some reason, I can't get the FOSE editor to run with GECK, so I was not able to use this function unfortunately :sad:

How are you trying to run that GECK with FOSE? The easiest way to do it is to create a shortcut to fose_loader.exe (which should be in the same directory as GECK.exe) and add " -editor" (without quotes, and not the space before the hyphen) to the end of the "target" field - after the closing quote around the location of the loader.

 

If that doesn't work, make sure you're using the latest versions of the GECK and FOSE. If it still won't work, then let me know what happens instead and I'll try to help you troubleshoot it.

 

Cipscis

Link to comment
Share on other sites

How are you trying to run that GECK with FOSE? The easiest way to do it is to create a shortcut to fose_loader.exe (which should be in the same directory as GECK.exe) and add " -editor" (without quotes, and not the space before the hyphen) to the end of the "target" field - after the closing quote around the location of the loader.If that doesn't work, make sure you're using the latest versions of the GECK and FOSE. If it still won't work, then let me know what happens instead and I'll try to help you troubleshoot it.Cipscis

I don't know why I wasn't able to get this to load before, but the way you explained it made it work first try lol. Thanks again Cipscis!

Edited by xchargerfanx
Link to comment
Share on other sites

  • Recently Browsing   0 members

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