Jump to content

Heeeere's johnny!

Member
  • Content Count

    899
  • Joined

  • Last visited

  • Medals

Posts posted by Heeeere's johnny!


  1. As an alternative approach - correct me if I'm wrong, but afaik - if you don't set a trigger area, the trigger should work for every unit on the map:

    _trigger = createTrigger ["EmptyDetector", [0, 0, 0]];
    _trigger setTriggerStatements [
        "player != vehicle player",
        "player allowDamage false",
        "player allowDamage true"
    ];

    Nevertheless, I agree with terox on bull_a's solution.


  2. Wouldn't it be great to create a complete functioning dialog based only on HTML documents?

     

    Indeed, I'd really love that.

     

    The thing is, when it comes to CSS, there's certain things that would have to be ommitted, because they can't be handled by the "dialog engine" (if that's even the right way to say it), like for instance "tranksform" or tilting objects.

     

    Or there's gotta be a BI-custom css-free and "style"-tag-free way to style HTML dialogs for ArmA.


  3. Not that I would want to advertise my content, but I reckoned this to be the easiest and fastest way:

    _safezoneTrigger = createTrigger ["EmptyDetector", _yourSafezonePosition];
    _safezoneTrigger setTriggerActivation ["ANY", "PRESENT", true];
    _safezoneTrigger setTriggerArea [10, 10, 0, false];
    _safezoneTrigger = [
        _safezoneTrigger,
        {_x allowDamage false;},
        {_x allowDamage true;},
        true
    ] call fnc_triggerListChanged;

    Using this little script:

    [sCRIPT] Trigger List Changed v2.1 - Handle units which entered/left a trigger's list

     

    That way, every unit entering the trigger area (Safezone) is invulnerable. Every unit leaving the trigger area is vulnerable again.

     

    EDIT:

    I'm not sure right now whether this also affects the vehicle's crew, but I believe it doesn't. You might need to add some respective code to the trigger list lines above:

    if (_x isKindOf "Car") then {{_x allowDamage false;} forEach (crew _x);}
    if (_x isKindOf "Car") then {{_x allowDamage true;} forEach (crew _x);}

     And i have another question, if i put in a trigger "player allowdamage true;" does every Player turns the damage on or only the one who entered the trigger?

    Only the unit activating the trigger gets its allowDamage set.


  4. I will try out the: HandleDamage and Hit.

     

    so then i will change the Dammaged with HandleDamage or Hit ?

     

    You can use the code like that, yes. But you need to be aware of two things:

     

    1) The event handler should be executed server side (in a multiplayer mission), because it will only work on the machine where the event handler was added.

    2) "HandleDamage" will be executed for every damaged part of the unit. That means, if a granade causes the damage, your prisonner_ai.sqf will be executed many times.

    3) "HandleDamage" will continue to trigger even if the unit is already dead.

     

    You can read the details here: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HandleDamage


  5. I'm not 100% sure, but I assume that the resulting damage is regarding the "selection" (body part) where the unit is hit. So, instead of checking the damage value returned by the handler, check the damage of the unit. The problem with that is that the unit's damage value is updated after the EH is done (I'm also not 100% sure on that). So a workaround would be to spawn a script inside the EH which does the job:

    {
        _x addEventHandler
        [
            "Dammaged",
            {
                _this spawn
                {
                    sleep 0.5;
                    _unit = _this select 0;
                    if (damage _unit >= 0.9) then
                    {
                        _unit execVM "hostage\prisonner_ai.sqf"
                    };
                };
            }
        ];
    } foreach thislist

    Also, instead of using the (old) "Dammaged" EH, try the (newer) "HandleDamage" or "Hit" EHs.


  6. //(snip)
    for "n" from 1 to count _this do {
    //(snip)
    
    Still nothing.

     

     Well, have a look at the above line and search the "}" which is closing that for-loop. You will not find it, because it's missing.

     

    Now, let me show you how I would have indented your code. Since I can't understand it either, you decide whether that's correct.

    _this = [p0,[["B_Heli_Transport_01_F"],["B_Slingload_Cargo_01_F"],["B_quadbike_01_F","B_quadbike_01_F"],"",false]];
    
    switch (playerside) do {
        case blufor: {
            _slo = "B_Slingload_01_Cargo_F";
        };
        case opfor; {
            _slo = "O_Slingload_01_Cargo_F";
        };
    };
    
    _lv = 1;
    _slp = _this select 0;
    slghd = creategroup west;
    
    for "n" from 1 to count _this do {
        _la = _this select _lv;
        _lv1 = 0;
        _lst4 = true;
        _lst = true;
        _lst1 = true;
        _loc = 0;
        
        while (_lst) do {
            if ((ahd find _lv1) != -1) then {
                _lv1 = _lv1 + 1;
            } else {
                ahd append _lv1;
                _lst = false;
                hint str(_lv1);
            };
        };
        
        call compile format ["sthdd%1 = false;", _lv1];
        _lo = createVehicle [(_la select 0) select 0, _slp, [], 0, "FLY"];
        createvehiclecrew _lo;
        
        If ((count _la select 0) > 1) then {
            _lo1 = createVehicle [(_la select 0) select 1, _slp, [], 0, "FLY"];
            while (_lst4) do {
                _lo1 setpos getpos _lo;
                sleep 0.5;
            };
        };
        
        if (!isnull (_la select 1)) then {
            _loc = createVehicle [_la select 1, _slp, [], 0, "FLY"];
            _lo setSlingLoad _loc;
            
            while (_lst1) do {
                if (alive crew _lo) then {
                    if (call compile format ["sthdd%1", _lv1]) then {
                        _lo setslingload objnull;
                    };
                    
                    if (isnull getSlingLoad _lo) then {
                        _lst4 = false;
                        _lst1 = false;
                        
                        if (!isnull (_la select 2)) then {
                            _lp = getpos _loc;
                            _lp1 = getposatl _loc;
                            
                            {
                                createvehicle [_x, _lp, [], 0, "NONE"];
                                
                                if ((_lp1 select 3) > 4) then {
                                    _x call KK_fnc_paraDrop;
                                };
                                sleep 0.5;
                            } foreach (_la select 2);
                        };
                    };
                } else {
                    _lst1 = false;
                };
            };
        } else {
            if (!isnull (_la select 2)) then {
                if (!(_lo canslingload _la select 2)) then {
                    _loc = createVehicle [_slo, _slp, [], 0, "FLY"];
                    
                    while (_lst1) do {
                        if (alive crew _lo) then {
                            if (call compile format ["sthdd%1", _lv1]) then {
                                _lo setslingload objnull;
                            };
                            
                            if (isnull getSlingLoad _lo) then {
                                _lst4 = false;
                                _lst1 = false;
                                _lp = getpos _loc;
                                _lp1 = getposatl _loc;
                                deletevehicle _loc;
                                
                                {
                                    createvehicle [_x, _lp, [], 0, "NONE"];
                                    if ((_lp1 select 3) > 100) then {
                                        _x call KK_fnc_paraDrop;
                                    };
                                    sleep 0.5;
                                } foreach (_la select 2);
                            };
                        } else {
                            _lst1 = false;
                        };
                    };
                } else {
                    _loc = createVehicle [(_la select 2) select 0, _slp, [], 0, "FLY"];
                    while (_lst1) do {
                        if (alive crew _lo) then {
                            if (call compile format ["sthdd%1", _lv1]) then {
                                _lo setslingload objnull;
                                _lst1 = true;
                            };
                            
                            if (isnull getSlingLoad _lo) then {
                                _lst4 = false;
                                _lp = getpos _loc;
                                _lp1 = getposatl _loc;
                                
                                if ((_lp1 select 3) > 100) then {
                                    _loc call KK_fnc_paraDrop;
                                };
                                
                                if (count (_la select 2) > 1) then {
                                    {
                                        createvehicle [_x, _lp, [], 0, "NONE"];
                                        if ((_lp1 select 3) > 100) then {
                                            _x call KK_fnc_paraDrop;
                                            sleep 0.5;
                                        } foreach (_la select 2 set [0,objnull]);
                                    };
                                };
                            } else {
                                _lst1 = false;
                            };
                        };
                    };
                    _lo setSlingLoad _loc;
                };
            };
            
            if (!isnull (_la select 3)) then {
                call compile format ["sthdihd%1 = false;", _lv1];
                call compile format ["sthdicd%1 = false;", _lv1];
                _lg = [_slp, side player, _la select 3] call BIS_fnc_spawnGroup;
                
                if (_la select 4) then {
                    {
                        if ((_loc emptyPositions "cargo") > 0) then {
                            _x moveInCargo _loc;
                        } else {
                            _x moveInCargo _lo;
                        };
                    } foreach units _lg;
                } else {
                    {
                        _x moveInCargo _lo;
                    } foreach units _lg;
                };
                
                _lg join group player;
                _lst2 = true;
                _lst3 = false;
                
                while (lst2 or _lst3) do {
                    if (call compile format ["sthdihd%1", _lv1]) then {
                        {
                            if ((vehicle _x) == _lo) then {
                                [_lo,_x,130] execVM "eject.sqf";
                            };
                        } foreach units _lg;
                    };
                    
                    if (_la select 4) then {
                        _lst3 = true;
                        if (call compile format ["sthdicd%1", _lv1]) then {
                            {
                                if ((vehicle _x) == _loc) then {
                                    [_loc,_x,130] execVM "eject.sqf";
                                };
                            } foreach units _lg;
                        };
                    };
                };
            };
            
            crew _lo join slghd;
            [playerside,hq] commandchat "Transport identification: " + str (_lv1);
            
            if (_lv == count _this) then {
                slghd join group player;
            };
            _lv = _lv + 1;
        };
    //} is missing here
    

     

    Note that there is a ";" (semicolon) on line 7 when it has to be a ":" (colon):

    case opfor; {

    Also, have a look at line 126 to 134:

    if (count (_la select 2) > 1) then {
        { //<-- what is this?
            createvehicle [_x, _lp, [], 0, "NONE"];
            if ((_lp1 select 3) > 100) then {
                _x call KK_fnc_paraDrop;
                sleep 0.5;
            } foreach (_la select 2 set [0,objnull]);
        }; //<-- and this?
    };
    

    Is that going to work? I doubt it.

     

    Please, for the sake of saving life time and nerves, start your ArmA 3 with the startup parameter -showScriptErrors (with the leading "-"), because it's going to show you things like that!

     

    And finally, let me tell you on behalf of I guess all of us who posted here:

    You cannot expect the community to help you if you provide obfuscated code like this. It doesn't matter if you provide a list of what these obfuscated variables mean. If we cannot read the code as-is, we won't help simply because WE CAN'T.


  7. BIS_fnc_listPlayers is obsolete since command allPlayers. BIS_fnc_param and BIS_fnc_MP are already mentioned.
     
    Since you can use find toLower _someString to search if something exists in a string, I consider BIS_fnc_inString obsolete, too.

     

    But speaking of strings, I'd even like to have a command like findLast which finds the last occurance of a "needle" in a "hay stack".
     
    For those who follow proper naming conventions, this can simplify a lot of stuff with simple one line string sub selection. I had to write a custom function for that. Not a big deal, but it's pretty essential to all my larger projects and sometimes very intensively used, so speaking performance here, a scripting command could improve that to some extent.
     

    * What functions would benefit from dedicated scripting command?

    - BIS_fnc_relPos

    - BIS_fnc_dirTo

    - all stacked event handler functions

     

    At least I am using latter fairly heavily, often even adding one on key down and removing it on key up again.
    Since we all know that "EH" is an abbreviation for "event handler", wouldn't it be sufficient to shorten a potential future scripting command to "addStackedEH"?


  8. Nitpicking? :)

     

    I'm kindOf a freak when it comes to code performance, so yes, this is my nitpick of the day. :D

     

    You're right, who knows what code already runs and whiles and waits until ... just because ArmA is running. Still, good coding behaviour will sooner or later pay off when all the little things people do out of lazyness or because "it doesn't matter" start to stack up and in a sum will actually matter.

     

    A simple example I witnessed was a life mod with dozens of addAction statements which partly had very complex conditions. One or two complex conditions won't actually matter. But with a bunch of them, you could see a massive drop in frames compared to playing without all these actions. And a lot of these actions had conditions containing "playerSide == west" which you could easily avoid if you only added the action in the first place, IF the player has the respective side.

    • Like 2

  9. @all, please don't feel discouraged by Larrow's response. He's playing in another league (no offense ;)) and I'm still curious about the community's creativity! :D
     

    What counts as a special variable other than the obvious _foreachindex and _x ?


    I consider as special variables basically any local variables, which do exist in certain code blocks or event handlers or whatsoever, because "the engine placed it there", like _this in basically any script/function or _x and _forEachIndex in the forEach loop or _pos, _units, _shift, _alt in the onMapSingleClick EH.
     

    if ( vehicle player isEqualTo player ) then [ { -( parseNumber true ) }, {  [ -( parseNumber true ), [ -( parseNumber true ), [ -( parseNumber true ), [ vehicle player currentWeaponTurret ( [ assignedVehicleRole player select true, [ -( parseNumber true ) ] ] select (driver vehicle player isEqualTo player) ), vehicle player currentMagazineTurret ( [ assignedVehicleRole player select true, [ -( parseNumber true ) ] ] select (driver vehicle player isEqualTo player)), vehicle player magazineTurretAmmo [ vehicle player currentMagazineTurret ( [ assignedVehicleRole player select true, [ -( parseNumber true ) ] ] select (driver vehicle player isEqualTo player)), ( [ assignedVehicleRole player select true, [ -( parseNumber true ) ] ] select (driver vehicle player isEqualTo player)) ] ] ] select ( count ( vehicle player currentWeaponTurret ( [ assignedVehicleRole player select true, [ -( parseNumber true ) ] ] select ( driver vehicle player isEqualTo player ))) > parseNumber false )  ] select ( vehicle player turretUnit ( [ assignedVehicleRole player select true, [ -( parseNumber true ) ] ] select ( driver vehicle player isEqualTo player )) isEqualTo player )  ] select ( count assignedVehicleRole player >= parseNumber true || driver vehicle player isEqualTo player ) } ]
    If the player is in a vehicle and his current turret has a weapon it will return an array of [current weapon, mag, ammo count] else -1

     


    I must admit, I am fairly partly amazed since this massive script produces an output, but testing it as driver in the B_MRAP_01_hmg_F, it gave me a -1. I wonder if that's correct...
     

    Includes some repetition but is all needed for the final value with error checking. :shrug:


    As long as the repetition is needed for an actual purpose and can't be avoided, I'd say it's fine. :rolleyes:


  10. 1. Unless I misunderstood something, without breaking above rules is doable virtually endless chain of conditions (repeating is allowed, isn't?). Like:

     

    if (true or true or true or... etc. 

     

    2. Similar way, via repeating, you can have "endless" switch - do lists, any number of empty loops/scopes in the loops/scopes levels,  etc.

     

    There's likely more such cases.  

     

    Thanks! :) ... and yeah, rules updated. ;)


  11. What is the longest syntactically correct string of scripting commands you can create?

     

    To setup the rules:

    - only scripting commands, spaces, brackets: ( ) [ ] { } and logical operators: = ! & | , ; ? : < > + - * / ^ %

    - no functions

    - no global, local or special variables (like _x, _forEachIndex etc.)

    - no strings (meaning anything wrapped in quotes)

    - no numbers

    - no dull repetitions like infinitely long switch-case blocks or if (true or true or true or ... ;)

     

     

    Let's make two categories:

    1) number of words

    • only the number of words is important, not their length

     

    2) number of characters

    • only the number of characters (excluding logical operators and spaces) is important, not how many words they come from

     

    Here's a starter:

    diag_log str ((getPosATL (allPlayers select floor random count allPlayers)) select floor random count getPosATL player)

    1        2     3          4          5      6     7      8     9            10     11    12     13    14        15 words and 99 characters

     

    The above code grabs the position of a random player and prints a random value of that position into the RPT log.

     

    Have a nice Play!

    Johnny

     

    PS: If you find any loop holes in the rules to create infinitely long strings, please let me know. ;)

    • Like 1

  12. I don't know if there's any specific command to enable/disable mines, but try enableSimulation.

     

    There are some different approaches which come to my mind, depending on how you created the mines.

     

    If this minefield contains all mines throughout the map, you may iterate over allMines and disable them all.

     

    If you create them by script (not in the editor), you should put them into an array which you can then setVariable to the trigger which then can be gotten by the respective trigger statement and be iterated through.

     

    If you create them in the editor (which I assume), you can create a location covering all mines in that mine field, then iterate through allMines and check for each mine, whether it's in the location, so you can determine which you have to disable.


  13. Alright, seems like the BIKI is not clear about this EH. It's actually returning an array of injured parts, at least when it comes to explosives. That's why _this select ... is just the selection of the hit part and then you select according to the BIKI. So this finally works:

    this addEventHandler ["HitPart", {
        _hitPart	= _this select 0; comment "First part in array that got hit";
        _ammoArray	= _hitPart select 6;
        _ammoClass	= _ammoArray select 4;
        hintSilent _ammoClass;
    }];
    

  14.  this addEventHandler ["HitPart", { BMB = ((_this select 0) select 6) ; ammo1 select 4;hint format["%1", ammo1]  }];

     

    Actually, I wonder how that could work, made me wonder already in the first place... I don't know what BMB should be and where you get ammo1 from, but the zero deviser error probably comes from ammo1 select 4, because there is nothing at position 4 if ammo1 doesn't exist. To tell you how this thing works:

     

    If you add an event handler, like "HitPart" here, the code gets a variable called _this, which contains some data. In case of "HitPart" it's actually a lot (11 parameters), but let's focus on only a few ones. Read the BIKI for more.

    this addEventHandler ["HitPart", {
        _target = _this select 0; comment "Object that got injured/damaged";
        _shooter = _this select 1; comment "Unit that inflicted the damage";
        _bullet = _this select 2; comment "Object that was fired";
        _position = _this select 3; comment "Position the bullet impacted (ASL)";
    
        comment "Ammo info: [hit value, indirect hit value, indirect hit range, explosive damage, ammo class name] OR
        if there is no shot object: [impulse value on object collided with,0,0,0]";
        _ammoArray = _this select 6;
        _ammoClass = _ammoArray select 4;
        hintSilent _ammoClass;
    }];
    
    

    That's hopefully gonna solve your problem(s).

     

    EDIT: The above code is seemingly wrong. Read here.


  15. I'm still not at my home PC (where A3 is installed). Actually, I wonder how (_this select 0) select 6 could return the ammo array since I thought _this select 0 was the target that got hit/injured.

     

    Any way, you've got the ammo array looking like this:

    [100, 1000, 3, 1, "demoCharge_Remote_ammo"]
    

    Let's call this array _ammo. Now, if you want to get the string inside that array (the ammo class name), simply do _ammo select 4.

    • Like 1
×