Jump to content
Sign in to follow this  
adamjm

Arma 3 Steal Enemy Uniform Script

Recommended Posts

Hi All,

I have been working on a script for a mission to allow a player to kill an enemy and steal his clothes.

;Uniform steal action by adamjm

_deadguy = _this select 0
_caller = _this select 1
_id = _this select 2

;Get uniform of dead soldier
_clothes = uniform _deadguy

;remove whatever player are wearing first
~(random 0.3)
;remove existing uniform
removeUniform _caller

;remove headgear too - only works after uniform
~(random 0.3)
removeAllAssignedItems _caller
~(random 0.3)
;remove webbing / cargo containers as well - optional
;removeAllContainers _caller

~(random 0.3)
;add dead person uniform
_caller addUniform _clothes
~(random 0.3)
;remove clothes from deadguy so it doesn't look like you magically cloned his clothes
removeUniform _deadguy

;remove action
_deadguy removeAction _id

titletext ["You have changed clothes","plain"];
exit

Please see youtube demonstration of where I am at and the issue I've encountered.

For some reason you can steal their clothes when they are alive, but if you shoot them first (as you would in a mission) you cannot.

It seems to me that when a unit is dead it is no longer wearing that uniform name, so the script can't use it anymore. The unit name still can be used because you can still remove their clothes. It is really weird.

Any ideas?

Thanks.

Share this post


Link to post
Share on other sites

I'm not sure as to why, but I had a good laugh from him running away after you striped him XD

Sorry I couldn't be more help.

Share this post


Link to post
Share on other sites

I made a very simple script. I placed an addAction command to a trigger, which condition was "!alive enemy1" like so

stealUniform = enemy1 addAction["(take uniform)", "uniform.sqf", nil, 6, True, True, "", "(_target distance _this) < 4"];

On the uniform.sqf I wrote simply

//

removeUniform player;

removeHeadgear player;

player addUniform "U_OI_combatUniform_ocamo";

player addheadGear "h_helmet0_ocamo";

removeUniform enemy1;

removeheadGear enemy1;

player setCaptive true;

player removeAction stealUniform;

//

Works just fine. The enemy will not shoot you, until you make another script that when you open fire at enemy, or something like that, it sets setCaptive to false...

Only problem is that I don´t get the headgear for some reason. I checked the item name a 1000 times, and it wont work. But other than that.. incredibly simple script which works for me.

Share this post


Link to post
Share on other sites
I made a very simple script. I placed an addAction command to a trigger, which condition was "!alive enemy1" like so

stealUniform = enemy1 addAction["(take uniform)", "uniform.sqf", nil, 6, True, True, "", "(_target distance _this) < 4"];

On the uniform.sqf I wrote simply

//

removeUniform player;

removeHeadgear player;

player addUniform "U_OI_combatUniform_ocamo";

player addheadGear "h_helmet0_ocamo";

removeUniform enemy1;

removeheadGear enemy1;

player setCaptive true;

player removeAction stealUniform;

//

Works just fine. The enemy will not shoot you, until you make another script that when you open fire at enemy, or something like that, it sets setCaptive to false...

Only problem is that I don´t get the headgear for some reason. I checked the item name a 1000 times, and it wont work. But other than that.. incredibly simple script which works for me.

This is fine if you are happy to manually specify the uniform but its not really practical to use. I've been looking into this and it seems BIS have put some sort of block in place that's triggered once the unit is dead. It acts like the units uniform no longer exists.

I've come up with a work around that solves this. You basically need to create a reference for the units uniform at the start of the mission when he is still alive e.g badguyuniform = uniform unit. I'm currently doing this via a trigger.

In your script you then use this reference for adding the uniform e.g player adduniform badguyuniform

Also using "setcaptive true" is not the best way in my opinion to pretend to be an enemy unit. It's easier to just make your unit join an enemy group.

I've been working on a script and a sample mission similar to the one BIS demo'd where you could change uniform. I've got it working for the most part but there are a few issues I still need to solve. Will post when it's done.

On a side note I've observed that civilians have no uniform restrictions and can take uniform from dead units from either side.

Edited by pomigit

Share this post


Link to post
Share on other sites

For sneaking you'd probably want to use setCaptive combined with some logic that decides when you are detected. Works better than joining an enemy group IMO, as that would make you as un-detectable as setCaptive would, and in my experience can cause some other unpredictable AI issues.

Share this post


Link to post
Share on other sites
some logic that decides when you are detected

is exactly the problem with setcaptive. What logic do you use? This has been talked about for ARMA 2 and the best answer I've seen is to use addEventHandler ["fired"]. But that doesn't make sense. You fire your weapon and then they see you as an enemy and shoot you?

Joining an enemy group is a lot simpler and more effective. Enemy see you as a friendly, but will shoot you once you start killing them. Also important is how friendly units see you. It doesn't make sense for you to be walking around in an enemy uniform and yet friendlies know you are not an enemy and don't shoot.

Share this post


Link to post
Share on other sites

After a bit more testing I've concluded that "setcaptive" is probably a little less complicated to manage. Making your unit join an enemy group behaves better in my opinion because it takes at least 2 kills before you get shot and friendlies will think you are an enemy and shoot you if say you walk into a friendly base wearing an enemy uniform. But the problem with this approach is that it messes with your rating. i.e you get a negative score for every enemy kill. Gets messy to manage. And AI enemy doesn't always attack for some reason.

So I've got "setcaptive" working ok using "addeventhandler ["killed"]. Basically as soon as you kill an enemy your cover is blown. I've done this for every enemy unit by putting the following in an init

{
  if ((side _x) == East) then
  {_x addeventhandler ["killed", {player setcaptive false}];
  };
} forEach allUnits;

Below is the sample mission I've put together to demonstrate how it works. As soon as you get out of the water, walk up the gap in the rocks and kill the patrolling enemy unit. He is the only one you can take uniform from (might look at making it universal later using a script). The option to take the uniform is done via action menu exactly the same as the BI demo video. I've also included the option to put your BLUFOR Uniform back on. Even though in this demo you are a diver, you could use this script for any unit and it will revert to whatever you started with.

http://www.mediafire.com/download.php?ctp3he9444poxod

Share this post


Link to post
Share on other sites

When you join an enemy group and start killing them you won't necessarily become enemy. Don't count on the rating system to do the job for you. It is not reliable.

As for what logic - That's exactly what you'll have to decide. You can go as simple as first kill removes the captive status, and as complicated as seeing if enemy knew about your position when you killed them, or spending too much time too close to an enemy will get you detected, or whatever your imagination allows. Just make sure whatever system you use is intuitive, or else it will become annoying to the player.

Share this post


Link to post
Share on other sites

here's an easy way to get the uniform of a dead unit from the config. this will obviously not work if the dead unit changed clothes mid mission. all you need to do is add your preferred method to avoid enemies shooting you after you switched uniforms. i will release an updated version of this including a short delay for changing plus animation and sound for stealthy missions. feel free to use this code though.

here's how it works:

put this inside the enemy unit's init line:

this addAction ["steal uniform", "steal_uni.sqf", [], 1, false, true, "", "!alive _target"];

this will make sure the action is only available when the unit is dead to avoid skyrim-esque awkwardness (stealing clothes of off a conscious person)

and here goes the steal_uni.sqf

_obj = _this select 0;

_caller = _this select 1;

_id = _this select 2;

_class = typeof _obj;

_uniclass = getText (configFile >> "CfgVehicles" >> _class >> "uniformclass");

_uniclassp = uniform _caller;

RemoveUniform _obj;

RemoveUniform _caller;

_caller addUniform _uniclass;

_obj addUniform _uniclassp;

_obj removeaction _id;

to workaround the fact that the uniform class can't be retrieved from dead units i get it from the config.

it's just a basic concept. lots of room for improvement

Share this post


Link to post
Share on other sites
When you join an enemy group and start killing them you won't necessarily become enemy. Don't count on the rating system to do the job for you. It is not reliable.r.

Yep agree, as per my last post. I concluded you were correct. Rating is messy and is unreliable. i did find that manually setting the rating to -1000000 once you kill someone gave pretty reliable results, but it then creates problems reverting back to friendly, because every time you kill someone it modifies this value.

Let me know what you think of the sample mission. The triggering of "cover blown" is pretty basic. It doesnt account for whether you are seen by any other unit when you kill someone or suspicious activity.

Edited by pomigit

Share this post


Link to post
Share on other sites

Sorry to revive this old thread but it relates to this mostley.

