Jump to content

pierremgi

Member
  • Content Count

    4792
  • Joined

  • Last visited

  • Medals

  • Medals

Posts posted by pierremgi


  1. Hi dedmen nice to read you!

    Did you succeed in applying the EH "explosion" on the HMS Proteus, which is a structure without damage, or on the speedboat on which the submarine is attachedTo? After several trials on my side, I didn't find any EH triggering for such case (neither hit/damage nor epecontact). The reason why  I searched for another mean.

     

    waitUntil {uiSleep 0.3; {_x distanceSqr _this < 2600} count allMissionObjects "#explosion" > 0};

    You write that makes no sense ... but that work. The uiSleep is an habit (perhaps bad, but I didn't find any literature about any problem of using it instead of sleep). I did that from the moment I scripted for MP scenario (the game continues to run on pause). I found plenty of qualities with uiSleep but I'm fond of more detailed discussion about that.

     

    The allMissionObject "#explosion" is probably not the best solution, I admitted, I tested FPS and found the uiSleep (or sleep if you want) 0.3 is a good deal between FPS saving and explosion catching. I tested and re-tested, and you?

     

    For params, you're correcting me "passing _local data from a scope to another one", for "grabbing out of the _this". Thanks for such precision. Not sure to understand the difference at my level... but it's important to underline such point, because this confusion is too often made (search for: arma variable passing) by even skilled authors.

     

    I hope such skilled people as you will take time to write a little working script as answer of this topic, far better than mine of course, with the same determination as you did for your explanations.

    Thanks again.

     

     

    • Like 1

  2. 24 minutes ago, avibird 1 said:

    What do you use for the AI command system for your missions.

    Alive DAC EOS ect...

     

    Just mine. I'm fond of less mod as possible. Some of them are great: CUP, UNSUNG above all as they come with map + units. IFA3_AIO also.
    I created a bunch of modules for helping mission builders, but my scenario don't need this mod.

     

    Did you try:

    if (isServer) then {
      private _coolDown = 20;
      _coolDown spawn {
        params [["_coolDown",10],"_allVehicles"];
        while {true} do {
          _allVehicles = vehicles select {isNil {_x getVariable "vehiclepassed"} && _x isKindOf "car"};
          {
            [_x,_coolDown] spawn {
              params ["_veh","_coolDown","_pos"];
              while {alive _veh} do {
                waitUntil {uiSleep 2; _pos = getpos _veh; speed _veh < 1};
                uiSleep _coolDown;
                if (speed _veh < 1 && _veh distanceSqr _pos < 25 && !isPlayer driver _veh && currentCommand _veh != "") exitwith {
                  {_veh deleteVehicleCrew _x} count crew _veh; deleteVehicle _veh;
                };
              };
            };
            _x setVariable ["vehiclePassed",true];
          } forEach _allVehicles;
        };
      };
    };

     

    This work for any car (only), edited or spawned. Perhaps you should decrease _cooldown (here 20) for faster deletion.
    If not, I'm not sure to understand your parameters, but there is (most of the time), a solution.


     


  3. At start, the unitCapture was made for helicopters. You can run it also for boats, without weird behavior. On the other hand, you experience such bad behavior with land vehicles. Imho, the best thing you can try is to use your recorder points for path with the command setDriveOnPath

    To answer you question, it's possible to repeat the engine on, but not very immersive and the animation stays ugly.

    • Thanks 1

  4. onEachFrame {
      _units = player nearEntities [["CAManBase","air","landVehicle","ship"], 17];
      _units = _units - [player];
        {
        _color = switch (playerSide) do {
            case (EAST): {[1,0,0,1]};
            case (WEST): {[0,0,1,1]};
            case (independent): {[0,1,0,1]};
            case default {[2.55,0.55,0,10]};
        };
        if (side _x isEqualto playerSide) then {
          if (([player,"view", _x] checkVisibility [AGLToASL positionCameraToWorld[0,0,0],getPosASL vehicle _x])>0) then {
            drawIcon3D [
              "",
              _color,
              [visiblePosition _x select 0,visiblePosition  _x select 1, (visiblePosition _x select 2) +((_x ModelToWorld (_x selectionPosition "player")) select 2)+ 1.83],
              45,
              -2,
              -1,
              name _x,
              2,
              0.035,
              "Puristamedium",
              "center"
            ];
          };
        };
      }forEach _units;
    };

     

    But, you can use the stackable version:
     

    ["myCodeForTags", "onEachFrame", {
      _units = player nearEntities [["CAManBase","air","landVehicle","ship"], 17];
      _units = _units - [player];
        {
        _color = switch (playerSide) do {
            case (EAST): {[1,0,0,1]};
            case (WEST): {[0,0,1,1]};
            case (independent): {[0,1,0,1]};
            case default {[2.55,0.55,0,10]};
        };
        if (side _x isEqualto playerSide) then {
          if (([player,"view", _x] checkVisibility [AGLToASL positionCameraToWorld[0,0,0],getPosASL vehicle _x])>0) then {
            drawIcon3D [
              "",
              _color,
              [visiblePosition _x select 0,visiblePosition  _x select 1, (visiblePosition _x select 2) +((_x ModelToWorld (_x selectionPosition "player")) select 2)+ 1.83],
              45,
              -2,
              -1,
              name _x,
              2,
              0.035,
              "Puristamedium",
              "center"
            ];
          };
        };
      }forEach _units;
    }] call BIS_fnc_addStackedEventHandler;

     

     

     

    • Like 2

  5. Are you using naval mines? What is made your explosion of?

     

    Anyway, here is an alternate solution:

    - place your speedboat, name it speedboat, add waypoints;

    - place your HMS Proteus, in its init field, write this code:


     

    this attachTo [speedBoat,[0,0,-3]];
    this setVectorDirAndUp [[0,-1,0],[0,0,1]];
    0 = this spawn {
      _sub = _this;
      waitUntil {uiSleep 0.3; {_x distanceSqr _this < 2600} count allMissionObjects "#explosion" > 0};
      detach _this;
      {speedboat deleteVehicleCrew _x} count crew speedboat;
      deleteVehicle speedboat;
      _timer = diag_tickTime;
      while {uiSleep 0.1; diag_tickTime < _timer + 30} do {_sub setVelocityModelSpace [0,-5,-3]};
      deleteVehicle _sub
    };

     

    Optional : Smooth the waves (to zero) in environment menu.

    Probably not the best solution, but the first one so far 😉

    Enjoy.

    • Like 1

  6. 34 minutes ago, avibird 1 said:

    @pierremgi getting a undefined variable error with the code.  I can't get the code to work. I placed it in a trigger game logic and a server.init. 

    That' because I gave you an example with car1, car2, car3 which MUST exist. You have to adapt the code to your existing cars (or use my first solution with isKindOf "car")

     

    34 minutes ago, avibird 1 said:

    The car type I am using is the Qilin (minigun) with a drive and a Gunner crew and a fire team of 4 that will jump out when the vechicle engages units. 

    That doesn't matter but if your crew jump out of car, the car is abandoned, not stuck, so out of my script scope.

     

    34 minutes ago, avibird 1 said:

    Issues I for see is

     

    if the fire team jumps out to engage units the Jeep and crew may hold position and if the time reaches the two minute mark the script will delete the group! 

    I don't understand

     

    34 minutes ago, avibird 1 said:

    Jebus will delete units at start of mission then respawn them into the mission. when this happens the variable name and custom call sign of the vehicle if you gave one will be deleted.

    That's the Jebus problem but there is some code/script to avoid that. I made and shared my own respawn vehicle script, spent a lot of time on it. As said above, the first solution applies, even with spawned vehicles.

     

     

    • Thanks 1

  7. On 11/9/2019 at 9:25 AM, killzone_kid said:

    How more obvious could this be? https://prnt.sc/pujsvq

    Sure! But perhaps, you should take one more time for clear explanation rather than :

    If you don’t understand what command does, why do you use it? Use what you can understand, like _this select n instead

    Except if you want a forum for skilled persons only, without any basic question, just referencing the holy BIKI. Not my concept.

     

    On 11/9/2019 at 12:00 PM, Play3r said:

    @pierre MGI and @killzone_kid

     

    Thank you for your help with this problem, but is look like the blast won't go true the submarine so it hits the speedboat.

    I have tried with just the boat and there i can hit approx 3 mtr from the speedboat and it sinks fine, when i add the submarine nothing happens the submarine just keeps rocking in the water.

    So i guess there has so be added another parameter like a distance to the blast from the boat, but that is way over my knowhow.

    But thanks for your help, it was a success for me i did learn something.

    Your submarine can't take hit. It's a structure, not a ship, without any effect with damage. The only thing you can do is a new cinematic (sinking) when your speeboat is destroyed: Re-attach to the wrecked boat, not tested, not sure it's feasible or applying a velocity like proteus (or name you gave to it)

    after speedboat setdamage 1; write:

    proteus spawn { _sub = _this; _timer = diag_tickTime; while {uiSleep 0.5; diag_tickTime < _timer + 30} do {_sub setVelocityModelSpace [0,2,-10]}; deleteVehicle proteus};

    • Like 3

  8. 4 hours ago, Play3r said:

    So i did understand it right, i just didn't know that i had to type SetDamage 1 and not just the % i wanted it to damaged.

    Am i right that i can type  >params["speedboat"] < instead of _veh if i want to?

     

    No you're wrong. As said, params doesn't accept a global variable. See BIKI for variables.

    You can use _speedboat instead, no matter the name of your ship. With params, you start the inside code with "let's call here the object (on which you apply the EH "explosion" and passed as 1st param by engine):  _speedboat. This local variable has no "existence" in an outter scope (spawned or else).

     

    If you want to apply a simple value like: 1, let's try the EH "handleDamage", far more difficult to understand, and not specific for explosion.


  9. You can replace _x isKindOf "landVehicle" by _x isKindOf "car"

    or

    if (isServer) then {
      private _coolDown = 20;
      {
        [_x,_coolDown] spawn {
          params ["_veh","_coolDown","_pos"];
          while {alive _veh} do {
              waitUntil {uiSleep 2; _pos = getpos _veh; speed _veh < 1};
            uiSleep _coolDown;
            if (speed _veh < 1 && _veh distanceSqr _pos < 25 && !isPlayer driver _veh && currentCommand _veh != "") exitwith {
              {_veh deleteVehicleCrew _x} count crew _veh;
              deleteVehicle _veh;
            };
          };
        };
      } forEach [car1,car2,car3];
    };

    for car1, car2, car3.

    • Like 1
    • Thanks 1

  10. To make it short and less moralist, you can't pass global variable in params. (And it's totally useless).

     

    params is used for passing _local data from a scope (script level) to another one (other script, spawned script,  EH code, add action code...). Some of them are already sent by the engine (like for EHs, addAction).

    params ["speedboat", "1"]; has no sense because speedboat and 1 are values working everywhere (as soon as speedboat is defined). speedboat (without underscore) is a global variable. For example, the name you gave in editor to the boat.

     

    As you can read here, your "explosion" EH has 2 parameters: (_vehicle and _damage) but you can rename it if you want.

    Try:

    this addEventHandler ["Explosion", { params ["_veh"];  _veh setDamage 1}];

     

     

    • Like 1

  11. something like this?

     

    if (isServer) then {
      private _coolDown = 20;
      _coolDown spawn {
       params [["_coolDown",10],"_allVehicles"];
       while {true} do {
         _allVehicles = vehicles select {isNil {_x getVariable "vehiclepassed"} && _x isKindOf "landVehicle"};
         {
           [_x,_coolDown] spawn {
             params ["_veh","_coolDown","_pos"];
              while {alive _veh} do {
               waitUntil {uiSleep 2; _pos = getpos _veh; speed _veh < 1};
               uiSleep _coolDown;
               if (speed _veh < 1 && _veh distanceSqr _pos < 25 && !isPlayer driver _veh && currentCommand _veh != "") exitwith {
                 {_veh deleteVehicleCrew _x} count crew _veh;
                 deleteVehicle _veh;
               };
             };
           };
           _x setVariable ["vehiclePassed",true];
         } forEach _allVehicles;
       };
     };
    };

    You will not delete empty vehicle, crew just stopped (so waiting for a move order), vehicle driven by player.

     

    • Like 1

  12. Sure, as KK said, use the weather menu in editor. You're just writing useless lines.

    A while {something true} do {if (this time) then {same code } 24 times} is just a waste of code.

    First of all dayTime depends on time multiplier, so there is no need for your delay stuff. Btw, also follow agentRev remark in setOvercast command:

    (1800 * timeMultiplier) setOvercast _value;

    Furthermore your time multiplier is never updated in your loop! So, useless.

     

    So, if you want to change weather on each hour, spawn :

    while {_weather} do {
      private _valueOvercast = random [0, 0.3, 1];
      (1800 * timeMultiplier) setOvercast _valueOvercast;
      if (_valueOvercast >= 0.5) then {
        _vauleRain = _valueOvercast;
        (1800 * timeMultiplier) setRain _vauleRain;
        if (_vauleRain <= 0.4) then {
          (1800 * timeMultiplier) setFog random [0, 0.2, 0.5];
        };
      } else {
        (1800 * timeMultiplier) setRain 0;
      };
      uiSleep 3600;
    };

     

    • Like 3
    • Thanks 1
×