OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Evan Scown on 17 Jun 2006, 21:27:14

Title: Enemy Spawn
Post by: Evan Scown on 17 Jun 2006, 21:27:14
Hello again,

How would I get an enemy squad to spawn like 100 meters behind my players squad as I'm running around? Would be in a trigger of course.
Title: Re: Enemy Spawn
Post by: The-Architect on 17 Jun 2006, 22:09:51
What you need.

A player called me1.
An enemy group called SpetzGrp1 (I used Spetz Naz)
The leader of the Spetz Naz group should be called Spet1

Obviously that's just so you can test the script. Change it according to your wishs.

Code: [Select]
#Start
{_x setPos [(GetPos Player Select 0) - 250*Sin(GetDir Player),(GetPos Player Select 1) - 250*Cos(GetDir Player),0]} ForEach Units SpetzGrp1
Goto "Approach"

#Approach
? Not (alive Spet1) : Goto "End"
spet1 setbehaviour "combat"
SpetzGrp1 Move GetPos Me1
? me1 distance Spet1 <=25 : goto "End"
~20
GoTo "Approach"

#End
Exit
Title: Re: Enemy Spawn
Post by: Evan Scown on 18 Jun 2006, 13:26:44
Can I replace Me1 with something like a group leader?
Title: Re: Enemy Spawn
Post by: myke13021 on 18 Jun 2006, 14:23:03
you can get actual group leader the player is in with

Code: [Select]
_groupleader = leader player

this wont work if you make a MP map since "player" is local on client machines and therefore different on each client.

When i think about it, as long all playable units belong to the same group, this should work.

so just modifiy architects script in this way:

Code: [Select]
#Start
_grpleader = leader player
{_x setPos [(GetPos _grpleader Select 0) - 250*Sin(GetDir _grpleader),(GetPos _grpleader Select 1) - 250*Cos(GetDir _grpleader),0]} ForEach Units SpetzGrp1
Goto "Approach"

#Approach
? Not (alive Spet1) : Goto "End"
spet1 setbehaviour "combat"
SpetzGrp1 Move GetPos _grpleader
? _grpleader distance Spet1 <=25 : goto "End"
~20
GoTo "Approach"

#End
Exit

@The-Architect
please check if i did it right, will ya?
Title: Re: Enemy Spawn
Post by: The-Architect on 18 Jun 2006, 14:25:32
I'm no good with the global stuff m8 you check it.  :(
Title: Re: Enemy Spawn
Post by: Evan Scown on 18 Jun 2006, 14:33:28
Sweet as bro,

I'll give it a go mate.