PDA

View Full Version : Development: RNG and Weather

Hiroshi Sotomura
January 1st, 2010, 9:22 PM
This is actually something that's already been done (and can be redone again here) - a weather RNG script which I actually haven't used in rijonAdventures. It's a long read, though. I want to implement this eventually, but maybe we can create a script out of this now. Think anyone has any contributions? Ideas? Can someone create a script? (And if the script doesn't work, this forum also means we can find out why it doesn't work and make sure it works. That's the point of Research and Development!)

Also, this idea is for all games, and I'd prefer that it isn't transferred if it dies.

---------------------
This is certainly not an original idea. In fact, it’s something that I’ve seen long before – the first person to demonstrate it of whose name I forget designed it for his hack, Pokémon Dirt Brown (which, mind you, actually has no relation to Pokémon Brown and never made it to the public… as the person had lost interest).

Using RNG, I’ve thought up a similar system. It might actually be the same as this one; I’ll never know since the hack never released. My system (which I actually wrote on paper but now the sheet’s disappeared) involves changing weather depending on certain variables to another weather condition. For example, if it’s sunny in a map at the moment, then there may be a small chance that the sky will become cloudy (and then, the area will seemingly dim) when the player enters another map. When the player enters another map, there’s a chance that it will start raining, or it will become clear again. (Perhaps the chance that it starts raining will be somewhat high.) Enter another map, and the rain will either clear instantaneously (low chance), the rain will stop and the map will return to a cloudy state (high chance), or, for the worst possible condition, a thunderstorm will occur (low, low chance).

Perhaps if structured out, the script would look like, though my sheet of paper did it better so this might not work:

Variables values reserved:
1 = normal, 2 = cloudy, 3 = rain, 4 = thunderstorm, 5 = light fog, 6 = thick fog, 7 = diagonal fog
(5, 6, and 7 will not be used in this sample structure.)

Perhaps I’ll keep in mind that, upon switching to a different map where ever the script is loaded:
- If its currently sunny, 2/20 that it will be cloudy, 17/20 that it will remain sunny, and 1/20 determining that it will suddenly start raining.
- If it’s cloudy, 5/20 chance that it will suddenly become sunny again, 2/10 that it will remain cloudy, and 10/20 chance that it will suddenly rain. 3/20 chance that the player will be slapped with a thunderstorm.
- If it’s currently raining, make a 3/20 chance that a thunderstorm will start, 7/20 that it will continue raining, 2/20 that the rain will cut out, and 8/20 that the rain will stop but the area remains cloudy.
- Finally, if a thunderstorm has popped up, leave a 13/20 chance that it will reduce into rain again, 3/20 that it’ll quickly become cloudy, and a 4/20 chance that it will continue as-is.

Due to how the script is formatted, if the player enters a map where the script isn’t already implemented, the conditions in the maps prior will remain. So, if I entered a house in the town where the script was, when I exit, the RNG magic will start again.

Main script

- Check variable for weather condition set between maps
– If variable = 1, go to RNG script 1 (sets conditions when normal)
– If variable = 2, go to RNG script 2 (sets conditions when cloudy)
– If variable = 3, go to RNG script 3 (sets conditions when raining)
– If variable = 4, go to RNG script 4 (sets conditions during thunderstorm)

RNG script 1

- Start RNG, set to 20 (is this meant to be an integer value?) and store into LASTRESULT.
– Copy LASTRESULT to variable.
– (Following the chances set above) If RNG returns 0 (treat as hex?), go to script that sets weather to cloudy.
– If RNG returns 1, set to cloudy.
– If RNG returns 2, run script that ends script without doing anything.
– If RNG returns 3, do nothing.
– If RNG returns 4, do nothing.
(the rest of the script would be rinse and repeat of RNGs and such, so it’s cut for brevity)
---------------------------------------------------------------

interdpth
January 1st, 2010, 9:32 PM
I'd prefer seeing the RNG script as assembly and not a script and it'd be able to store the value in lastresult pretty easily.

Then an example script would be like

#define normal 1
#define cloudy 2
etc

call asm \$blah 'rng number will be stored here
cmp lastresult normal
if 1 goto normalscript
cmp lastresult cloudy
if 1 goto cloudyscript
etc
I see something like that being much perferable

Hiroshi Sotomura
January 1st, 2010, 10:01 PM
Would such an idea be possible to implement in all maps, akin to say, the Day and Night scripts? Or would that call for a big recode of sorts?

I guess embedding in the code rather than storing values would be quite an idea too.

interdpth
January 1st, 2010, 10:04 PM
Hmm, a easy solution i'd see is to make the script for one town, make sure it'd work, then place a hook in the level loading script before the map script( so map script over rides your weather) the asm hook would make your script execute every time a level loads, I see that as very feasible, i'd be willing to make the hook for FR/LG if you or some one can do the scripting

