Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Lua Condition- If Destroyed In A Area

 
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 >> Lua Condition- If Destroyed In A Area Page: [1]
Login
Message << Older Topic   Newer Topic >>
Lua Condition- If Destroyed In A Area - 5/22/2021 3:26:49 PM   
butch4343

 

Posts: 327
Joined: 3/26/2015
Status: offline
Hi folks

I was wondering if its possible to set a condition of where a unit is destroyed, I have some Backfires that are participating in a carrier strike, I want the player to score if they are destroyed on their airfield rather than in the air.

I have had a look and wondered if theres a way to set a condition whereby the scoring is only allowed if the unit is within XYZ?

I have looked at the LUA script

local u = side:unitsInArea({Area = { 'RP-5094', 'RP-5095', 'RP-5096', 'RP-5097'}, TargetFilter = { TargetType = 'Aircraft'} })

But I dont think that would work TBH because its to do with side contacts, I think what I need is something that references where the unit is if that makes sense?


Or alternatively another easier way to score it, I did consider just having the player score for damaging the Large Parking Spot that only bombers can be parked on but then they would score damaging empty parking stands.

Anyone any thoughts?

Regards

Butch




Post #: 1
RE: Lua Condition- If Destroyed In A Area - 5/22/2021 3:47:27 PM   
BDukes

 

Posts: 1695
Joined: 12/27/2017
Status: offline
Hmm. Maybe a conditional based on the aircraft's altitude?

Mike

(in reply to butch4343)
Post #: 2
RE: Lua Condition- If Destroyed In A Area - 5/22/2021 9:45:21 PM   
KnightHawk75

 

Posts: 1450
Joined: 11/15/2018
Status: offline
Butch sadly when destroyed a unit no longer has a location, this is flaw in my opinion but it is what it is atm, well technically it has a location - 0 lat and 0 lon, indicating it's dead, so while I have some inside-polygon checking code you could use it will not work here, nor may :inArea after unit has been destroyed. It does however maintain it's past 'base' and 'group' during the event execution though, so if it's a member of a air-base group or otherwise hosted by a facility you could check if it's the base\group\unit in question you want to compare against.
In the following example the airbase is a typical grouped airbase called "Some Airbase" and the unit was in a facility with-in that group.

So you can set an event based on a Unit Destroyed trigger for Blackfire's side (we'll call it Red), aircraft, bomber,tu-22m etc and tie an action (or condition) to something like following

--change function names or all to locals to suit your desires, globals presented here.
--global funcs on scene load.
gKH={};gKH.Unit={};gKH.SceneGlobals={};
function gKH.Unit:isAircraftAirborne(u)
    if ((u.condition_v == "Airborne") or u.condition_v == "RTB") or u.condition_V == "Landing_PreTouchdown" or
     u.condition_v == "ManoeuveringToRefuel" or u.condition_v == "Refuelling" or u.condition_v == "OffloadingFuel" or 
     u.condition_v == "DeployingDippingSonar" or u.condition_v == "EmergencyLanding" or  u.condition_v == "BVRAttack" or 
     u.condition_v == "BVRCrank" or u.condition_v == "Dogfight" or u.condition_v == "BVRDrag" or u.condition_v == "TransferringCargo" then
      return true;
    end
    return false;
end

function gKH.SceneGlobals.QualifiyBackfireDestruction(u,airbasename)
  if ((u ~= nil) and u.base ~=nil) and gKH.Unit:isAircraftAirborne(u) == false and 
    u.base.group.type=="AirBase" and u.base.group.name == airbasename  then return true;
  else return false;
  end
end
-- end global startup functions
--Placed in some action script for the event or convert for use in a 'condition'.
local u = ScenEdit_UnitX();
if gKH.SceneGlobals.QualifiyBackfireDestruction(u,"Some Airbase") == true then
    ScenEdit_SetScore("Blue",ScenEdit_GetScore("Blue") + 50,'Backfire unit ' .. tostring(u.name) .. ' destroyed at qualified airbase.');
end


< Message edited by KnightHawk75 -- 5/22/2021 9:51:52 PM >

(in reply to BDukes)
Post #: 3
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Lua Condition- If Destroyed In A Area 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

1.594