Jump to content
Sign in to follow this  
michel87

Realistic insurgents. pick up weapon and fire..

Recommended Posts

Hello members

i search on the internet but cant find it.

i want a realistic thing that happens in iraq and afghanistan. you see civilians on farms or villages and the first time without a weapon. the second time you got ambush fire by the same person with a weapon. is there a script or something. that you see first a person without weapon and when u walk on a trigger or something he has a weapon and fire on you.

second.

automatic fire enemy on trigger wirth rpg's. if i walk onm a trigger the enemy fire direct a rpg to a location. also when he not see me or spot me. just when i walk on a trigger. boem a rpg out. is that possible.

i hope if somebody can help me..

Share this post


Link to post
Share on other sites

1. You could try the "addWeapon" command

2. Dunno but i'm not a scripting master so...

Share this post


Link to post
Share on other sites
1. You could try the "addWeapon" command

2. Dunno but i'm not a scripting master so...

then why did you even bother replying?

Share this post


Link to post
Share on other sites
then why did you even bother replying?

trollling forums, hows that going for you??

As ArmAriffic said use the addWeapon command.

Share this post


Link to post
Share on other sites

One other thing you might try is putting the guys on the map as civilians, but then right before you use addWeapon to arm them, use commands to assign the units to (an) OPFOR group(s). That way they can be nice and docile until such time as they decide to arm themselves, when they will suddenly coordinate an attack on Western soldiers. :P

Share this post


Link to post
Share on other sites

Or instead have them setcaptive true, then when triggered add the weapon/ammo and setcaptive false. Will just need the OpFor units without the masks haha

Share this post


Link to post
Share on other sites

Here's what I did:

Used AddWeapons script, placed a civilian and named him civ1, made a trigger set off by blufor presence. in the triggers on Act. box I put:

[civ1,["M4A1",2]] exec "cly_addweapon.sqs"

Now when blufor enter the trigger civ1 is equipped with an M4 and 2 clips. The problem I kept running into though, was how to get the civilian to then attack blufor troops. I tried a few different ways, but either he wouldn't attack, or blufors would recognize them as an enemy even if the civilian was unarmed and shoot them on site.

That was until I read that civilians, once armed, take the allegiance of whatever the independents are set too. So if you want hostile civilians once armed, just set your independents to friendly to nobody, or friendly to opfor. This way, blufor won't attack civilians until they are armed and start engaging blufor troops.

Edited by Rail82

Share this post


Link to post
Share on other sites

if you want multiple civilians to be armed off one trigger I put:

[civ,["M4A1",2]] exec "cly_addweapon.sqs"; [civ1,["M4A1",2]] exec "cly_addweapon.sqs"; [civ2,["M4A1",2]] exec "cly_addweapon.sqs";

in the on act. box of the trigger. Now I am still new at this scripting stuff, I'm sure there is an easier way to do this besides putting the individual command for each unit, but for my purposes this works for me.

I grouped those 3 civilians together and gave the group leader a 50% probability of appearance, and a 200m spawn radius. I then set the condition of the other 2 civilians to:

alive civ

So now the group of 3 civilians may or may not be on the map, if they are, they spawn in a 200m radius, and 1 trigger arms all 3 of them and they will now attack blufor on sight.

Put these groups and triggers all over the map, add in ambient civilian module, and you now have a completely random insurgency.

Share this post


Link to post
Share on other sites

Can you not, then, simply script the civs to join a group of side east (assuming the player is side west) in order to avoid having to change the allegiance of the resistance faction?

Share this post


Link to post
Share on other sites

I tried to do it that way at first. I linked the civilians to an opfor unit and then set that unit to a probability of 0. The problem with it, was that blufor would shoot the civs on site regardless of whether or not they were armed. I also tried to link them to a side via trigger, and even a join and join and lead waypoint, but they either didn't work as expected, or completely didn't work.

At least by manipulating the independents, the civs aren't considered hostile until they are armed and engage.

