The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Research & Development
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!
Research & Development programs in this forum are subject to moderator approval before they are displayed.

Reply
Click here to go to the first staff post in this thread.  
Thread Tools
  #1    
Old January 1st, 2010, 09:22 PM
Hiroshi Sotomura's Avatar
Hiroshi Sotomura
 
Join Date: Sep 2003
Location: Melbourne, Australia
Age: 24
Gender: Male
Nature: Lax
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)
---------------------------------------------------------------
__________________
Hiroshi Sotomura

That's Our Switch.
Pre-Service Teacher. Tech Guy. Web Designer. PokéCommunity Administrator. Wanderer. Novice Hockey Player. rijonAdventures Developer. #westjournal. Views are my own.
Reply With Quote
  #2    
Old January 1st, 2010, 09:32 PM
interdpth
I've seen things, man.
 
Join Date: Jul 2004
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
__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote
  #3    
Old January 1st, 2010, 10:01 PM
Hiroshi Sotomura's Avatar
Hiroshi Sotomura
 
Join Date: Sep 2003
Location: Melbourne, Australia
Age: 24
Gender: Male
Nature: Lax
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.
__________________
Hiroshi Sotomura

That's Our Switch.
Pre-Service Teacher. Tech Guy. Web Designer. PokéCommunity Administrator. Wanderer. Novice Hockey Player. rijonAdventures Developer. #westjournal. Views are my own.
Reply With Quote
  #4    
Old January 1st, 2010, 10:04 PM
interdpth
I've seen things, man.
 
Join Date: Jul 2004
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
__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote
  #5    
Old January 1st, 2010, 10:31 PM
Hiroshi Sotomura's Avatar
Hiroshi Sotomura
 
Join Date: Sep 2003
Location: Melbourne, Australia
Age: 24
Gender: Male
Nature: Lax
This huge script by colcolstyles has an implementation of the weatherwork above. Thing is, I haven't actually been able to work it.
__________________
Hiroshi Sotomura

That's Our Switch.
Pre-Service Teacher. Tech Guy. Web Designer. PokéCommunity Administrator. Wanderer. Novice Hockey Player. rijonAdventures Developer. #westjournal. Views are my own.
Reply With Quote
  #6    
Old January 1st, 2010, 10:32 PM
DreadWaffle's Avatar
DreadWaffle
LOVE AND PEACE!
 
Join Date: Aug 2009
Location: Underground
Gender: Male
Nature: Calm
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
__________________
"I am known as Valentinez Alkalinella Xifax Sicidabohertz Gombigobilla Blue Stradivari Talentrent Pierre Andri Charton-Haymoss Ivanovici Baldeus George Doitzel Kaiser III. Don't hesitate to call."
Reply With Quote
  #7    
Old January 1st, 2010, 10:37 PM
interdpth
I've seen things, man.
 
Join Date: Jul 2004
Quote:
Originally Posted by Anthony La View Post
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.
__________________
yes, this is doge.

potato is not here.

bye
Reply With Quote
  #8    
Old January 1st, 2010, 10:56 PM
DreadWaffle's Avatar
DreadWaffle
LOVE AND PEACE!
 
Join Date: Aug 2009
Location: Underground
Gender: Male
Nature: Calm
Quote:
Originally Posted by interdpth View Post
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 View Post
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

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 :'(
__________________
"I am known as Valentinez Alkalinella Xifax Sicidabohertz Gombigobilla Blue Stradivari Talentrent Pierre Andri Charton-Haymoss Ivanovici Baldeus George Doitzel Kaiser III. Don't hesitate to call."
Reply With Quote
  #9    
Old January 2nd, 2010, 02:33 AM
Darthatron's Avatar
Darthatron
巨大なトロール。
Community Supporter
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 23
Gender: Male
Nature: Modest
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.
__________________
あなた は しきしゃ です
わたし は ばか です

Last edited by Darthatron; January 2nd, 2010 at 02:40 AM. Reason: Kindness and love.
Reply With Quote
  #10    
Old January 2nd, 2010, 03:11 AM
Hiroshi Sotomura's Avatar
Hiroshi Sotomura
 
Join Date: Sep 2003
Location: Melbourne, Australia
Age: 24
Gender: Male
Nature: Lax
There actually a command that reads the set map value, though?
__________________
Hiroshi Sotomura

That's Our Switch.
Pre-Service Teacher. Tech Guy. Web Designer. PokéCommunity Administrator. Wanderer. Novice Hockey Player. rijonAdventures Developer. #westjournal. Views are my own.
Reply With Quote
  #11    
Old January 2nd, 2010, 03:35 AM
Darthatron's Avatar
Darthatron
巨大なトロール。
Community Supporter
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 23
Gender: Male
Nature: Modest
Quote:
Originally Posted by Anthony La View Post
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.
__________________
あなた は しきしゃ です
わたし は ばか です
Reply With Quote
  #12    
Old January 2nd, 2010, 04:27 AM
Hiroshi Sotomura's Avatar
Hiroshi Sotomura
 
Join Date: Sep 2003
Location: Melbourne, Australia
Age: 24
Gender: Male
Nature: Lax
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.
__________________
Hiroshi Sotomura

That's Our Switch.
Pre-Service Teacher. Tech Guy. Web Designer. PokéCommunity Administrator. Wanderer. Novice Hockey Player. rijonAdventures Developer. #westjournal. Views are my own.
Reply With Quote
  #13    
Old January 2nd, 2010, 04:41 AM
Darthatron's Avatar
Darthatron
巨大なトロール。
Community Supporter
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 23
Gender: Male
Nature: Modest
Quote:
Originally Posted by Anthony La View Post
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.
__________________
あなた は しきしゃ です
わたし は ばか です

Last edited by Darthatron; January 2nd, 2010 at 06:27 AM.
Reply With Quote
  #14    
Old January 2nd, 2010, 06:51 AM
Pokepal17's Avatar
Pokepal17
More cowbell~
 
Join Date: Oct 2008
Location: Steeltown
Age: 20
Gender: Male
Nature: Modest
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)
__________________
Pokémon Stardrop
Reply With Quote
  #15    
Old January 2nd, 2010, 03:50 PM
Hiroshi Sotomura's Avatar
Hiroshi Sotomura
 
Join Date: Sep 2003
Location: Melbourne, Australia
Age: 24
Gender: Male
Nature: Lax
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?
__________________
Hiroshi Sotomura

That's Our Switch.
Pre-Service Teacher. Tech Guy. Web Designer. PokéCommunity Administrator. Wanderer. Novice Hockey Player. rijonAdventures Developer. #westjournal. Views are my own.
Reply With Quote
  #16    
Old January 2nd, 2010, 05:30 PM
Pokepal17's Avatar
Pokepal17
More cowbell~
 
Join Date: Oct 2008
Location: Steeltown
Age: 20
Gender: Male
Nature: Modest
Quote:
Originally Posted by Anthony La View Post
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.
__________________
Pokémon Stardrop
Reply With Quote
  #17    
Old January 2nd, 2010, 05:57 PM
Darthatron's Avatar
Darthatron
巨大なトロール。
Community Supporter
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 23
Gender: Male
Nature: Modest
Quote:
Originally Posted by Pokepal17 View Post
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?
__________________
あなた は しきしゃ です
わたし は ばか です
Reply With Quote
  #18    
Old January 2nd, 2010, 06:33 PM
Pokepal17's Avatar
Pokepal17
More cowbell~
 
Join Date: Oct 2008
Location: Steeltown
Age: 20
Gender: Male
Nature: Modest
Quote:
Originally Posted by Darthatron View Post
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.
__________________
Pokémon Stardrop

Last edited by Pokepal17; January 2nd, 2010 at 07:18 PM.
Reply With Quote
  #19    
Old January 2nd, 2010, 06:49 PM
colcolstyles's Avatar
colcolstyles
Yours truly
 
Join Date: May 2008
Location: The Bay Area
Gender: Male
Nature: Lonely
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.
__________________

Brother of Vrai
Reply With Quote
  #20    
Old January 2nd, 2010, 07:00 PM
Darthatron's Avatar
Darthatron
巨大なトロール。
Community Supporter
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 23
Gender: Male
Nature: Modest
Quote:
Originally Posted by colcolstyles View Post
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. :\
__________________
あなた は しきしゃ です
わたし は ばか です
Reply With Quote
  #21    
Old January 2nd, 2010, 07:04 PM
colcolstyles's Avatar
colcolstyles
Yours truly
 
Join Date: May 2008
Location: The Bay Area
Gender: Male
Nature: Lonely
Quote:
Originally Posted by Darthatron View Post
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.
__________________

Brother of Vrai
Reply With Quote
  #22    
Old January 2nd, 2010, 07:12 PM
Darthatron's Avatar
Darthatron
巨大なトロール。
Community Supporter
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 23
Gender: Male
Nature: Modest
Quote:
Originally Posted by colcolstyles View Post
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.
__________________
あなた は しきしゃ です
わたし は ばか です
Reply With Quote
  #23    
Old January 2nd, 2010, 07:24 PM
colcolstyles's Avatar
colcolstyles
Yours truly
 
Join Date: May 2008
Location: The Bay Area
Gender: Male
Nature: Lonely
Quote:
Originally Posted by Darthatron View Post
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
__________________

Brother of Vrai
Reply With Quote
  #24    
Old January 2nd, 2010, 07:35 PM
Darthatron's Avatar
Darthatron
巨大なトロール。
Community Supporter
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 23
Gender: Male
Nature: Modest
Quote:
Originally Posted by colcolstyles View Post
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.
That definitely seems logical. Try it out and if it doesn't work then no harm is done, right? 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
__________________
あなた は しきしゃ です
わたし は ばか です

Last edited by Darthatron; January 2nd, 2010 at 07:46 PM.
Reply With Quote
  #25    
Old January 2nd, 2010, 07:42 PM
colcolstyles's Avatar
colcolstyles
Yours truly
 
Join Date: May 2008
Location: The Bay Area
Gender: Male
Nature: Lonely
Quote:
Originally Posted by Darthatron View Post
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.
__________________

Brother of Vrai
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 08:48 PM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 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 - 2014 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.