Jump to content
Sign in to follow this  
st!gar

Creating units and squads

Recommended Posts

Arrgh! I've been trying to find a way to create units and squads in the game, by for example having a squad appear at a point once a trigger is, well, triggered and so on.

I checked the BI wiki, but I just got confused. huh.gif I'm really stumped at the moment and in desperation, I decided to post here. I hope I'm not upsetting anyone with this.

I'd be really grateful if someone could write down a simple guide on how to, say, make a squad of enemies appear in a village once you have reached a certain waypoint or something of the sort. Again, I'm sorry if I'm being unreasonable here, but please remember that I'm an utter n00b on this stuff. Thanks in advance. smile_o.gif

Share this post


Link to post
Share on other sites

Just make a squad's presence False and trigger it to be True after an event perhaps?

Share this post


Link to post
Share on other sites

You certainly *could* create units out of the blue (via the createVehicle and related commands), but it'd be much easier and much more realistic if the units existed from the beginning, but at some point away from their final point on engagement.

Just start'em out somewhere far enough away, give'em a conditional or synchronized waypoint so they end up at their destination in time, and you've solved the problem of having units at the right place at the right time, plus you don't end up with unrealistically spawned enemies that are beamed into place out of nowhere.

This also adds some more variety to the mission, as they player could now decide to intercept those forces on their way to their destination, rather than only having one, and only one, way of fighting the enemy. And isn't that what OFP/ArmA is all about? wink_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]Just make a squad's presence False and trigger it to be True after an event perhaps?

How do you do that? I mean; I know how to set a unit's probability of presence to false, but how do I make it true in a trigger? What do I write in the init line?

Share this post


Link to post
Share on other sites

Right. I told you I tried that wiki, but that thing's complicated and annoying. I'm getting more and more frustrated as we speak. I've searched everything from this forum to Google, and I still have no idea what I'm supposed to be doing.

When I choose the unit's position to spawn, for example, I'm somehow supposed to write down coordinates?! Well, how the heck do I find them?!

Share this post


Link to post
Share on other sites

put an "empty" marker on the map and name it whatever you want... say its called spawn.

Then when you do the createVehicle, its

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

"type" createVehicle getPos spawn;

Share this post


Link to post
Share on other sites

Thanks for the reply. However, when I write the line into the init-field, I get an error saying "Type Object, expected Nothing". huh.gif

Share this post


Link to post
Share on other sites

simply put in the activation line of the trigger:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"SoldierWB" createUnit [getpos LOCATION,GROUPNAME]

This will spawn one West Rifleman (SoldierWB), if you want to spawn something different you can find a list of all different class names here

Now LOCATION will have to be a name of an object, or game logic at the location you want to spawn the soldier. If you want to use a Marker, simple put getmarkerpos "markername", instead of getpos OBJECTNAME. Make sure to include the " " when using getmarkerpos.

GROUPNAME must be the name of a group or unit that already exists, if a group doesn't exist nothing will spawn. A simple way to do this is to have a unit placed far away and name him something for example BOB. Then just put BOB where it says GROUPNAME. or if you want the new soldiers to join the player, simply put Player.

Now the newly created soldiers will try and return to formation with BOB but hes placed far far away. You now have two options:

1.In the activation of the trigger, after the creatvehicle command i previously mentioned put <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;BOB setpos (getpos LOCATION); This will place BOB at the spawn location along with his squad of newly spawned soldiers. ready to fight the enemy. Of course replace LOCATION with what ever you named the object or gamelogic like previously mentioned. And again if you decide to use marker instead its Getmarkerpos "Markername".

Or

2.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"SoldierWB" createUnit [getpos LOCATION,GROUPNAME,"This join grpnull"] Now the newly spawn soldier will "join" no group and wont try to keep in formation of BOB or any one.

So heres an example to spawn 5 West riflemen at a object or game logic called Spawn and teleport the group leader called AlphaBob to there location:

On trigger activation:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"SoldierWB" createUnit [getpos Spawn,AlphaBob];"SoldierWB" createUnit [getpos Spawn,AlphaBob];"SoldierWB" createUnit [getpos Spawn,AlphaBob];"SoldierWB" createUnit [getpos Spawn,AlphaBob];"SoldierWB" createUnit [getpos Spawn,AlphaBob];AlphaBob setpos (getpos Spawn)

Remember to part different codes with a ; like in the above example.

Hope that works!

Cheers,

Murphy

Share this post


Link to post
Share on other sites

another neat trick i've been playing with is creating an array of markers as spawn points for enemies and then using triggers to teleport enemies to random markers out of the array (by cycling through an array of the units to be teleported) . . . that way the mission never plays out exactly the same way twice, and theoretically you could make fairly dynamic missions with a few scripting tricks [i'm just not very knowledgeable about scripting, in fact someone else could probably explain what i'm talking about better, and with actual code examples wink_o.gif]

Share this post


Link to post
Share on other sites
Just make a squad's presence False and trigger it to be True after an event perhaps?

I also would like to know how to do this...

I create a mission with 20 objectives which gets activated dynamically and i dont want to write 20 scripts which are all hundrets of lines long for all the units i'm planning to build-in.

I already searched the Scripting commands, but i couldn't find the right one so far...

edit: also played around with the "Condition of Presence" and written the name of a variable in there which gets set to true during the mission by a trigger - however it don't works...

Help would be great with that

Share this post


Link to post
Share on other sites

this is a script to make dynamic games so when i start a mission there are no east on the map at all then all hell starts

help

;_trigger = starting pos of enemy "does not need to be own trigger"

;_enemyunits = how many enemy units you want to have start "0 = random 3"

;_type = what type of enemy unit "all = random, ground = ground vehicles or troops, air = air vehicles, "T72" = T72 ECT

;_unitlist = the array of units you want this enemy group to track or the trigger \ object enemy units will patrol around

;_movement = type of movement for tha enemy "any = random track,roam,patrol,airtrack. track = enemy will track west in _unitlist, roam = enemy will roam the island, patrol = enemy will patrol 500m around trigger; airtrack = for enemy planes ,enemy will track west in _unitlist;

;_distance = if _distance > 0 it will create the enemy unit in a random position that distance away from the trigger.

;Example   [tr1,3,"tank",tr1,"track",0] exec "RE\enemy.sqs"  or [tr2,0,"all",tr1,"patrol",250] exec "RE\enemy.sqs";[tr2,0,"GROUND",tr1,"roam",250] exec "RE\enemy.sqs";[tr2,0,"AIR",tr1,"airtrack",250] exec "RE\enemy.sqs"

add a empty east tank,car and chopper somewhere on the map

i use the patrol most of all

you will notice the enemy are different and so are the amount and placement everytime you start the mission

you can make it stay the same if you want

it is only setup for enemy = east for now;

add all code that is in the init.sqs file

add all code that is in the description.ext file

look in the enemy.sqs file for types you can use  

i have to rewrite in sqf format so i will write a better help then

if you have any probs let me know

the script and test mission

http://www.zonekiller.ath.cx/Scripts....tro.rar

Michael

Share this post


Link to post
Share on other sites

wow, this sounds good.... but tell me: Is it possible to give all those dynamic troops created also waypoints with values like their behavior? This is what i do need at most....

Ill check it out and report it here later.

Best Regards, Christian

Share this post


Link to post
Share on other sites
wow, this sounds good.... but tell me: Is it possible to give all those dynamic troops created also waypoints with values like their behavior? This is what i do need at most....

Ill check it out and report it here later.

Best Regards, Christian

Sure Is

just look at the patrol script and tracking scripts ect

you can add your own script to the enemy.sqs file

at this part

?(_movement == "track") : [_leader, _unitlist] exec "RE\track.sqs"

?(_movement == "patrol") : [_leader, _unitlist] exec "RE\patrol.sqs"

?(_movement == "roam") : [_leader, _unitlist] exec "RE\roam.sqs"

?(_movement == "airtrack") : [_leader, _unitlist] exec "RE\airtrack.sqs"

ie :

?(_movement == "myscript") : [_leader, _unitlist] exec "RE\myscript.sqs"

and script in your own waypoints

script would look something like

_leader = _this select 0

_grp = group _leader

_grp addWaypoint [ position somewhere, 0]

[_grp, 1] setWaypointType "MOVE"

[_grp, 1] setWaypointFormation "COLUMN"

[_grp, 1] setWaypointSpeed "FULL"

_grp addWaypoint [ position somewhere else, 0]

[_grp, 2] setWaypointType "MOVE"

[_grp, 2] setWaypointFormation "COLUMN"

[_grp, 2] setWaypointSpeed "FULL"

Michael

Share this post


Link to post
Share on other sites

Ok thanks this looks good... however a few things im not sure how to handle when using my method with waypoints:

1. In the "init" code you have to specifie... "_unitlist" and "_movement"... movement i'll replace with "myscript" but what to do with "_unitlist"? They should not track me nor should they roam around any place (just follow waypoints wink_o.gif )

2. I want to create many, many groups (around 20) and to set the waypoints for them in the "myscript" file, how can i find out what the groups names are?

3. "_grp addWaypoint [ position somewhere, 0]" - "position somewhere" can i get them with getpos from game-logics or markers?

Best Regards, Christian

Share this post


Link to post
Share on other sites

if your dont need the _unitlist it will just not use it so there is no prob there

position is the same as getpos

so position game logic will work.

this will make these groups go to logic 1 then logic 2 from town 1

make a trigger called tr1 in town 1

add this to it

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[tr1,3,"tank",tr1,"myscript",0] exec "RE\enemy.sqs"

this will make these groups go to logic 2 then logic 1 from town 2

make a trigger called tr2 in town 2

add this to it

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[tr2,3,"ural",tr2,"myscript",0] exec "RE\enemy.sqs"

this will make one set of groups go to logic 1 then logic 2

and the other set of groups go to logic 2 then logic 1

from town 3

make a trigger called tr3 in town 3

add this to it

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[tr3,3,"ground",tr1,"myscript",0] exec "RE\enemy.sqs";[tr3,3,"all",tr2,"myscript",0] exec "RE\enemy.sqs";

this way you can set different waypoints for each set of groups

myscript.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_leader = _this select 0

_unitlist = _this select 1

?(_unitlist == tr1) : _pos = position game logic 1

?(_unitlist == tr2) : _pos = position game logic 2

_grp = group _leader

_grp addWaypoint [ _pos , 0]

[_grp, 1] setWaypointType "MOVE"

[_grp, 1] setWaypointFormation "COLUMN"

[_grp, 1] setWaypointSpeed "FULL"

?(_unitlist == tr2) : _pos = position game logic 1

?(_unitlist == tr1) : _pos = position game logic 2

_grp addWaypoint [ _pos , 0]

[_grp, 2] setWaypointType "MOVE"

[_grp, 2] setWaypointFormation "COLUMN"

[_grp, 2] setWaypointSpeed "FULL"

you can set as many waypoints as you want

Share this post


Link to post
Share on other sites

thanks for your reply, but some questions still unanswered for me...

- i have already many gamelogics on my mission - is this a problem?

- How to find out the name of the groups? I don't have all groups move in the same towns.... they are all spread over north and south sahrani...

Regards, Christian

Share this post


Link to post
Share on other sites
thanks for your reply, but some questions still unanswered for me...

- i have already many gamelogics on my mission - is this a problem?

- How to find out the name of the groups? I don't have all groups move in the same towns.... they are all spread over north and south sahrani...

Regards, Christian

im not sure i can answer it any easier  

they dont have to be logics they can be triggers , objects ect

just as long as you name them

i dont think you can get the name of a group before it is created.........

_grp = group _leader

is the var name of the group

if you have have 20 start points with 20 sets of waypoints that is no problem

the example i showed wos 3 start point and two sets of way points  just expand on that.

