chromium Posted December 8, 2014 Posted December 8, 2014 (edited) Hello, copying some script from more experienced author (SNAFU's range script for sure, Grimes also, maybe MBot but I can't remember...), I'm trying to set-up something simple to simulate fragmentation damage of rockets. In this first draft is done by creating an additional explosion when a rockets go under 2 mt from the terrain: -- VARIABLES local VerticalOffset = 2 -- variable that define when the "gimme the offset" is calculated. local ProduceLog = false -- if this is set as "true" it will save any tracked shot to a CSV file. local hitLog = "" local HitTable = {} -- this one track every shot to a single target in a 1000 mt distance range RocketHandler = {} function RocketHandler:onEvent(event) if event.id == world.event.S_EVENT_SHOT then RocketInit = event.initiator RocketInitGroup = RocketInit:getGroup() RocketInitGroupName = event.initiator:getName() --"Prova" --RocketInitGroup.name _ordnance = event.weapon _ordnanceName = _ordnance:getTypeName() if (_ordnanceName == "weapons.nurs.C_8" or _ordnanceName == "weapons.nurs.C_8OFP2" or _ordnanceName == "weapons.nurs.S-8KOM" or _ordnanceName == "weapons.nurs.C_8OM" or _ordnanceName == "weapons.nurs.C_8CM" or _ordnanceName == "weapons.nurs.HYDRA_70_M156") then function TrackRocket() local RocketPos = _ordnance:getPoint() local _time = timer.getTime() if RocketPos.y < land.getHeight({x = RocketPos.x, y = RocketPos.z}) + VerticalOffset then trigger.action.explosion(ExpPos, 90) --trigger.action.explosion(ExpPos, 60) if ProduceLog == true then hitLog = hitLog.. "pilot = " .. RocketInitGroupName .. ", position: x = " .. RocketPos.x .. ", y = " .. RocketPos.z .. ", timeShot = " .. _time .. "\n" end return end return timer.getTime() + 0.1 end timer.scheduleFunction(TrackRocket, nil, timer.getTime() + 1) end end end world.addEventHandler(RocketHandler) Sadly I believe that this is not the best way to archieve what I want. Do you know if there is a way to determinee the range and the magnitude of the triggered explosion? Edited December 8, 2014 by chromium Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Flagrum Posted December 8, 2014 Posted December 8, 2014 I can't help you with the script, but ... you are aware that recently (since 1.2.8 ... iirc) ED already has implemented a workaround for the missing fragmentation damange modelling that is very similar already to what you are trying to do? ED has increased the amount of HE ammunitions (rockets, missiles? and shells) significantly to make them more effective. (which leads to other problems, like that HE tank rounds are now way more effective against tanks than APFSDS rounds ... but that's a different story)
Stonehouse Posted December 8, 2014 Posted December 8, 2014 I had similar trouble with the flak script and trying to simulate the damage sphere for an 88 shell. There is no guide to how the explosion strength works (linear, logarithmic etc etc) when you go from strength 1 to 2 or 100. Ditto for the distance from the point of explosion to the limit of damage. I ended up parking AI planes on the ramp and positioned the explosion trigger point at the distance my research said was the lethal radius for an 88 shell then fiddled with explosion strength until I got something that caused enough damage at the correct range to make the plane unflyable. Not talking smoking burning wreck but enough damage to flight surfaces etc that the crew would choose to bail. The radius of effect is definitely linked to strength though. Also where the explosion went off had a big impact on what damage was caused. Typically an explosion behind the aircraft caused less damage than one in front or to the side.
chromium Posted December 8, 2014 Author Posted December 8, 2014 uhm, then I think that make 4 very small explosion around the impact point should work better... I may only be concerned for the performances (lag, etc). Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
chromium Posted December 8, 2014 Author Posted December 8, 2014 ok, tried this one: -- build internal vars local RingNum = nil -- number of fragmentation ring explosions available local RingOffset = nil -- mt, number that will define the distance betw local IntRingTotPower = nil -- fraction of the warhead power that will be divided into ringExpNumber -- internal backup vars local bckRingNum = 1 -- number of fragmentation ring explosions available local bckRingOffset = 25 -- mt, number that will define the distance betw local bckIntRingTotPower = 0.50 -- fraction of the warhead power that will be divided into ringExpNumber -- retrieve external variables if not RingNum then RingNum = bckRingNum end if not RingOffset then RingOffset = bckRingOffset end if not IntRingTotPower then IntRingTotPower = bckRIntRingTotPower end -- DEFINED VARIABLES local ringExpNumber = 4 -- number of explosion per ring. /// ONLY "4" or "8" VALUES ARE ACCEPTED!! /// local VerticalOffset = 2 -- variable that define when the "gimme the offset" is calculated. local ProduceLog = false -- if this is set as "true" it will save any tracked shot to a CSV file. local hitLog = "" local RocketData = {} local HitTable = {} -- this one track every shot to a single target in a 1000 mt distance range RocketHandler = {} function RocketHandler:onEvent(event) if event.id == world.event.S_EVENT_SHOT then -- launch event data RocketInit = event.initiator RocketInitGroup = RocketInit:getGroup() RocketInitGroupName = event.initiator:getName() --"Prova" --RocketInitGroup.name _ordnance = event.weapon _ordnanceName = _ordnance:getTypeName() if ProduceLog == true then hitLog = hitLog .. "launch event identified, launcher: " .. RocketInitGroupName .. ", weapon: " .. _ordnanceName .. "\n" end wpnDesc = Weapon.getDesc(_ordnance) [color="Red"][b] wpnWarhead = wpnDesc.warhead[/b][/color] _ordnanceExpMass = wpnWarhead.mass if _ordnanceExpMass == nil then _ordnanceExpMass = 50 end if ProduceLog == true then hitLog = hitLog .. "weapon warhead mass: " .. _ordnanceExpMass .. ", (50 means that the proper weapon mass hasn't been found!!)\n" end --Weapon.getDesc(aiMissiles[id].missile).warhead.explosiveMass if (_ordnanceName == "weapons.nurs.C_8" or _ordnanceName == "weapons.nurs.C_8OFP2" or _ordnanceName == "weapons.nurs.S-8KOM" or _ordnanceName == "weapons.nurs.C_8OM" or _ordnanceName == "weapons.nurs.C_8CM" or _ordnanceName == "weapons.nurs.HYDRA_70_M156") then function TrackRocket() local RocketPos = _ordnance:getPoint() local _time = timer.getTime() if RocketPos.y < land.getHeight({x = RocketPos.x, y = RocketPos.z}) + VerticalOffset then if ProduceLog == true then hitLog = hitLog .. "esplosione registrata al tempo: " .. _time .. "\n" end doExplosion(RocketPos,_ordnanceExpMass) --trigger.action.explosion(ExpPos, 90) --trigger.action.explosion(ExpPos, 60) if ProduceLog == true then hitLog = hitLog.. "pilot = " .. RocketInitGroupName .. ", main explosion position: x = " .. RocketPos.x .. ", y = " .. RocketPos.z .. "\n" end return end return timer.getTime() + 0.1 end timer.scheduleFunction(TrackRocket, nil, timer.getTime() + 1) end end end world.addEventHandler(RocketHandler) function doExplosion(ExpPos, Power) -- Explosions magnitude: IntPower = (RingTotPower*Power)/ringExpNumber -- main exp position ExpX = ExpPos.x ExpZ = ExpPos.z -- ## first ring explosion points: --1: north E1_ExpX = E1_ExpX E1_ExpZ = E1_ExpZ + RingOffset E1_ExpY = land.getHeight({x = E1_ExpX, y = E1_ExpZ}) E1_ExpPos = {x =E1_ExpX, y = E1_ExpY , z = E1_ExpZ} --2: south E2_ExpX = E2_ExpX E2_ExpZ = E2_ExpZ - RingOffset E2_ExpY = land.getHeight({x = E2_ExpX, y = E2_ExpZ}) E2_ExpPos = {x =E2_ExpX, y = E2_ExpY , z = E2_ExpZ} --3: est E3_ExpX = E3_ExpX + RingOffset E3_ExpZ = E3_ExpZ E3_ExpY = land.getHeight({x = E3_ExpX, y = E3_ExpZ}) E3_ExpPos = {x =E3_ExpX, y = E3_ExpY , z = E3_ExpZ} --4: est E4_ExpX = E4_ExpX - RingOffset E4_ExpZ = E4_ExpZ E4_ExpY = land.getHeight({x = E4_ExpX, y = E4_ExpZ}) E4_ExpPos = {x =E4_ExpX, y = E4_ExpY , z = E4_ExpZ} -- OTHER EXPLOSION? -- ## INTERNAL RING EXPLOSIONS if ringExpNumber == 4 then trigger.action.explosion(E1_ExpPos, IntPower) trigger.action.explosion(E2_ExpPos, IntPower) trigger.action.explosion(E3_ExpPos, IntPower) trigger.action.explosion(E4_ExpPos, IntPower) elseif ringExpNumber == 8 then env.info(("Fragmentation script: ringExpNumber = 8 but script not ready to that details: use 4")) else env.info(("Fragmentation script: ringExpNumber not valid")) end -- ## EXTERNAL RING EXPLOSIONS --// not ready yet end function Logging() if ProduceLog == true then local fName = "hitLog.txt" local g = io.open(lfs.writedir() .. "Logs/" .. fName, "w") g:close() end end mist.scheduleFunction(Logging,{},timer.getTime() + 1,10,14400) but I get an error due to the red part: seems that "warhead" is nil, in fact when a rocket is launched I got an error on the line after the red one, saying that wpnWarhead is nil Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Recommended Posts