Home   Help Search Login Register  

Author Topic: Spawn Units In A Trigger Area  (Read 2960 times)

0 Members and 1 Guest are viewing this topic.

Offline 2234jones

  • Members
  • *
Spawn Units In A Trigger Area
« 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.
« Last Edit: 18 Jan 2012, 05:02:39 by 2234jones »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Spawn Units In A Trigger Area
« Reply #1 on: 18 Jan 2012, 17:22:49 »
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.
"When 900 years YOU reach, look as good you will not!"

Offline Jack48271

  • Members
  • *
Re: Spawn Units In A Trigger Area
« Reply #2 on: 08 Jun 2012, 16:28:25 »
Make the units first and then put the trigger near them so they will be in the radius of the trigger. :good: