From e7fb073bab0364793c2c9cbf4e1dd282263a2bed Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 22 Dec 2023 21:11:30 +0100 Subject: [PATCH 1/2] Update RAT.lua - Removed restriction that zones need to be defined in the ME --- Moose Development/Moose/Functional/RAT.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua index 57a0783da..ae6408d76 100644 --- a/Moose Development/Moose/Functional/RAT.lua +++ b/Moose Development/Moose/Functional/RAT.lua @@ -170,7 +170,7 @@ -- -- * A specific departure and/or destination airport can be chosen. -- * Valid coalitions can be set, e.g. only red, blue or neutral, all three "colours". --- * It is possible to start in air within a zone defined in the mission editor or within a zone above an airport of the map. +-- * It is possible to start in air within a zone or within a zone above an airport of the map. -- -- ## Flight Plan -- @@ -1179,13 +1179,13 @@ function RAT:SetTakeoffAir() return self end ---- Set possible departure ports. This can be an airport or a zone defined in the mission editor. +--- Set possible departure ports. This can be an airport or a zone. -- @param #RAT self -- @param #string departurenames Name or table of names of departure airports or zones. -- @return #RAT RAT self object. -- @usage RAT:SetDeparture("Sochi-Adler") will spawn RAT objects at Sochi-Adler airport. -- @usage RAT:SetDeparture({"Sochi-Adler", "Gudauta"}) will spawn RAT aircraft radomly at Sochi-Adler or Gudauta airport. --- @usage RAT:SetDeparture({"Zone A", "Gudauta"}) will spawn RAT aircraft in air randomly within Zone A, which has to be defined in the mission editor, or within a zone around Gudauta airport. Note that this also requires RAT:takeoff("air") to be set. +-- @usage RAT:SetDeparture({"Zone A", "Gudauta"}) will spawn RAT aircraft in air randomly within Zone A, or within a zone around Gudauta airport. Note that this also requires RAT:takeoff("air") to be set. function RAT:SetDeparture(departurenames) self:F2(departurenames) @@ -2537,7 +2537,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) end elseif self:_ZoneExists(_departure) then -- If it's not an airport, check whether it's a zone. - departure=ZONE:New(_departure) + departure=ZONE:FindByName(_departure) else local text=string.format("ERROR! Specified departure airport %s does not exist for %s.", _departure, self.alias) self:E(RAT.id..text) @@ -2635,7 +2635,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) end elseif self:_ZoneExists(_destination) then - destination=ZONE:New(_destination) + destination=ZONE:FindByName(_destination) else local text=string.format("ERROR: Specified destination airport/zone %s does not exist for %s!", _destination, self.alias) self:E(RAT.id.."ERROR: "..text) @@ -3142,7 +3142,7 @@ function RAT:_PickDeparture(takeoff) end elseif self:_ZoneExists(name) then if takeoff==RAT.wp.air then - dep=ZONE:New(name) + dep=ZONE:FindByName(name) else self:E(RAT.id..string.format("ERROR! Takeoff is not in air. Cannot use %s as departure.", name)) end @@ -3254,7 +3254,7 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing) end elseif self:_ZoneExists(name) then if landing==RAT.wp.air then - dest=ZONE:New(name) + dest=ZONE:FindByName(name) else self:E(RAT.id..string.format("ERROR! Landing is not in air. Cannot use zone %s as destination!", name)) end @@ -4930,12 +4930,12 @@ function RAT:_AirportExists(name) return false end ---- Test if a trigger zone defined in the mission editor exists. +--- Test if a zone exists. -- @param #RAT self -- @param #string name -- @return #boolean True if zone exsits, false otherwise. function RAT:_ZoneExists(name) - local z=trigger.misc.getZone(name) + local z=ZONE:FindByName(name) --trigger.misc.getZone(name) as suggested by @Viking on MOOSE discord #rat if z then return true end From 7cc040c23489047b68a376827c7b8ffd1b609d51 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sat, 23 Dec 2023 14:51:55 +0100 Subject: [PATCH 2/2] #RANGE * Fixed Range trying to find a pilot on each and every birth event... --- Moose Development/Moose/Functional/Range.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 8da132f14..5b4d52623 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -1737,7 +1737,9 @@ end -- @param Core.Event#EVENTDATA EventData function RANGE:OnEventBirth( EventData ) self:F( { eventbirth = EventData } ) - + + if not EventData.IniPlayerName then return end + local _unitName = EventData.IniUnitName local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )