Jump to content

sarogahtyp

Member
  • Content Count

    2494
  • Joined

  • Last visited

  • Medals

Posts posted by sarogahtyp


  1.  

     
    I have to enter that code in "Condition" ?

     

     

    No, try to add it in your init.sqf

     

    For u the better solution should be to place a trigger in editor with:

     

    Condition field: player in thisList

    On activation field: player allowDamage false

    On deactivation field: player allowDamage true

    • Like 1

  2. So here I proudly present a snippet which should do the job. _perfect_start should be the best start point in players model space for our problem.

    _perfect_end = screenToWorld [0.5,0.5];
    _err = vectorDiff _perfect_end - _posXhair;
    
    _dir = player weaponDirection (currentWeapon player);
    
    _reverse_start = _perfect_end vectorAdd (_dir vectorMultiply -5000);
    
    _array = lineIntersectsSurfaces [_perfect_end, _reverse_start, objNull,objNull, false, 10, "GEOM","NONE"];
    
    _array_count = count _array;
    
    if (0 < _array_count) then
    { 
     {  
      if((_x select 2) == player)  
      {   
       _perfect_start = player worldToModel(_x select 0);  
      } 
     } forEach _array;
    };

    I ve calculated _err which is the error vector between actual crosshair and the perfect crosshair position. But I m not using it. It can be used to test if we have a precise crosshair position when the snippet is implemented to code.

     

    Upto now there are some problems with that snippet.

     

    1. yesterday I tested to use screenToWorld [0.5,0.5]; all the time to draw the crosshair but the command is to slow. crosshair was blinking.

       I suggest this correction could be run one time per second.

     

    2. screenToWorld [0.5,0.5]; is working with the surface only. that means you get very wrong values if aiming to heaven.

     

    3. screenToWorld [0.5,0.5]; is not working with objects (surface only) that means that the 10 I used at lineintersect command could be to low.

     

    4. the snippet has to be implemented as auto correction in the code and yes of cause it has to be tested :-)


  3. Some questions:

     

    Is it a multiplayer problem?

    You said a script should target those player. Do u only need the script to know who the player is or is that script controlling AI which should taget at the player?

    If it is a multiplayer problem then I need some info where the script is running, at client or at server and how is that script started? Is it started by trigger, eventhandler or is it always running and tracking the player if it reaches those box?

     

    If u answer some of those questions then u could get some more help. Posting ur script will us help to help u, too.

     

    EDIT: I wrote that before I read the previous post...


  4. Now I substituted this line of my code:

    _corr = ([0.12,0.57,0.52] vectorAdd [0,0,1.5*(_dir select 2)]);

    with that one:

    _corr = [0.12,0.57,0.52 * (_dir select 2)];

    and now it is as precise as your solution:

     

    crosshair reached inner x-axis marker at a distance of 9 m

    crosshair reached inner y-axis marker at a distance of 10 m

    I prefer my code now for the much better performance.


  5. okay, i tested both solutions a bit and it turns out they both have advantiges and disadvantages.

    I tested with a scope where I now define the horizontal line as x-axis and the vertical line as y-axis to let u know what i found out.
    I used this scope: this addPrimaryWeaponItem "optic_SOS";
    and that weapon: this addWeapon "arifle_MXM_F";

    there are markers at these lines which I used to get a distance when the crosshair reaches em. I used the inner markers for that.

    Your solution:

    crosshair reached inner x-axis marker at a distance of 7 m
    crosshair reached inner y-axis marker at a distance of 10 m

    My solution:

    crosshair reached inner x-axis marker at a distance of 130 m
    crosshair reached inner y-axis marker at a distance of 9 m

    So ur solution is much more precise but I ve the problem with your code that it seems to be slow. The crosshair is blinking very much at my slow PC. I tried to compensate that by retracing the crosshair between calculations and it gets a bit better but it is still blinking.

    EDIT: i did not test leaning, kneeling and crouching. i assume that my code should cover it cause i use eye position. i dont know if yours do.


  6. I dont know, I m to tired to test it but here is my solution. 

    while{true} do
    {
     while {player isIRLaserOn currentWeapon player} do
     {
      if (cameraView == "GUNNER") then
      {
       _txtXhair = "";
       _posXhair = positionCameraToWorld [0, 0, 10000];
    
       _dir = player weaponDirection (currentWeapon player);
    
    //EDIT: substituted following line as it is a better solution then
    
    //   _corr = ([0.12,0.57,0.52] vectorAdd [0,0,1.5*(_dir select 2)]);
    
       _corr = [0.12,0.57,0.52 * (_dir select 2)];
    
       _temppos = player selectionPosition "pilot";
       _posLaser = AGLToASL (player modelToWorld (_temppos vectorAdd _corr));
    
       _posXhair = _posLaser vectorAdd (_dir vectorMultiply 4999);
    
       _hitLaser = lineIntersectsSurfaces [_posLaser, _posXhair, player,objNull, true, 1, "GEOM","NONE"];
       if (0 < count _hitLaser) then
       {
        _posXhair = (_hitLaser select 0) select 0;
        _txtXhair = str(round(_posLaser distance _posXhair));
       };
       _posXhair = ASLToAGL _posXhair;
    
      drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\weapon_ca.paa", [0,0.2,0,1], _posXhair, 1, 1, 0, _txtXhair, 0, 0.02, 
    
    "TahomaB", "center", false];
      };
     sleep 0.03;
     };
    sleep 5;
    };
    

  7. that eventhandler seems to be never activated. i have to think about it some time. maybe we should use another eventhandler but I never used those eventhandlers... im learning while helping. give me some minutes and we try another thing.

    could u do another clean vanilla mission in virtual reality meanwhile? with one player only and the same script and init line. just to reduce the problem. and use the 2d editor for it cause eden is buggy.

×