OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: 2234jones on 18 Jan 2012, 04:45:26
-
I trying to work out a way to spawn units in a trigger's area. I have the spawn script for the units that will be spawning but I can't figure out how to make them spawn in the trigger area.
In addition to this I want an area to be protected from the spawned units that try to enter the base. So if any of the spawned units enters the base they die instantly.
If anybody can help, It will be greatly appreciated.
-
Is the trigger area a circle and you want them spawned randomly inside it? That's already baked into the createUnit and createVehicle commands!
_unit = group player createUnit ["SoldierWB", position player, [], 100, "FORM"]
_veh = createVehicle ["Cobra", position player, [], 100, "FLY"]
The number in bold there is the same as "placement radius" when you create the units in the editor, i.e. the random area around the "position player" (the centre) in which the unit will spawn. So just use position trigggerName or invisibleH1 or gameLogic1 or whatever as the centre and spawn away! Since you already have the spawning script, you might have to edit it, but it's not a very difficult edit.
If you've got an esoteric trigger shape and actually want to spawn things inside it by necessity, well, that's going to be a little more complex. Unfortunately I can't help you with the math of that :( Kronzky uses it in his UPS though, so if you google that you might get some pointers?
As to killing enemies who enter a certain trigger area, there are plenty of scripts that do these kinds of things for you, but the simplest would be:
Trigger, x-y = area of death. Activated by: [enemy side] Present, Repeatedly. Condition: this, on activation: {_x setdamage 1} foreach thisList
That should kill anyone of [enemy side] entering the trigger area. :)
Wolfrug out.
-
Make the units first and then put the trigger near them so they will be in the radius of the trigger. :good: