Jump to content
Sign in to follow this  
NeuroFunker

How to make civilians as enemies, and equip them with weapons, some of the gear?

Recommended Posts

Hi guys, i want to make some simple SWAT style mission, infiltrate town with enemy armed civis in it, however i have no idea how to do this. Help pls.

Share this post


Link to post
Share on other sites

Yeah i wanted hostile civilians as well so i took some opfor basic soldiers, removed all their equipments, gears and items and then you're free to add what you want :-) including civilian clothes for exemple!

Share this post


Link to post
Share on other sites

One way to handle this is to set up regular civilians, and make them led by an OPFOR soldier with the "probability of presence" slider set to zero. This way the OPFOR guy won't be around but the civilians whose leader he was regard themselves as OPFOR. Then give them weapons and ammunition with addWeapon and addMagazines. You can find the classnames for equipment from the SIX Config Browser, for example. And more on hostile civilians in the wiki.

Take a look at this and this.

In case you want to go with the dressing OPFOR as civilians, add this to the unit's initialization line:

removeAllWeapons this;
removeUniform this;
removeHeadgear this;
removeVest this;
this unassignItem "NVGoggles";
this removeItem "NVGoggles"; 

followed by the equipment you want to add, for example

this addUniform "U_C_Poloshirt_redwhite";		
this addHeadgear "H_Cap_red";
this addVest "V_BandollierB_cbr";
this addMagazine "HandGrenade";
this addMagazines ["30Rnd_65x39_caseless_green", 5];
this addWeapon "arifle_Khaybar_F";

Since this makes the initialization box quite cluttered, many prefer to use a seperate script file instead, but I guess this is easier for starters.

Share this post


Link to post
Share on other sites

Its going to be a mixture of 'removeallweapons' this etc and addweapon etc.

I am still learning myself, but i would recommend googling those lines, or also looking at them on youtube, because it will help you to understand.

Share this post


Link to post
Share on other sites

I was thinking about this. Is there a way that we can create a script, whereby we can list every Civilian clothing model, but attach a randomiser coding to it. Same goes with vests (e.g. plate carrier, Opfor rig, etc). Something like a probability code.

So instead of making individual scripts per unit, we can just spawn an Opfor group, and let the coding randomise their kit everytime so no two Opfor will have the same clothing + vest + hat (optional).

Surely this must be possible in the scripting. Can this be done?

Opfor is spawned, has 1 in 7 chance of getting one of the Civie clothing, then has 1 in 5 chance of different vests, and then has 1 in 2 chance of getting a hat or not.

Share this post


Link to post
Share on other sites
One way to handle this is to set up regular civilians, and make them led by an OPFOR soldier with the "probability of presence" slider set to zero. This way the OPFOR guy won't be around but the civilians whose leader he was regard themselves as OPFOR. Then give them weapons and ammunition with addWeapon and addMagazines. You can find the classnames for equipment from the SIX Config Browser, for example. And more on hostile civilians in the wiki.

Take a look at this and this.

In case you want to go with the dressing OPFOR as civilians, add this to the unit's initialization line:

removeAllWeapons this;
removeUniform this;
removeHeadgear this;
removeVest this;
this unassignItem "NVGoggles";
this removeItem "NVGoggles"; 

followed by the equipment you want to add, for example

this addUniform "U_C_Poloshirt_redwhite";		
this addHeadgear "H_Cap_red";
this addVest "V_BandollierB_cbr";
this addMagazine "HandGrenade";
this addMagazines ["30Rnd_65x39_caseless_green", 5];
this addWeapon "arifle_Khaybar_F";

Since this makes the initialization box quite cluttered, many prefer to use a seperate script file instead, but I guess this is easier for starters.

hey, thanks a lot! The idea with opfor soldier is reaaly good and simple, ill try that :)

Share this post


Link to post
Share on other sites
hey, thanks a lot! The idea with opfor soldier is reaaly good and simple, ill try that :)

There's a module in A3 modules that should let you do that without this weird grouping.

Share this post


Link to post
Share on other sites

I would go with the opfor units wearing civilian clothing. Easiest way with the desired outcome.

Share this post


Link to post
Share on other sites

There's also another easy way, if you want to make every civilian a hostile:

// Sets civilians hostile towards blufor
civilian setFriend [blufor, 0];
// Sets blufor hostile towards civilians
blufor setFriend [civilian, 0];

You can execute that from init.sqf for example. If you only want to set certain civilians hostile, you should stick

with joinSilent or that 0% probability team leader of opfor faction.

Share this post


Link to post
Share on other sites
There's also another easy way, if you want to make every civilian a hostile:

// Sets civilians hostile towards blufor
civilian setFriend [blufor, 0];
// Sets blufor hostile towards civilians
blufor setFriend [civilian, 0];

