Jump to content
JCataclisma

[SOLVED] How to board attached static weapons using addAction on a vehicle?

Recommended Posts

Hello, guys!

I have once played in a mission in which player would "automatically" assume the gunner position in one of the specific sentries that were attached to a vehicle, once they clicked "Get in as passenger" for some seats.

In my current case, I'd like the player manning the right static mounted AT when clicking to getin the rear right passenger seat, and manning as a gunner for the HMG by clicking to getIn as the left rear passenger.
I know that, for the NATO Prowler, these are the Cargo4/cargoTurret_04 and Cargo5/cargoTurret_05 seats.

I use the script bellow to successfully attach the desired weapons to a nearby vehicle of the specific class, once I execute an addAction that calls such script.
But I am stuck regarding the eventHandler situation, because when using 'GetIn' I got a "generic error in expression", and by using GetInMan instead, nothing happens - I believe is because the latter one should work only for units and not vehicles.

So it seems the code bellow is the closer I've got so far.
Any suggestions regarding how could I change it so that "Get in as passenger right seat 3" would NOT seat, but man the "_objMidTowerD" turret, and so that "get is passenger left seat 3" would make the player board as gunner for the "_objLeftGun" object?

Cheers!
============
P.s.: currently, I also use the lines
    _currentVehicle lockCargo [4, true];
    _currentVehicle lockCargo [5, true];
, so that nobody can actually seat on those places while the weapons are attached, but I DON'T use these when attempting to use eventHandler.

private _nearbyVehicles = nearestObjects[player, ["Car"], 15];
{
    private _currentVehicle = _x;
    if (typeName _currentVehicle == "OBJECT" && (typeOf _currentVehicle in ["B_T_LSV_01_unarmed_F", "B_LSV_01_unarmed_F"])) then {

        _objLeftGun = "B_HMG_01_high_F" createVehicle [0, 0, 0];
        _objLeftGun attachTo [_currentVehicle, [-0.7, -1.4, 0.7]];
        _objLeftGun setDir 210;
        _objLeftGun enableWeaponDisassembly FALSE;

        _objMidTowerD = "B_T_Static_AT_F" createVehicle [0, 0, 0];
        _objMidTowerD attachTo [_currentVehicle, [0.4, -1.7, 0.2]];
        _objMidTowerD setDir 30;
        _objMidTowerD enableWeaponDisassembly FALSE;

        _currentVehicle addEventHandler ["GetIn", {
            params ["_vehicle", "_unit", "_role", "_turret"];
            if (_unit == player && _role == 'cargo') then {
                player moveInAny _objMidTowerD;
            };
        }];

        _currentVehicle addEventHandler ["GetIn", {
            params ["_vehicle", "_unit", "_role", "_turret"];
            if (_unit == player && _role == 'cargo' && _turret == 5) then {
                player moveInTurret [_objLeftGun, [0]];
            };
        }];

    };
} forEach _nearbyVehicles;

 

Edited by JCataclisma

Share this post


Link to post
Share on other sites

Ok, even after correcting the syntax/params' order I couldn't manage to make it work using EH, so I tried by using a more familiar (to me) approach with addAction.
It's working fine ONLY for the right turret (static AT), but player performs "moveInTurret" in same AT even when I click on the other action, for the HMG/left turret.

I suspect it's something related to the fact I am using "_x" for both turrets'  variables, so the script just pass the first one it reads - in case, the AT/right turret.

EDIT: by attaching even more static weapons, I have noticed it doesn't necessarily matters the names, because it always puts the player in the first gun it finds in the list, regardless.... ?

Any suggestions about where am I messing and how could I keep different turrets for different addAction' s ?

 

private _nearbyVehicles = nearestObjects[player, ["Car"], 15];
{
    private _currentVehicle = _x;
    if (typeName _currentVehicle == "OBJECT" && (typeOf _currentVehicle in ["B_T_LSV_01_unarmed_F", "B_LSV_01_unarmed_F"])) then {

        _objMidRightGun = "B_T_Static_AT_F" createVehicle [0, 0, 0];
        _objMidRightGun attachTo [_currentVehicle, [0.4, -1.6, 0.05]];
        _objMidRightGun setDir 30;
        _objMidRightGun enableWeaponDisassembly FALSE;

        _objRLeftGun = "B_HMG_01_high_F" createVehicle [0, 0, 0];
        _objRLeftGun attachTo [_currentVehicle, [-0.7, -1.4, 0.5]];
        _objRLeftGun setDir 210;
        _objRLeftGun enableWeaponDisassembly FALSE;

		private _rightTurrets = [_objMidRightGun];
		private _leftTurrets = [_objRLeftGun];
            {
                _x setVariable ["isRightTurrets", true];
            } forEach _rightTurrets;
            {
                _x setVariable ["isLeftTurrets", true];
            } forEach _leftTurrets;

_currentVehicle addaction
	["<t color='#24c048'>AT Torre</t>",
	{
				_jipe = _this # 0;
                private _attachedObjects = attachedObjects _jipe;
                {
                    private _object = _x;
                    if (_object getVariable ["isRightTurrets", true]) then
                    {
						player moveInTurret [_x, [0]];
                    }
                } forEach _attachedObjects;
	},
	nil,
	0,
	false,
	true,"User16","_this distance _target < 5"];

_currentVehicle addaction
	["<t color='#5a01da'>HMG Torre</t>",
	{
				_jipe = _this # 0;
                private _attachedObjects = attachedObjects _jipe;
                {
                    private _object = _x;
                    if (_object getVariable ["isLeftTurrets", true]) then
                    {
						player moveInTurret [_x, [0]];
                    }
                } forEach _attachedObjects;
	},
	nil,
	0,
	false,
	true,"User17","_this distance _target < 5"];

    };
} forEach _nearbyVehicles;

 

Edited by JCataclisma

Share this post


Link to post
Share on other sites

OK, these lines are a problem:

if (_object getVariable ["isRightTurrets", true]) then

if (_object getVariable ["isLeftTurrets", true]) then

See alternate syntax here:

https://community.bistudio.com/wiki/getVariable

 

You are retrieving the variables' values, but also setting those values to true if they return null. As you iterate through _attachedObjects, you are ALWAYS moved into the first _object (the AT turret). You are NOT then moved into the second _object when applicable because moveInTurret requires that the unit not be in a vehicle to work. Changing those lines to:

if (_object getVariable "isRightTurrets") then

if (_object getVariable "isLeftTurrets") then

fixes that issue. However, once in a turret, your only real option is to get out of the vehicle - you can't move to the other turret (nor can you move to any seat in the vehicle.)

 

So, here is the code fixed for the initial moveInTurret and moving from turret to turret:

private _nearbyVehicles = nearestObjects [player, ["Car"], 15];

{
	private _currentVehicle = _x;
	if (typeName _currentVehicle == "OBJECT" && (typeOf _currentVehicle in ["B_T_LSV_01_unarmed_F", "B_LSV_01_unarmed_F"])) then 
	{
		
		_objMidRightGun = "B_T_Static_AT_F" createVehicle [0, 0, 0];
		_objMidRightGun attachTo [_currentVehicle, [0.4, -1.6, 0.05]];
		_objMidRightGun setDir 30;
		_objMidRightGun enableWeaponDisassembly FALSE;
		
		_objRLeftGun = "B_HMG_01_high_F" createVehicle [0, 0, 0];
		_objRLeftGun attachTo [_currentVehicle, [-0.7, -1.4, 0.5]];
		_objRLeftGun setDir 210;
		_objRLeftGun enableWeaponDisassembly FALSE;
		
		private _rightTurrets = [_objMidRightGun];
		private _leftTurrets = [_objRLeftGun];
		
			{
				_x setVariable ["isRightTurrets", true];
			} forEach _rightTurrets;
			
			{
				_x setVariable ["isLeftTurrets", true];
			} forEach _leftTurrets;

		_currentVehicle addaction
		[
			"<t color='#24c048'>AT Torre</t>",
			{
				_jipe = _this # 0;
				private _attachedObjects = attachedObjects _jipe;
				{
					private _object = _x;
					if (_object getVariable "isRightTurrets") then
					{
						moveOut player;
						player moveInTurret [_object, [0]];
					}
				} forEach _attachedObjects;
			},
			nil,
			0,
			false,
			true,
			"User16",
			"_this distance _target < 5"
		];

		_currentVehicle addaction
		[
			"<t color='#5a01da'>HMG Torre</t>",
			{
				_jipe = _this # 0;
				private _attachedObjects = attachedObjects _jipe;
				{
					private _object = _x;
					if (_object getVariable "isLeftTurrets") then
					{
						moveOut player;
						player moveInTurret [_object, [0]];
					}
				} forEach _attachedObjects;
			},
			nil,
			0,
			false,
			true,
			"User17",
			"_this distance _target < 5"
		];

	};
} forEach _nearbyVehicles;

 

Not sure about how to fix not being able to move to the other seats - the problem there is that you aren't actually in the vehicle, you are in the attached turret. It's certainly possible, I'm just running out of brainpower at the moment.

  • Thanks 1

Share this post


Link to post
Share on other sites

Oh... I read and "re-read" quite a few times the variables' stuff, especially after that tip of yours regarding magical _x, but my understanding was going in a COMPLETELY opposite way! And it would take a long, loooong time until (maybe) I realize what was actually going on with "["isRightTurrets", true]".

I would not even try anything related to change turrets without leaving the occupied one first, so that possibility is another amusing surprise.

Will apply the code to the full version of the rigged-by-scripts vehicle, perform changes and then bring it here.

For now, thank you very much! 🍺

Share this post


Link to post
Share on other sites

This version of the video is a little outdated, but even under such a low-res one can get a better idea of the real use for such a code 😁 .
No, there would be no problems when trying to take control of attached turrets, but the addAction (or eventually an EH) does help A LOT for these main reasons, besides several others:
1.) sometimes then the attached weapons are end up being "inside" the vehicle's LOD or whatnot, their simulation/interaction is compromised;
2.) other attached objects that might be "in between" player and attached weapons usually avoid player interaction with the weapons;
3.) in many cases - this included - player might need a mod like Enhanced Movement to be able to climb upon vehicle and reach the weapons, as there a single "edible" vanilla ladder which can somehow be used to help climbing vehicles ("Land_Obstacle_Climb_F" class)

Will post it here later on.

 

Edited by JCataclisma

Share this post


Link to post
Share on other sites

Here it is.
Hope it offers enough fun to compensate all the brain work.
I am posting as "spoiler" because for what I understood people here prefer it to be like this when the code is much longer.

Cheers!

P.s.: for using it, just spawn a NATO Prowler nearby (EXCEPT the AT version, because its attaching numbers are different, just like armed Hunter is different from unarmed Hunter) and execute this script (starting from "private _nearbyVehicles").

P.s.2: several lines with "QS_" are custom variables from Quiksilver to run within his Apex framework - so they can be either ignored or complete deleted for vanilla use.
 

Spoiler


//29/07/2023 - by JCataclisma
/*/
Several of these lines were only possible thanks to modifications by Quiksilver and Harzach - at the two links bellow:
https://forums.bohemia.net/forums/topic/212240-apex-framework/
https://forums.bohemia.net/forums/topic/243063-how-to-board-attached-static-weapons-when-clicking-getin-a-vehicle/
/*/
//62th_gamersBR_smokeProwlerMontado.sqf

