Jump to content

Recommended Posts

Posted

 

Also I think I have the gun angle settings all jacked up.  Again, more explanation from ChatGPT... any old-salts around here can jump in an correct if something is incorrect, but I found it useful...

 

🔧 GT.WS[2].reference_angle_Y = math.rad(150)

✅ What It Does

This line defines the default yaw orientation (left/right direction) of the weapon station (in this case, WS[2]) relative to the model’s forward axis.

In simpler terms:

  • It tells DCS:
    “This gun should face 150 degrees to the right from the building’s forward direction.”


🧭 How the Angle Works

DCS uses a clockwise angle system based on degrees from front (0°):

  • reference_angle_Y = math.rad(0) → faces forward

  • reference_angle_Y = math.rad(90) → faces right

  • reference_angle_Y = math.rad(180) → faces backward

  • reference_angle_Y = math.rad(270) → faces left (or -90°)

So:

GT.WS[2].reference_angle_Y = math.rad(150)

Means:

  • The gun on WS[2] is angled slightly to the right of rear — facing between right-rear and rear

  • Useful if your gun is placed on the rear-left corner of a building and should cover the rear-right approach

 

 

✅ Related Properties You Should Know

🔄 angles = {{ left_limit, right_limit, down_limit, up_limit }}

This defines the arc of movement for the weapon station.

Example:

angles = {
    {math.rad(120), math.rad(180), math.rad(-10), math.rad(30)}
}

  • Can move between 120° and 180° in yaw

  • Can elevate from -10° (down) to +30° (up)

⬅️➡️ maxLeft and maxRight

These are soft yaw constraints for aiming AI.

🎯 Combined Use

For a rear-facing MG:

GT.WS[2].reference_angle_Y = math.rad(180)  -- gun faces rear
GT.WS[2].angles = {
    {math.rad(135), math.rad(225), math.rad(-10), math.rad(30)}  -- covers rear arc
}

  • Thanks 1

[sIGPIC]sigpic65507_1.gif[/sIGPIC]

Posted

Another key point.  The left and right thing obviously depends on point of view.  So imagine you are IN the house looking out the front door. 

I had been doing it wrong, thinking I was looking at, or facing the object.

 

The Z-axis value (left/right offset) is:

  • Positive (+Z) → Right from the object's own point of view

  • Negative (−Z) → Left from the object's own point of view

  • Like 1

[sIGPIC]sigpic65507_1.gif[/sIGPIC]

Posted (edited)

I think this is a good place to post a correction (possibly).

 

Testing has proven this to be exactly backwards - for some reason, and I've had ongoing debates with ChatGPT on this (he is not convinced), it seems like the first angle and second angle are reversed. 

 

Or in other words, for a rear-facing gun placement aimed at 180 degrees, to have coverage from 135 degrees to 225 degrees, you want to go in COUNTERCLOCKWISE order, and not clockwise.  So this (below) is wrong, according to my testing.

 

For a rear-facing MG:

GT.WS[2].reference_angle_Y = math.rad(180)  -- gun faces rear
GT.WS[2].angles = {
    {math.rad(135), math.rad(225), math.rad(-10), math.rad(30)}  -- covers rear arc

 

Instead, this seems to produce the correct behavior (below):

 

GT.WS[2].reference_angle_Y = math.rad(180)  -- gun faces rear
GT.WS[2].angles = {
    {math.rad(225), math.rad(135), math.rad(-10), math.rad(30)}  -- covers rear arc

 

Here is a building that only fires forward and rear, covering a 120 degree field of fire each way - in testing I park trucks on the left and the right, and the building does not engage them.

 

--DCS Middle Eastern Armed Building template--

GT = {};
GT_t.ws = 0;

set_recursive_metatable(GT, GT_t.generic_stationary);
set_recursive_metatable(GT.chassis, GT_t.CH_t.STATIC);
GT.chassis.life = 50 

GT.visual.shape = "MEArmedBldg10"; -- edm name
GT.visual.shape_dstr = "s3_crush"  -- using destroyed shape model from existing object
GT.CustomAimPoint = {1,1.5,1}
--Burning after hit
GT.visual.fire_size = 1.2 --relative burning size
GT.visual.fire_pos = {0.5,0,0};
GT.visual.fire_time = 600 --burning time (seconds)
GT.visual.min_time_agony = 20;
GT.visual.max_time_agony = 120;

GT.sensor = {};
set_recursive_metatable(GT.sensor, GT_t.SN_visual);
GT.sensor.height = 3.0;
GT.sensor.max_range_finding_target = 1000;

local __LN_PK = {}; 
set_recursive_metatable(__LN_PK, GT_t.LN_t.machinegun_7_62);
__LN_PK.connectorFire = false;
__LN_PK.distanceMax = 800;
for i=2,10 do -- 1000 rnds
    __LN_PK.PL[i] = {};
    set_recursive_metatable(__LN_PK.PL[i], __LN_PK.PL[1]);
end
__LN_PK.BR[1].pos = {1,0,0};

GT.WS = {};
GT.WS.maxTargetDetectionRange = 1500;

-- 🔧 Reset inherited angles 
__LN_PK.angles = nil
__LN_PK.angles_mech = nil

-- 🔧 Reset other rotation fields to prevent leaks
__LN_PK.reference_angle_Y = nil
__LN_PK.omegaY = nil
__LN_PK.omegaZ = nil
__LN_PK.pidY = nil
__LN_PK.pidZ = nil

-- Front-facing MG
local ws = GT_t.inc_ws()
GT.WS[ws] = {
    pos = {3.5, 2.7, -1.7}, -- {x,y,z} = (front+/back-, up+/down- , left-/right+)
    angles = {
        {math.rad(60), math.rad(300), math.rad(-10), math.rad(35)}
    },
    reference_angle_Y = math.rad(0),
    omegaY = math.rad(120),
    omegaZ = math.rad(120),
    pidY = {p=10,i=0.05,d=2,inn=3},
    pidZ = {p=10,i=0.05,d=2,inn=3},
}
add_launcher(GT.WS[ws], __LN_PK)


-- Rear-facing MG
ws = GT_t.inc_ws()
GT.WS[ws] = {
    pos = {-3.5, 1.5, -1.5}, --  {x,y,z} = (front+/back-, up+/down- , left-/right+)
    angles = {
        {math.rad(240), math.rad(120), math.rad(-10), math.rad(35)}
    },
    reference_angle_Y = math.rad(180),
    omegaY = math.rad(120),
    omegaZ = math.rad(120),
    pidY = {p=10,i=0.05,d=2,inn=3},
    pidZ = {p=10,i=0.05,d=2,inn=3},
}
add_launcher(GT.WS[ws], __LN_PK)

GT.Name = "MEArmedBldg10";
GT.DisplayName = _("Armed Building10");
GT.Rate = 5;
GT.DetectionRange  = 0;
GT.ThreatRange = __LN_PK.distanceMax
GT.mapclasskey = "P0091000076";
GT.attribute = {wsType_Ground,wsType_Tank,wsType_Gun,wsType_GenericFort,
                "Fortifications",
                "CustomAimPoint",
                };
GT.category = "Fortification";

add_surface_unit(GT)

 

Please offer comments or evidence if this is incorrect.

 

 

Edited by Ripcord

[sIGPIC]sigpic65507_1.gif[/sIGPIC]

Posted (edited)

There are couple of buildings, I guess, that offer some interesting design features that might lend themselves to things like this:

Fun with Insurgents

Armed Insurgents near armed building

Edited by Ripcord

[sIGPIC]sigpic65507_1.gif[/sIGPIC]

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...