Login
Register
Menu
Home
Forum
JassDoc
Types
Functions
Variables
Help
Chat
Media
Search
Search posts
WC3 JASS.com
"The Jass Vault" plus vJASS and Zinc
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Warcraft III Resources
Warcraft III Spells and Systems
Codes & Snippets
Random weather script
Warcraft III:
Maps
Models
Skins
Icons
Spells / Systems
Tools
Tutorials
Snippets
JASS vJASS Spells and Systems
Tutorials
Chat @Discord
vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation
-
Zinc documentation
-
WC3 Optimizer documentation
Random weather script
Codes & Snippets
Started by
moyack
Views
1736
Replies
0
Users
1
1
Pages:
1
Go Down
0 Members and 1 Guest are viewing this topic.
Rating
Average Score
- 5 / 5
«
Created: January 02, 2018, 08:05:56 PM by moyack
»
moyack
Site Owner
Administrator
Posts:
971
WC3 Models: 20
WC3 Tutorials: 17
WC3 Tools: 19
WC3 Maps: 12
WC3 Skins: 0
WC3 Icons: 1
WC3 Spells: 16
Reputation:
1153
Site Admin - I love fix things
Random weather script
on:
February 18, 2012, 05:59:47 AM
Category:
Effect
Language:
vJASS
Random weather script
By moyack. 2008.
I did this as a request: a code that changes randomly the weather from normal to a rainy day. Due to its configurability and easy to use (just copy it to your map and it will work) I'll post it to the public. Now the current version allows multiple types of weathers and with a few functions you can achieve very nice weather effect transitions.
How the script works?
The script initializes a timer with a random duration (configurable via globals), and it will change from no weather to a weather environment. if you use the minimalistic version, it will turn on and off in a random way the specified weather. If you use the Standard version, it will do the same but with a set of weathers configured previously. this preconfiguration can be done at map init or at game time... there's no limitation.
Credits and Acknowledgments
Greetings to Syntic_Arrow for doing the request.
Credits to Ammorth for the suggestion of weights to implement randomness
Gives credits when you use it...
How to install:
Create a new trigger
Call it whatever you want
Convert it to custom text
Delete all the content of that trigger
Paste this trigger code and voila!!!
Standard version
The standard version offers the possibility to setup the kind of weathers you want to see in your map and their chances to appear. To start a set of weathers, you just have to add a code like this:
Sample code
Code: jass
function
StartWeather
takes
nothing
returns
nothing
// This function can run at map init...
call
CleanWeatherWeights()
// Prepares and clean the Weather script...
call
SetWeatherWeight(Northrend_Blizzard, 3.)
// adds a weather type and its weight.
call
SetWeatherWeight(Rays_Of_Light, 5.)
call
SetWeatherWeight(Wind_Heavy, 8.)
// if a weather has a higher weight, it will have more chances to happen than others.
// this value is arbitrary...
endfunction
If you need to change the weather weights, or types, you must clean them with
CleanWeatherWeights()
and then reset the values with
SetWeatherWeight(...)
command.
Random Weather Script - Standard version
Code: jass
// Random weather changer, by moyack. 2008.
library
RandomWeather
initializer
init
// Configuration section
globals
private
constant
real
MinDur = 5.
// minimum time that we have to wait between weathers
private
constant
real
MaxDur = 15.
// maximum time that we have to wait between weathers
endglobals
// End configuration section
globals
// Weather Type Constants
constant
integer
Ashenvale_Rain_Heavy =
'RAhr'
constant
integer
Ashenvale_Rain_Light =
'RAlr'
constant
integer
Dalaran_Shield =
'MEds'
constant
integer
Dungeon_Blue_Fog_Heavy =
'FDbh'
constant
integer
Dungeon_Blue_Fog_Light =
'FDbl'
constant
integer
Dungeon_Green_Fog_Heavy =
'FDgh'
constant
integer
Dungeon_Green_Fog_Light =
'FDgl'
constant
integer
Dungeon_Red_Fog_Heavy =
'FDrh'
constant
integer
Dungeon_Red_Fog_Light =
'FDrl'
constant
integer
Dungeon_White_Fog_Heavy =
'FDwh'
constant
integer
Dungeon_White_Fog_Light =
'FDwl'
constant
integer
Lordaeron_Rain_Heavy =
'RLhr'
constant
integer
Lordaeron_Rain_Light =
'RLlr'
constant
integer
Northrend_Blizzard =
'SNbs'
constant
integer
Northrend_Snow_Heavy =
'SNhs'
constant
integer
Northrend_Snow_Light =
'SNls'
constant
integer
Outland_Wind_Heavy =
'WOcw'
constant
integer
Outland_Wind_Light =
'WOlw'
constant
integer
Rays_Of_Light =
'LRaa'
constant
integer
Rays_Of_Moonlight =
'LRma'
constant
integer
Wind_Heavy =
'WNcw'
// End Weather type Constants...
private
boolean
IsWeather =
false
endglobals
private
struct
Weather
// this is the struct that manages all the weather behavior
private
static
rect
R
private
static
real
total = 0.
private
static
integer
index = 0
weathereffect
w
integer
id
real
weight
real
chance
private
method
onDestroy
takes
nothing
returns
nothing
call
RemoveWeatherEffect
(.w)
endmethod
static
method
Clean
takes
nothing
returns
nothing
local
integer
i = 1
local
Weather W
loop
exitwhen
i > Weather.index
set
W = Weather(i)
call
W.destroy()
set
i = i+1
endloop
set
Weather.index = 0
endmethod
static
method
Add
takes
integer
id,
real
w
returns
nothing
local
integer
i = 1
local
Weather W = Weather.
allocate
()
set
W.id = id
set
W.weight = w
set
W.w =
AddWeatherEffect
(Weather.R, id)
call
EnableWeatherEffect
(W.w,
false
)
set
Weather.total = Weather.total + w
set
Weather.index =
integer
(W)
loop
exitwhen
i > Weather.index
set
W = Weather(i)
set
W.chance = W.weight / Weather.total
set
i = i+1
endloop
endmethod
static
method
Start
takes
nothing
returns
nothing
local
integer
i = 1
local
real
r =
GetRandomReal
(0,1)
local
real
s = 0.
local
Weather W
loop
exitwhen
i > Weather.index
set
W = Weather(i)
exitwhen
s <= r
and
r < s+W.chance
set
s = s+W.chance
set
i = i+1
endloop
call
EnableWeatherEffect
(W.w,
true
)
endmethod
static
method
Stop
takes
nothing
returns
nothing
local
integer
i = 1
local
Weather W
loop
exitwhen
i > Weather.index
set
W = Weather(i)
call
EnableWeatherEffect
(W.w,
false
)
set
i = i+1
endloop
endmethod
private
static
method
onInit
takes
nothing
returns
nothing
set
Weather.R =
GetWorldBounds
()
endmethod
endstruct
private
function
Loop
takes
nothing
returns
nothing
local
timer
t =
GetExpiredTimer
()
set
IsWeather =
not
IsWeather
if
IsWeather
then
call
Weather.Start()
else
call
Weather.Stop()
endif
call
PauseTimer
(t)
call
TimerStart
(t,
GetRandomReal
(MinDur, MaxDur),
false
,
function
Loop)
set
t =
null
endfunction
private
function
init
takes
nothing
returns
nothing
call
TimerStart
(
CreateTimer
(),
GetRandomReal
(MinDur, MaxDur),
false
,
function
Loop)
endfunction
// ==============
// user functions
// ==============
function
SetWeatherWeight
takes
integer
wid,
real
w
returns
nothing
call
Weather.Add(wid, w)
endfunction
function
CleanWeatherWeights
takes
nothing
returns
nothing
call
Weather.Clean()
endfunction
endlibrary
Minimalistic version. Only manages one type of weather
Code: jass
// Random weather changer, by moyack. 2008.
scope
RandomWeather
initializer
init
globals
private
constant
integer
Rain =
'RAhr'
//Set the weather type that you want to use...
private
constant
real
MinDur = 15.
// minimum time that we have to wait between weathers
private
constant
real
MaxDur = 35.
// maximum time that we have to wait between weathers
private
weathereffect
W
private
boolean
IsRain =
false
endglobals
private
function
Loop
takes
nothing
returns
nothing
local
timer
t =
GetExpiredTimer
()
set
IsRain =
not
IsRain
call
EnableWeatherEffect
(W, IsRain)
call
PauseTimer
(t)
call
TimerStart
(t,
GetRandomReal
(MinDur, MaxDur),
false
,
function
Loop)
set
t =
null
endfunction
private
function
init
takes
nothing
returns
nothing
set
W =
AddWeatherEffect
(
GetWorldBounds
(), Rain)
call
TimerStart
(
CreateTimer
(),
GetRandomReal
(MinDur, MaxDur),
false
,
function
Loop)
endfunction
endscope
Weather RawCodes
Code: jass
globals
// Weather Type Constants
constant
integer
Ashenvale_Rain_Heavy =
'RAhr'
constant
integer
Ashenvale_Rain_Light =
'RAlr'
constant
integer
Dalaran_Shield =
'MEds'
constant
integer
Dungeon_Blue_Fog_Heavy =
'FDbh'
constant
integer
Dungeon_Blue_Fog_Light =
'FDbl'
constant
integer
Dungeon_Green_Fog_Heavy =
'FDgh'
constant
integer
Dungeon_Green_Fog_Light =
'FDgl'
constant
integer
Dungeon_Red_Fog_Heavy =
'FDrh'
constant
integer
Dungeon_Red_Fog_Light =
'FDrl'
constant
integer
Dungeon_White_Fog_Heavy =
'FDwh'
constant
integer
Dungeon_White_Fog_Light =
'FDwl'
constant
integer
Lordaeron_Rain_Heavy =
'RLhr'
constant
integer
Lordaeron_Rain_Light =
'RLlr'
constant
integer
Northrend_Blizzard =
'SNbs'
constant
integer
Northrend_Snow_Heavy =
'SNhs'
constant
integer
Northrend_Snow_Light =
'SNls'
constant
integer
Outland_Wind_Heavy =
'WOcw'
constant
integer
Outland_Wind_Light =
'WOlw'
constant
integer
Rays_Of_Light =
'LRaa'
constant
integer
Rays_Of_Moonlight =
'LRma'
constant
integer
Wind_Heavy =
'WNcw'
// End Weather type Constants...
endglobals
«
Last Edit: December 21, 2017, 12:05:33 PM by moyack
»
WC3 Modding Information Center
Print
Pages:
1
Go Up
« previous
next »
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Warcraft III Resources
Warcraft III Spells and Systems
Codes & Snippets
Random weather script
Suggested Topics
InjuryEffectScript
Started by
moyack
Replies: 0
Views: 1612
Codes & Snippets
[reference] common.j
Started by
moyack
Replies: 40
Views: 58668
Jass Theory & Questions
Tutorial about jetscript??
Started by
moyack
Replies: 1
Views: 7099
JetScript
Jetscript BBcode testing
Started by
moyack
Replies: 5
Views: 10223
JetScript
PortaMx-SEF 1.54
|
PortaMx © 2008-2015
,
PortaMx corp.
Search
Username
Password
Always stay logged in
Forgot your password?