Jump to content
Sign in to follow this  
MuadDib

A question on spawning units

Recommended Posts

Hi there, please note I am a total noob when it comes to scripting :P

Basically I have a trigger that executes a script fine, I want that script to spawn a transport chopper of the east side at a gamelogic location in flight as s2_group(for naming sake) I also want the script to spawn around 5 SoldierEB's as s1_group in the cargo of the chopper and then move the chopper to a gamelogic position called ND2. At that point I want s1_group to exit the chopper and make their way to gamelogic position ND1.

This is what Ive come up with sofar and it doesn't work of course :P

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

"Mi17_MG" createUnit [position NDCS, s2_group, "east_chop = this", 1.0, "corporal"];

"SoldierEB" createUnit [position NDCS, s1_group, "NDU1 = this", 0.6, "corporal"];

"SoldierEB" createUnit [position NDCS, s1_group, "NDU2 = this", 0.6, "private"];

"SoldierEB" createUnit [position NDCS, s1_group, "NDU3 = this", 0.6, "private"];

"SoldierEB" createUnit [position NDCS, s1_group, "NDU4 = this", 0.6, "private"];

NDU1 assignAsCargo east_chop;

NDU2 assignAsCargo east_chop;

NDU3 assignAsCargo east_chop;

NDU4 assignAsCargo east_chop;

_waypoint0 = s2_group addWaypoint [getMarkerPos "ND1", 0];

_waypoint0 setWaypointType "TR UNLOAD";

_waypoint0 setWaypointStatements ["true", ""];

_waypoint1 = s1_group addWaypoint [getMarkerPos "ND1", 0];

_waypoint1 setWaypointType "GET OUT";

_waypoint1 = s1_group addWaypoint [getMarkerPos "ND2", 0];

_waypoint1 setWaypointType "MOVE";

Please note I have another gamelogic called NDCS which is pretty far out to sea.

I also run 2 bits of script that create groups called s1_group and s2_group

figured out some more stuff but still haven't got it working

Share this post


Link to post
Share on other sites

Well,

you have used a limited form of the syntax,

it's up to you to name the units with the complete syntax:

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

"SoldierEB" createunit [position NDCS,s1_group,"ESoldier1 = this", 1, "PRIVATE"];

and from the Wiki:

Quote[/b] ]

type createUnit [position, group, init*, skill*, rank*] * optional, if one is set, all precedent arguments have to be set too

Lol, while i am writing this you have edited your post, so forget the previous section!

The chopper is spawned the wrong way, you need to createvehicle a vehicle:

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

_ChopperName= "Mi17_MG" createVehicle position NDCS;

After that you need to movein a pilot he gets the group s2_group:

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

"SoldierEPilot" createunit [position NDCS,s2_group,"EPilot1 = this", 1, "PRIVATE"];

EPilot1 moveindriver _ChopperName;

Now you have to oder your group to get in:

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

units s1_group ordergetin true;

For the waypoints you have to synchronize the chopper waypoint with the getout waypoint of the group!

The chopper and the cargo group should be unequal for this to work! (or you would just simple use "getout" for all of them, if the pilot is in the cargo group)

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

_waypoint0 synchronizeWaypoint [ _waypoint1 ];

For the generic error cause, you have to let us know the line where you tell east_chop to land, sounds like a variable or syntax problem.

EDIT: More problems : if NDCS is far out on the sea, your chopper will spawn right in the sea and ne destroyed. So if you wanna still have the units climb in the chopper without using moveincargo, you need to position NDCS on a piece of land.

With moveincargo you could spawn the chopper mid-air and move em all in instantaneously.

Share this post


Link to post
Share on other sites

cheers for replying :P

and yes I was kind of working on it when I was posting too so I ended up editing the post like 3 times :P

Anyway, the plan was for the chopper to spawn in midair with the units inside it instantaneously. Ill keep trying though, hopefully with some of the stuff you have given me I might be able to get closer biggrin_o.gif

Share this post


Link to post
Share on other sites

To spawn the chopper mid-air it would be:

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

east_chop = createVehicle ["Mi17_MG", position NDCS, [], 0, "FLY"];

