Jump to content

Recommended Posts

ok, I put it into the init.sqf as:

player addAction 
["Cloak", "cloak.sqf", 6, [], false, true, "", 
{(uniform player) in 
	[
		"U_B_Protagonist_VR", 
		"U_B_Soldier_VR", 
		"U_C_Soldier_VR", 
		"U_I_Protagonist_VR", 
		"U_I_Soldier_VR", 
		"U_O_Protagonist_VR", 
		"U_O_Soldier_VR"
	]
}
];

then I put the soldier as VR Soldier, so he already has the uniform on, ran it, and there's no option to cloak.

I can only seem to get him to cloak if I put:

this addaction ["cloak", "cloak.sqf", [], 6, false, true];

into the player init. even with the uniform off, he still can cloak.

I even tried to put:

this addAction 
["Cloak", "cloak.sqf", 6, [], false, true, "", 
{(uniform player) in 
	[
		"U_B_Protagonist_VR", 
		"U_B_Soldier_VR", 
		"U_C_Soldier_VR", 
		"U_I_Protagonist_VR", 
		"U_I_Soldier_VR", 
		"U_O_Protagonist_VR", 
		"U_O_Soldier_VR"
	]
}
];

into the player's init, but no option would show up.

Only thing I can get to work in the init.sqf is:

player addaction ["cloak", "cloak.sqf", [], 6, false, true];

if I switch the [], 6, with 6, [], it won't work.

Edited by RTEK

Share this post


Link to post
Share on other sites

You're supposed to put the arguments before priority, my mistake. About the option not showing up, put:

hint str (uniform player);

before the action, and add that to the list.

Edited by DreadedEntity

Share this post


Link to post
Share on other sites

like this?

hint str (uniform player)  
player addAction 
["Cloak", "cloak.sqf", [], 6, false, true, "", 
{(uniform player) in 
	[
		"U_B_Protagonist_VR", 
		"U_B_Soldier_VR", 
		"U_C_Soldier_VR", 
		"U_I_Protagonist_VR", 
		"U_I_Soldier_VR", 
		"U_O_Protagonist_VR", 
		"U_O_Soldier_VR"
	]
}
];

Share this post


Link to post
Share on other sites

hint str (uniform player);  
player addAction   
["Cloak", "cloak.sqf", [], 6, false, true, "", 
{(uniform player) in 
	[
		"U_B_Protagonist_VR", 
		"U_B_Soldier_VR", 
		"U_C_Soldier_VR", 
		"U_I_Protagonist_VR", 
		"U_I_Soldier_VR", 
		"U_O_Protagonist_VR", 
		"U_O_Soldier_VR"
	]
}
];

I tried that but no option yet.

Share this post


Link to post
Share on other sites

Shouldn't the (uniform player) within the addAction array be (uniform _this) or (uniform _target), depending on who/what the addAction is attached to.

Share this post


Link to post
Share on other sites
Shouldn't the (uniform player) within the addAction array be (uniform _this) or (uniform _target), depending on who/what the addAction is attached to.

You can use _this if you want, but there's not really a point since the action will be added to the player, and _this = player.

Share this post


Link to post
Share on other sites

It has something to do with that part. If I remove that, it works as before. I've tried the double quotes thing too.

{(uniform player) in 
	[
		"U_B_Protagonist_VR", 
		"U_B_Soldier_VR", 
		"U_C_Soldier_VR", 
		"U_I_Protagonist_VR", 
		"U_I_Soldier_VR", 
		"U_O_Protagonist_VR", 
		"U_O_Soldier_VR"
	]
}

Share this post


Link to post
Share on other sites

Works fine with the double quotes, I just tested it in VR.

player addAction ["Cloak", "hint ""You have cloaked.""", [], 6, false, true, "",
"
(uniform player) in
[""U_B_Protagonist_VR"",""U_B_Soldier_VR"",""U_C_Soldier_VR"",
""U_I_Protagonist_VR"",""U_I_Soldier_VR"",""U_O_Protagonist_VR"",""U_O_Soldier_VR""]
"];

Share this post


Link to post
Share on other sites

oh ok, man I'm sorry, I thought the double quotes, you meant go somewhere else. My bad on that. Thanks.

Share this post


Link to post
Share on other sites
oh ok, man I'm sorry, I thought the double quotes, you meant go somewhere else. My bad on that. Thanks.

You're welcome. Make sure you add "-showScriptErrors" to your startup parameters.

Edited by DreadedEntity

Share this post


Link to post
Share on other sites

Just did it, thanks.

I updated the OP with the uniform addaction. I also linked a small mission I made last night if anyone wants to see it in game in a mission scenario. I put HallyG's EMP grenade script in there too, since it's a Splinter Cell type mission.

Share this post


Link to post
Share on other sites

Can hideObjectGlobal be applied to partially work, as in like a event horizon? Say there was an AOE cloaking field, as a vehicle or player passes through the event horizon, it vanishes at the event horizon. Like the Puddle Jumper in Stargate Atlantis as it enters and exits the Stargate event horizon.

http://opendayz.net/threads/release-freds-anti-zombie-frequency-emitter-aka-zombie-shield.12340/

I used to use that script for the zombie shield, and wonder if it could be modified to project a cloak barrier, then tie in the partcle effects to reach the boundary of it.

Edited by RTEK

Share this post


Link to post
Share on other sites

Sure, you can do something like

_allUnits = [];
_effectTimer = [] spawn 
{
sleep 60; //cloak device will last for 1 minute
};

while (!scriptDone _effectTimer) do
{
_objects = nearestObjects [getPos _grenade, ["man"], 10];
_allUnits = _allUnits - _objects; //prevents duplicates in the array
_allUnits = _allUnits + _objects; //prevents duplicates in the array
{
	hideObjectGlobal _x;
}forEach _objects;
};

{
_x hideObjectGlobal false;
}forEach _allUnits;

Be warned, any units that walk into the AOE will be cloaked until the effect wears off, even if they leave the anomaly. I could probably build a better system, but I was just banging my keyboard for a minute to get this typed up quickly.

The anti-zombie script is much simpler because it doesn't have to keep track of any of the units, it just kills them. For this script, you have to keep track of the units so you can un-hide them after the effect wears off.

Share this post


Link to post
Share on other sites

LOL the guy who made the video and wrote the original script is a friend of mine, Ill show him to this thread. He might be willing to share his code :)

btw look at his other arma videos as well, hes a script magician xD

Edited by Silderoy

Share this post


Link to post
Share on other sites

So Im not sure this is still relevant but this is what I wrote for the original video:

_source = "#particlesource" createVehicleLocal getPos SELECTED_UNIT;
_source setParticleParams [["\A3\data_f\ParticleEffects\Universal\Refract.p3d",1,0,1,0],"","Billboard",1,	1,	[0,0,.4],[0,0,1],0,1,1,0,[.25,3,.25,0],[[1,1,1,1],[1,1,1,1]],[1.5,0.5],0,0,"","",SELECTED_UNIT];
_source setDropInterval .1;

However that was just me playing around a bit inside the editor.

I made a multiplayer compatible version (however it has CBA as a dependancy),

initPlayerLocal.sqf

["MPCloakToggle", {
_unit = _this Select 0;
_mode = _this Select 1;

if (_mode) then
{
	_source = "#particlesource" createVehicleLocal getPos _unit;
	_source setParticleParams [["\A3\data_f\ParticleEffects\Universal\Refract.p3d",1,0,1,0],"","Billboard",1,	1,	[0,0,.4],[0,0,1],0,1,1,0,[.25,3,.25,0],[[1,1,1,1],[1,1,1,1]],[1.5,0.5],0,0,"","",_unit];
	_source setDropInterval .1;
	_unit setVariable ["CloakVic", _source];
	[_unit] spawn 
	{
		sleep .4;
		(_this select 0) hideObjectGlobal true;
	};
} else {
	deleteVehicle (_unit getVariable "CloakVic");
	[_unit] spawn 
	{
		sleep .25;
		(_this select 0) hideObjectGlobal false;
	};
};
}] call CBA_fnc_addEventHandler;

