F2k Sel: Fixed being able to attach from a long distance. Only problem I am facing now is that sometimes act1 in act2 doesn't initialize and I end up sticking the jerry can with the player attached to it to the truck.
I also changed the names and added a few comments. I also want to say thanks for being such a big help, any contribution is fine and you have gone far beyond what I expected to be contributed.
Carry
PHP Code:
//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: TODO: Author Name
//////////////////////////////////////////////////////////////////
//init: take=0; act1 = this addaction ["Take Fuel Can","carry.sqf",[0],1,false,true,"","player distance scase < 2"]
//Jerry Can starts at case 0 so first the player can pick it up
switch (take) do
{
//pick up jerry can
case 0:
{
_scase = _this select 0;
_man = _this select 1;
_scase attachto [_man, [-0.23,0,-0.15],"Pelvis"];
_scase setdir 75;
_scase removeAction act1;
act1 = _man addaction ["Drop Jerry Can","carry.sqf","",1,false,true,""];
take=1;scase = _scase;taken=true;
};
case 1:
{
_man = _this select 0;
detach scase;
scase setvelocity[0,0,-.3];
_man removeAction act1;
act1 = scase addaction ["Take Jerry Can","carry.sqf","",1,false,true,""];
take=0;
};
};
Attach
PHP Code:
//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: TODO: Author Name
//////////////////////////////////////////////////////////////////
//init: truck_start addaction ["Refuel truck","fill.sqf","",1,false,true,"","scase distance truck_start <= 5 and player distance truck_start <= 5"];
//act2 = truck_start addaction ["Attach Options","attachtruck.sqf",[1],1,false,true,"","player distance truck_start < 4 and player distance scase < 4"];
player removeAction act1;
switch (take) do
{
//Fasten jerry can to back of truck
case 0:
{
titleText ["Fastening Fuel Can to Truck","PLAIN"];
truck_start removeAction act2;
detach scase;
sleep 5;
scase attachTo [truck_start,[-0.9,-3.1875,-0.5]];
titleText ["Jerry Can is secured","PLAIN"];
truck_start removeAction act2;//remove action so that player doesn't select it again
act2 = scase addaction ["Remove from Truck","attachtruck.sqf","",1,false,true,"","player distance scase < 2"]; //change action for next case
take=1;
};
//Attach Jerry Can to hip after removing jerry can from back of truck
case 1:
{
_man = player
titleText ["Unfastening Fuel Can","PLAIN"];
sleep 5;
detach scase;
sleep 1;
act2 = truck_start addaction ["Attach to back of Truck","attachtruck.sqf","",1,false,true,"player distance truck_start < 2 and player distance scase < 2"];
act1 = _man addaction ["Drop Jerry Can","carry.sqf",[1],1,false,true,"",""];
take=0;
};
};