• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Flattening Permanent Terrain Deformers?

Status
Not open for further replies.

Red

Red

Level 26
Joined
Dec 10, 2008
Messages
156
I've been playing around with the idea of procedurally-generated areas of terrain, allowing for (in theory) infinitely large areas to explore. Unfortunately, there's no trigger function to remove permanent "craters", so after a few executions of the trigger, my terrain looks like the Swiss alps... :hohum:

Does anyone know how to remove permanent terrain deformations with a script? Or even a GUI trigger I've somehow overlooked? Thanks in advance!
 

Red

Red

Level 26
Joined
Dec 10, 2008
Messages
156
Sorry if i was vague. I know that would work, but even on a little 128x128 map I'm having it make hundreds of deformers... Maybe it's just wishful thinking, but I was hoping there would be an easier way to just flatten the area in one action as opposed to storing all of those random locations and values ; ;

I just had an idea, let me see if this works...
 
it inclues a workaround cause you will surely hit the operation limit when creating 999999 craters all around the map
I did not delete the leaks caused by the hashtable yet cause I was to lazy
I also did not test it too much
there probably are some bugs

  • StartReset
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • -------- start integer --------
      • Set i = 0
      • -------- permanent? --------
      • Set b = True
      • -------- seconds to rise --------
      • Set r = 1.00
      • -------- in which region? --------
      • Set region = (Playable map area)
      • -------- start it --------
      • Trigger - Run ResetTerrain <gen> (ignoring conditions)
  • Ini
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • Hashtable - Create a hashtable
      • Set Terrain_Hashtable = (Last created hashtable)
      • For each (Integer i) from 1 to 100, do (Actions)
        • Loop - Actions
          • Set loc = (Random point in (Playable map area))
          • Set r = 512.00
          • Set r2 = 128.00
          • Trigger - Run DeformCraterSave <gen> (ignoring conditions)
  • DeformCraterSave
    • Events
    • Conditions
    • Actions
      • Environment - Create a 0.01 second Permanent crater deformation at loc with radius r and depth r2
      • Set Terrain_Max = (Terrain_Max + 1)
      • Hashtable - Save (X of loc) as 0 of Terrain_Max in Terrain_Hashtable
      • Hashtable - Save (Y of loc) as 1 of Terrain_Max in Terrain_Hashtable
      • Hashtable - Save r as 2 of Terrain_Max in Terrain_Hashtable
      • Hashtable - Save (-1.00 x r2) as 3 of Terrain_Max in Terrain_Hashtable
      • Custom script: call RemoveLocation(udg_loc)
  • ResetTerrain
    • Events
    • Conditions
    • Actions
      • Custom script: call ResetTerrain(udg_i, udg_region, udg_r, udg_b)
JASS:
function ResetTerrain takes integer i, rect r, real duration, boolean permanent returns nothing
    local real x = 0
    local real y = 0
    local integer counter = 0
    loop
        exitwhen i == udg_Terrain_Max
        set i = i + 1
        set x = LoadReal(udg_Terrain_Hashtable, i, 0)
        set y = LoadReal(udg_Terrain_Hashtable, i, 1)
        if RectContainsCoords(r, x, y) then
            call TerrainDeformCrater(x, y, LoadReal(udg_Terrain_Hashtable, i, 2), LoadReal(udg_Terrain_Hashtable, i, 3), R2I(duration*1000), permanent)
        endif
        set counter = counter + 1
        if counter > 1337 then
            set udg_i = i
            set udg_r = duration
            set udg_b = permanent
            call TriggerExecute(gg_trg_ResetTerrain)
        endif
    endloop
    call RemoveRect(r)
endfunction
replace 1337 with any value which appears to be fine (does not break the operation limit)
I only tried this with 100 cause else there will be uber terrain deformation bug causing weird graphic glitches but it might even work!!...or not
whatever try it yourself and feel free to modify and improve it
 

Attachments

  • test.w3x
    14.2 KB · Views: 27
  • Like
Reactions: Red
Status
Not open for further replies.
Top