Jump to content
csk222

How to use addAction in editor placed Helicopter and Respawn Module

Recommended Posts

Hello. How do I get the same vehicle crew to respawn after it has been destroyed?

 

For example: I have a helicopter placed in the editor called "uh80_alpha" with the initialization

BIS_grpAlphaUH80 = group this;clearItemCargoGlobal uh80_alpha; 
clearWeaponCargoGlobal uh80_alpha; clearMagazineCargoGlobal uh80_alpha; 
clearBackpackCargoGlobal uh80_alpha;

It is an insertion chopper, How can I get it to respawn exactly how I placed it in the editor with the name and initialization after it has been destroyed?

 

Side question: Is there an easier way to remove all of the vehicles inventory? (Instead of - clearItemCargoGlobal uh80_alpha; etc.)

Share this post


Link to post
Share on other sites

I personally use Murkspawn 3. Its light weight, works as simply as syncronizing the team lead (or this case the occupied Helo).

 

You can find it here - https://www.dropbox.com/s/d94q0abf499qce8/murk_spawn3.sqf

Learn more about it here - https://forums.bistudio.com/topic/158029-editor-based-ai-spawn-by-trigger/

And when this group was still active, I did a video tutorial here -

 

 

 

 

Please note to be careful when following the code in the read me, they need to be updated to refer to murkspawn 3 and not murkspawn 2....watch the video and it makes more sense.

Share this post


Link to post
Share on other sites

Could you not just use the vanilla vehicle respawn module along with the "expression" field within it.

Share this post


Link to post
Share on other sites

I've been messing around with the vanilla vehicle respawn module but I just get an empty chopper to spawn. I'm still very uncertain of how to achieve this. Any help from anyone will be greatly appreciated.

Share this post


Link to post
Share on other sites

Thank you very much. That did the trick but now I'm getting an error message about "this" in BIS_grpAlphaUH80 = group this; when I place the following code in the expression field. It works fine when I remove it.

createVehicleCrew uh80_alpha
BIS_grpAlphaUH80 = group this
uh80_alpha animateDoor ["door_L",1];
uh80_alpha animateDoor ["door_R",1];
uh80_alpha setObjectTexture [0,'images\bomsf_woodland.paa'];
uh80_alpha setObjectTexture [1,'images\bomsf_woodland.paa'];
clearItemCargoGlobal uh80_alpha;
clearWeaponCargoGlobal uh80_alpha;
clearMagazineCargoGlobal uh80_alpha;
clearBackpackCargoGlobal uh80_alpha;

Share this post


Link to post
Share on other sites

Hello. I am expanding the use of my helicopters and want to add on to my previous posts. I am trying to use an addAction in an editor placed Helicopter and Respawn Module on a dedicated server. I use a GUI (Tablet) that calls the script to move the helicopter around and everything works properly. I want to add the addActions to the helicopter’s init to be able to move the chopper around without having to enter the GUI Tablet.

Here’s how we call the script using a button on the GUI Tablet

	class btnD5: abo_RscButton
	{
		idc = 5;
		action = "[] call abo_noshow_dbtns;ctrlShow [80,true];ctrlShow [97,true];ctrlShow [96,true];ctrlShow [79,false];_nulainsl = [player] execVM 'bPad\abo\airborne\abo_ainsx.sqf';closeDialog 0;";
		text = "LZ"; //--- ToDo: Localize;
		tooltip = "Alpha Insertion/Pickup"; //--- ToDo: Localize;
		x = 0.1;
		y = 0.01;
		w = 0.19;
		h = 0.05;
	};

_nulains = [player] execVM 'bPad\abo\airborne\abo_ainsx.sqf';  <- Need to transform this into an addAction to use in the helicopter and then again in the expression field of the respawn module

Share this post


Link to post
Share on other sites

The addActions work properly at spawn but, it doesn't work in the expression field of the respawn module. The helicopter does not respawn with the addActions after being destroyed.

 

I've tried the following with some success. What's the difference between the two "working" addActions below?

// Works
uh80_alpha addAction["Move to Alpha Insertion","bPad\abo\airborne\abo_ainsx.sqf", [], 6, false, true, ""];

// Works
uh80_alpha addAction ["Move to Alpha Insertion","[player] execVM 'bPad\abo\airborne\abo_ainsx.sqf'"];

// Get an error when I use "[this]"
uh80_alpha addAction ["Move to Alpha Insertion","[this] execVM 'bPad\abo\airborne\abo_ainsx.sqf'"];

 

Share this post


Link to post
Share on other sites

the problem in the third example is that it is a string that will be converted somehwere else by the engine where the "this" variable will not exist/be something else. the "player" variable (second example) however will exist anywhere.

 

