OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Mr.T on 15 May 2003, 06:56:01

Title: making units indestructible
Post by: Mr.T on 15 May 2003, 06:56:01
I was wondering if anyone can tell me how to make stock OFP objects such as Player units and vehicles indestructible.

This is for a multiplayer map im making. Is there a line of code that i should include in the objects Init field?


Thanks,


Mr.T
Title: Re:making units indestructible
Post by: O Neil on 15 May 2003, 07:38:57
Hey

I was just gonna ask this, as in, don't you type :

                           Alive Unitname
In the condition feild ?

If so, are you SURE it works ?

O Neil ;)
Title: Re:making units indestructible
Post by: Mr.T on 15 May 2003, 07:51:20
Hey

I was just gonna ask this, as in, don't you type :

                           Alive Unitname
In the condition feild ?

If so, are you SURE it works ?

O Neil ;)


I think that just returnes wether or not that unit is alive... it doesnt make them stay alive....


 not sure
Title: Re:making units indestructible
Post by: O Neil on 15 May 2003, 08:58:00
Oh, yea I had a feeling...

O Neil ;)
Title: Re:making units indestructible
Post by: Knut Erik on 15 May 2003, 09:45:48
You could create a script...

_object = _this select 0

#Alive
@getdammage _object < 0.25
_object setdammage 0
~0.01
?!alive _object : goto "end"
goto "alive"

#end
exit


Not sure about the syntax, but at least you'll se where I'm going..
Title: Re:making units indestructible
Post by: LCD on 15 May 2003, 10:18:56
put in its init

this addeventhandler ["hit","this setdammage 0"]; this addeventhandler ["killed","this setdammage 0"]

LCD OUT
Title: Re:making units indestructible
Post by: toadlife on 15 May 2003, 22:03:11
None of these will reliably work becuase when a unit is killed the AI of the unit is completely disbaled, even if you bring it back to life.  :-[

A script that constantly sets a units damage to 0, won't save anyone from a bullet to the head.

A script such as knut erics's is the best way to make units really tough...not indestructable but tough.

I'd make the script like this:

Code: [Select]
#Alive
_object setdammage 0
~0.01
?!alive _object :exit
goto "alive"
Title: Re:making units indestructible
Post by: Tomb on 15 May 2003, 22:38:30
the engine can take faster loops then that, toadster mate, like:

~0.00000001

 or even worse.... it's up to yer CPU/RAM  :)

'course, in MP one should prolly keep the slowest PC in mind...



PS - most machines should be able to eat a delay of some ~0.0001
 :-*



Title: Re:making units indestructible
Post by: Mr.T on 16 May 2003, 02:02:48
None of these will reliably work becuase when a unit is killed the AI of the unit is completely disbaled, even if you bring it back to life.  :-[

A script that constantly sets a units damage to 0, won't save anyone from a bullet to the head.

A script such as knut erics's is the best way to make units really tough...not indestructable but tough.

I'd make the script like this:

Code: [Select]
#Alive
_object setdammage 0
~0.01
?!alive _object :exit
goto "alive"

Sorry guys im a bit of a n00b at this. Toadlife where would i incude this code int the ext or a sqs file? Can i put it in the units Init field?

Thanks for the input so far.

Much appreciated,

Mr.T


Title: Re:making units indestructible
Post by: toadlife on 16 May 2003, 02:09:39
ok save this script as "toughguy.sqs", and put it iny our missions folder.

Code: [Select]
#loop
_this setdammage 0
~0.01
?!alive _this:_this setdammage 1;exit
goto "loop"

For every unit that you want to make tough, put: this exec "toughguy.sqs" in their init feild.
Title: Re:making units indestructible
Post by: Mr.T on 16 May 2003, 05:16:54
Excellent Thanks a bunch!


Finally i might be able to get my map to work.
Title: Re:making units indestructible
Post by: dmakatra on 16 May 2003, 08:19:12
no "[]"?

And Mr T. Are ya da same guy as Mr T at the swedish PCG forum?
Title: Re:making units indestructible
Post by: toadlife on 16 May 2003, 11:01:32
no "[]"?

No you don't have to pass an array to a script. If you are just passing one variable to a script, why put it inside of an array?

"_this" is the variable that you pass to a script...it can be an array which contains multiple variables, or just a single variable. In the exmaple I posted above, there was only one variable that needed to be passed to the script so there was no need for me to put it inside an array. It saves keystrokes. :)
Title: Re:making units indestructible
Post by: LCD on 16 May 2003, 12:56:54
@ toady - i saw somwere dat da eventhandlers work b4 da game itself react2 da death ;) worth checkin isnt it ? ;)

LCD OUT