Jump to content
Sign in to follow this  
Mirek

my ai spawning script "truck.sqf" doesnt work can you find why?

Recommended Posts

I use them unit spawning sqf´s alot and they allways work this one doesnt, and i cant find why.

if (isServer) then {

trk = CreateGroup EAST;     
truck = trk createVehicle ["V3S_Civ", [(getMarkerPos "spwn") select 0,(getMarkerPos "spwn") select 1,0], [], 0, "CANCOLIDE"]; 
ridic = trk createUnit ["Ins_Woodlander1", [(getMarkerPos "spwn") select 0,(getMarkerPos "spwn") select 1,0], [], 0, "CANCOLIDE"]; 
ridic  moveInDriver truck;


grp = CreateGroup EAST;     
c = grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn") select 0,(getMarkerPos "spwn") select 1,0], [], 0, "CANCOLIDE"]; 
d = grp createUnit ["Ins_Soldier_GL", [(getMarkerPos "spwn") select 0,(getMarkerPos "spwn") select 1,0], [], 0, "CANCOLIDE"]; 
e = grp createUnit ["Ins_Soldier_AR", [(getMarkerPos "spwn") select 0,(getMarkerPos "spwn") select 1,0], [], 0, "CANCOLIDE"]; 
f = grp createUnit ["Ins_Soldier_2", [(getMarkerPos "spwn") select 0,(getMarkerPos "spwn") select 1,0], [], 0, "CANCOLIDE"]; 
g = grp createUnit ["Ins_Soldier_Medic", [(getMarkerPos "spwn") select 0,(getMarkerPos "spwn") select 1,0], [], 0, "CANCOLIDE"]; 
h = grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn") select 0,(getMarkerPos "spwn") select 1,0], [], 0, "CANCOLIDE"]; 

c moveInCargo truck;
d moveInCargo truck;
e moveInCargo truck;
f moveInCargo truck;
g moveInCargo truck;
h moveInCargo truck;

mg1 = trk addWaypoint [getMarkerPos "wp_1",0 ]; 
mg1 setWaypointType "TR UNLOAD" ;  
mg1 setWaypointCombatMode "RED";
mg1 setWaypointBehaviour "SAFE";
mg1 setWaypointSpeed "FULL"; 

mg2 = grp addWaypoint [getMarkerPos "z1",0 ]; 
mg2 setWaypointType "SAD" ;  
mg2 setWaypointCombatMode "RED";
mg2 setWaypointBehaviour "COMBAT";
mg2 setWaypointSpeed "FULL";



};

it is called via radio trigger 0-0-3

null = execVM "truck.sqf";

but when i press0-0-3 in game nothing happends. read trough it 5 times, i dont see any missing brackets or theese:";"

And i didnt forget to place marker called "spwn" nor the others.

Edited by Mirek

Share this post


Link to post
Share on other sites

Try this out:

if (isServer) then {

truck = createVehicle ["V3S_Civ", (getMarkerPos 'spwn'), [], 0, "CAN_COLLIDE"];
trk = createGroup EAST;
ridic = trk createUnit ["Ins_Woodlander1", (getMarkerPos 'spwn'), [], 0, "CAN_COLLIDE"]; 
ridic  moveInDriver truck;

grp = createGroup EAST;
c = grp createUnit ["Ins_Soldier_1", (getMarkerPos 'spwn'), [], 0, "CAN_COLLIDE"]; c moveInCargo truck;
d = grp createUnit ["Ins_Soldier_1", (getMarkerPos 'spwn'), [], 0, "CAN_COLLIDE"]; d moveInCargo truck;
e = grp createUnit ["Ins_Soldier_1", (getMarkerPos 'spwn'), [], 0, "CAN_COLLIDE"]; e moveInCargo truck;
f = grp createUnit ["Ins_Soldier_1", (getMarkerPos 'spwn'), [], 0, "CAN_COLLIDE"]; f moveInCargo truck;
g = grp createUnit ["Ins_Soldier_1", (getMarkerPos 'spwn'), [], 0, "CAN_COLLIDE"]; g moveInCargo truck;
h = grp createUnit ["Ins_Soldier_1", (getMarkerPos 'spwn'), [], 0, "CAN_COLLIDE"]; h moveInCargo truck;

[_grp, 2] setWaypointType "HOLD";

mg1 = trk addWaypoint [getMarkerPos 'wp_1', 0];
mg1 setWaypointType "TR UNLOAD";
mg1 setWaypointCombatMode "RED";
mg1 setWaypointBehaviour "SAFE";
mg1 setWaypointSpeed "FULL";
MG1 setWaypointStatements ["true", "unassignVehicle c; unassignVehicle d; unassignVehicle e; unassignVehicle f; unassignVehicle g; unassignVehicle h"];

mg2 = grp addWaypoint [getMarkerPos 'Z1', 0];
mg2 setWaypointType "SAD";
mg2 setWaypointCombatMode "RED";
mg2 setWaypointBehaviour "COMBAT";
mg2 setWaypointSpeed "FULL";

};