if you look at the "addaction" wiki page you can see what the command passes into the script/code that is executed by it https://community.bistudio.com/wiki/addAction

specifically look at "parameters -> script" on that page.

 

in short though: add the following to the top of your sqf to be able to refer to the vehicle in your script

 

params ["_obj", "_caller", "_id", "_args"];

now inside your script you can refer to the vehicle the action is applied on via the _obj variable.

you are already doing a version of this since you are trying to pass the vehicle into the script. you are just doing it wrong because you didn't know it's done by default.

 

i hope this wasn't too messy to understand what i'm trying to say.

Share this post


Link to post
Share on other sites

I've read all about it and I've tried various examples from other posts but I just don't get it. I simply don't know what to do. <~ Period. If i can manage to just get one working example I can replicate it with the rest of the insertion types we use.

 

I kinda/sorta learned that you can't use "this" in the respawn module, so I name everything. Why it has to be that way - no clue. I guess that's the explanation

9 hours ago, bad benson said:

the problem in the third example is that it is a string that will be converted somehwere else by the engine where the "this" variable will not exist/be something else.

---

Here is what is in the init of the helicopter (uh80_alpha):

Spoiler

BIS_grpAlphaUH80 = group this;
uh80_alpha animateDoor ['door_L',1]; uh80_alpha animateDoor ['door_R',1];
this setObjectTextureGlobal [0,'images\bomsf_woodland.paa'];
this setObjectTextureGlobal [1,'images\bomsf_woodland.paa'];
uh80_alpha addAction ["Toggle Doors", {private [ "_state1","_state2" ];
_state1 = ( _this select 0 ) doorPhase "door_L"; _state2 = ( _this select 0 ) doorPhase "door_R";
if ( _state1 == 0 ) then {( _this select 0 ) animateDoor ["door_L", 1, false];}
else {( _this select 0 ) animateDoor ["door_L", 0, false];};
if ( _state2 == 0 ) then {( _this select 0 ) animateDoor ["door_R", 1, false];}
else {( _this select 0 ) animateDoor ["door_R", 0, false];};}]; 

 

Here is what's in the expression field of the respawn module synced to the helicopter (uh80_alpha)

Spoiler

createVehicleCrew uh80_alpha;
uh80_alpha animateDoor ['door_L',1]; uh80_alpha animateDoor ['door_R',1];
uh80_alpha setObjectTextureGlobal [0,'images\bomsf_woodland.paa'];
uh80_alpha setObjectTextureGlobal [1,'images\bomsf_woodland.paa'];
uh80_alpha addAction ["Toggle Doors", {private [ "_state1","_state2" ];  _state1 = ( _this select 0 ) doorPhase "door_L"; _state2 = ( _this select 0 ) doorPhase "door_R";
if ( _state1 == 0 ) then {( _this select 0 ) animateDoor ["door_L", 1, false];}
else {( _this select 0 ) animateDoor ["door_L", 0, false];};
if ( _state2 == 0 ) then {( _this select 0 ) animateDoor ["door_R", 1, false];}
else {( _this select 0 ) animateDoor ["door_R", 0, false];};}];

 

The above example works and respawns properly, How the door toggle addaction works on respawn - no clue but it works

---

Here is the abo_ainsx.sqf I'm trying to use as an addaction

Spoiler

/*
Author: Cobra [BOMSF] 1949-2014
bomsfarma3@gmail.com - www.bomsf.enjin.com
You may re-use any of this work as long as you provide credit back to me.
	Edit By CSK222
		UH80 Alpha: LZ Alpha Insertion
*/
private ["_caller"];
_caller = _this select 0;
omsca = false;
if (not visibleMap) then {openMap true};
titleText ["Open Map and Click on Alpha insertion location.", "PLAIN"];