private _nearbyVehicles = nearestObjects[player, ["Car"], 15];
{
    private _currentVehicle = _x;
    if (typeName _currentVehicle == "OBJECT" && (typeOf _currentVehicle in
		[
		"B_T_LSV_01_unarmed_F", 
		"B_LSV_01_unarmed_F", 
		"B_T_LSV_01_armed_F", 
		"B_LSV_01_armed_F"
		])) then {

		_cargoLocked = _currentVehicle lockedCargo 1;
		if (_cargoLocked) exitWith {};
		
	[_currentVehicle, nil, ["HideDoor1",0,"HideDoor2",0,"HideDoor3",1,"HideDoor4",1,"Unarmed_Ammo_Hide", 1,"Unarmed_Rear_Cage_Hide", 0]] call bis_fnc_initVehicle;
	_currentVehicle setObjectTextureGlobal [1,"a3\soft_f_exp\lsv_01\data\nato_lsv_02_black_co.paa"];
	_currentVehicle setObjectTextureGlobal [0,"a3\soft_f_exp\lsv_01\data\nato_lsv_01_black_co.paa"];
	_currentVehicle lockCargo [1, true];
	_currentVehicle lockCargo [4, true];
	_currentVehicle lockCargo [5, true];
    _centerOfMass = getCenterOfMass _currentVehicle;
    _centerOfMass set [2, 1.75];
	
    _object1 = createVehicle ["Land_RailwayCar_01_sugarcane_empty_F",[0,0,0], [], 0, "NONE"];
    _object1 attachTo [_currentVehicle, [0, -2.4, -0.3]];
	_object1 setVariable ['QS_attached',true,!is3DEN];
	_arsenal = createVehicle ["Box_NATO_Ammo_F",[0,0,0], [], 0, "NONE"];
	_arsenal attachTo [_currentVehicle,[0.95, 0.5, -1.05]];
	_arsenal setVariable ['QS_attached',true,!is3DEN];
	_arsenal setVariable ['QS_arsenal_object',TRUE,TRUE];
	
	_bagTorreEExtTeto = createVehicle ["Land_BagFence_01_long_green_F",[0,0,0], [], 0, "NONE"];
	_bagTorreEExtTeto attachTo [_currentVehicle,[-0.9,-2.25,-0.6]];
	_bagTorreEExtTeto setVariable ['QS_attached',true,!is3DEN];
	_bagTorreEExtTeto setDir 270;
	_bagTorreEup = createVehicle ["Land_BagFence_Short_F",[0,0,0], [], 0, "NONE"];
	_bagTorreEup attachTo [_currentVehicle,[-0.8,-2.05,-0.1]];
	_bagTorreEup setVariable ['QS_attached',true,!is3DEN];
	_bagTorreEup setDir 270;

	_bagTras = createVehicle ["Land_BagFence_Short_F",[0,0,0], [], 0, "NONE"];
	_bagTras attachTo [_currentVehicle,[0.05,-3.7,-0.5]];
	_bagTras setVariable ['QS_attached',true,!is3DEN];

	_bagTorreDExtTeto = createVehicle ["Land_BagFence_01_long_green_F",[0,0,0], [], 0, "NONE"];
	_bagTorreDExtTeto attachTo [_currentVehicle,[0.95,-2.05,-0.6]];
	_bagTorreDExtTeto setVariable ['QS_attached',true,!is3DEN];
	_bagTorreDExtTeto setDir 270;
	_bagTorreDup = createVehicle ["Land_BagFence_Short_F",[0,0,0], [], 0, "NONE"];
	_bagTorreDup attachTo [_currentVehicle,[0.9,-2.25,-0.1]];
	_bagTorreDup setVariable ['QS_attached',true,!is3DEN];
	_bagTorreDup setDir 270;

	_bagMid = createVehicle ["Land_BagFence_Short_F",[0,0,0], [], 0, "NONE"];
	_bagMid attachTo [_currentVehicle,[0.05,-1.1,-0.35]];
	_bagMid setVariable ['QS_attached',true,!is3DEN];	
	_bagFrente = createVehicle ["Land_BagFence_01_short_green_F",[0,0,0], [], 0, "NONE"];
	_bagFrente attachTo [_currentVehicle,[0,0.7,-0.15]];
	_bagFrente setVariable ['QS_attached',true,!is3DEN];
	_bagFrente setDir 180;
	_bagFrente setVectorUp [0,0.99,0.01];
	
    _object3 = "Land_FirstAidKit_01_closed_F" createVehicle [0, 0, 0];
    _object3 attachTo [_currentVehicle, [1.1, 1.1, -0.85]];
	_object3 setVariable ['QS_attached',true,!is3DEN]; 
	_object3 setDir 270;
	_object2d = "B_HMG_01_high_F" createVehicle [0, 0, 0];
    _object2d attachTo [_currentVehicle, [0.4, -3.2, 0.9]];
	_object2d setVariable ['QS_attached',true,!is3DEN];
	_object2d setDir 150;
	_object2d enableWeaponDisassembly FALSE;
	_object2e = "B_HMG_01_high_F" createVehicle [0, 0, 0];
    _object2e attachTo [_currentVehicle, [-0.7, -3, 0.9]];
	_object2e setVariable ['QS_attached',true,!is3DEN];
	_object2e setDir 210;
	_object2e enableWeaponDisassembly FALSE;
	_object1 = createVehicle ["B_HMG_01_A_F",[0,0,0], [], 0, "NONE"];
    _object1 attachTo [_currentVehicle, [0.5, 1.4, 0.35]];
	_object1 enableWeaponDisassembly FALSE;
	_object1 allowDamage TRUE;
	createVehicleCrew _object1;
	_object1 setVariable ['QS_attached',true,!is3DEN];
	_object1 setDir 30;
	_objMidTowerD = "B_T_Static_AT_F" createVehicle [0, 0, 0];
    _objMidTowerD attachTo [_currentVehicle, [0.45, -1.75, 0.4]];
	_objMidTowerD setVariable ['QS_attached',true,!is3DEN];
	_objMidTowerD setDir 30;
	_objMidTowerD enableWeaponDisassembly FALSE;
	_objMidTowerE = "B_T_Static_AT_F" createVehicle [0, 0, 0];
    _objMidTowerE attachTo [_currentVehicle, [-0.25, -1.75, 0.4]];
	_objMidTowerE setVariable ['QS_attached',true,!is3DEN];
	_objMidTowerE setDir 330;
	_objMidTowerE enableWeaponDisassembly FALSE;

	_objectRoofMidLamp = "Land_PortableLight_02_single_folded_olive_F" createVehicle [0, 0, 0];
	_objectRoofMidLamp attachTo [_currentVehicle, [0.05, 1.1, -0.05]];
	_objectRoofMidLamp setVariable ['QS_attached',true,!is3DEN];
	_objectRoofMidLamp setDir 180;
	_objectRoofRightLamp = "Land_PortableLight_02_single_folded_olive_F" createVehicle [0, 0, 0];
	_objectRoofRightLamp attachTo [_currentVehicle, [0.75, 1.05, -0.1]];
	_objectRoofRightLamp setVariable ['QS_attached',true,!is3DEN];
	_objectRoofRightLamp setVectorDirAndUp [[-0.33,-0.66,0.33], [-0.33,-0.33,-0.66]];;
	_objectRoofLeftLamp = "Land_PortableLight_02_single_folded_olive_F" createVehicle [0, 0, 0];
	_objectRoofLeftLamp attachTo [_currentVehicle, [-0.7, 1.05, -0.1]];
	_objectRoofLeftLamp setVariable ['QS_attached',true,!is3DEN];
	_objectRoofLeftLamp setVectorDirAndUp [[0.33,-0.66,0.33], [-0.33,-0.33,-0.66]];

	_objectFrontRightLamp = "Land_PortableLight_02_single_folded_olive_F" createVehicle [0, 0, 0];
	_objectFrontRightLamp attachTo [_currentVehicle, [0.95, 1.9, -0.9]];
	_objectFrontRightLamp setVariable ['QS_attached',true,!is3DEN];
	_objectFrontRightLamp setDir 180;
	_objectMidPaxRightLamp = "Land_PortableLight_02_double_black_F" createVehicle [0, 0, 0];
	_objectMidPaxRightLamp attachTo [_currentVehicle, [1.05, -0, -0.5]];
	_objectMidPaxRightLamp setVariable ['QS_attached',true,!is3DEN];
	_objectMidPaxRightLamp setDir 250;
	_objectRearRightLamp = "Land_PortableLight_02_single_folded_olive_F" createVehicle [0, 0, 0];
	_objectRearRightLamp attachTo [_currentVehicle, [1.1, -2.1, -1.1]];
	_objectRearRightLamp setVariable ['QS_attached',true,!is3DEN];
	
	_objLowRightLamp = "PortableHelipadLight_01_red_F" createVehicle [0, 0, 0];
	_objLowRightLamp attachTo [_currentVehicle, [1,-3.85,-0.7]];
	_objLowRightLamp setVariable ['QS_attached',true,!is3DEN];
	_objLowRightLamp setVectorUp [0,-0.99,-0.01];
	_objLowLeftLamp = "PortableHelipadLight_01_red_F" createVehicle [0, 0, 0];
	_objLowLeftLamp attachTo [_currentVehicle, [-0.95,-3.85,-0.7]];
	_objLowLeftLamp setVariable ['QS_attached',true,!is3DEN];
	_objLowLeftLamp setVectorUp [0,-0.99,-0.01];
	
		private _rightATurret = [_objMidTowerD];
		private _leftATurret = [_objMidTowerE];
		private _rightHMG = [_object2d];
		private _leftHMG = [_object2e];
		
			{
				_x setVariable ["isRightATurret", true];
			} forEach _rightATurret;
			
			{
				_x setVariable ["isLeftATurret", true];
			} forEach _leftATurret;
			
			{
				_x setVariable ["isRightHMG", true];
			} forEach _rightHMG;
			
			{
				_x setVariable ["isLeftHMG", true];
			} forEach _leftHMG;

		_currentVehicle addaction
		[
			"<t color='#24c048'>Right AT</t>",
			{
				_jipe = _this # 0;
				private _attachedObjects = attachedObjects _jipe;
				{
					private _object = _x;
					if (_object getVariable "isRightATurret") then
					{
						moveOut player;
						player moveInTurret [_object, [0]];
					}
				} forEach _attachedObjects;
			},
			nil,
			0,
			false,
			true,
			"",
			"_this distance _target < 5"
		];

		_currentVehicle addaction
		[
			"<t color='#0036ff'>Left AT</t>",
			{
				_jipe = _this # 0;
				private _attachedObjects = attachedObjects _jipe;
				{
					private _object = _x;
					if (_object getVariable "isLeftATurret") then
					{
						moveOut player;
						player moveInTurret [_object, [0]];
					}
				} forEach _attachedObjects;
			},
			nil,
			0,
			false,
			true,
			"",
			"_this distance _target < 5"
		];
		
		_currentVehicle addaction
		[
			"<t color='#24c048'>Right HMG</t>",
			{
				_jipe = _this # 0;
				private _attachedObjects = attachedObjects _jipe;
				{
					private _object = _x;
					if (_object getVariable "isRightHMG") then
					{
						moveOut player;
						player moveInTurret [_object, [0]];
					}
				} forEach _attachedObjects;
			},
			nil,
			0,
			false,
			true,
			"",
			"_this distance _target < 5"
		];

		_currentVehicle addaction
		[
			"<t color='#0036ff'>Left HMG</t>",
			{
				_jipe = _this # 0;
				private _attachedObjects = attachedObjects _jipe;
				{
					private _object = _x;
					if (_object getVariable "isLeftHMG") then
					{
						moveOut player;
						player moveInTurret [_object, [0]];
					}
				} forEach _attachedObjects;
			},
			nil,
			0,
			false,
			true,
			"",
			"_this distance _target < 5"
		];

	_currentVehicle addAction
	[
	"<t color='#24c048'>SMOKE</t>",
		{
		chemLitW2 = "Chemlight_blue" createvehicle ((player) ModelToWorld [-7,5,1]);
		chemLitN = "Chemlight_green" createvehicle ((player) ModelToWorld [0,7,1]);
		chemLitE = "Chemlight_blue" createvehicle ((player) ModelToWorld [7,0,1]);
		chemLitE2 = "Chemlight_blue" createvehicle ((player) ModelToWorld [7,5,1]);
		chemLitS = "Chemlight_green" createvehicle ((player) ModelToWorld [0,-16,1]);
		chemLitSW = "Chemlight_yellow" createvehicle ((player) ModelToWorld [-5,-13,1]);
		chemLitSE = "Chemlight_yellow" createvehicle ((player) ModelToWorld [5,-13,1]);
		chemLitW = "Chemlight_blue" createvehicle ((player) ModelToWorld [-7,0,1]);
		
		chemLitW2 = "Chemlight_blue" createvehicle ((player) ModelToWorld [-19,17,1]);
		chemLitN2 = "Chemlight_green" createvehicle ((player) ModelToWorld [0,19,1]);
		chemLitE2 = "Chemlight_blue" createvehicle ((player) ModelToWorld [19,0,1]);
		chemLitE22 = "Chemlight_blue" createvehicle ((player) ModelToWorld [19,17,1]);
		chemLitS2 = "Chemlight_green" createvehicle ((player) ModelToWorld [0,-13,1]);
		chemLitSW2 = "Chemlight_yellow" createvehicle ((player) ModelToWorld [-17,-19,1]);
		chemLitSE2 = "Chemlight_yellow" createvehicle ((player) ModelToWorld [17,-19,1]);
		chemLitW2 = "Chemlight_blue" createvehicle ((player) ModelToWorld [-19,0,1]);
		},
		nil,
		0,
		false,
		true,
		"User17",
		"_this == _target turretUnit [-1] && (getPosATL _target) select 2 < 16",
		10,
		false
	];
		
_currentVehicle addAction
	[
		"<t color='#cb8f0f'>FLARES Noturnos</t>",
		{
		flareN = "F_20mm_Green" createvehicle ((player) ModelToWorld [0,50,150]); 
		flareN setVelocity [0,25,-5];
		flareNE = "F_20mm_Yellow" createvehicle ((player) ModelToWorld [15,25,150]);
		flareNE setVelocity [5,15,-15];
		flareE = "F_20mm_Red" createvehicle ((player) ModelToWorld [15,0,150]);
		flareE setVelocity [10,25,-5];
		flareSE = "F_20mm_Yellow" createvehicle ((player) ModelToWorld [15,-25,150]);
		flareSE setVelocity [-5,-15,-15];
		flareS = "F_20mm_Green" createvehicle ((player) ModelToWorld [0,-50,150]);
		flareS setVelocity [0,-25,-5];
		flareSW = "F_20mm_Yellow" createvehicle ((player) ModelToWorld [-15,-25,150]);
		flareSW setVelocity [-5,-15,-15];
		flareW = "F_20mm_Red" createvehicle ((player) ModelToWorld [-15,0,150]);
		flareW setVelocity [-10,25,-5];
		flareNW = "F_20mm_Yellow" createvehicle ((player) ModelToWorld [-15,25,150]);
		flareNW setVelocity [-5,15,-15];
		},
		nil,
		0,
		false,
		true,
		"User16",
		"_this == _target turretUnit [-1] && (getPosATL _target) select 2 < 150",
		10,
		false
	];

};
} forEach _nearbyVehicles;

 

 

