Jump to content
Sign in to follow this  

Change rating/side of spawned unit

Recommended Posts

I am working on trying to create a civilian hostage spawn, which you can then free. I have figured that out (with the help of some stolen script, sorry can't remember whose), but now I want to create another trigger that basically if times out causes OPFOR to shoot the civilians. Here is my script, which for testing purposes is changing the units side once he is free: 

if (isServer) then {
_hostageGroup = creategroup civilian;
freegroup = createGroup EAST;

"C_man_1" createUnit [getmarkerPos "spawn", _hostageGroup, "hostage1 = this; this setCaptive true; this switchMove 'Acts_ExecutionVictim_Loop';"];

// Add Hold Action to Free Hostage
/* 0 object */				        hostage1,
/* 1 action title */				"Free Hostage",
/* 2 idle icon */				"\a3\ui_f\data\IGUI\Cfg\HoldActions\holdAction_unbind_ca.paa",
/* 3 progress icon */				"\a3\ui_f\data\IGUI\Cfg\HoldActions\holdAction_unbind_ca.paa",
/* 4 condition to show */			"_this distance _target < 3",
/* 5 condition for action */			"_caller distance _target < 3",
/* 6 code executed on start */			{},
/* 7 code executed per tick */			{},
/* 8 code executed on completion */      	{
						      //  if (_this select 3 select 0 == "Acts_ExecutionVictim_Loop") then {
								_this select 0 playMove "Acts_ExecutionVictim_Unbow";
							// } else {
							//	_this select 0 switchMove "Acts_AidlPsitMstpSsurWnonDnon_out";
						//	};
							_complMessage = selectRandom ["I thought I was gonna die in here!","Thank you so much man.","Can I hug you?"];
							["Hostage", _complMessage] remoteExec ["BIS_fnc_showSubtitle"];
							sleep 0.5;
							(_this select 0) enableAI "MOVE";
							(_this select 0) enableAI "AUTOTARGET";
							(_this select 0) enableAI "ANIM";
							(_this select 0) setBehaviour "SAFE";
							[(_this select 0)] joinSilent freegroup;
							[(_this select 0),(_this select 2)] remoteExec ["bis_fnc_holdActionRemove",[0,-2] select isDedicated,true];

/* 9 code executed on interruption */       {
						_intrMessage = selectRandom ["Hey! I don't wanna die here!","Don't leave me here man! Please!","*Mumbles* Shit shit shit..."];
						["Hostage", _intrMessage] remoteExec ["BIS_fnc_showSubtitle"];
/* 10 arguments */			    [],
/* 11 action duration */		    3,
/* 12 priority */			    0,
/* 13 remove on completion */		    true,
/* 14 show unconscious */		    false
] remoteExec ["BIS_fnc_holdActionAdd",[0,-2] select isDedicated,true];

	[west, ["rescue"], ["We have more reports of mass executions in this area, secure the area and see if anyone can be saved.", "Rescue civilians", "Rescue"], getMarkerPos "spawn", true] spawn BIS_fnc_taskCreate;
	["rescue", "ASSIGNED",true] call BIS_fnc_taskSetState;

hostage_rescue = createTrigger ["EmptyDetector", getMarkerPos "spawn", true];
hostage_rescue setTriggerActivation ["NONE", "NOT PRESENT", false];
hostage_rescue setTriggerStatements ["hostage1 in units freegroup", "['rescue', 'SUCCEEDED', true] call BIS_fnc_taskSetState;",""];


This makes the civilian spawn, adds the action to free him, and when rescued he joins freegroup (which I know works due to the trigger activating and completing task). If I am in Zeus, the units group icon will change to an OPFOR diamond, but remain purple. BLUFOR units will also never fire on him. I have tried spawning instead of a civilian an OPFOR unit, same result EXCEPT the spawned OPFOR unit WILL shoot at BLUFOR units, who don't shoot the OPFOR unit. I have also tried using addrating -10000, but still the BLUFOR units will not shoot. I can also add units using Zeus (in case already placed units won't detect for some reason) and still nothing. Any help appreciated!

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