Jump to content

Recommended Posts

Hi there,

 

I have a problem with my loop of a trigger.

 

arma3counterproblem.jpg

 

as shown in this image. I use a game logic as a loop restarter for this trigger named "widerstand_counter_area_re_altivierer" which is set to "true".

When I run now into that area or already respawned in it. it fires just one time and is than only again triggered when i leave and reenter the area of this trigger.

 

Well if I delite the "AND (resistance countSide thislist) > (west countSide thislist) or (resistance countSide thislist) > (east countSide thislist)" my trigger is looped every second while I am in it also re entering activates the loop well. But now it does not controll anymore which side have now the controll of that area of the trigger. 

 

What I would like to have is

 

1. only living player in the area can hold/activate area/trigger.

2. let the trigger area only be controlled by the restistance when there are more (for example) restinance in it than from any other side (west; east).

3. let the counter and hint loop as long as the trigger is activated. ( widerstand_counter = widerstand_counter + 1 ;  hint format ["Widerstand Punkte %1 von 100", widerstand_counter]; )

4. When there are form the given side enough players in the area the area_marker should change its own color to for example green/guer and change to the other color of the other side when there are more of em or change to gray if there are non in the area.

 

I hope you have all necessary informations to maybe help me out, and sorry for my probbaly bad english.

 

Greetings Silentsands.

Share this post


Link to post
Share on other sites

first of all , regroup these condition in the same ():

( (resistance countSide thislist) > (west countSide thislist) or (resistance countSide thislist) > (east countSide thislist) )

remove and alive player (dead player is civilian anyway)

 

 

Share this post


Link to post
Share on other sites

hi,

 

at first a big thanks for that tip. @pierremgi

 

Now I had made for testing just a little map with only one trigger wehere i was WEST and had two RESISTANCE in the Trigger area.
Well I come to an interessting point. If I Only use " ( (west countSide thislist) > (resistance countSide thislist) )" and when the trigger gets aktivated it just gives back a - hint "VICTORY"; - and if i leave or die, the trigger gets Deaktivated and gives back - hint "Loose"; -

 

Well, aktually it happened nothing. Nothing when i killed all resistance or when i died. It looks like the side "RESISTANCE" is not the correkt name for the independent. I also used independent or even guar instead of resistance in the script and still nothing happened. but if i replace the - resistance - part in my code with - east - . It works!

 

So how can I make even the independent in my scenario beeing registered when I want to test out who side counts more in a area?

 

Greetings Silentsands

 

 

Share this post


Link to post
Share on other sites

1. The reason it (de)activate constantly when you remove those lines, is becase you it also needs the ..._re_akitivierer variable to be true. But immediately when the trigger activate, you set it to false, thus the trigger deactivates.

2. I think you want an 'and' between your two countSide checks.

 

I looked a bit at this, and have the side changing working but not the counter. Personally, I believe putting all that code in a trigger becomes too complicated. Especially since a trigger can only detect whether something is true or not, but you have 3 sides. Instead you could do something like this:

 

Condition:
0 = [thisTrigger, "area_marker"] call compile preProcessFile "TriggerArea.sqf"; false

 

Clear the On Act, and On Deact fields. They will set them by script. Then you make a file called TriggerArea.sqf in your mission folder root, where you put the following.

params ["_trigger", "_marker"];

// We create some helper functions, but only once
if (isNil "TriggerFunctions_Init") then {
    TriggerFunctions_Init = true;

    // This code will return true if the trigger changed side
    TriggerSideChanged = {
        params ["_trigger"];
        private _list = list _trigger;
        // Assume last side still owns it
        private _lastSide = _trigger getVariable ["MostSide", sideUnknown];
        private _mostSide = _lastSide;
        private _mostCount = 0;
        {
            private _sideCount = _x countSide _list;
            // We have a tie.
            if (_sideCount == _mostCount) then {
                _mostSide = sideUnknown;
            };
            // Or a new winner?
            if (_sideCount > _mostCount) then {
                _mostCount = _sideCount;
                _mostSide = _x;
            };
        } forEach [west, east, resistance];
        _trigger setVariable ["MostSide", _mostSide];
        // Return whether side changed
        _mostSide != _lastSide
    };

    TriggerSideHasChanged = {
        params ["_trigger"];
        private _newSide = _trigger getVariable ["MostSide", sideUnknown];
        // Find new color for marker
        private _colors = ["ColorGrey", "ColorGuer", "ColorBlue", "ColorRed"];
        private _sides = [resistance, west, east];
        private _newColor = _colors select ((_sides find _newSide)+1);
        private _marker = _trigger getVariable ["Marker", ""];
        _marker setMarkerColor _newColor;
    };
};

_trigger setVariable ["Marker", _marker];
_trigger setTriggerStatements [
    "[thisTrigger] call TriggerSideChanged",
    "[thisTrigger] call TriggerSideHasChanged;",
    ""
];

 

Share this post


Link to post
Share on other sites

thislist returns players . So, how do you test your trigger? On MP hosted or dedicated? How many players?

Share this post


Link to post
Share on other sites
3 hours ago, silentsands said:

Well I come to an interessting point. If I Only use " ( (west countSide thislist) > (resistance countSide thislist) )" and when the trigger gets aktivated it just gives back a - hint "VICTORY"; - and if i leave or die, the trigger gets Deaktivated and gives back - hint "Loose"; -

 

Well, aktually it happened nothing.

Did you play alone, with some AI's? Because, then of course nothing happened. You trigger uses "ANY PLAYER", there is only you. So the values are (west countSide thisList) = 0 and  (resistance countSide thisList) = 1. So the trigger never activates. And because the trigger never activates, it never deactivates either. And you killing any of them would change nothing, since the trigger is  Jeder Spieler and no AI is a player

Share this post


Link to post
Share on other sites

Hi,

 

thank you all very much. I will look later soon on your script and try to implement it. So at last I do have to start to use extra seperated files and work outside and inside of the arma 3 editor IDE. Stuff I don´t like butt well, seems like i do have to do that to get it all work as I would like to have. edit trigger ==> tab out arma 3 and start seperated text-editor. write some script... ==> TAB back to arma 3 and insert script. loong live the need of multiple programms to get one thing going. :(

 

i also wanted to avoid it becouse i read allot of it to avoid it as much as possible to write seperated scripts outside of the arma 3 editor. So the server get´s some more performance. Also it means now for me to learn another script language. Well.

 

to answer your questions about how I test my scenario. I Host localy a Multiplayer server and test it on it with AIs. Seems like I need to find also someone to test with me my scenario.

 

So yes, I might report soon if your script worked well for me and also if i need some more help from you great people. thanks to you all.

 

Greetings Silentsands.

EDIT:

 

Hi again.

 

@Muzzleflash

 

i have added and integrated your script successfully and now i have some questions about it.

 

I do see that in the conditions there stands

0 = [thisTrigger, "area_marker"] call compile preProcessFile "TriggerArea.sqf"; false

but  why is there a 0 = ? And last, why false?

 

In the scriptfile there is also something what i don´t get it right now.

 

// Find new color for marker
        private _colors = ["ColorGrey", "ColorGuer", "ColorWest", "ColorEast"];
        private _sides = [resistance, west, east];
        private _newColor = _colors select ((_sides find _newSide)+1);
        private _marker = _trigger getVariable ["Marker", ""];
        _marker setMarkerColor _newColor;

why is there at

 

        private _newColor = _colors select ((_sides find _newSide)+1);

 

a "+1" on the end?

 

Greetings Silentsands

Edited by silentsands
Script Questions

Share this post


Link to post
Share on other sites

In a trigger, running an sqf (called compiled) or a direct  code is same. You call compile each time so no added value except for readability.

Imho, let the conditions readable in your trigger.  ExecVM sqf on act /deact if you want, but not in condition field.

On the other hand,  you can script the trigger (createTrigger). It's fine!

 

thisList is not easy to catch with any player + rearm trigger like you did.

You can let "none" "none" condition (no predefined "any player" or "blufor" "present"..) and make you own condition like:

 

{_x inArea thisTrigger && side _x == west} count allPlayers >  ({_x inArea thisTrigger && side _x == east} count allPlayers)

is a far better condition.

 

 

 

Share this post


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

ExecVM sqf on act /deact if you want, but not in condition field.

Just to be clear, I rewrite the condition field when the script runs, so that line is only ever only executed once (by that trigger). I did it did way because I suspected OP has most if not all content in the mission itself, so this was less intrusive. But normally I would have compiled the function from elsewhere.

 

18 hours ago, silentsands said:

but  why is there a 0 = ? And last, why false?

I can't remember if Arma allows me to omit it, so I just added it. It essentially does nothing. I change the condition/on act/on deact when the script runs. False is there because I am not sure what would happen on the very first check otherwise. So false tells it that the condition (that the trigger changed side) has not happened yet.

19 hours ago, silentsands said:

a "+1" on the end?

 

So about the +1. It's a bit of a trick. You have 3 sides  [resistance, west, east] with index from 0 to 2,  e.g.  _sides select 1 is equal to west. But you also have four colors; green if resistance, blue if west, red if east, and finally grey if noone. I use find to find the index of the side that currently controls the area, so, 0 if resistance, 2 if east. But if find fails to find the side, it returns -1. So I add one to shift unknown to grey, 0 in the color array,  and resistance to 1 its position in the color array. I could have done it this way instead:

 

private _colors = ["ColorGrey", "ColorGuer", "ColorWest", "ColorEast"];

private _sides = [sideUnknown, resistance, west, east];

private _newColor = _colors select (_sides find _newSide);

 

Share this post


Link to post
Share on other sites
19 hours ago, silentsands said:

thank you all very much. I will look later soon on your script and try to implement it. So at last I do have to start to use extra seperated files and work outside and inside of the arma 3 editor IDE. Stuff I don´t like butt well, seems like i do have to do that to get it all work as I would like to have. edit trigger ==> tab out arma 3 and start seperated text-editor. write some script... ==> TAB back to arma 3 and insert script. loong live the need of multiple programms to get one thing going. :(

 

i also wanted to avoid it becouse i read allot of it to avoid it as much as possible to write seperated scripts outside of the arma 3 editor. So the server get´s some more performance. Also it means now for me to learn another script language.

 

You don't have to; you can do it all from inside the editor. In fact, to do that a copy-paste of the script I wrote, for example, where you replace "compile preProcessFile "TriggerArea.sqf"; false" with the contents of the script file is almost all you need to do. But then you got 50 lines of code in a 3 "line tall" window that actually only has one long line -- and it is beyond my abilities to deal with that kind of complexity. And speaking of efficiency, I actually think it will run slower! Btw, the scripting language you do in the editor is exactly the same as the one in that file. True you use a tiny bit few more commands, like 'call'. So you don't have to, the game will run fine with everything stuffed into the condition/on act/on deact.

Share this post


Link to post
Share on other sites

Hi,

 

@Muzzleflash and @pierremgi , thank you two very much for your help and answering all my questions I had realy good.

 

Didn´t expacted that it would be this way good and information like according how mad some people are most time getting while in game... XD^^

 

So again Thanks you all and well this Topic is done.

 

Greetings

 

Silentsands

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

×