The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary Hack Research & Development (https://www.pokecommunity.com/forumdisplay.php?f=195)
-   -   Development RNG and Weather (https://www.pokecommunity.com/showthread.php?t=204509)

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

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

DreadWaffle 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

third, i wish i new more about this stuff 0.o

interdpth January 1st, 2010 10:37 PM

Quote:

Originally Posted by Anthony La (Post 5442759)
This huge script 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.

DreadWaffle January 1st, 2010 10:56 PM

Quote:

Originally Posted by interdpth (Post 5442771)
DreadWaffles post made me think of numerous possibilities this effect could have with the day and night systems.

SUCSESS!

Quote:

Originally Posted by Anthony La (Post 5442759)
This huge script 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.
Code:

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.

Darthatron January 2nd, 2010 3:35 AM

Quote:

Originally Posted by Anthony La (Post 5443103)
There actually a command that reads the set map value, though?

Not for someone who doesn't know there way around the ROM:
Code:

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.

Darthatron January 2nd, 2010 4:41 AM

Quote:

Originally Posted by Anthony La (Post 5443174)
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.

Code:

#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)

Pokepal17 January 2nd, 2010 5:30 PM

Quote:

Originally Posted by Anthony La (Post 5444697)
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

Quote:

Originally Posted by Pokepal17 (Post 5443352)
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

Quote:

Originally Posted by Darthatron (Post 5445079)
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

Quote:

Originally Posted by colcolstyles (Post 5445230)
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...
Code:

#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

Quote:

Originally Posted by Darthatron (Post 5445248)
I saw a pretty major problem in your script:

Say V_RANDVAR = 1...
Code:

#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

Quote:

Originally Posted by colcolstyles (Post 5445263)
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

Quote:

Originally Posted by Darthatron (Post 5445289)
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:
Code:

#seek @end
doweather
end


... I think. But then again, you're the programmer. :P

Darthatron January 2nd, 2010 7:35 PM

Quote:

Originally Posted by colcolstyles (Post 5445333)
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:
Code:

#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...
Code:

doweather
end


...uses 2 bytes. ;)

EDIT2: Here is my script which will be quicker and save space. :)
Code:

#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

Quote:

Originally Posted by Darthatron (Post 5445387)
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

Quote:

Originally Posted by colcolstyles (Post 5445435)
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

Code:

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

colcolstyles January 2nd, 2010 9:21 PM

Quote:

Originally Posted by Anthony La (Post 5445854)
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:
Code:

//----------------------------------------------------------------
// 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



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.
Though I had an idea...
What about snow?
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

Quote:

Originally Posted by Anthony La (Post 5446290)
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:
Code:

//----------------------------------------------------------------
// 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


Quote:

Originally Posted by 0m3GA ARS3NAL (Post 5446292)
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.
Though I had an idea...
What about snow?
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. ^_^


All times are GMT -8. The time now is 8:50 AM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.