I'm sure that there is a better way to do this, like I said, I'm really really new at this, and have only made a handful of missions using scripts and commands. But this is the easiest way I figured out how to do it. Like I said in another post, for my purposes this works for me, if someone knows a better way, or if you can find a better way, then have at it, as I'm sure there is a better way, I just don't know of it because I'm very very green when it comes to this.

Share this post


Link to post
Share on other sites

once bluefor is near whatever, have civilians take up weapons and then do this:

_group = createGroup east;

[_civilianname] joinsilent _group;

this will create a east group, then the name above will join that east group.

and be enemy.

Share this post


Link to post
Share on other sites
once bluefor is near whatever, have civilians take up weapons and then do this:

_group = createGroup east;

[_civilianname] joinsilent _group;

this will create a east group, then the name above will join that east group.

and be enemy.

I'm not understanding this, am I putting this in a trigger on act, or am I making a .sqf, or am I putting it in a civilians init? I keep getting errors no matter where I try to put it.

I've tried it several different ways and it's not working for me. I keep getting variable in global space, and invalid number in expression errors when I put it in a trigger or in a unit. I even made a .sqf and had a trigger pointing to it in game, and nothing happened when I activated the trigger.

And while the switching independents allegiance thing worked for my purpose, I found out when I did it on a larger scale, that some groups even when armed, will not engage, and BLUFOR won't engage them. I even gave the civ's seek and destroy waypoints with open fire engage at will and aware. Some groups are fast to light up BLUFOR, while others seem to care less and just stand there looking at me with their weapons at ease. So figured if I want the mission to be how it is in my head, I need to step up my game a little bit, and not take the shortcut.

And there is just something not right about beating a mission and having a negative score for killing a bunch of "civilians".

edit:

im stupid, i got it to work

Edited by Rail82

Share this post


Link to post
Share on other sites

As a quick followup to this, I have been thinking about using this in scenarios for some time since reading this thread and have quickly thrown together the following.

// Paste the following in "rebel.sqf"

_grpLdr = _this select 0;
_wpnCache = _this select 1;
_grpThis = group _grpLdr;

sleep (5 + (random 10));

_armWaypoint = _grpThis addWaypoint [getPos _wpnCache, 0];
_armWaypoint setWaypointCompletionRadius 2.5;
_armWaypoint setWaypointType "MOVE";
_armWaypoint setWaypointBehaviour "COMBAT";
_armWaypoint setWaypointSpeed "FULL";
_armWaypoint setWaypointStatements ["true", 
    "_grpOPFOR = createGroup east; 
     (units group this) joinSilent _grpOPFOR;
     {_x addMagazine ""10x_303"";
      _x addWeapon ""LeeEnfield"";} forEach units _grpOPFOR;"];
_grpThis setCurrentWaypoint _armWaypoint;

Instead of my addweapon nonsense, you can just throw in a call to that armament script you linked and voila. Now whatever you want to give the civilians cause to arm themselves should just declare:

nul = [nameOfCivGroupLeader, nameOfObjectYouWantThemToGoStandNextTo] execVM "rebel.sqf";

Of course mine does it a group at a time, and arms them all identically. Just demonstrating the technique since I got it working as such ;p

Edit:

To elaborate, the first parameter sent to the sqf will name the leader of a group of civilians. When the script is called, the group led by that man will then run full speed to within 2.5 meters of whatever object is named in the second parameter sent to the script. Then, they will arm themselves as prescribed. Finally, since they're all still residually in "combat" mode, they will begin taking cover and engaging known hostiles (BLUFOR).

Edited by dwringer

Share this post


Link to post
Share on other sites

The independent trick seems to work wonderfully. That's a nice piece of information! :)

So yeah, it should be easy, just make independent enemy with whatever side is playing the mission, and then all you have to do is script the weapon addition.

If players are already play independent, then I think the easiest way would be to just make the players play bluefor/opfor by grouping them with blufor/opfor unit that has a 0% probability of presence, since controlling the armed civilians side would be a bit more difficult.

Share this post


Link to post
Share on other sites

I just tried the independent trick. The armed civilian set friendly to neither side engaged nearby Blufor units however the Blufor did not return fire.

Share this post


Link to post
Share on other sites
I just tried the independent trick. The armed civilian set friendly to neither side engaged nearby Blufor units however the Blufor did not return fire.

Sometimes they will return fire, but I found out it happens more like if you sit and shoot friendlies... they'll let you kill a few of your own before they turn on you and open fire back.

Like I said, when I was testing that method, most of the time it worked fine, but the AI felt a little sluggish to react to each other and then at random there would be no reaction to each other.

That's why I switched the mission up and used the creategroup and joinsilent commands and it works like a friggin charm. AI is really responsive and both sides are quick to engage once the civs go from civ to east. And at the end of the mission you'll have positive points because it counts those civs as opfor kills. IF you just use the independent trick, you'll have a negative score because you just spent an entire mission killing "civilians".

IF you just link the civs to an opfor unit even with a probability of 0, blufor will fire on the civs even if they are unarmed.

creategroup and joinsilent worked out the best for me. Now I can pass a group of civs and when I activate the trigger they pick up guns and fire on me. Depending on where the trigger is, a lot of the time the civ group is behind me when they pick up weapons, so it gets pretty intense. This way blufor doesn't recognize them as enemy until the moment when it's already too late... makes for an interesting patrol mission.

My trigger to do this looks like this:

Blufor present

on act: (I first set weapons for all 3 members of civ group) then I use: t1=createGroup east; [civ] joinsilent t1; [civ1] joinsilent t1; [civ2] joinsilent t1;

Now when I enter the trigger the civs pick up arms and join OPFORs side.

Edited by Rail82

Share this post


Link to post
Share on other sites

dwringer,

I've been looking for something like your script for for quite some time to add a little flavour to COIN type missions. I've copied the script and init line from your post as per but unfortunately I can't seen to get it to work. The civilian is running to the weapons cache ok but is neither being armed or switching sides. Unfortunately its beyond my extremely meagre scripting abilities to work out what the problem is so would be very greatful for any advice.

Share this post


Link to post
Share on other sites

Sorry, that script I posted before was pretty buggy and not very smart on my part. Since then I've worked it out to be a lot more detailed; here are the results:

First, rebel.sqf

_grpLdr = _this select 0;
_wpnCache = _this select 1;
_grpThis = group _grpLdr;
_mgznMen = """10x_303""";
_wpnMen = """LeeEnfield""";
_mgznLdr = """75Rnd_545x39_RPK""";
_wpnLdr = """RPK_74""";

{_x allowFleeing 0;} forEach units _grpThis;
{_x setVariable ["hasRebelled", true];} forEach units _grpThis;
sleep (5 + (random 10));
_grpNew = createGroup (side _grpLdr);
_wptRegroup = _grpNew addWaypoint [waypointPosition [_grpThis, 0], 0];
_wptArm = _grpNew addWaypoint [position _wpnCache, 0];
_wptDummy = _grpNew addWaypoint [position _wpnCache, 5];
_wptRegroup setWaypointType "MOVE";
_wptRegroup setWaypointBehaviour "SAFE";
_wptArm setWaypointCompletionRadius 2.5;
_wptArm setWaypointType "MOVE";
_wptArm setWaypointBehaviour "STEALTH";
_wptArm setWaypointStatements ["true", format 
 ["_grpOPFOR = createGroup east; 
   _wptSecure = _grpOPFOR addWaypoint [position this, 2.5];
   _wptSecure setWaypointCombatMode ""RED"";
   _wptSecure setWaypointBehaviour ""COMBAT"";
   _wptSecure setWaypointType ""SAD"";
   _grpOPFOR setCurrentWaypoint _wptSecure;	
   (units group this) joinSilent _grpOPFOR;
   {_dude = _x; {_dude addMagazine %1;} forEach [1,2,3,4];
   _x addWeapon %2;} forEach ((units _grpOPFOR) - [leader _grpOPFOR]);
   {(leader _grpOPFOR) addMagazine %3;} forEach [1,2,3,4];
   (leader _grpOPFOR) addWeapon %4;", _mgznMen, _wpnMen, _mgznLdr, _wpnLdr]];
_wptDummy setWaypointType "SAD";
_wptDummy setWaypointCombatMode "RED";
{[_x] join _grpNew} forEach units (group _grpLdr);
_grpNew setCurrentWaypoint _wptRegroup;

If you want, you can keep the civs in one area giving them a "DISMISS" waypoint to start and using "wrangle.sqf" in their groupleaders' init lines.

wrangle.sqf:

_man = _this select 0;
_distMax = _this select 1;
_distRet = _distMax * 0.85;
_posStart = getPos _man;
_man setVariable ["hasRebelled", false];

while {!(_man getVariable "hasRebelled")} do {
  _compX = abs ((position _man select 0) - (_posStart select 0));
  _compY = abs ((position _man select 1) - (_posStart select 1));
  _distCurr = (sqrt ((_compX * _compX) + (_compY * _compY)));
  if (_distCurr >= _distMax) then {
     _grpNew = createGroup (side _man);
     _wptReturn = _grpNew addWaypoint [_posStart, 0];
     _wptDismiss = _grpNew addWaypoint [waypointPosition _wptReturn, 0];
     _wptReturn setWaypointType "MOVE";
     _wptReturn setWaypointSpeed "LIMITED";
     _wptDismiss setWaypointType "DISMISS";
     _wptDismiss setWaypointSpeed "NORMAL";
     _wptReturn setWaypointCompletionRadius _distRet;
     _wptDismiss setWaypointCompletionRadius _distRet;
     _grpNew setCurrentWaypoint _wptReturn;
     {[_x] join _grpNew} forEach units (group _man);
  };
  sleep (4 + (random 2));
};

Now to call you can make a trigger (with whatever conditions you want to spawn the ambush), and in its on-act put something like:

{nul = _x execVM "rebel.sqf"} forEach [[civReb, wpc_0_1], [civReb_1, wpc_0_1], [civReb_2, wpc_2_3], [civReb_3, wpc_2_3], [civReb_4, wpc_4]];

That would be assuming you have three caches, wpc_0_1, wpc_2_3, and wpc_4, serving the civilian groups referenced by number (civReb . . . civReb_4).

Then in each civReb leader's init box put

nul = [this, 125] execVM "wrangle.sqf";

(Where "125" would get replaced with whatever distance you want them to stay within).

Problems: Every time the civilians get farther than _distMax from their starting dismissed location under the effects of "wrangle.sqf", they ALWAYS return to their initial position before wandering again. Cannot for the life of me find away around this, because when the dismissal is cancelled (by reassigning them to a newly created group), they always return to that group's waypointPosition for the dismiss waypoint.

They're not particularly smart when they become hostile at first, perhaps scripting in some knowsAbout thisList stuff from the trigger would help that.

Finally, my script just gives all the civilian leaders an rpk with 4 mags, and the followers a lee enfield apiece with 4 mags. You can change this however you want, even make a switch statement or add more parameters to the script call. I left the definitions of these weapons/magazines as local variables declared at the top of the script, so you can do with them as you will.

PS Make certain you use the double quotes when they show up. They do that to tell the compiler not to break out of evaluating the string passed to format, and to interpret them as literal "'s. That goes also for the triple quotes at the top, being a string representation of the above :P

PPS As far as I can tell , you MUST set civilians to be friendly to 'everyone', or at the very least to 'opfor' in the editor. If you don't, they will not do what they're supposed to in any predictable fashion.

EDIT: Here's a way to use a list of civilians and a list of weapon caches to randomize which civilians rebel, and to which caches they run to arm themselves. It's very primitive, and there are tons of ways this could be made smarter or integrated into a broader mission setup. Instead of calling the "rebel.sqf" script yourself, just use your trigger to call "ambush.sqf". Then edit ambush.sqf to contain the list of your civilians and your weapon caches in the first two lines.

Ambush.sqf:

_civsAvail = [civ, civ_1, civ_2, civ_3, civ_4, civ_5];
_wpcsAvail = [wpc, wpc_1, wpc_2];
_chanceAmbush = 0.4;
_parmArr = [];
_xWpcFound = false;
_countWpcs = count _wpcsAvail;
_xWpc = nil;

{if (_x getVariable "hasRebelled") then
   {_civsAvail = _civsAvail - [_x];}} forEach _civsAvail;
{if ((random 1) < _chanceAmbush) then {
   while {!_xWpcFound} do {
   	  {if ((random _countWpcs) < 1) then {
      _xWpcFound = true;
      _xWpc = _x;}} forEach _wpcsAvail;};
   _parmArr = _parmArr + [[_x, _xWpc]];
   _xWpcFound = false;};} forEach _civsAvail;
{_x execVM "rebel.sqf"} forEach _parmArr;

You can also set the chance any given group will rebel, by default here it is a 40% chance.

Edited by dwringer
Minor optimizations and bugfixes throughout.

Share this post


Link to post
Share on other sites

dwringer,

Thanks for the update, the scripts looking really good. I dived into a little bit of testing and i'm sadly still noticing the same problems, unfortunately i'm unable to offer any technical nous as to where problems may lie in the script but I thought i'd offer my observations in case they help with any development.

FYI I set up the Player (BLUFOR), another BLUFOR rifleman, one cache, a group of four civillians and a trigger to detect BLUFOR present, all on the runway of Utes. When rebel.sqf is triggered the civilians move to the cache but do not arm or change sides. One thing which did seem odd was that on reaching the cache the group seemed to have problems getting into formation again with one or more members always apparently getting stuck and 'stuttering'. I tried with different objects as cache's, locations and sizes of civillian group and the result was similar each time. Cant see how your script would cause that though but my loose inference was that the waypoint had not 'completed' and thus it wasn't progressing on to the next stage and creating the East group. Apologies in advance if its just me being an idiot and missing something really obvious.

I hope you continue to develop this, it really does bring a lot to the party for mission making.

Cheers

Share this post


Link to post
Share on other sites

Now to see about possibly combining this with ambient civilian module... Though I remember it causing issues last time I checked, hopefully they were either fixed or can be worked around after enough fiddling...

EDIT: Doesn't seem like there's a way to make it work. Ambient civilians does too many stuff that seemed too messed up to understand. For example making the civilians join an opfor group gives errors, and giving them weapons without making them join an east group won't even make them shoot even though independent are friendly to nobody.

Edited by galzohar

Share this post


Link to post
Share on other sites

Hrm. I was almost certain the inconsistencies had been mostly worked out. There is just one thing that I neglected to mention - you MUST create a unit of side east in the editor for this script to work. If you do not, you have to do some extra steps to create the opfor group (stuff with which i'm not very familiar. it's much easier to just drop some random opfor guy somewhere hidden and far away.)

Also, keep in mind the way it is now, the civilians will all meander back to a point where they will regroup prior to running to the armWaypoint. Thus, it may seem to not be working, but eventually you should see the civs do their thing. I have been able to get it to function consistently using all three current versions of the scripts in my post above, although like with any other technique getting things to "make sense" in a mission is never quite so simple without a lot of trial and error to balance things.

So yeah, basically my only advice could be, make sure you have created at least SOME unit of side OPFOR in the editor before trying to use these scripts. Otherwise it will NOT work without properly setting up an OPFOR hq (something I don't really know how to do off the top of my head).:confused:

EDIT: As for the ALICE stuff, yeah, I can never get anything cool to work with that. Even giving them event handlers to tally how many i kill was something I never accomplished even after hours of trying (and fully developing scripts to do it with civs I placed manually). I am pretty sure some people have gotten that part working, not that I have seen a fleshed out working example of it, but I try not to use ambient civilians for that and myriad other reasons of convenience when it comes to having this level of control over their behaviour.

Edited by dwringer

Share this post


Link to post
Share on other sites

dwringer,

Have now chucked on some OPFOR to test and it works like a charm, many thanks.

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  

×