Jump to content
Sign in to follow this  
Cornish Rebel

Need help with a FOB transport script

Recommended Posts

Making a mission where I want to build my own FOB in one location in the editor, but be able to load it into a truck and then deploy it in another location in the mission.

Is there any help or suggestions? would be gratefully appreciated, thanks in advanced.

Share this post


Link to post
Share on other sites

Thanks for the wiki link.

So I should be able to script it to load a custom composition into a truck and unload it? so its the same layout?

Share this post


Link to post
Share on other sites

Once again, something I was unaware of completely, now revealed thanks to kylania - we are lucky to have your att'n on this board!

So this functionality is really only useful for spawning objects while the mission is in-progress right, they are all accessible within the editor as well right? My process for SP missions involves placing just about everything there from the get-go, but I can see how this would be a useful technique in Cornish Rebel's case.

Share this post


Link to post
Share on other sites

You'd create a custom composition with the items you want. Then you'll spawn it when you want to place it and remove the ability to place a new one. To 'pack it back up' you'd delete everything and somehow indicate that you can place it again.

These are certainly available in single player as well. While you can't place them in the editor, you can place down a gamelogic where you want it and call it from the init and it'll be placed there. So in preview you'll see it, but not on the editor map really.

Share this post


Link to post
Share on other sites
You'd create a custom composition with the items you want. Then you'll spawn it when you want to place it and remove the ability to place a new one. To 'pack it back up' you'd delete everything and somehow indicate that you can place it again.

I've got to the stage where I can spawn a custom composition around a flag pole, and remove ability to spawn another, but I'm finding it hard to work out a way to delete the old composition when another spawns, and have no idea how to script it or reverse the objectmapper to delete it

Share this post


Link to post
Share on other sites

objectMapper.sqf will return a list of objects created. Store that list of objects somewhere (e.g. in MyFOB), and with {deletevehicle _x} forEach MyFOB you should be able to remove the objects again when you need to remove the FOB again.

Share this post


Link to post
Share on other sites

It may be better to use Createcomposition.sqf though, at the end of the script there is this line. Actually that may be the same program as onbjectmapper.

_newObjs = _newObjs + [_newObj];

I'd leave that alone but create a new variable right after it so that you can use in other scripts or trigger

newObjN =[];
newObjsN = newObjsN + [_newObj];

then in your new script or trigger

{deletevehicle _x} forEach  newObjsN;

I've use something like this on it before and even had it creating soldiers and deleting them and the objects when needed.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thanks for the help all, got it working.

But a problem I've ran into now, is that when the vehicle that is used for spawning the composition is destroyed, the variable name of the vehicle needs to be defined but cant seem where or how to put it in my vehicle respawn script.

Vehicle respawn script is this:-

if (!isServer) exitWith {};

sleep 1+(random 3);

_v = _this select 0;

_pos = getpos _v;

_dir = direction _v;

_type = typeOf _v;

waitUntil {not alive _v};

sleep 30;

deleteVehicle _v;

_v =_type createVehicle _pos;

_v setdir _dir;

_v setpos _pos;

[_v] execVM "scripts\vrs.sqf";

sleep 1

New to this scripting, sorry ^^

Share this post


Link to post
Share on other sites
Use Tophe's respawn script. :)

I was looking at that and I think I may have to use it, was hoping to learn how to put what I wanted into a script though, so I can build scripts for myself later on.

Its abit to advanced for me to look at it and see what I need out of it to put in my own,lol.

But I guess I'll have to go use it.

---------- Post added at 21:45 ---------- Previous post was at 21:32 ----------

Use Tophe's respawn script. :)

Tested it, it works perfectly, just need to try it in MP now.

Share this post


Link to post
Share on other sites

One reason I mentioned that one is that it has an option for that with the code, this part:

{_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
processInitCommands;};

Share this post


Link to post
Share on other sites
One reason I mentioned that one is that it has an option for that with the code, this part:

