Jump to content

Recommended Posts

So i want to make an AI enemy soldier swap uniform when changing to combat mode.

 

I can do it with a trigger no problem

 

Condition = behaviour man == "COMBAT"

On Activation = man unassignItem "U_O_Protagonist_VR"; 

And another for assigning the new item.

 

This works great, however, i want the same for like 100 enemy soldiers and i dont feel like typing it out for 100 different dudes.

 

Is there a way of arranging this code into the units init? 

Then i can just copy paste the enemy soldier and they will all have it in their init.

 

So if man = combat then unassignItem such and such, and assignItem such and such

 

Any ideas? I cant think of a way of applying this to millions of soldiers without manually typing out 100+ unit names in the trigger 🙂

 

Share this post


Link to post
Share on other sites

Don't do that in init field of the units! Why running 100+ codes instead of one!

Let's say your guys are all dressed with "U_O_Protagonist_VR" , which seems to me a good criteria (but I don't know exactly how do you choose them).

 

In your trigger, no preset condition (none none) and server only, repeatable:

condition:

(allUnits findIf {behaviour _x isEqualTo "COMBAT" && uniform _x isEqualTo "U_O_Protagonist_VR"} > -1) && isNil "VRpassed"
on act:

VRpassed = true; {_x unAssignItem "U_O_Protagonist_VR"; _x forceAddUniform "U_O_CombatUniform_ocamo"} forEach (allUnits select {behaviour _x isEqualTo "COMBAT" && uniform _x isEqualTo "U_O_Protagonist_VR"})
on deact:

VRpassed = nil

 

 

Share this post


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

Don't do that in init field of the units! Why running 100+ codes instead of one!

Let's say your guys are all dressed with "U_O_Protagonist_VR" , which seems to me a good criteria (but I don't know exactly how do you choose them).

 

In your trigger, no preset condition (none none) and server only, repeatable:

condition:

(allUnits findIf {behaviour _x isEqualTo "COMBAT" && uniform _x isEqualTo "U_O_Protagonist_VR"} > -1) && isNil "VRpassed"
on act:

VRpassed = true; {_x unAssignItem "U_O_Protagonist_VR"; _x forceAddUniform "U_O_CombatUniform_ocamo"} forEach (allUnits select {behaviour _x isEqualTo "COMBAT" && uniform _x isEqualTo "U_O_Protagonist_VR"})
on deact:

VRpassed = nil

 

 

 

Thanks MGI, I only need for a certain batch of units, and they are all in separate teams.

 

Which is why i was hoping for something in the init of each unit, that way i could control which units swap out uniform on combat..

 

Not sure how else i can specify which units are affected, without giving them all unique names, which seems like a headache.

 

 

 

Share this post


Link to post
Share on other sites
2 hours ago, chrisbaker1981 said:

I only need for a certain batch of units, and they are all in separate teams.

 

Separate teams or not doesn't matter in this case.

Batch of units is at your hand. The fact they start with OPFOR VR suit is the way I filter them. If not truly accurate, you can also name the first one unitVR or else. then when you copy /paste this unit, multiple times, the editor automatically add _1 _2 ... on name, so: unitVR_1 unitVR_2 ... The filter for them can be:

allUnits select {"unitVR" in str _x}

 

2 hours ago, chrisbaker1981 said:

Which is why i was hoping for something in the init of each unit, that way i could control which units swap out uniform on combat..

 

Don't write a full script in these init field, for 100+ units. I showed you 2 simple ways for selecting what units are to be treated with your code:

- VR suit at start;

- unitVR_xxx  named units;

- you can also set a variable on them:  in init field: this setVariable ["mySpecialUnitVR",true];  (or any other name for the variable). Now you filter is:

  allUnits select {!isNil {_x getVariable "mySpecialUnitVR"} }

 

But, just test the code I wrote above, which is the first solution, without anything in init fields. If you have extra conditions, just say them.

 

Share this post


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

 

Separate teams or not doesn't matter in this case.

Batch of units is at your hand. The fact they start with OPFOR VR suit is the way I filter them. If not truly accurate, you can also name the first one unitVR or else. then when you copy /paste this unit, multiple times, the editor automatically add _1 _2 ... on name, so: unitVR_1 unitVR_2 ... The filter for them can be:

