Jump to content

sarogahtyp

Member
  • Content Count

    2494
  • Joined

  • Last visited

  • Medals

Posts posted by sarogahtyp


  1. MMB is to select default action from action menu without opening it. It also opens doors or weapon arsenals depending on the situation or where u r pointing at. I guess you have to look in general controls for something like default action. But currently i ve no arma and are guessing...

    • Like 1

  2. not tested but should do safe teleports if working generally:

    Spoiler
    
    private _pos = [6447,4788,0];
    
    [thisList, _pos] spawn
    {
     params ["_triggerObjects", "_teleportPosition"];
     
     private ["_radius", "_vec", "_minDist", "_maxDist", "_safePos"];
     private _maxRadius = 0;
     private _distLimit = 1000;
     private _defPos = [ 0, 0, 0];
      
     // select all land vehicles, get radius of all vehicles, get maximum radius
     private _triggerVehicles = _triggerObjects select { _x isKindOf "LandVehicle" } apply 
     { 
       _radius = (sizeOf _x) / 2;
       if ( _radius > _maxRadius ) then { _maxRadius = _radius };
       [ _x, _radius ]
     };
      
     // select all units which are on foot
     private _triggerUnits = _triggerObjects select  { _x isKindOf "Man" and isNull ObjectParent _x  };
     
     // find a safe position for each vehicle and place it
      {
        _vec = _x select 0;
        _radius = _x select 1;
        _minDist = _maxRadius + 2 + _radius;
        _maxDist = 50;
        _safePos = _defPos;
        
        while { _safePos isEqualTo _defPos and _maxDist < _distLimit } do
        {
         _safePos = [ _teleportPosition, _minDist, _maxDist, minDist, 0, 0.7, 0, [], [ _defPos, _defPos ] ] call BIS_fnc_findSafePos;
         _maxDist = _maxDist + _maxDist;
        };
        
        if( _safePos isNotEqualTo _defPos ) then { _vec setVehiclePosition [ _safePos , [], 1, "NONE" ]; };
          
      } forEach _triggerVehicles;
      
      _minDist = 2;
      
       // find a safe position for each unit and place it
      {
        _maxDist = 50;
        _safePos = _defPos;
        
        while { _safePos isEqualTo _defPos and _maxDist < _distLimit } do
        {
         _safePos = [ _teleportPosition, _minDist, _maxDist, minDist, 0, 0.7, 0, [], [ _defPos, _defPos ] ] call BIS_fnc_findSafePos;
         _maxDist = _maxDist + _maxDist;
        };
        
        if( _safePos isNotEqualTo _defPos ) then { _x setPos _safePos; };
        
      } forEach _triggerUnits;

     

    • Like 3

  3. Just now, Deleted said:


    I see. That makes sense, thank you very much. I suppose I should revisit the BI Wiki to evaluate which commands are local and which are global.

    So from what I understand from your comments, should I place something like this in the helicopter's init box?
     

    
    if (!isServer) exitWith {};
    
    [[HelicopterVarName, true], "Scripts\H60Setup.sqf"] remoteExec ["execVM", 0];

     

    No this would execute the script on each machine which is exactly the opposite of what the first line (if (!isServer ...) does.

    You have to use remoteExec within your scipt on the 2 commands I mentioned.

    hint has to get executed on each client and not on server. use -2 as the target parameter on remoteExec for this.

    setHitPointDamage has to get executed where _helicopter is local. therefore u use _helicopter as target parameter of remoteExec


  4. The script is running on your dedicated server but it does'nt work as intended because you did not pay attention to locality.

    Multiplayer scripting is very different to Singleplayer scripting because on each line of your script you have to ask on which machine that command has to be executed.

     

    Basically 2 commands of your script do not work as intended:

     

    1. your hint command gets executed on server only and therefore its string will only get shown on server.

    2. the command setHitPointDamage is executed on server as well but its arguments have to be local on the machine where this command gets executed to take any effect. But the argument _helicopter is local on the machine of the pilot player who is flying it. Therefore the whole command has to get executed on that machine.

     

    How to get those commands executed where they have to get executed?

    The command you need to learn is remoteExec

     

    How to know which command needs such "remote execution"?

    Every command on the top of its biki page has some icons like "AL" or "EL". Those icons show you if the effects of this command are local to the machine where it is executed like with the hint command or if the arguments of the command have to be local on the machine where it gets executed loke with the setHitPointDamage command.  

    • Like 1

  5. private _mercTargets =
        [
            loner_1,
            loner_2,
            loner_3,
            loner_4,
            loner_5,
            loner_6,
            loner_7,
            loner_8,
            loner_9,
            loner_10,
            loner_11,
            loner_12,
    
            duty_1,
            duty_2,
            duty_3,
            duty_4,
    
            bandit_1,
            bandit_2,
            bandit_3,
            bandit_4,
    
            sky_1,
            sky_2,
            sky_3
        ];
    
    private _randSel = [];
    
    // do 9 times
    for "_i" from 1 to 9 do
    {
     private [ "_temp", "_d" ];
     
      // select one element randomly
     _temp = selectRandom _mercTargets;
      
      //find the selected element in array and delete it (there are many other ways doing this)
     _d = _mercTargets deleteAt ( _mercTargets findIf { _x isEqualTo _temp }; );
      
      //push the selected element into an array
     _d = _randSel pushBack _temp;
    };
    
    // now you have the array _randSel which contains 9 random elements out of _mercTargets

    not tested cause I ve no arma available this week

    • Like 1

  6. usually the script fires at a random position somewhere in the air.

    you can't declare a target but you could pass an array of ASL positions to the script by using the 4th parameter. The script will select one of those positions randomly.

     

    I created a working example mission which shows that the script works flawlessly:

    https://www.dropbox.com/s/o7spbwtcl1dj0y8/tempMissionMP.VR.zip?dl=0

    It does not use those predefined positions array.

    • Like 1

  7. 59 minutes ago, _foley said:

    If you know the mods that will be used during the mission beforehand, you can run @sarogahtyp 's script in editor, copy the contents of the generated hashmap to clipboard and paste it into the mission scripts. That way you don't have to spawn a bunch of vehicles during play and you will have the data available instantaneously.

     

    @Waldemar 337 

    I think @_foley's suggestion is a good idea. Normally I am more in favour of a dynamic solution, but if you have to spawn vehicles all the time, then I am also more in favour of hardcoding or a dynamic/hardcoding-hybrid:

     

    In your vehicle viewer mod you could hard code the data for the most common vehicle mods like CUP and RHS and of course for the vanilla vehicles.

    You could also use the ugly solution (using createVehicleLocal) for all vehicles that are not found in the hashmap.

    This way you have a fast, always working solution which mostly will not spawn vehicles for just viewing them with your mod.

    • Like 1

  8. You could try it with using showHUD in description.ext to set it for all players for the whole mission:

    https://community.bistudio.com/wiki/Description.ext#showHUD

    This should behave differently from the script command.

     

    If that is not helping and if you are talking about the visionAid difficulty setting (see here) then it's upto the server owner to set a fitting difficulty preset (see here forcedDifficulty and here ) and then you just can't change that with a script command or a mission setting.


  9. createSimpleObject does not work for getting the mass.

     

    This script will create the hashmap for all vehicles. it can be tested on debug console and will hint the number of vehicles and the runtime used for the script:

    private [ "_startTime", "_d", "_runtime", "_className" ];
    
    sneakyPeakyGlobalMassHashmap = createHashMap;
    
    isNil {
     _startTime = diag_tickTime;
    
     {
      _className = configName _x;
      _d = _className createVehicleLocal [ 0, 0, 0 ];
      sneakyPeakyGlobalMassHashmap set [ _className, ( getMass _d ) ];
      deleteVehicle _d;
     } forEach
     ( "_classname = configName _x; getNumber (_x >> 'scope') isEqualTo 2 && (_classname isKindOf 'Helicopter' ||
                        _classname isKindOf 'Plane' || _className isKindOf 'Car' || _className isKindOf 'Motorcycle' || _className isKindOf 'Tank' ||
                        _className isKindOf 'Ship_F') " configClasses (configFile >> "CfgVehicles") );
    
     _runtime = diag_tickTime - _startTime;
    };
    
    hint format [ "Count: %1 - Time: %2", (count sneakyPeakyGlobalMassHashmap), _runtime];

     

    If u really want to get the mass within the mission then I recommend to use createVehicleLocal to "hide" the spawned vehicle from other connected players. You will also have no vehicle collisions this way.

    • Like 3

  10. 3 hours ago, Waldemar 337 said:

    1. Requirement to make some measurements of all possible vehicle classes in the game.

    Its not a problem to spawn/despawn 1000 vehicles local on server within some seconds before any player has joined.

     

    3 hours ago, Waldemar 337 said:

     

    1.1. This makes mission initialization fragile. If some add-on breaks the initialization process of these calculations, we will have to make them again and again.

    What?

     

    3 hours ago, Waldemar 337 said:

     

    1.2. Big data needs big space. Who and where will store all the encyclopedia of class parameters ? I thought that vehicle classes were created right for that very purpose. Game modders do not need to make the game engine themselves.

     

    2. Requirement to search data in a big data storage. All this takes time.

    1000 times the classname as key and the mass as data stored in a hashmap. There is no problem with memory usage and not with the access time.

    • Like 2
×