Jump to content
roy86

Spawn Aircraft Carrier 'USS Freedom' Jets DLC

Recommended Posts

Useful tip

To spawn the new Jets DLC carrier via a script is the same as creating any other vehicle. However, to orientate or reposition it, the object will not update once spawned like other standard vehicles as the carrier is multiple objects. To update the position, direction and pitchbank, there is a new function: BIS_fnc_Carrier01PosUpdate;

 

To spawn the carrier:

private _carrier = createVehicle ["Land_Carrier_01_base_F",<position>,[],0,"None"];

To set its direction or to shift the carrier's position via a script, update the original object's attributes then run the function BIS_fnc_Carrier01PosUpdate:

_carrier setPosWorld <position>;
_carrier setDir <degree>;
[_carrier] call BIS_fnc_Carrier01PosUpdate;

The carrier will now be aligned to its base.

 

Example Singleplayer

Spoiler

private _carrier = createVehicle ["Land_Carrier_01_base_F",[10,50,0],[],0,"None"];
_carrier setDir 45;
[_carrier] call BIS_fnc_Carrier01PosUpdate;

 

 

Example Multiplayer - Working Catapults Tested!! 

Spoiler

if (isServer) then {
	// Spawn Carrier on Server
	private _carrier = createVehicle ["Land_Carrier_01_base_F",getMarkerPos "marker_0",[],0,"None"];
	_carrier setPosWorld getMarkerPos "marker_0";
	_carrier setDir 270;
	[_carrier] call BIS_fnc_Carrier01PosUpdate;

	// Broadcast Carrier ID over network
	missionNamespace setVariable ["USS_FREEDOM_CARRIER",_carrier]; publicVariable "USS_FREEDOM_CARRIER";
} else {
	[] spawn {
		// Clients wait for carrier
		waitUntil { !(isNull (missionNamespace getVariable ["USS_FREEDOM_CARRIER",objNull])) };

		// Work around for missing carrier data not being broadcast as expected
		if (count (USS_FREEDOM_CARRIER getVariable ["bis_carrierParts", []]) == 0) then {
			["Carrier %1 is empty. Client Fixing.",str "bis_carrierParts"] call BIS_fnc_logFormatServer;
			private _carrierPartsArray = (configFile >> "CfgVehicles" >> typeOf USS_FREEDOM_CARRIER >> "multiStructureParts") call BIS_fnc_getCfgDataArray;
			private _partClasses = _carrierPartsArray apply {_x select 0};
			private _nearbyCarrierParts = nearestObjects [USS_FREEDOM_CARRIER,_partClasses,500];
			{
				private _carrierPart = _x;
				private _index = _forEachIndex;
				{
					if ((_carrierPart select 0) isEqualTo typeOf _x) exitWith { _carrierPart set [0,_x]; };
				} forEach _nearbyCarrierParts;
				_carrierPartsArray set [_index,_carrierPart];
			} forEach _carrierPartsArray;
			USS_FREEDOM_CARRIER setVariable ["bis_carrierParts",_nearbyCarrierParts];
			["Carrier %1 was empty. Now contains %2.",str "bis_carrierParts",USS_FREEDOM_CARRIER getVariable ["bis_carrierParts", []]] call BIS_fnc_logFormatServer;
		};

		// Client Initiate Carrier Actions with slight delay to ensure carrier is sync'd
		[USS_FREEDOM_CARRIER] spawn { sleep 1; _this call BIS_fnc_Carrier01Init};
	};
};

 

 

Cheers,

  • Like 12

Share this post


Link to post
Share on other sites

Good for letting us now, thanks!

Also a reminder for self to look through the built in functions after every other update.

 

Cheers

Share this post


Link to post
Share on other sites

Thanks for figuring this out and putting it out!

Share this post


Link to post
Share on other sites

Thanks for info.

 

So.. player allowdamage false and you can try walk on it :) I hope they will fix bugs.

 

btw. catapult doesn't works yet :(

Share this post


Link to post
Share on other sites
8 minutes ago, riten said:

Thanks for info.

 

So.. player allowdamage false and you can try walk on it :) I hope they will fix bugs.

 

btw. catapult doesn't works yet :(

lol works ok for me. Been testing it for PO4. Couple of quirks but BO1 and BIS have a little time to iron those out.

Share this post


Link to post
Share on other sites
7 minutes ago, roy86 said:

lol works ok for me. Been testing it for PO4. Couple of quirks but BO1 and BIS have a little time to iron those out.

 

That's correct it was my fault, i was just pressing space instead of holding it ;) Catapult works.

Share this post


Link to post
Share on other sites
4 minutes ago, riten said:

 

That's correct it was my fault, i was just pressing space instead of holding it ;) Catapult works.

Ahh yeah, i fell for that too. Wish the elevators did and had a bit more interior but still, its shaping up to be a good DLC.

Share this post


Link to post
Share on other sites

A quick hack

