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.
History :
v1.0.0 - First release.