System Terrain Generator

Azylaminaz

Vox Populi
Reaction score
91
I was using an exact number. 150. It randomed me the same thign three times. o.o I even took a screen shot of two, and compared, same thing.
Now I use random 140-160.

If you have ever experimenting with making good terrain, you should know the water trick. You start off with a 32x32(most simple) covered in shallow water. Then you use the increase hight tool and make it above water. This makes it so you can decrease hight, giving you water, without having the straight edges of the cliff.

I did this for your system. Problem is, it doesn't do it. Maybe it doesn't work with triggers.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> It randomed me the same thign three times.

I have no idea why it would do that. Do you have the Fixed Random Seed turned off in File - Preferences - Test Map?

Ok, for all the JASS-savvy that want to help, I have a problem with the timer thing. Here's the trigger:

JASS:
function looping takes nothing returns nothing
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = R2I(( GetRectHeightBJ(GetPlayableMapRect()) / I2R(udg_GeneratorSeed) ))
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            set udg_TempPoint = Location(( I2R(udg_Loop) * I2R(udg_GeneratorSeed) ), ( I2R(GetForLoopIndexA()) * I2R(udg_GeneratorSeed) ))
            call TerrainDeformationCraterBJ( 0.10, true, udg_TempPoint, GetRandomReal(64.00, 512.00), ( -1.00 * GetRandomReal(-32.00, 32.00) ) )
            call RemoveLocation(udg_TempPoint)
            set udg_TempPoint = Location(( I2R(udg_Loop) * I2R(( -1 * udg_GeneratorSeed )) ), ( I2R(GetForLoopIndexA()) * I2R(udg_GeneratorSeed) ))
            call TerrainDeformationCraterBJ( 0.10, true, udg_TempPoint, GetRandomReal(64.00, 512.00), ( -1.00 * GetRandomReal(-32.00, 32.00) ) )
            call RemoveLocation(udg_TempPoint)
            set udg_TempPoint = Location(( I2R(udg_Loop) * I2R(udg_GeneratorSeed) ), ( I2R(GetForLoopIndexA()) * I2R(( -1 * udg_GeneratorSeed )) ))
            call TerrainDeformationCraterBJ( 0.10, true, udg_TempPoint, GetRandomReal(64.00, 512.00), ( -1.00 * GetRandomReal(-32.00, 32.00) ) )
            call RemoveLocation(udg_TempPoint)
            set udg_TempPoint = Location(( I2R(udg_Loop) * I2R(( -1 * udg_GeneratorSeed )) ), ( I2R(GetForLoopIndexA()) * I2R(( -1 * udg_GeneratorSeed )) ))
            call TerrainDeformationCraterBJ( 0.10, true, udg_TempPoint, GetRandomReal(64.00, 512.00), ( -1.00 * GetRandomReal(-32.00, 32.00) ) )
            call RemoveLocation(udg_TempPoint)
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
endfunction
function Trig_Terrain_Generator_Height_Copy_Actions takes nothing returns nothing
    local timer countdown=CreateTimer()
    set udg_Loop = 1
    loop
        exitwhen udg_Loop > R2I(( GetRectWidthBJ(GetPlayableMapRect()) / I2R(udg_GeneratorSeed) ))
        set udg_Loop = udg_Loop+1
        call TimerStart(countdown, 0.01, false, looping)
    endloop
    call ConditionalTriggerExecute( gg_trg_Destructable_Generator )
endfunction

//===========================================================================
function InitTrig_Terrain_Generator_Height takes nothing returns nothing
    set gg_trg_Terrain_Generator_Height = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Terrain_Generator_Height, function Trig_Terrain_Generator_Height_Copy_Actions )
endfunction


I get an Expected '(' on the TimerStart line when I try to enable the trigger.
 

Sim

Forum Administrator
Staff member
Reaction score
534
> call TimerStart(countdown, 0.01, false, looping)

call TimerStart(countdown, 0.01, false, function looping)

:p
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Ok, thanks, that works. Didn't know I needed to put function there. But the trigger doesn't work. It changes the height of a small section in the center of the map and then instantly moves on to the destructables. Does the bottom loop keep going after the it starts the timer? What's wrong here?
 