You can execute that from init.sqf for example. If you only want to set certain civilians hostile, you should stick

with joinSilent or that 0% probability team leader of opfor faction.

The reason why I didn't mention this was that I thought there was a hardcoded score decrease from killing anyone on the civilian side, at least in ArmA 2. I guess I remembered wrong since I can't find any mentions of it right now.

I was thinking about this. Is there a way that we can create a script, whereby we can list every Civilian clothing model, but attach a randomiser coding to it. Same goes with vests (e.g. plate carrier, Opfor rig, etc). Something like a probability code.

So instead of making individual scripts per unit, we can just spawn an Opfor group, and let the coding randomise their kit everytime so no two Opfor will have the same clothing + vest + hat (optional).

Surely this must be possible in the scripting. Can this be done?

Opfor is spawned, has 1 in 7 chance of getting one of the Civie clothing, then has 1 in 5 chance of different vests, and then has 1 in 2 chance of getting a hat or not.

It is pretty simple, though at least with my limited knowledge pretty cumbersome since the classnames need to be listed manually. This is one way to do it: add if(isServer) then { {if (side _x == opfor) then {nil = [_x] execVM "civguise.sqf"}} forEach allUnits }; to init.sqf, then create a script called civguise.sqf and add this:

waitUntil {!isNil "bis_fnc_init"};

_civ_clothes = ["U_C_Commoner1_1",
               "U_C_Commoner1_2",
               "U_C_Commoner1_3",
               "U_C_Poloshirt_blue",
               "U_C_Poloshirt_burgundy",
               "U_C_Poloshirt_redwhite",
               "U_C_Poloshirt_salmon",
               "U_C_Poloshirt_stripped",
               "U_C_Poloshirt_tricolour"];

_civ_hats    = ["H_Cap_red", "H_Cap_blu", "H_Cap_brn_SERO"];

_vests       = ["V_Rangemaster_belt",
               "V_TacVest_brn",
               "V_BandollierB_cbr"];

_unit = _this select 0;


// Remove original equipment
removeAllWeapons _unit;
removeUniform _unit;
removeHeadgear _unit;
removeVest _unit;
removeBackpack _unit;
_unit unassignItem "NVGoggles";
_unit removeItem "NVGoggles";


// Add vest and clothing
_vest_item = _vests call BIS_fnc_selectRandom;
_unit addVest _vest_item;

_cloth_item = _civ_clothes call BIS_fnc_selectRandom;
_unit addUniform _cloth_item;


// Random integer, if 1 instead of 0, add a random item from the array
if(round (random 1) == 1) then
{

       _hat_item = _civ_hats call BIS_fnc_selectRandom;
_unit addHeadgear _hat_item;
};

// Random weapon loadout
switch (round(random 3)) do
{
       case 0:
       {
               _unit addMagazines ["30Rnd_65x39_caseless_green", 5];
               _unit addWeapon "arifle_Khaybar_F";
       };
       case 1:
       {
               _unit addMagazines ["30Rnd_65x39_case_mag", 5];
               _unit addWeapon "arifle_TRG20_F";
       };
       case 2:
       {
               _unit addMagazines ["200Rnd_65x39_cased_Box", 3];
               _unit addWeapon "LMG_Mk200_F";
       };
       case 3:
       {
               _unit addMagazines ["30Rnd_65x39_caseless_mag", 5];
               _unit addWeapon "arifle_MX_F";
       };
};

_unit addMagazine "HandGrenade";

Now, all units on the OPFOR side will get their equipment cleared and are applied with random clothes and weapon loadouts. In case you want to apply this to only specific units, skip the init.sqf line and add nil = [this] execVM "civguise.sqf"; to the unit's init box instead. It can be applied to whole groups by adding {nil = [_x] execVM "civguise.sqf"}} forEach (units group this); to the init of any single group member.

Uniforms, headgear and vests can be easily added to the relevant arrays in the script, while for more weapon loadouts you need to change the number in "switch (round(random 3)) do" and add new cases. Any more experienced scripter can probably suggest improvements.

Share this post


Link to post
Share on other sites

Yeah, I'm not certain about the score issue but there's another problem with using blufor setFriend [civilian, 0] though, because it makes the blufor AI engage some world objects that happen to be on side civilian. If you are not using friendly AI then I don't see any problems using setFriend.

Share this post


Link to post
Share on other sites
The reason why I didn't mention this was that I thought there was a hardcoded score decrease from killing anyone on the civilian side, at least in ArmA 2. I guess I remembered wrong since I can't find any mentions of it right now.