initCloak.sqf

// callscript with 0 = this execVM "initCloak.sqf" from a units init line
if (str player != str _this) exitWith {};

player setVariable ["CloakIsOn", false];

_OffId = player addAction ["Turn off cloak",{player setVariable ["CloakIsOn", false]; player setCaptive false; ["MPCloakToggle",[player, false]] call CBA_fnc_globalEvent;}, "",1,true,true,"","(player getVariable ""CloakIsOn"")"];
_OnId = player addAction ["Turn on cloak",{player setVariable ["CloakIsOn", true]; player setCaptive false; ["MPCloakToggle",[player, true]] call CBA_fnc_globalEvent;}, "",1,true,true,"","!(player getVariable ""CloakIsOn"")"];
player setVariable ["CloakOffActionID", _OffId];
player setVariable ["CloakOnfActionID", _OnId];

0 = [] spawn
{
while {true} do
{
	waituntil{!alive player};
	player removeAction (player getVariable "CloakOffActionID");
	player removeAction (player getVariable "CloakOnActionID");
	waituntil{alive player};
	_OffId = player addAction ["Turn off cloak",{player setVariable ["CloakIsOn", false]; player setCaptive false; ["MPCloakToggle",[player, false]] call CBA_fnc_globalEvent;}, "",1,true,true,"","(player getVariable ""CloakIsOn"")"];
	_OnId = player addAction ["Turn on cloak",{player setVariable ["CloakIsOn", true]; player setCaptive false; ["MPCloakToggle",[player, true]] call CBA_fnc_globalEvent;}, "",1,true,true,"","!(player getVariable ""CloakIsOn"")"];
	player setVariable ["CloakOffActionID", _OffId];
	player setVariable ["CloakOnfActionID", _OnId];
};

};

I haven't bugtested it too much but it should get the job done...

I know Im kind of late to the party, but maybe this will help someone at some point...

Share this post


Link to post
Share on other sites

Hey Racketen, thanks for posting this. I've been curious what params you used for the refract effect. the way you have it, gives it that nice enveloping effect as the player blinks out.

When I first saw your video, i was search for any Arma 3 cloaking scripts. I was surprised that none were out. So I was really wanting to get that cloak going on the forums, because that's some cool looking shit.

I'm going to post up your code to the original post so it's up front for people to see when they search for cloaking in Arma 3.

Share this post


Link to post
Share on other sites

Seems like this script has progressed quite a lot since I was saw it, looks good! I have been learning about dialogs recently and I thought that I would share a little feature that I made and then added into this script. It's nothing amazing but I suppose it's the small things that count.

This does not contain the code to add the action to the player if they are wearing a specific uniform. Additionally, I have only tested this briefly in single player, so I do not know if it will work in MP!

Init.sqf

cutRsc ["CLOAK_BAR","PLAIN"];

Description.ext

#define CT_PROGRESS         8

class RscTitles
{
class RscProgress
{
	type = 8;
	style = 0;
	shadow = 2;
	colorFrame[] = {0,0,0,1};
	colorBar[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.69])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.75])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.5])","(profilenamespace getvariable ['GUI_BCG_RGB_A',0.8])"}; 
	texture = "\A3\ui_f\data\GUI\RscCommon\RscProgress\progressbar_ca.paa"; 
	w = 0.25;
	h = 0.03;
};	
	class CLOAK_BAR
	{
		idd = 10000;
		onload ="((_this select 0) displayCtrl -1) progressSetPosition 1;uiNamespace setVariable [""TAG_CLOAKBAR"", _this select 0];_this ExecVM 'Cloak_ProgressBar.sqf';";
		duration = 10000000;
		class Controls
		{
			class Progress: RscProgress 
				{
					idc = -1;
					x = 0.849 * safezoneW + safezoneX;
					y = 0.9350 * safezoneH + safezoneY;
				};
		};
	};
 };