Hero

─║╣ero─
Reaction score
250
JASS:
function Trig_Terrain_Generator_Height_Copy_Actions takes nothing returns nothing
    local timer countdown=CreateTimer()
    set udg_Loop = 1
    loop
        exitwhen udg_Loop > R2I(( GetRectWidthBJ(GetPlayableMapRect()) / I2R(udg_GeneratorSeed) ))
        set udg_Loop = udg_Loop+1
        call TimerStart(countdown, 0.01, false, looping)
    endloop
    call ConditionalTriggerExecute( gg_trg_Destructable_Generator )
endfunction


Thats gonna be nasty...why not just call the function directly?

Example:

JASS:
function Trig_Terrain_Generator_Height_Copy_Actions takes nothing returns nothing
    set udg_Loop = 1
    loop
        exitwhen udg_Loop > R2I(( GetRectWidthBJ(GetPlayableMapRect()) / I2R(udg_GeneratorSeed) ))
        set udg_Loop = udg_Loop+1
        call looping()
    endloop
    call ConditionalTriggerExecute( gg_trg_Destructable_Generator )
endfunction


Cause you were basically Starting the timer over and over again
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> Cause you were basically Starting the timer over and over again

I though that was the idea. Add in a wait of some sort so that the trigger doesn't hit the execution limit....
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
But using waits in loops is weird.

Did you remove the elses? Also, instead of using "udg_Loop", create a local integer called "i" or something then just keep creating it in each trigger. The global isn't needed since in each trigger it is just equal to 1. ;)
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> create a local integer called "i"

I have to use it in multiple functions if I'm going with the timer, though.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Oh, then create a seperate function that does the timer work for you and make it have a parameter for the integer eg:
JASS:
function Callback takes nothing returns nothing
    call SetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE,GetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE)  - 20)
endfunction

function TimerFunc takes integer i returns nothing
    local timer t = CreateTimer()
    call TimerStart(t,0.01,true,function Callback)
endfunction

function Func takes nothing returns nothing
    local integer i = 1 
    call TimerFunc(i)
endfunction


It might seem as too much of a hassle though so erm... I guess you can just use a global.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Grr... none of this is either making sense or working. How about using the original JASS I made for it? :p
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> Just remove the damn elses.

Ok! Ok! Don't have a heart attack. :p I did it.
 

waaaks!

Zinctified
Reaction score
255
nice, thats what im waiting for, the jass version

OFFTOPIC: how did u make those show and hide quotes? like if u click show, then the quote comes out..
is that for mods only?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Do you mean Spoilers?

Just use this [noparse]
Text to display
[/noparse]

Then it becomes:
Text to display
 

waaaks!

Zinctified
Reaction score
255
ahhh....this option is not visible to the reply topic, is it?

let me try...

thanks purge
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Well, did anyone find any bugs, errors, it's-not-working-crys, imperfections, or general wrongness? I think I've hammered out any and all problems, but maybe not....
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Well, you do some awkward things in the JASS version, like using mixed globals and locals, when you can only use locals and,
convert co-ordinates to a location and later, get the co-ordinates of the same location.

"set udg_TempPoint = ..."
...
"GetTerrainType(GetLocationX(udg_TempPoint), ..."


In addition, I can spot a lot of BJ functions and really,
you should implement some constant functions for terrain type/destructible etc. rawcodes.


I suggest to nip/tuck on the JASS version a little bit, before you allow anyone to download it,
because, at present, it's on the same level as the GUI one.

Just harder to understand.


Feel free to ask help from me, if you get stuck.


P.S, I still dislike random terrain generators. Nothing against you.
 

Sim

Forum Administrator
Staff member
Reaction score
534
The code still can be optimized a lot, but it is not what is preventing me from approving it :D

Perfect, approved!
 

WackO_WilL

New Member
Reaction score
4
LOL I dont think its worth it, Because it is more work than terraining, But im thinking about using it in one of my maps, because if the terrain changes every time, The map would never get old,
So genious.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top