Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

moving reference points to align with changing threat axis

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> moving reference points to align with changing threat axis Page: [1]
Login
Message << Older Topic   Newer Topic >>
moving reference points to align with changing threat axis - 5/13/2021 12:48:24 AM   
orca

 

Posts: 501
Joined: 11/6/2013
Status: offline
I want to move reference points for a CAP so that they are always located between the my carrier strike group (CSG) and the enemy CSG. Both CSGs are moving and therefore need to set/move the RPs every so often.

I plan to use 4 RPs which I will label CAP-1, CAP-2, CAP-3, and CAP-4.

I think there is a way to check the bearing between my group (or carrier) and them enemy and then set/move the CAP RPs based on this bearing +/- the appropriate degree and the range for the RP that I want, but I can't figure it out. I would run this every 15 min or so to keep the CAP is proper position relative to the enemy.

Thanks in advance for any help!
Post #: 1
RE: moving reference points to align with changing thre... - 5/14/2021 3:08:26 AM   
KnightHawk75

 

Posts: 1450
Joined: 11/15/2018
Status: offline
Assuming for the sake of argument using relative bearing to the carrier and adjusting the 'distance' property that's available when that's set doesn't work for what you're doing, yeah you can just brute force it.

Run something like this every 15 minutes.

-- This function assumes only 4pts in the feed rps param and disttbl tables.
-- copy and adjust as needed for different shapes and designs etc.
-- when providing thebear and therange override params slat,slon,tlat,tlon can all be nil.
-- otherwise they are required.
local function handle4pBoxPTzone(slat,slon,tlat,tlon,rps,disttbl,pct,thebear,therange)
    if thebear ==nil then thebear = Tool_Bearing({latitude=slat, longitude=slon},{latitude=tlat, longitude=tlon}); end
    if therange ==nil then therange = Tool_Range({latitude=slat, longitude=slon},{latitude=tlat, longitude=tlon}); end
    local centerpoint = World_GetPointFromBearing({latitude=slat,longitude=slon,BEARING=thebear,DISTANCE=(therange * pct)})
    local,retval1,retval2,adjbear,bFlag = false,nil,0,false;
    for k,v in pairs(rps) do
       if k == 1 then adjbear = (thebear + (k * 45)) %360; --original bearing 45d offset from that starting point
       else adjbear = (adjbear + 90)%360;  end  --90d offset from ^starting point or later.. lastpoint.
        local therp = World_GetPointFromBearing({latitude=centerpoint.latitude,longitude=centerpoint.longitude,BEARING=adjbear,DISTANCE=disttbl[k]});
         --a simple v.latitude,v.longitude=therp.latitude,therp.longitude here will not actually update it,must use setrefpt. 
        retval1,retval2 = pcall(ScenEdit_SetReferencePoint,{guid=v.guid,side=v.side,latitude=therp.latitude,longitude=therp.longitude});
        if retval1 ==false then print("Error updating ref point: " .. tostring(retval2)); bFlag = true; end
    end
    if bFlag then return false; else return true;end
end
local function UpdatePatrolMissionRPSourceToTarget(mname,mside,sname,sside,tname,tside,pct,nenm,senm,swnm,nwnm,pznm)
    if mname ==nil or mside == nil or tname ==nil or tside ==nil or sname==nil or sside==nil then 
        print("One or more of missionname,missionside,sourcename,sourceside,targetname,targetside params are missing."); return;
    end
    if pct == nil then pct = 0.50;end  if pznm == nil then pznm = 50.0;end
    if nenm == nil then nenm = 50.0;end  if senm == nil then senm = 50.0;end
    if swnm == nil then swnm = 50.0;end  if nwnm == nil then nwnm = 50.0;end
    local m = ScenEdit_GetMission(mside,mname);
    local s = ScenEdit_GetUnit({name=sname,side=sside});
    local t = ScenEdit_GetUnit({name=tname,side=tside});
    if m==nil or t==nil or s==nil then print("Could not get mission or source or target."); return end --sanity check.
    local tmparea = {};
    if (m.patrolmission.PatrolZone ~=nil) and #m.patrolmission.PatrolZone == 4 then
        for i =1,#m.patrolmission.PatrolZone do
          tmparea[i] = m.patrolmission.PatrolZone[i].name
        end
        local ppoints = ScenEdit_GetReferencePoints({side=m.side, area=tmparea});
        handle4pBoxPTzone(s.latitude,s.longitude,t.latitude,t.longitude,ppoints,{nenm,senm,swnm,nwnm},pct)
    end
    if (m.patrolmission.ProsecutionZone ~=nil) and #m.patrolmission.ProsecutionZone == 4 then
        tmparea = {};
        for i =1,#m.patrolmission.ProsecutionZone do
          tmparea[i] = m.patrolmission.ProsecutionZone[i].name
        end
        local ppoints = ScenEdit_GetReferencePoints({side=m.side, area=tmparea})
        handle4pBoxPTzone(s.latitude,s.longitude,t.latitude,t.longitude,ppoints,{nenm+pznm,senm+pznm,swnm+pznm,nwnm+pznm},pct)
    end
end
--call update to a square box centered 50% distance to target with 50nm extra add on for prosecution rp's if any.
UpdatePatrolMissionRPSourceToTarget("Testy","China","Shandong Carrier Strike Group","China","Abraham Lincoln Strike Group","United States",0.50,100,100,100,100,50);

--call update to a polygon centered 40% distance to target with 30nm extra add on for prosecution rp's if any.
UpdatePatrolMissionRPSourceToTarget("Testy","China","Shandong Carrier Strike Group","China","Abraham Lincoln Strike Group","United States",0.40,125,50,50,125,30);


Above test usage assumes an AAW patrol mission "Testy" exists for side "China", and has 4, and only 4 rp's in it's patrol zone and or prosecution zone, and of course the group\unit names used exist. Obviously if not using mission assigned rp's you can just adjust the code to handle your own area= arrayofnames and forgo all the lookup code, but I provide it cause it's a common case.

< Message edited by KnightHawk75 -- 5/14/2021 3:13:08 AM >

(in reply to orca)
Post #: 2
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> moving reference points to align with changing threat axis Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.656