You would then have to "movein" the pilot and the cargo with:

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

EPilot1 moveindriver east_chop;

{_x moveincargo east_chop} foreach units s1_group;

That chopper has a gunner too, so you could create a gunner that is in s2_group :

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

"SoldierEPilot" createUnit [position NDCS, s2_group, "EGunner = this", 0.6, "corporal"];

EGunner moveingunner east_chop;

Not sure if it's necessary, but if the chopper keeps falling from the sky, the you would need to add:

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

EPilot1 action ["ENGINEON", east_chop];

or issue a quick move-command

Hope that gets you to where you wanna go with it.

Charon

Share this post


Link to post
Share on other sites

lol yes it is :P

now though it seems the chopper does not want to go to the waypoint, it ends up flying somewhere else completely... not sure where though

here is the updated code so far :P

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

eastchop = createVehicle ["Mi17_MG", position NDCS, [], 0, "FLY"];

"SoldierEPilot" createunit [position ND2,s2_group,"EPilot1 = this", 1, "PRIVATE"];

EPilot1 moveindriver eastchop;

EPilot1 action ["ENGINEON", eastchop];

"SoldierEB" createUnit [position ND2, s1_group, "NDU1 = this", 0.6, "corporal"];

"SoldierEB" createUnit [position ND2, s1_group, "NDU2 = this", 0.6, "private"];

"SoldierEB" createUnit [position ND2, s1_group, "NDU3 = this", 0.6, "private"];

"SoldierEB" createUnit [position ND2, s1_group, "NDU4 = this", 0.6, "private"];

NDU1 moveincargo eastchop;

NDU2 moveincargo eastchop;

NDU3 moveincargo eastchop;

NDU4 moveincargo eastchop;

_waypoint0 = s2_group addWaypoint [getMarkerPos "ND1", 0];

_waypoint0 setWaypointType "TR UNLOAD";

_waypoint0 setWaypointStatements ["true", ""];

_waypoint1 = s1_group addWaypoint [getMarkerPos "ND1", 0];

_waypoint1 setWaypointType "GET OUT";

_waypoint0 synchronizeWaypoint [_waypoint1];

_waypoint2 = s1_group addWaypoint [getMarkerPos "ND2", 0];

_waypoint2 setWaypointType "MOVE";

Share this post


Link to post
Share on other sites

This is because of a typo, your chopper doesn't have a pilot in your version,make sure to name the chopper always the same check for the underscore.

Edit: You obviously found it, lol this is an Edit-war

Share this post


Link to post
Share on other sites

ok, I moved myself into the chopper after its created to try to figure out where its heading and as far as I can tell it just continues to head SouthWest which is pretty much opposite to where it should be going (out past rahmadi lol)

what have I done wrong? btw latest piece of code is up there ---^

Share this post


Link to post
Share on other sites

Replace

Quote[/b] ]

_waypoint0 setWaypointType "TR UNLOAD";

with

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

_waypoint0 setWaypointType "MOVE";

and see if the chopper goes into the correct direction now.

If yes, then it must be a problem with the waypointtype,

try just "UNLOAD" then.

Share this post


Link to post
Share on other sites

it still goes in the incorrect direction sad_o.gif no change on how it behaves

Share this post


Link to post
Share on other sites

The error is here:

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

_waypoint0 = s2_group addWaypoint [getMarkerPos "ND1", 0];

ND1,ND2 are gamelogics you have said, then it must be :

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

_waypoint0 = s2_group addWaypoint [position ND1, 0];

_waypoint2 = s1_group addWaypoint [position ND2, 0];

except ND1 is a map marker then the syntax is correct.

Share this post


Link to post
Share on other sites

cheers mate, the chopper now flies to the waypoint however he doesn't land, ive tried giving him several different types of waypoints such as UNLOAD and TR UNLOAD. Ive even changed the waypoint location to an invisible helipad and he still doesn't land sad_o.gif

I have also tried putting in

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

_waypoint1 setWaypointStatements ["true", "eastchop land "LAND""];

however it gives me an error saying expected object yet recieved string when clearly that command as far as I can tell is correct.

Any ideas on how to get this helicopter to land?

