View Single Post
  #963    
Old October 17th, 2009 (04:10 PM). Edited October 17th, 2009 by colcolstyles.
colcolstyles's Avatar
colcolstyles colcolstyles is offline
Yours truly
Crystal Tier
 
Join Date: May 2008
Location: The Bay Area
Gender: Male
Nature: Lonely
Posts: 1,592
I was intrigued reading about your weather system. So much, in fact, that I decided to go to work implementing it. This is what I got:
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 0x14
copyvar V_RANDVAR LASTRESULT
compare V_WEATHER W_SUNNY
if B_== call @sunnyscript
compare V_WEATHER W_CLOUDY
if B_== call @cloudyscript
compare V_WEATHER W_RAIN
if B_== call @rainscript
compare V_WEATHER W_THUNDER
if B_== call @thunderscript
doweather
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
return

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

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

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

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

#org @becomesunny
setvar v_WEATHER W_SUNNY
setweather W_SUNNY
return

#org @becomecloudy
setvar V_WEATHER W_CLOUDY
setweather W_CLOUDY
return

#org @becomerainy
setvar V_WEATHER W_RAIN
setweather W_RAIN
return

#org @becomethunder
setvar V_WEATHER W_THUNDER
setweather W_THUNDER
return

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

#org @manual
setweather V_WEATHER
doweather
end

'----------------------------------------------------------------
I thought this would be a lot easier until I realized that FR/LG's scripting language doesn't have elseif statements -_-'
So I made some changes to the control flow and I think I've got it working pretty well. And, as an added bonus, I threw in a few lines of code which allow the player to manually override the script and specify a particular weather that they want on every map. As I'm writing this, I'm thinking that maybe I should expand that feature to allow for people to shut down the script entirely, as in: let the weather be dictated by what is written in each map's header. And, as I was writing that, I think I' figured out how to do it: as I was experimenting with things early on, I found that the script wasn't working at first. I eventually realized that the variable 'V_WEATHER' has to be initialized (I set it to '0x2') for the script to activate. So I guess that's how the hacker can turn it off (and back on by setting it to one of those constants). One last thing: in your outlining of the system, you used 0x1, 0x2, etc. for the various weather effects but I decided to use the values I found in AdvanceMap for them so that I could double the effectiveness of my constants by using them in my 'setweather' statements.
OK I'll shut up now ^_^

By the way, I really like this idea and I was wondering if you would give me permission to use something similar to it if I changed up the odds (I was planning on doing that anyway because there are a few slight tweaks I'd like to make based on my observations while debugging the script)?
__________________

Brother of Vrai