{_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
processInitCommands;};

Yeah I tried grabbing it and adjusting to my script, but I got to annoyed at trying to get it to work,lol

---------- Post added at 22:25 ---------- Previous post was at 21:49 ----------

Ok got a problem in MP, SP all works find.

Got and engineering array in the init.

Then execultes eng_menu.sqf which is basic at the moment because of testing reasons

But the objects used are:-

FOB = a flag pole used to spawn the composition

u1 = a supply truck used to spawn "FOB" flag pole

ustele = a teleport flagpole at main base/original spawn area used to get distance from base as well

The problem is when I teleport the FOB flag to the u1 supply truck it is supposed to create the composition, in the editor it does that....But when exported to MP and used on a dedicated server it just teleports the FOB flagpole and doesn't create the composition.

eng_menu.sqf:-

_eng = eng;

_ps = playerSide;

_p = player;

if ((_ps == WEST) && (_p in _eng)) then

{

_p addAction ["Load FOB","base\w_l_fob.sqf"];

_p addAction ["Unload FOB","base\w_d_fob.sqf"];

};

"Load FOB" moves the flag to an area way off map called safe:-

_p = player;

if ((FOB distance ustele <= 2100) && (_P distance u1 <= 10) && (FOB distance u1 <= 50)) then

{

FOB setpos (getpos safe1);

hint format ["Loading FOB"];

{deleteVehicle _X} forEach w_fob;

w_fob = objNull

}

else {

if (_p distance u1 > 10) then

{

hint format ["To far away from truck"]

};

if (FOB distance u1 > 50) then

{

hint format ["Truck is to far away from FOB"]

};

if (FOB distance ustele > 2100) then

{

hint format ["FOB is already loaded"]

};

};

"Unload FOB" is used to set "FOB" flag position and create the composition:-

_d = getdir u1;

_p = player;

if ((ustele distance u1 <= 2000) && (_P distance u1 <= 10) && (FOB distance ustele >= 2000)) then

{

FOB setdir _d+180;

FOB setpos [((getpos u1 select 0)+5),getpos u1 select 1, ((getpos u1 select 2)+0)];

w_fob = ["base\base2", getDir FOB, getPos FOB] execVM "base\base.sqf";

}

else {

if (_p distance u1 >= 10) then

{

hint format ["To far away from truck"]

};

if (FOB distance ustele < 2000) then

{

hint format ["FOB is already deployed"]

};

if (ustele distance u1 > 2000) then

{

hint format ["Can not deploy FOB, to far from base"]

};

};

Below is the script to call and create the composition base\base.sqf:-

/*

Original Script

objectMapper.sqf Author: Joris-Jan van 't Land

* Edited by armatec

* slightly edited by Onkel Bo

Description:

Takes an array of data about a dynamic object template and creates the objects.

Parameter(s):

_this select 0: compositions name - "fuelDepot_us"

_this select 1: Direction in degrees - Number

_this select 2: Location to start

Exsample:

["fuelDepot_us", 0, getpos player] execVM "Createcomposition.sqf";

*/

_script = _this select 0;

_azi = _this select 1;

_pos = _this select 2;

_objs = [];

_objs = call (compile (preprocessFileLineNumbers format ["%1.sqf",_script]));

private ["_posX", "_posY"];

_posX = _pos select 0;

_posY = _pos select 1;

_newObjs = [];

private ["_multiplyMatrixFunc"];

_multiplyMatrixFunc =

{

private ["_array1", "_array2", "_result"];

_array1 = _this select 0;

_array2 = _this select 1;

_result =

[

(((_array1 select 0) select 0) * (_array2 select 0)) + (((_array1 select 0) select 1) * (_array2 select 1)),

(((_array1 select 1) select 0) * (_array2 select 0)) + (((_array1 select 1) select 1) * (_array2 select 1))

];

_result

};

for "_i" from 0 to ((count _objs) - 1) do

