Jump to content
Ivanoff.N

Mortar gun elevation and direction, are they local ?

Recommended Posts

Hi.

I am writing a script for artillery so that a person standing outside of the mortar can see the mortar`s elevation and direction. And it works in SP, however in multiplayer I get false readings. The digits I get is not what the gunner sees.

Are the values local ? 

If so is it possible to get true gunner`s values, globalize them and share with people nearby ?

Share this post


Link to post
Share on other sites
1 hour ago, Grumpy Old Man said:

Read it where they are local.

Nothing much to do without an example either way.

 

Cheers

private _gundirection = ((getdir (vehicle gunner _unit)));

//Unit is the mortar the script is executed on.

 

That is basically the script to read gun direction, is there another place to read it from as global  ?

Share this post


Link to post
Share on other sites
1 hour ago, Ivanoff.N said:

No suggestions ? 

How can we help you with so few script? I guess _unit is not coming from nowhere! So, give your script with the context.

 

Share this post


Link to post
Share on other sites
On ‎1‎/‎12‎/‎2018 at 1:43 AM, pierremgi said:

How can we help you with so few script? I guess _unit is not coming from nowhere! So, give your script with the context.

 

Okay this is the full thing:

//This below is some BIS code to make the 3d icon show
params [["_units", []]];
if (isNil "BIS_iconUnits") then { BIS_iconUnits = [];};
BIS_iconUnits append _units;if (!(isNil "BIS_fakeTexture")) exitWith { true};
BIS_fakeTexture = [1,1,1,0] call BIS_fnc_colorRGBAtoTexture;
addMissionEventHandler[ "Draw3D", {  {   
  
//these are the variables I use to calculate mortar elevation, direction and charge   
 private _unit = _x;   
 //Determine selection positions for the markers   
 private _poschargepl = _unit modelToWorld [_unit selectionPosition "pilot" select 0, _unit selectionPosition "pilot" select 1,_unit selectionPosition "pilot" select 2 ];   
 private _poschargepl2 = _unit modelToWorld [_unit selectionPosition "usti hlavne" select 0, _unit selectionPosition "usti hlavne" select 1,_unit selectionPosition "usti hlavne" select 2 ];   
 private _poschargepl3 = _unit modelToWorld [_unit selectionPosition "OsaHlavne" select 0, _unit selectionPosition "OsaHlavne" select 1,_unit selectionPosition "OsaHlavne" select 2 ];   
 //Get direction of the mortar base   
  private _Globdir = ((getdir (_unit)));        
  if     
  ((_unit iskindof "StaticMortar")&&(alive _unit))     
  then     
  {      
    if
      (! isnull (gunner _unit))       
    then       
    {       
      // Determine charge        
      private _charge = getnumber (configfile >> "CfgWeapons" >> (currentweapon _unit) >> (currentweaponmode (gunner _unit)) >> "artillerycharge");        		//Determine gun elevation        
      private _Gunelev = Deg (( _unit) AnimationPhase "MainGun");        
      //Convert gun elevation to milliradian (Note, there are no calculations for slope here so if mortar is not on even surface the elevation is not shown correctly)        
      private _Gunelevfin = (round((((_Gunelev)+75))*17.77777777777778));        
      //Get mortar turret direction in relation to mortar base and convert to 360 degrees        
      private _Gundir = ((Deg ((_unit) AnimationPhase "MainTurret")-360)% 360);        
      //Get turret direction in relation to world        
      private _endres = (((((_gundir)*-1))+_Globdir)%360);         
      //Convert direction to milliradian        
      private _endresfin = ((round((_endres)*17.77777777777778)));        
      //Convert variables to strings to be displayed        
      private _prsnmbr = str (round(_charge*3)) ;        
      private _prsnmbr2 = str _endresfin;        
      private _prsnmbr3 = str _Gunelevfin;                
      
      //Draw 3d icons        
      drawIcon3D        
        [         
        BIS_fakeTexture,         
        [0,125,255,1],         
        [_poschargepl select 0, _poschargepl select 1, (_poschargepl select 2)],         
        0,         
        -0.5,         
        0,         
        "Dir "+_prsnmbr2,                  
        0,         
        0.025        
      	];        
      
      drawIcon3D        
        [         
        BIS_fakeTexture,         
        [0,125,255,1],         
        [_poschargepl2 select 0, _poschargepl2 select 1, (_poschargepl2 select 2)],         
        0,         
        -0.5,         
        0,         
        "Ch "+_prsnmbr,                  
        0,         
        0.025        
      	];        
      
      drawIcon3D        
        [         
        BIS_fakeTexture,         
        [0,125,255,1],         
        [_poschargepl3 select 0, _poschargepl3 select 1, (_poschargepl3 select 2)],         
        0,         
        -0.5,         
        0,         
        "Ang "+_prsnmbr3,                  
        0,         
        0.025        
      	];       
    }     
  };        
       } forEach BIS_iconUnits; 
    }
];

This makes a 3d marker and places it on the mortar and shows its data to someone standing outside. 

The function is executed by the mortar [[mortarname]] call fnc_function;

 

Problem is that in single player the displayed data is correct. But in multiplayer, the data displayed differs from the one the gunner is seeing. 

It is not off by much, few mills, but still it is off.;

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

×