Fixed zone find

This commit is contained in:
Frank
2019-05-23 21:07:47 +02:00
parent 1e1335e2ed
commit 614a1cc906
4 changed files with 69 additions and 34 deletions
+20 -2
View File
@@ -595,18 +595,36 @@ do -- Event Handling
-- @param Core.Event#EVENTDATA EventData The EventData structure.
--- Occurs when any unit begins firing a weapon that has a high rate of fire. Most common with aircraft cannons (GAU-8), autocannons, and machine guns.
-- initiator : The unit that is doing the shooing.
-- initiator : The unit that is doing the shooting.
-- target: The unit that is being targeted.
-- @function [parent=#BASE] OnEventShootingStart
-- @param #BASE self
-- @param Core.Event#EVENTDATA EventData The EventData structure.
--- Occurs when any unit stops firing its weapon. Event will always correspond with a shooting start event.
-- initiator : The unit that was doing the shooing.
-- initiator : The unit that was doing the shooting.
-- @function [parent=#BASE] OnEventShootingEnd
-- @param #BASE self
-- @param Core.Event#EVENTDATA EventData The EventData structure.
--- Occurs when a new mark was added.
-- MarkID: ID of the mark.
-- @function [parent=#BASE] OnEventMarkAdded
-- @param #BASE self
-- @param Core.Event#EVENTDATA EventData The EventData structure.
--- Occurs when a mark was removed.
-- MarkID: ID of the mark.
-- @function [parent=#BASE] OnEventMarkRemoved
-- @param #BASE self
-- @param Core.Event#EVENTDATA EventData The EventData structure.
--- Occurs when a mark text was changed.
-- MarkID: ID of the mark.
-- @function [parent=#BASE] OnEventMarkChange
-- @param #BASE self
-- @param Core.Event#EVENTDATA EventData The EventData structure.
end
+1 -12
View File
@@ -304,16 +304,6 @@ do -- Zones
self.ZONES[ZoneName] = nil
end
--- Finds an @{Zone} based on the zone name in the DATABASE.
-- @param #DATABASE self
-- @param #string ZoneName
-- @return Core.Zone#ZONE_BASE The found @{Zone}.
function DATABASE:FindZone( ZoneName )
local ZoneFound = self.ZONES[ZoneName]
return ZoneFound
end
--- Private method that registers new ZONE_BASE derived objects within the DATABASE Object.
@@ -348,7 +338,6 @@ do -- Zones
end -- zone
do -- cargo
--- Adds a Cargo based on the Cargo Name in the DATABASE.
@@ -1166,7 +1155,7 @@ function DATABASE:OnEventNewZone( EventData )
self:F2( { EventData } )
if EventData.Zone then
self:AddZone( EventData.Zone )
self:AddZone( EventData.Zone.ZoneName, EventData.Zone )
end
end
+11 -7
View File
@@ -272,10 +272,16 @@ EVENTS = {
-- @field Wrapper.Airbase#AIRBASE Place The MOOSE airbase object.
-- @field #string PlaceName The name of the airbase.
--
-- @field weapon The weapon used during the event.
-- @field Weapon
-- @field WeaponName
-- @field WeaponTgtDCSUnit
-- @field #table weapon The weapon used during the event.
-- @field #table Weapon
-- @field #string WeaponName Name of the weapon.
-- @field DCS#Unit WeaponTgtDCSUnit Target DCS unit of the weapon.
--
-- @field Cargo.Cargo#CARGO Cargo The cargo object.
-- @field #string CargoName The name of the cargo object.
--
-- @field Core.ZONE#ZONE Zone The zone object.
-- @field #string ZoneName The name of the zone.
@@ -959,8 +965,7 @@ function EVENT:onEvent( Event )
Event.PlaceName=Event.Place:GetName()
end
-- @FC: something like this should be added.
--[[
-- Mark points.
if Event.idx then
Event.MarkID=Event.idx
Event.MarkVec3=Event.pos
@@ -969,7 +974,6 @@ function EVENT:onEvent( Event )
Event.MarkCoalition=Event.coalition
Event.MarkGroupID = Event.groupID
end
]]
if Event.cargo then
Event.Cargo = Event.cargo
+37 -13
View File
@@ -692,7 +692,7 @@ function FOX:onafterMissileLaunch(From, Event, To, missile)
end -- end function trackBomb
-- Weapon is not yet "alife" just yet. Start timer with a little delay.
self:T(FOX.lid..string.format("Tracking of missile starts in 0.1 seconds."))
self:T(FOX.lid..string.format("Tracking of missile starts in 0.0001 seconds."))
timer.scheduleFunction(trackMissile, missile.weapon, timer.getTime()+0.0001)
end
@@ -766,9 +766,6 @@ function FOX:OnEventBirth(EventData)
-- Init player data.
self.players[playername]=playerData
-- Init player grades table if necessary.
--self.playerscores[playername]=self.playerscores[playername] or {}
end
end
@@ -860,6 +857,7 @@ function FOX:OnEventShot(EventData)
-- Add missile table.
table.insert(self.missiles, missile)
-- Trigger MissileLaunch event.
self:__MissileLaunch(0.1, missile)
end
@@ -925,7 +923,7 @@ function FOX:_AddF10Commands(_unitName)
--------------------------------
-- F10/F<X> FOX/F1 Help
--------------------------------
local _helpPath=missionCommands.addSubMenuForGroup(gid, "Help", _rootPath)
--local _helpPath=missionCommands.addSubMenuForGroup(gid, "Help", _rootPath)
-- F10/FOX/F1 Help/
--missionCommands.addCommandForGroup(gid, "Subtitles On/Off", _helpPath, self._SubtitlesOnOff, self, _unitName) -- F7
--missionCommands.addCommandForGroup(gid, "Trapsheet On/Off", _helpPath, self._TrapsheetOnOff, self, _unitName) -- F8
@@ -934,9 +932,9 @@ function FOX:_AddF10Commands(_unitName)
-- F10/F<X> FOX/
-------------------------
missionCommands.addCommandForGroup(gid, "Launch Alerts On/Off", _rootPath, self._ToggleLaunchAlert, self, _unitName) -- F2
missionCommands.addCommandForGroup(gid, "Destroy Missiles On/Off", _rootPath, self._ToggleDestroyMissiles, self, _unitName) -- F3
missionCommands.addCommandForGroup(gid, "Launch Alerts On/Off", _rootPath, self._ToggleLaunchAlert, self, _unitName) -- F1
missionCommands.addCommandForGroup(gid, "Destroy Missiles On/Off", _rootPath, self._ToggleDestroyMissiles, self, _unitName) -- F2
missionCommands.addCommandForGroup(gid, "My Status", _rootPath, self._MyStatus, self, _unitName) -- F3
end
else
self:E(self.lid..string.format("ERROR: Could not find group or group ID in AddF10Menu() function. Unit name: %s.", _unitName))
@@ -965,17 +963,43 @@ function FOX:_MyStatus(_unitname)
if playerData then
local m,mtext=self:_GetTargetMissiles(playerData.name)
local text=string.format("Status of player %s:", playerData.name)
local safe=self:_CheckCoordSafe(playerData.unit:GetCoordinate())
text=text..string.format("Destroy missiles: %s", playerData.destroy)
text=text..string.format("Launch alert: %s", playerData.launchalert)
text=text..string.format("Me target: %d", self:_GetTargetMissiles(playerData.unit))
text=text..string.format("Am I safe? %s", self:_CheckCoordSafe(playerData.unit:GetCoordinate()))
text=text..string.format("Destroy missiles: %s", tostring(playerData.destroy))
text=text..string.format("Launch alert: %s", tostring(playerData.launchalert))
text=text..string.format("Am I safe? %s", tostring(safe))
text=text..string.format("Me target: %d\n%s", m, mtext)
MESSAGE:New(text, 10, "FOX", true):ToClient(playerData.client)
end
end
end
--- Turn player's launch alert on/off.
-- @param #FOX self
-- @param #string playername Name of the player.
-- @return #number Number of missiles targeting the player.
-- @return #string Missile info.
function FOX:_GetTargetMissiles(playername)
local text=""
local n=0
for _,_missile in pairs(self.missiles) do
local missile=_missile --#FOX.MissileData
if missile.targetPlayer.name==playername then
n=n+1
text=text..string.format("Type %s: active %s\n", missile.missileType, tostring(missile.active))
end
end
return n,text
end
--- Turn player's launch alert on/off.
-- @param #FOX self
@@ -1010,7 +1034,7 @@ function FOX:_ToggleLaunchAlert(_unitname)
end
end
--- Turn player's
--- Turn destruction of missiles on/off for player.
-- @param #FOX self
-- @param #string _unitname Name of the player unit.
function FOX:_ToggleDestroyMissiles(_unitname)