Jump to content
PSYKO_nz

change INDFOR side via trigger

Recommended Posts

hi again,

 

according to this https://community.bistudio.com/wiki/Side_relations#Change_relations it is impossible to change the indfor relationships while a mission is running....

 

i was wondering, has anyone come up with a work arround for this??

 

context:

 

for a mission i'm building BLUFOR have to put out fire places and barrels in the area (for air quality purposes ;) ). i would like the INDFOR units (armed militia) to be friendly to BLUFOR up until BLUFOR  turn off the first fire, then INDFOR need to go hostile and engage BLUEFOR.

 

any ideas?

 

also, this mission will be played on a DS

Share this post


Link to post
Share on other sites

There is no difficulty. Your trigger must be server only.

condition, something like: {inflamed _x} count [barrel1,barrel2,barrel3] < 3

and on act.:

west setFriend [resistance,0];
resistance setFriend [west,0]

 

Multiple times tested.

 

Share this post


Link to post
Share on other sites

Don't use setFriend during mission runtime, since it might affect their FSMs somehow.

Just let all indfor units join new opfor groups like this:

_allIndforGroups = allgroups select {side _x isEqualTo resistance};
_allIndforGroups apply {_grp = creategroup east;units _x joinSilent _grp};

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
23 minutes ago, Grumpy Old Man said:

Don't use setFriend during mission runtime, since it might affect their FSMs somehow.

Just let all indfor units join new opfor groups like this:


_allIndforGroups = allgroups select {side _x isEqualTo resistance};
_allIndforGroups apply {_grp = creategroup east;units _x joinSilent _grp};

Cheers

 

Is it a proven fact or just some affirmation? I played and tested what I wrote on SP/MP missions. So "don't use... " seems to me at least questionable.

Share this post


Link to post
Share on other sites
4 minutes ago, pierremgi said:

 

Is it a proven fact or just some affirmation? I played and tested what I wrote on SP/MP missions. So "don't use... " seems to me at least questionable.

 

Find it out for yourself if you think my post was "questionable".

If you can guarantee that setFriend doesn't affect AI behavior if used during mission runtime then feel free to edit the wiki entry.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
35 minutes ago, Grumpy Old Man said:

 

Find it out for yourself if you think my post was "questionable".

If you can guarantee that setFriend doesn't affect AI behavior if used during mission runtime then feel free to edit the wiki entry.

 

Cheers

Did you guarantee changing side doesn't affect same FSM?

 

What I can affirm is a 100% success on my missions. More than that, I played on Tanoa with balanced relationship along with west putting the pressure on independent, and the number of kills/murders in game. So, this relationship changes several times during game.

Share this post


Link to post
Share on other sites

@Grumpy Old Man

 

What is fsm? I have used setFriend a few times in mission, I did notice a bit of a hickup in some cases but nothing that could be repeated. Normally on mission start with opfor engaging for a second before the init file engages. 

 

Can you please explain why it's no good to use during a mission

Share this post


Link to post
Share on other sites
6 hours ago, pierremgi said:

Did you guarantee changing side doesn't affect same FSM?

 

What I can affirm is a 100% success on my missions. More than that, I played on Tanoa with balanced relationship along with west putting the pressure on independent, and the number of kills/murders in game. So, this relationship changes several times during game.

 

Good to see this command is working in your case, it doesn't mean it's not causing any issues for someone else.

 

On the wiki: "Intended to be used on mission start.".

I don't know the inner workings of the AI FSM or the setFriend command, but if the wiki entry states something like this I'll take it for granted.

 

The wiki page also states that running it during mission runtime can cause issues with the AI FSM.

 

It does not have to cause issues, but when it does and someone's not aware of this possibility then have a good time debugging what went wrong and why.

I'm sure I'm not the only one that has seen AI stopping to attack each other on some random domination/patrol ops server.

Enough reason to avoid using setFriend during mission runtime.

 

Might wanna read these though:

 

 

Even Jezuro suggests to use changing the units side (basically what grouping an opfor unit to a civilian in the editor does):

 

Maybe the command got fixed without any patchnotes whatsoever but until I know any better I'll use it on mission init exclusively.

 

5 hours ago, Chuc said:

@Grumpy Old Man

 

What is fsm? I have used setFriend a few times in mission, I did notice a bit of a hickup in some cases but nothing that could be repeated. Normally on mission start with opfor engaging for a second before the init file engages. 

 

Can you please explain why it's no good to use during a mission

 