Edited by JCataclisma

Share this post


Link to post
Share on other sites
56 minutes ago, JCataclisma said:

a better idea of the real use for such a code 😁

 

Oh, the ol' Battlebus concept has been around for a very long time - have fun!

Share this post


Link to post
Share on other sites
On 7/28/2023 at 1:44 PM, JCataclisma said:

Ok, even after correcting the syntax/params' order I couldn't manage to make it work using EH

 

Spoiler

        _objLeftGun = "B_HMG_01_high_F" createVehicle [0, 0, 0];
        //snip

        _objMidTowerD = "B_T_Static_AT_F" createVehicle [0, 0, 0];
        //snip

        _currentVehicle addEventHandler ["GetIn", {
            params ["_vehicle", "_unit", "_role", "_turret"];
            if (_unit == player && _role == 'cargo') then {
                player moveInAny _objMidTowerD;
            };
        }];

        _currentVehicle addEventHandler ["GetIn", {
            params ["_vehicle", "_unit", "_role", "_turret"];
            if (_unit == player && _role == 'cargo' && _turret == 5) then {
                player moveInTurret [_objLeftGun, [0]];
            };
        }];

 

The local variables _objMidTowerD and _objLeftGun would be out of scope once inside the eventHandlers so would be undefined.

  • Like 2

