#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#
# B E G I N C O N F I G U R A T I O N
#
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
module Swim_Config
=begin
#-=-=-=-=-=-=-=-=-=-=-#
# * script calls #
#-=-=-=-=-=-=-=-=-=-=-#
#changes the value of oxegen pictures if PICTURE_MODE is true
$game_system.oxegen_pictures = VALUE
#changes the max oxegen when bar mode is active
$game_system.oxegen_max = VALUE
#-=-=-=-=-=-=-=-=-=-=-#
# * end script calls #
#-=-=-=-=-=-=-=-=-=-=-#
=end
#Extension of the filename to change the swimming graphic
SWIM_EXTENSION = '_swim'
#Terrain tag of water to swim on
WATER_TERRAIN = 2
#oxegen timer when in water (true/false)
OXEGEN_TIMER = false
#picture mode if true, bar mode if false
PICTURE_MODE = false
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * if oxegen timer is true #
#-------------------------------------------------------------------------#
# * if the picture mode is true #
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
#Picture name of the oxegen picture to show
PICTURE_NAME = 'bubble'
#initial amount of oxegen pictures
PICTURES = 5
#how many frames does it take for 1 oxegen picture to disapear?
PICTURE_FRAMES = 100
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * if the picture mode is not true (bar mode) #
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
#how many initial oxegen blocks(pixles) are there?
OXEGEN = 100
#the frame rate each oxegen block(pixle) decreases
OXEGEN_COUNT = 10
end
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#
# E N D C O N F I G U R A T I O N
#
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_System
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_System
attr_accessor :oxegen_picture_count
attr_accessor :oxegen_pictures
attr_accessor :oxegen_max
attr_accessor :oxegen
attr_accessor :oxegen_count
alias init_swim initialize
def initialize
init_swim
@oxegen_picture_count = 0
@oxegen_pictures = Swim_Config::PICTURES
@oxegen_max = Swim_Config::OXEGEN
@oxegen = @oxegen_max
@oxegen_count = Swim_Config::OXEGEN_COUNT
end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Map
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Map
attr_accessor :passages, :map, :virtual_passability
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Character
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Character
attr_reader :swimming
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Window_Oxegen
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Window_Oxegen < Window_Base
def initialize
if Swim_Config::PICTURE_MODE == true
@image = RPG::Cache.picture(Swim_Config::PICTURE_NAME)
@oxegen_picture_amount = $game_system.oxegen_pictures
super(0, 0, ((@image.width + 5) * $game_system.oxegen_pictures) + 32, @image.height + 32)
else
super(0, 0, $game_system.oxegen_max + 34, 7 + 32)
end
self.contents = Bitmap.new(width - 32, height - 32)
self.active = false
self.opacity = 0
self.visible = true
refresh
end
def refresh
self.contents.clear
if Swim_Config::PICTURE_MODE == true
if $game_player.swimming == true
if @oxegen_picture_amount > -1
if $game_system.oxegen_picture_count > 0
$game_system.oxegen_picture_count -= 1
else
$game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
@oxegen_picture_amount -= 1
end
for i in 0 ... @oxegen_picture_amount
rect = Rect.new(0, 0, @image.width, @image.height)
self.contents.blt(0 + (@image.width + 5) * i, 0, @image, rect, 255)
end
else
$game_temp.gameover = true
end
else
@oxegen_picture_amount = $game_system.oxegen_pictures
end
else
if $game_player.swimming == true
rect = Rect.new(0, 0, $game_system.oxegen_max + 2, 7)
bitmap = Bitmap.new(rect.width, rect.height)
bitmap.fill_rect(rect.x, rect.y, rect.width, rect.height, Color.new(0, 0, 0, 255))
self.contents.blt(0, 0, bitmap, rect)
if $game_system.oxegen_count > 0 && $game_system.oxegen > 0
$game_system.oxegen_count -= 1
else
$game_system.oxegen_count = Swim_Config::OXEGEN_COUNT
$game_system.oxegen -= 1
end
if $game_system.oxegen > 0
rect = Rect.new(0, 0, $game_system.oxegen, 5)
bitmap = Bitmap.new(rect.width, rect.height)
bitmap.fill_rect(rect.x, rect.y, rect.width, rect.height, Color.new(0, 0, 255, 255))
self.contents.blt(1, 1, bitmap, rect)
else
$game_temp.gameover = true
end
end
end
end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Scene_Map
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Scene_Map
alias main_swim main
def main
@oxegen_window = Window_Oxegen.new if Swim_Config::OXEGEN_TIMER == true
main_swim
@oxegen_window.dispose if Swim_Config::OXEGEN_TIMER == true
end
alias update_swim update
def update
if Swim_Config::OXEGEN_TIMER == true
@oxegen_window.refresh
if $game_player.swimming == true
@oxegen_window.visible = true
else
@oxegen_window.visible = false
end
end
update_swim
end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * class Game_Player
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Game_Player < Map_Actor
attr_accessor :character_name
EXTENSION = "_swim"
TERRAIN = 2
def change_water_passable(passage=0)
@water = []
(0...$game_map.width).each {|x|
(0...$game_map.height).each {|y|
[2, 1, 0].each {|i|
id = $game_map.data[x, y, i]
@water << id if $game_map.terrain_tags[id] == Swim_Config::WATER_TERRAIN
}}}
# This code will get all the possible tile id with
# water terrain tags
@water.each {|i| $game_map.passages[i] = passage }
$game_map.virtual_passability = $BlizzABS.util.setup_passability($game_map.map)
# then this code will change all the water passages
end
alias update_swim update
def update
if $game_map.terrain_tag(@x, @y) != Swim_Config::WATER_TERRAIN
player = $game_party.actors[0]
if @swimming == true
$game_system.oxegen = $game_system.oxegen_max if
Swim_Config::OXEGEN_TIMER == true && Swim_Config::PICTURE_MODE == false
change_water_passable(15)
orig_name = player.character_name.split(Swim_Config::SWIM_EXTENSION)[0]
@character_name = @character_name_org = orig_name
player.set_graphic(orig_name, player.character_hue, player.battler_name, player.battler_hue)
@step_anime = false
@swimming = false
end
if Input.trigger?(Input::C)
case @direction
when 2
if $game_map.terrain_tag(@x, @y + 1) == Swim_Config::WATER_TERRAIN
start_swimming(player)
move_down
end
when 4
if $game_map.terrain_tag(@x - 1, @y) == Swim_Config::WATER_TERRAIN
start_swimming(player)
move_left
end
when 6
if $game_map.terrain_tag(@x + 1, @y) == Swim_Config::WATER_TERRAIN
start_swimming(player)
move_right
end
when 8
if $game_map.terrain_tag(@x, @y - 1) == Swim_Config::WATER_TERRAIN
start_swimming(player)
move_up
end
end
end
end
update_swim
end
def start_swimming(player)
$game_system.oxegen_picture_count = Swim_Config::PICTURE_FRAMES
change_water_passable(0)
swim_graphic = player.character_name + Swim_Config::SWIM_EXTENSION
@character_name = @character_name_org = swim_graphic
player.set_graphic(swim_graphic, player.character_hue, player.battler_name, player.battler_hue)
@step_anime = true
@swimming = true
end
end