Jump to content

Splash Damage 2.0 script (make explosions better!)


Recommended Posts

Aaaand another update: I think I fixed the stability issue - seems like the tracked_weapons map was growing over time. I added an attribute called launchTime in the onWpnEvent function:

function onWpnEvent(event)
  if event.id == world.event.S_EVENT_SHOT then
    if event.weapon then
      local ordnance = event.weapon
      local weapon_desc = ordnance:getDesc()
      if string.find(ordnance:getTypeName(), "weapons.shells") then 
        debugMsg("event shot, but not tracking: "..ordnance:getTypeName())
        return  --we wont track these types of weapons, so exit here
      end
        
      if explTable[ordnance:getTypeName()] then
--        trigger.action.outText(ordnance:getTypeName().." found.", 10)
      else 
--        env.info(ordnance:getTypeName().." missing from Splash Damage script")
        if splash_damage_options.weapon_missing_message == true then
          trigger.action.outText(ordnance:getTypeName().." missing from Splash Damage script", 10)
          debugMsg("desc: "..mist.utils.tableShow(weapon_desc))
        end
      end
      if (weapon_desc.category ~= 0) and event.initiator then
		local launchingUnit = ordnance:getLauncher()
		local launchingCoalition
		local launchingPlayerName
		if (launchingUnit ~= nil) then
			launchingCoalition = launchingUnit:getCoalition()
			launchingPlayerName = launchingUnit:getPlayerName()
		end

        if (weapon_desc.category == 1) then
          if (weapon_desc.MissileCategory ~= 1 and weapon_desc.MissileCategory ~= 2) then
            tracked_weapons[event.weapon.id_] = { wpn = ordnance, init = event.initiator:getName(), pos = ordnance:getPoint(), dir = ordnance:getPosition().x, name = ordnance:getTypeName(), speed = ordnance:getVelocity(), cat = ordnance:getCategory(), unit = launchingUnit, coalition = launchingCoalition, player = launchingPlayerName, launchTime = timer.getTime() }
          end
        else
          tracked_weapons[event.weapon.id_] = { wpn = ordnance, init = event.initiator:getName(), pos = ordnance:getPoint(), dir = ordnance:getPosition().x, name = ordnance:getTypeName(), speed = ordnance:getVelocity(), cat = ordnance:getCategory(), unit = launchingUnit, coalition = launchingCoalition, player = launchingPlayerName, launchTime = timer.getTime() }
        end
      end
    end
  end
end

 

(Note, I also added some extra information which I use to trigger MOOSE scoring for things killed by the shockwave)

Then in the track_wpns() function, I added a bit that removes entries after 1200 seconds, no matter what.

 

function track_wpns()
--  env.info("Weapon Track Start")
  for wpn_id_, wpnData in pairs(tracked_weapons) do   
    if wpnData.wpn:isExist() then  -- just update speed, position and direction.
      wpnData.pos = wpnData.wpn:getPosition().p
      wpnData.dir = wpnData.wpn:getPosition().x
      wpnData.speed = wpnData.wpn:getVelocity()
      --wpnData.lastIP = land.getIP(wpnData.pos, wpnData.dir, 50)
    else -- wpn no longer exists, must be dead.
--      trigger.action.outText("Weapon impacted, mass of weapon warhead is " .. wpnData.exMass, 2)
      local ip = land.getIP(wpnData.pos, wpnData.dir, lookahead(wpnData.speed))  -- terrain intersection point with weapon's nose.  Only search out 20 meters though.
      local impactPoint
      if not ip then -- use last calculated IP
        impactPoint = wpnData.pos
  --        trigger.action.outText("Impact Point:\nPos X: " .. impactPoint.x .. "\nPos Z: " .. impactPoint.z, 2)
      else -- use intersection point
        impactPoint = ip
  --        trigger.action.outText("Impact Point:\nPos X: " .. impactPoint.x .. "\nPos Z: " .. impactPoint.z, 2)
      end
      --env.info("Weapon is gone") -- Got to here -- 
      --trigger.action.outText("Weapon Type was: ".. wpnData.name, 20)
      if splash_damage_options.larger_explosions == true then
          --env.info("triggered explosion size: "..getWeaponExplosive(wpnData.name))
          trigger.action.explosion(impactPoint, getWeaponExplosive(wpnData.name))
          --trigger.action.smoke(impactPoint, 0)
      end
      --if wpnData.cat == Weapon.Category.ROCKET then
        blastWave(impactPoint, splash_damage_options.blast_search_radius, wpnData.ordnance, getWeaponExplosive(wpnData.name), wpnData.unit, wpnData.coalition, wpnData.player)
      --end
      tracked_weapons[wpn_id_] = nil -- remove from tracked weapons first.
    end
	if (timer.getTime() > wpnData.launchTime + 1200) then
	  tracked_weapons[wpn_id_] = nil
	end
  end
--  env.info("Weapon Track End")
end

 

  • Thanks 2
Link to comment
Share on other sites

Hi @Toumal, thanks for looking into this in such detail.  Sorry I have been busy with my RotorOps project!

Do you know how the tracked_weapons table is growing undesirably?  From the existing code it looks like we remove the weapon object from the table when isExist() is false. 

Link to comment
Share on other sites

On 2/18/2022 at 10:18 PM, Grimm said:

Hi @Toumal, thanks for looking into this in such detail.  Sorry I have been busy with my RotorOps project!

Do you know how the tracked_weapons table is growing undesirably?  From the existing code it looks like we remove the weapon object from the table when isExist() is false. 

My guess is that isExist() doesn't become false reliably.

Link to comment
Share on other sites

1 hour ago, Toumal said:

My guess is that isExist() doesn't become false reliably.

It would be good to know under what circumstances this is happening.  Since this is the primary method for triggering the extra damage attributes of the script.  Are missiles landing softly in the grass somewhere or going off the map into space? How can I recreate the issues you saw?


Edited by Grimm
Link to comment
Share on other sites

On 2/20/2022 at 1:19 AM, Grimm said:

It would be good to know under what circumstances this is happening.  Since this is the primary method for triggering the extra damage attributes of the script.  Are missiles landing softly in the grass somewhere or going off the map into space? How can I recreate the issues you saw?

 

I wish I was able to reproduce it reliably. All I can say is, since I made this change the server runs stable. It may well be that I only got that crash because there's quite a lot going on in my mission, so running for the full 8 hours tends to expose more problems.

Link to comment
Share on other sites

4 hours ago, Toumal said:

I wish I was able to reproduce it reliably. All I can say is, since I made this change the server runs stable. It may well be that I only got that crash because there's quite a lot going on in my mission, so running for the full 8 hours tends to expose more problems.

Fair enough. I appreciate the time you've spent looking into it and the info you've provided. Can you confirm that you know for sure that the weapons table was growing undesirably?  Just want to be sure there's an issue before I spend a lot of time trying to reproduce it. 

Link to comment
Share on other sites

On 2/24/2022 at 9:57 PM, Grimm said:

Fair enough. I appreciate the time you've spent looking into it and the info you've provided. Can you confirm that you know for sure that the weapons table was growing undesirably?  Just want to be sure there's an issue before I spend a lot of time trying to reproduce it. 

Without a debugger and the ability to hook into the LUA interpreter running on the server, I cannot be 100% sure. All I can say is: The server stopped multiple times and had to be manually killed. Once I added the above sections, the problem went away and we have been running for over a week with lots of players and activity, and no server hang or crash.

In any case, I would personally prefer a bit of defensive coding over relying that everything else works fine. In any case, if nobody else has a problem with the current script that's fine of course - and those who find their server hanging can just add the fix.

Link to comment
Share on other sites

19 minutes ago, Toumal said:

Without a debugger and the ability to hook into the LUA interpreter running on the server, I cannot be 100% sure. All I can say is: The server stopped multiple times and had to be manually killed. Once I added the above sections, the problem went away and we have been running for over a week with lots of players and activity, and no server hang or crash.

In any case, I would personally prefer a bit of defensive coding over relying that everything else works fine. In any case, if nobody else has a problem with the current script that's fine of course - and those who find their server hanging can just add the fix.