Share this post


Link to post
Share on other sites

Oh, so that's where some "undefined variable" warnings have come. 😒

Thank you!

P.s.: I will remain trying with EHs, as the addAction has that issue regarding locally vs. globally, which demands much more work for passing the functions into server prior to remote calling them. 😬

Edited by JCataclisma

Share this post


Link to post
Share on other sites

One question to attached static weapons - WHY it can't be transported as cargo by this method https://community.bistudio.com/wiki/Arma_3:_Vehicle_in_Vehicle_Transport even when it have set config to 

canBeTransported = 1; and all mass and size parameters are meet - other vehicles (smaller than specified weaopon turret)  in the same situation (transporter vehicle) are able to load.??????

 

?imw=5000&imh=5000&ima=fit&impolicy=Lett

  • Like 1

Share this post


Link to post
Share on other sites

A few months ago, inside his "Invade&Annex" framework, Quiksilver has managed to kind of deal with that, @h4wek . We were having a similar issue with that flatbed truck: it could only carry a single small container at once, instead of two, even if the sizes and weights were ok for more.

I don't know how did he tweak that, but your issue might be related to that little game bug as well.

And I won't dare to offer additional suggestions, because every single incursion of mine in such subjects were ALWAYS outside the regular/original set up from the game, so as you can see in this topic specifically, I could only make them work with the help of the savy guys around here. 😎

Share this post


Link to post
Share on other sites

This is not a reason of config belive me - i try to load transport static weapons to very kind of vehicle in vanilla set and gues what - no f.... way to that, but if I change the same object to parent class as non static wapon, for example tank, it is possibile to load to the same vehicle what previously not, and to those trucks also, So why i ask for check those classes by BI, i try many possibilities to do that and it is blocked on engine (loading transport vehicles) level.

 

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, h4wek said:

This is not a reason of config belive me - i try to load transport static weapons to very kind of vehicle in vanilla set and gues what - no f.... way to that, but if I change the same object to parent class as non static wapon, for example tank, it is possibile to load to the same vehicle what previously not, and to those trucks also, So why i ask for check those classes by BI, i try many possibilities to do that and it is blocked on engine (loading transport vehicles) level.

 

OH, indeed!

My apologies: now, after your latest message, I've read once more your previous issue and realized that it was I who has misunderstood what was actually the difficulty.
Cheers!

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

×