OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Dingmatt on 19 Feb 2005, 14:21:26

Title: All Units
Post by: Dingmatt on 19 Feb 2005, 14:21:26
I need to find a way to effect every unit on the map with a command "setfuel 0", anyone have any ideas?

Dingmatt
Title: Re:All Units
Post by: Infierie Blou on 19 Feb 2005, 14:28:11
how many units?
Title: Re:All Units
Post by: macguba on 19 Feb 2005, 14:36:04
Trigger:-

Area:  whole map
Condition:  as you like
On Activation:   "_x setFuel 0" forEach thislist

Not guaranteed.  
Title: Re:All Units
Post by: Dingmatt on 19 Feb 2005, 15:30:27
No triggers.... i can't use triggers this is a drop and play unit. as for how many? random, maybe 1 maybe 2000.

Dingmatt
Title: Re:All Units
Post by: macguba on 19 Feb 2005, 16:31:43
No idea what you are talking about.   What is "drop and play"?     Don't understand why you can't use triggers.    Don't understand why you didn't mention you couldn't use triggers.    Don't understand why, when I gave a most excellent answer to the question you asked, you didn't either thank me or apologise for not being clearer in what you wanted.

In this particular case it doesn't matter if you can't use a trigger.   All you need is an array of the units and there are several ways of getting it other than using a trigger.
Title: Re:All Units
Post by: Planck on 19 Feb 2005, 16:36:28
I've never heard of a unit that you can't use triggers with.

Perhaps you can enlighten us further.


Planck
Title: Re:All Units
Post by: Dingmatt on 19 Feb 2005, 18:53:07
i cannot use triggers because  the script is part of a addon, independant from any missions. I can't have it needing any setting up on a map. just placed down or "built" then ready to go. you can't createvehicle triggers (as far as i know).

Dingmatt
Title: Re:All Units
Post by: macguba on 19 Feb 2005, 21:04:47
IIRC you can theoretically create triggers, but you can't control most of the fields so they aren't really much use.

Since this is an addon question it should probably be on an addon board.

The question is really "How do I grab an array of all the vehicles on the map from inside an addon?".     The setFuel bit is straightfoward once you have the array.
 
Title: Re:All Units
Post by: General Barron on 19 Feb 2005, 23:22:08
All you need to do is to configure an "init" eventhandler in your addon's config. From that EH, you then add the unit to an array. Keep in mind that an error in init EH's makes the eventhandler fire again whenever the unit gets into/out of a vehicle, so you need to make sure you only add the unit to the array once. If you need more info on how to config EHs, I'd post in the addon editing board, as suggested.
Title: Re:All Units
Post by: Deepsmeg on 20 Feb 2005, 18:36:09
Wouldn't that only add the units that are the addon to the array if it is that unit's EH?
Title: Re:All Units
Post by: General Barron on 21 Feb 2005, 03:20:01
Quote
Wouldn't that only add the units that are the addon to the array if it is that unit's EH?
Correct. However, I assume that if you are creating this addon, then you can edit the addon's config, and therefore its eventhandlers.

If you want to add units to this array that are NOT from your addon, then you need to either (a) use the suggestions already posted here (i.e. use triggers), or (b) modify the game's core config and change the init EH for the class that these other units are inheriting from.
Title: Re:All Units
Post by: Deepsmeg on 21 Feb 2005, 19:52:18
The thing is, we need this unit to affect all the other units.

We're getting round it at the moment by detecting everything by doing a NearestObject from a moving thing.

This is obviously not optimal.
Title: Re:All Units
Post by: General Barron on 22 Feb 2005, 07:13:41
Yeah, that is going to be the only way to do it, unless you use a trigger or some other form of input from the mission editor.

So, my suggestion would be to simply put a note into your addon's readme, and hope that the mission editor who uses this addon is smart enough to actually read it, which I would think they would be. :)
Title: Re:All Units
Post by: Deepsmeg on 23 Feb 2005, 02:11:31
Users?
Intelligent?
Title: Re:All Units
Post by: Triggerhappy on 23 Feb 2005, 04:31:07
Tee hee heee  :P :o ::)