Share this post


Link to post
Share on other sites

In Flashpoint it was:

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

ChopperName flyInHeight 0

ChopperName land "get in"

dostop driver Choppername

then for the unload

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

_Squad = units GroupName

_z = 0

#START

? _z >= count _Squad : goto "Next"

(_Squad select _z) action ["eject", Choppername]

~1

_z= z + 1

goto "Start"

#NEXT

you can wait untill the group has unloaded completely before giving the chopper its next waypoint or domove (which I prefer). The Flyinheight needs to be set back up or the chopper will try to drive away. I hope this works because if there is a different way to do this in Arma I would like to know.

Share this post


Link to post
Share on other sites

Well ArmA offers the possibilty to create waypoints by scripting commands, so it is possible to do it only with waypoints.

Okay, apart from that i would disadvise you to use the command that way, you have to be carefull with hyphens within hyphens,

it would be:

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

_waypoint1 setWaypointStatements ["true", "eastchop land ""LAND"""];

I will look into it later,

the chopper not landing can only mean

that the synchronization fails.

Share this post


Link to post
Share on other sites

Pretty interesting,

unless there is no typos involved,

it seems as if the command synchronize waypoint

DOES NOT succefully synchronize waypoints.

I have checked the units' behaviours with TroopMon

and the pilot is in WAIT mode as he should be to

let the cargo out, but the cargo units, don't get issued

a waypoint at all, they are always in unitready mode.

I have also changed the waypoint type to "GETOUT" without

the space, as it is stated in the Wiki.

The script that i have used for the test:

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

s1_group = createGroup east;

s2_group = createGroup east;

eastchop = createVehicle ["Mi17_MG", position NDCS, [], 0, "FLY"];

"SoldierEPilot" createunit [position ND2,s2_group,"EPilot1 = this", 1, "PRIVATE"];

EPilot1 moveindriver eastchop;

EPilot1 action ["ENGINEON", eastchop];

"SoldierEB" createUnit [position ND2, s1_group, "NDU1 = this", 0.6, "corporal"];

"SoldierEB" createUnit [position ND2, s1_group, "NDU2 = this", 0.6, "private"];

"SoldierEB" createUnit [position ND2, s1_group, "NDU3 = this", 0.6, "private"];

"SoldierEB" createUnit [position ND2, s1_group, "NDU4 = this", 0.6, "private"];

NDU1 moveincargo eastchop;

NDU2 moveincargo eastchop;

NDU3 moveincargo eastchop;

NDU4 moveincargo eastchop;

_waypoint0 = s2_group addWaypoint [Position ND1, 0];

_waypoint0 setWaypointType "TR UNLOAD";

_waypoint1 = s1_group addWaypoint [Position ND1, 0];

_waypoint1 setWaypointType "GETOUT";

_waypoint0 synchronizeWaypoint [_waypoint1];

sleep 200;

_waypoint2 = s1_group addWaypoint [Position ND2, 0];

_waypoint2 setWaypointType "MOVE";

Anyone wanna join in on this experiment?

Charon

Share this post


Link to post
Share on other sites

Okay i have made more experiments and it all works when

the waypoints are put in the editor. Synchronization wasn't even needed.

When scripted the cargo group DOES receive the getout waypoint

and the pilot DOES receive the TR UNLOAD waypoint, but the units won't get out !!!

That's a bug, can anyone confirm that?

Share this post


Link to post
Share on other sites

cheers for helping :P

what do you mean that it all works when you enter the waypoints in the editor? how can you add waypoints for units that dont exist?

lol here I thought I would try out something easy for my first foray into scripting :P

Share this post


Link to post
Share on other sites

Welcome to scripting. Things can get more complicated very quickly but the new features in Arma should save some headaches hopefully. What you learn in one area will likely be very useful later on if you continue making scripts.

Groups can be set up with waypoints in the editor and then deletevehicle this to clear the unit (in init of unit). When you spawn your unit into that group it will automatically use the first waypoint and go from there. Whether you lay down WPs in editor or script they should work the same. In scripts you can move and configure the WPs I just prefer a game logic and a domove command since in OFP it just seemed less breakable.