_nul0 = [] spawn { 
	private _startPos = getMarkerPos "marker_0"; // Place a marker
	private _startDir = 90; // Heading East

	private _carrier = createVehicle ["Land_Carrier_01_base_F",_startPos,[],0,"None"]; 

	while {true} do {
		_startPos = _startPos getPos [0.2,_startDir];
		_carrier setPosWorld ASLToATL _startPos;
		_carrier setDir (_startDir - 180);
		[_carrier] call BIS_fnc_Carrier01PosUpdate;
	}; 
};
  • Like 1

Share this post


Link to post
Share on other sites
On 4/21/2017 at 9:03 PM, roy86 said:

Useful tip

To spawn the new Jets DLC carrier via a script is the same as creating any other vehicle. However, to orientate or reposition it, the object will not update once spawned like other standard vehicles as the carrier is multiple objects. To update the position, direction and pitchbank, there is a new function: BIS_fnc_Carrier01PosUpdate;

 

To spawn the carrier:


private _carrier = createVehicle ["Land_Carrier_01_base_F",<position>,[],0,"None"];

To set its direction or to shift the carrier's position via a script, update the original object's attributes then run the function BIS_fnc_Carrier01PosUpdate:


_carrier setPosWorld <position>;
_carrier setDir <degree>;
[_carrier] call BIS_fnc_Carrier01PosUpdate;

The carrier will now be aligned to its base.

 

Cheers,

 

So I could use:

private _carrier = createVehicle ["Land_Carrier_01_base_F",<position>,[],0,"None"];

In an sqf file to spawn the carrier in my server?

 

I assume with the position it would look like this:

 

private _carrier = createVehicle ["Land_Carrier_01_base_F",507.486,14504.5,0,[],0,"None"];

 

Thank you.

Share this post


Link to post
Share on other sites

Close, you need brackets around your position.  See: https://community.bistudio.com/wiki/createVehicle

 

And if you're hosting MP, wrap the code in isServer

if (isServer) then {
	private _carrier = createVehicle ["Land_Carrier_01_base_F",[507.486,14504.5,0],[],0,"NONE"];
	// rest of code....
};

Share this post


Link to post
Share on other sites
13 hours ago, roy86 said:

Close, you need brackets around your position.  See: https://community.bistudio.com/wiki/createVehicle

 

And if you're hosting MP, wrap the code in isServer


if (isServer) then {
	private _carrier = createVehicle ["Land_Carrier_01_base_F",[507.486,14504.5,0],[],0,"NONE"];
	// rest of code....
};

 

Thank you, roy86 

 

Would this work running it from my mission init.sqf file?

 

I already have:

if(hasInterface) then{
[] execVM "addons\service_point\service_point.sqf";
};

in my init.sqf

 

I guess I could just add the carrier line to that.

 

I also have a script running serverside that has code like this:

_pos = [11898.6,13059.9,0];
_object = createVehicle ["Land_cargo_addon02_V2_F", _pos, [], 0, "CAN_COLLIDE"];
_object setDir 0.0;
_object setPosATL _pos;




_pos = [11876.1,13074.5,0];
_object = createVehicle ["Land_HelipadCivil_F", _pos, [], 0, "CAN_COLLIDE"];
_object setDir 0.0;
_object setPosATL _pos;




_pos = [11905,13059.7,0];
_object = createVehicle ["MetalBarrel_burning_F", _pos, [], 0, "CAN_COLLIDE"];
_object setDir 0.0;
_object setPosATL _pos;

Could I add the line to this as an alternative?

 

The reason I ask is because I'd like the carrier to spawn in as early as possible so vehicles don't fall into the water at restart.

 

What would you suggest?

 

Thanks again.

Share this post


Link to post
Share on other sites

Yep, just add it to either and it should be ok, as long as it is server side ;)

 

  • Like 1

Share this post


Link to post
Share on other sites
38 minutes ago, roy86 said:

Yep, just add it to either and it should be ok, as long as it is server side ;)

 

 

Thank you.

 

Hopefully tomorrow I'll be able to add it. )

Share this post


Link to post
Share on other sites

Hi

 

Tried some variations to that code to get the USS Freedom carrier to spawn on a Wasteland Server.

 

Gives me errors. I tried adding it to init.sqf

Tried this

 

if (isServer) then {
    private _carrier = createVehicle ["Land_Carrier_01_base_F",[11244.858,11248.437,0],[],0,"NONE"];
 

    _carrier setPosWorld;
    _carrier setDir;
    [_carrier] call BIS_fnc_Carrier01PosUpdate;
};

 

and this with co-ordinates.

 

if (isServer) then {
    private _carrier = createVehicle ["Land_Carrier_01_base_F",[11244.858,11248.437,0],[],0,"NONE"];
 

    _carrier setPosWorld [11244.858,11248.437,0];
    _carrier setDir [0,5.5152407,0];
    [_carrier] call BIS_fnc_Carrier01PosUpdate;
};

 

Am i missing something .Are co-ordinates in wrong format ?

 

Thanks in advance

 

Zeus

Share this post


Link to post
Share on other sites
1 hour ago, gszeus said:

Hi

 

Tried some variations to that code to get the USS Freedom carrier to spawn on a Wasteland Server.

 

Gives me errors. I tried adding it to init.sqf

Tried this

 

