Jump to content
Sign in to follow this  
Ronin[NR]

Camo faces Script

Recommended Posts

This may have already been posted somewheres, so apologies in advance.

The below script takes a group and sets a camo face for each of the units in that group

Place a logic, call it server

Place a functions logic

Create a group - initialize with

enemygroup1 = group this

In a radio trigger - OnActivation

_nul = enemygroup1 execVM "r_camoface.sqf"

r_camoface.sqf

//This script will apply a random camo face to AI soldiers when called

//Check if script is running on server, if not, then exit

if ( isServer ) then {

//Initialize functions
waitUntil{!(isNil "BIS_fnc_init")};
waitUntil{!(isNil "BIS_MPF_InitDone")};


//Set Camoface!
{_x setFace format["face%1_camo%2" ,round(random 106) ,round(random(5))]}foreach units _this;
}

Works on dynamically created groups too, but this is for another thread :p

Just one of those little snippets peeps may want or find a use for ;)

Posted a tube aswell with instructions

Edited by Ronin =ASP=

Share this post


Link to post
Share on other sites

Having created something similar (see below), a few suggestions:

- account for faces 0 - 9 being named 01 .. 09

- camo 0 is the un-camo'd face, you may want to avoid this

- this function also applies a random faces, potentially providing (for example) Russian or Takistan forces with black faces. You may want to add a parameter to define the nationality, and leave out certain faces to reflect that nation's population characteristics.

Regards, William

comment "Customize face of each unit in the group according a profile";
comment "Invoke as: nul = [group this, 'usarmy1985'] execVM 'planned_assault\kit\apply_group_face_camo.sqf';";
comment "William van der Sterren, (c) 2011, www.plannedassault.com";

private ["_debug", "_script"];
_script   = "camo_group_faces.sqf";
_debug    = 0;

private ["_group", "_profile"];
_group     = _this select 0;
_profile    = _this select 1;

if (_debug == 1) then { diag_log (format ["time: %1 [%3, %4] exec '%2' - entered", time, _script, _group, _profile]); };

{
private ["_face_ix", "_camo_ix", "_match"];
comment "Select a random face matching the profile";
_camo_ix = floor(random 4) + 2;
_match   = false; 
while { !_match } do 
{
	_face_ix = 1 + floor(random 99);
	_match   = (_profile == "usarmy1985") || (!(_face_ix >= 27 && _face_ix <= 40)) || (!(_face_ix >= 78 && _face_ix <= 87));
};

private ["_face", "_face_fmt"];
if ( _face_ix < 10 ) then { _face_fmt = "Face0%1_camo%2"; } else { _face_fmt = "Face%1_camo%2";};
_face = format[_face_fmt, _face_ix, _camo_ix];
if (_debug == 1) then { diag_log (format ["time: %1 person %2 gets face %3", time, __x, _face]); };
_x setface _face;
} forEach (units _group);

true

Share this post


Link to post
Share on other sites

many thanks for the feedback, its really appreciated.

What I've posted is very basic and your quite right, misses out checks such as nationality and face0 (No camo)

I also appreciate the code that you have posted, am still pretty new to scripting, do you or anyone else reading have suggestions as to how to restructure this to allow for these checks?

Share this post


Link to post
Share on other sites

just one thing:

Place a logic, call it server

Why this? i dont see any use of it in the script.. both functions and MPF is activated through the functions module.

Have seen it earlyer on in many scripts, though i just asumed it was because it was directly used by them.

Anywho, cool snippet thanks, it goes into the collecton.

Share this post


Link to post
Share on other sites

Not entirely sure, but, my understanding of placing a game logic and calling it server, is for mp compatibility.

The line of code

//Check if script is running on server, if not, then exit

if ( isServer ) then {

Checks to see if the script is running on the server as opposed to a client machine. If the game detects it is being called on a client, it will exit, if called on the server, it will run.

This means it will run once on the server as opposed to being run by each client connected/connecting to the server.

As I say, am no scripting guru, and is only based on what I have managed to find and attempt to understand about scripts for an mp environment. Still not sure if this is being implemented as it is intended to be, I don't have a dedicated server to test this on, really based on assumption and research.

If your using it for sp missions, you can get rid of the surrounding block and just use the following:

//Initialize functions
waitUntil{!(isNil "BIS_fnc_init")};
waitUntil{!(isNil "BIS_MPF_InitDone")};


//Set Camoface!
{_x setFace format["face%1_camo%2" ,round(random 106) ,round(random(5))]}foreach units _this;

Glad you like it - If I could find a way to implement what _William suggested, it could come in really handy - At the moment, as it doesn't have the neccessary checks, it has tendency to create black and asian russians, which for me isn't a problem, but, for those who want the 'realism' factor, it could well be.

This posed quite an interesting, slightly off-topic question:

Do black people live in Russia?

Based on the posts there, seems to be a very small minority, made up of international exchange students and other groups. I would imagine there are more, but then again, lets face it...Its cold in most of Russia :p

Edited by Ronin =ASP=

Share this post


Link to post
Share on other sites

I'm not sure you need the BIS function library to use the function. It works for me without it.

My script goes some ways to ensure a group has a pretty consistent way of camouflaging itself, using similar camo patterns (not camo01, not a blank face). See the results:

_a2_p85_panzer_grenadiere.jpg _a2_german_cold_war_fallschirmjaeger.jpg _a2_cwr_camo_face.jpg

The biggest problem I'm having is that swapping a face might switch to a face wearing a modern-day set of glasses/goggles. Occasionally these cold war soldiers receive Oakley M-frames... AFAIK, there is no way to test for that...

Share this post


Link to post
Share on other sites

if ( [url="http://community.bistudio.com/wiki/isServer"]isServer[/url] ) then 

Means that if its server: run it, has nothing to do with a logic named server.

Im pretty sure, that if you remove the logic named server, as long as you dont need it for other scripts ofc, it will all work fine, one less object to deal with.

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  

×