Jump to content
mrcurry

Artillery Terrain Deformation example

Recommended Posts

Hey guys,

 

I decided to play around with the new fancy stuff from Arma 3 v2.10 to make a little basic script to make artillery deform terrain just to check out what v2.10 can do.

It started as a test / learning example to see what's what but I decided to implement the multiplayer optimizations from the setTerrainHeight biki page so should be good enough to play online with if you are so inclined.

 

Some basic features:

  • Applies to all configured projectiles no matter if spawned, shot from a gun, or placed. (kudos to BIS for the new Eventhandlers)
  • Any CfgAmmo entry that explodes should be configurable to work. Let me know if it doesn't!
  • Works in MP
  • Script only, no additional mods required.
     

Since this is supposed to be an example here's the basics of how it works, I'll spoiler it for those of you who just wanna get blasting:

Spoiler

1. The map is divided into update regions of a given size

  • Each region contains all terrain mesh points that can be updated by setTerrainHeight.
  • Any change of height at any point in the region requires us to update the entire region (MP optimization).
  • 2 hashMaps keeps track of this for us, ARDM_heightMap and ARDM_defaultHeightMap.
  • Initially these hashMaps are empty and will be generated as impacts are recorded.

 

2. On init configured ammo is read automatically into a hashMap, ARDM_ammoMap.

3. Tracking is provided by 2 eventhandlers:

  • A mission eventhandler "ProjectileCreated" checks for new projectiles and filters based on the contents of the ARDM_ammoMap.
  • An "Explode" eventhandler initiates the crater creation for impacts that are close to the ground (a.k.a. didn't hit a building, rock or other terrain feature).

4. On impact a few things happen.

  • Terrain vertices that should be updated are found.
  • Each affected vertex is given a new height by a parabolic function based on their distance from the center of impact.
  • The region that the vertex is in is updated with the new value and is set to update as well.
  • If the region is not initialized yet this happens now.
  • The full region (including previous craters) is sent to setTerrainHeight to resolve the actual change.
  • The changes are stored in ARDM_heightMap so we don't "forget" about previous craters.

 

If you are interested in how this is done in detail check out ARDM_fnc_doBlast which does most of the heavy lifting.

 

A few caveats of course (wouldn't be ArmA without them):

The limiting factor to quality really is the terrain mesh resolution as alluded to in the dev diary and the biki.

On maps with a small terrain cell size like  Prairie Fire's "The Bra" ( 2.5 m ) the look is always going to be better than on terrains like Altis ( 7.5 m ) or Malden 2035 ( 12.5! ) were things can look edgy (no pun intended) and, small enough craters might not even register.

 

In addition to that the current ammo config is aimed at the Prairie Fire maps (which tend to have a slight better resolution in general) and is intended to not make too big an impact on the "walkability" of the map. 

For other maps I recommend playing around with the width and depth values in the config to get the best look for your mission.

 

Bonus feature: If you wish to undo all changes you can use:

call ARDM_fnc_resetTerrain;

 

Time for some pictures.

Prairie Fire - The Bra example:

Spoiler

?imw=5000&imh=5000&ima=fit&impolicy=Lett

 

Before and after on Altis:

Spoiler

?imw=5000&imh=5000&ima=fit&impolicy=Lett
?imw=5000&imh=5000&ima=fit&impolicy=Lett

 

There are 2 files that are meant to be configurable:

  • ARDM\ARDM_ammo.ext - Contains all configured ammunition and their impact parameters. Tweak as you like.
    When adding more ammo to the mix consider what the final stage ammo is called. The MLRS for example fires a "R_230mm_HE" ammo but the submunition that creates the explosion is called "R_230mm_fly" which is why that is listed in the config, not _HE.
  • ARDM\fnc\macros.sqf - Two possible defines to play with.
    - MAX_ADJUST - How much the combined effect of craters is allowed to deviate from the default height map.
    - UPDATE_GRID_SCALE - Controls the size of each update region. If network performance becomes a problem because of this script increase this value.

 

Tested in MP to work as advertised but if you find any issues let me know.

 

Links: 

Example missions: https://www.dropbox.com/sh/j1gybz79dqikdr4/AAD4dXEgM0Y1hkwgM5mYutzla?dl=0

  • Like 10
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×