Player init

player addaction ["Cloak", "Cloak.sqf", [], 6, false, true]; 

Cloak.sqf

_Unit = _this select 0;
_id = _this select 2;
player removeAction _id;   


// You can change these and it'll do the rest woooo
timer = 60; 
cooldown = 10;

_Unit hideObjectGlobal true;  
SystemChat "Cloak Active";  
_Unit setCaptive true;  

[timer] spawn {
    disableSerialization;
 number = _this select 0;
_Display = uiNamespace getVariable "TAG_CLOAKBAR";
_setProgress = _display displayCtrl -1;
_setProgress progressSetPosition 1;
_number = (1/number);
BarTimer = 1; 
   for "_i" from 0 to number do 
 {  
       _setProgress progressSetPosition BarTimer; 
       BarTimer = BarTimer - (_number);
	sleep 1; 

   }; 
 };

_source = "#particlesource" createVehicleLocal getPos _Unit;
_source setParticleParams [["\A3\data_f\ParticleEffects\Universal\Refract.p3d",1,0,1,0],"","Billboard",1,    1,    [0,0,.4],[0,0,1],0,1,1,0,[.25,3,.25,0],[[1,1,1,1],[1,1,1,1]],[1.5,0.5],0,0,"","",_Unit];
_source setDropInterval .05;  

while {!(timer == -1)} do 
   {  
       SystemChat format ["%1 seconds left",timer]; 
       timer = timer -1; 
       sleep 1; 
   }; 


_Unit hideObjectGlobal false; 
deleteVehicle _source;  
SystemChat "Cloak Deactivated"; 
_Unit setCaptive false; 

[cooldown] spawn {
    disableSerialization;
 number = _this select 0;
_Display = uiNamespace getVariable "TAG_CLOAKBAR";
_setProgress = _display displayCtrl -1;
_setProgress progressSetPosition 1;
_number = (1/number);
BarTimer = 0; 
   for "_i" from 0 to number do 
 {  
       _setProgress progressSetPosition BarTimer; 
       BarTimer = BarTimer + (_number);
	sleep 1; 

   }; 
 };
timer = 0;
while {!(timer == cooldown)} do 
   {  
       timer = timer +1; 
       sleep 1; 
   };  

player addaction ["Cloak", "Cloak.sqf", [], 6, false, true];
playsound3d ["a3\missions_f_beta\data\sounds\firing_drills\drill_finish.wss",player,false,getPosASL _unit,1,1,100];
systemChat "Your cloak has recharged";  

Cloak_ProgressBar.sqf

disableSerialization;

_Display = uiNamespace getVariable "TAG_CLOAKBAR";
_setProgress = _display displayCtrl -1;
_setProgress progressSetPosition 1;

Because this is the second dialog I have ever made and coupled with my inexperience with scripting, expect errors :P. Although I do think it goes to show that you can still create interesting things in ArmA even if you have limited scripting knowledge!

Again, Eye Candy: Progress Bar

And for those who don't want to copy and paste ;): Test Mission

Share this post


Link to post
Share on other sites
HallyG, thats awesome!

Thank you, I hope you enjoy using it! Took me forever to work out how to do it. Dialogs are such a pain :P

Share this post


Link to post
Share on other sites

I tried it out, and it's great. I'm definitely adding that to my mission.

I've run into an issue though. I moved the particle effects to before the hideObjectGlobal line so that the refract would envelope the player before he blinks out. Issue I'm having is that for some reason the progress bar shows up , and doesn't run down. The cooldown part works though, then when I recloak, the progress bar works fine.

_Unit = _this select 0; 
_id = _this select 2; 
player removeAction _id;  