["mk_ainsrtlnd", "onMapSingleClick", {
	titleText ["", "PLAIN"];

	_tpos = _pos;
	"ainsrsp" setMarkerPos _pos;
	hpad_alpha setPos _pos;
	server_1 setVariable ["abo_ains","true",true];
	if (visibleMap) then {openMap false};
	["mk_ainsrtlnd", "onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;
	omsca = true;
	true;
}] call BIS_fnc_addStackedEventHandler;

 

---

Here is ultimately what I'd like to end up with in its entirety - not just the uh80_alpha addAction ["Move to Alpha Insertion","[player] execVM 'bPad\abo\airborne\abo_ainsx.sqf'"]; example given

Spoiler

BIS_grpAlphaUH80 = group this;
uh80_alpha animateDoor ['door_L',1]; uh80_alpha animateDoor ['door_R',1];
uh80_alpha setObjectTextureGlobal [0,'images\bomsf_woodland.paa'];
uh80_alpha setObjectTextureGlobal [1,'images\bomsf_woodland.paa'];
uh80_alpha addAction ["Toggle Doors", {private [ "_state1","_state2" ];
_state1 = ( _this select 0 ) doorPhase "door_L"; _state2 = ( _this select 0 ) doorPhase "door_R";
if ( _state1 == 0 ) then {( _this select 0 ) animateDoor ["door_L", 1, false];}
else {( _this select 0 ) animateDoor ["door_L", 0, false];};
if ( _state2 == 0 ) then {( _this select 0 ) animateDoor ["door_R", 1, false];}
else {( _this select 0 ) animateDoor ["door_R", 0, false];};}];
uh80_alpha addAction ["Move to Alpha Insertion","[player] execVM 'bPad\abo\airborne\abo_ainsx.sqf'"];
uh80_alpha addAction ["Move to Alpha Fast Rope","[player] execVM 'bPad\abo\airborne\abo_aropex.sqf'"];
uh80_alpha addAction ["Move to Alpha Parajump","[player] execVM 'bPad\abo\airborne\abo_a600x.sqf'"];
uh80_alpha addAction ["Move to Alpha Helocast","[player] execVM 'bPad\abo\airborne\abo_asealx.sqf'"];
uh80_alpha addAction ["Move to Alpha Base (RTB)","[player] execVM 'bPad\abo\airborne\abo_artbx.sqf'"];

 

additionally, I have recently added the VcomAI script to the mission so I'll have to add the following at a later time {_x setvariable ["NOAI",true];_x setvariable ["VCOM_NOPATHING_Unit",true];} foreach (Crew this);

---

Finally, here is a short video ARMA 3 - Helicopter insertion example

 

Sorry for the length of the post. I appreciate any help and direction given very much!

Share this post


Link to post
Share on other sites

here is an example using a respawn script instead of respawn module.

it worked out better for me as the respawn module would stop working after a while.

http://www.mediafire.com/file/9ddchv41nbwlgtu/vehicle+respawn.Stratis.rar

one vehicle respawn with arsenal as an addction, after respawn its only accesible from inside vehicle.

anyways.. not exactly what your looking for but its a working example of respawn with addaction.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you very much @schmoking. Took me a couple of tries and uploads to the dedicated server to test it, but it's working!

Spoiler

/*
usage:
_nul = [this, 0.1, 0.1, {[_this] call fnc_uh80}] execVM "veh_respawn\vehRespawn.sqf";
*/

fnc_uh80 =
{
	params ["_veh"];
	
	createVehicleCrew _veh;
	_veh animateDoor ['door_L',1]; _veh animateDoor ['door_R',1];
	_veh setObjectTextureGlobal [0,'images\bomsf_woodland.paa'];
	_veh setObjectTextureGlobal [1,'images\bomsf_woodland.paa'];	
	_veh remoteExec ["fnc_uh80_action", 0, _veh];
	{_x setvariable ["NOAI",true];_x setvariable ["VCOM_NOPATHING_Unit",true];} foreach (Crew _veh);		
};

fnc_uh80_action =
{
	params ["_veh"];

	_veh addAction ["Toggle Doors", {private [ "_state1","_state2" ];
	_state1 = ( _this select 0 ) doorPhase "door_L"; _state2 = ( _this select 0 ) doorPhase "door_R";
	if ( _state1 == 0 ) then {( _this select 0 ) animateDoor ["door_L", 1, false];}
	else {( _this select 0 ) animateDoor ["door_L", 0, false];};
	if ( _state2 == 0 ) then {( _this select 0 ) animateDoor ["door_R", 1, false];}
	else {( _this select 0 ) animateDoor ["door_R", 0, false];};}];
	_veh addAction ["Move to Alpha Insertion","[player] execVM 'bPad\abo\airborne\abo_ainsx.sqf'"];
	_veh addAction ["Move to Alpha Fast Rope","[player] execVM 'bPad\abo\airborne\abo_aropex.sqf'"];
	_veh addAction ["Move to Alpha Parajump","[player] execVM 'bPad\abo\airborne\abo_a600x.sqf'"];
	_veh addAction ["Move to Alpha Helocast","[player] execVM 'bPad\abo\airborne\abo_asealx.sqf'"];
	_veh addAction ["Move to Alpha Base (RTB)","[player] execVM 'bPad\abo\airborne\abo_artbx.sqf'"];
};

 

 

Share this post


Link to post
Share on other sites

Can't you just pass variables into the expression field in the respawn module?!?

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

×