mirror of
https://github.com/akaAgar/the-universal-mission-for-dcs-world.git
synced 2025-11-25 19:31:01 +00:00
Added Library.objectNames.getGeneric(obj, inaccurate)
This commit is contained in:
parent
136359703a
commit
d11e1dc3a2
@ -548,4 +548,115 @@ do
|
||||
if not typeName then return "unknown" end
|
||||
return typeName
|
||||
end
|
||||
|
||||
function Library.objectNames.getGeneric(obj, inaccurate)
|
||||
inaccurate = inaccurate or false
|
||||
if not obj then return "nothing" end
|
||||
|
||||
if Object.getCategory(obj) == Object.Category.SCENERY then
|
||||
return DCSEx.table.getRandom({"building", "structure"})
|
||||
elseif Object.getCategory(obj) == Object.Category.STATIC then
|
||||
return DCSEx.table.getRandom({"building", "structure"})
|
||||
elseif Object.getCategory(obj) == Object.Category.UNIT then
|
||||
local objDesc = obj:getDesc()
|
||||
|
||||
if objDesc.category == Unit.Category.AIRPLANE then
|
||||
if inaccurate then return "aircraft" end
|
||||
|
||||
if obj:hasAttribute("AWACS") then
|
||||
return "AWACS"
|
||||
elseif obj:hasAttribute("Tankers") then
|
||||
return "tanker"
|
||||
elseif obj:hasAttribute("Transports") then
|
||||
return "transport"
|
||||
elseif obj:hasAttribute("Bombers") then
|
||||
return "bomber"
|
||||
elseif obj:hasAttribute("Multirole fighters") or obj:hasAttribute("Fighters") then
|
||||
return "fighter"
|
||||
elseif obj:hasAttribute("Interceptors") then
|
||||
return "interceptor"
|
||||
elseif obj:hasAttribute("UAVs") then
|
||||
return "UAV"
|
||||
else
|
||||
return "aircraft"
|
||||
end
|
||||
elseif objDesc.category == Unit.Category.HELICOPTER then
|
||||
if inaccurate then return "helicopter" end
|
||||
|
||||
if obj:hasAttribute("Attack helicopters") then
|
||||
return "attack helicopter"
|
||||
elseif obj:hasAttribute("Transport helicopters") then
|
||||
return "transport helicopter"
|
||||
else
|
||||
return "helicopter"
|
||||
end
|
||||
elseif objDesc.category == Unit.Category.GROUND_UNIT then
|
||||
if inaccurate then
|
||||
if obj:hasAttribute("Infantry") then
|
||||
return "infantry"
|
||||
else
|
||||
return "vehicle"
|
||||
end
|
||||
end
|
||||
|
||||
if obj:hasAttribute("MANPADS") then
|
||||
return "MANPADS"
|
||||
elseif obj:hasAttribute("Infantry") then
|
||||
return "infantry"
|
||||
elseif obj:hasAttribute("SR SAM") then
|
||||
return "short-range SAM"
|
||||
elseif obj:hasAttribute("SAM SR") then
|
||||
return "SAM search radar"
|
||||
elseif obj:hasAttribute("SAM TR") then
|
||||
return "SAM tracking radar"
|
||||
elseif obj:hasAttribute("SAM LL") then
|
||||
return "SAM launcher"
|
||||
elseif obj:hasAttribute("AAA") then
|
||||
return "AAA"
|
||||
elseif obj:hasAttribute("Air Defence") then
|
||||
return "air defense"
|
||||
elseif obj:hasAttribute("Artillery") then
|
||||
return "artillery"
|
||||
elseif obj:hasAttribute("Armored vehicles") then
|
||||
return "armor"
|
||||
elseif obj:hasAttribute("Trucks") then
|
||||
return "truck"
|
||||
else
|
||||
return "vehicle"
|
||||
end
|
||||
elseif objDesc.category == Unit.Category.SHIP then
|
||||
if inaccurate then return "ship" end
|
||||
if obj:getTypeName() == "speedboat" then return "speedboat" end
|
||||
|
||||
if obj:hasAttribute("Submarines") then
|
||||
return "submarine"
|
||||
elseif obj:hasAttribute("Aircraft Carriers") then
|
||||
return "carrier"
|
||||
elseif obj:hasAttribute("Heavy armed ships") then
|
||||
return "warship"
|
||||
elseif obj:hasAttribute("Light armed ships") then
|
||||
return "armed ship"
|
||||
elseif obj:hasAttribute("Unarmed ships") then
|
||||
return "cargo ship"
|
||||
else
|
||||
return "ship"
|
||||
end
|
||||
elseif objDesc.category == Unit.Category.STRUCTURE then
|
||||
return DCSEx.table.getRandom({"building", "structure"})
|
||||
end
|
||||
end
|
||||
|
||||
return "unknown"
|
||||
end
|
||||
|
||||
function Library.objectNames.getGenericGroup(grp, inaccurate)
|
||||
if not grp then return "nothing" end
|
||||
|
||||
-- TODO: should not just take the first unit but pick the most relevant one (e.g. one SAM and 3 supply trucks should be reported as "SAM" not as "truck")
|
||||
for _,u in ipairs(grp:getUnits()) do
|
||||
return Library.objectNames.getGeneric(u, inaccurate)
|
||||
end
|
||||
|
||||
return "unknown"
|
||||
end
|
||||
end
|
||||
@ -156,86 +156,23 @@ do
|
||||
killMessage = "pilotKillStrike"
|
||||
doAmbientChatter("pilotKillStrike", nil, killerName, 1)
|
||||
elseif Object.getCategory(event.target) == Object.Category.UNIT then
|
||||
local killUnitType = "unit"
|
||||
local killUnitType = Library.objectNames.getGeneric(event.target)
|
||||
|
||||
if targetDesc.category == Unit.Category.AIRPLANE then
|
||||
killMessage = "pilotKillAir"
|
||||
|
||||
if event.target:hasAttribute("AWACS") then
|
||||
killUnitType = "AWACS"
|
||||
elseif event.target:hasAttribute("Tankers") then
|
||||
killUnitType = "tanker"
|
||||
elseif event.target:hasAttribute("Transports") then
|
||||
killUnitType = "transport"
|
||||
elseif event.target:hasAttribute("Bombers") then
|
||||
killUnitType = "bomber"
|
||||
elseif event.target:hasAttribute("Multirole fighters") or event.target:hasAttribute("Fighters") then
|
||||
killUnitType = "fighter"
|
||||
elseif event.target:hasAttribute("Interceptors") then
|
||||
killUnitType = "interceptor"
|
||||
elseif event.target:hasAttribute("UAVs") then
|
||||
killUnitType = "UAV"
|
||||
else
|
||||
killUnitType = "aircraft"
|
||||
end
|
||||
killUnitType = Library.objectNames.get(event.target) -- Report exact unit type for aircraft
|
||||
elseif targetDesc.category == Unit.Category.HELICOPTER then
|
||||
killMessage = "pilotKillAir"
|
||||
if event.target:hasAttribute("Attack helicopters") then
|
||||
killUnitType = "attack "
|
||||
elseif event.target:hasAttribute("Transport helicopters") then
|
||||
killUnitType = "transport "
|
||||
else
|
||||
killUnitType = ""
|
||||
end
|
||||
killUnitType = killUnitType.." "..DCSEx.table.getRandom({"helicopter", "helo", "chopper"})
|
||||
killUnitType = Library.objectNames.get(event.target) -- Report exact unit type for aircraft
|
||||
elseif targetDesc.category == Unit.Category.GROUND_UNIT then
|
||||
if event.target:hasAttribute("Infantry") then return end -- No kill message for infantry (yet?)
|
||||
killMessage = "pilotKillGround"
|
||||
|
||||
if event.target:hasAttribute("MANPADS") then
|
||||
killUnitType = "MANPADS"
|
||||
elseif event.target:hasAttribute("Infantry") then
|
||||
killUnitType = "infantry"
|
||||
elseif event.target:hasAttribute("SR SAM") then
|
||||
killUnitType = "short-range SAM"
|
||||
elseif event.target:hasAttribute("SAM SR") then
|
||||
killUnitType = "SAM search radar"
|
||||
elseif event.target:hasAttribute("SAM TR") then
|
||||
killUnitType = "SAM tracking radar"
|
||||
elseif event.target:hasAttribute("SAM LL") then
|
||||
killUnitType = "SAM launcher"
|
||||
elseif event.target:hasAttribute("AAA") then
|
||||
killUnitType = "AAA"
|
||||
elseif event.target:hasAttribute("Air Defence") then
|
||||
killUnitType = "air defense"
|
||||
elseif event.target:hasAttribute("Artillery") then
|
||||
killUnitType = "artillery"
|
||||
elseif event.target:hasAttribute("Armored vehicles") then
|
||||
killUnitType = "armor"
|
||||
elseif event.target:hasAttribute("Trucks") then
|
||||
killUnitType = "truck"
|
||||
else
|
||||
killUnitType = "vehicle"
|
||||
end
|
||||
elseif targetDesc.category == Unit.Category.SHIP then
|
||||
killMessage = "pilotKillShip"
|
||||
|
||||
if event.target:hasAttribute("Aircraft Carriers") then
|
||||
killUnitType = "carrier"
|
||||
elseif event.target:hasAttribute("Heavy armed ships") then
|
||||
killUnitType = "warship"
|
||||
elseif event.target:hasAttribute("Light armed ships") then
|
||||
killUnitType = "armed ship"
|
||||
elseif event.target:hasAttribute("Unarmed ships") then
|
||||
killUnitType = "cargo ship"
|
||||
else
|
||||
killUnitType = "ship"
|
||||
end
|
||||
elseif targetDesc.category == Unit.Category.STRUCTURE then
|
||||
killMessage = "pilotKillStrike"
|
||||
end
|
||||
|
||||
killUnitType = Library.objectNames.get(event.target)
|
||||
doAmbientChatter(killMessage, killUnitType, killerName, 1)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user