Hi marcus3
Try this -
; hunger.sqs
; Set starting energy and rations on hand
energy = 100
rations = 3
; start loop
#loop
energy = energy - 1
; display messages as jason slowly starves
? energy == 40 : jason sidechat "Maybe we should stop for a bite."
? energy == 20 : jason sidechat "I'm hungry !"
? energy == 10 : jason sidechat "Seriously, I'm REALLY hungry !!"
? energy == 0 : jason sidechat "I'm STARVING !!"
? energy < 0 : jason sidechat "so . . . hungry . . . "
? energy < 0 : jason setDammage ((getDammage jason) + 0.05)
~10
goto "loop"
The loop is pretty slow so it should have almost no effect on lag.
Note that once jason's energy goes below 0 he will display his hunger message every cycle of the loop, not just once. He will also start to take damage until after about 3 minutes he dies from hunger. Of course you can change these values to suit your mission.
Now to add to this all you have to do is give him the addAction
jason addAction ["Eat rations", "eatRations.sqs"]
and make up the script eatRations.sqs as follows -
; eatRations.sqs
? rations < 1 : jason sidechat "You're out of food !", exit
rations = rations - 1
energy = energy + 50
Note that the script hunger.sqs starts jason with 3 rations, again feel free to change this to suit your mission.
Finally, if you REALLY want to have some fun put the following addaction on some sort of object on the map -
this addAction ["Take Rations", "takeRations.sqs"]
; takeRations.sqs
rations = rations + 3
this removeAction 0
This should give jason three more rations and remove the addAction from the assigned object. If you want more rations, again, just edit the script acordingly.
Hope this is of use !
roni