allUnits select {"unitVR" in str _x}

 

 

Don't write a full script in these init field, for 100+ units. I showed you 2 simple ways for selecting what units are to be treated with your code:

- VR suit at start;

- unitVR_xxx  named units;

- you can also set a variable on them:  in init field: this setVariable ["mySpecialUnitVR",true];  (or any other name for the variable). Now you filter is:

  allUnits select {!isNil {_x getVariable "mySpecialUnitVR"} }

 

But, just test the code I wrote above, which is the first solution, without anything in init fields. If you have extra conditions, just say them.

 

 

 

Oh silly me i didnt read your code correctly, now i see, it looks for combat mode and the specific uniform, very clever thanks..

 

The activation part gives me an error, says invalid number in expression i fiddled around but cant get that part to work 🙂

 

Share this post


Link to post
Share on other sites

OK i dont know what i did, but it works now...

 

Just copied and pasted your code again, perhaps something went wrong with the last copy and paste..

 

 

It works great! thanks so much again MGI, its great that you and many others carry on sharing your knowledg... Learning a lot..

 

So part of my mission is you have to get through the jungle at night with CSAT bionic soldiers roaming around dressed in red VR suits etc. When they switch to combat upon spotting you they switch out to the black tracksuit. Looks great. The effect from the players perspective is their VR suit lights go off when they go to combat..

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Nice idea. You can revert into VR suit for AWARE (or Non-COMBAT) behaviour.

In this case, 3rd example (with setVariable) is probably more accurate...

Share this post


Link to post
Share on other sites

As example (if you don't spawn this kind of units, so just placed in editor and starting in VR suit)

 

trigger not repeatable but condition: TRUE


 

0 = [] spawn {
  private _specUnits = (allUnits select {uniform _x isEqualTo "U_O_Protagonist_VR"});
  {
    _x spawn {
      while {TRUE} do {
        waitUntil {sleep 1; behaviour _this isEqualTo "COMBAT" && uniform _this isEqualTo "U_O_Protagonist_VR"};
        _this unassignItem "U_O_Protagonist_VR"; _this forceAddUniform "U_O_R_Gorka_01_black_F" ;
        waitUntil {sleep 1; !(behaviour _this isEqualTo "COMBAT") && uniform _this isEqualTo "U_O_R_Gorka_01_black_F"};
        _this unassignItem "U_O_R_Gorka_01_black_F"; _this forceAddUniform "U_O_Protagonist_VR"
      };
    };
  } forEach _specUnits;
};

Of course there is also a solution in case you spawn them.

Share this post


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

As example (if you don't spawn this kind of units, so just placed in editor and starting in VR suit)

 

trigger not repeatable but condition: TRUE


 


0 = [] spawn {
  private _specUnits = (allUnits select {uniform _x isEqualTo "U_O_Protagonist_VR"});
  {
    _x spawn {
      while {TRUE} do {
        waitUntil {sleep 1; behaviour _this isEqualTo "COMBAT" && uniform _this isEqualTo "U_O_Protagonist_VR"};
        _this unassignItem "U_O_Protagonist_VR"; _this forceAddUniform "U_O_R_Gorka_01_black_F" ;
        waitUntil {sleep 1; !(behaviour _this isEqualTo "COMBAT") && uniform _this isEqualTo "U_O_R_Gorka_01_black_F"};
        _this unassignItem "U_O_R_Gorka_01_black_F"; _this forceAddUniform "U_O_Protagonist_VR"
      };
    };
  } forEach _specUnits;
};

Of course there is also a solution in case you spawn them.

 

 

Thats a good idea thanks, ill try that, although i wont have a need in this scenario but this can be really usefull adapted to any item being switched by combat mode changing... Can do a lot with that.

 

ON a side note, i should start a new thread but anyhow,

 

do you know how to deactivate thermals and night vision for the special ops viper helmet on a player.

H_HelmetO_ViperSP_ghex_F is its name. Ive looked through the wiki but can only find deactivate thermals and night vision for vehicles.

 

I have found a way of turning night vision off with a trigger but then the player can just turn it back on again. 

 

I want to force the player who at this point will be wearing the special purpose viper hemlet, to not use night vision or thermals... Basically deactivate the features but still be able to wear the helmet for the armour and look...

 

 

 

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

×