Snippet Weather

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Weather v1.0.0
JASS:

/*
    Weather 
    v1.0.0
    by kingking
    
    ===================
    What is Weather?
    ===================
    Weather gives you better APIs for weather.
    
    =======
    API :
    =======
    Static method :
    Weather.create() -> Weather
    - Returns a new instance.
    
    Methods :
    this.type=whichType
    - Set weather type.
    
    this.rect=whichRect
    - Set which rect for weather to be applied.
    
    this.enabled=True/False
    - Enable/Disable weather. (Works even in GetLocalPlayer() block.)
    
    this.destroy()
    - Destroy weather.
    
    Jass :
    SetWorldWeatherForPlayer(player,weather type)
    - Adjust world weather for player.
    
    EnableWorldWeatherForPlayer(player,boolean)
    - Enable/Disable world weather for player.
    
    =======================
    Implementation steps :
    =======================
    1) Copy this trigger to your map.
    2) Enjoy!
    
    ==============
    Requirement :
    ==============
    Jasshelper 0.A.2.B or later.
    
    ===================
    Works well with :
    ===================
    Weather Type : <a href="http://www.thehelper.net/forums/showthread.php/141522-Weather-Type" class="link link--internal">http://www.thehelper.net/forums/showthread.php/141522-Weather-Type</a>
    
*/
library Weather initializer onInit

    globals
        private integer array WorldWeather
    endglobals
    
    struct Weather
        private weathereffect we
        private integer wetype
        private rect re
        
        method operator type= takes integer i returns nothing
            set this.wetype=i
            if this.re!=null then
                call RemoveWeatherEffect(this.we)
                set this.we=AddWeatherEffect(this.re,i)
                call EnableWeatherEffect(this.we,true)
            endif
        endmethod
        
        method operator rect= takes rect r returns nothing
            set this.re=r
            if this.wetype!=0 then
                call RemoveWeatherEffect(this.we)
                set this.we=AddWeatherEffect(r,this.wetype)            
                call EnableWeatherEffect(this.we,true)
            endif
        endmethod
        
        method operator enabled= takes boolean b returns nothing
            call EnableWeatherEffect(this.we,b)
        endmethod
        
        method destroy takes nothing returns nothing
            call RemoveWeatherEffect(we)
            set this.we=null
            set this.re=null
            set this.wetype=0
        endmethod
        
        private static method onInit takes nothing returns nothing
            local integer i=0
            loop
                set WorldWeather<i>=Weather.create()
                set Weather(WorldWeather<i>).rect=GetWorldBounds()
                set i=i+1
            exitwhen i==bj_MAX_PLAYERS
            endloop
        endmethod
    endstruct
    
    function SetWorldWeatherForPlayer takes player p, integer dat returns nothing
        local Weather w=WorldWeather[GetPlayerId(p)]
        set w.type=dat
        set w.enabled=false
        if GetLocalPlayer()==p then
            set w.enabled=true
        endif
    endfunction
    
    function EnableWorldWeatherForPlayer takes player p, boolean boo returns nothing
        local Weather w=WorldWeather[GetPlayerId(p)]
        if GetLocalPlayer()==p then
            set w.enabled=true
        endif
    endfunction

endlibrary
</i></i>

It is basically wrappers for weather, and provides extra functionality. :D

History :
v1.0.0 - First release.
 

Romek

Super Moderator
Reaction score
964
JASS:
        set w.enabled=false
        if GetLocalPlayer()==p then
            set w.enabled=true
        endif

->
JASS:
set w.enabled = GetLocalPlayer() == p

Your code doesn't have much going for it in terms of readability anyway.

I'm not too sure about the whole purpose of this. Are the standard weather natives really that bad?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
It would be cool if it included a list of the weather types. Those are always annoying to lookup:
JASS:
globals
    constant integer ASHENVALE_RAIN_HEAVY    = &#039;RAhr&#039;
    constant integer ASHENVALE_RAIN_LIGHT    = &#039;RAlr&#039;
    constant integer DALARAN_SHIELD          = &#039;MEds&#039;
    constant integer DUNGEON_BLUE_FOG_HEAVY  = &#039;FDbh&#039;
    constant integer DUNGEON_BLUE_FOG_LIGHT  = &#039;FDbl&#039;
    constant integer DUNGEON_GREEN_FOG_HEAVY = &#039;FDgh&#039;
    constant integer DUNGEON_GREEN_FOG_LIGHT = &#039;FDgl&#039;
    constant integer DUNGEON_RED_FOG_HEAVY   = &#039;FDrh&#039;
    constant integer DUNGEON_RED_FOG_LIGHT   = &#039;FDrl&#039;
    constant integer DUNGEON_WHITE_FOG_HEAVY = &#039;FDwh&#039;
    constant integer DUNGEON_WHITE_FOG_LIGHT = &#039;FDwl&#039;
    constant integer LORDAERON_RAIN_HEAVY    = &#039;RLhr&#039; 
    constant integer LORDAERON_RAIN_LIGHT    = &#039;RLlr&#039; 
    constant integer NORTHREND_BLIZZARD      = &#039;SNbs&#039;
    constant integer NORTHREND_SNOW_HEAVY    = &#039;SNhs&#039;
    constant integer NORTHREND_SNOW_LIGHT    = &#039;SNls&#039;
    constant integer OUTLAND_WIND_HEAVY      = &#039;WOcw&#039;
    constant integer OUTLAND_WIND_LIGHT      = &#039;WOlw&#039;
    constant integer RAYS_OF_LIGHT           = &#039;LRaa&#039;
    constant integer RAYS_OF_MOONLIGHT       = &#039;LRma&#039;
    constant integer WIND_HEAVY              = &#039;WNcw&#039;
endglobals
 

Laiev

Hey Listen!!
Reaction score
188
JASS:
 /*
   ===================
    Works well with :
    ===================
    Weather Type : <a href="http://www.thehelper.net/forums/showthread.php/141522-Weather-Type" class="link link--internal">http://www.thehelper.net/forums/showthread.php/141522-Weather-Type</a>
    
*/
 

tooltiperror

Super Moderator
Reaction score
231
JASS:
// onInit
                set Weather(WorldWeather<i>).rect=GetWorldBounds()
</i>

You're creating [LJASS]bj_MAX_PLAYER_SLOTS[/LJASS] rects when you only need one. I hate to do this, but you should actually use WorldBounds.

>private weathereffect we
>private integer wetype
>private rect re
Turn these into stacks and let us have a lot in one Weather :D
 

tooltiperror

Super Moderator
Reaction score
231
Hasn't been looked at in months.

Graveyarded.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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