Share this post


Link to post
Share on other sites

Here is the demo mission i said i would make you

and this is the script i called it waypoints.sqs

http://www.zonekiller.ath.cx/Scripts....tro.rar

;EXAMPLE [tr1,3,"tank",tr1,"waypoints",0] exec "RE\enemy.sqs"

; tr1 = where units start

; "tank" = type of unit

; tr1 = must be logic , trigger or object it tell the units what array of waypoints to use

; "waypoints" = tells units to use this script

; 0 = distance from trigger to start

; you must name the logics , triggers or objects that you want to use as waypoint positions then add the names into the _posarrays of waypoints that you want the units to use, the _fullspeed arrays are used for changing the speed of the waypoints you can add other arrays and IF statments to change other waypoint settings. change _debug = 1 to debug = 0 after testing is done................

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_leader = _this select 0

_unitlist = _this select 1

_grp = group _leader

;ARRAYS USED ADD ANY NEW ARRAYS HERE

;-------------

_posarray = []

_fullspeed = []

;-----------------

;-------------------------------------

; SET DEBUG TO 0 WHEN FINISHED TESTING

;-------------------------------------

_debug = 1

;ARRAY OF WAYPOINTS

;-----------------------------------------------------------------------------

?(_unitlist == tr1) : _posarray = [gl1,gl2,obj3,gl3]; _fullspeed = [gl1,gl3]

?(_unitlist == tr2) : _posarray = [obj1,obj2,obj3,obj4]; _fullspeed = [obj4]

?(_unitlist == tr3) : _posarray = [wp1,wp2,obj3,wp3,wp4]; _fullspeed = [wp1 ,obj3]

;-----------------------------------------------------------------------------

_loop = 0

#wpbuild

_pos = position (_posarray select _loop)

_WpNo = _loop + 1

_grp addWaypoint [ _pos , 0]

[_grp, _WpNo] setWaypointType "MOVE"

[_grp, _WpNo] setWaypointFormation "COLUMN"

;CHANGE THE SPEED OF THE WAYPOINTS LISTED IN ARRAY _fullspeed.

;-------------------------------------------------------------

if((_posarray select _loop) in _fullspeed) then {[_grp, _WpNo] setWaypointSpeed "FULL";} else {[_grp, _WpNo] setWaypointSpeed "NORMAL";}

;-------------------------------------------------------------

~1

? _debug == 1 : _markername = name _leader + format[" WP %1 ", _WpNo]

~0.5

? _debug == 1 : _marker = createMarkerLocal [_markername, _pos];

? _debug == 1 : _marker setMarkerShapeLocal "ICON";

? _debug == 1 : _marker setMarkerTypeLocal "Dot";

? _debug == 1 : _marker setMarkerSizeLocal [.3,.3];

? _debug == 1 : _marker setMarkerTextLocal _markername

? _debug == 1 && _unitlist == tr1 : _marker setmarkercolor "ColorRed"; _colour = "ColorRed";

? _debug == 1 && _unitlist == tr2 : _marker setmarkercolor "ColorBlue"; _colour = "ColorBlue";

? _debug == 1 && _unitlist == tr3 : _marker setmarkercolor "ColorGreen"; _colour = "ColorGreen";

_loop = _loop + 1

?(_loop < count _posarray) : goto "wpbuild"

? _debug == 1 : x = [_leader,_colour] execVM "RE\wptest.sqf"

Share this post


Link to post
Share on other sites

Thank you very very much.... i'll try it as soon as possible....

Best Regards, Christian

Share this post


Link to post
Share on other sites

After trying you mission (run from the editor) this happens:

unbenanntid7.th.jpg

Best Regards, Christian

Share this post


Link to post
Share on other sites

if you are running it as a single player or editing in the mission editor you will need to add 1 east man unit "sorry"

but if you are running it from a server or editing it in the multiplayer it will work fine

try adding a east man and running it..

any time your making single missions with the create enemy

just add a east man as well as the empty car tank and chopper

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×