Jump to content
Sign in to follow this  
Socrate

Paratrooper Stupid Issue

Recommended Posts

I'm writing a basic paratrooper script...ok nothing new but i can't understand why the eject action works only if the soldier i order this action is created in the editor and it doesn't if i create the unit with createUnit...the code is here

_pilot = nil;
_pilot2 = nil;
_soldier = nil;

_chopper = "MH60S" createVehicle (getMarkerPos "createPos1");
_westHQ = createCenter West;
_grp1 = createGroup _westHQ;
_grp2 = createGroup _westHQ;
"USMC_Soldier_Pilot" createUnit[getMarkerPos "createPos2",_grp1,"_pilot = this"];
"USMC_Soldier_Pilot" createUnit[getMarkerPos "createPos2",_grp1,"_pilot2 = this"];
"USMC_Soldier" createUnit[getMarkerPos "createPos2",_grp2,"_soldier = this"];

_pilot moveInDriver _chopper;
_pilot2 moveInCargo _chopper;
_soldier moveInCargo _chopper;

_chopper flyInHeight 150;

_wp = _grp1 addWaypoint [getMarkerPos "jumpPos", 0];

_trg = createTrigger["EmptyDetector",getMarkerPos "jumpPos"];
_trg setTriggerArea [100, 100, 1, false ];
_trg setTriggerActivation ["WEST","PRESENT",true];
_trg setTriggerStatements ["this", "{_x action ['EJECT',vehicle _x];unassignVehicle _x;}forEach in Units _grp2;",""];

Some info:

1) i've two trigger set as the spawn position of the chopper and the soldiers

2) i've a trigger names jumpPos for the position where the soldier must to jump out

3) i create a trigger and the main command is

{_x action ['EJECT',vehicle _x];unassignVehicle _x;}forEach in Units _grp2;

Share this post


Link to post
Share on other sites
_trg setTriggerStatements ["this", "{_x action ['EJECT',vehicle _x];unassignVehicle _x;}forEach in Units _grp2;",""];

{_x action ['EJECT',vehicle _x];unassignVehicle _x;}forEach in Units _grp2;

Have you checked that the _grp2 is actually replaced in the trigger statement command? I have a feeling it's not, without running it through format at least. So, the trigger is trying to refer to a local variable _grp2 from outside the script.

Edited by Shuko

Share this post


Link to post
Share on other sites
Have you checked that the _grp2 is actually replaced in the trigger statement command? I have a feeling it's not, without running it through format at least. So, the trigger is trying to refer to a local variable _grp2 from outside the script.

mm i'm not sure if i got it right...are you saying that the _grp2 variable doesn't refere to the one declered before and filled with the createGroup command?

Share this post


Link to post
Share on other sites

You're trying to call local variables (_grp2) in a global setting (trigger statements). You need to refer to them from the start globally so that when looked for by the trigger it knows what you're talking about.

Here's your script re-written to use BIS functions, BIS_fnc_spawnVehicle for the helo and BIS_fnc_spawnGroup for the AI to drop. Less lines of code (even including the 4 "config" lines :p), and it deletes the helo after the drop. It also checks for when the helo hits the trigger, not just BLUFOR. Just make sure you place a delete marker for it to fly to and place the Functions module on your map somewhere.

_startPoint = "createPos";
_dropPoint = "jumpPos";
_deletePoint = "deletePos";
_groupType = "USMC_FireTeam_MG";

_grpHelo = creategroup west;
_chopperSpawn = [[(getMarkerPos _startPoint) select 0, (getMarkerPos _startPoint) select 1, 150], 270, "MH60S", _grpHelo] call BIS_fnc_spawnVehicle;
chopper = _chopperSpawn select 0;

dropGroup = [getMarkerPos _dropPoint, side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> _groupType)] call BIS_fnc_spawnGroup;

{_x moveInCargo chopper;} forEach units dropGroup;

_wp = _grpHelo addWaypoint [getMarkerPos _dropPoint, 0];
_wp2 = _grpHelo addWaypoint [getMarkerPos _deletePoint, 0];
[_grpHelo, 2] setWaypointStatements ["true", "{deleteVehicle _x} forEach crew chopper; deletevehicle chopper;"];	

_trg = createTrigger["EmptyDetector",getMarkerPos _dropPoint];
_trg setTriggerArea [100, 100, 0, false ];
_trg setTriggerActivation ["WEST","PRESENT",false];
_trg setTriggerStatements ["chopper in thislist", "{unassignVehicle _x; _x action ['EJECT', vehicle _x];} forEach units dropGroup;",""];

Share this post


Link to post
Share on other sites

thank you kilania,

so it was a scope problem basicly if i declare global the groups and the chopper i create my script should work, right?

Hwr i'm really interested in the function you wrote in your script! where can i found more info about them?

Btw in my script i created the groups with local variable cause the script was meant to be executed only by the server and i read somewhere that the unit are local to the machine who create them (so in my example of the server)..i'm interested in seeing how this function of bis works with locality...

one last question: which is the locality of the trigger i created? i thought it was of the machine who created it..in fact i thought that in the on activation field i could use local variables...

i hope that someone can clean a little my mess with locality and variable scope...

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  

×