// You can change these and it'll do the rest woooo 
timer = 60;  
cooldown = 30; 

_source = "#particlesource" createVehiclelocal getpos player; 
_source setParticleCircle [0, [0.1, 0.1, 0.1]];
_source setParticleRandom [0, [0, 0.1, 1], [0.1, 0, 0.1], 0, 0.1, [0, 0, 0, 0.1], 0, 0];
_source setParticleParams [["\A3\data_f\ParticleEffects\Universal\Refract", 1, 0, 1], "", "Billboard", 1, 4, [0, 0, 0], [0, 0, 0.5], 9, 10, 7.9, 0.1, [0.6, 1, 0.9, 0.8], [[0.1, 0.1, 0.1, 1], [0.25, 0.25, 0.25, 0.5], [0.5, 0.5, 0.5, 0]], [0, 0.1, 0.2, 0.5, 0.1, 0.1], 0, 0, "", "", player];
_source setDropInterval 0.1; 
_source attachto [player,[0,0,0]];

sleep 1;

_Unit hideObjectGlobal true;   
SystemChat "Cloak Active";   
_Unit setCaptive true;   

[timer] spawn { 
    disableSerialization; 
    number = _this select 0; 
   _Display = uiNamespace getVariable "TAG_CLOAKBAR"; 
   _setProgress = _display displayCtrl -1; 
   _setProgress progressSetPosition 1; 
   _number = (1/number); 
   BarTimer = 1;  
   for "_i" from 0 to number do  
 {   
       _setProgress progressSetPosition BarTimer;  
       BarTimer = BarTimer - (_number); 
       sleep 1;  

   };  
 }; 


while {!(timer == -1)} do  
   {   
       SystemChat format ["%1 seconds left",timer];  
       timer = timer -1;  
       sleep 1;  
   };

deleteVehicle _source;
sleep 1;
_Unit hideObjectGlobal false;  

SystemChat "Cloak Deactivated";  
_Unit setCaptive false;  

[cooldown] spawn { 
    disableSerialization; 
    number = _this select 0; 
   _Display = uiNamespace getVariable "TAG_CLOAKBAR"; 
   _setProgress = _display displayCtrl -1; 
   _setProgress progressSetPosition 1; 
   _number = (1/number); 
   BarTimer = 0;  
   for "_i" from 0 to number do  
 {   
       _setProgress progressSetPosition BarTimer;  
       BarTimer = BarTimer + (_number); 
       sleep 1;  

   };  
 }; 
timer = 0; 
while {!(timer == cooldown)} do  
   {   
       timer = timer +1;  
       sleep 1;  
   };   

