Home   Help Search Login Register  

Author Topic: A script to spawn a set of enemies  (Read 706 times)

0 Members and 1 Guest are viewing this topic.

SH@dow 113

  • Guest
A script to spawn a set of enemies
« on: 28 Jun 2004, 22:17:12 »
I need a script that will spawn some enemie soldiers when you walk into a trigger. I have searched for it but i didnt find anything.
Thx in advance ;)

FlidMerchant

  • Guest
Re:A script to spawn a set of enemies
« Reply #1 on: 28 Jun 2004, 22:36:23 »
I don't do scripting but you can do it by placing the soldiers in some far off place and placing gamelogics where you want them to appear. Then in the activation field for the trigger you put "soldiername setpos getpos gamelogicname"

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:A script to spawn a set of enemies
« Reply #2 on: 29 Jun 2004, 00:10:56 »
There's a good thread about this going on at the moment either here on on the Advanced board.    Well actually its about deleting units once they have been created but in passing it covered exactly what you need to know.
Plenty of reviewed ArmA missions for you to play

SH@dow 113

  • Guest
Re:A script to spawn a set of enemies
« Reply #3 on: 29 Jun 2004, 11:34:13 »
you got a link to that thread? thx anyways ;)

CrashnBurn

  • Guest
Re:A script to spawn a set of enemies
« Reply #4 on: 29 Jun 2004, 20:50:07 »
;simple create script by -CrashnBurn- dwaters59@msn.com
;randomizes unit type, skill and rank.
;pass script using array [positiontocreate,groupname] exec "create.sqs"
;positiontocreate can be gamelogic, marker, object id# etc...
;groupname must already exist in editor, cannot be grpnull.
;-----------------------------------------------------------------------------
created = 0
#CREATE
_position = _this select 0
_group = _this select 1
;-----------------------------------------------------------------------------
;choose random unit type. Set your unit types here.
_UnitTypeArray = ["SoldierWB","SoldierWG","SoldierWLAW","SoldierWMedic","SoldierWB","SoldierWMG","SoldierWAT","SoldierWB","SoldierWG","OfficerW"]
_UnitType = _UnitTypeArray select (random 9)
;-----------------------------------------------------------------------------
;give unit a random brain.
_skillArray = [1,.9,.7,.8,1,.6]
_skill = _skillArray select (random 5)
;-----------------------------------------------------------------------------
;assign unit a random squad rank.
_rankArray = ["SERGEANT","CORPORAL","LIEUTENANT","PRIVATE"]
_rank = _rankArray select (random 3)
;-----------------------------------------------------------------------------
;and another virtual moron with a gun is born.
_UnitType CreateUnit [_position,_group,"",_skill,_rank]
;-----------------------------------------------------------------------------
;delay used to smooth creation a bit.
~1 + (random 1)
created = created + 1
;-----------------------------------------------------------------------------
;set number of units to create. Variable "created = 0" is at top of script.
;12 units is max number to be alive at one time for any group !!
? created >= 9: exit
goto "CREATE"

SH@dow 113

  • Guest
Re:A script to spawn a set of enemies
« Reply #5 on: 29 Jun 2004, 21:29:34 »
thx but could u explain a bit. ;)
What do i put in editor to make it work?
« Last Edit: 29 Jun 2004, 21:30:21 by Sh@dow 113 »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:A script to spawn a set of enemies
« Reply #6 on: 29 Jun 2004, 22:47:32 »
Ah.

Making CrashnBurn's most excellent answer work is not difficult.   However, you need a good solid base of OFP knowledge to understand it.   Fortunately, this is easy to achieve.

Head over to the Editors Depot and read snYpir's Friendly Intro to Code Snippets.     It covers pretty much everything you need to know to understand how to make this script work.    (In general terms of course.)

The critical bit is that in your mission you will have  a trigger somewhere with something like this:

On Activation:    [getPos gamelogic1, grp1] exec "create.sqs"

The script file create.sqs is a text file in your mission directory:    copy and past CrashnBurn's reply into an empty text file to create it.   There must be a group called grp1 (in this example) already in existance - created by you in the mission editor - for this to work.

You will certainly have further questions about this, and ask them by all means:  but before you ask them, study snYpir's tute - it will help more than any answer here.   Also read about createUnit in the online command reference.

@CrashnBurn - very pleased that _skillarray has nothing under .5   :)
Plenty of reviewed ArmA missions for you to play

SH@dow 113

  • Guest
Re:A script to spawn a set of enemies
« Reply #7 on: 30 Jun 2004, 11:16:32 »
Thx for the info :), I read snYpir's Friendly Intro to Code Snippets, and now I understand a little more of scripts  ;D.
 Thx again ;D ;D ;D ;D ;D :cheers: :thumbsup:

SH@dow 113

  • Guest
Re:A script to spawn a set of enemies
« Reply #8 on: 30 Jun 2004, 14:07:42 »
I got a problem, i managed to spawn the soldiers (in this case "SST Bugs") but i can't get them to the place i want after spawn. ???