Share this post


Link to post
Share on other sites

how do you make the unit join the group of the deleted unit? I have no idea what the group of that deleted unit is called. Is there a default name?

I have tried in the init of the deleted unit to put

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

[this]join s2_group; deletevehicle this;

but that doesnt seem to work either sad_o.gif

Share this post


Link to post
Share on other sites

It goes :

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

MYGROUP=group this; deletevehicle this

you put that into any unit's init field of the side that you wanna use

and then into another unit's init field:

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

[MYSOLDIER] join [MYGROUP]

Quote[/b] ]

what do you mean that it all works when you enter the waypoints in the editor? how can you add waypoints for units that dont exist?

Well i tend to check scripted stuff that i know works in the editor and for some reason not in a script by placing some units in the editor and have them (in this case) follow GETOUT and TR UNLOAD waypoints to compare and look for possible faults.

The problem lies in the waypoint functionality and the new scripting commands...

Share this post


Link to post
Share on other sites

Of course it works in the editor, the Mi17 would start manned in the editor. Based on my experiences in OFP, Transport Unload does NOT work when the crew is moved into the vehicle (using moveindriver/gunner/etc..). I'm not sure if this works (or if this is still the same in ArmA) but I think you might have to assign the crew positions as well as move them in it, using assignasdriver/gunner/etc. You should also note the differences between Unload and Transport Unload, the former only disembarks units in cargo that are in the same group as the vehicle's crew, and the latter only for units in a group other than that of the crew.

If the pilot still won't initiate the transport unload then you can always order the cargo units out with unassignvehicle and the pilot will automatically land to let them out.

Share this post


Link to post
Share on other sites
Quote[/b] ]

Of course it works in the editor, the Mi17 would start manned in the editor

You don't understand what i am saying.

I have tried to compare the waypoint behaviour of

units just for the special case if they get assigned the waypoint

by script or in the editor and these cases show different results.

I am aware of the fact that placing an east side Mi17 (not empty ofc) will have a crew upon mission start.

You thoughts about the waypoints are helpful and show up limitations that have obviously already been there in OFP.

The assign/unassignvehicle options are worth considering.

I am still of the opinion that BIS can fix that bug, if it is brought to their attention.

Share this post


Link to post
Share on other sites
Quote[/b] ]

Of course it works in the editor, the Mi17 would start manned in the editor

You don't understand what i am saying.

I have tried to compare the waypoint behaviour of

units just for the special case if they get assigned the waypoint

by script or in the editor and these cases show different results.

I am aware of the fact that placing an east side Mi17 (not empty ofc) will have a crew upon mission start.

You thoughts about the waypoints are helpful and show up limitations that have obviously already been there in OFP.

The assign/unassignvehicle options are worth considering.

I am still of the opinion that BIS can fix that bug, if it is brought to their attention.

I understand, what I was saying is that the behavour of Transport Unload waypoints (and possibly others) are related to wether or not the vehicle's crew was moved in (even from init field/script) or started in it (as in placed as a manned vehicle from the editor). In the case of the script the pilot is moved in and thus the vehicle is not created with a crew like it is in the editor - this WILL change the results. I'm not sure but it might related to the crew being (or not being) assigned to the vehicle. However I'm not sure if the moveIn... commands automatically assign the units to the vehicle, I think it might, thus conflicting with my previous hypothesis.

Share this post


Link to post
Share on other sites

by using unnassignvehicle I have been able to get the chopper to land and the squad to exit and follow some other waypoints. Cheers for all the help to everyone :P

Its weird how we get different behaviour when the waypoints are scripted or placed in the editor....

btw I tried the assigndriver to the pilot before he is moved in but that didnt work, the only way to get it to land was by using unassignvehicle on each of the infantry squad members in a separate script file executed when the chopper reached its first waypoint.

Share this post


Link to post
Share on other sites

Cool thanks for reporting your findings and sharing.

So the conclusion of this is, that a scripted "GETOUT" waypoint

does not unassign the group from the assigned vehicle as it succesfully does in a editor-placed "GETOUT" waypoint.

That should be added to the Buglist.

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  

×