Share this post


Link to post
Share on other sites

0. initialisation

if !(isServer) exitwith {};

rather than if (isServer) then {...};

1. (getMarkerPos "spwn") select 0

maybe try

(getMarkerPos "spwn" select 0)

or even at the top of the script

_pos = getMarkerPos "spwn";

then use

(_pos select 0) etc further down

2. also

[], 0, "CAN_COLLIDE"];

the 0 here is the radius, so youre spawning all the units in each other

maybe try changing this 0 to 20 to reduce people getting killed by the trucks

3. typo

CANCOLIDE

should be

CANCOLLIDE

4. variables localiity

c = grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn") select 0,(getMarkerPos "spwn") select 1,0], [], 0, "CANCOLIDE"];

c moveInCargo truck;

try localising the variables:

_c = _grp createUnit ["Ins_Soldier_1", etc

_c moveInCargo _truck; etc

5. assignation

_a = _grp createUnit ["Ins_Soldier_1", [(_pos select 0),(_pos select 1),0], [], 20, "CANCOLLIDE"];

_a assignasdriver _truck;

_a moveIndriver _truck;

_c = _grp createUnit ["Ins_Soldier_1", [(_pos select 0),(_pos select 1),0], [], 20, "CANCOLLIDE"];

_c assignascargo _truck;

_C moveInCargo _truck;

p.s. anyone in my clan who says they want to help edit missions - I always say go write a simple script that creates a convoy and moves it from A to B - as a learning exercise - before they try to do anything complicated. this is a vital first lesson in scripting, and everyone has to learn it. it takes a lot of understanding to get even this simple process right.

good luck man

Edited by eggbeast

Share this post


Link to post
Share on other sites

OK made it like this:

if !(isServer) exitWith {};

_autak = createVehicle ["V3S_Civ", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 0, "CANCOLLIDE"];
_trk = CreateGroup EAST;     
_ridic = _trk createUnit ["Ins_Woodlander1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 5, "CANCOLLIDE"]; 
_ridic assignAsdriver _autak;
_ridic moveInDriver _autak;

_grp = CreateGroup EAST;     
_c = _grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_d = _grp createUnit ["Ins_Soldier_GL", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_e = _grp createUnit ["Ins_Soldier_AR", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_f = _grp createUnit ["Ins_Soldier_2", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_g = _grp createUnit ["Ins_Soldier_Medic", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_h = _grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 

_c assignasCargo _autak;
_c moveInCargo _autak;
_d assignasCargo _autak;
_d moveInCargo _autak;
_e assignasCargo _autak;
_e moveInCargo _autak;
_f assignasCargo _autak;
_f moveInCargo _autak;
_g assignasCargo _autak;
_g moveInCargo _autak;
_h assignasCargo _autak;
_h moveInCargo _autak;

_mg1 = _trk addWaypoint [getMarkerPos "wp_1",0 ]; 
_mg1 setWaypointType "TR UNLOAD" ;  
_mg1 setWaypointCombatMode "RED";
_mg1 setWaypointBehaviour "SAFE";
_mg1 setWaypointSpeed "FULL"; 
_mg1 setWaypointStatements ["true", "unassignVehicle c; unassignVehicle d; unassignVehicle e; unassignVehicle f; unassignVehicle g; unassignVehicle h"];

_mg2 = _grp addWaypoint [getMarkerPos "z1",0 ]; 
_mg2 setWaypointType "SAD" ;  
_mg2 setWaypointCombatMode "RED";
_mg2 setWaypointBehaviour "COMBAT";
_mg2 setWaypointSpeed "FULL";

And it works except the grp guys doesnt getout from the truck at the mg1 waypoint.

BUt you are still awesom guys, at least it spawns them now.

Edited by Mirek

Share this post


Link to post
Share on other sites

ah yeah i was gonna say, those waypoint types tend to break.

maybe try:

[_grp, 1] setWaypointType "GETOUT";

to shorten stuff you can also do this:

{_X assignascargo _autak; _X moveincargo _autak} foreach (units _grp);

I would also have a body control system in there

{_x addEventHandler ["killed", {handle = [_this select 0] execVM "bury.sqf"}]} forEach (units _grp);

_autak addEventHandler ["killed", {handle = [_this select 0] execVM "bury.sqf"}];

bury:

// Deletes dead Enemy

_unit = _this select 0;

if (not (_unit isKindOf "Man")) then

{

{_x setpos position _unit} forEach crew _unit;

sleep 300.0;

deletevehicle _unit;

};

if (_unit isKindOf "Man") then

{

if(not ((vehicle _unit) isKindOf "Man")) then {_unit setpos (position vehicle _unit)} ;

sleep 310.0;

hideBody _unit;

};

also a tip on filling cargo for any truck or jeep

you send your vehicle _vec to the script here

_vec = _this select 0;

_grp = creategroup east; (or you can use _side and send this to the script at start)

_pos = position _vec;

_npos = [(_pos select 0) + (random 10), (_pos select 1)+(random 10), (_pos select 2)];

_type = typeof _vec;

_maxcrew = getNumber (configFile >> "CfgVehicles" >> _type >> "transportSoldier");

_crewtype = getArray (configFile >> "CfgVehicles" >> _type >> "typicalCargo");

_maxc = (count _crewtype)-1;

if (_maxc <1) then

{

_crewtype = EGG_EVO_meguardc; //defined in init.sqf as EGG_EVO_meguardc = ["Ins_Soldier_1","Ins_Soldier_GL","Ins_Soldier_AR","Ins_Soldier_2","Ins_Soldier_Medic"];

_maxc = (count _crewtype)-1;

};

if (_maxcrew > 0) then

{

_n = 0;

while {_n < _maxcrew} do

{

_unit = _grp createUnit [(_crewtype select round random _maxc), _npos, [], 5, "NONE"];

_unit assignAsCargo _vec;

_unit moveinCargo _vec;

_n = _n+1;

Sleep 0.1;

};

};

i use this in my evo missions to create full enemy APC's, so you shoot the tracks and 10 guys get out going mental.

Edited by eggbeast

Share this post


Link to post
Share on other sites

After reading tons of useless wikipedia articles and forum threads, finally gave up on that transport. Soldiers will spawn much closer and will advance on foot.

if !(isServer) exitWith {};


_grp = CreateGroup EAST;     
_c = _grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_d = _grp createUnit ["Ins_Soldier_GL", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_e = _grp createUnit ["Ins_Soldier_AR", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_f = _grp createUnit ["Ins_Soldier_2", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_g = _grp createUnit ["Ins_Soldier_Medic", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_h = _grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_i = _grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_j = _grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_k = _grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 
_l = _grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"]; 


_mg1 = _grp addWaypoint [getMarkerPos "wp_1",0 ]; 
_mg1 setWaypointType "MOVE" ;  
_mg1 setWaypointCombatMode "RED";
_mg1 setWaypointBehaviour "AWARE";
_mg1 setWaypointSpeed "FULL";
_mg1 setWaypointFormation "LINE";

_mg2 = _grp addWaypoint [getMarkerPos "z1",0 ]; 
_mg2 setWaypointType "SAD" ;  
_mg2 setWaypointCombatMode "RED";
_mg2 setWaypointBehaviour "COMBAT";
_mg2 setWaypointSpeed "FULL";

Thank you for trying, but it seems to me that iam not supposed to get the original idea working.

Edited by Mirek

Share this post


Link to post
Share on other sites

try making them all the same group, not having separate driver. you're 99% done.

it works fine in evo all the time, every day of the year...

Share this post


Link to post
Share on other sites

Re. post #4. Problem is, you are creating units with names like "_c", as in...

_c = _grp createUnit ["Ins_Soldier_1", [(getMarkerPos "spwn" select 0),(getMarkerPos "spwn" select 1),0], [], 20, "CANCOLLIDE"];

...but you are applying unassignVehicle to units with names like "c".

_mg1 setWaypointStatements ["true", "unassignVehicle c; unassignVehicle d; unassignVehicle e; unassignVehicle f; unassignVehicle g; unassignVehicle h"];

Replace the above line with...

_mg1 setWaypointStatements ["true", "unassignVehicle _c; unassignVehicle _d; unassignVehicle _e; unassignVehicle _f; unassignVehicle _g; unassignVehicle _h"];

...and see how you get on. It should work as per your original intent, and you will be able to have the vehicle unloading where you want it to, and not have to rely only on enemies on foot.

Share this post


Link to post
Share on other sites

Thanks guys i just let the enemy go on foot.

But i made this for my reinforcements:

if !(isServer) exitWith {};

_tigr = createVehicle ["Mi24_D_CZ_ACR", [(getMarkerPos "copter" select 0),(getMarkerPos "copter" select 1),0], [], 0, "CANCOLLIDE"];
_podpora = CreateGroup WEST;     
_pilot = _podpora createUnit ["CZ_Soldier_Pilot_Wdl_ACR", [(getMarkerPos "copter" select 0),(getMarkerPos "copter" select 1),0], [], 20, "CANCOLLIDE"]; 
_strelec = _podpora createUnit ["CZ_Soldier_Pilot_Wdl_ACR", [(getMarkerPos "copter" select 0),(getMarkerPos "copter" select 1),0], [], 20, "CANCOLLIDE"];
_pilot assignAsdriver _tigr;
_pilot moveInDriver _tigr;
_strelec assignAsgunner _tigr;
_strelec moveIngunner _tigr;

_autak = createVehicle ["T810A_MG_ACR", [(getMarkerPos "auto" select 0),(getMarkerPos "auto" select 1),0], [], 0, "CANCOLLIDE"];
_posila = CreateGroup WEST;     
_c = _posila createUnit ["CZ_Soldier_Leader_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 
_d = _posila createUnit ["CZ_Soldier_MG_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 
_e = _posila createUnit ["CZ_Soldier_Medic_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 
_f = _posila createUnit ["CZ_Soldier_MG2_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 
_g = _posila createUnit ["CZ_Sharpshooter_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 
_h = _posila createUnit ["CZ_Soldier_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 
_i = _posila createUnit ["CZ_Soldier_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 
_j = _posila createUnit ["CZ_Soldier_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 
_k = _posila createUnit ["CZ_Soldier_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 
_l = _posila createUnit ["CZ_Soldier_Wdl_ACR", [(getMarkerPos "posily" select 0),(getMarkerPos "posily" select 1),0], [], 20, "CANCOLLIDE"]; 


_wp1 = _posila addWaypoint [getMarkerPos "auto",0 ]; 
_wp1 setWaypointType "GETIN NEAREST" ;  
_wp1 setWaypointCombatMode "RED";
_wp1 setWaypointBehaviour "SAFE";
_wp1 setWaypointSpeed "FULL";

_wp2 = _posila addWaypoint [getMarkerPos "disembark",0 ]; 
_wp2 setWaypointType "GETOUT" ;  
_wp2 setWaypointCombatMode "RED";
_wp2 setWaypointBehaviour "SAFE";
_wp2 setWaypointSpeed "FULL";

_wp3 = _posila addWaypoint [getMarkerPos "z1",0 ]; 
_wp3 setWaypointType "SAD" ;  
_wp3 setWaypointCombatMode "RED";
_wp3 setWaypointBehaviour "COMBAT";
_wp3 setWaypointSpeed "FULL";

_mg2 = _podpora addWaypoint [getMarkerPos "z1",0 ]; 
_mg2 setWaypointType "SAD" ;  
_mg2 setWaypointCombatMode "RED";
_mg2 setWaypointBehaviour "COMBAT";
_mg2 setWaypointSpeed "FULL";

it works perfectly. Actually is what Eggbeast suggesting. but ill definitely try the Jameses way next time.

Edited by Mirek

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  

×