Jump to content
npmproductions13

Trying to spawn tanks with crew and give waypoints

Recommended Posts

Hi there everyone so here is what i'm trying to create i want three Tanks to spawn with crew and then move to waypoints after a certain amount of time has elapsed.

This is what i have so far.. major disclaimer here I've been experimenting with a lot of this just seeing how certain things work and trying to get the basic understanding of the language so Arma 3 coding veterans prepare the defibrillators because you might need to restart your hearts after seeing this.

 

On a side note if anyone has any tips on learning how to code SQF, SQS etc in arma please let me know as im hungry to learn this language but can't find any good material anywhere.

 

//if (isServer) then {

_type = _this select 0;
_mark = _this select 1;
_time = _this select 2;
_slaGrp = createGroup INDEPENDENT;

//Sherman #1
_vehicleObject = createVehicle ["LIB_M4A3_75_Tubes", getMarkerPos "spawn1", [], 1, ""];_vehicleObject setDir 217.344;
_S1vehicleName = "sherman1";
missionNamespace setVariable [_S1vehicleName,_vehicleObject];
publicVariable _S1vehicleName;

//Sherman #1 Crew
_s1Inf = "LIB_US_tank_crew" createUnit [ getMarkerPos "spawn1crew", _slaGrp];
missionNamespace setVariable _s1Inf;
publicVariable _s1Inf;
_s1Inf moveInDriver "sherman1";

//Sherman #2 Crew
_s2Inf = "LIB_US_tank_crew" createUnit [ getMarkerPos "spawn1crew", _slaGrp];
missionNamespace setVariable [_s2Inf];
publicVariable _s2Inf;
_s2Inf moveInGunner "sherman1";

//Sherman #3 Crew
_s3Inf = "LIB_US_tank_crew" createUnit [ getMarkerPos "spawn1crew", _slaGrp];
missionNamespace setVariable [_s3Inf];
publicVariable _s3Inf;
_s3Inf moveInCommander "sherman1";
//createVehicleCrew (sherman1 select 0);


//Sherman #2
//_vehicleObject = createVehicle ["LIB_M4A3_75_Tubes", getMarkerPos "spawn2", [], 1, ""];_vehicleObject setDir 217.344;
//_S2vehicleName = "sherman2";
//missionNamespace setVariable [_S2vehicleName,_vehicleObject];
//publicVariable _S2vehicleName;
//createVehicleCrew (sherman2 select 0);

//Sherman #3
// = createVehicle ["LIB_M4A3_75_Tubes", getMarkerPos "spawn3", [], 1, ""];_vehicleObject setDir 217.344;
//_S3vehicleName = "sherman3";
//missionNamespace setVariable [_S3vehicleName,_vehicleObject];
// _S3vehicleName;
//createVehicleCrew (sherman3 select 0);

//};

 

  • Like 1

Share this post


Link to post
Share on other sites

Forget all your stuff.

Use bis_fnc_spawnGroup on a single line for grouped manned tanks, or one line for each tank if not grouped

 

_grp1 = [getMarkerPos "spawn1", INDEPENDENT, ["LIB_M4A3_75_Tubes"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;

 

Note1: the return value is a group (even for one unit). So don't wait for any change (during combat) but add following lines to get the extra info:
(here for one tank/one group)

 _leader = leader _grp1;

_vehicle  = vehicle _leader;

_crew = crew _vehicle;....

 

Note2: for waypoints, it's immediate:

_wpt1 = _grp1 addWaypoint [<position>,0];

_wpt setWaypointType "SAD";.. and what you want with setWayoint.. commands

  • Like 2

Share this post


Link to post
Share on other sites

OMG thats great so far how did you learn to code in SQF ? i want to learn so much.

Anyways it works but probably not as neat or as efficient as you sent it.

 

At the top you say i can use 1 line of code for multiple tanks can you give an example of this or is this code i have what you meant ?

//Sherman #1 & Crew
_grp1 = [getMarkerPos "spawn1", INDEPENDENT, ["LIB_M4A3_75_Tubes"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
//
_leader1 = leader _grp1;//Note1: the return value is a group (even for one unit). So don't wait for any change (during combat) but add following lines to get the extra info:   //(here for one tank/one group)
_vehicle1  = vehicle _leader1;
_vehicle1 setVehicleLock "LOCKED";
_crew1 = crew _vehicle1;
_vehicle1 setDir 212.340;

//Sherman #2 & Crew
_grp2 = [getMarkerPos "spawn2", INDEPENDENT, ["LIB_M4A3_75_Tubes"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
//
_leader2 = leader _grp2;
_vehicle2  = vehicle _leader2;
_vehicle2 setVehicleLock "LOCKED";
_crew2 = crew _vehicle2;
_vehicle2 setDir 212.340;

//Sherman #3 & Crew
_grp3 = [getMarkerPos "spawn3", INDEPENDENT, ["LIB_M4A3_75_Tubes"],[],[],[],[],[], 0] call BIS_fnc_spawnGroup;
//
_leader3 = leader _grp3;
_vehicle3  = vehicle _leader3;
_vehicle3 setVehicleLock "LOCKED";
_crew3 = crew _vehicle3;
_vehicle3 setDir 212.340;

//Waypoints for Sherman #1 - #3
_wpt1 = _grp1 addWaypoint [getMarkerPos "shermanadvance1",0];			//Note2: for waypoints, it's immediate:
_wpt1 setWaypointType "MOVE";											//.. and what you want with setWayoint.. commands

_wpt2 = _grp2 addWaypoint [getMarkerPos "shermanadvance2",0];
_wpt2 setWaypointType "MOVE";											//.. and what you want with setWayoint.. commands

_wpt3 = _grp3 addWaypoint [getMarkerPos "shermanadvance3",0];
_wpt3 setWaypointType "MOVE";		

 

Share this post


Link to post
Share on other sites

Yes, probably work!

I gave you some links for all possibilities of this function, then some commands for waypoints.

The main BIKI page (directory) for command is here! One major rule: take time to read the whole page for a command. Always respect the syntax! Most of beginners' errors come from non-respect of the types of the variables (parameters). group must be a group, array of units is an array with unit objects, weapons, magazines are usually strings of their classes..

To go deeper in scripting.

and also:

variables (type of variable (string, nbr, object...) but also their scope: private, global, public..

operators (not so evident if you work with arrays)

Use SQF syntax.

And... the good habits, right now!

Further and other:

http://www.ofpec.com/forum/index.php?topic=32468.0

Editing

 

 

 

Running your first codes:

If the aim is to write an sqf and register it in mission file (where the mission.sqm is, the only file automatically created when you start Eden), you can test it without pain, from the debug console or a trigger (condition let to true).

But debug console or activation field or a trigger don't like:

- direct suspension (sleep, waituntil...);

- comments made of //  /* */

So, for a quick test of a code like yours, you just have to remove all the comments, copy paste in debug or trigger already activated then go!

If on other days, you need to wait/sleep then wrap your code with:

0 = [] spawn { < your code here >};

and test it without creating any file.

 

Last but not least, I suggest you use an sqf editor with highlighted SQF CPP... syntax! You will track some evident errors (and save some posts on forum). I use the excellent sublime text2 embedded in Poseidon tools by Tom_48_97.

 

Have fun!

 

 

  • Like 3

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

×