Is it possible create a script like above, but instead of taking from a dead ai, from say a crate, to be seen/treated as if you were taking that item straight from the crate and wearing it... In particular civilian clothes?

Share this post


Link to post
Share on other sites

id like this to be a feature in game. Makes sense, steal enemy clothes, blend in.

Share this post


Link to post
Share on other sites
Sorry to revive this old thread but it relates to this mostley.

Is it possible create a script like above, but instead of taking from a dead ai, from say a crate, to be seen/treated as if you were taking that item straight from the crate and wearing it... In particular civilian clothes?

I'm busy making something like that. I just need to figure out how to determine the side or faction the clothes are meant to be on from the config.

Edited by Phoenix_ZA

Share this post


Link to post
Share on other sites

Done.

The code snippet from my script that finds the side of clothes is as follows:

// Each uniform has its own person model which contains the side info
_uniform_man = getText (configfile >> "CfgWeapons" >> (uniform _subject) >> "ItemInfo" >> "uniformClass");

// That person model must be civilian
if !( getNumber (configfile >> "CfgVehicles" >> _uniform_man >> "side") == 3 ) exitWith {true};

Here is my whole script. Save the following code into a file called undercover.sqf into your root mission directory:

/*
Author(s):
	Phoenix of Zulu-Alpha

License:
	APL-SA: http://www.bistudio.com/english/community/licenses/arma-public-license-share-alike

Purpose:
	Makes the target unit (should be a player) be undercover (set as captive) unless these conditions are met:

		The subject has a non civilian uniform, nor a civilian uniform that has been compromised earlier, a vest, backpack, any
		headgear with armor, any primary or secondary weapon on person (pistols can be carried but must be holstered or hidden),
		holding any equipment in their hands (even binocs), must not be using NVGs or thermals, must not be in a non civilian
		vehicle and must not be closer than 5 meters to an enemy who would be able to see you (you can be behind them or behind a wall for eg).

	If any one of these conditions are violated and there is an enemy who is close enough (within 200m), who has you within their FOV
	(from 60 deg at 0m to 10 deg at 200m) and has LOS of you and fully knows about you, then your uniform will be compromised and remembered by
	all enemies and you	would have to change into a different civilian uniform in order to remain under cover. Note that you cannot compromise
	a uniform for someone else, as the enemy only remembers the particular combination of person and uniform.

Params:
	0: OBJECT - Person to make undercover

Return:
	Null

Example:
	nul = [this] execVm "undercover.sqf";

Version: 1.0

Changelog:
	v1.0
		- First release
*/

private ["_subject"];
_subject = _this select 0;

// Should be local
if !(local _subject) exitWith {};

// Initialize isConspicuous variable, used for keeping track of
// whether or not the person's cover should be blown
_subject setVariable ["isConspicuous", true];

// Initialize compromised_uniforms variable, used to keep track
// of uniforms the enemy has noticed you wearing
_subject setVariable ["compromised_uniforms", []];

// Start off by making sure the subject is not captive
_subject setCaptive false;

// Spawn loop that checks if the appearance is conspicuous
[_subject] spawn {

private ["_subject"];
_subject = _this select 0;

// Make sure the unit is initialized
waitUntil {!isNull _subject};

// Infinite loop
for "" from 0 to 1 step 0 do {

	private ["_isConspicuous", "_uniform_man", "_isConspicuous_var"];
	_subject = _this select 0;

	// High performance switch statement. If any one of these is not met, then the person is conspicuous
	_isConspicuous = call {

		// Check if the the uniform is compromised
		if ( (uniform _subject) in (_subject getVariable ["compromised_uniforms", []]) ) exitWith {true};

		// Each uniform has its own person model which contains the side info
		 _uniform_man = getText (configfile >> "CfgWeapons" >> (uniform _subject) >> "ItemInfo" >> "uniformClass");

		// That person model must be civilian
		if !( getNumber (configfile >> "CfgVehicles" >> _uniform_man >> "side") == 3 ) exitWith {true};

		// Must not have vest or backpack
		if !( vest _subject == "" ) exitWith {true};
		if !( backpack _subject == "" ) exitWith {true};

		// The headgear must not have any armor
		if !( getNumber (configfile >> "CfgWeapons" >> (headGear _subject) >> "ItemInfo" >> "armor") == 0 ) exitWith {true};

		// Must not have primary, secondary or active weapons
		if !( primaryWeapon _subject == "" ) exitWith {true};
		if !( secondaryWeapon _subject == "" ) exitWith {true};
		if !( currentWeapon _subject == "" ) exitWith {true};

		// Check if using thermals or NVGs (advanced optics)
		if !( currentVisionMode _subject == 0 ) exitWith {true};

		// Check if driving non civ vehicle
		if !(
				if (vehicle _subject != _subject) then {getNumber (configfile >> "CfgVehicles" >> (typeOf (vehicle _subject)) >> "side") == 3} else {true}
			) exitWith {true};

		// Not conspicuous
		false

	};

	// Get global isConspicuous var
	_isConspicuous_var = _subject getVariable ["isConspicuous", true];

	// If is conspicuous but the var is not yet set to reflect that, then set it and hint the player
	// as he\she most probably just became conspicuous
	if (_isConspicuous && !_isConspicuous_var) then {
		hint "You now look conspicuous!";
		_subject setCaptive false;
		_subject setVariable ["isConspicuous", true];
	};

	// Otherwise if it is visa versa, then set to not captive and hint the player
	if (!_isConspicuous && _isConspicuous_var) then {
		hint "You don't look conspicuous now.";
		_subject setCaptive true;
		_subject setVariable ["isConspicuous", false];
	};

	// Delay timer
	sleep 2;

};

};


