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 >
|