• 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.

[JASS] Cell Based Weather System

Status
Not open for further replies.
So in the current map I'm making Infection The terrain is given a random heightmap, which certain tiles are placed onto it based on the elevation. This weather takes the average of the elevation in a cell (512x512) of terrain and picks a weather type based on the value. The below function is what creates the weather. It says it is working and picking the correct weather types, but it fails to actually create the weather (in game no weather is visible).

I generate weather after terrain.

JASS:
function CreateWeather takes nothing returns nothing
    local real X=-udg_WorldSize
    local real Y=0
    local integer Index=0
    local integer Wait=0
    local integer ID=-1
    local integer Weather=udg_WeatherType[0]
    local integer Loop=0
    loop
        exitwhen X>=udg_WorldSize
        set Y=-udg_WorldSize
        loop
            exitwhen Y>=udg_WorldSize
            set ID=GetTerrainType(X+256,Y+256)
            set Loop=0
            loop
                exitwhen Loop>10
                if ID==udg_TileTypes[Loop]then
                    set Weather=udg_WeatherType[Loop]
                endif
                set Loop=Loop+1
            endloop
            call RemoveRect(udg_WeatherRects[Index])
            set udg_WeatherRects[Index]=null
            set udg_WeatherRects[Index]=Rect(X,Y,X+480,Y+480)
            call RemoveWeatherEffect(udg_Weathers[Index])
            set udg_Weathers[Index]=null
            set udg_Weathers[Index]=AddWeatherEffect(udg_WeatherRects[Index],Weather)
            call EnableWeatherEffect(udg_Weathers[Index],true)
            //Code
            set Index=Index+1
            set Wait=Wait+1
            if Wait>=10then
                set Wait=0
                call DisplayTextToPlayer(Player(0),0,0,"Weathering...")
                call TriggerSleepAction(0.25)
            endif
            set Y=Y+512
        endloop
        set X=X+512
    endloop
endfunction

PS: Assume all global variables are correctly set up.
 
Level 5
Joined
Jun 16, 2004
Messages
108
Have not looked at your trigger, but came to drop some information regardless: in your game video settings, if the particle details are set to low, you might not see some weather effects.
 
Level 5
Joined
Jun 16, 2004
Messages
108
Well I can tell you it might start working the first time at least for whatever reason if you make this change:

if (udg_Weathers[Index] != null) then
call RemoveWeatherEffect(udg_Weathers[Index])
endif

Well that is the only change I had to make copying the function over to a blank map with all the weather types and terrain types set to one value each.
 
Status
Not open for further replies.
Top