Lua: Added weapon causing damage to Event_Damaged/Destroyed
Posted: Sun Aug 05, 2018 7:46 pm
In the latest .10 release notes there is:
Lua: Added weapon causing damage to Event_Damaged/Destroyed
I take this to mean that I could get the weapon that caused a unit to be destroyed with an event that has a trigger of unit destroyed and then I should be able to find it in the Event wrapper, but I am not having any luck.
Here is what I have so far, which gets me some info but I don't see anything about a weapon.
This really is no big deal, but if it is possible it would be cool, I log units lost/damaged to the luahistory log, and sometimes I would like to know what weapon caused the damage.
I think what I get is:
So maybe the weapon is really in UnitX() not the event so I am printing the UnitX() wrapper also, and there is a weapon object in there but I have only seen it as nil so far:
Lua: Added weapon causing damage to Event_Damaged/Destroyed
I take this to mean that I could get the weapon that caused a unit to be destroyed with an event that has a trigger of unit destroyed and then I should be able to find it in the Event wrapper, but I am not having any luck.
Here is what I have so far, which gets me some info but I don't see anything about a weapon.
This really is no big deal, but if it is possible it would be cool, I log units lost/damaged to the luahistory log, and sometimes I would like to know what weapon caused the damage.
local a = ScenEdit_EventX() -- current active event
print(a.fields)
for k,v in pairs(a.fields) do
if string.find(k,'property_') ~= nil then
local t = string.find(v," , ") -- location of first ,
print("\r\n[object] = " .. string.sub(v,2,t-1) ) -- property name
print( a[string.sub(v,2,t-1)] ) -- value of property
end
end
I think what I get is:
[object] = name
nil
[object] = triggers
{ [1] = { UnitDamaged = { TargetFilter = { TargetSide = 'd9db85a7-6503-4ddc-b7be-1bed566af144', TargetType = '0', ID = '288370c9-3697-4166-bc29-35e97b804939', TargetSubType = '0' }, Description = 'Unit Damaged Lua Logger Blue', ID = 'b263ff72-0e5b-4f55-b2da-1e6c2a249f94', DamagePercent = '1' } }, [2] = { UnitDamaged = { TargetFilter = { TargetSide = 'd3c2bd6b-2f33-469c-9745-8c64005e03a8', TargetType = '0', ID = '64ba2083-9038-4660-aa46-21289f25c763', TargetSubType = '0' }, Description = 'Unit Damaged Lua Logger Red', ID = '32bb4081-6be5-475e-9bb9-ba377911d7d7', DamagePercent = '1' } } }
[object] = conditions
{ }
[object] = isShown
False
[object] = probability
100
[object] = isActive
'Yes'
[object] = guid
d49adac5-0154-4ca0-af82-ce756893bef6
[object] = details
{ probability = 100, triggers = { [1] = { UnitDamaged = { TargetFilter = { TargetSide = 'd9db85a7-6503-4ddc-b7be-1bed566af144', TargetType = '0', ID = '288370c9-3697-4166-bc29-35e97b804939', TargetSubType = '0' }, Description = 'Unit Damaged Lua Logger Blue', ID = 'b263ff72-0e5b-4f55-b2da-1e6c2a249f94', DamagePercent = '1' } }, [2] = { UnitDamaged = { TargetFilter = { TargetSide = 'd3c2bd6b-2f33-469c-9745-8c64005e03a8', TargetType = '0', ID = '64ba2083-9038-4660-aa46-21289f25c763', TargetSubType = '0' }, Description = 'Unit Damaged Lua Logger Red', ID = '32bb4081-6be5-475e-9bb9-ba377911d7d7', DamagePercent = '1' } } }, isActive = 'Yes', actions = { [1] = { type = 'LuaScript', LuaScript = { Description = 'Unit Damaged Lua Logger', ID = '0e6bad4b-2e0e-4352-a9aa-c17d40f4d846', ScriptText = 'local a = ScenEdit_EventX()
So maybe the weapon is really in UnitX() not the event so I am printing the UnitX() wrapper also, and there is a weapon object in there but I have only seen it as nil so far:
[**Unit Destroyed**] [Red] Spirit 7, Type: Tu-160 Blackjack on Sunday July 22 2239Z [**Unit Destroyed**]
----- wrapper start destroyed ----
{ property_48 = '.targetedBy , Object , False', property_24 = '.mission , Object , True', property_22 = '.dbid , Int32 , False', property_5 = '.latitude , Double , True', property_41 = '.unitstate , String , False', property_44 = '.weapon , Object , False', property_33 = '.weather , LuaTable , False', property_14 = '.fuel , LuaTable , True', property_15 = '.group , Object , True', property_35 = '.magazines , LuaTable , True', property_42 = '.fuelstate , String , False', property_46 = '.areaTriggersFired , LuaTable , False', property_10 = '.manualAltitude , Object , True', method_1 = ':delete , System.Void', property_47 = '.hostedUnits , LuaTable , False', property_36 = '.mounts , LuaTable , True', method_3 = ':rangetotarget , System.Single', property_18 = '.OODA , LuaTable , True', property_27 = '.airbornetime , Object , False', property_25 = '.holdposition , Boolean , True', method_2 = ':filterOnComponent , NLua.LuaTable', property_17 = '.heading , Object , True', property_51 = '.isOperating , Boolean , False', property_50 = '.firedOn , Object , False', property_4 = '.classname , String , False', property_9 = '.speed , Object , True', property_49 = '.firingAt , Object , False', property_23 = '.guid , String , False', property_6 = '.longitude , Double , True', property_8 = '.altitude , Object , True', method_4 = ':inArea , System.Boolean', property_45 = '.hostFacility , LuaWrapper_Facility , False', property_31 = '.ascontact , LuaTable , False', property_2 = '.type , String , False', property_26 = '.holdfire , Object , True', property_40 = '.condition_v , String , False', property_43 = '.weaponstate , String , False', property_39 = '.condition , String , False', property_38 = '.components , LuaTable , True', property_11 = '.manualSpeed , Object , True', property_37 = '.sensors , LuaTable , True', property_20 = '.sprintDrift , Boolean , True', property_34 = '.proficiency , String , True', property_12 = '.throttle , Object , True', property_7 = '.autodetectable , Boolean , True', property_19 = '.base , LuaWrapper_ActiveUnit , True', property_32 = '.desiredheading , Object , True', property_13 = '.course , LuaTable , True', property_1 = '.name , String , True', property_3 = '.side , String , False', property_28 = '.readytime , Object , False', property_16 = '.formation , LuaTable , True', property_29 = '.loadoutdbid , Object , False', property_30 = '.damage , LuaTable , False', property_21 = '.subtype , String , False' }
[object] = targetedBy
{ 5 = 'd293f139-cf78-4f22-8f59-422233924a89', 6 = '857d3661-4474-4883-8f64-d63db8bb833d', 7 = '9c08bc35-2bde-4975-9510-35e23591a956', 8 = '4fd97129-7710-49de-a278-94d9cf83873a', 1 = '67288000-e450-4a7e-8488-068c44c9a5e5', 2 = '0e2cc280-1bc6-4f86-8044-90102c215a90', 3 = '3f0b894e-67ab-4ed1-9809-caba3ab5c579', 4 = '19567afe-eed6-4c81-ac35-1542e73f0d84', 0 = 'cd7a9158-f5de-43a0-b236-1848cb18cee6', 9 = '9f83e628-0c2a-482a-aa48-b482509601de', 11 = '1cdd0a03-d9c6-4f42-910f-0b39307a13cc', 12 = '0e1a856b-d174-41e5-a7cc-355268527d5d', 10 = '9577d4f6-ea28-489c-a674-53521eb9e92f' }
[object] = mission
mission {
guid = 'f3889b81-43a0-4648-8a47-ebea981bab5b',
name = 'Bombers2',
side = 'Red',
type = 'Strike',
subtype = 'Land Strike',
isactive = 'True',
starttime = '7/22/2018 9:12:00 PM',
endtime = '',
SISH = 'False',
aar = 'table',
unitlist = 'table',
}
[object] = dbid
357
[object] = latitude
20.2965572832031
[object] = unitstate
EngagedDefensive
[object] = weapon
nil
[object] = weather
{ rainfall = 0, undercloud = 0, temp = 41, seastate = 2 }
[object] = fuel
{ [2001] = { max = 160000, name = 'AviationFuel', current = 128159.8203125 } }
[object] = group
group {
guid = '6e5d0e3c-0f23-4144-9bc4-8ae85faa8832',
name = 'Flight Farmer61',
side = 'Red',
type = 'AirGroup',
unitlist = 'table',
}
[object] = magazines
{ }
[object] = fuelstate
None
[object] = areaTriggersFired
{ }
[object] = manualAltitude
'No'
[object] = hostedUnits
{ }
[object] = mounts
{ [1] = { mount_name = 'APP-50 x 24 [288 Cartridges]', mount_dbid = 1805, mount_weapons = { [1] = { wpn_default = 24, wpn_maxcap = 24, wpn_name = 'Generic Chaff Salvo [8x Cartridges]', wpn_guid = 'fc8d098c-a3a6-4089-aadd-50f7709e4887', wpn_type = 2005, wpn_dbid = 565, wpn_current = 22 }, [2] = { wpn_default = 24, wpn_maxcap = 24, wpn_name = 'Generic Flare Salvo [4x Cartridges, Single Spectral]', wpn_guid = 'cda89c6f-2fb1-41da-8e9d-9c081206a03b', wpn_type = 2005, wpn_dbid = 555, wpn_current = 24 } }, mount_guid = 'fea06ef1-4235-458f-9801-d1c4ac5e708d', mount_status = 'Operational' } }
[object] = OODA
{ detection = 15, evasion = 2, targeting = 15 }
[object] = airbornetime
1 hr 16 min
[object] = holdposition
'No'
[object] = heading
305.641448974609
[object] = isOperating
'Yes'
[object] = firedOn
nil
[object] = classname
Tu-160 Blackjack
[object] = speed
587.806335449219
[object] = firingAt
nil
[object] = guid
4f61c70a-4e5c-40b9-8a88-ec2287218922
[object] = longitude
-74.6944756399783
[object] = altitude
592.440002441406
[object] = hostFacility
nil
[object] = ascontact
{ [1] = { side = 'd9db85a7-6503-4ddc-b7be-1bed566af144', name = 'Tu-160 Blackjack #156', guid = '56156f68-c0be-4fad-afb9-4df6b87772d4' } }
[object] = type
Aircraft
[object] = holdfire
{ Land = 'Inherit', Air = 'Inherit', Surface = 'Inherit', SubSurface = 'Inherit' }
[object] = condition_v
Airborne
[object] = weaponstate
None
[object] = condition
Airborne
[object] = components
{ [1] = { comp_guid = '8e7bb427-093c-465e-bda6-c62edcb511bf', comp_dbid = 450, comp_name = 'Clam Pipe [Obzor-K]', comp_type = 'Sensor', comp_status = 'Operational' }, [2] = { comp_guid = '9f058f4c-0275-4b7a-b85b-0249d47d9147', comp_dbid = 3318, comp_name = 'Bomb Sight [OPB-15T Groza]', comp_type = 'Sensor', comp_status = 'Operational' }, [3] = { comp_guid = '439c9bdb-e977-4c15-a804-c54dfa7ef37d', comp_dbid = 4444, comp_name = 'MAWS [Baykal]', comp_type = 'Sensor', comp_status = 'Operational' }, [4] = { comp_guid = '31fbc0f1-a611-4cd8-a8d7-26be63fe0b5e', comp_dbid = 4445, comp_name = 'RWR [Baykal]', comp_type = 'Sensor', comp_status = 'Operational' }, [5] = { comp_guid = '7fff7ea6-28e7-48cb-be03-6b0bd908c5ef', comp_dbid = 4443, comp_name = 'DECM [Baykal]', comp_type = 'Sensor', comp_status = 'Operational' }, [6] = { comp_guid = 'a28db1fa-399f-4d7d-bbf8-f640c4222658', comp_dbid = 0, comp_name = 'Mk1 Eyeball', comp_type = 'Sensor', comp_status = 'Operational' }, [7] = { comp_guid = 'fea06ef1-4235-458f-9801-d1c4ac5e708d', comp_dbid = 1805, comp_name = 'APP-50 x 24 [288 Cartridges]', comp_type = 'Mount', comp_status = 'Operational' }, [8] = { comp_guid = '4a5a59cd-2df9-439b-8a6b-e395f4cfe2c8', comp_dbid = 20, comp_name = 'UHF/VHF Radio [Unsecure]', comp_type = 'CommDevice', comp_status = 'Operational' }, [9] = { comp_guid = '2254930e-e7e7-420a-a5e8-495e8c6cbdea', comp_dbid = 238, comp_name = 'HF Radio [Unsecure]', comp_type = 'CommDevice', comp_status = 'Operational' }, [10] = { comp_guid = '72bdef27-92dc-4a81-8e12-6d73c046e28f', comp_dbid = 742, comp_name = 'NK-32 #1', comp_type = 'Engine', comp_status = 'Operational' }, [11] = { comp_guid = 'a244c561-b706-41d5-bbec-8e063fc1e608', comp_dbid = 742, comp_name = 'NK-32 #2', comp_type = 'Engine', comp_status = 'Operational' }, [12] = { comp_guid = '9d2392f2-967c-4b0b-99eb-4c6dd2c050f3', comp_dbid = 742, comp_name = 'NK-32 #3', comp_type = 'Engine', comp_status = 'Operational' }, [13] = { comp_guid = '49c74bba-accb-4684-8a5e-bda9bc4f751b', comp_dbid = 742, comp_name = 'NK-32 #4', comp_type = 'Engine', comp_status = 'Operational' } }
[object] = manualSpeed
nil
[object] = sensors
{ [1] = { sensor_name = 'Clam Pipe [Obzor-K]', sensor_maxrange = 180, sensor_status = 'Operational', sensor_type = 2001, sensor_isactive = 'No', sensor_role = 2124, sensor_guid = '8e7bb427-093c-465e-bda6-c62edcb511bf', sensor_dbid = 450 }, [2] = { sensor_name = 'Bomb Sight [OPB-15T Groza]', sensor_maxrange = 2, sensor_status = 'Operational', sensor_type = 2003, sensor_isactive = 'No', sensor_role = 2512, sensor_guid = '9f058f4c-0275-4b7a-b85b-0249d47d9147', sensor_dbid = 3318 }, [3] = { sensor_name = 'MAWS [Baykal]', sensor_maxrange = 5, sensor_status = 'Operational', sensor_type = 2004, sensor_isactive = 'No', sensor_role = 2891, sensor_guid = '439c9bdb-e977-4c15-a804-c54dfa7ef37d', sensor_dbid = 4444 }, [4] = { sensor_name = 'RWR [Baykal]', sensor_maxrange = 120, sensor_status = 'Operational', sensor_type = 3001, sensor_isactive = 'No', sensor_role = 3001, sensor_guid = '31fbc0f1-a611-4cd8-a8d7-26be63fe0b5e', sensor_dbid = 4445 }, [5] = { sensor_name = 'DECM [Baykal]', sensor_maxrange = 0, sensor_status = 'Operational', sensor_type = 3002, sensor_isactive = 'No', sensor_role = 4011, sensor_guid = '7fff7ea6-28e7-48cb-be03-6b0bd908c5ef', sensor_dbid = 4443 }, [6] = { sensor_name = 'Mk1 Eyeball', sensor_maxrange = 50, sensor_status = 'Operational', sensor_type = 2003, sensor_isactive = 'No', sensor_role = 2016, sensor_guid = 'a28db1fa-399f-4d7d-bbf8-f640c4222658', sensor_dbid = 0 } }
[object] = sprintDrift
'No'
[object] = proficiency
Veteran
[object] = throttle
Flank
[object] = autodetectable
'No'
[object] = base
unit {
type = 'Group',
subtype = 'None',
name = 'Red Airbase 4',
side = 'Red',
guid = 'edb7c642-0f9d-4bf0-a97f-36f49682be2f',
class = '',
proficiency = 'Veteran',
latitude = '11.7055253589347',
longitude = '-70.052033340425',
altitude = '35',
heading = '0',
speed = '0',
throttle = 'FullStop',
autodetectable = 'False',
group = 'Red Airbase 4',
mounts = '0',
magazines = '3',
unitstate = 'Unassigned',
fuelstate = 'None',
weaponstate = 'None',
}
[object] = desiredheading
280
[object] = course
{ [1] = { DesiredAltitudeTF = '60.96', DesiredSpeed = '580', TF = 'True', longitude = -74.7556237595772, Description = '5', latitude = 20.1896980803724, TypeOf = 'InitialPoint', PresetThrottle = 'Full' }, [2] = { DesiredAltitudeTF = '60.96', DesiredSpeed = '580', TF = 'True', longitude = -74.839581291838, Description = '6', latitude = 20.1628980576312, TypeOf = 'Target', PresetThrottle = 'Full' }, [3] = { DesiredSpeed = '480', PresetThrottle = 'Cruise', longitude = -74.6142718288192, Description = '7', latitude = 19.3579789939062, TypeOf = 'StrikeEgress', DesiredAltitude = '10972.8' }, [4] = { DesiredSpeed = '480', PresetThrottle = 'Cruise', longitude = -70.052033340425, Description = '8', latitude = 11.5390494782207, TypeOf = 'LandingMarshal', DesiredAltitude = '10972.8' }, [5] = { DesiredSpeed = '350', PresetThrottle = 'Loiter', longitude = -70.052033340425, Description = '9', latitude = 11.7055253589347, TypeOf = 'Land', DesiredAltitude = '35' } }
[object] = name
Spirit 7
[object] = side
Red
[object] = readytime
0
[object] = formation
{ distance = 0, sprint = 'False', guid = '4f61c70a-4e5c-40b9-8a88-ec2287218922', type = 'Fixed', latitude = 20.2965572832031, longitude = -74.6944756399783, bearing = 0 }
[object] = loadoutdbid
9654
[object] = damage
{ startdp = '20', flood = 'NoFlooding', dp = -59.2856369018555, fires = 'NoFire' }
[object] = subtype
3101
---- wrapper end destroyed ------