{

private ["_obj", "_type", "_relPos", "_azimuth", "_fuel", "_damage","_vehicleinit","_newObj","_name","_action"];

_obj = _objs select _i;

_type = _obj select 0;

_relPos = _obj select 1;

_azimuth = _obj select 2;

if ((count _obj) > 3) then {_fuel = _obj select 3;};

if ((count _obj) > 4) then {_damage = _obj select 4;};

//if ((count _obj) > 5) then {_vehicleinit = _obj select 5;};

if ((count _obj) > 5) then {_name = _obj select 5;};

private ["_rotMatrix", "_newRelPos", "_newPos"];

_rotMatrix =[[cos _azi, sin _azi],[-(sin _azi), cos _azi]];

_newRelPos = [_rotMatrix, _relPos] call _multiplyMatrixFunc;

private ["_z"];

if ((count _relPos) > 2) then {_z = _relPos select 2} else {_z = 0};

_newPos = [_posX + (_newRelPos select 0), _posY + (_newRelPos select 1), _z];

_newObj = _type createVehiclelocal _newPos;

_newObj setDir (_azi + _azimuth);

_newObj setPos _newPos;

if (!isNil "_fuel") then {_newObj setFuel _fuel};

if (!isNil "_damage") then {_newObj setDamage _damage};

//if (!isNil "_vehicleinit") then {_newObj setVehicleInit format ["%1;",_vehicleinit]};

if (!isNil "_name") then {_newObj setVehicleVarName _name; _newObj Call Compile Format ["%1=_this ; PublicVariable ""%1""",_name]};

_newObjs = _newObjs + [_newObj];

};

w_fob = _newObjs;

Edited by Cornish Rebel

Share this post


Link to post
Share on other sites

Ok fixed the problem.

Put some sleep commands in, guessing the flag pole and command to execute the composition needed a break between it.

changed "unload" script from this:-

_d = getdir u1;

_p = player;

if ((ustele distance u1 <= 2000) && (_P distance u1 <= 10) && (FOB distance ustele >= 2000)) then

{

FOB setdir _d+180;

FOB setpos [((getpos u1 select 0)+5),getpos u1 select 1, ((getpos u1 select 2)+0)];

w_fob = ["base\base2", getDir FOB, getPos FOB] execVM "base\base.sqf";

}

else {

if (_p distance u1 >= 10) then

{

hint format ["To far away from truck"]

};

if (FOB distance ustele < 2000) then

{

hint format ["FOB is already deployed"]

};

if (ustele distance u1 > 2000) then

{

hint format ["Can not deploy FOB, to far from base"]

};

};

To this:-

if ((ustele distance u1 <= 2000) && (player distance u1 <= 10) && (FOB distance ustele >= 2000)) then

{

hint format ["FOB will be ready in 10 seconds"];

sleep 5;

FOB setdir ((getdir u1)+180);

FOB setpos [((getpos u1 select 0)+5),getpos u1 select 1, ((getpos u1 select 2)+0)];

sleep 5;

w_fob = ["base\base2", getDir FOB, getPos FOB] execVM "base\base.sqf";

}

else {

if (player distance u1 >= 10) then

{

hint format ["To far away from truck"]

};

if (FOB distance ustele < 2000) then

{

hint format ["FOB is already deployed"]

};

if (ustele distance u1 > 2000) then

{

hint format ["Can not deploy FOB, to far from base"]

};

};

Share this post


Link to post
Share on other sites

Problem again, tested with a friend on a dedicated server see if there was any issues with the player deleting and creating the composition again, and there is.

When game starts the engineers actions work fine for him, he can delete it and recreate it, but its not being sent to clients so the original FOB/composition is there from the start and cant see the new one.

---------- Post added at 01:13 ---------- Previous post was at 00:32 ----------

Ok problem solved I think, removed w_fob = objNull out of the "load fob" script

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  

×