FSM means finite state machine, basically what's driving the AI in arma 3.

Nothing too complicated in itself, it can get pretty complex if you want something to do many things under many situations, like when to go into cover, when to fire, what to check first before firing etc.

Reasons mentioned above.

 

Cheers

Share this post


Link to post
Share on other sites

@Grumpy Old Man

Come to think of it the mission I was using it on had a bad glitch I couldn't fix and had to abandon 200hrs work. 

 

ALL the civilians went hostile to the players faction. It didn't matter if I changed sides the civs where only hostile to the players side.

 

Also every vehicle in game turned to civilian, purple on map, and you couldn't enter them. Also loot/containers on ground did the same thing and the player couldnt access or pick them up. 

 

I had 20+ hours of game play set up with

Missions, Intel, friendly encounters, interrogation, murder, hacking. All with different consequences with your actions. 

 

3 friendly factions and civilians negotiating peace. 

 

Assassination on a general

 

Nuke going off in blue hq or wherever the bomber is killed, dead man's switch. So if the player kills the bomber he saves the day but dies in the process. 

 

Nuke releases a zombie apocalypse. 

 

I was just starting on the zombies and some scripts when I went to test it the civilians went bat shit and attacked me.

 

No one could figure out why it happened. 

 

Funniest test was when the guy carrying the nuke crashed his car and died setting off the nuke. 

Share this post


Link to post
Share on other sites

@Grumpy Old ManA very long post without consistent demonstration. I often remarked some AI's "indecisiveness" with heavy scenarios and/or heavy mods + time on mission, without any line calling setFriend. There are so many reasons... On the other hand, this command is rather old (the two first notes are no more true).

And when BIKI affirms:

"NOTE: It is not possible to change the Resistance side relationship while a mission is running"
it's a little short, because it's wrong as is.  You can play hours with many shifts. Just test it!

 

Script working not so bad. Kill 3 friendly resistance >> they become enemy. kill 20 more , they claim for truce, and so on. With all expected behaviors so far.

 

Spoiler

 


 addMissionEventHandler ["entityKilled",{  
  _victim = _this select 0;   
  _killer = _this select 1;  
  _killer spawn {
    private _killer = param [0,objNull];
    sleep 0.2;
    if (rating _killer < 0) then {  
     _killer addRating (- rating _killer)
    };  
  };  
  _oldSide = getNumber (configFile >> "cfgVehicles" >> typeOf _victim >> "side");  
  call {  
      if (_oldSide == 2) exitWith {  
        _victim setVariable ["oldSideName","separatists"];  
        _victim setVariable ["oldSide",resistance]};  
      if (_oldSide == 0) exitWith {  
        _victim setVariable ["oldSideName","reds"];  
        _victim setVariable ["oldSide",east]};  
      if (_oldSide == 1) exitWith {  
        _victim setVariable ["oldSideName","allies"];  
        _victim setVariable ["oldSide",west]};  
      if (_oldSide == 3) exitWith {  
        _victim setVariable ["oldSideName","locals"];  
        _victim setVariable ["oldSide",civilian]};  
      _victim setVariable ["oldSideName","unknowns"];  
      _victim setVariable ["oldSide",sideUnknown]  
    };   
  _concord = (_victim getVariable "oldSide") getFriend side _killer;  
 
  MGI_penalty = if (_victim getVariable "oldSide" == WEST) then [{0.6},{0.2}];   
  publicVariable "MGI_penalty";   
  call {   
    if ((_victim getVariable "oldSide") == civilian) exitWith {};   
    if (_concord >= 0.6 && {side _killer != _victim getVariable "oldSide"}) exitwith {   
      (_victim getVariable "oldSide") setFriend [side _killer,_concord - MGI_penalty];   
      if (_concord <= 0.6) then {format ["The %1 are enemy!",_victim getVariable "oldSideName"] remoteExec ["hint",side _killer]};   
    };   
    if (_concord < 0.6   
        ) exitWith {   
      (_victim getVariable "oldSide") setFriend [side _killer,_concord + (MGI_penalty/20)];   
      if (_concord >= 0.58) then  {format ["The %1 call for truce!", _victim getVariable "oldSideName"] remoteExec ["hint",side _killer]; (_victim getVariable "oldSide") setFriend [side _killer,1];  side _killer setFriend [(_victim getVariable "oldSide"),1]};   
    };   
  };  
}]

 

 

 

 

Share this post


Link to post
Share on other sites

 

Sorry it's taken so long to reply, been a busy week, so...

 

first off let me say thanks to both of you for your help with this, its a million levels above me so i really appreciate your help and your discussions on this

 

On 8/4/2017 at 1:26 PM, pierremgi said:

There is no difficulty. Your trigger must be server only.

condition, something like: {inflamed _x} count [barrel1,barrel2,barrel3] < 3

and on act.:

west setFriend [resistance,0];
resistance setFriend [west,0]

 

Multiple times tested.

 

 

this works great! i like how if any fire is turned off it activates it, ive tested it a few times (sp only, not server yet)

 

however

 

i don't want to cause issues with the fsm i don't exactly understand it but it doesn't sound good and given the wiki thing about it not being possible i'm unsure about it. the mission is massively scripted as it is, using the volcano script and the fire dancing script as well as a few others i don't want to take any chances with this thing glitching i've spent a lot of time on it as it is. 

 

also in the past i have used the group to another unit trick to make civs be opfor etc but that's always been at the start of a mission and i've killed the opfor immediately, not what i want to achieve in this mission, as you know

 

so im going to keep it as a back up and try this one

 

 

On 8/4/2017 at 3:24 PM, Grumpy Old Man said:

Don't use setFriend during mission runtime, since it might affect their FSMs somehow.

Just let all indfor units join new opfor groups like this:


_allIndforGroups = allgroups select {side _x isEqualTo resistance};
_allIndforGroups apply {_grp = creategroup east;units _x joinSilent _grp};

Cheers

 

 

i assume that i can call this the same condition trigger

 

"{inflamed _x} count [barrel1,barrel2,barrel3] < 3"

 

then place the 

_allIndforGroups = allgroups select {side _x isEqualTo resistance};
_allIndforGroups apply {_grp = creategroup east;units _x joinSilent _grp};

into the on act.

 

do i need to place an opfor unit down for them to group to?

 

also and this is important, will the units all start moving to form up on the opfor unit i place?

 

one more question, can or should i use both of these methods?

 

again i am very sorry for the stupid questions but this is a bigey above me and i need to nail it down in my head

 

 

i look forward to reading your replies

Share this post


Link to post
Share on other sites
19 minutes ago, PSYKO_nz said:

i assume that i can call this the same condition trigger

 

"{inflamed _x} count [barrel1,barrel2,barrel3] < 3"

 

then place the 


_allIndforGroups = allgroups select {side _x isEqualTo resistance};
_allIndforGroups apply {_grp = creategroup east;units _x joinSilent _grp};

into the on act.

 

do i need to place an opfor unit down for them to group to?

 

also and this is important, will the units all start moving to form up on the opfor unit i place?

 

one more question, can or should i use both of these methods?

 

again i am very sorry for the stupid questions but this is a bigey above me and i need to nail it down in my head

 

 

i look forward to reading your replies

 

Nothing wrong with asking questions, there are no stupid questions.

Since this forum is about discussing mission editing and scripting there's no better place to be in that regard.

 

I'd personally refrain from using setFriend as it has caused issues in the past and probably still does, but as @pierremgi stated, it can work just fine.

As said earlier, the setFriend command might have been fixed, didn't get around to test this thoroughly.

No harm done in using either of both methods just don't use both at once since they're doing the same basically.

 

The condition will fire as soon as there's less than three fires burning,

there's no need to place any opfor units using this method, since opfor groups will be created and all indfor units on the map will join the opfor groups.

 

With groups the data type "group" is meant, which defines which units belong to it. Not the term "group" in a military sense, heh.

 

You need to be aware that switching to a new group will get rid of all waypoints you set for the indfor units, since waypoints belong to specific groups. Upon joining the units into a new group they will have no more waypoints.

To make the waypoints persist after switching all units over to the new opfor groups simply use this instead:

 

_allIndforGroups = allgroups select {side _x isEqualTo resistance};
_allIndforGroups apply {
_newGrp = creategroup east;
_oldGrp = group _x;
_newGrp copyWaypoints _oldGrp;
units _x joinSilent _newGrp;
};

Nothing fancy, a simple line takes over the waypoints from the indfor to the new opfor group, so you can place waypoints in the editor to your hearts content, the AI will keep them after switching sides.

 

Cheers

 

  • Like 1

Share this post


Link to post
Share on other sites

played the mission on sunday. went so well, everything worked.

 

over the next few days or weeks ill take out our content and make it as basic as i can, rhs, ace etc and upload to steam and post a link here!

 

keep an eye out

  • Like 2

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

×