02-17-2010, 08:27 PM
Rataime's Dynamic Shadow Script:
Instructions:
Installation:
Put this script in a new class called Dynamic Shadows. Put it over both the Sun Effects Script and Wachungaââ¬â¢s Fog of War script if you are using it. Script is in the spoiler tags.
Usage:
Ok, jusââ¬â¢ an FYI, this script is caterpillar compatible. Its quite simple to use actually. I find it easier though to write down all the different commands to the scripts I have implemented, for easy reference, so I suggest you do the same. Now, here are the commands that you will need to use in order to use this script:
**All of these commands go into comments in the events, also, donââ¬â¢t capitalize any of the commands at any point, otherwise it wont work**
Now, put these in comments only if you have selected the event to be a source:
And thatââ¬â¢s all there is to it. Just remember Geometry; this script works in angles, 180 being half way around, and 360 being all the way around.
There is currently a bug that causes shadows to get ââ¬Åstuckââ¬Â on the top of the window as you move down away from them.
Rataime's Sun Effects Script :
Instructions:
Installation:
Put this script in a new class called Dynamic Shadows. Put it under the Dynamic Shadows Script and over Wachungaââ¬â¢s Fog of War script if you are using it. Script is in the spoiler tags.
Usage:
Same as before, this script is Caterpillar compatible. Place this in a class under the Dynamic Shadows script (you should use both of them). Again, some commands, make sure you put them in comments inside an empty event in maps where you want a sun:
You can also have 2 suns or more by making another even using begin sun and setting an angle for the second, third, ect.
SephirothSpawn's Dynamic bank Script:
Instructions:
Installation:
Now, make a new class above 'Main' and cal it Dynamic Banks then add the spoilered script into it.
Usage:
This is a very interesting little script. It calculates interest so whenever you leave money in the bank, it will accrue interest.
Now, to call this use this in a call script:
Now, to adjust this to your needs you can edit these lines:
these lines effect your initial balance, and interest rate, what savings bonds you already have, and the amount of time that has passed for your bonds and interest:
These lines affect the amount of time it takes to update your balance with the interest, and how much the interest adds to your total amount of money. Note that the 3600 is in seconds:
finally, these allow you to modify the bonds. Hereââ¬â¢s a break down of how the bonds are set up above:
Now, if you want each bank to be different, then you can do this in the call script:
so, in this exapmle, we want 2 custom bonds and a new intrest rate:
we now have 2 custom bonds and the interest rate will be set to 10%. Custom bond 1 will cost 10,000 gold, increase by 30% at maturity and take 5 hours of game play to mature, while custom bond 2 will cost 20,000 gold, increase by 60% at maturity and take 10 hours of game play to mature.
Instructions:
Installation:
Put this script in a new class called Dynamic Shadows. Put it over both the Sun Effects Script and Wachungaââ¬â¢s Fog of War script if you are using it. Script is in the spoiler tags.
Usage:
Ok, jusââ¬â¢ an FYI, this script is caterpillar compatible. Its quite simple to use actually. I find it easier though to write down all the different commands to the scripts I have implemented, for easy reference, so I suggest you do the same. Now, here are the commands that you will need to use in order to use this script:
**All of these commands go into comments in the events, also, donââ¬â¢t capitalize any of the commands at any point, otherwise it wont work**
Quote:begin shadow source ââ¬â starts a source of light in an event
begin shadow ââ¬â starts shadows for an event (party members all have this automatically)
Now, put these in comments only if you have selected the event to be a source:
Quote:anglemin (number between 0 and 360. Example: anglemin 0)- sets angle of rotation
anglemax (number between 0 and 360. Example: anglemax 360) ââ¬â sets angle of rotation
distancemax (number)- sets how far the shadow will show up.
And thatââ¬â¢s all there is to it. Just remember Geometry; this script works in angles, 180 being half way around, and 360 being all the way around.
There is currently a bug that causes shadows to get ââ¬Åstuckââ¬Â on the top of the window as you move down away from them.
Dynamic Shadows
#==============================================================================
# ? Sprite_Shadow (Sprite_Ombre )
# Based on Genzai Kawakami's shadows, dynamisme&features by Rataime, extra features Boushy
#==============================================================================
CATERPILLAR_COMPATIBLE = true
SHADOW_WARN = true
class Game_Party
attr_reader :characters
end
class Sprite_Shadow < RPG::Sprite
attr_accessor :character
def initialize(viewport, character = nil,id=0)
super(viewport)
params=$shadow_spriteset.shadows[id]
@source=params[0]
@anglemin=0
@anglemin=params[1] if params.size>1
@anglemax=0
@anglemax=params[2] if params.size>2
@self_opacity=100
@self_opacity=params[4] if params.size>4
@distancemax=350
@distancemax=params[3] if params.size>3
@character = character
update
end
def update
if !in_range?(@character, @source, @distancemax)
self.opacity=0
return
end
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
if self.angle>90 or angle<-90
if @character.direction== 6
sy = ( 4- 2) / 2 * @ch
end
if @character.direction== 4
sy = ( 6- 2) / 2 * @ch
end
if @character.direction== 2
sy = ( 8- 2) / 2 * @ch
end
if @character.direction== 8
sy = ( 2- 2) / 2 * @ch
end
end
self.src_rect.set(sx, sy, @cw, @ch)
end
self.x = @character.screen_x
self.y = @character.screen_y-5
self.z = @character.screen_z(@ch)-1
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
@deltax=@source.screen_x-self.x
@deltay= @source.screen_y-self.y
self.color = Color.new(0, 0, 0)
@distance = ((@deltax ** 2) + (@deltay ** 2))
self.opacity = @self_opacity*13000/((@distance*370/@distancemax)+6000)
self.angle = 57.3*Math.atan2(@deltax, @deltay )
@angle_trigo=self.angle+90
if @angle_trigo<0
@angle_trigo=360+@angle_trigo
end
if @anglemin !=0 or @anglemax !=0
if (@angle_trigo<@anglemin or @angle_trigo>@anglemax) and @anglemin<@anglemax
self.opacity=0
return
end
if (@angle_trigo<@anglemin and @angle_trigo>@anglemax) and @anglemin>@anglemax
self.opacity=0
return
end
end
end
def in_range?(element, object, range)# From Near's Anti Lag Script, edited
x = (element.screen_x - object.screen_x) * (element.screen_x - object.screen_x)
y = (element.screen_y - object.screen_y) * (element.screen_y - object.screen_y)
r = x + y
if r <= (range * range)
return true
else
return false
end
end
end
#===================================================
# ? CLASS Sprite_Character edit
#===================================================
class Sprite_Character < RPG::Sprite
alias shadow_initialize initialize
def initialize(viewport, character = nil)
@character = character
super(viewport)
@ombrelist=[]
if character.is_a?(Game_Event) and $shadow_spriteset.shadows!=[]
params = XPML_read("Shadow",@character.id,4)
if params!=nil
for i in 0...$shadow_spriteset.shadows.size
@ombrelist.push(Sprite_Shadow.new(viewport, @character,i))
end
end
end
if character.is_a?(Game_Player) and $shadow_spriteset.shadows!=[]
for i in 0...$shadow_spriteset.shadows.size
@ombrelist.push(Sprite_Shadow.new(viewport, $game_player,i))
end
#===================================================
# ? Compatibility with fukuyama's caterpillar script
#===================================================
if CATERPILLAR_COMPATIBLE and $game_party.characters!=nil
for member in $game_party.characters
for i in 0...$shadow_spriteset.shadows.size
@ombrelist.push(Sprite_Shadow.new(viewport, member,i))
end
end
end
#===================================================
# ? End of the compatibility
#===================================================
end
shadow_initialize(viewport, @character)
end
alias shadow_update update
def update
shadow_update
if @ombrelist!=[]
for i in 0...@ombrelist.size
@ombrelist[i].update
end
end
end
end
#===================================================
# ? CLASS Game_Event edit
#===================================================
class Game_Event
attr_accessor :id
end
#===================================================
# ? CLASS Spriteset_Map edit
#===================================================
class Spriteset_Map
attr_accessor :shadows
alias shadow_initialize initialize
def initialize
$shadow_spriteset=self
@shadows=[]
warn=false
for k in $game_map.events.keys.sort
warn=true if ($game_map.events[k].list!=nil and $game_map.events[k].list[0].code == 108 and ($game_map.events[k].list[0].parameters == ["s"] or $game_map.events[k].list[0].parameters == ["o"]))
params = XPML_read("Shadow Source",k,4)
$shadow_spriteset.shadows.push([$game_map.events[k]]+params) if params!=nil
end
p "Warning : At least one event on this map uses the obsolete way to add shadows" if warn == true and SHADOW_WARN
shadow_initialize
end
end
#===================================================
# ? XPML Definition, by Rataime, using ideas from Near Fantastica
#
# Returns nil if the markup wasn't present at all,
# returns [] if there wasn't any parameters, else
# returns a parameters list with "int" converted as int
# eg :
# begin first
# begin second
# param1 1
# param2 two
# begin third
# anything 3
#
# p XPML_read("first", event_id) -> []
# p XPML_read("second", event_id) -> [1,"two"]
# p XPML_read("third", event_id) -> [3]
# p XPML_read("forth", event_id) -> nil
#===================================================
def XPML_read(markup,event_id,max_param_number=0)
parameter_list = nil
event=$game_map.events[event_id]
return if event.list==nil
for i in 0...event.list.size
if event.list[i].code == 108 and event.list[i].parameters[0].downcase == "begin "+markup.downcase
parameter_list = [] if parameter_list == nil
for j in i+1...event.list.size
if event.list[j].code == 108
parts = event.list[j].parameters[0].split
if parts.size!=1 and parts[0].downcase!="begin"
if parts[1].to_i!=0 or parts[1]=="0"
parameter_list.push(parts[1].to_i)
else
parameter_list.push(parts[1])
end
else
return parameter_list
end
else
return parameter_list
end
return parameter_list if max_param_number!=0 and j==i+max_param_number
end
end
end
return parameter_list
end
# ? Sprite_Shadow (Sprite_Ombre )
# Based on Genzai Kawakami's shadows, dynamisme&features by Rataime, extra features Boushy
#==============================================================================
CATERPILLAR_COMPATIBLE = true
SHADOW_WARN = true
class Game_Party
attr_reader :characters
end
class Sprite_Shadow < RPG::Sprite
attr_accessor :character
def initialize(viewport, character = nil,id=0)
super(viewport)
params=$shadow_spriteset.shadows[id]
@source=params[0]
@anglemin=0
@anglemin=params[1] if params.size>1
@anglemax=0
@anglemax=params[2] if params.size>2
@self_opacity=100
@self_opacity=params[4] if params.size>4
@distancemax=350
@distancemax=params[3] if params.size>3
@character = character
update
end
def update
if !in_range?(@character, @source, @distancemax)
self.opacity=0
return
end
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
if self.angle>90 or angle<-90
if @character.direction== 6
sy = ( 4- 2) / 2 * @ch
end
if @character.direction== 4
sy = ( 6- 2) / 2 * @ch
end
if @character.direction== 2
sy = ( 8- 2) / 2 * @ch
end
if @character.direction== 8
sy = ( 2- 2) / 2 * @ch
end
end
self.src_rect.set(sx, sy, @cw, @ch)
end
self.x = @character.screen_x
self.y = @character.screen_y-5
self.z = @character.screen_z(@ch)-1
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
@deltax=@source.screen_x-self.x
@deltay= @source.screen_y-self.y
self.color = Color.new(0, 0, 0)
@distance = ((@deltax ** 2) + (@deltay ** 2))
self.opacity = @self_opacity*13000/((@distance*370/@distancemax)+6000)
self.angle = 57.3*Math.atan2(@deltax, @deltay )
@angle_trigo=self.angle+90
if @angle_trigo<0
@angle_trigo=360+@angle_trigo
end
if @anglemin !=0 or @anglemax !=0
if (@angle_trigo<@anglemin or @angle_trigo>@anglemax) and @anglemin<@anglemax
self.opacity=0
return
end
if (@angle_trigo<@anglemin and @angle_trigo>@anglemax) and @anglemin>@anglemax
self.opacity=0
return
end
end
end
def in_range?(element, object, range)# From Near's Anti Lag Script, edited
x = (element.screen_x - object.screen_x) * (element.screen_x - object.screen_x)
y = (element.screen_y - object.screen_y) * (element.screen_y - object.screen_y)
r = x + y
if r <= (range * range)
return true
else
return false
end
end
end
#===================================================
# ? CLASS Sprite_Character edit
#===================================================
class Sprite_Character < RPG::Sprite
alias shadow_initialize initialize
def initialize(viewport, character = nil)
@character = character
super(viewport)
@ombrelist=[]
if character.is_a?(Game_Event) and $shadow_spriteset.shadows!=[]
params = XPML_read("Shadow",@character.id,4)
if params!=nil
for i in 0...$shadow_spriteset.shadows.size
@ombrelist.push(Sprite_Shadow.new(viewport, @character,i))
end
end
end
if character.is_a?(Game_Player) and $shadow_spriteset.shadows!=[]
for i in 0...$shadow_spriteset.shadows.size
@ombrelist.push(Sprite_Shadow.new(viewport, $game_player,i))
end
#===================================================
# ? Compatibility with fukuyama's caterpillar script
#===================================================
if CATERPILLAR_COMPATIBLE and $game_party.characters!=nil
for member in $game_party.characters
for i in 0...$shadow_spriteset.shadows.size
@ombrelist.push(Sprite_Shadow.new(viewport, member,i))
end
end
end
#===================================================
# ? End of the compatibility
#===================================================
end
shadow_initialize(viewport, @character)
end
alias shadow_update update
def update
shadow_update
if @ombrelist!=[]
for i in 0...@ombrelist.size
@ombrelist[i].update
end
end
end
end
#===================================================
# ? CLASS Game_Event edit
#===================================================
class Game_Event
attr_accessor :id
end
#===================================================
# ? CLASS Spriteset_Map edit
#===================================================
class Spriteset_Map
attr_accessor :shadows
alias shadow_initialize initialize
def initialize
$shadow_spriteset=self
@shadows=[]
warn=false
for k in $game_map.events.keys.sort
warn=true if ($game_map.events[k].list!=nil and $game_map.events[k].list[0].code == 108 and ($game_map.events[k].list[0].parameters == ["s"] or $game_map.events[k].list[0].parameters == ["o"]))
params = XPML_read("Shadow Source",k,4)
$shadow_spriteset.shadows.push([$game_map.events[k]]+params) if params!=nil
end
p "Warning : At least one event on this map uses the obsolete way to add shadows" if warn == true and SHADOW_WARN
shadow_initialize
end
end
#===================================================
# ? XPML Definition, by Rataime, using ideas from Near Fantastica
#
# Returns nil if the markup wasn't present at all,
# returns [] if there wasn't any parameters, else
# returns a parameters list with "int" converted as int
# eg :
# begin first
# begin second
# param1 1
# param2 two
# begin third
# anything 3
#
# p XPML_read("first", event_id) -> []
# p XPML_read("second", event_id) -> [1,"two"]
# p XPML_read("third", event_id) -> [3]
# p XPML_read("forth", event_id) -> nil
#===================================================
def XPML_read(markup,event_id,max_param_number=0)
parameter_list = nil
event=$game_map.events[event_id]
return if event.list==nil
for i in 0...event.list.size
if event.list[i].code == 108 and event.list[i].parameters[0].downcase == "begin "+markup.downcase
parameter_list = [] if parameter_list == nil
for j in i+1...event.list.size
if event.list[j].code == 108
parts = event.list[j].parameters[0].split
if parts.size!=1 and parts[0].downcase!="begin"
if parts[1].to_i!=0 or parts[1]=="0"
parameter_list.push(parts[1].to_i)
else
parameter_list.push(parts[1])
end
else
return parameter_list
end
else
return parameter_list
end
return parameter_list if max_param_number!=0 and j==i+max_param_number
end
end
end
return parameter_list
end
Rataime's Sun Effects Script :
Instructions:
Installation:
Put this script in a new class called Dynamic Shadows. Put it under the Dynamic Shadows Script and over Wachungaââ¬â¢s Fog of War script if you are using it. Script is in the spoiler tags.
Usage:
Same as before, this script is Caterpillar compatible. Place this in a class under the Dynamic Shadows script (you should use both of them). Again, some commands, make sure you put them in comments inside an empty event in maps where you want a sun:
Quote:begin sun ââ¬â starts a sun
(optional)
angle (number between ââ¬â180 and 180)
opacity (number between 0 and 255, sets darkness of shadow)
You can also have 2 suns or more by making another even using begin sun and setting an angle for the second, third, ect.
Sun Effects
#==============================================================================
# ? Sprite_Sun
# # Based on Sprite_Shadow, modified by Rataime
#==============================================================================
CATERPILLAR_COMPATIBLE = true
SUN_WARN =true
class Game_Party
attr_reader :characters
end
class Sprite_Sun < RPG::Sprite
attr_accessor :character
def initialize(viewport, character = nil,id=0)
super(viewport)
@character = character
params=$sun_spriteset.sun[id]
self_angle=45
self_angle=params[0] if params.size>0
self_opacity=128
self_opacity=params[1] if params.size>1
@self_angle=self_angle
@self_opacity=self_opacity
update
end
def update
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
@direct=@character.direction
if self.angle>90 or angle<-90
if @direct== 6
sy = ( 4- 2) / 2 * @ch
end
if @direct== 4
sy = ( 6- 2) / 2 * @ch
end
if @direct != 4 and @direct !=6
sy = (@character.direction - 2) / 2 * @ch
end
else
sy = (@character.direction - 2) / 2 * @ch
end
self.src_rect.set(sx, sy, @cw, @ch)
end
self.x = @character.screen_x
self.y = @character.screen_y-5
self.z = @character.screen_z(@ch)-1
self.opacity = @self_opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
self.angle = @self_angle.to_i-90
self.color = Color.new(0, 0, 0)
end
end
#===================================================
# ? CLASS Sprite_Character edit
#===================================================
class Sprite_Character < RPG::Sprite
alias sun_initialize initialize
def initialize(viewport, character = nil)
@character = character
super(viewport)
@sunlist=[]
if character.is_a?(Game_Event) and $sun_spriteset.sun!=[]
params = XPML_read("Shadow",@character.id,2)
if params!=nil
for i in 0...$sun_spriteset.sun.size
@sunlist.push(Sprite_Sun.new(viewport, @character,i))
end
end
end
if character.is_a?(Game_Player) and $sun_spriteset.sun!=[]
for i in 0...$sun_spriteset.sun.size
@sunlist.push(Sprite_Sun.new(viewport, $game_player,i))
end
#===================================================
# ? Compatibility with fukuyama's caterpillar script
#===================================================
if CATERPILLAR_COMPATIBLE and $game_party.characters!=nil
for member in $game_party.characters
for i in 0...$sun_spriteset.sun.size
@sunlist.push(Sprite_Sun.new(viewport, member,i))
end
end
end
#===================================================
# ? End of the compatibility
#===================================================
end
sun_initialize(viewport, @character)
end
alias sun_update update
def update
sun_update
if @sunlist!=[]
for i in 0...@sunlist.size
@sunlist[i].update
end
end
end
end
#===================================================
# ? CLASS Game_Event edit
#===================================================
class Game_Event
attr_accessor :id
end
#===================================================
# ? CLASS Spriteset_Map edit
#===================================================
class Spriteset_Map
attr_accessor :sun
alias sun_initialize initialize
def initialize
@sun=[]
$sun_spriteset=self
warn=false
for k in $game_map.events.keys.sort
warn=true if ($game_map.events[k].list!=nil and $game_map.events[k].list[0].code == 108 and ($game_map.events[k].list[0].parameters == ["sun"] or $game_map.events[k].list[0].parameters == ["o"]))
params = XPML_read("Sun",k,2)
$sun_spriteset.sun.push(params) if params!=nil
end
p "Warning : At least one event on this map uses the obsolete way to add a sun effect" if warn == true and SUN_WARN
sun_initialize
end
end
#===================================================
# ? XPML Definition, by Rataime, using ideas from Near Fantastica
#
# Returns nil if the markup wasn't present at all,
# returns [] if there wasn't any parameters, else
# returns a parameters list with "int" converted as int
# eg :
# begin first
# begin second
# param1 1
# param2 two
# begin third
# anything 3
#
# p XPML_read("first", event_id) -> []
# p XPML_read("second", event_id) -> [1,"two"]
# p XPML_read("third", event_id) -> [3]
# p XPML_read("forth", event_id) -> nil
#===================================================
def XPML_read(markup,event_id,max_param_number=0)
parameter_list = nil
event=$game_map.events[event_id]
return if event.list==nil
for i in 0...event.list.size
if event.list[i].code == 108 and event.list[i].parameters[0].downcase == "begin "+markup.downcase
parameter_list = [] if parameter_list == nil
for j in i+1...event.list.size
if event.list[j].code == 108
parts = event.list[j].parameters[0].split
if parts.size!=1 and parts[0].downcase!="begin"
if parts[1].to_i!=0 or parts[1]=="0"
parameter_list.push(parts[1].to_i)
else
parameter_list.push(parts[1])
end
else
return parameter_list
end
else
return parameter_list
end
return parameter_list if max_param_number!=0 and j==i+max_param_number
end
end
end
return parameter_list
end
# ? Sprite_Sun
# # Based on Sprite_Shadow, modified by Rataime
#==============================================================================
CATERPILLAR_COMPATIBLE = true
SUN_WARN =true
class Game_Party
attr_reader :characters
end
class Sprite_Sun < RPG::Sprite
attr_accessor :character
def initialize(viewport, character = nil,id=0)
super(viewport)
@character = character
params=$sun_spriteset.sun[id]
self_angle=45
self_angle=params[0] if params.size>0
self_opacity=128
self_opacity=params[1] if params.size>1
@self_angle=self_angle
@self_opacity=self_opacity
update
end
def update
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
@direct=@character.direction
if self.angle>90 or angle<-90
if @direct== 6
sy = ( 4- 2) / 2 * @ch
end
if @direct== 4
sy = ( 6- 2) / 2 * @ch
end
if @direct != 4 and @direct !=6
sy = (@character.direction - 2) / 2 * @ch
end
else
sy = (@character.direction - 2) / 2 * @ch
end
self.src_rect.set(sx, sy, @cw, @ch)
end
self.x = @character.screen_x
self.y = @character.screen_y-5
self.z = @character.screen_z(@ch)-1
self.opacity = @self_opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
self.angle = @self_angle.to_i-90
self.color = Color.new(0, 0, 0)
end
end
#===================================================
# ? CLASS Sprite_Character edit
#===================================================
class Sprite_Character < RPG::Sprite
alias sun_initialize initialize
def initialize(viewport, character = nil)
@character = character
super(viewport)
@sunlist=[]
if character.is_a?(Game_Event) and $sun_spriteset.sun!=[]
params = XPML_read("Shadow",@character.id,2)
if params!=nil
for i in 0...$sun_spriteset.sun.size
@sunlist.push(Sprite_Sun.new(viewport, @character,i))
end
end
end
if character.is_a?(Game_Player) and $sun_spriteset.sun!=[]
for i in 0...$sun_spriteset.sun.size
@sunlist.push(Sprite_Sun.new(viewport, $game_player,i))
end
#===================================================
# ? Compatibility with fukuyama's caterpillar script
#===================================================
if CATERPILLAR_COMPATIBLE and $game_party.characters!=nil
for member in $game_party.characters
for i in 0...$sun_spriteset.sun.size
@sunlist.push(Sprite_Sun.new(viewport, member,i))
end
end
end
#===================================================
# ? End of the compatibility
#===================================================
end
sun_initialize(viewport, @character)
end
alias sun_update update
def update
sun_update
if @sunlist!=[]
for i in 0...@sunlist.size
@sunlist[i].update
end
end
end
end
#===================================================
# ? CLASS Game_Event edit
#===================================================
class Game_Event
attr_accessor :id
end
#===================================================
# ? CLASS Spriteset_Map edit
#===================================================
class Spriteset_Map
attr_accessor :sun
alias sun_initialize initialize
def initialize
@sun=[]
$sun_spriteset=self
warn=false
for k in $game_map.events.keys.sort
warn=true if ($game_map.events[k].list!=nil and $game_map.events[k].list[0].code == 108 and ($game_map.events[k].list[0].parameters == ["sun"] or $game_map.events[k].list[0].parameters == ["o"]))
params = XPML_read("Sun",k,2)
$sun_spriteset.sun.push(params) if params!=nil
end
p "Warning : At least one event on this map uses the obsolete way to add a sun effect" if warn == true and SUN_WARN
sun_initialize
end
end
#===================================================
# ? XPML Definition, by Rataime, using ideas from Near Fantastica
#
# Returns nil if the markup wasn't present at all,
# returns [] if there wasn't any parameters, else
# returns a parameters list with "int" converted as int
# eg :
# begin first
# begin second
# param1 1
# param2 two
# begin third
# anything 3
#
# p XPML_read("first", event_id) -> []
# p XPML_read("second", event_id) -> [1,"two"]
# p XPML_read("third", event_id) -> [3]
# p XPML_read("forth", event_id) -> nil
#===================================================
def XPML_read(markup,event_id,max_param_number=0)
parameter_list = nil
event=$game_map.events[event_id]
return if event.list==nil
for i in 0...event.list.size
if event.list[i].code == 108 and event.list[i].parameters[0].downcase == "begin "+markup.downcase
parameter_list = [] if parameter_list == nil
for j in i+1...event.list.size
if event.list[j].code == 108
parts = event.list[j].parameters[0].split
if parts.size!=1 and parts[0].downcase!="begin"
if parts[1].to_i!=0 or parts[1]=="0"
parameter_list.push(parts[1].to_i)
else
parameter_list.push(parts[1])
end
else
return parameter_list
end
else
return parameter_list
end
return parameter_list if max_param_number!=0 and j==i+max_param_number
end
end
end
return parameter_list
end
SephirothSpawn's Dynamic bank Script:
Instructions:
Installation:
Now, make a new class above 'Main' and cal it Dynamic Banks then add the spoilered script into it.
Usage:
This is a very interesting little script. It calculates interest so whenever you leave money in the bank, it will accrue interest.
Now, to call this use this in a call script:
Quote:$scene = Scene_Bank.new
Now, to adjust this to your needs you can edit these lines:
Quote:@account_balance = 0
@interest_rate = 1
@saving_bonds = []
@last_interest_time = 0
these lines effect your initial balance, and interest rate, what savings bonds you already have, and the amount of time that has passed for your bonds and interest:
Quote:interest_time = (Graphics.frame_count / Graphics.frame_rate - @last_interest_time) / 3600.0
interest_amt = (@account_balance * @interest_rate / 100.0 * interest_time).to_I
These lines affect the amount of time it takes to update your balance with the interest, and how much the interest adds to your total amount of money. Note that the 3600 is in seconds:
Quote:bonds = [ Savings_Bond.new("CD-7", 100, 7.5, 7), Savings_Bond.new("CD-14", 500, 15, 14)])
finally, these allow you to modify the bonds. Hereââ¬â¢s a break down of how the bonds are set up above:
Quote:bonds = [ Savings_Bond.new("Bond Name", Bond Cost, Bond Intrest, Time for Bond to Mature )])
Now, if you want each bank to be different, then you can do this in the call script:
Quote:bonds = [ Savings_Bond.new("Bond Name", Bond Cost, Bond Intrest, Time for Bond to Mature )])
$scene = Scene_Bank.new(intrest)
so, in this exapmle, we want 2 custom bonds and a new intrest rate:
Quote:bonds = [Savings_Bond.new("Custom Bond 1", 10000, 30, 5), Savings_Bond.new("Custom Bond 2", 20000, 60, 10)])
$scene = Scene_Bank.new (10)
we now have 2 custom bonds and the interest rate will be set to 10%. Custom bond 1 will cost 10,000 gold, increase by 30% at maturity and take 5 hours of game play to mature, while custom bond 2 will cost 20,000 gold, increase by 60% at maturity and take 10 hours of game play to mature.
Dynamic Banks
#==============================================================================
# Banking System
#--------------------------------------------------------------------------
# Created By SephirothSpawn (12.05.05)
# Last Updated: 12.06.05
#==============================================================================
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Alias Command: New Game
#--------------------------------------------------------------------------
alias bank_command_new_game command_new_game
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
$game_bank = Game_BankSystem.new
bank_command_new_game
end
end
#==============================================================================
# ** Window_RefreshCommand
#==============================================================================
class Window_RefreshCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands)
# Compute window height from command quantity
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(commands = @commands)
@commands = commands
@item_max = commands.size
if self.contents != nil
self.contents.dispose
self.contents = nil
end
self.contents = Bitmap.new(width - 32, @item_max * 32)
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
self.contents.draw_text(0, 32 * index, self.contents.width - 8, 32, @commands[index], 1)
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
#--------------------------------------------------------------------------
# * Undisable Item
# index : item number
#--------------------------------------------------------------------------
def undisable_item(index)
draw_item(index, normal_color)
end
end
#==============================================================================
# ** Game_BankSystem
#==============================================================================
class Game_BankSystem
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :account_balance
attr_accessor :interest_rate
attr_accessor :saving_bonds
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@account_balance = 0
@interest_rate = 1
@saving_bonds = []
@last_interest_time = 0
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
# Updates Deposited Amount
interest_time = (Graphics.frame_count / Graphics.frame_rate - @last_interest_time) / 3600.0
interest_amt = (@account_balance * @interest_rate / 100.0 * interest_time).to_i
if interest_amt > 0
@last_interest_time = Graphics.frame_count / Graphics.frame_rate
@account_balance += interest_amt
# Refreshes Data Windows
$scene.refresh_windows
end
end
#--------------------------------------------------------------------------
# * Deposit
#--------------------------------------------------------------------------
def deposit(amount)
$game_party.lose_gold(amount)
@account_balance += amount
end
#--------------------------------------------------------------------------
# * Withdraw
#--------------------------------------------------------------------------
def withdraw(amount)
@account_balance -= amount
$game_party.gain_gold(amount)
end
#--------------------------------------------------------------------------
# * Add Savings Bond
#--------------------------------------------------------------------------
def add_bond(bond)
@saving_bonds.push(bond)
@saving_bonds.sort! {|a, b| a.name <=> b.name}
end
end
#==============================================================================
# ** Savings_Bond
#==============================================================================
class Savings_Bond
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :name
attr_accessor :cost
attr_accessor :interest_rate
attr_accessor :length
attr_accessor :time_bought
attr_accessor :time_finished
attr_accessor :mature_value
#--------------------------------------------------------------------------
# * Object Initialization
# name : Savings Bond Name
# cost : Savings Bond Cost
# interest_rate : Savings Bond Interest Rate (In Percent)
# length : Length of Hours until Mature
#--------------------------------------------------------------------------
def initialize(name, cost, interest_rate, length)
@name = name
@cost = cost
@interest_rate = interest_rate
@length = length
@mature_value = (@cost * (1+ @interest_rate / 100.0)).to_i
end
#--------------------------------------------------------------------------
# * Set Times
#--------------------------------------------------------------------------
def set_times
@time_bought = Graphics.frame_count / Graphics.frame_rate
@time_finished = @time_bought + @length * 3600
end
#--------------------------------------------------------------------------
# * Make Time to HH:MM:SS
#--------------------------------------------------------------------------
def return_time(time)
hours = time / 60 / 60
minutes = time / 60 % 60
seconds = time % 60
return sprintf("%02d:%02d:%02d", hours, minutes, seconds)
end
end
#==============================================================================
# ** Window_BankNumber
#==============================================================================
class Window_BankNumber < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(640, 272, 240, 192)
self.opacity = 175
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# * Refresh
# money : Gold being...
# type : Deposit or Withdraw
#--------------------------------------------------------------------------
def refresh(money, type)
contents.clear
# Deposit or Withdraw
contents.font.color = system_color
contents.draw_text(0, 0, contents.width, 24, "Amount to #{type}", 1)
if type == "Deposit"
# Draws Game Party Gold
contents.draw_text(4, 48, contents.width, 24, "Current #{$data_system.words.gold}:")
contents.font.color = normal_color
contents.draw_text(-4, 48, contents.width, 24, $game_party.gold.to_s, 2)
else
# Draws Account Balance
contents.draw_text(4, 48, contents.width, 24, "Account Balance:")
contents.font.color = normal_color
contents.draw_text(-4, 48, contents.width, 24, $game_bank.account_balance.to_s, 2)
end
# Draws Money Being Deposited or Withdrawn
contents.font.color = system_color
contents.draw_text(4, 72, contents.width, 24, "#{type} Amount:")
contents.font.color = normal_color
contents.draw_text(-4, 72, contents.width, 24, "- #{money}", 2)
# Draws Line
line = ""
while contents.text_size(line).width < contents.width
line += "-"
end
contents.draw_text(0, 96, contents.width, 24, line, 2)
# Draws Game Party Gold Amont
contents.font.color = system_color
contents.draw_text(4, 112, contents.width, 32, "#{$data_system.words.gold} After:")
amount = $game_party.gold
amount += type == "Deposit" ? -money : money
contents.font.color = normal_color
contents.draw_text(-4, 112, contents.width, 32, amount.to_s, 2)
# Draws Deposit Amont
amount = $game_bank.account_balance
amount += type == "Deposit" ? money : -money
contents.font.color = system_color
contents.draw_text(4, 136, contents.width, 32, "Balance After:")
contents.font.color = normal_color
contents.draw_text(-4, 136, contents.width, 32, amount.to_s, 2)
end
end
#==============================================================================
# ** Window_BankBio
#==============================================================================
class Window_BankBio < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-240, 272, 240, 192)
self.opacity = 175
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
# Deposit or Withdraw
contents.font.color = system_color
# Draws Actor Name in Postition 1
contents.font.color = normal_color
contents.draw_text(0, 0, contents.width, 24, "#{$game_party.actors[0].name}", 1)
# Draws Game Party Gold
contents.font.color = system_color
contents.draw_text(4, 32, contents.width, 24, "Current #{$data_system.words.gold}:")
contents.font.color = normal_color
contents.draw_text(-4, 32, contents.width, 24, $game_party.gold.to_s, 2)
# Draws Account Balance
contents.font.color = system_color
contents.draw_text(4, 56, contents.width, 24, "Account Balance:")
contents.font.color = normal_color
contents.draw_text(-4, 56, contents.width, 24, $game_bank.account_balance.to_s, 2)
# Draws Number of Savings Bond's
contents.font.color = system_color
contents.draw_text(4, 80, contents.width, 24, "Bonds Owned:")
contents.font.color = normal_color
contents.draw_text(-4, 80, contents.width, 24, $game_bank.saving_bonds.size.to_s, 2)
# Draws Value of Savings Bond's
value = 0
$game_bank.saving_bonds.each { |x| value += x.mature_value}
contents.font.color = system_color
contents.draw_text(4, 104, contents.width, 24, "Bonds Value:")
contents.font.color = normal_color
contents.draw_text(-4, 104, contents.width, 24, value.to_s, 2)
# Draws Current Interest Rate
contents.font.color = system_color
contents.draw_text(4, 136, contents.width, 24, "Interest Rate:")
contents.font.color = normal_color
contents.draw_text(-4, 136, contents.width, 24, "#{$game_bank.interest_rate} %", 2)
end
end
#==============================================================================
# ** Window_Bond
#==============================================================================
class Window_Bond < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-240, 264, 240, 200)
self.opacity = 175
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# * Refresh
# bond : Savings Bond
#--------------------------------------------------------------------------
def refresh(bond, bought = false)
contents.clear
unless bond == nil
# Draws Bond Name
contents.font.color = system_color
contents.draw_text(0, 0, contents.width, 24, bond.name, 1)
# Draws Bond Cost
contents.font.color = system_color
contents.draw_text(4, 24, contents.width, 24, "Bond Cost:")
contents.font.color = normal_color
contents.draw_text(-4, 24, contents.width, 24, bond.cost.to_s, 2)
# Draws Bond Mature Value
contents.font.color = system_color
contents.draw_text(4, 48, contents.width, 24, "Mature Value:")
contents.font.color = normal_color
contents.draw_text(-4, 48, contents.width, 24, "#{bond.mature_value}", 2)
# Draws Bond Interest Rate
contents.font.color = system_color
contents.draw_text(4, 72, contents.width, 24, "Interest Rate:")
contents.font.color = normal_color
contents.draw_text(-4, 72, contents.width, 24, "#{bond.interest_rate} %", 2)
# Draws Length until Maturity
contents.font.color = system_color
contents.draw_text(4, 96, contents.width, 24, "Maturity Time:")
contents.font.color = normal_color
contents.draw_text(-4, 96, contents.width, 24, "#{bond.length} Hours", 2)
# Display only if Purchased CD
if bought
# Draws Time Bought
contents.font.color = system_color
contents.draw_text(4, 120, contents.width, 24, "Time Bought:")
contents.font.color = normal_color
contents.draw_text(-4, 120, contents.width, 24, bond.return_time(bond.time_bought), 2)
# Draws Time Finished
contents.font.color = system_color
contents.draw_text(4, 144, contents.width, 24, "Time Finished:")
contents.font.color = normal_color
contents.draw_text(-4, 144, contents.width, 24, bond.return_time(bond.time_finished), 2)
end
end
end
end
#==============================================================================
# ** Scene_Bank
#==============================================================================
class Scene_Bank
#--------------------------------------------------------------------------
# * Object Initialization
# interest rate : Changes Current Interest Rate (Leave 0 for no Change)
# bonds : Avaliable CD's For Purchasing
#--------------------------------------------------------------------------
def initialize(interest_rate = $game_bank.interest_rate,
bonds = [ Savings_Bond.new("CD-7", 100, 7.5, 7), Savings_Bond.new("CD-14", 500, 15, 14)])
$game_bank.interest_rate = interest_rate unless interest_rate == 0
@bonds = bonds
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Current Phase
@phase = -1
# Refreshing Variables
@amount, @depositing = 0, true
@current_bond, @bond_bought = nil, false
# Make sprite set
@spriteset = Spriteset_Map.new
# Help Window
@help_window = Window_Help.new
@help_window.y, @help_window.opacity = -64, 175
@help_window.set_text("Welcome to the Bank", 1)
# Bank Bio
@bank_bio_window = Window_BankBio.new
# Avaliable Bond Information Display Window
@av_bond_display_window = Window_Bond.new
# Owned Bond Information Display Window
@own_bond_display_window = Window_Bond.new
# Main Command
@main_command = Window_RefreshCommand.new(180, [
"Deposit #{g_word = $data_system.words.gold}",
"Withdraw #{g_word}", "Purchase Bond", "Get Mature Bond", "Exit"])
@main_command.x, @main_command.y, @main_command.opacity = 644, 272, 175
@main_command.active = false
# Bank Number Window
@bank_number_window = Window_BankNumber.new
# Avaliable Bonds Command
commands = []
@bonds.each {|x| commands.push(x.name)}; commands.push("Back")
@av_bond_command = Window_RefreshCommand.new(180, commands)
@av_bond_command.x, @av_bond_command.y = 644, 272
@av_bond_command.height, @av_bond_command.opacity = 192, 175
@av_bond_command.active = false
# CD's Have
@own_bond_command = Window_RefreshCommand.new(180, get_cd_list)
@own_bond_command.x, @own_bond_command.y = 644, 272
@own_bond_command.height, @own_bond_command.opacity = 192, 175
@own_bond_command.active = false
# Scene Objects
@objects = [@spriteset, @help_window, @bank_bio_window, @av_bond_display_window,
@own_bond_display_window, @main_command, @bank_number_window,
@av_bond_command, @own_bond_command]
# Execute transition
Graphics.transition
# Main loop
while $scene == self
# Update game screen
Graphics.update
# Update input information
Input.update
# Update Objects
@objects.each {|x| x.update}
# Updates Bank System
$game_bank.update
# Frame update
update
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@objects.each {|x| x.dispose}
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Splits Phases Up
case @phase
when -1 # Intro Phase
intro_update
when 0 # Main Phase
main_update
when 1 # Deposit or Withdraw Phase
account_update
when 2 # Buy CD Phase
buy_bond_update
when 3 # Get Mature CD Phse
get_bond_update
when 99 # Exit Phase
exit_update
end
end
#--------------------------------------------------------------------------
# * Intro Update
#--------------------------------------------------------------------------
def intro_update
# Moves Window Down
@help_window.y += 4 if @help_window.y < 0
if @help_window.y == 0
# Input Processing
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
# Returns to Scene
@phase = 99
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
# Switchs to Main Phase
@phase = 0
end
end
end
#--------------------------------------------------------------------------
# * Main Update
#--------------------------------------------------------------------------
def main_update
# Turns On Main Command
@main_command.active = true
# Turns Off Other Command Windows
@av_bond_command.active = @own_bond_command.active = false
# Moves In Active Windows
@bank_bio_window.z = @main_command.z = 9999
@bank_bio_window.x += 32 if @bank_bio_window.x < 16
@main_command.x -= 25 if @main_command.x > 444
# Moves Out Inactive Windows
@av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
[@av_bond_display_window, @own_bond_display_window, @bank_number_window,
@av_bond_command, @own_bond_command].each {|window| window.z = 9995}
[@av_bond_command, @own_bond_command].each {|command|
command.x += 25 if command.x < 644}
@own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
@bank_number_window.x += 32 if @bank_number_window.x < 640
# Sets Help Window
case @main_command.index
when 0; @help_window.set_text("Deposit Money Into your Account", 1)
when 1; @help_window.set_text("Withdraw Money From your Account", 1)
when 2; @help_window.set_text("Purchase a Savings Bond", 1)
when 3; @help_window.set_text("Take Out Mature Savings Bond", 1)
when 4; @help_window.set_text("Exit Bank", 1)
end
# Input Processing
if Input.trigger?(Input::B) # Returns to Map
$game_system.se_play($data_system.cancel_se)
@phase = 99
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @main_command.index
when 0 # Deposit
@amount, @depositing = 0, true
refresh_windows
@help_window.set_text("Deposit #{@amount} #{$data_system.words.gold}", 1)
@phase = 1
when 1 # Withdraw
@amount, @depositing = 0, false
refresh_windows
@help_window.set_text("Withdraw #{@amount} #{$data_system.words.gold}", 1)
@phase = 1
when 2 # Buy CD
@current_bond = @bonds[@av_bond_command.index]
@bond_bought = false
refresh_windows
@phase = 2
when 3 # Get CD
@current_bond = $game_bank.saving_bonds[@own_bond_command.index]
@bond_bought = true
refresh_windows
@phase = 3
when 4 # Exit Bank
@phase = 99
end
end
end
#--------------------------------------------------------------------------
# * Accpunt Update
#--------------------------------------------------------------------------
def account_update
# Turns Off Command Windows
@main_command.active = @av_bond_command.active = @own_bond_command.active = false
# Moves In Active Windows
@bank_bio_window.z = @bank_number_window.z = 9999
@bank_bio_window.x += 32 if @bank_bio_window.x < 16
@bank_number_window.x -= 32 if @bank_number_window.x > 384
# Moves Out Inactive Windows
@av_bond_display_window.z = @own_bond_display_window.z =
@main_command.z = @av_bond_command.z = @own_bond_command.z = 9995
@av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
[@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
[@main_command, @av_bond_command, @own_bond_command].each {|command|
command.x += 25 if command.x < 644}
# Input Processing
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@phase = 0
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.shop_se)
if @depositing
$game_bank.deposit(@amount)
refresh_windows
@phase = 0
else
$game_bank.withdraw(@amount)
refresh_windows
@phase = 0
end
elsif Input.repeat?(Input::LEFT) && Input.press?(Input::LEFT)
if @amount > 0
$game_system.se_play($data_system.cursor_se)
@amount -= 1
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
elsif Input.repeat?(Input::RIGHT) && Input.press?(Input::RIGHT)
if @depositing
if @amount < $game_party.gold
$game_system.se_play($data_system.cursor_se)
@amount += 1
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
else
if @amount < $game_bank.account_balance
$game_system.se_play($data_system.cursor_se)
@amount += 1
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
end
elsif Input.repeat?(Input::UP) && Input.press?(Input::UP)
if @amount == 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
@amount > 10 ? @amount -= 10 : @amount = 0
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
end
elsif Input.repeat?(Input::DOWN) && Input.press?(Input::DOWN)
if @depositing
if @amount < $game_party.gold
$game_system.se_play($data_system.cursor_se)
@amount < $game_party.gold - 10 ? @amount += 10 : @amount = $game_party.gold
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
else
if @amount < $game_bank.account_balance
$game_system.se_play($data_system.cursor_se)
@amount < $game_bank.account_balance - 10 ? @amount += 10 : @amount = $game_bank.account_balance
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
end
elsif Input.repeat?(Input::L) && Input.press?(Input::L)
if @amount == 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
@amount > 100 ? @amount -= 100 : @amount = 0
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
end
elsif Input.repeat?(Input::R) && Input.press?(Input::R)
if @depositing
if @amount < $game_party.gold
$game_system.se_play($data_system.cursor_se)
@amount < $game_party.gold - 100 ? @amount += 100 : @amount = $game_party.gold
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
else
if @amount < $game_bank.account_balance
$game_system.se_play($data_system.cursor_se)
@amount < $game_bank.account_balance - 100 ? @amount += 100 : @amount = $game_bank.account_balance
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
end
end
end
#--------------------------------------------------------------------------
# * Buy Bond Update
#--------------------------------------------------------------------------
def buy_bond_update
# Turns On Avaliable Bond Window
@av_bond_command.active = true
# Turns Off Other Command Windows
@main_command.active = @own_bond_command.active = false
# Moves In Active Windows
@av_bond_display_window.z = @av_bond_command.z = 9999
@av_bond_display_window.x += 32 if @av_bond_display_window.x < 16
@av_bond_command.x -= 25 if @av_bond_command.x > 444
# Moves Out Inactive Windows
[@bank_bio_window, @bank_number_window, @own_bond_display_window,
@main_command, @own_bond_command].each {|window| window.z = 9995}
@bank_bio_window.x -= 32 if @bank_bio_window.x > - 240
@bank_number_window.x += 32 if @bank_number_window.x < 640
@own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
[@main_command, @own_bond_command].each {|command| command.x += 25 if command.x < 644}
# Input Processing
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@phase = 0
elsif Input.trigger?(Input::C)
if @av_bond_command.index == @bonds.size
$game_system.se_play($data_system.cancel_se)
@phase = 0
else
current_bond = @bonds[@av_bond_command.index].dup
if current_bond.cost > $game_party.gold
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
$game_party.lose_gold(current_bond.cost)
current_bond.set_times
$game_bank.add_bond(current_bond)
refresh_windows
@phase = 0
end
end
# Updates Current Bond
elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
@current_bond = @bonds[@av_bond_command.index]
refresh_windows
end
end
#--------------------------------------------------------------------------
# * Get Bond Update
#--------------------------------------------------------------------------
def get_bond_update
# Turns On Avaliable Bond Window
@own_bond_command.active = true
# Turns Off Other Command Windows
@main_command.active = @av_bond_command.active = false
# Moves In Active Windows
[@own_bond_display_window, @own_bond_command].each {|window| window.z = 9999}
@own_bond_display_window.x += 32 if @own_bond_display_window.x < 16
@own_bond_command.x -= 25 if @own_bond_command.x > 444
# Moves Out Inactive Windows
[@bank_bio_window, @av_bond_display_window, @main_command, @bank_number_window,
@av_bond_command].each {|window| window.z = 9995}
[@bank_bio_window, @av_bond_display_window].each {|window|
window.x -= 32 if window.x > - 240}
[@main_command, @av_bond_command].each {|window|
window.x += 25 if window.x < 640}
@bank_number_window.x += 32 if @bank_number_window.x < 640
# Input Processing
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@phase = 0
elsif Input.trigger?(Input::C)
if @own_bond_command.index == $game_bank.saving_bonds.size
$game_system.se_play($data_system.cancel_se)
@phase = 0
else
current_bond = $game_bank.saving_bonds[@own_bond_command.index]
if current_bond.time_finished > Graphics.frame_count / Graphics.frame_rate
$game_system.se_play($data_system.buzzer_se)
@help_window.set_text("Savings Bond Not Mature Yet!", 1)
else
$game_system.se_play($data_system.decision_se)
$game_party.gain_gold(current_bond.mature_value)
$game_bank.saving_bonds.delete_at[@own_bond_command.index]
refresh_windows
@phase = 0
end
end
elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
@current_bond = $game_bank.saving_bonds[@own_bond_command.index]
refresh_windows
end
end
#--------------------------------------------------------------------------
# * Exit Update
#--------------------------------------------------------------------------
def exit_update
# Moves Out Windows
@help_window.y -= 4 if @help_window.y > - 64
[@bank_bio_window, @av_bond_display_window].each {|window| window.x -= 32 if window.x > - 240}
[@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
[@main_command, @bank_number_window, @av_bond_command,
@own_bond_command].each {|window| window.x += 25 if window.x < 640}
# Checks To Make Sure All Windows Are Out
if @help_window.y <= - 64 && @bank_bio_window.x <= - 240 && @av_bond_display_window.x <= - 240 &&
@own_bond_display_window.x <= - 240 && @main_command.x >= 644 &&
@bank_number_window.x >= 640 && @av_bond_command.x >= 640 && @own_bond_command.x >= 640
$scene = Scene_Map.new
end
end
#--------------------------------------------------------------------------
# * Get CD List
#--------------------------------------------------------------------------
def get_cd_list
commands = []
$game_bank.saving_bonds.each {|x| commands.push(x.name)}
commands.push("Back")
return commands
end
#--------------------------------------------------------------------------
# * Refresh Windows
#--------------------------------------------------------------------------
def refresh_windows
@bank_bio_window.refresh
@av_bond_display_window.refresh(@current_bond, @bond_bought)
@own_bond_display_window.refresh(@current_bond, @bond_bought)
@bank_number_window.refresh(@amount, @depositing ? "Deposit" : "Withdraw")
@own_bond_command.refresh(get_cd_list)
end
end
# Banking System
#--------------------------------------------------------------------------
# Created By SephirothSpawn (12.05.05)
# Last Updated: 12.06.05
#==============================================================================
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Alias Command: New Game
#--------------------------------------------------------------------------
alias bank_command_new_game command_new_game
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
$game_bank = Game_BankSystem.new
bank_command_new_game
end
end
#==============================================================================
# ** Window_RefreshCommand
#==============================================================================
class Window_RefreshCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands)
# Compute window height from command quantity
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(commands = @commands)
@commands = commands
@item_max = commands.size
if self.contents != nil
self.contents.dispose
self.contents = nil
end
self.contents = Bitmap.new(width - 32, @item_max * 32)
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
self.contents.draw_text(0, 32 * index, self.contents.width - 8, 32, @commands[index], 1)
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
#--------------------------------------------------------------------------
# * Undisable Item
# index : item number
#--------------------------------------------------------------------------
def undisable_item(index)
draw_item(index, normal_color)
end
end
#==============================================================================
# ** Game_BankSystem
#==============================================================================
class Game_BankSystem
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :account_balance
attr_accessor :interest_rate
attr_accessor :saving_bonds
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@account_balance = 0
@interest_rate = 1
@saving_bonds = []
@last_interest_time = 0
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
# Updates Deposited Amount
interest_time = (Graphics.frame_count / Graphics.frame_rate - @last_interest_time) / 3600.0
interest_amt = (@account_balance * @interest_rate / 100.0 * interest_time).to_i
if interest_amt > 0
@last_interest_time = Graphics.frame_count / Graphics.frame_rate
@account_balance += interest_amt
# Refreshes Data Windows
$scene.refresh_windows
end
end
#--------------------------------------------------------------------------
# * Deposit
#--------------------------------------------------------------------------
def deposit(amount)
$game_party.lose_gold(amount)
@account_balance += amount
end
#--------------------------------------------------------------------------
# * Withdraw
#--------------------------------------------------------------------------
def withdraw(amount)
@account_balance -= amount
$game_party.gain_gold(amount)
end
#--------------------------------------------------------------------------
# * Add Savings Bond
#--------------------------------------------------------------------------
def add_bond(bond)
@saving_bonds.push(bond)
@saving_bonds.sort! {|a, b| a.name <=> b.name}
end
end
#==============================================================================
# ** Savings_Bond
#==============================================================================
class Savings_Bond
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :name
attr_accessor :cost
attr_accessor :interest_rate
attr_accessor :length
attr_accessor :time_bought
attr_accessor :time_finished
attr_accessor :mature_value
#--------------------------------------------------------------------------
# * Object Initialization
# name : Savings Bond Name
# cost : Savings Bond Cost
# interest_rate : Savings Bond Interest Rate (In Percent)
# length : Length of Hours until Mature
#--------------------------------------------------------------------------
def initialize(name, cost, interest_rate, length)
@name = name
@cost = cost
@interest_rate = interest_rate
@length = length
@mature_value = (@cost * (1+ @interest_rate / 100.0)).to_i
end
#--------------------------------------------------------------------------
# * Set Times
#--------------------------------------------------------------------------
def set_times
@time_bought = Graphics.frame_count / Graphics.frame_rate
@time_finished = @time_bought + @length * 3600
end
#--------------------------------------------------------------------------
# * Make Time to HH:MM:SS
#--------------------------------------------------------------------------
def return_time(time)
hours = time / 60 / 60
minutes = time / 60 % 60
seconds = time % 60
return sprintf("%02d:%02d:%02d", hours, minutes, seconds)
end
end
#==============================================================================
# ** Window_BankNumber
#==============================================================================
class Window_BankNumber < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(640, 272, 240, 192)
self.opacity = 175
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# * Refresh
# money : Gold being...
# type : Deposit or Withdraw
#--------------------------------------------------------------------------
def refresh(money, type)
contents.clear
# Deposit or Withdraw
contents.font.color = system_color
contents.draw_text(0, 0, contents.width, 24, "Amount to #{type}", 1)
if type == "Deposit"
# Draws Game Party Gold
contents.draw_text(4, 48, contents.width, 24, "Current #{$data_system.words.gold}:")
contents.font.color = normal_color
contents.draw_text(-4, 48, contents.width, 24, $game_party.gold.to_s, 2)
else
# Draws Account Balance
contents.draw_text(4, 48, contents.width, 24, "Account Balance:")
contents.font.color = normal_color
contents.draw_text(-4, 48, contents.width, 24, $game_bank.account_balance.to_s, 2)
end
# Draws Money Being Deposited or Withdrawn
contents.font.color = system_color
contents.draw_text(4, 72, contents.width, 24, "#{type} Amount:")
contents.font.color = normal_color
contents.draw_text(-4, 72, contents.width, 24, "- #{money}", 2)
# Draws Line
line = ""
while contents.text_size(line).width < contents.width
line += "-"
end
contents.draw_text(0, 96, contents.width, 24, line, 2)
# Draws Game Party Gold Amont
contents.font.color = system_color
contents.draw_text(4, 112, contents.width, 32, "#{$data_system.words.gold} After:")
amount = $game_party.gold
amount += type == "Deposit" ? -money : money
contents.font.color = normal_color
contents.draw_text(-4, 112, contents.width, 32, amount.to_s, 2)
# Draws Deposit Amont
amount = $game_bank.account_balance
amount += type == "Deposit" ? money : -money
contents.font.color = system_color
contents.draw_text(4, 136, contents.width, 32, "Balance After:")
contents.font.color = normal_color
contents.draw_text(-4, 136, contents.width, 32, amount.to_s, 2)
end
end
#==============================================================================
# ** Window_BankBio
#==============================================================================
class Window_BankBio < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-240, 272, 240, 192)
self.opacity = 175
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
# Deposit or Withdraw
contents.font.color = system_color
# Draws Actor Name in Postition 1
contents.font.color = normal_color
contents.draw_text(0, 0, contents.width, 24, "#{$game_party.actors[0].name}", 1)
# Draws Game Party Gold
contents.font.color = system_color
contents.draw_text(4, 32, contents.width, 24, "Current #{$data_system.words.gold}:")
contents.font.color = normal_color
contents.draw_text(-4, 32, contents.width, 24, $game_party.gold.to_s, 2)
# Draws Account Balance
contents.font.color = system_color
contents.draw_text(4, 56, contents.width, 24, "Account Balance:")
contents.font.color = normal_color
contents.draw_text(-4, 56, contents.width, 24, $game_bank.account_balance.to_s, 2)
# Draws Number of Savings Bond's
contents.font.color = system_color
contents.draw_text(4, 80, contents.width, 24, "Bonds Owned:")
contents.font.color = normal_color
contents.draw_text(-4, 80, contents.width, 24, $game_bank.saving_bonds.size.to_s, 2)
# Draws Value of Savings Bond's
value = 0
$game_bank.saving_bonds.each { |x| value += x.mature_value}
contents.font.color = system_color
contents.draw_text(4, 104, contents.width, 24, "Bonds Value:")
contents.font.color = normal_color
contents.draw_text(-4, 104, contents.width, 24, value.to_s, 2)
# Draws Current Interest Rate
contents.font.color = system_color
contents.draw_text(4, 136, contents.width, 24, "Interest Rate:")
contents.font.color = normal_color
contents.draw_text(-4, 136, contents.width, 24, "#{$game_bank.interest_rate} %", 2)
end
end
#==============================================================================
# ** Window_Bond
#==============================================================================
class Window_Bond < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-240, 264, 240, 200)
self.opacity = 175
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# * Refresh
# bond : Savings Bond
#--------------------------------------------------------------------------
def refresh(bond, bought = false)
contents.clear
unless bond == nil
# Draws Bond Name
contents.font.color = system_color
contents.draw_text(0, 0, contents.width, 24, bond.name, 1)
# Draws Bond Cost
contents.font.color = system_color
contents.draw_text(4, 24, contents.width, 24, "Bond Cost:")
contents.font.color = normal_color
contents.draw_text(-4, 24, contents.width, 24, bond.cost.to_s, 2)
# Draws Bond Mature Value
contents.font.color = system_color
contents.draw_text(4, 48, contents.width, 24, "Mature Value:")
contents.font.color = normal_color
contents.draw_text(-4, 48, contents.width, 24, "#{bond.mature_value}", 2)
# Draws Bond Interest Rate
contents.font.color = system_color
contents.draw_text(4, 72, contents.width, 24, "Interest Rate:")
contents.font.color = normal_color
contents.draw_text(-4, 72, contents.width, 24, "#{bond.interest_rate} %", 2)
# Draws Length until Maturity
contents.font.color = system_color
contents.draw_text(4, 96, contents.width, 24, "Maturity Time:")
contents.font.color = normal_color
contents.draw_text(-4, 96, contents.width, 24, "#{bond.length} Hours", 2)
# Display only if Purchased CD
if bought
# Draws Time Bought
contents.font.color = system_color
contents.draw_text(4, 120, contents.width, 24, "Time Bought:")
contents.font.color = normal_color
contents.draw_text(-4, 120, contents.width, 24, bond.return_time(bond.time_bought), 2)
# Draws Time Finished
contents.font.color = system_color
contents.draw_text(4, 144, contents.width, 24, "Time Finished:")
contents.font.color = normal_color
contents.draw_text(-4, 144, contents.width, 24, bond.return_time(bond.time_finished), 2)
end
end
end
end
#==============================================================================
# ** Scene_Bank
#==============================================================================
class Scene_Bank
#--------------------------------------------------------------------------
# * Object Initialization
# interest rate : Changes Current Interest Rate (Leave 0 for no Change)
# bonds : Avaliable CD's For Purchasing
#--------------------------------------------------------------------------
def initialize(interest_rate = $game_bank.interest_rate,
bonds = [ Savings_Bond.new("CD-7", 100, 7.5, 7), Savings_Bond.new("CD-14", 500, 15, 14)])
$game_bank.interest_rate = interest_rate unless interest_rate == 0
@bonds = bonds
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Current Phase
@phase = -1
# Refreshing Variables
@amount, @depositing = 0, true
@current_bond, @bond_bought = nil, false
# Make sprite set
@spriteset = Spriteset_Map.new
# Help Window
@help_window = Window_Help.new
@help_window.y, @help_window.opacity = -64, 175
@help_window.set_text("Welcome to the Bank", 1)
# Bank Bio
@bank_bio_window = Window_BankBio.new
# Avaliable Bond Information Display Window
@av_bond_display_window = Window_Bond.new
# Owned Bond Information Display Window
@own_bond_display_window = Window_Bond.new
# Main Command
@main_command = Window_RefreshCommand.new(180, [
"Deposit #{g_word = $data_system.words.gold}",
"Withdraw #{g_word}", "Purchase Bond", "Get Mature Bond", "Exit"])
@main_command.x, @main_command.y, @main_command.opacity = 644, 272, 175
@main_command.active = false
# Bank Number Window
@bank_number_window = Window_BankNumber.new
# Avaliable Bonds Command
commands = []
@bonds.each {|x| commands.push(x.name)}; commands.push("Back")
@av_bond_command = Window_RefreshCommand.new(180, commands)
@av_bond_command.x, @av_bond_command.y = 644, 272
@av_bond_command.height, @av_bond_command.opacity = 192, 175
@av_bond_command.active = false
# CD's Have
@own_bond_command = Window_RefreshCommand.new(180, get_cd_list)
@own_bond_command.x, @own_bond_command.y = 644, 272
@own_bond_command.height, @own_bond_command.opacity = 192, 175
@own_bond_command.active = false
# Scene Objects
@objects = [@spriteset, @help_window, @bank_bio_window, @av_bond_display_window,
@own_bond_display_window, @main_command, @bank_number_window,
@av_bond_command, @own_bond_command]
# Execute transition
Graphics.transition
# Main loop
while $scene == self
# Update game screen
Graphics.update
# Update input information
Input.update
# Update Objects
@objects.each {|x| x.update}
# Updates Bank System
$game_bank.update
# Frame update
update
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@objects.each {|x| x.dispose}
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Splits Phases Up
case @phase
when -1 # Intro Phase
intro_update
when 0 # Main Phase
main_update
when 1 # Deposit or Withdraw Phase
account_update
when 2 # Buy CD Phase
buy_bond_update
when 3 # Get Mature CD Phse
get_bond_update
when 99 # Exit Phase
exit_update
end
end
#--------------------------------------------------------------------------
# * Intro Update
#--------------------------------------------------------------------------
def intro_update
# Moves Window Down
@help_window.y += 4 if @help_window.y < 0
if @help_window.y == 0
# Input Processing
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
# Returns to Scene
@phase = 99
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
# Switchs to Main Phase
@phase = 0
end
end
end
#--------------------------------------------------------------------------
# * Main Update
#--------------------------------------------------------------------------
def main_update
# Turns On Main Command
@main_command.active = true
# Turns Off Other Command Windows
@av_bond_command.active = @own_bond_command.active = false
# Moves In Active Windows
@bank_bio_window.z = @main_command.z = 9999
@bank_bio_window.x += 32 if @bank_bio_window.x < 16
@main_command.x -= 25 if @main_command.x > 444
# Moves Out Inactive Windows
@av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
[@av_bond_display_window, @own_bond_display_window, @bank_number_window,
@av_bond_command, @own_bond_command].each {|window| window.z = 9995}
[@av_bond_command, @own_bond_command].each {|command|
command.x += 25 if command.x < 644}
@own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
@bank_number_window.x += 32 if @bank_number_window.x < 640
# Sets Help Window
case @main_command.index
when 0; @help_window.set_text("Deposit Money Into your Account", 1)
when 1; @help_window.set_text("Withdraw Money From your Account", 1)
when 2; @help_window.set_text("Purchase a Savings Bond", 1)
when 3; @help_window.set_text("Take Out Mature Savings Bond", 1)
when 4; @help_window.set_text("Exit Bank", 1)
end
# Input Processing
if Input.trigger?(Input::B) # Returns to Map
$game_system.se_play($data_system.cancel_se)
@phase = 99
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @main_command.index
when 0 # Deposit
@amount, @depositing = 0, true
refresh_windows
@help_window.set_text("Deposit #{@amount} #{$data_system.words.gold}", 1)
@phase = 1
when 1 # Withdraw
@amount, @depositing = 0, false
refresh_windows
@help_window.set_text("Withdraw #{@amount} #{$data_system.words.gold}", 1)
@phase = 1
when 2 # Buy CD
@current_bond = @bonds[@av_bond_command.index]
@bond_bought = false
refresh_windows
@phase = 2
when 3 # Get CD
@current_bond = $game_bank.saving_bonds[@own_bond_command.index]
@bond_bought = true
refresh_windows
@phase = 3
when 4 # Exit Bank
@phase = 99
end
end
end
#--------------------------------------------------------------------------
# * Accpunt Update
#--------------------------------------------------------------------------
def account_update
# Turns Off Command Windows
@main_command.active = @av_bond_command.active = @own_bond_command.active = false
# Moves In Active Windows
@bank_bio_window.z = @bank_number_window.z = 9999
@bank_bio_window.x += 32 if @bank_bio_window.x < 16
@bank_number_window.x -= 32 if @bank_number_window.x > 384
# Moves Out Inactive Windows
@av_bond_display_window.z = @own_bond_display_window.z =
@main_command.z = @av_bond_command.z = @own_bond_command.z = 9995
@av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
[@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
[@main_command, @av_bond_command, @own_bond_command].each {|command|
command.x += 25 if command.x < 644}
# Input Processing
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@phase = 0
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.shop_se)
if @depositing
$game_bank.deposit(@amount)
refresh_windows
@phase = 0
else
$game_bank.withdraw(@amount)
refresh_windows
@phase = 0
end
elsif Input.repeat?(Input::LEFT) && Input.press?(Input::LEFT)
if @amount > 0
$game_system.se_play($data_system.cursor_se)
@amount -= 1
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
elsif Input.repeat?(Input::RIGHT) && Input.press?(Input::RIGHT)
if @depositing
if @amount < $game_party.gold
$game_system.se_play($data_system.cursor_se)
@amount += 1
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
else
if @amount < $game_bank.account_balance
$game_system.se_play($data_system.cursor_se)
@amount += 1
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
end
elsif Input.repeat?(Input::UP) && Input.press?(Input::UP)
if @amount == 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
@amount > 10 ? @amount -= 10 : @amount = 0
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
end
elsif Input.repeat?(Input::DOWN) && Input.press?(Input::DOWN)
if @depositing
if @amount < $game_party.gold
$game_system.se_play($data_system.cursor_se)
@amount < $game_party.gold - 10 ? @amount += 10 : @amount = $game_party.gold
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
else
if @amount < $game_bank.account_balance
$game_system.se_play($data_system.cursor_se)
@amount < $game_bank.account_balance - 10 ? @amount += 10 : @amount = $game_bank.account_balance
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
end
elsif Input.repeat?(Input::L) && Input.press?(Input::L)
if @amount == 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
@amount > 100 ? @amount -= 100 : @amount = 0
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
end
elsif Input.repeat?(Input::R) && Input.press?(Input::R)
if @depositing
if @amount < $game_party.gold
$game_system.se_play($data_system.cursor_se)
@amount < $game_party.gold - 100 ? @amount += 100 : @amount = $game_party.gold
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
else
if @amount < $game_bank.account_balance
$game_system.se_play($data_system.cursor_se)
@amount < $game_bank.account_balance - 100 ? @amount += 100 : @amount = $game_bank.account_balance
refresh_windows
@help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
else
$game_system.se_play($data_system.buzzer_se)
end
end
end
end
#--------------------------------------------------------------------------
# * Buy Bond Update
#--------------------------------------------------------------------------
def buy_bond_update
# Turns On Avaliable Bond Window
@av_bond_command.active = true
# Turns Off Other Command Windows
@main_command.active = @own_bond_command.active = false
# Moves In Active Windows
@av_bond_display_window.z = @av_bond_command.z = 9999
@av_bond_display_window.x += 32 if @av_bond_display_window.x < 16
@av_bond_command.x -= 25 if @av_bond_command.x > 444
# Moves Out Inactive Windows
[@bank_bio_window, @bank_number_window, @own_bond_display_window,
@main_command, @own_bond_command].each {|window| window.z = 9995}
@bank_bio_window.x -= 32 if @bank_bio_window.x > - 240
@bank_number_window.x += 32 if @bank_number_window.x < 640
@own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
[@main_command, @own_bond_command].each {|command| command.x += 25 if command.x < 644}
# Input Processing
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@phase = 0
elsif Input.trigger?(Input::C)
if @av_bond_command.index == @bonds.size
$game_system.se_play($data_system.cancel_se)
@phase = 0
else
current_bond = @bonds[@av_bond_command.index].dup
if current_bond.cost > $game_party.gold
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
$game_party.lose_gold(current_bond.cost)
current_bond.set_times
$game_bank.add_bond(current_bond)
refresh_windows
@phase = 0
end
end
# Updates Current Bond
elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
@current_bond = @bonds[@av_bond_command.index]
refresh_windows
end
end
#--------------------------------------------------------------------------
# * Get Bond Update
#--------------------------------------------------------------------------
def get_bond_update
# Turns On Avaliable Bond Window
@own_bond_command.active = true
# Turns Off Other Command Windows
@main_command.active = @av_bond_command.active = false
# Moves In Active Windows
[@own_bond_display_window, @own_bond_command].each {|window| window.z = 9999}
@own_bond_display_window.x += 32 if @own_bond_display_window.x < 16
@own_bond_command.x -= 25 if @own_bond_command.x > 444
# Moves Out Inactive Windows
[@bank_bio_window, @av_bond_display_window, @main_command, @bank_number_window,
@av_bond_command].each {|window| window.z = 9995}
[@bank_bio_window, @av_bond_display_window].each {|window|
window.x -= 32 if window.x > - 240}
[@main_command, @av_bond_command].each {|window|
window.x += 25 if window.x < 640}
@bank_number_window.x += 32 if @bank_number_window.x < 640
# Input Processing
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@phase = 0
elsif Input.trigger?(Input::C)
if @own_bond_command.index == $game_bank.saving_bonds.size
$game_system.se_play($data_system.cancel_se)
@phase = 0
else
current_bond = $game_bank.saving_bonds[@own_bond_command.index]
if current_bond.time_finished > Graphics.frame_count / Graphics.frame_rate
$game_system.se_play($data_system.buzzer_se)
@help_window.set_text("Savings Bond Not Mature Yet!", 1)
else
$game_system.se_play($data_system.decision_se)
$game_party.gain_gold(current_bond.mature_value)
$game_bank.saving_bonds.delete_at[@own_bond_command.index]
refresh_windows
@phase = 0
end
end
elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
@current_bond = $game_bank.saving_bonds[@own_bond_command.index]
refresh_windows
end
end
#--------------------------------------------------------------------------
# * Exit Update
#--------------------------------------------------------------------------
def exit_update
# Moves Out Windows
@help_window.y -= 4 if @help_window.y > - 64
[@bank_bio_window, @av_bond_display_window].each {|window| window.x -= 32 if window.x > - 240}
[@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
[@main_command, @bank_number_window, @av_bond_command,
@own_bond_command].each {|window| window.x += 25 if window.x < 640}
# Checks To Make Sure All Windows Are Out
if @help_window.y <= - 64 && @bank_bio_window.x <= - 240 && @av_bond_display_window.x <= - 240 &&
@own_bond_display_window.x <= - 240 && @main_command.x >= 644 &&
@bank_number_window.x >= 640 && @av_bond_command.x >= 640 && @own_bond_command.x >= 640
$scene = Scene_Map.new
end
end
#--------------------------------------------------------------------------
# * Get CD List
#--------------------------------------------------------------------------
def get_cd_list
commands = []
$game_bank.saving_bonds.each {|x| commands.push(x.name)}
commands.push("Back")
return commands
end
#--------------------------------------------------------------------------
# * Refresh Windows
#--------------------------------------------------------------------------
def refresh_windows
@bank_bio_window.refresh
@av_bond_display_window.refresh(@current_bond, @bond_bought)
@own_bond_display_window.refresh(@current_bond, @bond_bought)
@bank_number_window.refresh(@amount, @depositing ? "Deposit" : "Withdraw")
@own_bond_command.refresh(get_cd_list)
end
end