OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Nobby on 14 Jun 2003, 19:18:50

Title: Self-healing power
Post by: Nobby on 14 Jun 2003, 19:18:50
Is there any way to script a healing process that recovers a soldiers health gradually?

e.g

?(getdammage player > 0.5)

player setdammage minus 0.1

player setdammge minus 0.1

etc

Cheers.

Nobby
Title: Re:Mutant healing power
Post by: dmakatra on 14 Jun 2003, 19:57:32
If noon else check this out IÂ'll help u out. Right now IÂ've alt-tabbed out of a CTI game 8) ;D
Title: Re:Mutant healing power
Post by: Nobby on 14 Jun 2003, 20:01:37
Cheers mate.

So far all I've got is a trigger in game which is simply

?(getdammage player > 0.5)
player setdammage 0

However, I find with this is that if you die then you come back to life instantaneously, which dont look good.

I don't know of any way to gradually increase your health. How bout you?
Title: Re:Mutant healing power
Post by: deaddog on 14 Jun 2003, 20:16:45
One way is to have a simple script running:

;recover.sqs

_u=_this select 0

#loop
~15
_d=getdammage _u
?_d>0.1:_u setdammage (_d-0.1)
goto "loop"

By having this running all the time, the unit's health will gradually increase.  Change the 15 second delay to whatever you find suitable.

In the init line of the unit type:
[this] exec "recover.sqs"

Hope that answers your question.  :)
Title: Re:Mutant healing power
Post by: Nobby on 14 Jun 2003, 21:08:32
just tried it and it don't work.
I appreciate the help though mate.
Cheers
Title: Re:Mutant healing power
Post by: Gameer_77 on 14 Jun 2003, 21:15:48
You probably don't notice it - change the '~15' to '~1'.

Gameer
Title: Re:Mutant healing power
Post by: deaddog on 14 Jun 2003, 21:24:11
I just tried it and it works perfectly.  Insert this line after the delay so you can see it working:

player sidechat format ["%1",getdammage _u]

As is, this script won't take the damage all the way to zero, just somewhere under 0.1.  
Title: Re:Mutant healing power
Post by: Shaggy on 14 Jun 2003, 23:56:09
Yes the perfect thing that i was looking for. I wanted my players not to die until a certain point in the game. Is there a way i can get them to be more or less "GODMODE" until a certain point in the game..then they're vunerable. Because my character are playing a certain role in my game i am creating.
Title: Re:Mutant healing power
Post by: dmakatra on 14 Jun 2003, 23:58:16
Yes the perfect thing that i was looking for. I wanted my players not to die until a certain point in the game. Is there a way i can get them to be more or less "GODMODE" until a certain point in the game..then they're vunerable. Because my character are playing a certain role in my game i am creating.

just setcaptive him instead.
Title: Re:Mutant healing power
Post by: Shaggy on 15 Jun 2003, 00:00:34
Jesus man that was a quick reply :) Thanks

:cheers:
Title: Re:Self-healing power
Post by: Nobby on 15 Jun 2003, 12:38:35
the script does heal the player, however, after the player dies he stays standing and displays his posistion and keeps sending orders, even though your dead.
I've tried combatting this with:

?alive _u
goto "loop"

?not alive _u
goto "end"

 #loop
~1
_d=getdammage _u
?_d>0.1:_u setdammage (_d-0.1)
goto "loop"

#end
exit

and this doesn't wanna work.
Please help.
Title: Re:Self-healing power
Post by: deaddog on 15 Jun 2003, 14:08:10
Ahhh,  I didn't think of when the unit dies.

Ok, Make the whole script like this:

Quote
#loop
~1
?!alive _u:exit
_d=getdammage _u
?_d>0.1 and alive _u:_u setdammage (_d-0.1)
goto "loop"

Hopefully that should do the trick   :)

PS. The reason your additions don't work is because they only occur when the script is first run.  The two "if" statements are not inside the loop so they never get looked at again.
Title: Re:Self-healing power
Post by: Nobby on 15 Jun 2003, 17:28:59
Much better mate cheers. Although, 1 outta 20 times the undead thing happens.

Also, I was wondering if the setdammage 0.1 could be any smoother?
Gradually building up health etc.

Do you reckon this is possible?

Cheers
Title: Re:Self-healing power
Post by: dmakatra on 15 Jun 2003, 17:35:21
Yea, u can change da ~1 line to perhaps ~0.1 and then just setdammage minus 0.01 everytime. Like this:

Code: [Select]
#loop
~0.1
?!alive _u:exit
_d=getdammage _u
?_d>0.1 and alive _u:_u setdammage (_d-0.01)
goto "loop"

EDIT: Just remember that the faster loops u make, the more CPU u need. So dont make it ~0.0000000000000000000000000000001 OK? ;D
Title: Re:Self-healing power
Post by: deaddog on 15 Jun 2003, 18:30:04
I don't know why the undead thing happens.

I put the "and alive _u" part in there to prevent that.  
 :hmm:
Title: Re:Self-healing power
Post by: LCD on 15 Jun 2003, 18:35:09
u cn make it function so it wil faster onh checkin n all ;D

LCD OUT
Title: Re:Self-healing power
Post by: Nobby on 16 Jun 2003, 12:29:50
the undead thing still happens, I don't get it.
I tried adding a

?not alive _u: goto "end"

#end
_u setdammage 1
exit

but that had no effect.
I also tried adding a playmove "combatdead"
but that didn't work.

This is really starting to bug me now.
Title: Re:Self-healing power
Post by: dmakatra on 16 Jun 2003, 14:13:35
Does this really doesnÂ't work? Are u sure? IÂ've tried it like 50 times now and it always works!

Are u sure u got the right code?

Code: [Select]
_u = _this select 0

#loop
~0.1
?!alive _u: goto exit
_d=getdammage _u
?_d>0.1 and alive _u:_u setdammage (_d-0.01)
goto "loop"

#exit

exit
Title: Re:Self-healing power
Post by: deaddog on 16 Jun 2003, 14:23:02
If your mission.sqm is under 50K then attach it to a reply.  We might be able to figure it out if we can play the mission.  Better yet, export the mission as a single user mission and post the pbo file. That will give us all the scripts, too.

Thanks.
Title: Re:Self-healing power
Post by: Nobby on 17 Jun 2003, 13:14:40
I'll give this script a try now and then get back to you in a minute.
Cheers Guys

Nobby
Title: Re:Self-healing power
Post by: Nobby on 17 Jun 2003, 13:24:24
just tried it and... it's still a no go.
The first and second attempts went fine but on the third attempt he died and then magically got back up again, although I was still dead.

The .pbo file is huge, 4,921KB. So I don't know if you want me to post it, however, the glitch may occur in the units. I am using the invasion 1944 guys and they may have something in their .cpp files which stops them from quickly healing, but I don't know this for certain.

I'll keep on fiddling around with the script until I come to the conclusion.

Cheers

Nobby
Title: Re:Self-healing power
Post by: Nobby on 17 Jun 2003, 17:13:09
just found out the problem, I had an old trigger in the game which I forgot about which setdammage to 0 if damage went above 0.5, the deletion of this meant the script worked a treat.
Thanks again.

Nobby.

PS, If you wanna try out my mission then just ask, you do need the invasion 1944 demo and Flak 36 from WW2EC though.