Would you mind adding a logging statement to the condition where you remove the table entry? 

if (timer.getTime() > wpnData.launchTime + 1200) then
	env.warning("Removing old "..wpnData.name.." from weapon table.")
	tracked_weapons[wpn_id_] = nil
end

Something like this? That should give us all the information we need. 


Edited by Grimm
Link to comment
Share on other sites

  • 2 weeks later...

I added the HOT3 on my end, not sure about the value it seems to correspond to the explosive payload for other payloads.

["HOT3"] = 6,

Can you confirm it is correct and add it if all is ok ? Thanks a lot for the script


Edited by ked
Link to comment
Share on other sites

  • 2 weeks later...

Hello, does this script help solve some of the issues with trees blocking ordinance damage?

 

I'd really like to be able to pierce a treetop with a GBU-38 to kill units underneath 😄


Edited by bennyboy9800

Intel i7 9700k CPU

Nvidia GTX 1080Ti

16GB RAM

Samsung 256GB SSD

Thrustmaster T16000m HOTAS

Link to comment
Share on other sites

  • 3 weeks later...
On 3/22/2022 at 9:27 PM, bennyboy9800 said:

Hello, does this script help solve some of the issues with trees blocking ordinance damage?

 

I'd really like to be able to pierce a treetop with a GBU-38 to kill units underneath 😄

 

Yes.  Would you be interested in running a test and reporting your results here?  

Link to comment
Share on other sites

Updated with new weapons:

  ["AGM_114K"] = 10,
  ["HYDRA_70_M229"] = 8,
  ["AGM_65D"] = 130,
  ["AGM_65E"] = 300,
  ["AGM_65F"] = 300,
  ["HOT3"] = 15,
  ["AGR_20A"] = 8,
  ["GBU_54_V_1B"] = 118,

Also added a new rocket_multiplier option for boosting effectiveness of all rockets.  I tried with this value set at 5 and didn't think it was too 'arcade', but set the default to 3 to be safe?  Play with it and let me know!

Splash_Damage_2_0.lua

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 4/16/2022 at 6:20 PM, Grimm said:

Updated with new weapons:

  ["AGM_114K"] = 10,
  ["HYDRA_70_M229"] = 8,
  ["AGM_65D"] = 130,
  ["AGM_65E"] = 300,
  ["AGM_65F"] = 300,
  ["HOT3"] = 15,
  ["AGR_20A"] = 8,
  ["GBU_54_V_1B"] = 118,

Also added a new rocket_multiplier option for boosting effectiveness of all rockets.  I tried with this value set at 5 and didn't think it was too 'arcade', but set the default to 3 to be safe?  Play with it and let me know!

Splash_Damage_2_0.lua 19.29 kB · 33 downloads

If you haven't already, you might wanna add the AGM-84E SLAM-ER:

["AGM_84E"] = 488

This is based on the warhead size compared to similar sized bombs. You might want to lower that a bit if you think the damage is too extreme. 
 

 

Link to comment
Share on other sites

  • 2 weeks later...

Sorry, I have looked but cant find how to load the script within the mission editor? It has to be loaded manually into every mission you want the new effects in, is that correct? 

System specs: PC1 :Scan 3XS Ryzen 5900X, 64GB Corsair veng DDR4 3600, EVGA GTX 3090 Win 10, Quest Pro, Samsung Odyssey G9 Neo monitor. Tir5. PC2 ( Helo) Scan 3XS Intel 9900 K, 32 GB Ram, 2080Ti, 50 inch Phillips monitor

 F/A-18C: Rhino FFB base TianHang F16 grip, Winwing MP 1, F-18 throttle, TO & Combat panels, MFG crosswind & DFB Aces  seat :cool:                       

Viper: WinWing MFSSB base with F-16 grip, Winwing F-16 throttle, plus Vipergear ICP. MFG crosswind rudders. 

Helo ( Apache) set up: Virpil collective with AH64D grip, Cyclic : Rhino FFB base & TM F18 grip, MFG crosswind rudders, Total controls AH64 MFD's,  TEDAC Unit. 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...