Hiroshi Sotomura
January 1st, 2010, 10:31 PM
This huge script (http://www.pokecommunity.com/showpost.php?p=5231563&postcount=963) by colcolstyles has an implementation of the weatherwork above. Thing is, I haven't actually been able to work it.

January 1st, 2010, 10:32 PM
first off, i like where this is going
second, when you enter the maps like indoors it would run by your last comment, but i believe that you could get around that, or that it isn't even a problem to start with.
and interdpth, with the RTC for Fr/Lg you have, this could inevitably be a staple for all hacking

interdpth
January 1st, 2010, 10:37 PM
This huge script (http://www.pokecommunity.com/showpost.php?p=5231563&postcount=963) by colcolstyles has an implementation of the weatherwork above. Thing is, I haven't actually been able to work it.

heh, I think that that's just an example what with those variables and all.

DreadWaffles post made me think of numerous possibilities this effect could have with the day and night systems.

I think amazing effects can be pulled off with this.

January 1st, 2010, 10:56 PM
DreadWaffles post made me think of numerous possibilities this effect could have with the day and night systems.

SUCSESS!

This huge script (http://www.pokecommunity.com/showpost.php?p=5231563&postcount=963) by colcolstyles has an implementation of the weatherwork above. Thing is, I haven't actually been able to work it.

that helps me understand it a bit more, so thanks Anthony colcolstyles
just so many things, and it seems simple, but it isn't i believe
this kind of opens up a whole new world of scripting ideas for me, i would make a thread but i don't know to much hex :laugh:

but i have some ideas like adding onto what was already there
EX: if it is 6:00pm-6:00am chances from sunny(clear) to: Clouds 7/20, Rain 3/20, the same 8/20 and, Thunderstorm 2/20.
and also for different areas like snow/ice, lake affect, valleys, and droughts
I have realized that if this works out possibilities are near endless

just wish i could help :'(

Darthatron
January 2nd, 2010, 2:33 AM
This probably won't be anything interdpth doesn't know already but here is some information about the RAM regarding weather:

The default weather for a map is stored at 0x02036E12 in the RAM, it's 8 bit by the way. Surely this can be used to create maps with a higher chance of a certain weather than other.

And the 8 bit value at 0x02036E13 contains the type of map.
0x01 - Village/Town
0x02 - City
0x03 - Route
0x04 - Underground
0x05 - Underwater
0x08 - Inside
0x09 - Secret base
Obviously the ones in bold would not be effected by weather.

EDIT: Tell me if you think I should just edit this new information into the script that has been posted, it won't be difficult.

EDIT2: As it turns out I have already created a similar script a while ago, though I only have the compiled version at the moment I can easily edit it to your needs... I'll implement my RAM data and also your preferred likeliness of weather, then post it.

Hiroshi Sotomura
January 2nd, 2010, 3:11 AM
There actually a command that reads the set map value, though?

Darthatron
January 2nd, 2010, 3:35 AM
There actually a command that reads the set map value, though?

Not for someone who doesn't know there way around the ROM:
setvar 0x8000 0x0000
copybyte 0x020370B8 0x02036E12
setvar 0x8001 0x0000
copybyte 0x020370BA 0x02036E13

That script will store the default weather in variable 0x8000, and the map type in variable 0x8001.

Hiroshi Sotomura
January 2nd, 2010, 4:27 AM
However, the point is for the script to read a variable that's stored - preferably permanently. The "current condition" in this script intentionally reads from a stored value to determine what the weather was at one point. Once the current variable is found, the script runs an RNG specified by the hacker to determine the next condition. There is little use in reading the variable for the map's weather unless one of the bytes determined whether to disable the script.

Darthatron
January 2nd, 2010, 4:41 AM
However, the point is for the script to read a variable that's stored - preferably permanently. The "current condition" in this script intentionally reads from a stored value to determine what the weather was at one point. Once the current variable is found, the script runs an RNG specified by the hacker to determine the next condition. There is little use in reading the variable for the map's weather unless one of the bytes determined whether to disable the script.

To an extent, yes. But think of it this way: You're more likely to have snow in the mountains than, say, the beach. Simply enabling certain maps to have more of a chance of certain weather may be an upside. I do see your point, however.

EDIT: One working natural weather script that won't work indoors.

#dynamic 0x800000

#define V_MAPTYPE 0x8000
#define V_WEATHER 0x7000 //This must be set to a value between 1 and 4 to work.
#define V_RANDVAL 0x7001

#define W_SUNNY 0x02
#define W_CLOUDY 0x0B
#define W_RAIN 0x03
#define W_THUNDER 0x0D

#org @Setup
setvar V_WEATHER 0x01
setweather W_SUNNY
doweather
end

#org @Main
setvar 0x8000 0x0000
copybyte 0x020370B8 0x02036E13
compare 0x8000 0x03
if B_>> goto @Quit
random 0x13 //Create a random value between 0 and 19.
copyvar V_RANDVAL LASTRESULT
compare V_WEATHER 0x01
if B_TRUE call @CurrentlySunny
compare V_WEATHER 0x02
if B_TRUE call @CurrentlyCloudy
compare V_WEATHER 0x03
if B_TRUE call @CurrentlyRaining
compare V_WEATHER 0x04
if B_TRUE call @CurrentlyStorming
doweather
end

#org @Quit
end

#org @BecomeSunny
setweather W_SUNNY
setvar V_WEATHER 0x01
setvar V_RANDVAL 0xFF //Make the random value an impossible number to make sure it can't mess up.
return

#org @BecomeCloudy
setweather W_CLOUDY
setvar V_WEATHER 0x02
setvar V_RANDVAL 0xFF //Make the random value an impossible number to make sure it can't mess up.
return

#org @BecomeRaining
setweather W_RAIN
setvar V_WEATHER 0x03
setvar V_RANDVAL 0xFF //Make the random value an impossible number to make sure it can't mess up.
return

#org @BecomeStorming
setweather W_THUNDER
setvar V_WEATHER 0x04
setvar V_RANDVAL 0xFF //Make the random value an impossible number to make sure it can't mess up.
return

#org @CurrentlySunny
compare V_RANDVAL 0x01 //10% chance of becoming cloudly.
if B_<= call @BecomeCloudy
compare V_RANDVAL 0x02 //5% chance of it raining.
if B_<= call @BecomeRaining
compare V_RANDVAL 0x13 //85% chance of the weather staying the same.
if B_<= call @BecomeSunny
return

#org @CurrentlyCloudy
compare V_RANDVAL 0x04 //25% chance of becoming sunny.
if B_<= call @BecomeSunny
compare V_RANDVAL 0x06 //10% chance of it staying cloudy.
if B_<= call @BecomeCloudy
compare V_RANDVAL 0x10 //50% chance that it will start raining.
if B_<= call @BecomeRaining
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= call @BecomeStorming
return

#org @CurrentlyRaining
compare V_RANDVAL 0x06 //35% chance that it will keep raining.
if B_<= call @BecomeRaining
compare V_RANDVAL 0x08 //10% chance of it becoming sunny.
if B_<= call @BecomeSunny
compare V_RANDVAL 0x10 //40% chance that it will become cloudy.
if B_<= call @BecomeCloudy
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= call @BecomeStorming
return

#org @CurrentlyStorming
compare V_RANDVAL 0x0C //65% chance that it will start raining.
if B_<= call @BecomeRaining
compare V_RANDVAL 0x0F //15% chance of it becoming cloudy
if B_<= call @BecomeCloudy
compare V_RANDVAL 0x13 //20% chance that the thunder storm will continue.
if B_<= call @BecomeStorming
return

I tested it quite a bit and it worked fine, but if you find a problem, just tell me...

You won't need the bold lines if you're manually putting them on each map.
The italic lines are there merely the set up the script to work, you don't run this from the level script, you run @Main.

Pokepal17
January 2nd, 2010, 6:51 AM
Hmm, there is one other graphical problem you need to get around. As in Liquid Crystal, when the weather is forced to be changed by the "setweather" command, sometimes the weather palette doesn't refresh. I don't know whether that's secific to that hack, but I believe it will apply to all ROMs because I've noticed that the natural weather change from maps is not immediate. I would say that instead of using "setweather" edit it directly from the ram. (However this might still do the same things which would cause for maybe a big recoding :0)

Hiroshi Sotomura
January 2nd, 2010, 3:50 PM
Is it just an issue with FRLG (because weather almost doesn't exist in the game by default) or is the issue also there in RSE?

Pokepal17
January 2nd, 2010, 5:30 PM
Is it just an issue with FRLG (because weather almost doesn't exist in the game by default) or is the issue also there in RSE?

I don't know. I assume it probably is since FRLG was built of the RSE engine. It's okay switching back and forth from one weather effect, but when it's 3 or 4 different forced weather effects, the palette bug kicks in. Recoding would probably work, but I'm wondering if there's a less tedious way.

Darthatron
January 2nd, 2010, 5:57 PM
Hmm, there is one other graphical problem you need to get around. As in Liquid Crystal, when the weather is forced to be changed by the "setweather" command, sometimes the weather palette doesn't refresh. I don't know whether that's secific to that hack, but I believe it will apply to all ROMs because I've noticed that the natural weather change from maps is not immediate. I would say that instead of using "setweather" edit it directly from the ram. (However this might still do the same things which would cause for maybe a big recoding :0)

I've never experienced that problem and last night I spent over an hour testing that script. :\ Think you can make a video example of it happening?

Pokepal17
January 2nd, 2010, 6:33 PM
I've never experienced that problem and last night I spent over an hour testing that script. :\ Think you can make a video example of it happening?

There probably is in a lot of Liquid Crystal walkthroughs. However, I have never encountered ot myself, so I don't know whether it was specific to that hack, but I was just making you guys aware of it, I'll find a vid of it, however if testing doesn't prove it, then it can be said that the bug is only limited to that hack.

EDIT: It seems that his bug was confined to Liquid Crystal only, so ignore it for now.

colcolstyles
January 2nd, 2010, 6:49 PM
I was using a Fire Red ROM when I was testing my script and I never encountered any problems. I was using a "01 'setmaptile' script" level script, if that makes any difference.

Darthatron
January 2nd, 2010, 7:00 PM
I was using a Fire Red ROM when I was testing my script and I never encountered any problems. I was using a "01 'setmaptile' script" level script, if that makes any difference.
I saw a pretty major problem in your script:

Say V_RANDVAR = 1...
#org @sunnyscript
compare V_RANDVAR 0x1 ' 2/20 chance of becoming cloudy
if B_<= goto @becomecloudy
compare V_RANDVAR 0x2 ' 1/20 chance of spontaneous rain
if B_<= goto @becomerainy
setweather W_SUNNY ' 17/20 chance of remaining the same
return
It would set the weather cloudy, then set the weather to rain, and finally set it back to sunny. This is because the value of V_RANDVAR is kept the entire script, so nothing can ever change.

I don't know how you would have got it to work. :\

colcolstyles
January 2nd, 2010, 7:04 PM
I saw a pretty major problem in your script:

Say V_RANDVAR = 1...
#org @sunnyscript
compare V_RANDVAR 0x1 ' 2/20 chance of becoming cloudy
if B_<= goto @becomecloudy
compare V_RANDVAR 0x2 ' 1/20 chance of spontaneous rain
if B_<= goto @becomerainy
setweather W_SUNNY ' 17/20 chance of remaining the same
return
It would set the weather cloudy, then set the weather to rain, and finally set it back to sunny. This is because the value of V_RANDVAR is kept the entire script, so nothing can ever change.

I don't know how you would have got it to work. :\

I'm going to say right now that this explanation is going to suck but I'll give it my best shot.

In @main, @sunnyscript is called. However, in @sunnyscript (and the other corresponding scripts), @becomecloudy is accessed with 'goto'. So when the GBA reads the 'return' statement in @becomecloudy, it actually picks up where it left off all the way back in @main.

Hopefully you see what I did. It's a little hard to read because Pokémon scripting doesn't have "else if" statements.

I tested it quite a bit and it worked pretty darn well, if I may say so myself.

Darthatron
January 2nd, 2010, 7:12 PM
I'm going to say right now that this explanation is going to suck but I'll give it my best shot.

In @main, @sunnyscript is called. However, in @sunnyscript (and the other corresponding scripts), @becomecloudy is accessed with 'goto'. So when the GBA reads the 'return' statement in @becomecloudy, it actually picks up where it left off all the way back in @main.

Hopefully you see what I did. It's a little hard to read because Pokémon scripting doesn't have "else if" statements.

I tested it quite a bit and it worked pretty darn well, if I may say so myself.

I see your point now actually, I completely ignored that fact, sorry. Well then... I wonder why your script didn't work for Anthony La. :\

On a side note, your script should have "random 0x13" since it would give a random value between 0 and 19. Your current script is out of 21 possible situations, not 20. ;)

colcolstyles
January 2nd, 2010, 7:24 PM
I see your point now actually, I completely ignored that fact, sorry. Well then... I wonder why your script didn't work for Anthony La. :\

On a side note, your script should have "random 0x13" since it would give a random value between 0 and 19. Your current script is out of 21 possible situations, not 20. ;)

Ah, good catch. Strange, though, because I factored the possibility of 'random' returning zero into several parts of the script. You would think that I would have picked up on that. Oh well, simple fix.

Though the part that you originally pointed out seems to be correct, I think I just spotted another bug. Again, I'm terrible at explaining things but bear with me here:

Let's say the weather is currently sunny. Control would branch off to @sunnyscript. Now let's say the random number that was returned 0x1, which would therefore activate @becomecloudy. However, in @becomecloudy, V_WEATHER is actually changed to W_CLOUDY. This might cause a bug when control returns to @main because the script will check if V_WEATHER is set to W_CLOUDY. Because of this, it would be possible for it to go straight to a thunderstorm from sunny and it also increases chances of spontaneous rain too.
It can be fixed by replacing all the "call"s in @main to "goto"s and then changing the "return"s in @becomesunny/cloudy/etc. to "goto @end" and adding:
#seek @end
doweather
end
... I think. But then again, you're the programmer. :P

Darthatron
January 2nd, 2010, 7:35 PM
Ah, good catch. Strange, though, because I factored the possibility of 'random' returning zero into several parts of the script. You would think that I would have picked up on that. Oh well, simple fix.

Though the part that you originally pointed out seems to be correct, I think I just spotted another bug. Again, I'm terrible at explaining things but bear with me here:

Let's say the weather is currently sunny. Control would branch off to @sunnyscript. Now let's say the random number that was returned 0x1, which would therefore activate @becomecloudy. However, in @becomecloudy, V_WEATHER is actually changed to W_CLOUDY. This might cause a bug when control returns to @main because the script will check if V_WEATHER is set to W_CLOUDY. Because of this, it would be possible for it to go straight to a thunderstorm from sunny and it also increases chances of spontaneous rain too.
It can be fixed by replacing all the "call"s in @main to "goto"s and then changing the "return"s in @becomesunny/cloudy/etc. to "goto @end" and adding:
#seek @end
doweather
end
... I think. But then again, you're the programmer. :P

That definitely seems logical. Try it out and if it doesn't work then no harm is done, right? :P But yeah, from my point of view that should work. Good catch, by the way.

EDIT: It would save space to just replace the "return"s with the code you posted. "goto" uses 5 bytes, but...
doweather
end
...uses 2 bytes. ;)

EDIT2: Here is my script which will be quicker and save space. :)
#dynamic 0x800000

#define V_MAPTYPE 0x8000
#define V_WEATHER 0x7000 //This must be set to a value between 1 and 4 to work.
#define V_RANDVAL 0x7001

#define W_SUNNY 0x02
#define W_CLOUDY 0x0B
#define W_RAIN 0x03
#define W_THUNDER 0x0D

#org @Setup
setvar V_WEATHER 0x01
setweather W_SUNNY
doweather
end

#org @Main
setvar 0x8000 0x0000
copybyte 0x020370B8 0x02036E13
compare 0x8000 0x03
if B_>> goto @Quit
random 0x13 //Create a random value between 0 and 19.
copyvar V_RANDVAL LASTRESULT
compare V_WEATHER 0x01
if B_TRUE goto @CurrentlySunny
compare V_WEATHER 0x02
if B_TRUE goto @CurrentlyCloudy
compare V_WEATHER 0x03
if B_TRUE goto @CurrentlyRaining
compare V_WEATHER 0x04
if B_TRUE goto @CurrentlyStorming
end

#org @Quit
end

#org @BecomeSunny
setweather W_SUNNY
setvar V_WEATHER 0x01
doweather
end

#org @BecomeCloudy
setweather W_CLOUDY
setvar V_WEATHER 0x02
doweather
end

#org @BecomeRaining
setweather W_RAIN
setvar V_WEATHER 0x03
doweather
end

#org @BecomeStorming
setweather W_THUNDER
setvar V_WEATHER 0x04
doweather
end

#org @CurrentlySunny
compare V_RANDVAL 0x01 //10% chance of becoming cloudly.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x02 //5% chance of it raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //85% chance of the weather staying the same.
if B_<= goto @BecomeSunny
end

#org @CurrentlyCloudy
compare V_RANDVAL 0x04 //25% chance of becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x06 //10% chance of it staying cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x10 //50% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyRaining
compare V_RANDVAL 0x06 //35% chance that it will keep raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x08 //10% chance of it becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x10 //40% chance that it will become cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyStorming
compare V_RANDVAL 0x0C //65% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x0F //15% chance of it becoming cloudy
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //20% chance that the thunder storm will continue.
if B_<= goto @BecomeStorming
end

colcolstyles
January 2nd, 2010, 7:42 PM
That definitely seems logical. Try it out and if it doesn't work then no harm is done, right? :P But yeah, from my point of view that should work. Good catch, by the way.

Man, all that time spent coordinating the "call"s and "goto"s and now I don't even need them. :'(

I don't know if I should even bother fixing it as it seems like interdpth has some snazzy ASM plan which makes my method look pretty rudimentary. With mine, you have to add a level script for every single map that you want random weather on. Though the fact that you don't have to edit indoor maps (unless you want it to rain inside^^) makes things easier, it's still a hassle.

Still, I'm interested in seeing what you guys come up with. I could try to help out but my ASM knowledge is pretty pathetic. :(

Best of luck.

Darthatron
January 2nd, 2010, 7:49 PM
Man, all that time spent coordinating the "call"s and "goto"s and now I don't even need them. :'(

I don't know if I should even bother fixing it as it seems like interdpth has some snazzy ASM plan which makes my method look pretty rudimentary. With mine, you have to add a level script for every single map that you want random weather on. Though the fact that you don't have to edit indoor maps (unless you want it to rain inside^^) makes things easier, it's still a hassle.

Still, I'm interested in seeing what you guys come up with. I could try to help out but my ASM knowledge is pretty pathetic. :(

Best of luck.
The only thing he is planning on doing is making it so your or my script is called every time a map is loaded. I'll keep you updated. I think I have you added on MSN? :\

interdpth
January 2nd, 2010, 7:58 PM
SOmeone make a script that everyone agree's on, and i'll hack the level loading routines and make it execute.

DEAL?

colcolstyles
January 2nd, 2010, 8:33 PM
'----------------------------------------------------------------
' Natural Weather Script
' By colcolstyles
' 10/17/2009
' As the player moves from one map to the next, the weather has
' the possibility of changing. Both the type of weather that
' might begin and the odds of a change occurring depend on
' the current weather (actual odds given in script). This script
' also contains an available option for manual override; the
' hacker can (by setting the OVERRIDE flag) specify a particular
' weather to be used, thus deactivating the random weather.
'----------------------------------------------------------------

#erase 0x800000 0x100
#dynamic 0x800000

#define V_WEATHER 0x7000
#define V_RANDVAR 0x7001
#define F_OVERRIDE 0x500
#define W_SUNNY 0x2
#define W_CLOUDY 0xB
#define W_RAIN 0x3
#define W_THUNDER 0xD

'----------------------------------------------------------------

#org @main
compare F_OVERRIDE B_TRUE
if B_== goto @manual
random 0x13
copyvar V_RANDVAR LASTRESULT
compare V_WEATHER W_SUNNY
if B_== goto @sunnyscript
compare V_WEATHER W_CLOUDY
if B_== goto @cloudyscript
compare V_WEATHER W_RAIN
if B_== goto @rainscript
compare V_WEATHER W_THUNDER
if B_== goto @thunderscript
end

'----------------------------------------------------------------

#org @sunnyscript
compare V_RANDVAR 0x1 ' 2/20 chance of becoming cloudy
if B_<= goto @becomecloudy
compare V_RANDVAR 0x2 ' 1/20 chance of spontaneous rain
if B_<= goto @becomerainy
setweather W_SUNNY ' 17/20 chance of remaining the same
goto @end

#org @cloudyscript
compare V_RANDVAR 0x4 ' 5/20 chance of becoming sunny
if B_<= goto @becomesunny
compare V_RANDVAR 0xE ' 10/20 chance of becoming rainy
if B_<= goto @becomerainy
compare V_RANDVAR 0x11 ' 3/20 chance of thunderstorm
if B_<= goto @becomethunder
setweather W_CLOUDY ' 2/20 chance of remaining the same
goto @end

#org @rainscript
compare V_RANDVAR 0x2 ' 3/20 chance of thunderstorm
if B_<= goto @becomethunder
compare V_RANDVAR 0xA ' 8/20 chance of rain stopping but remaining cloudy
if B_<= goto @becomecloudy
compare V_RANDVAR 0xC ' 2/20 of rain cutting out completely
if B_<= goto @becomesunny
setweather W_RAIN ' 7/20 chance of remaining the same
goto @end

#org @thunderscript
compare V_RANDVAR 0xC ' 13/20 chance of reducing to rain
if B_<= goto @becomerainy
compare V_RANDVAR 0xF ' 3/20 chance of suddenly reducing cloudy
if B_<= goto @becomecloudy
setweather W_RAIN ' 4/20 chance of remaining the same
goto @end

'----------------------------------------------------------------

#org @becomesunny
setvar v_WEATHER W_SUNNY
setweather W_SUNNY
goto @end

#org @becomecloudy
setvar V_WEATHER W_CLOUDY
setweather W_CLOUDY
goto @end

#org @becomerainy
setvar V_WEATHER W_RAIN
setweather W_RAIN
goto @end

#org @becomethunder
setvar V_WEATHER W_THUNDER
setweather W_THUNDER
goto @end

'----------------------------------------------------------------

#org @manual
setweather V_WEATHER
doweather
end

'----------------------------------------------------------------

#org @end
doweather
end

'----------------------------------------------------------------

I looked through the script and I realized that a "goto @end" is also necessary at the end of @sunnyscript and its corresponding scripts.

This hasn't been fully tested yet but it's nearing the final stages. Does anyone have any other ideas that they want added? I've already added manual override and the ability to disable the random weather at any time but if there are any other features that you think would be nice to have, just speak up and I'm sure we can figure out how to implement them.

Hiroshi Sotomura
January 2nd, 2010, 9:19 PM
I looked through the script and I realized that a "goto @end" is also necessary at the end of @sunnyscript and its corresponding scripts.

This hasn't been fully tested yet but it's nearing the final stages. Does anyone have any other ideas that they want added? I've already added manual override and the ability to disable the random weather at any time but if there are any other features that you think would be nice to have, just speak up and I'm sure we can figure out how to implement them.
I guess we'll need to try and fully test it if you're satisfied. I know I am.

colcolstyles
January 2nd, 2010, 9:21 PM
I guess we'll need to try and fully test it if you're satisfied. I know I am.

Well, Darthatron and I have been talking and we're working on a better version. If you have MSN you can join us, actually.

edit: We think we're nearing in on a final version but we're still testing it. We'll keep you updated.

edit2: Well we think we have finally agreed on a script. We've tested it too and as far as we can tell, it works like we want it to. Now all we need is for interdpth to work his magic.

Here's the script:
//----------------------------------------------------------------
// Natural Weather Script
// Script by Darthatron and colcolstyles, original concept and odds by Anthony La
// 1/2/10
// This script will create a system which aims to simulate the
// "real world" weather by randomly switching between weather
// effects (sunny, cloudy, raining, and thunderstorm). The odds of
// a change occurring depend on the current weather (i.e. it is
// more likely to start raining when it is already cloudy than
// when it is sunny). However, random weather will only occur if
// the weather type on the player's current map is set to 0x0F.
// Because of this, the hacker can make a map use a preset weather
// condition and be exempt from random weather. The script will
// also only activate on maps of type Village, City, and Route to
// ensure that it does not rain inside or in a cave.
//----------------------------------------------------------------

#erase 0x800000 0xFFF
#dynamic 0x800000

#define V_DEFAULT 0x8000
#define V_WEATHER 0x7000 //This must be set to a value between 1 and 4 to work.
#define V_RANDVAL 0x7001

#define A_WEATHER 0x02036E12
#define A_MAPTYPE 0x02036E13
#define A_DEFAULT 0x020370B8

#define W_SUNNY 0x02
#define W_CLOUDY 0x0B
#define W_RAIN 0x03
#define W_THUNDER 0x0D

#org @Setup
setvar V_WEATHER 0x01
setweather W_SUNNY
doweather
end

#org @Main
setvar V_DEFAULT 0x0000
copybyte A_DEFAULT A_WEATHER //Grabs the default map weather and stores it in V_DEFAULT
compare V_DEFAULT 0x0F
if B_<< goto @Quit
copybyte A_DEFAULT A_MAPTYPE //Grabs the map type and stores it in V_DEFAULT
compare V_DEFAULT 0x03
if B_>> goto @Quit
random 0x13 //Create a random value between 0 and 19.
copyvar V_RANDVAL LASTRESULT
compare V_WEATHER 0x01
if B_TRUE goto @CurrentlySunny
compare V_WEATHER 0x02
if B_TRUE goto @CurrentlyCloudy
compare V_WEATHER 0x03
if B_TRUE goto @CurrentlyRaining
compare V_WEATHER 0x04
if B_TRUE goto @CurrentlyStorming
end

#org @Quit
end

#org @BecomeSunny
setweather W_SUNNY
setvar V_WEATHER 0x01
doweather
end

#org @BecomeCloudy
setweather W_CLOUDY
setvar V_WEATHER 0x02
doweather
end

#org @BecomeRaining
setweather W_RAIN
setvar V_WEATHER 0x03
doweather
end

#org @BecomeStorming
setweather W_THUNDER
setvar V_WEATHER 0x04
doweather
end

#org @CurrentlySunny
compare V_RANDVAL 0x01 //10% chance of becoming cloudly.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x02 //5% chance of it raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //85% chance of the weather staying the same.
if B_<= goto @BecomeSunny
end

#org @CurrentlyCloudy
compare V_RANDVAL 0x04 //25% chance of becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x06 //10% chance of it staying cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x10 //50% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyRaining
compare V_RANDVAL 0x06 //35% chance that it will keep raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x08 //10% chance of it becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x10 //40% chance that it will become cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyStorming
compare V_RANDVAL 0x0C //65% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x0F //15% chance of it becoming cloudy
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //20% chance that the thunder storm will continue.
if B_<= goto @BecomeStorming
end

Hiroshi Sotomura
January 3rd, 2010, 1:10 AM
Of note, is it fully necessary to define the ONE weather byte that the script activates on AND ensure it doesn't activate in certain areas? Sounds like an unnecessary measure when it's up to the hacker to set which weather byte activates it.

0m3GA ARS3NAL
January 3rd, 2010, 1:10 AM
Well well well, stuff happened pretty fast!
I wasn't even here for the initial idea pitch, oh well.
I've tried out this script a bit on my PSP, and all goes well, well indeed.
I know for a fact that people nowadays have the strangest fascination with snowy maps in a ROM hack, and if someone makes a snowy mountain, how would this random weather be incorporated...
I guess as of yet one could simply change the "Storm" and "Rain" to things like "3 Snowflakes" and the Ash snow used in R/S/E...
But that would require compiling a completely different script, and if someone were to cross maps while things are stormy, to a map intended to have the chance of snow, things may get a little buggy.

Darthatron
January 3rd, 2010, 1:23 AM
Of note, is it fully necessary to define the ONE weather byte that the script activates on AND ensure it doesn't activate in certain areas? Sounds like an unnecessary measure when it's up to the hacker to set which weather byte activates it.
You make a valid point. It's not difficult to simply get rid of that check, as it's only 3 lines. Here is an updated version for you:
//----------------------------------------------------------------
// Natural Weather Script!
//----------------------------------------------------------------
// By colcolstyles and Darthatron (3/1/2010)
//----------------------------------------------------------------
// This script will create a system which aims to simulate the
// "real world" weather by randomly switching between weather
// effects (sunny, cloudy, raining, and thunderstorm). The odds of
// a change occurring depend on the current weather (i.e. it is
// more likely to start raining when it is already cloudy than
// when it is sunny). However, random weather will only occur if
// the weather type on the player's current map is set to 0x0F.
// Because of this, the hacker can make a map use a preset weather
// condition and be exempt from random weather.
//----------------------------------------------------------------

#erase 0x800000 0xFFF
#dynamic 0x800000

#define V_DEFAULT 0x8000
#define V_WEATHER 0x7000 //This must be set to a value between 1 and 4 to work.
#define V_RANDVAL 0x7001

#define A_WEATHER 0x02036E12
#define A_MAPTYPE 0x02036E13
#define A_DEFAULT 0x020370B8

#define W_SUNNY 0x02
#define W_CLOUDY 0x0B
#define W_RAIN 0x03
#define W_THUNDER 0x0D

#org @Setup
setvar V_WEATHER 0x01
setweather W_SUNNY
doweather
end

#org @Main
setvar V_DEFAULT 0x0000
copybyte A_DEFAULT A_WEATHER //Grabs the default map weather and stores it in V_DEFAULT
compare V_DEFAULT 0x0F
if B_<< goto @Quit
random 0x13 //Create a random value between 0 and 19.
copyvar V_RANDVAL LASTRESULT
compare V_WEATHER 0x01
if B_TRUE goto @CurrentlySunny
compare V_WEATHER 0x02
if B_TRUE goto @CurrentlyCloudy
compare V_WEATHER 0x03
if B_TRUE goto @CurrentlyRaining
compare V_WEATHER 0x04
if B_TRUE goto @CurrentlyStorming
end

#org @Quit
end

#org @BecomeSunny
setweather W_SUNNY
setvar V_WEATHER 0x01
doweather
end

#org @BecomeCloudy
setweather W_CLOUDY
setvar V_WEATHER 0x02
doweather
end

#org @BecomeRaining
setweather W_RAIN
setvar V_WEATHER 0x03
doweather
end

#org @BecomeStorming
setweather W_THUNDER
setvar V_WEATHER 0x04
doweather
end

#org @CurrentlySunny
compare V_RANDVAL 0x01 //10% chance of becoming cloudly.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x02 //5% chance of it raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //85% chance of the weather staying the same.
if B_<= goto @BecomeSunny
end

#org @CurrentlyCloudy
compare V_RANDVAL 0x04 //25% chance of becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x06 //10% chance of it staying cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x10 //50% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyRaining
compare V_RANDVAL 0x06 //35% chance that it will keep raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x08 //10% chance of it becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x10 //40% chance that it will become cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyStorming
compare V_RANDVAL 0x0C //65% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x0F //15% chance of it becoming cloudy
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //20% chance that the thunder storm will continue.
if B_<= goto @BecomeStorming
end
Well well well, stuff happened pretty fast!
I wasn't even here for the initial idea pitch, oh well.
I've tried out this script a bit on my PSP, and all goes well, well indeed.
I know for a fact that people nowadays have the strangest fascination with snowy maps in a ROM hack, and if someone makes a snowy mountain, how would this random weather be incorporated...
I guess as of yet one could simply change the "Storm" and "Rain" to things like "3 Snowflakes" and the Ash snow used in R/S/E...
But that would require compiling a completely different script, and if someone were to cross maps while things are stormy, to a map intended to have the chance of snow, things may get a little buggy.
If you can come up with the chances of the snow weathers happening then I would have no problem adding it in. I, however, am far too lazy to think of those values up. ^_^

0m3GA ARS3NAL
January 3rd, 2010, 2:02 AM
Well, the sown weather would be the one thing that would need to change depending on the map itself, what it looks like, I mean, even I could add that in myself, I know my way around a script, what I mean, is the off chance someone decides to want to use this for snow too.
Adding in a probability wouldn't help one bit, since even then snow could happen in a place such as a beach, or a rain forest, not exactly natural.
The best thing I can come up with is a variable the user would have to set themselves.... (Aside from @setup, where V_SNOW is set to 0, which can be removed fairly easily)

Here is a changed script for you to look at, changes in BOLD RED

//----------------------------------------------------------------
// Natural Weather Script!
//----------------------------------------------------------------
// By colcolstyles and Darthatron (3/1/2010)
// Revised for snow by 0m3GA ARS3NAL (2:15 AM -8 PST)
//----------------------------------------------------------------
// This script will create a system which aims to simulate the
// "real world" weather by randomly switching between weather
// effects (sunny, cloudy, raining, and thunderstorm). The odds of
// a change occurring depend on the current weather (i.e. it is
// more likely to start raining when it is already cloudy than
// when it is sunny). However, random weather will only occur if
// the weather type on the player's current map is set to 0x0F.
// Because of this, the hacker can make a map use a preset weather
// condition and be exempt from random weather. The hacker may
// now also set Variable 0x7002 to either 0 or 1 do define if the map
// the player is on will be a normal map, or a snowy one respectively.
//----------------------------------------------------------------

#erase 0x800000 0xFFF
#dynamic 0x800000

#define V_DEFAULT 0x8000
#define V_WEATHER 0x7000 //This must be set to a value between 1 and 5 to work.
#define V_RANDVAL 0x7001
#define V_SNOW 0x7002 //Set this to either 0 or 1, 0 to define normal weather, 1 for snow changes

#define A_WEATHER 0x02036E12
#define A_MAPTYPE 0x02036E13
#define A_DEFAULT 0x020370B8

#define W_SUNNY 0x02
#define W_CLOUDY 0x0B
#define W_RAIN 0x03
#define W_THUNDER 0x0D
#define W_SNOW 0x7

#org @Setup
setvar V_WEATHER 0x01
setvar V_SNOW 0x0
setweather W_SUNNY
doweather
end

#org @Main
setvar V_DEFAULT 0x0000
copybyte A_DEFAULT A_WEATHER //Grabs the default map weather and stores it in V_DEFAULT
compare V_DEFAULT 0x0F
if B_<< goto @Quit
random 0x13 //Create a random value between 0 and 19.
copyvar V_RANDVAL LASTRESULT
compare V_WEATHER 0x01
if B_TRUE goto @CurrentlySunny
compare V_WEATHER 0x02
if B_TRUE goto @CurrentlyCloudy
compare V_WEATHER 0x03
if B_TRUE goto @CurrentlyRaining
compare V_WEATHER 0x04
if B_TRUE goto @CurrentlyStorming
compare V_WEATHER 0x5
if B_TRUE goto @CurrentlySnowing
end

#org @Quit
end

#org @BecomeSunny
setweather W_SUNNY
setvar V_WEATHER 0x01
doweather
end

#org @BecomeCloudy
setweather W_CLOUDY
setvar V_WEATHER 0x02
doweather
end

#org @BecomeRaining
compare V_SNOW 0x1
if B_TRUE goto @BecomeSnowing
setweather W_RAIN
setvar V_WEATHER 0x03
doweather
end

#org @BecomeStorming
compare V_SNOW
if B_TRUE goto @BecomeSnowing
setweather W_THUNDER
setvar V_WEATHER 0x04
doweather
end

#org @BecomeSnowing
setweather W_SNOW
setvar V_WEATHER 0x5
doweather
end

#org @CurrentlySunny
compare V_RANDVAL 0x01 //10% chance of becoming cloudly.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x02 //5% chance of it raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //85% chance of the weather staying the same.
if B_<= goto @BecomeSunny
end

#org @CurrentlyCloudy
compare V_RANDVAL 0x04 //25% chance of becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x06 //10% chance of it staying cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x10 //50% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyRaining
compare V_RANDVAL 0x06 //35% chance that it will keep raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x08 //10% chance of it becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x10 //40% chance that it will become cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyStorming
compare V_RANDVAL 0x0C //65% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x0F //15% chance of it becoming cloudy
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //20% chance that the thunder storm will continue.
if B_<= goto @BecomeStorming
end

#org @CurrentlySnowing
compare V_RANDVAL 0x2 //15% chance of it becoming cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //85% Chance that the snow will continue.
if b_<== goto @BecomeSnowing
end

Hiroshi Sotomura
January 3rd, 2010, 4:01 AM
I somehow don't find this to be "natural" weather anymore.

Of note, Matt, will you be calling this script from the header while leaving it modifiable?

colcolstyles
January 3rd, 2010, 6:36 PM
Of note, Matt, will you be calling this script from the header while leaving it modifiable?

It was my understanding that the script would be accessed by the ASM routine, making the script modifiable at any time.

Of note, is it fully necessary to define the ONE weather byte that the script activates on AND ensure it doesn't activate in certain areas? Sounds like an unnecessary measure when it's up to the hacker to set which weather byte activates it.

Actually, interdpth also wanted to get rid of the "check 0xF" part so if you don't want that part in the script either, then can just remove it without harming anything. However, I would argue that the "check 0xF" function is beneficial because it allows a hacker to make a map use a fixed weather condition for a map if they want without having to change the map type to indoors or something like that. It may not be the most realistic if a town always has rain but I could imagine that hackers might enjoy that option.

Eh, it's really up to you and if you don't want it, then just use the modified script that Darthatron posted.

//----------------------------------------------------------------
// condition and be exempt from random weather. The hacker may
// now also set Variable 0x7002 to either 0 or 1 do define if the map
// the player is on will be a normal map, or a snowy one respectively.
//----------------------------------------------------------------

...

Gah! You went over the character limit! My beautiful header text!

In my opinion, I think snow is just unnecessary. If the only conditions that the script can alter between are "3 snowflakes" and "snowing", it just doesn't seem worth it to me. I think the hacker would be better off setting a fixed condition seeing how they know how the map is going to look and can decide whether light or heavy snow is more realistic.

altariaking
January 3rd, 2010, 7:02 PM
where do you put the script after compiling it?

Darthatron
January 3rd, 2010, 7:05 PM
It was my understanding that the script would be accessed by the ASM routine, making the script modifiable at any time.
That's what he told me he was going to do.
In my opinion, I think snow is just unnecessary. If the only conditions that the script can alter between are "3 snowflakes" and "snowing", it just doesn't seem worth it to me. I think the hacker would be better off setting a fixed condition seeing how they know how the map is going to look and can decide whether light or heavy snow is more realistic.
This.

where do you put the script after compiling it?

Right now, in a level script on every map.

0m3GA ARS3NAL
January 3rd, 2010, 7:11 PM
In my opinion, I think snow is just unnecessary. If the only conditions that the script can alter between are "3 snowflakes" and "snowing", it just doesn't seem worth it to me. I think the hacker would be better off setting a fixed condition seeing how they know how the map is going to look and can decide whether light or heavy snow is more realistic.

Meh, just a suggestion you know, if someone wanted snow to happen, it could.
(Besides, I decided not to include 3 Snowflakes, since it isn't exactly... ideal, so to speak.)
The 3 Snowflakes weather is odd, and only seems to work half the time.

I do agree though, snow is a bit unnecessary, just thought I would include it for anyone who wants it. (And I know, someone out there wants a more natural snow, lol)
If only we could make MORE weather types...

altariaking
January 3rd, 2010, 8:59 PM
whenever I try to compile it says missing define

Megiddo-san
January 5th, 2010, 3:59 PM
Are these the correct settings for implementation? 1. Use offset of @main 2. Use an 01 setmaptile script 3. Set map weather to 0F I haven't gotten it to do anything yet. Probably some key detail I missed.

colcolstyles
January 12th, 2010, 9:23 PM
Are these the correct settings for implementation? 1. Use offset of @main 2. Use an 01 setmaptile script 3. Set map weather to 0F I haven't gotten it to do anything yet. Probably some key detail I missed.

Remember to initialize the weather variable (0x7000) to either 0x2, 0xB, 0x3, or 0xD (sunny, cloudy, raining, and thunderstorm respectively).

So how's the ASM part of this idea coming along? Last time I checked, interdpth said that he was going to add a "hook" to the routine that runs every time a map loads. Is that still the plan? And if so, how is progress on that so far?

Darthatron
January 12th, 2010, 10:10 PM
Remember to initialize the weather variable (0x7000) to either 0x2, 0xB, 0x3, or 0xD (sunny, cloudy, raining, and thunderstorm respectively).

It should actually be between 1 and 4, as stated in the comments on the line that defines the variable. ;)

0m3GA ARS3NAL
January 12th, 2010, 10:15 PM
It should actually be between 1 and 4, as stated in the comments on the line that defines the variable. ;)

OR 5 if the person is using the snow modded one! lol...

Megiddo-san
January 13th, 2010, 8:29 PM
Ah, gotcha. I'll try that. :)

Powerflare
January 14th, 2010, 12:48 PM
Think you could make a video tutorial on this? I think it'd help me a bit more as I am having a bit of trouble understanding exactly how to do this.

----------------------------------------------------
Also....

You make a valid point. It's not difficult to simply get rid of that check, as it's only 3 lines. Here is an updated version for you:
//----------------------------------------------------------------
// Natural Weather Script!
//----------------------------------------------------------------
// By colcolstyles and Darthatron (3/1/2010)
//----------------------------------------------------------------
// This script will create a system which aims to simulate the
// "real world" weather by randomly switching between weather
// effects (sunny, cloudy, raining, and thunderstorm). The odds of
// a change occurring depend on the current weather (i.e. it is
// more likely to start raining when it is already cloudy than
// when it is sunny). However, random weather will only occur if
// the weather type on the player's current map is set to 0x0F.
// Because of this, the hacker can make a map use a preset weather
// condition and be exempt from random weather.
//----------------------------------------------------------------

#erase 0x800000 0xFFF
#dynamic 0x800000

#define V_DEFAULT 0x8000
#define V_WEATHER 0x7000 //This must be set to a value between 1 and 4 to work.
#define V_RANDVAL 0x7001

#define A_WEATHER 0x02036E12
#define A_MAPTYPE 0x02036E13
#define A_DEFAULT 0x020370B8

#define W_SUNNY 0x02
#define W_CLOUDY 0x0B
#define W_RAIN 0x03
#define W_THUNDER 0x0D

#org @Setup
setvar V_WEATHER 0x01
setweather W_SUNNY
doweather
end

#org @Main
setvar V_DEFAULT 0x0000
copybyte A_DEFAULT A_WEATHER //Grabs the default map weather and stores it in V_DEFAULT
compare V_DEFAULT 0x0F
if B_<< goto @Quit
random 0x13 //Create a random value between 0 and 19.
copyvar V_RANDVAL LASTRESULT
compare V_WEATHER 0x01
if B_TRUE goto @CurrentlySunny
compare V_WEATHER 0x02
if B_TRUE goto @CurrentlyCloudy
compare V_WEATHER 0x03
if B_TRUE goto @CurrentlyRaining
compare V_WEATHER 0x04
if B_TRUE goto @CurrentlyStorming
end

#org @Quit
end

#org @BecomeSunny
setweather W_SUNNY
setvar V_WEATHER 0x01
doweather
end

#org @BecomeCloudy
setweather W_CLOUDY
setvar V_WEATHER 0x02
doweather
end

#org @BecomeRaining
setweather W_RAIN
setvar V_WEATHER 0x03
doweather
end

#org @BecomeStorming
setweather W_THUNDER
setvar V_WEATHER 0x04
doweather
end

#org @CurrentlySunny
compare V_RANDVAL 0x01 //10% chance of becoming cloudly.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x02 //5% chance of it raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //85% chance of the weather staying the same.
if B_<= goto @BecomeSunny
end

#org @CurrentlyCloudy
compare V_RANDVAL 0x04 //25% chance of becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x06 //10% chance of it staying cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x10 //50% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyRaining
compare V_RANDVAL 0x06 //35% chance that it will keep raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x08 //10% chance of it becoming sunny.
if B_<= goto @BecomeSunny
compare V_RANDVAL 0x10 //40% chance that it will become cloudy.
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //15% chance that a thunder storm will start.
if B_<= goto @BecomeStorming
end

#org @CurrentlyStorming
compare V_RANDVAL 0x0C //65% chance that it will start raining.
if B_<= goto @BecomeRaining
compare V_RANDVAL 0x0F //15% chance of it becoming cloudy
if B_<= goto @BecomeCloudy
compare V_RANDVAL 0x13 //20% chance that the thunder storm will continue.
if B_<= goto @BecomeStorming
endIf you can come up with the chances of the snow weathers happening then I would have no problem adding it in. I, however, am far too lazy to think of those values up. ^_^

That script you have there, where exactly do you put that in the game? Or do you just compile it... I'm such a n00b.

Darthatron
January 14th, 2010, 8:20 PM
Think you could make a video tutorial on this? I think it'd help me a bit more as I am having a bit of trouble understanding exactly how to do this.

----------------------------------------------------
Also....

That script you have there, where exactly do you put that in the game? Or do you just compile it... I'm such a n00b.
Compile it anywhere, then put it in a level script.

rockeymon
January 14th, 2010, 8:46 PM
Um so question.
1.) Is this open to the public
2.) What is a level script
3.) Where do you put it on a map
4.) Can you use xse and Am1.92 to insert it into the game?

colcolstyles
January 14th, 2010, 10:25 PM
Um so question.
1.) Is this open to the public
2.) What is a level script
3.) Where do you put it on a map
4.) Can you use xse and Am1.92 to insert it into the game?

1) Not technically
2) This isn't the place to be asking that
3) I don't really feel like explaining
4) Yes but, as I said, it's not finished yet. If you wait a little longer, there will be a patch that won't require using XSE or AdvanceMap to use :)

Powerflare
January 15th, 2010, 2:22 PM
Compile it anywhere, then put it in a level script.

A level script, okay. So I have to put it on a level script for each map I want this random weather to be on?

interdpth
January 15th, 2010, 3:45 PM
A level script, okay. So I have to put it on a level script for each map I want this random weather to be on?

So, uh, have you read the thread at all? And have you read the rules for this sub-forum?

Powerflare
January 15th, 2010, 5:49 PM
So, uh, have you read the thread at all? And have you read the rules for this sub-forum?
I have. Have you read my post? ^.^ I'm a n00b at this kinda stuff. xD I didn't fully understand it. :|

colcolstyles
January 16th, 2010, 2:10 PM
I'm a n00b at this kinda stuff. xD I didn't fully understand it. :|

Makes no difference to me.

Anyways, all you need to know is that this isn't finished yet. It's nearing completion but it's not ready for public release yet. Try to be patient, please.

Powerflare
January 17th, 2010, 12:23 PM
Makes no difference to me.

Anyways, all you need to know is that this isn't finished yet. It's nearing completion but it's not ready for public release yet. Try to be patient, please.

Sorry if I was impatient, I have a tendency to to that. :| Anyways, I can wait. For me, the more complicated stuff can wait till later; since I'm starting a new hack, I want to get some of the essentials out of the way.

interdpth
January 19th, 2010, 9:40 PM
Okay, so I take it we now have a set script to use? :)

colcolstyles
January 19th, 2010, 10:16 PM
Okay, so I take it we now have a set script to use? :)

This post (http://www.pokecommunity.com/showpost.php?p=5445856&postcount=30) has the final script. And if you don't want the "only run if map type is 0xF" part, then use the script in Darthatron's post a couple posts down the page.

HackMew
January 26th, 2010, 11:30 AM
For those interested, I'll briefly explain how I made it in my hack. First of all, the weather-based seasons are enabled only on maps where the weather byte is set to 0xF. This is useful to provide a manual override for particular maps and, at the same point, to avoid weather changes inside buildings, caves etc. So, let's suppose the player has just entered a 0xF map. If the old weather value (stored elsewhere from the actual map weather) is set to 0x0, and the weather timer is 0x0 as well, a new weather type would be randomly selected from the weather-season tables, one for each season and 32 byte each. This gives a 3.125% chance for each item in the table. Then the weather would be applied and stored in the extra memory area I talked about earlier. Finally, the timer would be randomly set to a certain amount of seconds, representing a few hours. Whenever the timer elapses, a new weather is randomly chosen and the timer is reinitialized. Saving the weather byte is important, as when going to another 0xF map (as long as the timer is not 0x0) the same weather would be applied.

0m3GA ARS3NAL
January 26th, 2010, 7:58 PM
Interesting, a timer system is a good idea, but it seems a little impractical.
So far as I can tell all that is needed now is an ASM routine to get the weather to run whenever you enter the maps you want. (This script also used 0xF as the weather byte for this to work.)

HackMew
January 28th, 2010, 4:23 PM
Interesting, a timer system is a good idea, but it seems a little impractical.
So far as I can tell all that is needed now is an ASM routine to get the weather to run whenever you enter the maps you want. (This script also used 0xF as the weather byte for this to work.)

Why a timer would be impractical? I don't get it.

Darthatron
January 28th, 2010, 6:55 PM
If anything it would be more practical. You could stand in one spot and the weather could change randomly. That makes much more sense then just when changing maps.

0m3GA ARS3NAL
January 28th, 2010, 8:13 PM
I was thinking it had a timer to the point where it would only change when changing maps, and if the timer went off. A Real-time timer would be even better.
Sorry for the confusion.

HackMew
January 29th, 2010, 4:48 AM
I was thinking it had a timer to the point where it would only change when changing maps, and if the timer went off. A Real-time timer would be even better.
Sorry for the confusion.

In fact, it would be "only change when changing maps, and/or if the timer went off."
BTW, what do you mean by "real-time timer" ?

0m3GA ARS3NAL
January 29th, 2010, 4:57 AM
I mean it happens as soon as the timer goes off, no need to change maps.

I've set up a timer in a hack before, wasn't very helpful as the player could sit in the map forever and never have the event planned happen until they change map.
Not exactly Real Time if you ask me...

HackMew
January 29th, 2010, 6:25 AM
I mean it happens as soon as the timer goes off, no need to change maps.

Maybe I didn't express myself correctly, but that's exactly what would happen. There's no need to change map. But if you do, the same weather is applied (assuming the weather byte is set to 0xF).

ZodiacDaGreat
January 29th, 2010, 5:25 PM
Maybe I didn't express myself correctly, but that's exactly what would happen. There's no need to change map. But if you do, the same weather is applied (assuming the weather byte is set to 0xF).
The timer updates a lot so theres no need to change maps ^^ As it refreshes and then there's script execution as well when the timer hits max/min.

HackMew
January 30th, 2010, 1:35 AM
The timer updates a lot so theres no need to change maps ^^ As it refreshes and then there's script execution as well when the timer hits max/min.

Well, the timer updates, but only once some hours. So it's perfectly understandable the player might change map in the meanwhile. Anyway, I never said you need to change map. I only said then when you enter/exit a map, if the map weather is 0xF, then the same weather as the old map is going to be applied. The weather actually changes, from 0xF to whatever, but the result in-game is not noticeable.

PokeBunny
October 4th, 2014, 8:36 AM
Why don't you make an automatic ASM function?

Danny0317
October 4th, 2014, 5:25 PM
Why don't you make an automatic ASM function?

Well, for one because nobody has posted in this thread for four years and this was very forgotten.

Criminon
May 18th, 2015, 12:29 AM
Well, for one because nobody has posted in this thread for four years and this was very forgotten.

Hoping it gets remembered now.