OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Cooba on 03 Feb 2004, 15:28:02

Title: respawn nearest object
Post by: Cooba on 03 Feb 2004, 15:28:02
I need one building (which is normally a static map object on map) to  be respawned. I know that its ID is to be found using "nearestobject" command but I'm not quite sure how this should be done.

Please help me  :)
Title: Re:respawn nearest object
Post by: Terox on 03 Feb 2004, 18:59:52
Not sure what you want to do, please clarify

1) Do you want to repair an object that by default is already on an island, eg an object with an id number

2) Do you want to place a specific object (Building) on the map at a certain point in time

3) Do you want a player to respawn at a certain point on the map that isnt the standard respawn point
Title: Re:respawn nearest object
Post by: Chris Death on 03 Feb 2004, 19:40:07
Terox is right, and to add one more thing:

if it's only the id of the object you want to figure out,
then click in the editor onto "show id's" and zoom in closer.

whoop the object id's appearing for you.

:note - SHOW ID's exists since OFP resistance (just in case
you cannot find such a button in your editor)  ;)

~S~ CD
Title: Re:respawn nearest object
Post by: Cooba on 03 Feb 2004, 21:12:13
Yes..im sorry...its not clear what i wrote.

i want repair building  that by default is already on an island. I have this building ID.
i want repair this building when players destroy them. I need simple trigger with not alive command (or something like that).

Im sorry for my English -  Im working about this...  8)
Title: Re:respawn nearest object
Post by: Terox on 03 Feb 2004, 22:11:32
ah i see

Ya dont need a trigger m8

In the init sqs enter the following lines
Code: [Select]
repairarray = [object XXXX,object yyyy,object zzzz]
[]exec "repair.sqs"

and then create the following script run on all machines
(It simply loops repairing everything back to 0 on each circuit


Code: [Select]
;;Repair.sqs
;;damagecontrol
;;used to keep vital objects in good repair, eg ammocrates, medtents etc
;;objects in damconarray are stated in init.sqs
~10
#START
~2
{_x Setdammage 0} forEach repairarray
goto "START"



or if it is only used to repair 1 object then you could use the following, without creating the array in the init.sqs, just activating the script

Code: [Select]
;;Repair.sqs
~10
#START
@ getdammage (object XXXX) > 0.1
(Object XXXX) Setdammage 0
goto "START"


Ideally you would use the array system and you would add the names of all your ammo crates and med tents to it

eg
Repairarray = [Ec1,Ec2,Wc1,Wc2,Object XXX,Object YYY]


The only problem i find when trying to repair an object that is placed on the island by the hardcoding is that if you immediately set its dammage to 0 from heavy damage it will not look repaired

However what you can do is something like the following
Code: [Select]
#START
@ getdammage (object XXXX) > 0.5
~0.2
(Object XXXX) Setdammage 0.4
~0.2
(Object XXXX) Setdammage 0.3
~0.2
(Object XXXX) Setdammage 0.2
~0.2
(Object XXXX) Setdammage 0.1
~0.2
(Object XXXX) Setdammage 00
~0.2
(Object XXXX) Setdammage 0
goto "START"
This will as you can see repair it in stages and the end product will be a cosmetically repaired building as well


Dont worry about the cpu usage of the @ sign, as it is beiung run on your client iy wont cause any noticeable strain on your machine unless you have lots more @ commands in your scripts
Title: Re:respawn nearest object
Post by: Cooba on 04 Feb 2004, 03:06:49
Wow!
Thx Terox. Your post is very ...hmm... i dont know this word in english. Well...i just thx you.   ;)

Best regards for all ZEUS members  ;D
Title: Re:respawn nearest object
Post by: Terox on 04 Feb 2004, 16:08:48
Your welcome m8 :)