Jump to content
Sign in to follow this  
dar

Need help with setfriend - or alternative

Recommended Posts

Hello comunity,

Another day, another question.

I tried nearly everything I can do with this command: "SetFriend" - I don't get any further on my own, so I had to ask.

I have a BLUFOR unit, from which I am the leader. I have an OPFOR unit. I have civilians around.

From mission start, all should be friends. This is part of my INIT

sleep1;
WEST setFriend [EAST, 1];
EAST setFriend [WEST, 1];
CIVILIAN setFriend [EAST, 1];
EAST setFriend [CIVILIAN, 1];

That works.

Now at a specific time, I want the OPFOR unit to rampage and kill everything and everyone, including civilians. I run this script via trigger(on activation: _nul = execVM "ENEMY.sqf"):

WEST setFriend [EAST, 0];
EAST setFriend [WEST, 0];
CIVILIAN setFriend [EAST, 0];
EAST setFriend [CIVILIAN, 0];

I don't care if they also shoot civilian objects. I appreciate it more.

But this is what happens: On that trigger, everybody will shout around, take cover, hit the dirt, raise thier guns, spot enemys (they are also tagged as enemys, I can give orders to target etc) and - do NOTHING else. They don't attack. Don't shoot. Just behave like in combat and stare at each other, standing literatly nose to nose or better, flash hider to flash hider. Thats it. In 2/10 test runs one of them "accidentialy" fires a few shots. No more than that. I can dance around in front of them and nothing will happen.

Its like they are hostile again, but the AI intelligence/skill/spotting range was just set to minus 1Mio and thier guns are all jammed.

What is wrong here?

Is there a better way (I hope there is) to accomplish that?

Share this post


Link to post
Share on other sites

HI,

Check the BIKI page: http://community.bistudio.com/wiki/setFriend

On the notes there it says "Intended to be used on mission start. Changing value during mission can cause unexpected errors in AI behavior."

I can't think of any other way at this moment. You could try addRating, but then the OPFOR would fire on each other so that wouldn't be what you're looking for from the sounds of it. Maybe someone else can think of a way.

Share this post


Link to post
Share on other sites

I hope so.

can cause "unexpected AI behavior". Sounds like BI doesn't really know what they did there themselves.

This would be a lot of writing, but would it work to joinSilent all OPFOR units (about 15) to a blufor unit / group at mission start and then on trigger let them joinsilent an OPFOR unit, while all civilians in the area (about 30) will joinsilent to a blufor placeholder?

Edited by Dar

Share this post


Link to post
Share on other sites

Use "setcaptive true" on both blufor and opfor soldiers,

go to advanced intel, set independent friendly to nobody.

then place an independent soldier on the map and give him a high rank, group every civilian to him so he's the group leader.

set the independent soldiers presence to 0.

then set every civilian to "setcaptive true".

on trigger activation use "setcaptive false" for every unit.

should do the trick.

Share this post


Link to post
Share on other sites

I've just thought; at the moment, are you using Indy units in your mission as well?

If not, you could do this:

At mission start set sides something like this:

WEST setFriend [EAST, 1];

EAST setFriend [WEST, 1];

CIVILIAN setFriend [EAST, 1];

EAST setFriend [CIVILIAN, 1];

Resistance setFriend [East, 0];

East setFriend [Resistance, 0];

Resistance setFriend [West, 0];

West setFriend [Resistance, 0];

Resistance setFriend [Civilian, 0];

Civilian setFriend [Resistance, 0];

And put a indy unit down in the editor with 0% prob of prescence.

Then at the moment when you need the opfor to start firing, creater a new indy group for each opfor group and make all the units of the group join it.

It might be a pita, but it's the only wayt I can think of right now :)

EDIT: ninja'd by GOM - forgot about setCaptive as well! :)

Share this post


Link to post
Share on other sites
Use "setcaptive true" on both blufor and opfor soldiers,

go to advanced intel, set independent friendly to nobody.

then place an independent soldier on the map and give him a high rank, group every civilian to him so he's the group leader.

set the independent soldiers presence to 0.

then set every civilian to "setcaptive true".

on trigger activation use "setcaptive false" for every unit.

should do the trick.

This is unfortunatly not an option. The civs should walk around and not be part of a group, which would force them to stay in a formation.

Also there are a bunch of triggers, that are set on Side and can't be activated by captive units.

@Das Attorney: I will give it a try

Share this post


Link to post
Share on other sites

You could try this as the code to make them switch sides:

{
_group = _x;
if (side _group == east) then
{
	_newGroup = createGroup independent;
	(units _group) joinSilent _newGroup;
	deleteGroup _group;
};
} forEach allGroups;

Untested but should work.

EDIT: Updated the code - forgot to define _group.

Edited by Das Attorney

Share this post


Link to post
Share on other sites

Thanks, this works for OPFOR vs BLUFOR. Unfortunatly not for OPFOR vs CIV

OPFOR (now independent) will spot the civs as enemy, raise thier guns but they won't fire. Just target them and stare at them.

EDIT: solved the problem by repeating the same for Civilian groups and "converting" them to blufor groups. Running tests know.

Edited by Dar

Share this post


Link to post
Share on other sites

Just do some cut and paste for civs as well maybe, like:

{
   _group = _x;
   if (side _group == east) then
   {
       _newGroup = createGroup independent;
       (units _group) joinSilent _newGroup;
       deleteGroup _group;
   };
   if (side _group == civilian) then
   {
       _newGroup = createGroup west;
       (units _group) joinSilent _newGroup;
       deleteGroup _group;
   };
} forEach allGroups;

:)

EDIT: Use this one in case you need to iterate through a lot of groups. It'll be a bit more efficient:

{ 
   _group = _x; 
call
{
	if (side _group == east) exitWith
	{ 
		_newGroup = createGroup independent; 
		(units _group) joinSilent _newGroup; 
		deleteGroup _group; 
	}; 
	if (side _group == civilian) exitWith 
	{ 
		_newGroup = createGroup west; 
		(units _group) joinSilent _newGroup; 
		deleteGroup _group; 
	};
};
} forEach allGroups;

Edited by Das Attorney

Share this post


Link to post
Share on other sites

 Nice one DA tho I can't get AI to fire back. My friendly AI will recognize the civilian turned enemy as dangerous and kill him but can't get him to use his newly spawned pistol

 

 

join.sqf:

 {

    _group = _x;

   

    if (side _group == civilian) then

    {

        _newGroup = createGroup west;

        (units _group) joinSilent _newGroup;

        deleteGroup _group;

    };

} forEach allGroups;

 Trigger:

            Condition: cursortarget == bad1 && player distance bad1 <10 and !weaponLowered player

 

            onAct:     hint "leave me alone";nul = execvm "join.sqf"; bad1 doTarget player; bad1 doFire player 

 

  Just thr in the doTargets/doFire's for extra measure but so far nothing -he just rotates staring at me lol. There used to be a switchSides module which did the trick no problem but they removed it at some point.

Share this post


Link to post
Share on other sites

you could always take an Ind unit and redress as civ. more work. but hey its arma right?

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  

×