It is pretty simple, though at least with my limited knowledge pretty cumbersome since the classnames need to be listed manually. This is one way to do it: add if(isServer) then { {if (side _x == opfor) then {nil = [_x] execVM "civguise.sqf"}} forEach allUnits }; to init.sqf, then create a script called civguise.sqf and add this:

waitUntil {!isNil "bis_fnc_init"};

_civ_clothes = ["U_C_Commoner1_1",
               "U_C_Commoner1_2",
               "U_C_Commoner1_3",
               "U_C_Poloshirt_blue",
               "U_C_Poloshirt_burgundy",
               "U_C_Poloshirt_redwhite",
               "U_C_Poloshirt_salmon",
               "U_C_Poloshirt_stripped",
               "U_C_Poloshirt_tricolour"];

_civ_hats    = ["H_Cap_red", "H_Cap_blu", "H_Cap_brn_SERO"];

_vests       = ["V_Rangemaster_belt",
               "V_TacVest_brn",
               "V_BandollierB_cbr"];

_unit = _this select 0;


// Remove original equipment
removeAllWeapons _unit;
removeUniform _unit;
removeHeadgear _unit;
removeVest _unit;
removeBackpack _unit;
_unit unassignItem "NVGoggles";
_unit removeItem "NVGoggles";


// Add vest and clothing
_vest_item = _vests call BIS_fnc_selectRandom;
_unit addVest _vest_item;

_cloth_item = _civ_clothes call BIS_fnc_selectRandom;
_unit addUniform _cloth_item;


// Random integer, if 1 instead of 0, add a random item from the array
if(round (random 1) == 1) then
{

       _hat_item = _civ_hats call BIS_fnc_selectRandom;
_unit addHeadgear _hat_item;
};

// Random weapon loadout
switch (round(random 3)) do
{
       case 0:
       {
               _unit addMagazines ["30Rnd_65x39_caseless_green", 5];
               _unit addWeapon "arifle_Khaybar_F";
       };
       case 1:
       {
               _unit addMagazines ["30Rnd_65x39_case_mag", 5];
               _unit addWeapon "arifle_TRG20_F";
       };
       case 2:
       {
               _unit addMagazines ["200Rnd_65x39_cased_Box", 3];
               _unit addWeapon "LMG_Mk200_F";
       };
       case 3:
       {
               _unit addMagazines ["30Rnd_65x39_caseless_mag", 5];
               _unit addWeapon "arifle_MX_F";
       };
};

_unit addMagazine "HandGrenade";

Now, all units on the OPFOR side will get their equipment cleared and are applied with random clothes and weapon loadouts. In case you want to apply this to only specific units, skip the init.sqf line and add nil = [this] execVM "civguise.sqf"; to the unit's init box instead. It can be applied to whole groups by adding {nil = [_x] execVM "civguise.sqf"}} forEach (units group this); to the init of any single group member.

Uniforms, headgear and vests can be easily added to the relevant arrays in the script, while for more weapon loadouts you need to change the number in "switch (round(random 3)) do" and add new cases. Any more experienced scripter can probably suggest improvements.

Holy CRAP! THIS IS GENIUS! I just tested it out and it works like a charm. Exactly how I always wanted it to be. thank you so so much my friend!

Share this post


Link to post
Share on other sites

There is a change side module in the editor that automatically does the change side of group trick. (just have to sync to group member)

Share this post


Link to post
Share on other sites

This script of mine allows you to designate civilians to be "sleeper agents", that'll engage a specified target or side on approach. It automatically selects the correct opposing side etc. It's fairly customizable, check the code itself for a proper documentation.

The script is set to work with A2 but only two very minor changes are needed to get it work with A3, they are explained in the code. It should also work with the site moduls though for now you'd have to execute the "affect all" version of the script after a short time into your mission as I don't know yet how I can write into the init space of the civs spawned by the site module.

ws_assassins.sqf on github

Edited by Wolfenswan

Share this post


Link to post
Share on other sites

Great script!

I was just about writing that:

EAST = createCenter EAST;
[civUnit] joinSilent grpNull;
_g = createGroup east;
[civUnit] joinSilent _g;

works well. But I see your script is doing this the prettypretty extended way.

Share this post


Link to post
Share on other sites

Throwing this out there in case someone knows how to make such a thing work... I'm using EOS to spawn civilians, in lieu of A3 not having an "ALICE" module. So basically they are cached until a player gets within range at which time they spawn into game. Is there any way to use such a script as this with civilians that spawn in and out around players? Yeah, multiplayer compatible would be nice.

Thanks in advance!

Share this post


Link to post
Share on other sites