if (isServer) then {
    private _carrier = createVehicle ["Land_Carrier_01_base_F",[11244.858,11248.437,0],[],0,"NONE"];
 

    _carrier setPosWorld;
    _carrier setDir;
    [_carrier] call BIS_fnc_Carrier01PosUpdate;
};

 

and this with co-ordinates.

 

if (isServer) then {
    private _carrier = createVehicle ["Land_Carrier_01_base_F",[11244.858,11248.437,0],[],0,"NONE"];
 

    _carrier setPosWorld [11244.858,11248.437,0];
    _carrier setDir [0,5.5152407,0];
    [_carrier] call BIS_fnc_Carrier01PosUpdate;
};

 

Am i missing something .Are co-ordinates in wrong format ?

 

Thanks in advance

 

Zeus

You're not using the commands correctly.

 

setPosWorld needs [x,y,z] see: https://community.bistudio.com/wiki/setPosWorld

setDir is a number - see: https://community.bistudio.com/wiki/setDir

 

It should look something like:

if (isServer) then {
    private _carrier = createVehicle ["Land_Carrier_01_base_F",[11244.858,11248.437,0],[],0,"NONE"];
    _carrier setPosWorld [11244.858,11248.437,0]; // [x,y,z] or positionWorld
    _carrier setDir 0; // North
    [_carrier] call BIS_fnc_Carrier01PosUpdate;
};

 

Share this post


Link to post
Share on other sites
5 minutes ago, roy86 said:

You're not using the commands correctly.

 

setPosWorld needs [x,y,z] see: https://community.bistudio.com/wiki/setPosWorld

setDir is a number - see: https://community.bistudio.com/wiki/setDir

 

It should look something like:


if (isServer) then {
    private _carrier = createVehicle ["Land_Carrier_01_base_F",[11244.858,11248.437,0],[],0,"NONE"];
    _carrier setPosWorld [11244.858,11248.437,0]; // [x,y,z] or positionWorld
    _carrier setDir 0; // North
    [_carrier] call BIS_fnc_Carrier01PosUpdate;
};

 

 

Fantastic ..

Thanks Roy86, I will try this in a few mins and restart the server and see what happens.

 

Will keep you posted. Thanks again.

 

Zeus

Share this post


Link to post
Share on other sites

No worries, I've added three examples in the first post to show exactly how to do it through different methods,

 

cheers,

Share this post


Link to post
Share on other sites
35 minutes ago, roy86 said:

No worries, I've added three examples in the first post to show exactly how to do it through different methods,

 

cheers,

 

Just confirming .

Works well.. Landed on the ship. Went inside all good.

 

Thanks again for the code.

 

Zeus

  • Like 1

Share this post


Link to post
Share on other sites
On 5/16/2017 at 3:17 PM, roy86 said:

 

It should look something like:


if (isServer) then {
    private _carrier = createVehicle ["Land_Carrier_01_base_F",[11244.858,11248.437,0],[],0,"NONE"];
    _carrier setPosWorld [11244.858,11248.437,0]; // [x,y,z] or positionWorld
    _carrier setDir 0; // North
    [_carrier] call BIS_fnc_Carrier01PosUpdate;
};

 

 

I used this and it works perfect.

 

Thanks again, roy86

Share this post


Link to post
Share on other sites
On 17/5/2017 at 0:23 AM, gszeus said:

 

Just confirming .

Works well.. Landed on the ship. Went inside all good.

 

Thanks again for the code.

 

Zeus

 

 

Hi Roy86, would you know if the catapult system works on this ship as per using the code we spoke about above?  I have landed a fighter on the ship and it does appear the cables do slow you down. But when i drive the plane to the start of the catapult it gives me no options to attach or launch with it.

 

Also the weapon systems do not appear on the ship. am I meant to be adding them separately?

 

Zeus

Share this post


Link to post
Share on other sites
25 minutes ago, gszeus said:

 

 

Hi Roy86, would you know if the catapult system works on this ship as per using the code we spoke about above?  I have landed a fighter on the ship and it does appear the cables do slow you down. But when i drive the plane to the start of the catapult it gives me no options to attach or launch with it.

 

Also the weapon systems do not appear on the ship. am I meant to be adding them separately?

 

Zeus

Can't say I've had a problem with the functions of the ship yet. Catapults work fine as well as the cables slowing down.

 

the defenses are separate objects that need to placed on to the carrier. If someone gets me the offset positions I can write a script to place them.

Share this post


Link to post
Share on other sites

Hi Roy86

I was looking through the editor and see several functions including one called carrier01Init. which says the following

"

Description:
 - This is a main function designed to assemble dynamic aircraft carrier. Carrier consists of multiple sub-objects that are linked together based on precise memory point positions in 3D space.

"

Some other functions appear in there too. But no idea how to get them to work.

 

Zeus

 

Just to add. spawning the ship in the editor and putting a plane on it works. So does the scripts for launching the plane with the catapults . So guess I need to add the functions somehow ?

Share this post


Link to post
Share on other sites

carrier01Init is automatically executed when the carrier spawns. That is how all the object segments of the carrier get put together. If you see the carrier in game, it means that script has executed already. You should not need to do anything.

 

How are you spawning the carrier exactly?

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

×