// Spawn loop that checks ai are close enough, in LOS, knows about and in correct angle
// to discover the subject and remember it's uniform in order to compromise its cover.
[_subject] spawn {

private ["_subject"];
_subject = _this select 0;

// Make sure the unit is initialized
waitUntil {!isNull _subject};

// Infinite loop
for "" from 0 to 1 step 0 do {

	private ["_uniform", "_compromised_uniforms"];
	_subject = _this select 0;
	_uniform = uniform _subject;

	{

		// If the uniform is already known by the enemy then that person can't be undercover
		// anymore anyway and there is nothing to do in this current loop count.
		_compromised_uniforms = _subject getVariable ["compromised_uniforms", []];
		if (_uniform in _compromised_uniforms) exitWith {};

		// If the uniform is not compromised, then carry on looking for compromising enemies
		call {

			private ["_distance", "_fov_max", "_dirTo"];

			// If unit not on an enemy side
			if !( (playerSide getFriend side _x) < 0.6 ) exitWith {};

			// If enemy doesn't know enough about him
			if !(_x knowsAbout _subject == 4) exitWith {};

			// If enemy not close enough
			_distance = _subject distance _x;
			if !( (_distance) <= 100 ) exitWith {};

			// The maximum FOV that the subject can be detected at (from 60 deg at 0m to 10 deg at 200m)
			_fov_max = (-0.25 * (_distance) + 60) max 0;

			// Direction to the subject from the enemy
			_dirTo = abs ( getDir _x - ([_x, _subject] call BIS_fnc_dirTo) );

			// Exit if out of FOV
			if (_dirTo > _fov_max) exitWith {};

			// Exit if no LOS
			if (lineIntersects [eyePos _subject, eyePos _x, _subject, _x] || {terrainIntersectASL [eyePos _subject,  eyePos _x]}) exitWith {};

			// If the subject is conspicuous, then the current enemy must blow the cover by rememebring the uniform
			if (_subject getVariable ["isConspicuous", false]) exitWith {
				_compromised_uniforms set [count _compromised_uniforms, _uniform];
				_subject setVariable ["compromised_uniforms", _compromised_uniforms];
			};

			// If the subject is not conspicuous, but close enough, then the cover will still be blown
			if (_distance <= 5) exitWith {
				_compromised_uniforms set [count _compromised_uniforms, _uniform];
				_subject setVariable ["compromised_uniforms", _compromised_uniforms];
			};

		};

	} count allUnits;

	// Delay timer
	sleep 2;

};

};

Edited by Phoenix_ZA
  • Like 1

Share this post


Link to post
Share on other sites

@Phoenix

Looks good. Thanks for sharing your script. Can't wait to actually try it in game.

I also gave this steal uniform thing a shot weeks back and here is what I came up with.

Crude way, activated via voice commands.

Share this post


Link to post
Share on other sites

Voice commands seem compelling. Hopefully the API is easy to use.

BTW my script is meant for hiding amongst civilians, so not for blending in with the enemy (as that seems less plausible in this day and age)

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  

×