What would be nice is to have a way to fire the script in a trigger that the player(s) have activated. It might need a sleep somewhere too. This way, with dynamically spawning civs such as EOS or TPW's, the mission maker could place a trigger around a town, the players get close to the town and trip the trigger, the civs start spawning (sleep on the assassination script so it doesn't fire until all the civs are spawned in) and Wolfenswan's assassination script (set to "true" to affect all civs) takes over. Would something like that work?

Share this post


Link to post
Share on other sites

although if you want/need to go with the opfor-as-civilian route, you could randomize the loadouts like this

 _weapon = ["classname1","classname2",etc.,etc.,] call BIS_fnc_selectRandom;
[_this,_weapon,8] call BIS_fnc_addWeapon;

Share this post


Link to post
Share on other sites
What would be nice is to have a way to fire the script in a trigger that the player(s) have activated. It might need a sleep somewhere too. This way, with dynamically spawning civs such as EOS or TPW's, the mission maker could place a trigger around a town, the players get close to the town and trip the trigger, the civs start spawning (sleep on the assassination script so it doesn't fire until all the civs are spawned in) and Wolfenswan's assassination script (set to "true" to affect all civs) takes over. Would something like that work?

I would love to see what you're trying to approach here. I'm not a big fan of how great ideas seem to fade into the mist in gaming forums >:(

I've also been trying to figure this out for quite a while on dynamically spawned civilians. Let's face it, ALiVE is just too RAM and virtual memory hungry when it comes to populating a map - I really wish they would put some of the stress on the CPU, the bulk of it in a dynamic external cache, and preserve the virtual memory and RAM as best as possible as it causes severe performance drops when the AI is active right now, even with the profiling system (That goes for BIS and the ALiVE dev team). If anyone has solved the mystery of working with dynamically created civilians while also saving their locations / last activities in an external file for when they're out of range for caching, I would love to see your solutions.

PS. ALiVE team, I love your work, don't take it too harshly; I know that the bulk of it is outside of your control.

Share this post


Link to post
Share on other sites

In case you want to go with the dressing OPFOR as civilians, add this to the unit's initialization line:

removeAllWeapons this;
removeUniform this;
removeHeadgear this;
removeVest this;
this unassignItem "NVGoggles";
this removeItem "NVGoggles"; 

followed by the equipment you want to add, for example

this addUniform "U_C_Poloshirt_redwhite";		
this addHeadgear "H_Cap_red";
this addVest "V_BandollierB_cbr";
this addMagazine "HandGrenade";
this addMagazines ["30Rnd_65x39_caseless_green", 5];
this addWeapon "arifle_Khaybar_F";

Since this makes the initialization box quite cluttered, many prefer to use a seperate script file instead, but I guess this is easier for starters.

This is correct. In my several months of mission scripting and building, making civs hostile has been impossible so dressing up CSAT forces as civs is your best bet.

Share this post


Link to post
Share on other sites

One thing to note for this discussion. Uniforms are side restricted, so not every civilian uniform will be fair game when putting them on opFor soldiers. It is not a reliable solution.

Share this post


Link to post
Share on other sites
One thing to note for this discussion. Uniforms are side restricted, so not every civilian uniform will be fair game when putting them on opFor soldiers. It is not a reliable solution.

Indeed there are restrictions however, you can use 'forceaddUniform'

Also i think this needs work...

this unassignItem "NVGoggles";

this removeItem "NVGoggles";

I believe it needs to be;

this unassignItem "NVGoggles_OPFOR";

this removeItem "NVGoggles_OPFOR";

Share this post


Link to post
Share on other sites

I would try just grouping them to opposite faction, arm them with random weapons and equipment to your taste. Set the 1 opposite faction unit to 0 probability and try that. I have tried other ways, changing opfor uniforms and stuff. I don't think there is an easy way. I would take may be 8 civ's and group them, give them different gear and then just copy those to make more. Not 100% on grouping civ's, it works for FIA to group them to opfor / AAF etc to fight Nato. I dislike how BIS has set this up. Way more work then I care. BUT welcome to ARMA editor.

Share this post


Link to post
Share on other sites
I would try just grouping them to opposite faction, arm them with random weapons and equipment to your taste. Set the 1 opposite faction unit to 0 probability and try that. I have tried other ways, changing opfor uniforms and stuff. I don't think there is an easy way. I would take may be 8 civ's and group them, give them different gear and then just copy those to make more. Not 100% on grouping civ's, it works for FIA to group them to opfor / AAF etc to fight Nato. I dislike how BIS has set this up. Way more work then I care. BUT welcome to ARMA editor.

Redress is simpler than weird unit grouping which just looks a complete mess on the editor. I've actually got a couple of functions to quickly redress to FIA or a new faction called MFA (Militant Forces for Altis) based on the unit classname on my computer (Meaning that you can redress every CSAT unit with a couple of lines of code) if you'd like them.

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  

×