player addAction ["Cloak", "cloak.sqf", [], 6, false, true, "",
"
(uniform player) in
[""U_B_Protagonist_VR"",""U_B_Soldier_VR"",""U_C_Soldier_VR"",
""U_I_Protagonist_VR"",""U_I_Soldier_VR"",""U_O_Protagonist_VR"",""U_O_Soldier_VR""]
"];
playsound3d ["a3\missions_f_beta\data\sounds\firing_drills\drill_finish.wss",player,false,getPosASL _unit,1,1,100]; 
systemChat "Your cloak has recharged";  

Edited by RTEK

Share this post


Link to post
Share on other sites

I tried it out and it seemed to work for me but then I changed "player" to "_Unit" in the cloak.sqf. He is the new version I was trying, I added it so that you don't need to have the condition in the addaction but instead it was in the Cloak.sqf file. When you are not wearing the correct uniform, it informs the player that you do not have the adequate equipment to cloak and so it doesn't let you cloak.

_Unit = _this select 0; 
_id = _this select 2; 
_Unit removeAction _id; 

UsableUniforms = ["U_B_Protagonist_VR","U_B_Soldier_VR","U_C_Soldier_VR","U_I_Protagonist_VR","U_I_Soldier_VR","U_O_Protagonist_VR","U_O_Soldier_VR"];



If ((uniform _Unit) in UsableUniforms) then 
	{

	// You can change these and it'll do the rest woooo 
	timer = 60;  
	cooldown = 30; 

	_source = "#particlesource" createVehiclelocal getpos _Unit; 
	_source setParticleCircle [0, [0.1, 0.1, 0.1]];
	_source setParticleRandom [0, [0, 0.1, 1], [0.1, 0, 0.1], 0, 0.1, [0, 0, 0, 0.1], 0, 0];
	_source setParticleParams [["\A3\data_f\ParticleEffects\Universal\Refract", 1, 0, 1], "", "Billboard", 1, 4, [0, 0, 0], [0, 0, 0.5], 9, 10, 7.9, 0.1, [0.6, 1, 0.9, 0.8], [[0.1, 0.1, 0.1, 1], [0.25, 0.25, 0.25, 0.5], [0.5, 0.5, 0.5, 0]], [0, 0.1, 0.2, 0.5, 0.1, 0.1], 0, 0, "", "", _Unit];
	_source setDropInterval 0.1; 
	_source attachto [_Unit,[0,0,0]];

	sleep 1;

	_Unit hideObjectGlobal true;   
	SystemChat "Cloak Active";   
	_Unit setCaptive true;   

[timer] spawn 
{ 
	disableSerialization; 
	number = _this select 0; 
	_Display = uiNamespace getVariable "TAG_CLOAKBAR"; 
	_setProgress = _display displayCtrl -1; 
	_setProgress progressSetPosition 1; 
	_number = (1/number); 
	BarTimer = 1;  
	for "_i" from 0 to number do  
	{   
		_setProgress progressSetPosition BarTimer;  
		BarTimer = BarTimer - (_number); 
		sleep 1;  

	};  
}; 


while {!(timer == -1)} do  
	{   
		SystemChat format ["%1 seconds left",timer];  
		timer = timer -1;  
		sleep 1;  
	};

deleteVehicle _source;
sleep 1;
_Unit hideObjectGlobal false;  

SystemChat "Cloak Deactivated";  
_Unit setCaptive false;  

[cooldown] spawn 
{ 
	disableSerialization; 
	number = _this select 0; 
	_Display = uiNamespace getVariable "TAG_CLOAKBAR"; 
	_setProgress = _display displayCtrl -1; 
	_setProgress progressSetPosition 1; 
	_number = (1/number); 
	BarTimer = 0;  
	for "_i" from 0 to number do  
	{   
		_setProgress progressSetPosition BarTimer;  
		BarTimer = BarTimer + (_number); 
		sleep 1;  

	};  
}; 
timer = 0; 
while {!(timer == cooldown)} do  
	{   
		timer = timer +1;  
		sleep 1;  
	};   

_Unit addAction ["Cloak", "cloak.sqf", [], 6, false, true, "",""];
playsound3d ["a3\missions_f_beta\data\sounds\firing_drills\drill_finish.wss",_Unit,false,getPosASL _unit,1,1,100]; 
systemChat "Your cloak has recharged";
_Unit addaction ["Cloak", "Cloak.sqf", [], 6, false, true];  


} else 
{ 
// If you're not wearing the correct uniform
	SystemChat "Your suit is not equipped with the Cloaking Technology";
	sleep 1;
	_Unit addAction ["Cloak", "cloak.sqf", [], 6, false, true, "",""];
};

Share this post


Link to post
Share on other sites

Oh ok cool. That works great. Figured out why the bar was showing up delayed. For some reason i had the cutRsc ["CLOAK_BAR","PLAIN"]; down at the bottom of my init.sqf with some other things above it, so I think when I did the first addaction there was a delay in the game reading down the init.sqf to that call for the bar. Moved it to just below the addaction and the bar is there ready to go, moved it back and it gets delayed.

Share this post


Link to post
Share on other sites
Guest

Thanks for sending us the release and sorry for the delay before posting but you know why ;)

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

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

×