├── .gitignore ├── RPGXP.chm ├── Rakefile ├── bin ├── play.rb ├── script_loader.rb └── scripts │ ├── 00_Game_Temp.rb │ ├── 01_Game_System.rb │ ├── 02_Game_Switches.rb │ ├── 03_Game_Variables.rb │ ├── 04_Game_SelfSwitches.rb │ ├── 05_Game_Screen.rb │ ├── 06_Game_Picture.rb │ ├── 07_Game_Battler 1.rb │ ├── 08_Game_Battler 2.rb │ ├── 09_Game_Battler 3.rb │ ├── 10_Game_BattlerAction.rb │ ├── 11_Game_Actor.rb │ ├── 12_Game_Enemy.rb │ ├── 13_Game_Actors.rb │ ├── 14_Game_Party.rb │ ├── 15_Game_Troop.rb │ ├── 16_Game_Map.rb │ ├── 17_Game_CommonEvent.rb │ ├── 18_Game_Character 1.rb │ ├── 19_Game_Character 2.rb │ ├── 20_Game_Character 3.rb │ ├── 21_Game_Event.rb │ ├── 22_Game_Player.rb │ ├── 23_Sprite_Character.rb │ ├── 24_Sprite_Battler.rb │ ├── 25_Sprite_Picture.rb │ ├── 26_Sprite_Timer.rb │ ├── 27_Spriteset_Map.rb │ ├── 28_Spriteset_Battle.rb │ ├── 29_Window_Base.rb │ ├── 30_Window_Selectable.rb │ ├── 31_Window_Command.rb │ ├── 32_Window_Help.rb │ ├── 34_Window_Gold.rb │ ├── 35_Window_PlayTime.rb │ ├── 36_Window_Steps.rb │ ├── 37_Window_MenuStatus.rb │ ├── 38_Window_Item.rb │ ├── 39_Window_Skill.rb │ ├── 40_Window_SkillStatus.rb │ ├── 41_Window_Target.rb │ ├── 42_Window_EquipLeft.rb │ ├── 43_Window_EquipRight.rb │ ├── 44_Window_EquipItem.rb │ ├── 45_Window_Status.rb │ ├── 46_Window_SaveFile.rb │ ├── 47_Window_ShopCommand.rb │ ├── 48_Window_ShopBuy.rb │ ├── 49_Window_ShopSell.rb │ ├── 50_Window_ShopNumber.rb │ ├── 51_Window_ShopStatus.rb │ ├── 52_Window_NameEdit.rb │ ├── 53_Window_InputNumber.rb │ ├── 53_Window_NameInput.rb │ ├── 54_Window_Message.rb │ ├── 55_Window_PartyCommand.rb │ ├── 56_Window_BattleStatus.rb │ ├── 57_Window_BattleResult.rb │ ├── 58_Window_DebugLeft.rb │ ├── 59_Window_DebugRight.rb │ ├── 60_Arrow_Base.rb │ ├── 61_Arrow_Enemy.rb │ ├── 62_Arrow_Actor.rb │ ├── 63_Interpreter 1.rb │ ├── 64_Interpreter 2.rb │ ├── 65_Interpreter 3.rb │ ├── 66_Interpreter 4.rb │ ├── 67_Interpreter 5.rb │ ├── 68_Interpreter 6.rb │ ├── 69_Interpreter 7.rb │ ├── 70_Scene_Title.rb │ ├── 71_Scene_Map.rb │ ├── 72_Scene_Menu.rb │ ├── 73_Scene_Item.rb │ ├── 74_Scene_Skill.rb │ ├── 75_Scene_Equip.rb │ ├── 76_Scene_Status.rb │ ├── 77_Scene_File.rb │ ├── 78_Scene_Save.rb │ ├── 79_Scene_Load.rb │ ├── 80_Scene_End.rb │ ├── 81_Scene_Battle 1.rb │ ├── 82_Scene_Battle 2.rb │ ├── 83_Scene_Battle 3.rb │ ├── 84_Scene_Battle 4.rb │ ├── 85_Scene_Shop.rb │ ├── 86_Scene_Name.rb │ ├── 87_Scene_GameOver.rb │ ├── 88_Scene_Debug.rb │ └── 89_Main.rb ├── lib ├── audio.rb ├── bitmap.rb ├── color.rb ├── font.rb ├── graphics.rb ├── input.rb ├── plane.rb ├── rect.rb ├── rgss_error.rb ├── rpg.rb ├── rpg │ ├── actor.rb │ ├── animation.rb │ ├── armor.rb │ ├── audio_file.rb │ ├── cache.rb │ ├── class.rb │ ├── common_event.rb │ ├── enemy.rb │ ├── event.rb │ ├── event_command.rb │ ├── item.rb │ ├── map.rb │ ├── map_info.rb │ ├── move_command.rb │ ├── move_route.rb │ ├── skill.rb │ ├── sprite.rb │ ├── state.rb │ ├── system.rb │ ├── tileset.rb │ ├── troop.rb │ ├── weapon.rb │ └── weather.rb ├── sprite.rb ├── table.rb ├── tilemap.rb ├── tone.rb ├── viewport.rb └── window.rb ├── readme.md └── test ├── color_test.rb ├── font_test.rb ├── input_test.rb ├── rect_test.rb ├── table_test.rb └── tone_test.rb /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | doc 3 | coverage 4 | .idea 5 | .yardoc 6 | -------------------------------------------------------------------------------- /RPGXP.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cstrahan/open-rpg-maker/04ec7c88d786a28fa2ccb68873cbffcd2cc4947e/RPGXP.chm -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'rake' 3 | require 'rake/rdoctask' 4 | require 'rake/testtask' 5 | require 'yard' 6 | require 'spec/rake/spectask' 7 | 8 | TEST_PATTERN = 'test/**/*_test.rb' 9 | 10 | desc 'Default: run tests.' 11 | task :default => ['test'] 12 | 13 | desc "Run tests." 14 | Rake::TestTask.new("test") do |t| 15 | t.libs << 'lib' 16 | t.pattern = TEST_PATTERN 17 | t.verbose = false 18 | t.warning = false 19 | t.ruby_opts << '-r turn' if Gem.available?('turn') 20 | end 21 | 22 | require 'rcov/rcovtask' 23 | desc "Run test coverage." 24 | Rcov::RcovTask.new("rcov") do |rcov| 25 | rcov.libs << 'test' 26 | rcov.pattern = TEST_PATTERN 27 | end 28 | 29 | YARD::Rake::YardocTask.new do |t| 30 | t.options += ['--title', "Open RPG Maker Documentation"] 31 | end 32 | 33 | Rake::RDocTask.new do |rdoc| 34 | rdoc.rdoc_dir = 'html' 35 | rdoc.title = "Open RPG Maker Documentation" 36 | end -------------------------------------------------------------------------------- /bin/play.rb: -------------------------------------------------------------------------------- 1 | dir = File.dirname(__FILE__) 2 | $LOAD_PATH << File.join(dir, "..", "lib") 3 | libs = Dir[File.join(dir, '..', "lib", "*.rb")].sort 4 | libs.each {|lib| require lib} 5 | load File.join(dir, 'script_loader.rb') -------------------------------------------------------------------------------- /bin/script_loader.rb: -------------------------------------------------------------------------------- 1 | script_dir = File.join(File.dirname(__FILE__), "scripts") 2 | scripts = Dir.glob(File.join(script_dir, "*.rb")) 3 | scripts.each do |script| 4 | load File.expand_path(script) 5 | end -------------------------------------------------------------------------------- /bin/scripts/02_Game_Switches.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Game_Switches 3 | #------------------------------------------------------------------------------ 4 | # This class handles switches. It's a wrapper for the built-in class "Array." 5 | # Refer to "$game_switches" for the instance of this class. 6 | #============================================================================== 7 | 8 | class Game_Switches 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | #-------------------------------------------------------------------------- 12 | def initialize 13 | @data = [] 14 | end 15 | #-------------------------------------------------------------------------- 16 | # * Get Switch 17 | # switch_id : switch ID 18 | #-------------------------------------------------------------------------- 19 | def [](switch_id) 20 | if switch_id <= 5000 and @data[switch_id] != nil 21 | return @data[switch_id] 22 | else 23 | return false 24 | end 25 | end 26 | #-------------------------------------------------------------------------- 27 | # * Set Switch 28 | # switch_id : switch ID 29 | # value : ON (true) / OFF (false) 30 | #-------------------------------------------------------------------------- 31 | def []=(switch_id, value) 32 | if switch_id <= 5000 33 | @data[switch_id] = value 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /bin/scripts/03_Game_Variables.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Game_Variables 3 | #------------------------------------------------------------------------------ 4 | # This class handles variables. It's a wrapper for the built-in class "Array." 5 | # Refer to "$game_variables" for the instance of this class. 6 | #============================================================================== 7 | 8 | class Game_Variables 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | #-------------------------------------------------------------------------- 12 | def initialize 13 | @data = [] 14 | end 15 | #-------------------------------------------------------------------------- 16 | # * Get Variable 17 | # variable_id : variable ID 18 | #-------------------------------------------------------------------------- 19 | def [](variable_id) 20 | if variable_id <= 5000 and @data[variable_id] != nil 21 | return @data[variable_id] 22 | else 23 | return 0 24 | end 25 | end 26 | #-------------------------------------------------------------------------- 27 | # * Set Variable 28 | # variable_id : variable ID 29 | # value : the variable's value 30 | #-------------------------------------------------------------------------- 31 | def []=(variable_id, value) 32 | if variable_id <= 5000 33 | @data[variable_id] = value 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /bin/scripts/04_Game_SelfSwitches.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Game_SelfSwitches 3 | #------------------------------------------------------------------------------ 4 | # This class handles self switches. It's a wrapper for the built-in class 5 | # "Hash." Refer to "$game_self_switches" for the instance of this class. 6 | #============================================================================== 7 | 8 | class Game_SelfSwitches 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | #-------------------------------------------------------------------------- 12 | def initialize 13 | @data = {} 14 | end 15 | #-------------------------------------------------------------------------- 16 | # * Get Self Switch 17 | # key : key 18 | #-------------------------------------------------------------------------- 19 | def [](key) 20 | return @data[key] == true ? true : false 21 | end 22 | #-------------------------------------------------------------------------- 23 | # * Set Self Switch 24 | # key : key 25 | # value : ON (true) / OFF (false) 26 | #-------------------------------------------------------------------------- 27 | def []=(key, value) 28 | @data[key] = value 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /bin/scripts/13_Game_Actors.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Game_Actors 3 | #------------------------------------------------------------------------------ 4 | # This class handles the actor array. Refer to "$game_actors" for each 5 | # instance of this class. 6 | #============================================================================== 7 | 8 | class Game_Actors 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | #-------------------------------------------------------------------------- 12 | def initialize 13 | @data = [] 14 | end 15 | #-------------------------------------------------------------------------- 16 | # * Get Actor 17 | # actor_id : actor ID 18 | #-------------------------------------------------------------------------- 19 | def [](actor_id) 20 | if actor_id > 999 or $data_actors[actor_id] == nil 21 | return nil 22 | end 23 | if @data[actor_id] == nil 24 | @data[actor_id] = Game_Actor.new(actor_id) 25 | end 26 | return @data[actor_id] 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /bin/scripts/15_Game_Troop.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Game_Troop 3 | #------------------------------------------------------------------------------ 4 | # This class deals with troops. Refer to "$game_troop" for the instance of 5 | # this class. 6 | #============================================================================== 7 | 8 | class Game_Troop 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | #-------------------------------------------------------------------------- 12 | def initialize 13 | # Create enemy array 14 | @enemies = [] 15 | end 16 | #-------------------------------------------------------------------------- 17 | # * Get Enemies 18 | #-------------------------------------------------------------------------- 19 | def enemies 20 | return @enemies 21 | end 22 | #-------------------------------------------------------------------------- 23 | # * Setup 24 | # troop_id : troop ID 25 | #-------------------------------------------------------------------------- 26 | def setup(troop_id) 27 | # Set array of enemies who are set as troops 28 | @enemies = [] 29 | troop = $data_troops[troop_id] 30 | for i in 0...troop.members.size 31 | enemy = $data_enemies[troop.members[i].enemy_id] 32 | if enemy != nil 33 | @enemies.push(Game_Enemy.new(troop_id, i)) 34 | end 35 | end 36 | end 37 | #-------------------------------------------------------------------------- 38 | # * Random Selection of a Target Enemy 39 | # hp0 : limited to enemies with 0 HP 40 | #-------------------------------------------------------------------------- 41 | def random_target_enemy(hp0 = false) 42 | # Initialize roulette 43 | roulette = [] 44 | # Loop 45 | for enemy in @enemies 46 | # If it fits the conditions 47 | if (not hp0 and enemy.exist?) or (hp0 and enemy.hp0?) 48 | # Add an enemy to the roulette 49 | roulette.push(enemy) 50 | end 51 | end 52 | # If roulette size is 0 53 | if roulette.size == 0 54 | return nil 55 | end 56 | # Spin the roulette, choose an enemy 57 | return roulette[rand(roulette.size)] 58 | end 59 | #-------------------------------------------------------------------------- 60 | # * Random Selection of a Target Enemy (HP 0) 61 | #-------------------------------------------------------------------------- 62 | def random_target_enemy_hp0 63 | return random_target_enemy(true) 64 | end 65 | #-------------------------------------------------------------------------- 66 | # * Smooth Selection of a Target Enemy 67 | # enemy_index : enemy index 68 | #-------------------------------------------------------------------------- 69 | def smooth_target_enemy(enemy_index) 70 | # Get an enemy 71 | enemy = @enemies[enemy_index] 72 | # If an enemy exists 73 | if enemy != nil and enemy.exist? 74 | return enemy 75 | end 76 | # Loop 77 | for enemy in @enemies 78 | # If an enemy exists 79 | if enemy.exist? 80 | return enemy 81 | end 82 | end 83 | end 84 | end 85 | -------------------------------------------------------------------------------- /bin/scripts/17_Game_CommonEvent.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Game_CommonEvent 3 | #------------------------------------------------------------------------------ 4 | # This class handles common events. It includes execution of parallel process 5 | # event. This class is used within the Game_Map class ($game_map). 6 | #============================================================================== 7 | 8 | class Game_CommonEvent 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | # common_event_id : common event ID 12 | #-------------------------------------------------------------------------- 13 | def initialize(common_event_id) 14 | @common_event_id = common_event_id 15 | @interpreter = nil 16 | refresh 17 | end 18 | #-------------------------------------------------------------------------- 19 | # * Get Name 20 | #-------------------------------------------------------------------------- 21 | def name 22 | return $data_common_events[@common_event_id].name 23 | end 24 | #-------------------------------------------------------------------------- 25 | # * Get Trigger 26 | #-------------------------------------------------------------------------- 27 | def trigger 28 | return $data_common_events[@common_event_id].trigger 29 | end 30 | #-------------------------------------------------------------------------- 31 | # * Get Condition Switch ID 32 | #-------------------------------------------------------------------------- 33 | def switch_id 34 | return $data_common_events[@common_event_id].switch_id 35 | end 36 | #-------------------------------------------------------------------------- 37 | # * Get List of Event Commands 38 | #-------------------------------------------------------------------------- 39 | def list 40 | return $data_common_events[@common_event_id].list 41 | end 42 | #-------------------------------------------------------------------------- 43 | # * Refresh 44 | #-------------------------------------------------------------------------- 45 | def refresh 46 | # Create an interpreter for parallel process if necessary 47 | if self.trigger == 2 and $game_switches[self.switch_id] == true 48 | if @interpreter == nil 49 | @interpreter = Interpreter.new 50 | end 51 | else 52 | @interpreter = nil 53 | end 54 | end 55 | #-------------------------------------------------------------------------- 56 | # * Frame Update 57 | #-------------------------------------------------------------------------- 58 | def update 59 | # If parallel process is valid 60 | if @interpreter != nil 61 | # If not running 62 | unless @interpreter.running? 63 | # Set up event 64 | @interpreter.setup(self.list, 0) 65 | end 66 | # Update interpreter 67 | @interpreter.update 68 | end 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /bin/scripts/19_Game_Character 2.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cstrahan/open-rpg-maker/04ec7c88d786a28fa2ccb68873cbffcd2cc4947e/bin/scripts/19_Game_Character 2.rb -------------------------------------------------------------------------------- /bin/scripts/20_Game_Character 3.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cstrahan/open-rpg-maker/04ec7c88d786a28fa2ccb68873cbffcd2cc4947e/bin/scripts/20_Game_Character 3.rb -------------------------------------------------------------------------------- /bin/scripts/23_Sprite_Character.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Sprite_Character 3 | #------------------------------------------------------------------------------ 4 | # This sprite is used to display the character.It observes the Game_Character 5 | # class and automatically changes sprite conditions. 6 | #============================================================================== 7 | 8 | class Sprite_Character < RPG::Sprite 9 | #-------------------------------------------------------------------------- 10 | # * Public Instance Variables 11 | #-------------------------------------------------------------------------- 12 | attr_accessor :character # character 13 | #-------------------------------------------------------------------------- 14 | # * Object Initialization 15 | # viewport : viewport 16 | # character : character (Game_Character) 17 | #-------------------------------------------------------------------------- 18 | def initialize(viewport, character = nil) 19 | super(viewport) 20 | @character = character 21 | update 22 | end 23 | #-------------------------------------------------------------------------- 24 | # * Frame Update 25 | #-------------------------------------------------------------------------- 26 | def update 27 | super 28 | # If tile ID, file name, or hue are different from current ones 29 | if @tile_id != @character.tile_id or 30 | @character_name != @character.character_name or 31 | @character_hue != @character.character_hue 32 | # Remember tile ID, file name, and hue 33 | @tile_id = @character.tile_id 34 | @character_name = @character.character_name 35 | @character_hue = @character.character_hue 36 | # If tile ID value is valid 37 | if @tile_id >= 384 38 | self.bitmap = RPG::Cache.tile($game_map.tileset_name, 39 | @tile_id, @character.character_hue) 40 | self.src_rect.set(0, 0, 32, 32) 41 | self.ox = 16 42 | self.oy = 32 43 | # If tile ID value is invalid 44 | else 45 | self.bitmap = RPG::Cache.character(@character.character_name, 46 | @character.character_hue) 47 | @cw = bitmap.width / 4 48 | @ch = bitmap.height / 4 49 | self.ox = @cw / 2 50 | self.oy = @ch 51 | end 52 | end 53 | # Set visible situation 54 | self.visible = (not @character.transparent) 55 | # If graphic is character 56 | if @tile_id == 0 57 | # Set rectangular transfer 58 | sx = @character.pattern * @cw 59 | sy = (@character.direction - 2) / 2 * @ch 60 | self.src_rect.set(sx, sy, @cw, @ch) 61 | end 62 | # Set sprite coordinates 63 | self.x = @character.screen_x 64 | self.y = @character.screen_y 65 | self.z = @character.screen_z(@ch) 66 | # Set opacity level, blend method, and bush depth 67 | self.opacity = @character.opacity 68 | self.blend_type = @character.blend_type 69 | self.bush_depth = @character.bush_depth 70 | # Animation 71 | if @character.animation_id != 0 72 | animation = $data_animations[@character.animation_id] 73 | animation(animation, true) 74 | @character.animation_id = 0 75 | end 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /bin/scripts/24_Sprite_Battler.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Sprite_Character 3 | #------------------------------------------------------------------------------ 4 | # This sprite is used to display the character.It observes the Game_Character 5 | # class and automatically changes sprite conditions. 6 | #============================================================================== 7 | 8 | class Sprite_Character < RPG::Sprite 9 | #-------------------------------------------------------------------------- 10 | # * Public Instance Variables 11 | #-------------------------------------------------------------------------- 12 | attr_accessor :character # character 13 | #-------------------------------------------------------------------------- 14 | # * Object Initialization 15 | # viewport : viewport 16 | # character : character (Game_Character) 17 | #-------------------------------------------------------------------------- 18 | def initialize(viewport, character = nil) 19 | super(viewport) 20 | @character = character 21 | update 22 | end 23 | #-------------------------------------------------------------------------- 24 | # * Frame Update 25 | #-------------------------------------------------------------------------- 26 | def update 27 | super 28 | # If tile ID, file name, or hue are different from current ones 29 | if @tile_id != @character.tile_id or 30 | @character_name != @character.character_name or 31 | @character_hue != @character.character_hue 32 | # Remember tile ID, file name, and hue 33 | @tile_id = @character.tile_id 34 | @character_name = @character.character_name 35 | @character_hue = @character.character_hue 36 | # If tile ID value is valid 37 | if @tile_id >= 384 38 | self.bitmap = RPG::Cache.tile($game_map.tileset_name, 39 | @tile_id, @character.character_hue) 40 | self.src_rect.set(0, 0, 32, 32) 41 | self.ox = 16 42 | self.oy = 32 43 | # If tile ID value is invalid 44 | else 45 | self.bitmap = RPG::Cache.character(@character.character_name, 46 | @character.character_hue) 47 | @cw = bitmap.width / 4 48 | @ch = bitmap.height / 4 49 | self.ox = @cw / 2 50 | self.oy = @ch 51 | end 52 | end 53 | # Set visible situation 54 | self.visible = (not @character.transparent) 55 | # If graphic is character 56 | if @tile_id == 0 57 | # Set rectangular transfer 58 | sx = @character.pattern * @cw 59 | sy = (@character.direction - 2) / 2 * @ch 60 | self.src_rect.set(sx, sy, @cw, @ch) 61 | end 62 | # Set sprite coordinates 63 | self.x = @character.screen_x 64 | self.y = @character.screen_y 65 | self.z = @character.screen_z(@ch) 66 | # Set opacity level, blend method, and bush depth 67 | self.opacity = @character.opacity 68 | self.blend_type = @character.blend_type 69 | self.bush_depth = @character.bush_depth 70 | # Animation 71 | if @character.animation_id != 0 72 | animation = $data_animations[@character.animation_id] 73 | animation(animation, true) 74 | @character.animation_id = 0 75 | end 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /bin/scripts/25_Sprite_Picture.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Sprite_Picture 3 | #------------------------------------------------------------------------------ 4 | # This sprite is used to display the picture.It observes the Game_Character 5 | # class and automatically changes sprite conditions. 6 | #============================================================================== 7 | 8 | class Sprite_Picture < Sprite 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | # viewport : viewport 12 | # picture : picture (Game_Picture) 13 | #-------------------------------------------------------------------------- 14 | def initialize(viewport, picture) 15 | super(viewport) 16 | @picture = picture 17 | update 18 | end 19 | #-------------------------------------------------------------------------- 20 | # * Dispose 21 | #-------------------------------------------------------------------------- 22 | def dispose 23 | if self.bitmap != nil 24 | self.bitmap.dispose 25 | end 26 | super 27 | end 28 | #-------------------------------------------------------------------------- 29 | # * Frame Update 30 | #-------------------------------------------------------------------------- 31 | def update 32 | super 33 | # If picture file name is different from current one 34 | if @picture_name != @picture.name 35 | # Remember file name to instance variables 36 | @picture_name = @picture.name 37 | # If file name is not empty 38 | if @picture_name != "" 39 | # Get picture graphic 40 | self.bitmap = RPG::Cache.picture(@picture_name) 41 | end 42 | end 43 | # If file name is empty 44 | if @picture_name == "" 45 | # Set sprite to invisible 46 | self.visible = false 47 | return 48 | end 49 | # Set sprite to visible 50 | self.visible = true 51 | # Set transfer starting point 52 | if @picture.origin == 0 53 | self.ox = 0 54 | self.oy = 0 55 | else 56 | self.ox = self.bitmap.width / 2 57 | self.oy = self.bitmap.height / 2 58 | end 59 | # Set sprite coordinates 60 | self.x = @picture.x 61 | self.y = @picture.y 62 | self.z = @picture.number 63 | # Set zoom rate, opacity level, and blend method 64 | self.zoom_x = @picture.zoom_x / 100.0 65 | self.zoom_y = @picture.zoom_y / 100.0 66 | self.opacity = @picture.opacity 67 | self.blend_type = @picture.blend_type 68 | # Set rotation angle and color tone 69 | self.angle = @picture.angle 70 | self.tone = @picture.tone 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /bin/scripts/26_Sprite_Timer.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Sprite_Timer 3 | #------------------------------------------------------------------------------ 4 | # This sprite is used to display the timer.It observes the $game_system 5 | # class and automatically changes sprite conditions. 6 | #============================================================================== 7 | 8 | class Sprite_Timer < Sprite 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | #-------------------------------------------------------------------------- 12 | def initialize 13 | super 14 | self.bitmap = Bitmap.new(88, 48) 15 | self.bitmap.font.name = "Arial" 16 | self.bitmap.font.size = 32 17 | self.x = 640 - self.bitmap.width 18 | self.y = 0 19 | self.z = 500 20 | update 21 | end 22 | #-------------------------------------------------------------------------- 23 | # * Dispose 24 | #-------------------------------------------------------------------------- 25 | def dispose 26 | if self.bitmap != nil 27 | self.bitmap.dispose 28 | end 29 | super 30 | end 31 | #-------------------------------------------------------------------------- 32 | # * Frame Update 33 | #-------------------------------------------------------------------------- 34 | def update 35 | super 36 | # Set timer to visible if working 37 | self.visible = $game_system.timer_working 38 | # If timer needs to be redrawn 39 | if $game_system.timer / Graphics.frame_rate != @total_sec 40 | # Clear window contents 41 | self.bitmap.clear 42 | # Calculate total number of seconds 43 | @total_sec = $game_system.timer / Graphics.frame_rate 44 | # Make a string for displaying the timer 45 | min = @total_sec / 60 46 | sec = @total_sec % 60 47 | text = sprintf("%02d:%02d", min, sec) 48 | # Draw timer 49 | self.bitmap.font.color.set(255, 255, 255) 50 | self.bitmap.draw_text(self.bitmap.rect, text, 1) 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /bin/scripts/28_Spriteset_Battle.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Spriteset_Battle 3 | #------------------------------------------------------------------------------ 4 | # This class brings together battle screen sprites. It's used within 5 | # the Scene_Battle class. 6 | #============================================================================== 7 | 8 | class Spriteset_Battle 9 | #-------------------------------------------------------------------------- 10 | # * Public Instance Variables 11 | #-------------------------------------------------------------------------- 12 | attr_reader :viewport1 # enemy viewport 13 | attr_reader :viewport2 # actor viewport 14 | #-------------------------------------------------------------------------- 15 | # * Object Initialization 16 | #-------------------------------------------------------------------------- 17 | def initialize 18 | # Make viewports 19 | @viewport1 = Viewport.new(0, 0, 640, 320) 20 | @viewport2 = Viewport.new(0, 0, 640, 480) 21 | @viewport3 = Viewport.new(0, 0, 640, 480) 22 | @viewport4 = Viewport.new(0, 0, 640, 480) 23 | @viewport2.z = 101 24 | @viewport3.z = 200 25 | @viewport4.z = 5000 26 | # Make battleback sprite 27 | @battleback_sprite = Sprite.new(@viewport1) 28 | # Make enemy sprites 29 | @enemy_sprites = [] 30 | for enemy in $game_troop.enemies.reverse 31 | @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy)) 32 | end 33 | # Make actor sprites 34 | @actor_sprites = [] 35 | @actor_sprites.push(Sprite_Battler.new(@viewport2)) 36 | @actor_sprites.push(Sprite_Battler.new(@viewport2)) 37 | @actor_sprites.push(Sprite_Battler.new(@viewport2)) 38 | @actor_sprites.push(Sprite_Battler.new(@viewport2)) 39 | # Make weather 40 | @weather = RPG::Weather.new(@viewport1) 41 | # Make picture sprites 42 | @picture_sprites = [] 43 | for i in 51..100 44 | @picture_sprites.push(Sprite_Picture.new(@viewport3, 45 | $game_screen.pictures[i])) 46 | end 47 | # Make timer sprite 48 | @timer_sprite = Sprite_Timer.new 49 | # Frame update 50 | update 51 | end 52 | #-------------------------------------------------------------------------- 53 | # * Dispose 54 | #-------------------------------------------------------------------------- 55 | def dispose 56 | # If battleback bit map exists, dispose of it 57 | if @battleback_sprite.bitmap != nil 58 | @battleback_sprite.bitmap.dispose 59 | end 60 | # Dispose of battleback sprite 61 | @battleback_sprite.dispose 62 | # Dispose of enemy sprites and actor sprites 63 | for sprite in @enemy_sprites + @actor_sprites 64 | sprite.dispose 65 | end 66 | # Dispose of weather 67 | @weather.dispose 68 | # Dispose of picture sprites 69 | for sprite in @picture_sprites 70 | sprite.dispose 71 | end 72 | # Dispose of timer sprite 73 | @timer_sprite.dispose 74 | # Dispose of viewports 75 | @viewport1.dispose 76 | @viewport2.dispose 77 | @viewport3.dispose 78 | @viewport4.dispose 79 | end 80 | #-------------------------------------------------------------------------- 81 | # * Determine if Effects are Displayed 82 | #-------------------------------------------------------------------------- 83 | def effect? 84 | # Return true if even 1 effect is being displayed 85 | for sprite in @enemy_sprites + @actor_sprites 86 | return true if sprite.effect? 87 | end 88 | return false 89 | end 90 | #-------------------------------------------------------------------------- 91 | # * Frame Update 92 | #-------------------------------------------------------------------------- 93 | def update 94 | # Update actor sprite contents (corresponds with actor switching) 95 | @actor_sprites[0].battler = $game_party.actors[0] 96 | @actor_sprites[1].battler = $game_party.actors[1] 97 | @actor_sprites[2].battler = $game_party.actors[2] 98 | @actor_sprites[3].battler = $game_party.actors[3] 99 | # If battleback file name is different from current one 100 | if @battleback_name != $game_temp.battleback_name 101 | @battleback_name = $game_temp.battleback_name 102 | if @battleback_sprite.bitmap != nil 103 | @battleback_sprite.bitmap.dispose 104 | end 105 | @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name) 106 | @battleback_sprite.src_rect.set(0, 0, 640, 320) 107 | end 108 | # Update battler sprites 109 | for sprite in @enemy_sprites + @actor_sprites 110 | sprite.update 111 | end 112 | # Update weather graphic 113 | @weather.type = $game_screen.weather_type 114 | @weather.max = $game_screen.weather_max 115 | @weather.update 116 | # Update picture sprites 117 | for sprite in @picture_sprites 118 | sprite.update 119 | end 120 | # Update timer sprite 121 | @timer_sprite.update 122 | # Set screen color tone and shake position 123 | @viewport1.tone = $game_screen.tone 124 | @viewport1.ox = $game_screen.shake 125 | # Set screen flash color 126 | @viewport4.color = $game_screen.flash_color 127 | # Update viewports 128 | @viewport1.update 129 | @viewport2.update 130 | @viewport4.update 131 | end 132 | end 133 | -------------------------------------------------------------------------------- /bin/scripts/31_Window_Command.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_Command 3 | #------------------------------------------------------------------------------ 4 | # This window deals with general command choices. 5 | #============================================================================== 6 | 7 | class Window_Command < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | # width : window width 11 | # commands : command text string array 12 | #-------------------------------------------------------------------------- 13 | def initialize(width, commands) 14 | # Compute window height from command quantity 15 | super(0, 0, width, commands.size * 32 + 32) 16 | @item_max = commands.size 17 | @commands = commands 18 | self.contents = Bitmap.new(width - 32, @item_max * 32) 19 | refresh 20 | self.index = 0 21 | end 22 | #-------------------------------------------------------------------------- 23 | # * Refresh 24 | #-------------------------------------------------------------------------- 25 | def refresh 26 | self.contents.clear 27 | for i in 0...@item_max 28 | draw_item(i, normal_color) 29 | end 30 | end 31 | #-------------------------------------------------------------------------- 32 | # * Draw Item 33 | # index : item number 34 | # color : text color 35 | #-------------------------------------------------------------------------- 36 | def draw_item(index, color) 37 | self.contents.font.color = color 38 | rect = Rect.new(4, 32 * index, self.contents.width - 8, 32) 39 | self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) 40 | self.contents.draw_text(rect, @commands[index]) 41 | end 42 | #-------------------------------------------------------------------------- 43 | # * Disable Item 44 | # index : item number 45 | #-------------------------------------------------------------------------- 46 | def disable_item(index) 47 | draw_item(index, disabled_color) 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /bin/scripts/32_Window_Help.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_Help 3 | #------------------------------------------------------------------------------ 4 | # This window shows skill and item explanations along with actor status. 5 | #============================================================================== 6 | 7 | class Window_Help < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 0, 640, 64) 13 | self.contents = Bitmap.new(width - 32, height - 32) 14 | end 15 | #-------------------------------------------------------------------------- 16 | # * Set Text 17 | # text : text string displayed in window 18 | # align : alignment (0..flush left, 1..center, 2..flush right) 19 | #-------------------------------------------------------------------------- 20 | def set_text(text, align = 0) 21 | # If at least one part of text and alignment differ from last time 22 | if text != @text or align != @align 23 | # Redraw text 24 | self.contents.clear 25 | self.contents.font.color = normal_color 26 | self.contents.draw_text(4, 0, self.width - 40, 32, text, align) 27 | @text = text 28 | @align = align 29 | @actor = nil 30 | end 31 | self.visible = true 32 | end 33 | #-------------------------------------------------------------------------- 34 | # * Set Actor 35 | # actor : status displaying actor 36 | #-------------------------------------------------------------------------- 37 | def set_actor(actor) 38 | if actor != @actor 39 | self.contents.clear 40 | draw_actor_name(actor, 4, 0) 41 | draw_actor_state(actor, 140, 0) 42 | draw_actor_hp(actor, 284, 0) 43 | draw_actor_sp(actor, 460, 0) 44 | @actor = actor 45 | @text = nil 46 | self.visible = true 47 | end 48 | end 49 | #-------------------------------------------------------------------------- 50 | # * Set Enemy 51 | # enemy : name and status displaying enemy 52 | #-------------------------------------------------------------------------- 53 | def set_enemy(enemy) 54 | text = enemy.name 55 | state_text = make_battler_state_text(enemy, 112, false) 56 | if state_text != "" 57 | text += " " + state_text 58 | end 59 | set_text(text, 1) 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /bin/scripts/34_Window_Gold.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_Gold 3 | #------------------------------------------------------------------------------ 4 | # This window displays amount of gold. 5 | #============================================================================== 6 | 7 | class Window_Gold < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 0, 160, 64) 13 | self.contents = Bitmap.new(width - 32, height - 32) 14 | refresh 15 | end 16 | #-------------------------------------------------------------------------- 17 | # * Refresh 18 | #-------------------------------------------------------------------------- 19 | def refresh 20 | self.contents.clear 21 | cx = contents.text_size($data_system.words.gold).width 22 | self.contents.font.color = normal_color 23 | self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2) 24 | self.contents.font.color = system_color 25 | self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /bin/scripts/35_Window_PlayTime.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_PlayTime 3 | #------------------------------------------------------------------------------ 4 | # This window displays play time on the menu screen. 5 | #============================================================================== 6 | 7 | class Window_PlayTime < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 0, 160, 96) 13 | self.contents = Bitmap.new(width - 32, height - 32) 14 | refresh 15 | end 16 | #-------------------------------------------------------------------------- 17 | # * Refresh 18 | #-------------------------------------------------------------------------- 19 | def refresh 20 | self.contents.clear 21 | self.contents.font.color = system_color 22 | self.contents.draw_text(4, 0, 120, 32, "Play Time") 23 | @total_sec = Graphics.frame_count / Graphics.frame_rate 24 | hour = @total_sec / 60 / 60 25 | min = @total_sec / 60 % 60 26 | sec = @total_sec % 60 27 | text = sprintf("%02d:%02d:%02d", hour, min, sec) 28 | self.contents.font.color = normal_color 29 | self.contents.draw_text(4, 32, 120, 32, text, 2) 30 | end 31 | #-------------------------------------------------------------------------- 32 | # * Frame Update 33 | #-------------------------------------------------------------------------- 34 | def update 35 | super 36 | if Graphics.frame_count / Graphics.frame_rate != @total_sec 37 | refresh 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /bin/scripts/36_Window_Steps.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_Steps 3 | #------------------------------------------------------------------------------ 4 | # This window displays step count on the menu screen. 5 | #============================================================================== 6 | 7 | class Window_Steps < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 0, 160, 96) 13 | self.contents = Bitmap.new(width - 32, height - 32) 14 | refresh 15 | end 16 | #-------------------------------------------------------------------------- 17 | # * Refresh 18 | #-------------------------------------------------------------------------- 19 | def refresh 20 | self.contents.clear 21 | self.contents.font.color = system_color 22 | self.contents.draw_text(4, 0, 120, 32, "Step Count") 23 | self.contents.font.color = normal_color 24 | self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2) 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /bin/scripts/37_Window_MenuStatus.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_MenuStatus 3 | #------------------------------------------------------------------------------ 4 | # This window displays party member status on the menu screen. 5 | #============================================================================== 6 | 7 | class Window_MenuStatus < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 0, 480, 480) 13 | self.contents = Bitmap.new(width - 32, height - 32) 14 | refresh 15 | self.active = false 16 | self.index = -1 17 | end 18 | #-------------------------------------------------------------------------- 19 | # * Refresh 20 | #-------------------------------------------------------------------------- 21 | def refresh 22 | self.contents.clear 23 | @item_max = $game_party.actors.size 24 | for i in 0...$game_party.actors.size 25 | x = 64 26 | y = i * 116 27 | actor = $game_party.actors[i] 28 | draw_actor_graphic(actor, x - 40, y + 80) 29 | draw_actor_name(actor, x, y) 30 | draw_actor_class(actor, x + 144, y) 31 | draw_actor_level(actor, x, y + 32) 32 | draw_actor_state(actor, x + 90, y + 32) 33 | draw_actor_exp(actor, x, y + 64) 34 | draw_actor_hp(actor, x + 236, y + 32) 35 | draw_actor_sp(actor, x + 236, y + 64) 36 | end 37 | end 38 | #-------------------------------------------------------------------------- 39 | # * Cursor Rectangle Update 40 | #-------------------------------------------------------------------------- 41 | def update_cursor_rect 42 | if @index < 0 43 | self.cursor_rect.empty 44 | else 45 | self.cursor_rect.set(0, @index * 116, self.width - 32, 96) 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /bin/scripts/38_Window_Item.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_Item 3 | #------------------------------------------------------------------------------ 4 | # This window displays items in possession on the item and battle screens. 5 | #============================================================================== 6 | 7 | class Window_Item < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 64, 640, 416) 13 | @column_max = 2 14 | refresh 15 | self.index = 0 16 | # If in battle, move window to center of screen 17 | # and make it semi-transparent 18 | if $game_temp.in_battle 19 | self.y = 64 20 | self.height = 256 21 | self.back_opacity = 160 22 | end 23 | end 24 | #-------------------------------------------------------------------------- 25 | # * Get Item 26 | #-------------------------------------------------------------------------- 27 | def item 28 | return @data[self.index] 29 | end 30 | #-------------------------------------------------------------------------- 31 | # * Refresh 32 | #-------------------------------------------------------------------------- 33 | def refresh 34 | if self.contents != nil 35 | self.contents.dispose 36 | self.contents = nil 37 | end 38 | @data = [] 39 | # Add item 40 | for i in 1...$data_items.size 41 | if $game_party.item_number(i) > 0 42 | @data.push($data_items[i]) 43 | end 44 | end 45 | # Also add weapons and items if outside of battle 46 | unless $game_temp.in_battle 47 | for i in 1...$data_weapons.size 48 | if $game_party.weapon_number(i) > 0 49 | @data.push($data_weapons[i]) 50 | end 51 | end 52 | for i in 1...$data_armors.size 53 | if $game_party.armor_number(i) > 0 54 | @data.push($data_armors[i]) 55 | end 56 | end 57 | end 58 | # If item count is not 0, make a bit map and draw all items 59 | @item_max = @data.size 60 | if @item_max > 0 61 | self.contents = Bitmap.new(width - 32, row_max * 32) 62 | for i in 0...@item_max 63 | draw_item(i) 64 | end 65 | end 66 | end 67 | #-------------------------------------------------------------------------- 68 | # * Draw Item 69 | # index : item number 70 | #-------------------------------------------------------------------------- 71 | def draw_item(index) 72 | item = @data[index] 73 | case item 74 | when RPG::Item 75 | number = $game_party.item_number(item.id) 76 | when RPG::Weapon 77 | number = $game_party.weapon_number(item.id) 78 | when RPG::Armor 79 | number = $game_party.armor_number(item.id) 80 | end 81 | if item.is_a?(RPG::Item) and 82 | $game_party.item_can_use?(item.id) 83 | self.contents.font.color = normal_color 84 | else 85 | self.contents.font.color = disabled_color 86 | end 87 | x = 4 + index % 2 * (288 + 32) 88 | y = index / 2 * 32 89 | rect = Rect.new(x, y, self.width / @column_max - 32, 32) 90 | self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) 91 | bitmap = RPG::Cache.icon(item.icon_name) 92 | opacity = self.contents.font.color == normal_color ? 255 : 128 93 | self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) 94 | self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) 95 | self.contents.draw_text(x + 240, y, 16, 32, ":", 1) 96 | self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) 97 | end 98 | #-------------------------------------------------------------------------- 99 | # * Help Text Update 100 | #-------------------------------------------------------------------------- 101 | def update_help 102 | @help_window.set_text(self.item == nil ? "" : self.item.description) 103 | end 104 | end 105 | -------------------------------------------------------------------------------- /bin/scripts/39_Window_Skill.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_Skill 3 | #------------------------------------------------------------------------------ 4 | # This window displays usable skills on the skill and battle screens. 5 | #============================================================================== 6 | 7 | class Window_Skill < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | # actor : actor 11 | #-------------------------------------------------------------------------- 12 | def initialize(actor) 13 | super(0, 128, 640, 352) 14 | @actor = actor 15 | @column_max = 2 16 | refresh 17 | self.index = 0 18 | # If in battle, move window to center of screen 19 | # and make it semi-transparent 20 | if $game_temp.in_battle 21 | self.y = 64 22 | self.height = 256 23 | self.back_opacity = 160 24 | end 25 | end 26 | #-------------------------------------------------------------------------- 27 | # * Acquiring Skill 28 | #-------------------------------------------------------------------------- 29 | def skill 30 | return @data[self.index] 31 | end 32 | #-------------------------------------------------------------------------- 33 | # * Refresh 34 | #-------------------------------------------------------------------------- 35 | def refresh 36 | if self.contents != nil 37 | self.contents.dispose 38 | self.contents = nil 39 | end 40 | @data = [] 41 | for i in 0...@actor.skills.size 42 | skill = $data_skills[@actor.skills[i]] 43 | if skill != nil 44 | @data.push(skill) 45 | end 46 | end 47 | # If item count is not 0, make a bit map and draw all items 48 | @item_max = @data.size 49 | if @item_max > 0 50 | self.contents = Bitmap.new(width - 32, row_max * 32) 51 | for i in 0...@item_max 52 | draw_item(i) 53 | end 54 | end 55 | end 56 | #-------------------------------------------------------------------------- 57 | # * Draw Item 58 | # index : item number 59 | #-------------------------------------------------------------------------- 60 | def draw_item(index) 61 | skill = @data[index] 62 | if @actor.skill_can_use?(skill.id) 63 | self.contents.font.color = normal_color 64 | else 65 | self.contents.font.color = disabled_color 66 | end 67 | x = 4 + index % 2 * (288 + 32) 68 | y = index / 2 * 32 69 | rect = Rect.new(x, y, self.width / @column_max - 32, 32) 70 | self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) 71 | bitmap = RPG::Cache.icon(skill.icon_name) 72 | opacity = self.contents.font.color == normal_color ? 255 : 128 73 | self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) 74 | self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0) 75 | self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2) 76 | end 77 | #-------------------------------------------------------------------------- 78 | # * Help Text Update 79 | #-------------------------------------------------------------------------- 80 | def update_help 81 | @help_window.set_text(self.skill == nil ? "" : self.skill.description) 82 | end 83 | end 84 | -------------------------------------------------------------------------------- /bin/scripts/40_Window_SkillStatus.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_SkillStatus 3 | #------------------------------------------------------------------------------ 4 | # This window displays the skill user's status on the skill screen. 5 | #============================================================================== 6 | 7 | class Window_SkillStatus < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | # actor : actor 11 | #-------------------------------------------------------------------------- 12 | def initialize(actor) 13 | super(0, 64, 640, 64) 14 | self.contents = Bitmap.new(width - 32, height - 32) 15 | @actor = actor 16 | refresh 17 | end 18 | #-------------------------------------------------------------------------- 19 | # * Refresh 20 | #-------------------------------------------------------------------------- 21 | def refresh 22 | self.contents.clear 23 | draw_actor_name(@actor, 4, 0) 24 | draw_actor_state(@actor, 140, 0) 25 | draw_actor_hp(@actor, 284, 0) 26 | draw_actor_sp(@actor, 460, 0) 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /bin/scripts/41_Window_Target.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_Target 3 | #------------------------------------------------------------------------------ 4 | # This window selects a use target for the actor on item and skill screens. 5 | #============================================================================== 6 | 7 | class Window_Target < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 0, 336, 480) 13 | self.contents = Bitmap.new(width - 32, height - 32) 14 | self.z += 10 15 | @item_max = $game_party.actors.size 16 | refresh 17 | end 18 | #-------------------------------------------------------------------------- 19 | # * Refresh 20 | #-------------------------------------------------------------------------- 21 | def refresh 22 | self.contents.clear 23 | for i in 0...$game_party.actors.size 24 | x = 4 25 | y = i * 116 26 | actor = $game_party.actors[i] 27 | draw_actor_name(actor, x, y) 28 | draw_actor_class(actor, x + 144, y) 29 | draw_actor_level(actor, x + 8, y + 32) 30 | draw_actor_state(actor, x + 8, y + 64) 31 | draw_actor_hp(actor, x + 152, y + 32) 32 | draw_actor_sp(actor, x + 152, y + 64) 33 | end 34 | end 35 | #-------------------------------------------------------------------------- 36 | # * Cursor Rectangle Update 37 | #-------------------------------------------------------------------------- 38 | def update_cursor_rect 39 | # Cursor position -1 = all choices, -2 or lower = independent choice 40 | # (meaning the user's own choice) 41 | if @index <= -2 42 | self.cursor_rect.set(0, (@index + 10) * 116, self.width - 32, 96) 43 | elsif @index == -1 44 | self.cursor_rect.set(0, 0, self.width - 32, @item_max * 116 - 20) 45 | else 46 | self.cursor_rect.set(0, @index * 116, self.width - 32, 96) 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /bin/scripts/42_Window_EquipLeft.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_EquipLeft 3 | #------------------------------------------------------------------------------ 4 | # This window displays actor parameter changes on the equipment screen. 5 | #============================================================================== 6 | 7 | class Window_EquipLeft < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | # actor : actor 11 | #-------------------------------------------------------------------------- 12 | def initialize(actor) 13 | super(0, 64, 272, 192) 14 | self.contents = Bitmap.new(width - 32, height - 32) 15 | @actor = actor 16 | refresh 17 | end 18 | #-------------------------------------------------------------------------- 19 | # * Refresh 20 | #-------------------------------------------------------------------------- 21 | def refresh 22 | self.contents.clear 23 | draw_actor_name(@actor, 4, 0) 24 | draw_actor_level(@actor, 4, 32) 25 | draw_actor_parameter(@actor, 4, 64, 0) 26 | draw_actor_parameter(@actor, 4, 96, 1) 27 | draw_actor_parameter(@actor, 4, 128, 2) 28 | if @new_atk != nil 29 | self.contents.font.color = system_color 30 | self.contents.draw_text(160, 64, 40, 32, "->", 1) 31 | self.contents.font.color = normal_color 32 | self.contents.draw_text(200, 64, 36, 32, @new_atk.to_s, 2) 33 | end 34 | if @new_pdef != nil 35 | self.contents.font.color = system_color 36 | self.contents.draw_text(160, 96, 40, 32, "->", 1) 37 | self.contents.font.color = normal_color 38 | self.contents.draw_text(200, 96, 36, 32, @new_pdef.to_s, 2) 39 | end 40 | if @new_mdef != nil 41 | self.contents.font.color = system_color 42 | self.contents.draw_text(160, 128, 40, 32, "->", 1) 43 | self.contents.font.color = normal_color 44 | self.contents.draw_text(200, 128, 36, 32, @new_mdef.to_s, 2) 45 | end 46 | end 47 | #-------------------------------------------------------------------------- 48 | # * Set parameters after changing equipment 49 | # new_atk : attack power after changing equipment 50 | # new_pdef : physical defense after changing equipment 51 | # new_mdef : magic defense after changing equipment 52 | #-------------------------------------------------------------------------- 53 | def set_new_parameters(new_atk, new_pdef, new_mdef) 54 | if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef 55 | @new_atk = new_atk 56 | @new_pdef = new_pdef 57 | @new_mdef = new_mdef 58 | refresh 59 | end 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /bin/scripts/43_Window_EquipRight.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_EquipRight 3 | #------------------------------------------------------------------------------ 4 | # This window displays items the actor is currently equipped with on the 5 | # equipment screen. 6 | #============================================================================== 7 | 8 | class Window_EquipRight < Window_Selectable 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | # actor : actor 12 | #-------------------------------------------------------------------------- 13 | def initialize(actor) 14 | super(272, 64, 368, 192) 15 | self.contents = Bitmap.new(width - 32, height - 32) 16 | @actor = actor 17 | refresh 18 | self.index = 0 19 | end 20 | #-------------------------------------------------------------------------- 21 | # * Item Acquisition 22 | #-------------------------------------------------------------------------- 23 | def item 24 | return @data[self.index] 25 | end 26 | #-------------------------------------------------------------------------- 27 | # * Refresh 28 | #-------------------------------------------------------------------------- 29 | def refresh 30 | self.contents.clear 31 | @data = [] 32 | @data.push($data_weapons[@actor.weapon_id]) 33 | @data.push($data_armors[@actor.armor1_id]) 34 | @data.push($data_armors[@actor.armor2_id]) 35 | @data.push($data_armors[@actor.armor3_id]) 36 | @data.push($data_armors[@actor.armor4_id]) 37 | @item_max = @data.size 38 | self.contents.font.color = system_color 39 | self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon) 40 | self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1) 41 | self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2) 42 | self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3) 43 | self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4) 44 | draw_item_name(@data[0], 92, 32 * 0) 45 | draw_item_name(@data[1], 92, 32 * 1) 46 | draw_item_name(@data[2], 92, 32 * 2) 47 | draw_item_name(@data[3], 92, 32 * 3) 48 | draw_item_name(@data[4], 92, 32 * 4) 49 | end 50 | #-------------------------------------------------------------------------- 51 | # * Help Text Update 52 | #-------------------------------------------------------------------------- 53 | def update_help 54 | @help_window.set_text(self.item == nil ? "" : self.item.description) 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /bin/scripts/44_Window_EquipItem.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_EquipItem 3 | #------------------------------------------------------------------------------ 4 | # This window displays choices when opting to change equipment on the 5 | # equipment screen. 6 | #============================================================================== 7 | 8 | class Window_EquipItem < Window_Selectable 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | # actor : actor 12 | # equip_type : equip region (0-3) 13 | #-------------------------------------------------------------------------- 14 | def initialize(actor, equip_type) 15 | super(0, 256, 640, 224) 16 | @actor = actor 17 | @equip_type = equip_type 18 | @column_max = 2 19 | refresh 20 | self.active = false 21 | self.index = -1 22 | end 23 | #-------------------------------------------------------------------------- 24 | # * Item Acquisition 25 | #-------------------------------------------------------------------------- 26 | def item 27 | return @data[self.index] 28 | end 29 | #-------------------------------------------------------------------------- 30 | # * Refresh 31 | #-------------------------------------------------------------------------- 32 | def refresh 33 | if self.contents != nil 34 | self.contents.dispose 35 | self.contents = nil 36 | end 37 | @data = [] 38 | # Add equippable weapons 39 | if @equip_type == 0 40 | weapon_set = $data_classes[@actor.class_id].weapon_set 41 | for i in 1...$data_weapons.size 42 | if $game_party.weapon_number(i) > 0 and weapon_set.include?(i) 43 | @data.push($data_weapons[i]) 44 | end 45 | end 46 | end 47 | # Add equippable armor 48 | if @equip_type != 0 49 | armor_set = $data_classes[@actor.class_id].armor_set 50 | for i in 1...$data_armors.size 51 | if $game_party.armor_number(i) > 0 and armor_set.include?(i) 52 | if $data_armors[i].kind == @equip_type-1 53 | @data.push($data_armors[i]) 54 | end 55 | end 56 | end 57 | end 58 | # Add blank page 59 | @data.push(nil) 60 | # Make a bit map and draw all items 61 | @item_max = @data.size 62 | self.contents = Bitmap.new(width - 32, row_max * 32) 63 | for i in 0...@item_max-1 64 | draw_item(i) 65 | end 66 | end 67 | #-------------------------------------------------------------------------- 68 | # * Draw Item 69 | # index : item number 70 | #-------------------------------------------------------------------------- 71 | def draw_item(index) 72 | item = @data[index] 73 | x = 4 + index % 2 * (288 + 32) 74 | y = index / 2 * 32 75 | case item 76 | when RPG::Weapon 77 | number = $game_party.weapon_number(item.id) 78 | when RPG::Armor 79 | number = $game_party.armor_number(item.id) 80 | end 81 | bitmap = RPG::Cache.icon(item.icon_name) 82 | self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) 83 | self.contents.font.color = normal_color 84 | self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) 85 | self.contents.draw_text(x + 240, y, 16, 32, ":", 1) 86 | self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) 87 | end 88 | #-------------------------------------------------------------------------- 89 | # * Help Text Update 90 | #-------------------------------------------------------------------------- 91 | def update_help 92 | @help_window.set_text(self.item == nil ? "" : self.item.description) 93 | end 94 | end 95 | -------------------------------------------------------------------------------- /bin/scripts/45_Window_Status.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_Status 3 | #------------------------------------------------------------------------------ 4 | # This window displays full status specs on the status screen. 5 | #============================================================================== 6 | 7 | class Window_Status < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | # actor : actor 11 | #-------------------------------------------------------------------------- 12 | def initialize(actor) 13 | super(0, 0, 640, 480) 14 | self.contents = Bitmap.new(width - 32, height - 32) 15 | @actor = actor 16 | refresh 17 | end 18 | #-------------------------------------------------------------------------- 19 | # * Refresh 20 | #-------------------------------------------------------------------------- 21 | def refresh 22 | self.contents.clear 23 | draw_actor_graphic(@actor, 40, 112) 24 | draw_actor_name(@actor, 4, 0) 25 | draw_actor_class(@actor, 4 + 144, 0) 26 | draw_actor_level(@actor, 96, 32) 27 | draw_actor_state(@actor, 96, 64) 28 | draw_actor_hp(@actor, 96, 112, 172) 29 | draw_actor_sp(@actor, 96, 144, 172) 30 | draw_actor_parameter(@actor, 96, 192, 0) 31 | draw_actor_parameter(@actor, 96, 224, 1) 32 | draw_actor_parameter(@actor, 96, 256, 2) 33 | draw_actor_parameter(@actor, 96, 304, 3) 34 | draw_actor_parameter(@actor, 96, 336, 4) 35 | draw_actor_parameter(@actor, 96, 368, 5) 36 | draw_actor_parameter(@actor, 96, 400, 6) 37 | self.contents.font.color = system_color 38 | self.contents.draw_text(320, 48, 80, 32, "EXP") 39 | self.contents.draw_text(320, 80, 80, 32, "NEXT") 40 | self.contents.font.color = normal_color 41 | self.contents.draw_text(320 + 80, 48, 84, 32, @actor.exp_s, 2) 42 | self.contents.draw_text(320 + 80, 80, 84, 32, @actor.next_rest_exp_s, 2) 43 | self.contents.font.color = system_color 44 | self.contents.draw_text(320, 160, 96, 32, "equipment") 45 | draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208) 46 | draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256) 47 | draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304) 48 | draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352) 49 | draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400) 50 | end 51 | def dummy 52 | self.contents.font.color = system_color 53 | self.contents.draw_text(320, 112, 96, 32, $data_system.words.weapon) 54 | self.contents.draw_text(320, 176, 96, 32, $data_system.words.armor1) 55 | self.contents.draw_text(320, 240, 96, 32, $data_system.words.armor2) 56 | self.contents.draw_text(320, 304, 96, 32, $data_system.words.armor3) 57 | self.contents.draw_text(320, 368, 96, 32, $data_system.words.armor4) 58 | draw_item_name($data_weapons[@actor.weapon_id], 320 + 24, 144) 59 | draw_item_name($data_armors[@actor.armor1_id], 320 + 24, 208) 60 | draw_item_name($data_armors[@actor.armor2_id], 320 + 24, 272) 61 | draw_item_name($data_armors[@actor.armor3_id], 320 + 24, 336) 62 | draw_item_name($data_armors[@actor.armor4_id], 320 + 24, 400) 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /bin/scripts/46_Window_SaveFile.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_SaveFile 3 | #------------------------------------------------------------------------------ 4 | # This window displays save files on the save and load screens. 5 | #============================================================================== 6 | 7 | class Window_SaveFile < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Public Instance Variables 10 | #-------------------------------------------------------------------------- 11 | attr_reader :filename # file name 12 | attr_reader :selected # selected 13 | #-------------------------------------------------------------------------- 14 | # * Object Initialization 15 | # file_index : save file index (0-3) 16 | # filename : file name 17 | #-------------------------------------------------------------------------- 18 | def initialize(file_index, filename) 19 | super(0, 64 + file_index % 4 * 104, 640, 104) 20 | self.contents = Bitmap.new(width - 32, height - 32) 21 | @file_index = file_index 22 | @filename = "Save#{@file_index + 1}.rxdata" 23 | @time_stamp = Time.at(0) 24 | @file_exist = FileTest.exist?(@filename) 25 | if @file_exist 26 | file = File.open(@filename, "r") 27 | @time_stamp = file.mtime 28 | @characters = Marshal.load(file) 29 | @frame_count = Marshal.load(file) 30 | @game_system = Marshal.load(file) 31 | @game_switches = Marshal.load(file) 32 | @game_variables = Marshal.load(file) 33 | @total_sec = @frame_count / Graphics.frame_rate 34 | file.close 35 | end 36 | refresh 37 | @selected = false 38 | end 39 | #-------------------------------------------------------------------------- 40 | # * Refresh 41 | #-------------------------------------------------------------------------- 42 | def refresh 43 | self.contents.clear 44 | # Draw file number 45 | self.contents.font.color = normal_color 46 | name = "File#{@file_index + 1}" 47 | self.contents.draw_text(4, 0, 600, 32, name) 48 | @name_width = contents.text_size(name).width 49 | # If save file exists 50 | if @file_exist 51 | # Draw character 52 | for i in 0...@characters.size 53 | bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1]) 54 | cw = bitmap.rect.width / 4 55 | ch = bitmap.rect.height / 4 56 | src_rect = Rect.new(0, 0, cw, ch) 57 | x = 300 - @characters.size * 32 + i * 64 - cw / 2 58 | self.contents.blt(x, 68 - ch, bitmap, src_rect) 59 | end 60 | # Draw play time 61 | hour = @total_sec / 60 / 60 62 | min = @total_sec / 60 % 60 63 | sec = @total_sec % 60 64 | time_string = sprintf("%02d:%02d:%02d", hour, min, sec) 65 | self.contents.font.color = normal_color 66 | self.contents.draw_text(4, 8, 600, 32, time_string, 2) 67 | # Draw timestamp 68 | self.contents.font.color = normal_color 69 | time_string = @time_stamp.strftime("%Y/%m/%d %H:%M") 70 | self.contents.draw_text(4, 40, 600, 32, time_string, 2) 71 | end 72 | end 73 | #-------------------------------------------------------------------------- 74 | # * Set Selected 75 | # selected : new selected (true = selected, false = unselected) 76 | #-------------------------------------------------------------------------- 77 | def selected=(selected) 78 | @selected = selected 79 | update_cursor_rect 80 | end 81 | #-------------------------------------------------------------------------- 82 | # * Cursor Rectangle Update 83 | #-------------------------------------------------------------------------- 84 | def update_cursor_rect 85 | if @selected 86 | self.cursor_rect.set(0, 0, @name_width + 8, 32) 87 | else 88 | self.cursor_rect.empty 89 | end 90 | end 91 | end 92 | -------------------------------------------------------------------------------- /bin/scripts/47_Window_ShopCommand.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_ShopCommand 3 | #------------------------------------------------------------------------------ 4 | # This window is used to choose your business on the shop screen. 5 | #============================================================================== 6 | 7 | class Window_ShopCommand < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 64, 480, 64) 13 | self.contents = Bitmap.new(width - 32, height - 32) 14 | @item_max = 3 15 | @column_max = 3 16 | @commands = ["Buy", "Sell", "Exit"] 17 | refresh 18 | self.index = 0 19 | end 20 | #-------------------------------------------------------------------------- 21 | # * Refresh 22 | #-------------------------------------------------------------------------- 23 | def refresh 24 | self.contents.clear 25 | for i in 0...@item_max 26 | draw_item(i) 27 | end 28 | end 29 | #-------------------------------------------------------------------------- 30 | # * Draw Item 31 | # index : item number 32 | #-------------------------------------------------------------------------- 33 | def draw_item(index) 34 | x = 4 + index * 160 35 | self.contents.draw_text(x, 0, 128, 32, @commands[index]) 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /bin/scripts/48_Window_ShopBuy.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_ShopBuy 3 | #------------------------------------------------------------------------------ 4 | # This window displays buyable goods on the shop screen. 5 | #============================================================================== 6 | 7 | class Window_ShopBuy < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | # shop_goods : goods 11 | #-------------------------------------------------------------------------- 12 | def initialize(shop_goods) 13 | super(0, 128, 368, 352) 14 | @shop_goods = shop_goods 15 | refresh 16 | self.index = 0 17 | end 18 | #-------------------------------------------------------------------------- 19 | # * Item Acquisition 20 | #-------------------------------------------------------------------------- 21 | def item 22 | return @data[self.index] 23 | end 24 | #-------------------------------------------------------------------------- 25 | # * Refresh 26 | #-------------------------------------------------------------------------- 27 | def refresh 28 | if self.contents != nil 29 | self.contents.dispose 30 | self.contents = nil 31 | end 32 | @data = [] 33 | for goods_item in @shop_goods 34 | case goods_item[0] 35 | when 0 36 | item = $data_items[goods_item[1]] 37 | when 1 38 | item = $data_weapons[goods_item[1]] 39 | when 2 40 | item = $data_armors[goods_item[1]] 41 | end 42 | if item != nil 43 | @data.push(item) 44 | end 45 | end 46 | # If item count is not 0, make a bit map and draw all items 47 | @item_max = @data.size 48 | if @item_max > 0 49 | self.contents = Bitmap.new(width - 32, row_max * 32) 50 | for i in 0...@item_max 51 | draw_item(i) 52 | end 53 | end 54 | end 55 | #-------------------------------------------------------------------------- 56 | # * Draw Item 57 | # index : item number 58 | #-------------------------------------------------------------------------- 59 | def draw_item(index) 60 | item = @data[index] 61 | # Get items in possession 62 | case item 63 | when RPG::Item 64 | number = $game_party.item_number(item.id) 65 | when RPG::Weapon 66 | number = $game_party.weapon_number(item.id) 67 | when RPG::Armor 68 | number = $game_party.armor_number(item.id) 69 | end 70 | # If price is less than money in possession, and amount in possession is 71 | # not 99, then set to normal text color. Otherwise set to disabled color 72 | if item.price <= $game_party.gold and number < 99 73 | self.contents.font.color = normal_color 74 | else 75 | self.contents.font.color = disabled_color 76 | end 77 | x = 4 78 | y = index * 32 79 | rect = Rect.new(x, y, self.width - 32, 32) 80 | self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) 81 | bitmap = RPG::Cache.icon(item.icon_name) 82 | opacity = self.contents.font.color == normal_color ? 255 : 128 83 | self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) 84 | self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) 85 | self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2) 86 | end 87 | #-------------------------------------------------------------------------- 88 | # * Help Text Update 89 | #-------------------------------------------------------------------------- 90 | def update_help 91 | @help_window.set_text(self.item == nil ? "" : self.item.description) 92 | end 93 | end 94 | -------------------------------------------------------------------------------- /bin/scripts/49_Window_ShopSell.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_ShopSell 3 | #------------------------------------------------------------------------------ 4 | # This window displays items in possession for selling on the shop screen. 5 | #============================================================================== 6 | 7 | class Window_ShopSell < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 128, 640, 352) 13 | @column_max = 2 14 | refresh 15 | self.index = 0 16 | end 17 | #-------------------------------------------------------------------------- 18 | # * Getting Items 19 | #-------------------------------------------------------------------------- 20 | def item 21 | return @data[self.index] 22 | end 23 | #-------------------------------------------------------------------------- 24 | # * Refresh 25 | #-------------------------------------------------------------------------- 26 | def refresh 27 | if self.contents != nil 28 | self.contents.dispose 29 | self.contents = nil 30 | end 31 | @data = [] 32 | for i in 1...$data_items.size 33 | if $game_party.item_number(i) > 0 34 | @data.push($data_items[i]) 35 | end 36 | end 37 | for i in 1...$data_weapons.size 38 | if $game_party.weapon_number(i) > 0 39 | @data.push($data_weapons[i]) 40 | end 41 | end 42 | for i in 1...$data_armors.size 43 | if $game_party.armor_number(i) > 0 44 | @data.push($data_armors[i]) 45 | end 46 | end 47 | # If item count is not 0, make a bitmap and draw all items 48 | @item_max = @data.size 49 | if @item_max > 0 50 | self.contents = Bitmap.new(width - 32, row_max * 32) 51 | for i in 0...@item_max 52 | draw_item(i) 53 | end 54 | end 55 | end 56 | #-------------------------------------------------------------------------- 57 | # * Draw Item 58 | # index : item number 59 | #-------------------------------------------------------------------------- 60 | def draw_item(index) 61 | item = @data[index] 62 | case item 63 | when RPG::Item 64 | number = $game_party.item_number(item.id) 65 | when RPG::Weapon 66 | number = $game_party.weapon_number(item.id) 67 | when RPG::Armor 68 | number = $game_party.armor_number(item.id) 69 | end 70 | # If items are sellable, set to valid text color. If not, set to invalid 71 | # text color. 72 | if item.price > 0 73 | self.contents.font.color = normal_color 74 | else 75 | self.contents.font.color = disabled_color 76 | end 77 | x = 4 + index % 2 * (288 + 32) 78 | y = index / 2 * 32 79 | rect = Rect.new(x, y, self.width / @column_max - 32, 32) 80 | self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) 81 | bitmap = RPG::Cache.icon(item.icon_name) 82 | opacity = self.contents.font.color == normal_color ? 255 : 128 83 | self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) 84 | self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) 85 | self.contents.draw_text(x + 240, y, 16, 32, ":", 1) 86 | self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) 87 | end 88 | #-------------------------------------------------------------------------- 89 | # * Help Text Update 90 | #-------------------------------------------------------------------------- 91 | def update_help 92 | @help_window.set_text(self.item == nil ? "" : self.item.description) 93 | end 94 | end 95 | -------------------------------------------------------------------------------- /bin/scripts/50_Window_ShopNumber.rb: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | #============================================================================== 4 | # ** Window_ShopNumber 5 | #------------------------------------------------------------------------------ 6 | # This window is for inputting quantity of items to buy or sell on the 7 | # shop screen. 8 | #============================================================================== 9 | 10 | class Window_ShopNumber < Window_Base 11 | #-------------------------------------------------------------------------- 12 | # * Object Initialization 13 | #-------------------------------------------------------------------------- 14 | def initialize 15 | super(0, 128, 368, 352) 16 | self.contents = Bitmap.new(width - 32, height - 32) 17 | @item = nil 18 | @max = 1 19 | @price = 0 20 | @number = 1 21 | end 22 | #-------------------------------------------------------------------------- 23 | # * Set Items, Max Quantity, and Price 24 | #-------------------------------------------------------------------------- 25 | def set(item, max, price) 26 | @item = item 27 | @max = max 28 | @price = price 29 | @number = 1 30 | refresh 31 | end 32 | #-------------------------------------------------------------------------- 33 | # * Set Inputted Quantity 34 | #-------------------------------------------------------------------------- 35 | def number 36 | return @number 37 | end 38 | #-------------------------------------------------------------------------- 39 | # * Refresh 40 | #-------------------------------------------------------------------------- 41 | def refresh 42 | self.contents.clear 43 | draw_item_name(@item, 4, 96) 44 | self.contents.font.color = normal_color 45 | self.contents.draw_text(272, 96, 32, 32, "×") 46 | self.contents.draw_text(308, 96, 24, 32, @number.to_s, 2) 47 | self.cursor_rect.set(304, 96, 32, 32) 48 | # Draw total price and currency units 49 | domination = $data_system.words.gold 50 | cx = contents.text_size(domination).width 51 | total_price = @price * @number 52 | self.contents.font.color = normal_color 53 | self.contents.draw_text(4, 160, 328-cx-2, 32, total_price.to_s, 2) 54 | self.contents.font.color = system_color 55 | self.contents.draw_text(332-cx, 160, cx, 32, domination, 2) 56 | end 57 | #-------------------------------------------------------------------------- 58 | # * Frame Update 59 | #-------------------------------------------------------------------------- 60 | def update 61 | super 62 | if self.active 63 | # Cursor right (+1) 64 | if Input.repeat?(Input::RIGHT) and @number < @max 65 | $game_system.se_play($data_system.cursor_se) 66 | @number += 1 67 | refresh 68 | end 69 | # Cursor left (-1) 70 | if Input.repeat?(Input::LEFT) and @number > 1 71 | $game_system.se_play($data_system.cursor_se) 72 | @number -= 1 73 | refresh 74 | end 75 | # Cursdr up (+10) 76 | if Input.repeat?(Input::UP) and @number < @max 77 | $game_system.se_play($data_system.cursor_se) 78 | @number = [@number + 10, @max].min 79 | refresh 80 | end 81 | # Cursor down (-10) 82 | if Input.repeat?(Input::DOWN) and @number > 1 83 | $game_system.se_play($data_system.cursor_se) 84 | @number = [@number - 10, 1].max 85 | refresh 86 | end 87 | end 88 | end 89 | end 90 | -------------------------------------------------------------------------------- /bin/scripts/51_Window_ShopStatus.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_ShopStatus 3 | #------------------------------------------------------------------------------ 4 | # This window displays number of items in possession and the actor's equipment 5 | # on the shop screen. 6 | #============================================================================== 7 | 8 | class Window_ShopStatus < Window_Base 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | #-------------------------------------------------------------------------- 12 | def initialize 13 | super(368, 128, 272, 352) 14 | self.contents = Bitmap.new(width - 32, height - 32) 15 | @item = nil 16 | refresh 17 | end 18 | #-------------------------------------------------------------------------- 19 | # * Refresh 20 | #-------------------------------------------------------------------------- 21 | def refresh 22 | self.contents.clear 23 | if @item == nil 24 | return 25 | end 26 | case @item 27 | when RPG::Item 28 | number = $game_party.item_number(@item.id) 29 | when RPG::Weapon 30 | number = $game_party.weapon_number(@item.id) 31 | when RPG::Armor 32 | number = $game_party.armor_number(@item.id) 33 | end 34 | self.contents.font.color = system_color 35 | self.contents.draw_text(4, 0, 200, 32, "number in possession") 36 | self.contents.font.color = normal_color 37 | self.contents.draw_text(204, 0, 32, 32, number.to_s, 2) 38 | if @item.is_a?(RPG::Item) 39 | return 40 | end 41 | # Equipment adding information 42 | for i in 0...$game_party.actors.size 43 | # Get actor 44 | actor = $game_party.actors[i] 45 | # If equippable, then set to normal text color. If not, set to 46 | # invalid text color. 47 | if actor.equippable?(@item) 48 | self.contents.font.color = normal_color 49 | else 50 | self.contents.font.color = disabled_color 51 | end 52 | # Draw actor's name 53 | self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name) 54 | # Get current equipment 55 | if @item.is_a?(RPG::Weapon) 56 | item1 = $data_weapons[actor.weapon_id] 57 | elsif @item.kind == 0 58 | item1 = $data_armors[actor.armor1_id] 59 | elsif @item.kind == 1 60 | item1 = $data_armors[actor.armor2_id] 61 | elsif @item.kind == 2 62 | item1 = $data_armors[actor.armor3_id] 63 | else 64 | item1 = $data_armors[actor.armor4_id] 65 | end 66 | # If equippable 67 | if actor.equippable?(@item) 68 | # If weapon 69 | if @item.is_a?(RPG::Weapon) 70 | atk1 = item1 != nil ? item1.atk : 0 71 | atk2 = @item != nil ? @item.atk : 0 72 | change = atk2 - atk1 73 | end 74 | # If armor 75 | if @item.is_a?(RPG::Armor) 76 | pdef1 = item1 != nil ? item1.pdef : 0 77 | mdef1 = item1 != nil ? item1.mdef : 0 78 | pdef2 = @item != nil ? @item.pdef : 0 79 | mdef2 = @item != nil ? @item.mdef : 0 80 | change = pdef2 - pdef1 + mdef2 - mdef1 81 | end 82 | # Draw parameter change values 83 | self.contents.draw_text(124, 64 + 64 * i, 112, 32, 84 | sprintf("%+d", change), 2) 85 | end 86 | # Draw item 87 | if item1 != nil 88 | x = 4 89 | y = 64 + 64 * i + 32 90 | bitmap = RPG::Cache.icon(item1.icon_name) 91 | opacity = self.contents.font.color == normal_color ? 255 : 128 92 | self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) 93 | self.contents.draw_text(x + 28, y, 212, 32, item1.name) 94 | end 95 | end 96 | end 97 | #-------------------------------------------------------------------------- 98 | # * Set Item 99 | # item : new item 100 | #-------------------------------------------------------------------------- 101 | def item=(item) 102 | if @item != item 103 | @item = item 104 | refresh 105 | end 106 | end 107 | end 108 | -------------------------------------------------------------------------------- /bin/scripts/52_Window_NameEdit.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_NameEdit 3 | #------------------------------------------------------------------------------ 4 | # This window is used to edit your name on the input name screen. 5 | #============================================================================== 6 | 7 | class Window_NameEdit < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Public Instance Variables 10 | #-------------------------------------------------------------------------- 11 | attr_reader :name # name 12 | attr_reader :index # cursor position 13 | #-------------------------------------------------------------------------- 14 | # * Object Initialization 15 | # actor : actor 16 | # max_char : maximum number of characters 17 | #-------------------------------------------------------------------------- 18 | def initialize(actor, max_char) 19 | super(0, 0, 640, 128) 20 | self.contents = Bitmap.new(width - 32, height - 32) 21 | @actor = actor 22 | @name = actor.name 23 | @max_char = max_char 24 | # Fit name within maximum number of characters 25 | name_array = @name.split(//)[0...@max_char] 26 | @name = "" 27 | for i in 0...name_array.size 28 | @name += name_array[i] 29 | end 30 | @default_name = @name 31 | @index = name_array.size 32 | refresh 33 | update_cursor_rect 34 | end 35 | #-------------------------------------------------------------------------- 36 | # * Return to Default Name 37 | #-------------------------------------------------------------------------- 38 | def restore_default 39 | @name = @default_name 40 | @index = @name.split(//).size 41 | refresh 42 | update_cursor_rect 43 | end 44 | #-------------------------------------------------------------------------- 45 | # * Add Character 46 | # character : text character to be added 47 | #-------------------------------------------------------------------------- 48 | def add(character) 49 | if @index < @max_char and character != "" 50 | @name += character 51 | @index += 1 52 | refresh 53 | update_cursor_rect 54 | end 55 | end 56 | #-------------------------------------------------------------------------- 57 | # * Delete Character 58 | #-------------------------------------------------------------------------- 59 | def back 60 | if @index > 0 61 | # Delete 1 text character 62 | name_array = @name.split(//) 63 | @name = "" 64 | for i in 0...name_array.size-1 65 | @name += name_array[i] 66 | end 67 | @index -= 1 68 | refresh 69 | update_cursor_rect 70 | end 71 | end 72 | #-------------------------------------------------------------------------- 73 | # * Refresh 74 | #-------------------------------------------------------------------------- 75 | def refresh 76 | self.contents.clear 77 | # Draw name 78 | name_array = @name.split(//) 79 | for i in 0...@max_char 80 | c = name_array[i] 81 | if c == nil 82 | c = "_" 83 | end 84 | x = 320 - @max_char * 14 + i * 28 85 | self.contents.draw_text(x, 32, 28, 32, c, 1) 86 | end 87 | # Draw graphic 88 | draw_actor_graphic(@actor, 320 - @max_char * 14 - 40, 80) 89 | end 90 | #-------------------------------------------------------------------------- 91 | # * Cursor Rectangle Update 92 | #-------------------------------------------------------------------------- 93 | def update_cursor_rect 94 | x = 320 - @max_char * 14 + @index * 28 95 | self.cursor_rect.set(x, 32, 28, 32) 96 | end 97 | #-------------------------------------------------------------------------- 98 | # * Frame Update 99 | #-------------------------------------------------------------------------- 100 | def update 101 | super 102 | update_cursor_rect 103 | end 104 | end 105 | -------------------------------------------------------------------------------- /bin/scripts/53_Window_InputNumber.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_InputNumber 3 | #------------------------------------------------------------------------------ 4 | # This window is for inputting numbers, and is used within the 5 | # message window. 6 | #============================================================================== 7 | 8 | class Window_InputNumber < Window_Base 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | # digits_max : digit count 12 | #-------------------------------------------------------------------------- 13 | def initialize(digits_max) 14 | @digits_max = digits_max 15 | @number = 0 16 | # Calculate cursor width from number width (0-9 equal width and postulate) 17 | dummy_bitmap = Bitmap.new(32, 32) 18 | @cursor_width = dummy_bitmap.text_size("0").width + 8 19 | dummy_bitmap.dispose 20 | super(0, 0, @cursor_width * @digits_max + 32, 64) 21 | self.contents = Bitmap.new(width - 32, height - 32) 22 | self.z += 9999 23 | self.opacity = 0 24 | @index = 0 25 | refresh 26 | update_cursor_rect 27 | end 28 | #-------------------------------------------------------------------------- 29 | # * Get Number 30 | #-------------------------------------------------------------------------- 31 | def number 32 | return @number 33 | end 34 | #-------------------------------------------------------------------------- 35 | # * Set Number 36 | # number : new number 37 | #-------------------------------------------------------------------------- 38 | def number=(number) 39 | @number = [[number, 0].max, 10 ** @digits_max - 1].min 40 | refresh 41 | end 42 | #-------------------------------------------------------------------------- 43 | # * Cursor Rectangle Update 44 | #-------------------------------------------------------------------------- 45 | def update_cursor_rect 46 | self.cursor_rect.set(@index * @cursor_width, 0, @cursor_width, 32) 47 | end 48 | #-------------------------------------------------------------------------- 49 | # * Frame Update 50 | #-------------------------------------------------------------------------- 51 | def update 52 | super 53 | # If up or down directional button was pressed 54 | if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN) 55 | $game_system.se_play($data_system.cursor_se) 56 | # Get current place number and change it to 0 57 | place = 10 ** (@digits_max - 1 - @index) 58 | n = @number / place % 10 59 | @number -= n * place 60 | # If up add 1, if down substract 1 61 | n = (n + 1) % 10 if Input.repeat?(Input::UP) 62 | n = (n + 9) % 10 if Input.repeat?(Input::DOWN) 63 | # Reset current place number 64 | @number += n * place 65 | refresh 66 | end 67 | # Cursor right 68 | if Input.repeat?(Input::RIGHT) 69 | if @digits_max >= 2 70 | $game_system.se_play($data_system.cursor_se) 71 | @index = (@index + 1) % @digits_max 72 | end 73 | end 74 | # Cursor left 75 | if Input.repeat?(Input::LEFT) 76 | if @digits_max >= 2 77 | $game_system.se_play($data_system.cursor_se) 78 | @index = (@index + @digits_max - 1) % @digits_max 79 | end 80 | end 81 | update_cursor_rect 82 | end 83 | #-------------------------------------------------------------------------- 84 | # * Refresh 85 | #-------------------------------------------------------------------------- 86 | def refresh 87 | self.contents.clear 88 | self.contents.font.color = normal_color 89 | s = sprintf("%0*d", @digits_max, @number) 90 | for i in 0...@digits_max 91 | self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1]) 92 | end 93 | end 94 | end 95 | -------------------------------------------------------------------------------- /bin/scripts/55_Window_PartyCommand.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_PartyCommand 3 | #------------------------------------------------------------------------------ 4 | # This window is used to select whether to fight or escape on the battle 5 | # screen. 6 | #============================================================================== 7 | 8 | class Window_PartyCommand < Window_Selectable 9 | #-------------------------------------------------------------------------- 10 | # * Object Initialization 11 | #-------------------------------------------------------------------------- 12 | def initialize 13 | super(0, 0, 640, 64) 14 | self.contents = Bitmap.new(width - 32, height - 32) 15 | self.back_opacity = 160 16 | @commands = ["Fight", "Escape"] 17 | @item_max = 2 18 | @column_max = 2 19 | draw_item(0, normal_color) 20 | draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color) 21 | self.active = false 22 | self.visible = false 23 | self.index = 0 24 | end 25 | #-------------------------------------------------------------------------- 26 | # * Draw Item 27 | # index : item number 28 | # color : text character color 29 | #-------------------------------------------------------------------------- 30 | def draw_item(index, color) 31 | self.contents.font.color = color 32 | rect = Rect.new(160 + index * 160 + 4, 0, 128 - 10, 32) 33 | self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) 34 | self.contents.draw_text(rect, @commands[index], 1) 35 | end 36 | #-------------------------------------------------------------------------- 37 | # * Cursor Rectangle Update 38 | #-------------------------------------------------------------------------- 39 | def update_cursor_rect 40 | self.cursor_rect.set(160 + index * 160, 0, 128, 32) 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /bin/scripts/56_Window_BattleStatus.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_BattleStatus 3 | #------------------------------------------------------------------------------ 4 | # This window displays the status of all party members on the battle screen. 5 | #============================================================================== 6 | 7 | class Window_BattleStatus < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 320, 640, 160) 13 | self.contents = Bitmap.new(width - 32, height - 32) 14 | @level_up_flags = [false, false, false, false] 15 | refresh 16 | end 17 | #-------------------------------------------------------------------------- 18 | # * Dispose 19 | #-------------------------------------------------------------------------- 20 | def dispose 21 | super 22 | end 23 | #-------------------------------------------------------------------------- 24 | # * Set Level Up Flag 25 | # actor_index : actor index 26 | #-------------------------------------------------------------------------- 27 | def level_up(actor_index) 28 | @level_up_flags[actor_index] = true 29 | end 30 | #-------------------------------------------------------------------------- 31 | # * Refresh 32 | #-------------------------------------------------------------------------- 33 | def refresh 34 | self.contents.clear 35 | @item_max = $game_party.actors.size 36 | for i in 0...$game_party.actors.size 37 | actor = $game_party.actors[i] 38 | actor_x = i * 160 + 4 39 | draw_actor_name(actor, actor_x, 0) 40 | draw_actor_hp(actor, actor_x, 32, 120) 41 | draw_actor_sp(actor, actor_x, 64, 120) 42 | if @level_up_flags[i] 43 | self.contents.font.color = normal_color 44 | self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!") 45 | else 46 | draw_actor_state(actor, actor_x, 96) 47 | end 48 | end 49 | end 50 | #-------------------------------------------------------------------------- 51 | # * Frame Update 52 | #-------------------------------------------------------------------------- 53 | def update 54 | super 55 | # Slightly lower opacity level during main phase 56 | if $game_temp.battle_main_phase 57 | self.contents_opacity -= 4 if self.contents_opacity > 191 58 | else 59 | self.contents_opacity += 4 if self.contents_opacity < 255 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /bin/scripts/57_Window_BattleResult.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_BattleResult 3 | #------------------------------------------------------------------------------ 4 | # This window displays amount of gold and EXP acquired at the end of a battle. 5 | #============================================================================== 6 | 7 | class Window_BattleResult < Window_Base 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | # exp : EXP 11 | # gold : amount of gold 12 | # treasures : treasures 13 | #-------------------------------------------------------------------------- 14 | def initialize(exp, gold, treasures) 15 | @exp = exp 16 | @gold = gold 17 | @treasures = treasures 18 | super(160, 0, 320, @treasures.size * 32 + 64) 19 | self.contents = Bitmap.new(width - 32, height - 32) 20 | self.y = 160 - height / 2 21 | self.back_opacity = 160 22 | self.visible = false 23 | refresh 24 | end 25 | #-------------------------------------------------------------------------- 26 | # * Refresh 27 | #-------------------------------------------------------------------------- 28 | def refresh 29 | self.contents.clear 30 | x = 4 31 | self.contents.font.color = normal_color 32 | cx = contents.text_size(@exp.to_s).width 33 | self.contents.draw_text(x, 0, cx, 32, @exp.to_s) 34 | x += cx + 4 35 | self.contents.font.color = system_color 36 | cx = contents.text_size("EXP").width 37 | self.contents.draw_text(x, 0, 64, 32, "EXP") 38 | x += cx + 16 39 | self.contents.font.color = normal_color 40 | cx = contents.text_size(@gold.to_s).width 41 | self.contents.draw_text(x, 0, cx, 32, @gold.to_s) 42 | x += cx + 4 43 | self.contents.font.color = system_color 44 | self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold) 45 | y = 32 46 | for item in @treasures 47 | draw_item_name(item, 4, y) 48 | y += 32 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /bin/scripts/58_Window_DebugLeft.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_DebugLeft 3 | #------------------------------------------------------------------------------ 4 | # This window designates switch and variable blocks on the debug screen. 5 | #============================================================================== 6 | 7 | class Window_DebugLeft < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super(0, 0, 192, 480) 13 | self.index = 0 14 | refresh 15 | end 16 | #-------------------------------------------------------------------------- 17 | # * Refresh 18 | #-------------------------------------------------------------------------- 19 | def refresh 20 | if self.contents != nil 21 | self.contents.dispose 22 | self.contents = nil 23 | end 24 | @switch_max = ($data_system.switches.size - 1 + 9) / 10 25 | @variable_max = ($data_system.variables.size - 1 + 9) / 10 26 | @item_max = @switch_max + @variable_max 27 | self.contents = Bitmap.new(width - 32, @item_max * 32) 28 | for i in 0...@switch_max 29 | text = sprintf("S [%04d-%04d]", i*10+1, i*10+10) 30 | self.contents.draw_text(4, i * 32, 152, 32, text) 31 | end 32 | for i in 0...@variable_max 33 | text = sprintf("V [%04d-%04d]", i*10+1, i*10+10) 34 | self.contents.draw_text(4, (@switch_max + i) * 32, 152, 32, text) 35 | end 36 | end 37 | #-------------------------------------------------------------------------- 38 | # * Get Mode 39 | #-------------------------------------------------------------------------- 40 | def mode 41 | if self.index < @switch_max 42 | return 0 43 | else 44 | return 1 45 | end 46 | end 47 | #-------------------------------------------------------------------------- 48 | # * Get ID Shown on Top 49 | #-------------------------------------------------------------------------- 50 | def top_id 51 | if self.index < @switch_max 52 | return self.index * 10 + 1 53 | else 54 | return (self.index - @switch_max) * 10 + 1 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /bin/scripts/59_Window_DebugRight.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Window_DebugRight 3 | #------------------------------------------------------------------------------ 4 | # This window displays switches and variables separately on the debug screen. 5 | #============================================================================== 6 | 7 | class Window_DebugRight < Window_Selectable 8 | #-------------------------------------------------------------------------- 9 | # * Public Instance Variables 10 | #-------------------------------------------------------------------------- 11 | attr_reader :mode # mode (0: switch, 1: variable) 12 | attr_reader :top_id # ID shown on top 13 | #-------------------------------------------------------------------------- 14 | # * Object Initialization 15 | #-------------------------------------------------------------------------- 16 | def initialize 17 | super(192, 0, 448, 352) 18 | self.contents = Bitmap.new(width - 32, height - 32) 19 | self.index = -1 20 | self.active = false 21 | @item_max = 10 22 | @mode = 0 23 | @top_id = 1 24 | refresh 25 | end 26 | #-------------------------------------------------------------------------- 27 | # * Refresh 28 | #-------------------------------------------------------------------------- 29 | def refresh 30 | self.contents.clear 31 | for i in 0..9 32 | if @mode == 0 33 | name = $data_system.switches[@top_id+i] 34 | status = $game_switches[@top_id+i] ? "[ON]" : "[OFF]" 35 | else 36 | name = $data_system.variables[@top_id+i] 37 | status = $game_variables[@top_id+i].to_s 38 | end 39 | if name == nil 40 | name = '' 41 | end 42 | id_text = sprintf("%04d:", @top_id+i) 43 | width = self.contents.text_size(id_text).width 44 | self.contents.draw_text(4, i * 32, width, 32, id_text) 45 | self.contents.draw_text(12 + width, i * 32, 296 - width, 32, name) 46 | self.contents.draw_text(312, i * 32, 100, 32, status, 2) 47 | end 48 | end 49 | #-------------------------------------------------------------------------- 50 | # * Set Mode 51 | # id : new mode 52 | #-------------------------------------------------------------------------- 53 | def mode=(mode) 54 | if @mode != mode 55 | @mode = mode 56 | refresh 57 | end 58 | end 59 | #-------------------------------------------------------------------------- 60 | # * Set ID Shown on Top 61 | # id : new ID 62 | #-------------------------------------------------------------------------- 63 | def top_id=(id) 64 | if @top_id != id 65 | @top_id = id 66 | refresh 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /bin/scripts/60_Arrow_Base.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Arrow_Base 3 | #------------------------------------------------------------------------------ 4 | # This sprite is used as an arrow cursor for the battle screen. This class 5 | # is used as a superclass for the Arrow_Enemy and Arrow_Actor classes. 6 | #============================================================================== 7 | 8 | class Arrow_Base < Sprite 9 | #-------------------------------------------------------------------------- 10 | # * Public Instance Variables 11 | #-------------------------------------------------------------------------- 12 | attr_reader :index # cursor position 13 | attr_reader :help_window # help window 14 | #-------------------------------------------------------------------------- 15 | # * Object Initialization 16 | # viewport : viewport 17 | #-------------------------------------------------------------------------- 18 | def initialize(viewport) 19 | super(viewport) 20 | self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name) 21 | self.ox = 16 22 | self.oy = 64 23 | self.z = 2500 24 | @blink_count = 0 25 | @index = 0 26 | @help_window = nil 27 | update 28 | end 29 | #-------------------------------------------------------------------------- 30 | # * Set Cursor Position 31 | # index : new cursor position 32 | #-------------------------------------------------------------------------- 33 | def index=(index) 34 | @index = index 35 | update 36 | end 37 | #-------------------------------------------------------------------------- 38 | # * Set Help Window 39 | # help_window : new help window 40 | #-------------------------------------------------------------------------- 41 | def help_window=(help_window) 42 | @help_window = help_window 43 | # Update help text (update_help is defined by the subclasses) 44 | if @help_window != nil 45 | update_help 46 | end 47 | end 48 | #-------------------------------------------------------------------------- 49 | # * Frame Update 50 | #-------------------------------------------------------------------------- 51 | def update 52 | # Update blink count 53 | @blink_count = (@blink_count + 1) % 8 54 | # Set forwarding origin rectangle 55 | if @blink_count < 4 56 | self.src_rect.set(128, 96, 32, 32) 57 | else 58 | self.src_rect.set(160, 96, 32, 32) 59 | end 60 | # Update help text (update_help is defined by the subclasses) 61 | if @help_window != nil 62 | update_help 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /bin/scripts/61_Arrow_Enemy.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Arrow_Enemy 3 | #------------------------------------------------------------------------------ 4 | # This arrow cursor is used to choose enemies. This class inherits from the 5 | # Arrow_Base class. 6 | #============================================================================== 7 | 8 | class Arrow_Enemy < Arrow_Base 9 | #-------------------------------------------------------------------------- 10 | # * Get Enemy Indicated by Cursor 11 | #-------------------------------------------------------------------------- 12 | def enemy 13 | return $game_troop.enemies[@index] 14 | end 15 | #-------------------------------------------------------------------------- 16 | # * Frame Update 17 | #-------------------------------------------------------------------------- 18 | def update 19 | super 20 | # Skip if indicating a nonexistant enemy 21 | $game_troop.enemies.size.times do 22 | break if self.enemy.exist? 23 | @index += 1 24 | @index %= $game_troop.enemies.size 25 | end 26 | # Cursor right 27 | if Input.repeat?(Input::RIGHT) 28 | $game_system.se_play($data_system.cursor_se) 29 | $game_troop.enemies.size.times do 30 | @index += 1 31 | @index %= $game_troop.enemies.size 32 | break if self.enemy.exist? 33 | end 34 | end 35 | # Cursor left 36 | if Input.repeat?(Input::LEFT) 37 | $game_system.se_play($data_system.cursor_se) 38 | $game_troop.enemies.size.times do 39 | @index += $game_troop.enemies.size - 1 40 | @index %= $game_troop.enemies.size 41 | break if self.enemy.exist? 42 | end 43 | end 44 | # Set sprite coordinates 45 | if self.enemy != nil 46 | self.x = self.enemy.screen_x 47 | self.y = self.enemy.screen_y 48 | end 49 | end 50 | #-------------------------------------------------------------------------- 51 | # * Help Text Update 52 | #-------------------------------------------------------------------------- 53 | def update_help 54 | # Display enemy name and state in the help window 55 | @help_window.set_enemy(self.enemy) 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /bin/scripts/62_Arrow_Actor.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Arrow_Actor 3 | #------------------------------------------------------------------------------ 4 | # This arrow cursor is used to choose an actor. This class inherits from the 5 | # Arrow_Base class. 6 | #============================================================================== 7 | 8 | class Arrow_Actor < Arrow_Base 9 | #-------------------------------------------------------------------------- 10 | # * Get Actor Indicated by Cursor 11 | #-------------------------------------------------------------------------- 12 | def actor 13 | return $game_party.actors[@index] 14 | end 15 | #-------------------------------------------------------------------------- 16 | # * Frame Update 17 | #-------------------------------------------------------------------------- 18 | def update 19 | super 20 | # Cursor right 21 | if Input.repeat?(Input::RIGHT) 22 | $game_system.se_play($data_system.cursor_se) 23 | @index += 1 24 | @index %= $game_party.actors.size 25 | end 26 | # Cursor left 27 | if Input.repeat?(Input::LEFT) 28 | $game_system.se_play($data_system.cursor_se) 29 | @index += $game_party.actors.size - 1 30 | @index %= $game_party.actors.size 31 | end 32 | # Set sprite coordinates 33 | if self.actor != nil 34 | self.x = self.actor.screen_x 35 | self.y = self.actor.screen_y 36 | end 37 | end 38 | #-------------------------------------------------------------------------- 39 | # * Help Text Update 40 | #-------------------------------------------------------------------------- 41 | def update_help 42 | # Display actor status in help window 43 | @help_window.set_actor(self.actor) 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /bin/scripts/76_Scene_Status.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Scene_Status 3 | #------------------------------------------------------------------------------ 4 | # This class performs status screen processing. 5 | #============================================================================== 6 | 7 | class Scene_Status 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | # actor_index : actor index 11 | #-------------------------------------------------------------------------- 12 | def initialize(actor_index = 0, equip_index = 0) 13 | @actor_index = actor_index 14 | end 15 | #-------------------------------------------------------------------------- 16 | # * Main Processing 17 | #-------------------------------------------------------------------------- 18 | def main 19 | # Get actor 20 | @actor = $game_party.actors[@actor_index] 21 | # Make status window 22 | @status_window = Window_Status.new(@actor) 23 | # Execute transition 24 | Graphics.transition 25 | # Main loop 26 | loop do 27 | # Update game screen 28 | Graphics.update 29 | # Update input information 30 | Input.update 31 | # Frame update 32 | update 33 | # Abort loop if screen is changed 34 | if $scene != self 35 | break 36 | end 37 | end 38 | # Prepare for transition 39 | Graphics.freeze 40 | # Dispose of windows 41 | @status_window.dispose 42 | end 43 | #-------------------------------------------------------------------------- 44 | # * Frame Update 45 | #-------------------------------------------------------------------------- 46 | def update 47 | # If B button was pressed 48 | if Input.trigger?(Input::B) 49 | # Play cancel SE 50 | $game_system.se_play($data_system.cancel_se) 51 | # Switch to menu screen 52 | $scene = Scene_Menu.new(3) 53 | return 54 | end 55 | # If R button was pressed 56 | if Input.trigger?(Input::R) 57 | # Play cursor SE 58 | $game_system.se_play($data_system.cursor_se) 59 | # To next actor 60 | @actor_index += 1 61 | @actor_index %= $game_party.actors.size 62 | # Switch to different status screen 63 | $scene = Scene_Status.new(@actor_index) 64 | return 65 | end 66 | # If L button was pressed 67 | if Input.trigger?(Input::L) 68 | # Play cursor SE 69 | $game_system.se_play($data_system.cursor_se) 70 | # To previous actor 71 | @actor_index += $game_party.actors.size - 1 72 | @actor_index %= $game_party.actors.size 73 | # Switch to different status screen 74 | $scene = Scene_Status.new(@actor_index) 75 | return 76 | end 77 | end 78 | end 79 | -------------------------------------------------------------------------------- /bin/scripts/77_Scene_File.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Scene_File 3 | #------------------------------------------------------------------------------ 4 | # This is a superclass for the save screen and load screen. 5 | #============================================================================== 6 | 7 | class Scene_File 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | # help_text : text string shown in the help window 11 | #-------------------------------------------------------------------------- 12 | def initialize(help_text) 13 | @help_text = help_text 14 | end 15 | #-------------------------------------------------------------------------- 16 | # * Main Processing 17 | #-------------------------------------------------------------------------- 18 | def main 19 | # Make help window 20 | @help_window = Window_Help.new 21 | @help_window.set_text(@help_text) 22 | # Make save file window 23 | @savefile_windows = [] 24 | for i in 0..3 25 | @savefile_windows.push(Window_SaveFile.new(i, make_filename(i))) 26 | end 27 | # Select last file to be operated 28 | @file_index = $game_temp.last_file_index 29 | @savefile_windows[@file_index].selected = true 30 | # Execute transition 31 | Graphics.transition 32 | # Main loop 33 | loop do 34 | # Update game screen 35 | Graphics.update 36 | # Update input information 37 | Input.update 38 | # Frame update 39 | update 40 | # Abort loop if screen is changed 41 | if $scene != self 42 | break 43 | end 44 | end 45 | # Prepare for transition 46 | Graphics.freeze 47 | # Dispose of windows 48 | @help_window.dispose 49 | for i in @savefile_windows 50 | i.dispose 51 | end 52 | end 53 | #-------------------------------------------------------------------------- 54 | # * Frame Update 55 | #-------------------------------------------------------------------------- 56 | def update 57 | # Update windows 58 | @help_window.update 59 | for i in @savefile_windows 60 | i.update 61 | end 62 | # If C button was pressed 63 | if Input.trigger?(Input::C) 64 | # Call method: on_decision (defined by the subclasses) 65 | on_decision(make_filename(@file_index)) 66 | $game_temp.last_file_index = @file_index 67 | return 68 | end 69 | # If B button was pressed 70 | if Input.trigger?(Input::B) 71 | # Call method: on_cancel (defined by the subclasses) 72 | on_cancel 73 | return 74 | end 75 | # If the down directional button was pressed 76 | if Input.repeat?(Input::DOWN) 77 | # If the down directional button pressed down is not a repeat, 78 | # or cursor position is more in front than 3 79 | if Input.trigger?(Input::DOWN) or @file_index < 3 80 | # Play cursor SE 81 | $game_system.se_play($data_system.cursor_se) 82 | # Move cursor down 83 | @savefile_windows[@file_index].selected = false 84 | @file_index = (@file_index + 1) % 4 85 | @savefile_windows[@file_index].selected = true 86 | return 87 | end 88 | end 89 | # If the up directional button was pressed 90 | if Input.repeat?(Input::UP) 91 | # If the up directional button pressed down is not a repeat? 92 | # or cursor position is more in back than 0 93 | if Input.trigger?(Input::UP) or @file_index > 0 94 | # Play cursor SE 95 | $game_system.se_play($data_system.cursor_se) 96 | # Move cursor up 97 | @savefile_windows[@file_index].selected = false 98 | @file_index = (@file_index + 3) % 4 99 | @savefile_windows[@file_index].selected = true 100 | return 101 | end 102 | end 103 | end 104 | #-------------------------------------------------------------------------- 105 | # * Make File Name 106 | # file_index : save file index (0-3) 107 | #-------------------------------------------------------------------------- 108 | def make_filename(file_index) 109 | return "Save#{file_index + 1}.rxdata" 110 | end 111 | end 112 | -------------------------------------------------------------------------------- /bin/scripts/78_Scene_Save.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Scene_Save 3 | #------------------------------------------------------------------------------ 4 | # This class performs save screen processing. 5 | #============================================================================== 6 | 7 | class Scene_Save < Scene_File 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | super("Which file would you like to save to?") 13 | end 14 | #-------------------------------------------------------------------------- 15 | # * Decision Processing 16 | #-------------------------------------------------------------------------- 17 | def on_decision(filename) 18 | # Play save SE 19 | $game_system.se_play($data_system.save_se) 20 | # Write save data 21 | file = File.open(filename, "wb") 22 | write_save_data(file) 23 | file.close 24 | # If called from event 25 | if $game_temp.save_calling 26 | # Clear save call flag 27 | $game_temp.save_calling = false 28 | # Switch to map screen 29 | $scene = Scene_Map.new 30 | return 31 | end 32 | # Switch to menu screen 33 | $scene = Scene_Menu.new(4) 34 | end 35 | #-------------------------------------------------------------------------- 36 | # * Cancel Processing 37 | #-------------------------------------------------------------------------- 38 | def on_cancel 39 | # Play cancel SE 40 | $game_system.se_play($data_system.cancel_se) 41 | # If called from event 42 | if $game_temp.save_calling 43 | # Clear save call flag 44 | $game_temp.save_calling = false 45 | # Switch to map screen 46 | $scene = Scene_Map.new 47 | return 48 | end 49 | # Switch to menu screen 50 | $scene = Scene_Menu.new(4) 51 | end 52 | #-------------------------------------------------------------------------- 53 | # * Write Save Data 54 | # file : write file object (opened) 55 | #-------------------------------------------------------------------------- 56 | def write_save_data(file) 57 | # Make character data for drawing save file 58 | characters = [] 59 | for i in 0...$game_party.actors.size 60 | actor = $game_party.actors[i] 61 | characters.push([actor.character_name, actor.character_hue]) 62 | end 63 | # Write character data for drawing save file 64 | Marshal.dump(characters, file) 65 | # Wrire frame count for measuring play time 66 | Marshal.dump(Graphics.frame_count, file) 67 | # Increase save count by 1 68 | $game_system.save_count += 1 69 | # Save magic number 70 | # (A random value will be written each time saving with editor) 71 | $game_system.magic_number = $data_system.magic_number 72 | # Write each type of game object 73 | Marshal.dump($game_system, file) 74 | Marshal.dump($game_switches, file) 75 | Marshal.dump($game_variables, file) 76 | Marshal.dump($game_self_switches, file) 77 | Marshal.dump($game_screen, file) 78 | Marshal.dump($game_actors, file) 79 | Marshal.dump($game_party, file) 80 | Marshal.dump($game_troop, file) 81 | Marshal.dump($game_map, file) 82 | Marshal.dump($game_player, file) 83 | end 84 | end 85 | -------------------------------------------------------------------------------- /bin/scripts/79_Scene_Load.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Scene_Load 3 | #------------------------------------------------------------------------------ 4 | # This class performs load screen processing. 5 | #============================================================================== 6 | 7 | class Scene_Load < Scene_File 8 | #-------------------------------------------------------------------------- 9 | # * Object Initialization 10 | #-------------------------------------------------------------------------- 11 | def initialize 12 | # Remake temporary object 13 | $game_temp = Game_Temp.new 14 | # Timestamp selects new file 15 | $game_temp.last_file_index = 0 16 | latest_time = Time.at(0) 17 | for i in 0..3 18 | filename = make_filename(i) 19 | if FileTest.exist?(filename) 20 | file = File.open(filename, "r") 21 | if file.mtime > latest_time 22 | latest_time = file.mtime 23 | $game_temp.last_file_index = i 24 | end 25 | file.close 26 | end 27 | end 28 | super("Which file would you like to load?") 29 | end 30 | #-------------------------------------------------------------------------- 31 | # * Decision Processing 32 | #-------------------------------------------------------------------------- 33 | def on_decision(filename) 34 | # If file doesn't exist 35 | unless FileTest.exist?(filename) 36 | # Play buzzer SE 37 | $game_system.se_play($data_system.buzzer_se) 38 | return 39 | end 40 | # Play load SE 41 | $game_system.se_play($data_system.load_se) 42 | # Read save data 43 | file = File.open(filename, "rb") 44 | read_save_data(file) 45 | file.close 46 | # Restore BGM and BGS 47 | $game_system.bgm_play($game_system.playing_bgm) 48 | $game_system.bgs_play($game_system.playing_bgs) 49 | # Update map (run parallel process event) 50 | $game_map.update 51 | # Switch to map screen 52 | $scene = Scene_Map.new 53 | end 54 | #-------------------------------------------------------------------------- 55 | # * Cancel Processing 56 | #-------------------------------------------------------------------------- 57 | def on_cancel 58 | # Play cancel SE 59 | $game_system.se_play($data_system.cancel_se) 60 | # Switch to title screen 61 | $scene = Scene_Title.new 62 | end 63 | #-------------------------------------------------------------------------- 64 | # * Read Save Data 65 | # file : file object for reading (opened) 66 | #-------------------------------------------------------------------------- 67 | def read_save_data(file) 68 | # Read character data for drawing save file 69 | characters = Marshal.load(file) 70 | # Read frame count for measuring play time 71 | Graphics.frame_count = Marshal.load(file) 72 | # Read each type of game object 73 | $game_system = Marshal.load(file) 74 | $game_switches = Marshal.load(file) 75 | $game_variables = Marshal.load(file) 76 | $game_self_switches = Marshal.load(file) 77 | $game_screen = Marshal.load(file) 78 | $game_actors = Marshal.load(file) 79 | $game_party = Marshal.load(file) 80 | $game_troop = Marshal.load(file) 81 | $game_map = Marshal.load(file) 82 | $game_player = Marshal.load(file) 83 | # If magic number is different from when saving 84 | # (if editing was added with editor) 85 | if $game_system.magic_number != $data_system.magic_number 86 | # Load map 87 | $game_map.setup($game_map.map_id) 88 | $game_player.center($game_player.x, $game_player.y) 89 | end 90 | # Refresh party members 91 | $game_party.refresh 92 | end 93 | end 94 | -------------------------------------------------------------------------------- /bin/scripts/80_Scene_End.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Scene_End 3 | #------------------------------------------------------------------------------ 4 | # This class performs game end screen processing. 5 | #============================================================================== 6 | 7 | class Scene_End 8 | #-------------------------------------------------------------------------- 9 | # * Main Processing 10 | #-------------------------------------------------------------------------- 11 | def main 12 | # Make command window 13 | s1 = "To Title" 14 | s2 = "Shutdown" 15 | s3 = "Cancel" 16 | @command_window = Window_Command.new(192, [s1, s2, s3]) 17 | @command_window.x = 320 - @command_window.width / 2 18 | @command_window.y = 240 - @command_window.height / 2 19 | # Execute transition 20 | Graphics.transition 21 | # Main loop 22 | loop do 23 | # Update game screen 24 | Graphics.update 25 | # Update input information 26 | Input.update 27 | # Frame Update 28 | update 29 | # Abort loop if screen is changed 30 | if $scene != self 31 | break 32 | end 33 | end 34 | # Prepare for transition 35 | Graphics.freeze 36 | # Dispose of window 37 | @command_window.dispose 38 | # If switching to title screen 39 | if $scene.is_a?(Scene_Title) 40 | # Fade out screen 41 | Graphics.transition 42 | Graphics.freeze 43 | end 44 | end 45 | #-------------------------------------------------------------------------- 46 | # * Frame Update 47 | #-------------------------------------------------------------------------- 48 | def update 49 | # Update command window 50 | @command_window.update 51 | # If B button was pressed 52 | if Input.trigger?(Input::B) 53 | # Play cancel SE 54 | $game_system.se_play($data_system.cancel_se) 55 | # Switch to menu screen 56 | $scene = Scene_Menu.new(5) 57 | return 58 | end 59 | # If C button was pressed 60 | if Input.trigger?(Input::C) 61 | # Branch by command window cursor position 62 | case @command_window.index 63 | when 0 # to title 64 | command_to_title 65 | when 1 # shutdown 66 | command_shutdown 67 | when 2 # quit 68 | command_cancel 69 | end 70 | return 71 | end 72 | end 73 | #-------------------------------------------------------------------------- 74 | # * Process When Choosing [To Title] Command 75 | #-------------------------------------------------------------------------- 76 | def command_to_title 77 | # Play decision SE 78 | $game_system.se_play($data_system.decision_se) 79 | # Fade out BGM, BGS, and ME 80 | Audio.bgm_fade(800) 81 | Audio.bgs_fade(800) 82 | Audio.me_fade(800) 83 | # Switch to title screen 84 | $scene = Scene_Title.new 85 | end 86 | #-------------------------------------------------------------------------- 87 | # * Process When Choosing [Shutdown] Command 88 | #-------------------------------------------------------------------------- 89 | def command_shutdown 90 | # Play decision SE 91 | $game_system.se_play($data_system.decision_se) 92 | # Fade out BGM, BGS, and ME 93 | Audio.bgm_fade(800) 94 | Audio.bgs_fade(800) 95 | Audio.me_fade(800) 96 | # Shutdown 97 | $scene = nil 98 | end 99 | #-------------------------------------------------------------------------- 100 | # * Process When Choosing [Cancel] Command 101 | #-------------------------------------------------------------------------- 102 | def command_cancel 103 | # Play decision SE 104 | $game_system.se_play($data_system.decision_se) 105 | # Switch to menu screen 106 | $scene = Scene_Menu.new(5) 107 | end 108 | end 109 | -------------------------------------------------------------------------------- /bin/scripts/86_Scene_Name.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Scene_Name 3 | #------------------------------------------------------------------------------ 4 | # This class performs name input screen processing. 5 | #============================================================================== 6 | 7 | class Scene_Name 8 | #-------------------------------------------------------------------------- 9 | # * Main Processing 10 | #-------------------------------------------------------------------------- 11 | def main 12 | # Get actor 13 | @actor = $game_actors[$game_temp.name_actor_id] 14 | # Make windows 15 | @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char) 16 | @input_window = Window_NameInput.new 17 | # Execute transition 18 | Graphics.transition 19 | # Main loop 20 | loop do 21 | # Update game screen 22 | Graphics.update 23 | # Update input information 24 | Input.update 25 | # Frame update 26 | update 27 | # Abort loop if screen is changed 28 | if $scene != self 29 | break 30 | end 31 | end 32 | # Prepare for transition 33 | Graphics.freeze 34 | # Dispose of windows 35 | @edit_window.dispose 36 | @input_window.dispose 37 | end 38 | #-------------------------------------------------------------------------- 39 | # * Frame Update 40 | #-------------------------------------------------------------------------- 41 | def update 42 | # Update windows 43 | @edit_window.update 44 | @input_window.update 45 | # If B button was pressed 46 | if Input.repeat?(Input::B) 47 | # If cursor position is at 0 48 | if @edit_window.index == 0 49 | return 50 | end 51 | # Play cancel SE 52 | $game_system.se_play($data_system.cancel_se) 53 | # Delete text 54 | @edit_window.back 55 | return 56 | end 57 | # If C button was pressed 58 | if Input.trigger?(Input::C) 59 | # If cursor position is at [OK] 60 | if @input_window.character == nil 61 | # If name is empty 62 | if @edit_window.name == "" 63 | # Return to default name 64 | @edit_window.restore_default 65 | # If name is empty 66 | if @edit_window.name == "" 67 | # Play buzzer SE 68 | $game_system.se_play($data_system.buzzer_se) 69 | return 70 | end 71 | # Play decision SE 72 | $game_system.se_play($data_system.decision_se) 73 | return 74 | end 75 | # Change actor name 76 | @actor.name = @edit_window.name 77 | # Play decision SE 78 | $game_system.se_play($data_system.decision_se) 79 | # Switch to map screen 80 | $scene = Scene_Map.new 81 | return 82 | end 83 | # If cursor position is at maximum 84 | if @edit_window.index == $game_temp.name_max_char 85 | # Play buzzer SE 86 | $game_system.se_play($data_system.buzzer_se) 87 | return 88 | end 89 | # If text character is empty 90 | if @input_window.character == "" 91 | # Play buzzer SE 92 | $game_system.se_play($data_system.buzzer_se) 93 | return 94 | end 95 | # Play decision SE 96 | $game_system.se_play($data_system.decision_se) 97 | # Add text character 98 | @edit_window.add(@input_window.character) 99 | return 100 | end 101 | end 102 | end 103 | -------------------------------------------------------------------------------- /bin/scripts/87_Scene_GameOver.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Scene_Gameover 3 | #------------------------------------------------------------------------------ 4 | # This class performs game over screen processing. 5 | #============================================================================== 6 | 7 | class Scene_Gameover 8 | #-------------------------------------------------------------------------- 9 | # * Main Processing 10 | #-------------------------------------------------------------------------- 11 | def main 12 | # Make game over graphic 13 | @sprite = Sprite.new 14 | @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name) 15 | # Stop BGM and BGS 16 | $game_system.bgm_play(nil) 17 | $game_system.bgs_play(nil) 18 | # Play game over ME 19 | $game_system.me_play($data_system.gameover_me) 20 | # Execute transition 21 | Graphics.transition(120) 22 | # Main loop 23 | loop do 24 | # Update game screen 25 | Graphics.update 26 | # Update input information 27 | Input.update 28 | # Frame update 29 | update 30 | # Abort loop if screen is changed 31 | if $scene != self 32 | break 33 | end 34 | end 35 | # Prepare for transition 36 | Graphics.freeze 37 | # Dispose of game over graphic 38 | @sprite.bitmap.dispose 39 | @sprite.dispose 40 | # Execute transition 41 | Graphics.transition(40) 42 | # Prepare for transition 43 | Graphics.freeze 44 | # If battle test 45 | if $BTEST 46 | $scene = nil 47 | end 48 | end 49 | #-------------------------------------------------------------------------- 50 | # * Frame Update 51 | #-------------------------------------------------------------------------- 52 | def update 53 | # If C button was pressed 54 | if Input.trigger?(Input::C) 55 | # Switch to title screen 56 | $scene = Scene_Title.new 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /bin/scripts/89_Main.rb: -------------------------------------------------------------------------------- 1 | #============================================================================== 2 | # ** Main 3 | #------------------------------------------------------------------------------ 4 | # After defining each class, actual processing begins here. 5 | #============================================================================== 6 | 7 | begin 8 | # Prepare for transition 9 | Graphics.freeze 10 | # Make scene object (title screen) 11 | $scene = Scene_Title.new 12 | # Call main method as long as $scene is effective 13 | while $scene != nil 14 | $scene.main 15 | end 16 | # Fade out 17 | Graphics.transition(20) 18 | rescue Errno::ENOENT 19 | # Supplement Errno::ENOENT exception 20 | # If unable to open file, display message and end 21 | filename = $!.message.sub("No such file or directory - ", "") 22 | print("Unable to find file #{filename}.") 23 | end 24 | -------------------------------------------------------------------------------- /lib/audio.rb: -------------------------------------------------------------------------------- 1 | # The module that carries out music and sound processing. 2 | module Audio 3 | # Starts BGM playback. Sets the file name, volume, and pitch in turn. 4 | # 5 | # Also automatically searches files included in RGSS-RTP. File extensions may be omitted. 6 | def Audio.bgm_play(filename, volume = 100, pitch = 100) 7 | raise "not implemented" 8 | end 9 | 10 | # Stops BGM playback. 11 | def Audio.bgm_stop 12 | raise "not implemented" 13 | end 14 | 15 | # Starts BGM fadeout. time is the length of the fadeout in milliseconds. 16 | def Audio.bgm_fade(time) 17 | raise "not implemented" 18 | end 19 | 20 | # Starts BGS playback. Sets the file name, volume, and pitch in turn. 21 | # 22 | # Also automatically searches files included in RGSS-RTP. File extensions may be omitted. 23 | def Audio.bgs_play(filename, volume = 100, pitch = 100) 24 | raise "not implemented" 25 | end 26 | 27 | # Stops BGS playback. 28 | def Audio.bgs_stop 29 | raise "not implemented" 30 | end 31 | 32 | # Starts BGS fadeout. time is the length of the fadeout in milliseconds. 33 | def Audio.bgs_fade(time) 34 | raise "not implemented" 35 | end 36 | 37 | # Starts ME playback. Sets the file name, volume, and pitch in turn. 38 | # 39 | # Also automatically searches files included in RGSS-RTP. File extensions may be omitted. 40 | def Audio.me_play(filename, volume = 100, pitch = 100) 41 | raise "not implemented" 42 | end 43 | 44 | # Stops ME playback. 45 | def Audio.me_stop 46 | raise "not implemented" 47 | end 48 | 49 | # Starts ME fadeout. time is the length of the fadeout in milliseconds. 50 | def Audio.me_fade(time) 51 | raise "not implemented" 52 | end 53 | 54 | # Starts SE playback. Sets the file name, volume, and pitch in turn. 55 | # 56 | # Also automatically searches files included in RGSS-RTP. File extensions may be omitted. 57 | # 58 | # When attempting to play the same SE more than once in a very short period, they will automatically be filtered to prevent choppy playback. 59 | def Audio.se_play(filename, volume = 100, pitch = 100) 60 | raise "not implemented" 61 | end 62 | 63 | # Stops SE playback. 64 | def Audio.se_stop 65 | raise "not implemented" 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /lib/bitmap.rb: -------------------------------------------------------------------------------- 1 | # The bitmap class. Bitmaps are expressions of so-called graphics. 2 | # Sprites ({Sprite}) and other objects must be used to display bitmaps on the screen. 3 | class Bitmap 4 | 5 | # Gets the font used to draw a string with the {Bitmap#draw_text} method. 6 | # @return [Font] the font used to draw a string with the {Bitmap#draw_text} method. 7 | attr_accessor :font 8 | 9 | # Gets the bitmap width. 10 | attr_reader :width 11 | 12 | # Gets the bitmap height. 13 | attr_reader :height 14 | 15 | # Gets the bitmap rectangle. 16 | # @return [Rect] the bitmap rectangle. 17 | attr_reader :rect 18 | 19 | # A new instance of {Bitmap}. 20 | # @overload initialize(filename) 21 | # Loads the graphic file specified in filename and creates a bitmap object. 22 | # Also automatically searches files included in RGSS-RTP and encrypted archives. File extensions may be omitted. 23 | # @return [Bitmap] a bitmap of the graphic file specified in filename. 24 | # @overload initialize(width, height) 25 | # Creates a bitmap object with the specified size. 26 | # @return [Bitmap] a bitmap oject with the specified size. 27 | def intialize(*args) 28 | if args.size == 1 29 | load_file args[0] 30 | elsif args.size == 2 31 | @width = args[0] 32 | @height = args[1] 33 | end 34 | end 35 | 36 | # Frees the bitmap. If the bitmap has already been freed, does nothing. 37 | def dispose 38 | raise "not implemented" 39 | 40 | @disposed = true 41 | end 42 | 43 | # @return [true,false] _true_ if the bitmap has been freed. 44 | def disposed? 45 | @disposed 46 | end 47 | 48 | # Performs a block transfer from the src_bitmap box src_rect to the specified bitmap coordinates (x, y). 49 | # Opacity can be set from 0 to 255. 50 | # 51 | # @param [Number] x 52 | # @param [Number] y 53 | # @param [Bitmap] src_bitmap the bitmap to transfer. 54 | # @param [Rect] src_rect the box section of the src_rect to transfer. 55 | # @param [Number] opacity the opacity to use for the src_bitmap. Valid values: (0..255). 56 | def blt(x, y, src_bitmap, src_rect, opacity = 255) 57 | raise "not implemented" 58 | end 59 | 60 | # Performs a block transfer from the src_bitmap box src_rect to the specified bitmap box dest_rect (Rect). 61 | # opacity can be set from 0 to 255. 62 | # 63 | # @param [Rect] dest_rect 64 | # @param [Bitmap] src_bitmap 65 | # @param [Rect] src_rect 66 | # @param [Number] opacity 67 | def stretch_blt(dest_rect, src_bitmap, src_rect, opacity = 255) 68 | raise "not implemented" 69 | end 70 | 71 | # Fills the bitmap box (x, y, width, height) or rect (Rect) with color (Color). 72 | # @overload fill_rect(x, y, width, height, color) 73 | # @overload fill_rect(rect, color) 74 | def fill_rect(*args) 75 | raise "not implemented" 76 | end 77 | 78 | # Clears the entire bitmap. 79 | def clear 80 | raise "not implemented" 81 | end 82 | 83 | # Gets the {Color} at the specified pixel (x, y). 84 | def get_pixel(x, y) 85 | raise "not implemented" 86 | end 87 | 88 | # Sets the specified pixel (x, y) to the specified {Color}. 89 | def set_pixel(x, y, color) 90 | raise "not implemented" 91 | end 92 | 93 | # Changes the bitmap's hue within 360 degrees of displacement. 94 | # This process is time-consuming. Furthermore, due to conversion errors, repeated hue changes may result in color loss. 95 | def hue_change(hue) 96 | raise "not implemented" 97 | end 98 | 99 | # Draws a string str in the bitmap box (x, y, width, height) or rect (Rect). 100 | # 101 | # If the text length exceeds the box's width, the text width will automatically be reduced by up to 60 percent. 102 | # 103 | # Horizontal text is left-aligned by default; set align to 1 to center the text and to 2 to right-align it. Vertical text is always centered. 104 | # 105 | # As this process is time-consuming, redrawing the text with every frame is not recommended. 106 | # 107 | # @overload draw_text(x, y, width, height, str[, align]) 108 | # @overload draw_text(rect, str[, align]) 109 | def draw_text(*args) 110 | raise "not implemented" 111 | end 112 | 113 | # @return [Rect] the box used when drawing a string str with the draw_text method. 114 | # Does not include the angled portions of italicized text. 115 | def text_size(str) 116 | raise "not implemented" 117 | end 118 | 119 | private 120 | 121 | def load_file(file) 122 | raise "not implemented" 123 | end 124 | end 125 | -------------------------------------------------------------------------------- /lib/color.rb: -------------------------------------------------------------------------------- 1 | # The RGBA color class. Each component is handled with a floating point value. 2 | class Color 3 | attr_reader :red, :green ,:blue ,:alpha 4 | 5 | # The red value (0-255). Values out of range are automatically corrected. 6 | def red=(num) 7 | @red = constrain num, 0..255 8 | end 9 | 10 | # The green value (0-255). Values out of range are automatically corrected. 11 | def green=(num) 12 | @green = constrain num, 0..255 13 | end 14 | 15 | # The blue value (0-255). Values out of range are automatically corrected. 16 | def blue=(num) 17 | @blue = constrain num, 0..255 18 | end 19 | 20 | # The alpha value (0-255). Values out of range are automatically corrected. 21 | def alpha=(num) 22 | @alpha = constrain num, 0..255 23 | end 24 | 25 | # Creates a Color object. If alpha is omitted, it is assumed at 255. 26 | def initialize(red, green, blue, alpha=255) 27 | set red, green, blue, alpha 28 | end 29 | 30 | # Sets all components at once. 31 | def set(red, green, blue, alpha=255) 32 | self.red = red 33 | self.green = green 34 | self.blue = blue 35 | self.alpha = alpha 36 | end 37 | 38 | private 39 | 40 | def constrain(val, range) 41 | if val >= range.min && val <= range.max 42 | val 43 | elsif val < range.min 44 | range.min 45 | elsif val > range.max 46 | range.max 47 | end 48 | end 49 | 50 | end 51 | -------------------------------------------------------------------------------- /lib/font.rb: -------------------------------------------------------------------------------- 1 | require 'color' 2 | 3 | # TODO: Need to support an array of font names 4 | # ... should Font#name return the first available font, 5 | # or should it return the array? 6 | class Font 7 | attr_accessor :name, :size, :bold, :italic, :color 8 | 9 | # Creates a Font object. 10 | def initialize(name=nil, size=nil) 11 | @name = name || Font.default_name 12 | @size = size || Font.default_size 13 | @bold = Font.default_bold 14 | @italic = Font.default_italic 15 | @color = Font.default_color 16 | end 17 | 18 | # Returns TRUE when the specified font exists within the system. 19 | def self.exist?(name) 20 | raise "not implemented" 21 | end 22 | 23 | # Defaults 24 | @default_name = "MS PGothic" 25 | @default_size = 22 26 | @default_bold = false 27 | @default_italic = false 28 | @default_color = Color.new(255,255,255,255) 29 | 30 | class << self 31 | attr_accessor :default_name, :default_size, :default_bold, :default_italic, :default_color 32 | end 33 | end -------------------------------------------------------------------------------- /lib/graphics.rb: -------------------------------------------------------------------------------- 1 | module Graphics 2 | class << self 3 | # In [Smooth Mode], the number of times the screen is refreshed per second. 4 | # The larger the value, the more CPU power is required. Normally set at 40. 5 | # When not in [Smooth Mode], the refresh rate is halved, 6 | # and graphics are drawn in every other frame. 7 | # 8 | # Changing this property is not recommended; however, it can be set 9 | # anywhere from 10 to 120. Values out of range are automatically corrected. 10 | attr_accessor :frame_rate 11 | 12 | # The screen's refresh rate count. Set this property to 0 at game start 13 | # and the game play time (in seconds) can be calculated 14 | # by dividing this value by the frame_rate property value. 15 | attr_accessor :frame_count 16 | end 17 | 18 | # Refreshes the game screen and advances time by 1 frame. This method must 19 | # be called at set intervals. 20 | # 21 | # If this method is not called in 10 seconds or more, the program will view 22 | # the script as having run out of control and will force a quit. 23 | def self.update() 24 | raise "not implemented" 25 | end 26 | 27 | # Fixes the current screen in preparation for transitions. 28 | # 29 | #Screen rewrites are prohibited until the transition method is called. 30 | def self.freeze() 31 | raise "not implemented" 32 | end 33 | 34 | # Carries out a transition from the screen fixed in Graphics.freeze to the 35 | # current screen. 36 | # 37 | # duration is the number of frames the transition will last. 38 | # When omitted, this value is set to 8. 39 | # 40 | # filename specifies the transition graphic file name. When not specified, 41 | # a standard fade will be used. Also automatically searches files included in 42 | # RGSS-RTP and encrypted archives. File extensions may be omitted. 43 | # 44 | # vague sets the ambiguity of the borderline between the graphic's starting 45 | # and ending points. The larger the value, the greater the ambiguity. 46 | # When omitted, this value is set to 40. 47 | def self.transition(duration = 8, filename = nil, vague = 40) 48 | raise "not implemented" 49 | end 50 | 51 | # Resets the screen refresh timing. After a time-consuming process, 52 | # call this method to prevent extreme frame skips. 53 | def self.frame_reset() 54 | raise "not implemented" 55 | end 56 | end -------------------------------------------------------------------------------- /lib/input.rb: -------------------------------------------------------------------------------- 1 | # A module that handles input data from a gamepad or keyboard. 2 | module Input 3 | # Updates input data. As a rule, this method is called once per frame. 4 | def self.update() 5 | raise "not implemented" 6 | end 7 | 8 | # Determines whether the button num is currently being pressed. 9 | # 10 | # If the button is being pressed, returns TRUE. If not, returns FALSE. 11 | # 12 | # @example Example 13 | # if Input.press?(Input::C) 14 | # do_something 15 | # end 16 | def self.press?(num) 17 | raise "not implemented" 18 | end 19 | 20 | # Determines whether the button num is being pressed again. 21 | # 22 | # "Pressed again" is seen as time having passed between the button being 23 | # not pressed and being pressed. 24 | # 25 | # If the button is being pressed, returns TRUE. If not, returns FALSE. 26 | def self.trigger?(num) 27 | raise "not implemented" 28 | end 29 | 30 | # Determines whether the button num is being pressed again. 31 | # 32 | # Unlike trigger?, takes into account the repeat input of a button 33 | # being held down continuously. 34 | # 35 | # If the button is being pressed, returns TRUE. If not, returns FALSE. 36 | def self.repeat?(num) 37 | raise "not implemented" 38 | end 39 | 40 | # Checks the status of the directional buttons, translates the data 41 | # into a specialized 4-direction input format, and returns the number 42 | # pad equivalent (2, 4, 6, 8). 43 | # 44 | # If no directional buttons are being pressed (or the equivalent), returns 0. 45 | def self.dir4() 46 | raise "not implemented" 47 | end 48 | 49 | # Checks the status of the directional buttons, translates the data into 50 | # a specialized 8-direction input format, and returns the 51 | # number pad equivalent (1, 2, 3, 4, 6, 7, 8, 9). 52 | # 53 | # If no directional buttons are being pressed (or the equivalent), returns 0. 54 | def self.dir8() 55 | raise "not implemented" 56 | end 57 | 58 | DOWN = 2 59 | LEFT = 4 60 | RIGHT = 6 61 | UP = 8 62 | 63 | A = 11 64 | B = 12 65 | C = 13 66 | X = 14 67 | Y = 15 68 | Z = 16 69 | L = 17 70 | R = 18 71 | 72 | SHIFT = 21 73 | CTRL = 22 74 | ALT = 23 75 | 76 | F5 = 25 77 | F6 = 26 78 | F7 = 27 79 | F8 = 28 80 | F9 = 29 81 | end -------------------------------------------------------------------------------- /lib/plane.rb: -------------------------------------------------------------------------------- 1 | # The Plane class. Planes are special sprites that tile bitmap patterns across 2 | # the entire screen, and are used to display panoramas and fog. 3 | class Plane 4 | # Refers to the {Bitmap} used in the plane. 5 | attr_accessor :bitmap 6 | 7 | # Whether the plane can be seen. If TRUE, the plane is visible. 8 | attr_accessor :visible 9 | 10 | # The plane's Z-coordinate. The larger this value, the closer to the player the plane will be displayed. If multiple objects share the same Z-coordinate, the more recently created object will be displayed closest to the player. 11 | attr_accessor :z 12 | 13 | # The X-coordinate of the plane's starting point. Change this value to scroll the plane. 14 | attr_accessor :ox 15 | 16 | # The Y-coordinate of the plane's starting point. Change this value to scroll the plane. 17 | attr_accessor :oy 18 | 19 | # The plane's X-axis zoom level. 1.0 denotes actual pixel size. 20 | attr_accessor :zoom_x 21 | 22 | # The plane's Y-axis zoom level. 1.0 denotes actual pixel size. 23 | attr_accessor :zoom_y 24 | 25 | # The plane's opacity (0-255). Values out of range are automatically corrected. 26 | attr_accessor :opacity 27 | 28 | # The plane's blending mode (0: normal, 1: addition, 2: subtraction). 29 | attr_accessor :blend_type 30 | 31 | # The {Color} to be blended with the plane. Alpha values are used in the blending ratio. 32 | attr_accessor :color 33 | 34 | # The plane's color {Tone}. 35 | attr_accessor :tone 36 | 37 | # Retrieves the {Viewport} specified when the plane was created. 38 | attr_reader :viewport 39 | 40 | # Creates a Plane object. Specifies a Viewport (Viewport) when necessary. 41 | def initialize(viewport = nil) 42 | raise "not implemented" 43 | 44 | @viewport = viewport 45 | end 46 | 47 | # Frees the plane. If the plane has already been freed, does nothing. 48 | def dispose 49 | raise "not implemented" 50 | 51 | @disposed = true 52 | end 53 | 54 | # Returns TRUE if the plane has been freed. 55 | def disposed? 56 | @disposed 57 | end 58 | 59 | end -------------------------------------------------------------------------------- /lib/rect.rb: -------------------------------------------------------------------------------- 1 | # The rectangle class. 2 | class Rect 3 | # The X-coordinate of the rectangle's upper left corner. 4 | attr_accessor :x 5 | 6 | # The Y-coordinate of the rectange's upper left corner. 7 | attr_accessor :y 8 | 9 | # The rectangle's width. 10 | attr_accessor :width 11 | 12 | # The rectangle's height. 13 | attr_accessor :height 14 | 15 | def initialize(x, y, width, height) 16 | set x, y, width, height 17 | end 18 | 19 | # Sets all parameters at once. 20 | def set(x, y, width, height) 21 | @x = x 22 | @y = y 23 | @width = width 24 | @height = height 25 | end 26 | end -------------------------------------------------------------------------------- /lib/rgss_error.rb: -------------------------------------------------------------------------------- 1 | # Exception class providing notifications of RGSS internal errors. 2 | # 3 | # Generated when, for instance, trying to access {Bitmap} or {Sprite} 4 | # class objects that have already been freed. 5 | class RGSSError < StandardError 6 | end -------------------------------------------------------------------------------- /lib/rpg.rb: -------------------------------------------------------------------------------- 1 | dir = File.dirname(__FILE__) 2 | Dir[File.join(dir, "rpg", "*.rb")].each {|lib| require lib} -------------------------------------------------------------------------------- /lib/rpg/actor.rb: -------------------------------------------------------------------------------- 1 | require 'table' 2 | 3 | module RPG 4 | class Actor 5 | def initialize 6 | @id = 0 7 | @name = "" 8 | @class_id = 1 9 | @initial_level = 1 10 | @final_level = 99 11 | @exp_basis = 30 12 | @exp_inflation = 30 13 | @character_name = "" 14 | @character_hue = 0 15 | @battler_name = "" 16 | @battler_hue = 0 17 | @parameters = Table.new(6,100) 18 | for i in 1..99 19 | @parameters[0,i] = 500+i*50 20 | @parameters[1,i] = 500+i*50 21 | @parameters[2,i] = 50+i*5 22 | @parameters[3,i] = 50+i*5 23 | @parameters[4,i] = 50+i*5 24 | @parameters[5,i] = 50+i*5 25 | end 26 | @weapon_id = 0 27 | @armor1_id = 0 28 | @armor2_id = 0 29 | @armor3_id = 0 30 | @armor4_id = 0 31 | @weapon_fix = false 32 | @armor1_fix = false 33 | @armor2_fix = false 34 | @armor3_fix = false 35 | @armor4_fix = false 36 | end 37 | 38 | # The actor ID. 39 | attr_accessor :id 40 | 41 | # The actor name. 42 | attr_accessor :name 43 | 44 | # The actor class ID. 45 | attr_accessor :class_id 46 | 47 | # The actor's initial level. 48 | attr_accessor :initial_level 49 | 50 | # The actor's final level. 51 | attr_accessor :final_level 52 | 53 | # The value on which the experience curve is based (10..50). 54 | attr_accessor :exp_basis 55 | 56 | # The amount of experience curve inflation (10..50). 57 | attr_accessor :exp_inflation 58 | 59 | # The actor's character graphic file name. 60 | attr_accessor :character_name 61 | 62 | # The adjustment value for the character graphic's hue (0..360). 63 | attr_accessor :character_hue 64 | 65 | # The actor's battler graphic file name. 66 | attr_accessor :battler_name 67 | 68 | # The adjustment value for the battler graphic's hue (0..360). 69 | attr_accessor :battler_hue 70 | 71 | # 2-dimensional {Table} containing base parameters for each level. 72 | # 73 | # Generally takes the form parameters[kind, level]. 74 | # 75 | # kind indicates the parameter type: 76 | # 0:: max HP 77 | # 1:: max SP 78 | # 2:: strength 79 | # 3:: dexterity 80 | # 4:: agility 81 | # 5:: intelligence). 82 | # @return [Table] 83 | attr_accessor :parameters 84 | 85 | # ID of the actor's initially equipped weapon. 86 | attr_accessor :weapon_id 87 | 88 | # ID of the actor's initially equipped shield. 89 | attr_accessor :armor1_id 90 | 91 | # ID of the actor's initially equipped helmet. 92 | attr_accessor :armor2_id 93 | 94 | # ID of the actor's initially equipped body armor. 95 | attr_accessor :armor3_id 96 | 97 | # ID of the actor's initially equipped accessory. 98 | attr_accessor :armor4_id 99 | 100 | # Flag making the actor's weapon unremovable. 101 | attr_accessor :weapon_fix 102 | 103 | # Flag making the actor's shield unremovable. 104 | attr_accessor :armor1_fix 105 | 106 | # Flag making the actor's helmet unremovable. 107 | attr_accessor :armor2_fix 108 | 109 | # Flag making the actor's body armor unremovable. 110 | attr_accessor :armor3_fix 111 | 112 | # Flag making the actor's accessory unremovable. 113 | attr_accessor :armor4_fix 114 | end 115 | end 116 | -------------------------------------------------------------------------------- /lib/rpg/animation.rb: -------------------------------------------------------------------------------- 1 | require 'rpg/audio_file' 2 | 3 | module RPG 4 | class Animation 5 | def initialize 6 | @id = 0 7 | @name = "" 8 | @animation_name = "" 9 | @animation_hue = 0 10 | @position = 1 11 | @frame_max = 1 12 | @frames = [RPG::Animation::Frame.new] 13 | @timings = [] 14 | end 15 | 16 | # The animation ID. 17 | attr_accessor :id 18 | 19 | # The animation name. 20 | attr_accessor :name 21 | 22 | # The animation's graphic file name. 23 | attr_accessor :animation_name 24 | 25 | # The adjustment value for the animation graphic's hue (0..360). 26 | attr_accessor :animation_hue 27 | 28 | # The animation's position: 29 | # 0:: top 30 | # 1:: middle 31 | # 2:: bottom 32 | # 3:: screen 33 | attr_accessor :position 34 | 35 | # Number of frames. 36 | attr_accessor :frame_max 37 | 38 | # Frame contents. An RPG::Animation::Frame array. 39 | # @return [Array] 40 | attr_accessor :frames 41 | 42 | # Timing for SE and flash effects. An {RPG::Animation::Timing} array. 43 | # @return [Array] 44 | attr_accessor :timings 45 | 46 | # Data class for animation frames. 47 | class Frame 48 | def initialize 49 | @cell_max = 0 50 | @cell_data = Table.new(0, 0) 51 | end 52 | 53 | # Number of cells. Equivalent to the largest cell number in the frame set. 54 | attr_accessor :cell_max 55 | 56 | # 2-dimensional array containing cell contents (Table). 57 | # 58 | # Generally takes the form cell_data[cell_index, data_index]. 59 | # 60 | # data_index ranges from 0 to 7 and denotes various 61 | # information about a cell: 62 | # 0:: pattern 63 | # 1:: X-coordinate 64 | # 2:: Y-coordinate 65 | # 3:: zoom level 66 | # 4:: angle of rotation 67 | # 5:: horizontal flip 68 | # 6:: opacity 69 | # 7:: blending mode 70 | # 71 | # Patterns are 1 less than the number displayed in RPGXP; 72 | # -1 indicates that that cell is not in use. 73 | attr_accessor :cell_data 74 | end 75 | 76 | # Data class for the timing of an animation's SE and flash effects. 77 | class Timing 78 | def initialize 79 | @frame = 0 80 | @se = RPG::AudioFile.new("", 80) 81 | @flash_scope = 0 82 | @flash_color = Color.new(255,255,255,255) 83 | @flash_duration = 5 84 | @condition = 0 85 | end 86 | 87 | # Frame number. 1 less than the number displayed in RPGXP. 88 | attr_accessor :frame 89 | 90 | # SE, or sound effect (RPG::AudioFile). 91 | attr_accessor :se 92 | 93 | # Flash area: 94 | # 0:: none 95 | # 1:: target 96 | # 2:: screen 97 | # 3:: delete target 98 | attr_accessor :flash_scope 99 | 100 | # Flash {Color}. 101 | attr_accessor :flash_color 102 | 103 | # Flash duration. 104 | attr_accessor :flash_duration 105 | 106 | # Condition of the effect: 107 | # 0:: none 108 | # 1:: hit 109 | # 2:: miss 110 | attr_accessor :condition 111 | end 112 | end 113 | end -------------------------------------------------------------------------------- /lib/rpg/armor.rb: -------------------------------------------------------------------------------- 1 | module RPG 2 | class Armor 3 | def initialize 4 | @id = 0 5 | @name = "" 6 | @icon_name = "" 7 | @description = "" 8 | @kind = 0 9 | @auto_state_id = 0 10 | @price = 0 11 | @pdef = 0 12 | @mdef = 0 13 | @eva = 0 14 | @str_plus = 0 15 | @dex_plus = 0 16 | @agi_plus = 0 17 | @int_plus = 0 18 | @guard_element_set = [] 19 | @guard_state_set = [] 20 | end 21 | 22 | # The armor ID. 23 | attr_accessor :id 24 | 25 | # The armor name. 26 | attr_accessor :name 27 | 28 | # The armor's icon graphic file name. 29 | attr_accessor :icon_name 30 | 31 | # The armor description. 32 | attr_accessor :description 33 | 34 | # Type of armor: 35 | # 0:: shield 36 | # 1:: helmet 37 | # 2:: body armor 38 | # 3:: accessory 39 | attr_accessor :kind 40 | 41 | # The auto state ID. 42 | attr_accessor :auto_state_id 43 | 44 | # The armor's price. 45 | attr_accessor :price 46 | 47 | # The armor's physical defense rating. 48 | attr_accessor :pdef 49 | 50 | # The armor's magic defense rating. 51 | attr_accessor :mdef 52 | 53 | # The armor's evasion correction. 54 | attr_accessor :eva 55 | 56 | # The armor's strength bonus. 57 | attr_accessor :str_plus 58 | 59 | # The armor's dexterity bonus. 60 | attr_accessor :dex_plus 61 | 62 | # The armor's agility bonus. 63 | attr_accessor :agi_plus 64 | 65 | # The armor's intelligence bonus. 66 | attr_accessor :int_plus 67 | 68 | # The armor's elemental defense rating. An elemental ID array. 69 | attr_accessor :guard_element_set 70 | 71 | # The armor's state defense rating. A state ID array. 72 | attr_accessor :guard_state_set 73 | end 74 | end -------------------------------------------------------------------------------- /lib/rpg/audio_file.rb: -------------------------------------------------------------------------------- 1 | module RPG 2 | class AudioFile 3 | # The sound file name. 4 | attr_accessor :name 5 | 6 | # The sound's volume (0..100). 7 | # The default values are 100 for BGM and ME and 80 for BGS and SE. 8 | attr_accessor :volume 9 | 10 | # The sound's pitch (50..150). The default value is 100. 11 | attr_accessor :pitch 12 | 13 | def initialize(name = "", volume = 100, pitch = 100) 14 | @name = name 15 | @volume = volume 16 | @pitch = pitch 17 | end 18 | end 19 | end -------------------------------------------------------------------------------- /lib/rpg/class.rb: -------------------------------------------------------------------------------- 1 | require 'table' 2 | 3 | # Data class for class. 4 | module RPG 5 | class Class 6 | # The class's ID. 7 | attr_accessor :id 8 | 9 | # The class name. 10 | attr_accessor :name 11 | 12 | # The class position: 13 | # 0:: front 14 | # 1:: middle 15 | # 2:: rear 16 | attr_accessor :position 17 | 18 | # Array containing IDs for equippable weapons. 19 | attr_accessor :weapon_set 20 | 21 | # Array containing IDs for equippable armor. 22 | attr_accessor :armor_set 23 | 24 | # Level of elemental effectiveness. 25 | # 1-dimensional {Table} using element IDs as subscripts, with 6 levels: 26 | # 0:: A 27 | # 1:: B 28 | # 2:: C 29 | # 3:: D 30 | # 4:: E 31 | # 5:: F 32 | attr_accessor :element_ranks 33 | 34 | # Level of status effectiveness. 35 | # 1-dimensional {Table} using status IDs as subscripts, with 6 levels: 36 | # 0:: A 37 | # 1:: B 38 | # 2:: C 39 | # 3:: D 40 | # 4:: E 41 | # 5:: F 42 | attr_accessor :state_ranks 43 | 44 | # Skills to Learn. An {RPG::Class::Learning} array. 45 | # @return [Array] 46 | attr_accessor :learnings 47 | 48 | def initialize 49 | @id = 0 50 | @name = "" 51 | @position = 0 52 | @weapon_set = [] 53 | @armor_set = [] 54 | @element_ranks = Table.new(1) 55 | @state_ranks = Table.new(1) 56 | @learnings = [] 57 | end 58 | 59 | # Data class for a [Class's Learned] skills. 60 | class Learning 61 | # Skill level. 62 | attr_accessor :level 63 | 64 | # The learned skill's ID. 65 | attr_accessor :skill_id 66 | 67 | def initialize 68 | @level = 1 69 | @skill_id = 1 70 | end 71 | end 72 | end 73 | end -------------------------------------------------------------------------------- /lib/rpg/common_event.rb: -------------------------------------------------------------------------------- 1 | require 'rpg/event_command' 2 | 3 | # Data class for common events. 4 | module RPG 5 | class CommonEvent 6 | def initialize 7 | @id = 0 8 | @name = "" 9 | @trigger = 0 10 | @switch_id = 1 11 | @list = [RPG::EventCommand.new] 12 | end 13 | 14 | # The event ID. 15 | attr_accessor :id 16 | 17 | # The event name. 18 | attr_accessor :name 19 | 20 | # The event trigger: 21 | # 0:: none 22 | # 1:: autorun 23 | # 2:: parallel 24 | attr_accessor :trigger 25 | 26 | # The condition switch ID. 27 | attr_accessor :switch_id 28 | 29 | # List of event commands. An {RPG::EventCommand} array. 30 | # @return [Array] 31 | attr_accessor :list 32 | end 33 | end -------------------------------------------------------------------------------- /lib/rpg/enemy.rb: -------------------------------------------------------------------------------- 1 | require 'table' 2 | 3 | module RPG 4 | class Enemy 5 | def initialize 6 | @id = 0 7 | @name = "" 8 | @battler_name = "" 9 | @battler_hue = 0 10 | @maxhp = 500 11 | @maxsp = 500 12 | @str = 50 13 | @dex = 50 14 | @agi = 50 15 | @int = 50 16 | @atk = 100 17 | @pdef = 100 18 | @mdef = 100 19 | @eva = 0 20 | @animation1_id = 0 21 | @animation2_id = 0 22 | @element_ranks = Table.new(1) 23 | @state_ranks = Table.new(1) 24 | @actions = [RPG::Enemy::Action.new] 25 | @exp = 0 26 | @gold = 0 27 | @item_id = 0 28 | @weapon_id = 0 29 | @armor_id = 0 30 | @treasure_prob = 100 31 | end 32 | 33 | # The enemy ID. 34 | attr_accessor :id 35 | 36 | # The enemy name. 37 | attr_accessor :name 38 | 39 | # The enemy's battler graphic file name. 40 | attr_accessor :battler_name 41 | 42 | # The adjustment value for the battler graphic's hue (0..360). 43 | attr_accessor :battler_hue 44 | 45 | # The enemy's max HP. 46 | attr_accessor :maxhp 47 | 48 | # The enemy's max SP. 49 | attr_accessor :maxsp 50 | 51 | # The enemy's strength. 52 | attr_accessor :str 53 | 54 | # The enemy's dexterity. 55 | attr_accessor :dex 56 | 57 | # The enemy's agility. 58 | attr_accessor :agi 59 | 60 | # The enemy's intelligence. 61 | attr_accessor :int 62 | 63 | # The enemy's attack power. 64 | attr_accessor :atk 65 | 66 | # The enemy's physical defense rating. 67 | attr_accessor :pdef 68 | 69 | # The enemy's magic defense rating. 70 | attr_accessor :mdef 71 | 72 | # The enemy's evasion rating. 73 | attr_accessor :eva 74 | 75 | # The battle animation ID. 76 | attr_accessor :animation1_id 77 | 78 | # The target animation ID. 79 | attr_accessor :animation2_id 80 | 81 | # Level of elemental effectiveness. 82 | # 1-dimensional {Table} using element IDs as subscripts, with 6 levels: 83 | # 0:: A 84 | # 1:: B 85 | # 2:: C 86 | # 3:: D 87 | # 4:: E 88 | # 5:: F 89 | attr_accessor :element_ranks 90 | 91 | # Level of status effectiveness. 92 | # 1-dimensional {Table} using status IDs as subscripts, with 6 levels: 93 | # 0:: A 94 | # 1:: B 95 | # 2:: C 96 | # 3:: D 97 | # 4:: E 98 | # 5:: F 99 | attr_accessor :state_ranks 100 | 101 | # The enemy's actions. An {RPG::Enemy::Action} array. 102 | # @return [Array] 103 | attr_accessor :actions 104 | 105 | # The enemy's experience. 106 | attr_accessor :exp 107 | 108 | # The enemy's gold. 109 | attr_accessor :gold 110 | 111 | # The ID of the item used as treasure. 112 | attr_accessor :item_id 113 | 114 | # The ID of the weapon used as treasure. 115 | attr_accessor :weapon_id 116 | 117 | # The ID of the armor used as treasure. 118 | attr_accessor :armor_id 119 | 120 | # The probability of treasure being left behind. 121 | attr_accessor :treasure_prob 122 | 123 | class Action 124 | def initialize 125 | @kind = 0 126 | @basic = 0 127 | @skill_id = 1 128 | @condition_turn_a = 0 129 | @condition_turn_b = 1 130 | @condition_hp = 100 131 | @condition_level = 1 132 | @condition_switch_id = 0 133 | @rating = 5 134 | end 135 | 136 | # Type of action: 137 | # 0:: basic 138 | # 1:: skill 139 | attr_accessor :kind 140 | 141 | # When set to a [Basic] action, defines it further: 142 | # 0:: attack 143 | # 1:: defend 144 | # 2:: escape 145 | # 3:: do nothing 146 | attr_accessor :basic 147 | 148 | # When set to a [Skill], the ID of that skill. 149 | attr_accessor :skill_id 150 | 151 | # a value specified in the [Turn] condition. 152 | # To be input in the form a + bx. 153 | # 154 | # When the turn is not specified as a condition, a = 0 and b = 1. 155 | attr_accessor :condition_turn_a 156 | 157 | # b value specified in the [Turn] condition. 158 | # To be input in the form a + bx. 159 | # 160 | # When the turn is not specified as a condition, a = 0 and b = 1. 161 | attr_accessor :condition_turn_b 162 | 163 | # Percentage specified in the [HP] condition. 164 | # 165 | # When HP is not specified as a condition, this value is set to 100. 166 | attr_accessor :condition_hp 167 | 168 | # Standard level specified in the [Level] condition. 169 | # 170 | # When the level is not specified as a condition, this value is set to 1. 171 | attr_accessor :condition_level 172 | 173 | # Switch ID specified in the [Switch] condition. 174 | # 175 | # When the switch ID is not specified as a condition, 176 | # this value is set to 0. Consequently, it is essential to check whether 177 | # this value is 0. 178 | attr_accessor :condition_switch_id 179 | 180 | # The action's rating (1..10). 181 | attr_accessor :rating 182 | end 183 | end 184 | end 185 | -------------------------------------------------------------------------------- /lib/rpg/event_command.rb: -------------------------------------------------------------------------------- 1 | module RPG 2 | # Data class for the Event command. 3 | class EventCommand 4 | def initialize(code = 0, indent = 0, parameters = []) 5 | @code = code 6 | @indent = indent 7 | @parameters = parameters 8 | end 9 | 10 | # The event code. 11 | attr_accessor :code 12 | 13 | # The event code. 14 | attr_accessor :indent 15 | 16 | # Array containing the Move command arguments. 17 | # The contents vary for each command. 18 | attr_accessor :parameters 19 | end 20 | end -------------------------------------------------------------------------------- /lib/rpg/item.rb: -------------------------------------------------------------------------------- 1 | require 'rpg/audio_file' 2 | 3 | module RPG 4 | class Item 5 | def initialize 6 | @id = 0 7 | @name = "" 8 | @icon_name = "" 9 | @description = "" 10 | @scope = 0 11 | @occasion = 0 12 | @animation1_id = 0 13 | @animation2_id = 0 14 | @menu_se = RPG::AudioFile.new("", 80) 15 | @common_event_id = 0 16 | @price = 0 17 | @consumable = true 18 | @parameter_type = 0 19 | @parameter_points = 0 20 | @recover_hp_rate = 0 21 | @recover_hp = 0 22 | @recover_sp_rate = 0 23 | @recover_sp = 0 24 | @hit = 100 25 | @pdef_f = 0 26 | @mdef_f = 0 27 | @variance = 0 28 | @element_set = [] 29 | @plus_state_set = [] 30 | @minus_state_set = [] 31 | end 32 | 33 | # The item ID. 34 | attr_accessor :id 35 | 36 | # The item name. 37 | attr_accessor :name 38 | 39 | # The item's icon graphic file name. 40 | attr_accessor :icon_name 41 | 42 | # The item description. 43 | attr_accessor :description 44 | 45 | # Scope of the item's effects: 46 | # 0:: none 47 | # 1:: one enemy 48 | # 2:: all enemies 49 | # 3:: one ally 50 | # 4:: all allies 51 | # 5:: 1 ally--HP 0 52 | # 6:: all allies--HP 0 53 | # 7:: the user 54 | attr_accessor :scope 55 | 56 | # When the item may be used 57 | # 0:: always 58 | # 1:: only in battle 59 | # 2:: only from the menu 60 | # 3:: never 61 | attr_accessor :occasion 62 | 63 | # The animation ID when using the item. 64 | attr_accessor :animation1_id 65 | 66 | # The animation ID when on the receiving end of the item. 67 | attr_accessor :animation2_id 68 | 69 | # SE played when item is used on the menu screen (RPG::AudioFile). 70 | attr_accessor :menu_se 71 | 72 | # The Common Event ID. 73 | attr_accessor :common_event_id 74 | 75 | # The item price. 76 | attr_accessor :price 77 | 78 | # Truth value of whether the item disappears when used. 79 | attr_accessor :consumable 80 | 81 | # Parameter affected 82 | # 0:: none 83 | # 1:: max HP 84 | # 2:: max SP 85 | # 3:: strength 86 | # 4:: dexterity 87 | # 5:: agility 88 | # 6:: intelligence 89 | attr_accessor :parameter_type 90 | 91 | # Amount by which parameter increases. 92 | attr_accessor :parameter_points 93 | 94 | # HP recovery rate. 95 | attr_accessor :recover_hp_rate 96 | 97 | # HP recovery amount. 98 | attr_accessor :recover_hp 99 | 100 | # SP recovery rate. 101 | attr_accessor :recover_sp_rate 102 | 103 | # SP recovery amount. 104 | attr_accessor :recover_sp 105 | 106 | # The item's hit probability. 107 | attr_accessor :hit 108 | 109 | # The item's physical defense F rating. 110 | attr_accessor :pdef_f 111 | 112 | # The item's magic defense F rating. 113 | attr_accessor :mdef_f 114 | 115 | # The item's degree of variance. 116 | attr_accessor :variance 117 | 118 | # The item's element. An Elemental ID array. 119 | attr_accessor :element_set 120 | 121 | # States to add. A State ID array. 122 | attr_accessor :plus_state_set 123 | 124 | # States to cancel. A Stae ID array. 125 | attr_accessor :minus_state_set 126 | end 127 | end 128 | -------------------------------------------------------------------------------- /lib/rpg/map.rb: -------------------------------------------------------------------------------- 1 | require 'rpg/audio_file' 2 | 3 | module RPG 4 | class Map 5 | def initialize(width, height) 6 | @tileset_id = 1 7 | @width = width 8 | @height = height 9 | @autoplay_bgm = false 10 | @bgm = RPG::AudioFile.new 11 | @autoplay_bgs = false 12 | @bgs = RPG::AudioFile.new("", 80) 13 | @encounter_list = [] 14 | @encounter_step = 30 15 | @data = Table.new(width, height, 3) 16 | @events = {} 17 | end 18 | 19 | # Tileset ID to be used in the map. 20 | attr_accessor :tileset_id 21 | 22 | # The map width. 23 | attr_accessor :width 24 | 25 | # The map height. 26 | attr_accessor :height 27 | 28 | # Truth-value of whether BGM autoswitching is enabled. 29 | attr_accessor :autoplay_bgm 30 | 31 | # If BGM autoswitching is enabled, the name of that BGM ({RPG::AudioFile}). 32 | attr_accessor :bgm 33 | 34 | # Truth-value of whether BGS autoswitching is enabled. 35 | attr_accessor :autoplay_bgs 36 | 37 | # If BGS autoswitching is enabled, the name of that BGS ({RPG::AudioFile}). 38 | attr_accessor :bgs 39 | 40 | # Encounter list. A troop ID array. 41 | attr_accessor :encounter_list 42 | 43 | # Number of steps between encounters. 44 | attr_accessor :encounter_step 45 | 46 | # The map data. A 3-dimensional tile ID {Table}. 47 | attr_accessor :data 48 | 49 | # Map events. A hash that represents {RPG::Event} instances as values, 50 | # using event IDs as the keys. 51 | attr_accessor :events 52 | end 53 | end -------------------------------------------------------------------------------- /lib/rpg/map_info.rb: -------------------------------------------------------------------------------- 1 | module RPG 2 | class MapInfo 3 | def initialize 4 | @name = "" 5 | @parent_id = 0 6 | @order = 0 7 | @expanded = false 8 | @scroll_x = 0 9 | @scroll_y = 0 10 | end 11 | 12 | # The map name. 13 | attr_accessor :name 14 | 15 | # The parent map ID. 16 | attr_accessor :parent_id 17 | 18 | # The map tree display order, used internally. 19 | attr_accessor :order 20 | 21 | # The map tree expansion flag, used internally. 22 | attr_accessor :expanded 23 | 24 | # The X-axis scroll position, used internally. 25 | attr_accessor :scroll_x 26 | 27 | # The Y-axis scroll position, used internally. 28 | attr_accessor :scroll_y 29 | end 30 | end -------------------------------------------------------------------------------- /lib/rpg/move_command.rb: -------------------------------------------------------------------------------- 1 | module RPG 2 | # Data class for the Move command. 3 | class MoveCommand 4 | # Move command code. 5 | attr_accessor :code 6 | 7 | # Array containing the Move command arguments. 8 | # The contents vary for each command. 9 | attr_accessor :parameters 10 | 11 | def initialize(code = 0, parameters = []) 12 | @code = code 13 | @parameters = parameters 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /lib/rpg/move_route.rb: -------------------------------------------------------------------------------- 1 | require 'rpg/move_command' 2 | 3 | module RPG 4 | # Data class for the move route (movement route). 5 | class MoveRoute 6 | def initialize 7 | @repeat = true 8 | @skippable = false 9 | @list = [RPG::MoveCommand.new] 10 | end 11 | 12 | # Truth value of the [Repeat Action] option. 13 | attr_accessor :repeat 14 | 15 | # Truth value of the [Ignore if Can't Move] option. 16 | attr_accessor :skippable 17 | 18 | # Program contents. An {RPG::MoveCommand} array. 19 | # @return [Array] 20 | attr_accessor :list 21 | end 22 | end -------------------------------------------------------------------------------- /lib/rpg/skill.rb: -------------------------------------------------------------------------------- 1 | require 'rpg/audio_file' 2 | 3 | module RPG 4 | # Data class for skills. 5 | class Skill 6 | def initialize 7 | @id = 0 8 | @name = "" 9 | @icon_name = "" 10 | @description = "" 11 | @scope = 0 12 | @occasion = 1 13 | @animation1_id = 0 14 | @animation2_id = 0 15 | @menu_se = RPG::AudioFile.new("", 80) 16 | @common_event_id = 0 17 | @sp_cost = 0 18 | @power = 0 19 | @atk_f = 0 20 | @eva_f = 0 21 | @str_f = 0 22 | @dex_f = 0 23 | @agi_f = 0 24 | @int_f = 100 25 | @hit = 100 26 | @pdef_f = 0 27 | @mdef_f = 100 28 | @variance = 15 29 | @element_set = [] 30 | @plus_state_set = [] 31 | @minus_state_set = [] 32 | end 33 | 34 | # The skill ID. 35 | attr_accessor :id 36 | 37 | # The skill name. 38 | attr_accessor :name 39 | 40 | # The skill's icon graphic file name. 41 | attr_accessor :icon_name 42 | 43 | # The skill description. 44 | attr_accessor :description 45 | 46 | # Scope of the skill's effects: 47 | # 0:: none 48 | # 1:: one enemy 49 | # 2:: all enemies 50 | # 3:: one ally 51 | # 4:: all allies 52 | # 5:: 1 ally--HP 0 53 | # 6:: all allies--HP 0 54 | # 7:: the user 55 | attr_accessor :scope 56 | 57 | # When the skill may be used: 58 | # 0:: always 59 | # 1:: only in battle 60 | # 2:: only from the menu 61 | # 3:: never 62 | attr_accessor :occasion 63 | 64 | # The animation ID when using the skill. 65 | attr_accessor :animation1_id 66 | 67 | # The animation ID when on the receiving end of the skill. 68 | attr_accessor :animation2_id 69 | 70 | # SE played when skill is used on the menu screen {RPG::AudioFile}. 71 | attr_accessor :menu_se 72 | 73 | # The Common Event ID. 74 | attr_accessor :common_event_id 75 | 76 | # Number of SP consumed. 77 | attr_accessor :sp_cost 78 | 79 | # The skill's power. 80 | attr_accessor :power 81 | 82 | # The skill's attack power F rating. 83 | attr_accessor :atk_f 84 | 85 | # The skill's evasion F rating. 86 | attr_accessor :eva_f 87 | 88 | # The skill's strength F rating. 89 | attr_accessor :str_f 90 | 91 | # The skill's dexterity F rating. 92 | attr_accessor :dex_f 93 | 94 | # The skill's agility F rating. 95 | attr_accessor :agi_f 96 | 97 | # The skill's intelligence F rating. 98 | attr_accessor :int_f 99 | 100 | # The skill's hit probability. 101 | attr_accessor :hit 102 | 103 | # The skill's physical defense F rating. 104 | attr_accessor :pdef_f 105 | 106 | # The skill's magic defense F rating. 107 | attr_accessor :mdef_f 108 | 109 | # The skill's degree of variance. 110 | attr_accessor :variance 111 | 112 | # The skill's element. An Elemental ID array. 113 | attr_accessor :element_set 114 | 115 | # States to add. A State ID array. 116 | attr_accessor :plus_state_set 117 | 118 | # States to cancel. A State ID array. 119 | attr_accessor :minus_state_set 120 | end 121 | end -------------------------------------------------------------------------------- /lib/rpg/state.rb: -------------------------------------------------------------------------------- 1 | module RPG 2 | # Data class for state. 3 | class State 4 | def initialize 5 | @id = 0 6 | @name = "" 7 | @animation_id = 0 8 | @restriction = 0 9 | @nonresistance = false 10 | @zero_hp = false 11 | @cant_get_exp = false 12 | @cant_evade = false 13 | @slip_damage = false 14 | @rating = 5 15 | @hit_rate = 100 16 | @maxhp_rate = 100 17 | @maxsp_rate = 100 18 | @str_rate = 100 19 | @dex_rate = 100 20 | @agi_rate = 100 21 | @int_rate = 100 22 | @atk_rate = 100 23 | @pdef_rate = 100 24 | @mdef_rate = 100 25 | @eva = 0 26 | @battle_only = true 27 | @hold_turn = 0 28 | @auto_release_prob = 0 29 | @shock_release_prob = 0 30 | @guard_element_set = [] 31 | @plus_state_set = [] 32 | @minus_state_set = [] 33 | end 34 | 35 | # State ID. 36 | attr_accessor :id 37 | 38 | # State name. 39 | attr_accessor :name 40 | 41 | # The state's animation ID. 42 | attr_accessor :animation_id 43 | 44 | # Sets restrictions: 45 | # 0:: none 46 | # 1:: can't use magic 47 | # 2:: always attack enemies 48 | # 3:: always attack allies 49 | # 4:: can't move 50 | attr_accessor :restriction 51 | 52 | # Truth value of the [Nonresistance] option. 53 | attr_accessor :nonresistance 54 | 55 | # Truth value of the [Regard as HP 0] option. 56 | attr_accessor :zero_hp 57 | 58 | # Truth value of the [Can't Get EXP] option. 59 | attr_accessor :cant_get_exp 60 | 61 | # Truth value of the [Can't Evade] option. 62 | attr_accessor :cant_evade 63 | 64 | # Truth value of the [Slip Damage] option. 65 | attr_accessor :slip_damage 66 | 67 | # State rating (0..10). 68 | attr_accessor :rating 69 | 70 | # Hit percentage. 71 | attr_accessor :hit_rate 72 | 73 | # Maximum HP percentage. 74 | attr_accessor :maxhp_rate 75 | 76 | # Maximum SP percentage. 77 | attr_accessor :maxsp_rate 78 | 79 | # Strength percentage. 80 | attr_accessor :str_rate 81 | 82 | # Dexterity percentage. 83 | attr_accessor :dex_rate 84 | 85 | # Agility percentage. 86 | attr_accessor :agi_rate 87 | 88 | # Intelligence percentage. 89 | attr_accessor :int_rate 90 | 91 | # Attack percentage. 92 | attr_accessor :atk_rate 93 | 94 | # Physical defense percentage. 95 | attr_accessor :pdef_rate 96 | 97 | # Magic defense percentage. 98 | attr_accessor :mdef_rate 99 | 100 | # Evasion correction. 101 | attr_accessor :eva 102 | 103 | # Truth value of whether the state wears off at battle end. 104 | attr_accessor :battle_only 105 | 106 | attr_accessor :hold_turn 107 | 108 | # Percent probability of wearing off after the number of turns 109 | # in hold_turn have passed. 110 | attr_accessor :auto_release_prob 111 | 112 | # Percent probability of wearing off after receiving physical damage. 113 | attr_accessor :shock_release_prob 114 | 115 | # Elemental defense. An Elemental ID array. 116 | attr_accessor :guard_element_set 117 | 118 | # States to add. A State ID array. 119 | attr_accessor :plus_state_set 120 | 121 | # States to cancel. A State ID array. 122 | attr_accessor :minus_state_set 123 | end 124 | end -------------------------------------------------------------------------------- /lib/rpg/tileset.rb: -------------------------------------------------------------------------------- 1 | require 'table' 2 | 3 | module RPG 4 | # Data class for tilesets. 5 | class Tileset 6 | def initialize 7 | @id = 0 8 | @name = "" 9 | @tileset_name = "" 10 | @autotile_names = [""]*7 11 | @panorama_name = "" 12 | @panorama_hue = 0 13 | @fog_name = "" 14 | @fog_hue = 0 15 | @fog_opacity = 64 16 | @fog_blend_type = 0 17 | @fog_zoom = 200 18 | @fog_sx = 0 19 | @fog_sy = 0 20 | @battleback_name = "" 21 | @passages = Table.new(384) 22 | @priorities = Table.new(384) 23 | @priorities[0] = 5 24 | @terrain_tags = Table.new(384) 25 | end 26 | 27 | # The tileset ID. 28 | attr_accessor :id 29 | 30 | # The tileset name. 31 | attr_accessor :name 32 | 33 | # The tileset's graphic file name. 34 | attr_accessor :tileset_name 35 | 36 | # The autotile graphic's file name array ([0]..[6]). 37 | attr_accessor :autotile_names 38 | 39 | # The panorama graphic file name. 40 | attr_accessor :panorama_name 41 | 42 | # The adjustment value for the panorama graphic's hue (0..360). 43 | attr_accessor :panorama_hue 44 | 45 | # The fog graphic's file name. 46 | attr_accessor :fog_name 47 | 48 | # The adjustment value for the fog graphic's hue (0..360). 49 | attr_accessor :fog_hue 50 | 51 | # The fog's opacity. 52 | attr_accessor :fog_opacity 53 | 54 | # The fog's blending mode. 55 | attr_accessor :fog_blend_type 56 | 57 | # The fog's zoom level. 58 | attr_accessor :fog_zoom 59 | 60 | # The fog's SX (automatic X-axis scrolling speed). 61 | attr_accessor :fog_sx 62 | 63 | # The fog's SY (automatic Y-axis scrolling speed). 64 | attr_accessor :fog_sy 65 | 66 | # The battle background's graphic file name. 67 | attr_accessor :battleback_name 68 | 69 | # Passage table. A 1-dimensional {Table} containing passage flags, 70 | # Bush flags, and counter flags. 71 | # 72 | # The tile ID is used as a subscript. Each bit is handled as follows: 73 | # 0x01:: Cannot move down. 74 | # 0x02:: Cannot move left. 75 | # 0x04:: Cannot move right. 76 | # 0x08:: Cannot move up. 77 | # 0x40:: Bush flag. 78 | # 0x80:: Counter flag. 79 | # @return [Table] 80 | attr_accessor :passages 81 | 82 | # Priority table. A 1-dimensional {Table} containing priority data. 83 | # 84 | # The tile ID is used as a subscript. 85 | # @return [Table] 86 | attr_accessor :priorities 87 | 88 | # Terrain tag table A 1-dimensional {Table} containing terrain tag data. 89 | # 90 | # The tile ID is used as a subscript. 91 | # @return [Table] 92 | attr_accessor :terrain_tags 93 | end 94 | end -------------------------------------------------------------------------------- /lib/rpg/troop.rb: -------------------------------------------------------------------------------- 1 | require 'rpg/event_command' 2 | 3 | module RPG 4 | class Troop 5 | def initialize 6 | @id = 0 7 | @name = "" 8 | @members = [] 9 | @pages = [RPG::BattleEventPage.new] # Shouldn't this be [RPG::Troop::Member.new] ? 10 | end 11 | 12 | # Troop ID. 13 | attr_accessor :id 14 | 15 | # Troop name. 16 | attr_accessor :name 17 | 18 | # Troop members. An {RPG::Troop::Member} array. 19 | # @returns [Array] 20 | attr_accessor :members 21 | 22 | # Battle events. An {RPG::Troop::Page} array. 23 | # @returns [Array] 24 | attr_accessor :pages 25 | 26 | # Data class for troop members. 27 | class Member 28 | def initialize 29 | @enemy_id = 1 30 | @x = 0 31 | @y = 0 32 | @hidden = false 33 | @immortal = false 34 | end 35 | 36 | # The enemy ID. 37 | attr_accessor :enemy_id 38 | 39 | # The troop member's X-coordinate. 40 | attr_accessor :x 41 | 42 | # The troop member's Y-coordinate. 43 | attr_accessor :y 44 | 45 | # Truth value of the [Appear Midway] option. 46 | attr_accessor :hidden 47 | 48 | # Truth value of the [Immortal] option. 49 | attr_accessor :immortal 50 | end 51 | 52 | # Data class for battle events (pages). 53 | class Page 54 | def initialize 55 | @condition = RPG::Troop::Page::Condition.new 56 | @span = 0 57 | @list = [RPG::EventCommand.new] 58 | end 59 | 60 | # Condition ({RPG::Troop::Page::Condition}). 61 | # @returns [RPG::Troop::Page::Condition] 62 | attr_accessor :condition 63 | 64 | # Span: 65 | # 0:: battle 66 | # 1:: turn 67 | # 2:: moment 68 | attr_accessor :span 69 | 70 | # Program contents. An {RPG::EventCommand} array. 71 | # @returns [Array] 72 | attr_accessor :list 73 | 74 | # A database of battle event [Conditions]. 75 | class Condition 76 | def initialize 77 | @turn_valid = false 78 | @enemy_valid = false 79 | @actor_valid = false 80 | @switch_valid = false 81 | @turn_a = 0 82 | @turn_b = 0 83 | @enemy_index = 0 84 | @enemy_hp = 50 85 | @actor_id = 1 86 | @actor_hp = 50 87 | @switch_id = 1 88 | end 89 | 90 | # Truth value for whether the [Turn] condition is valid. 91 | attr_accessor :turn_valid 92 | 93 | # Truth value for whether the [Enemy] condition is valid. 94 | attr_accessor :enemy_valid 95 | 96 | # Truth value for whether the [Actor] condition is valid. 97 | attr_accessor :actor_valid 98 | 99 | # Truth value for whether the [Switch] condition is valid. 100 | attr_accessor :switch_valid 101 | 102 | # a value specified in the [Turn] condition. 103 | # To be input in the form a + bx. 104 | attr_accessor :turn_a 105 | 106 | # b value specified in the [Turn] condition. 107 | # To be input in the form a + bx. 108 | attr_accessor :turn_b 109 | 110 | # Troop member index specified in the [Enemy] condition (0..7). 111 | attr_accessor :enemy_index 112 | 113 | # HP percentage specified in the [Enemy] condition. 114 | attr_accessor :enemy_hp 115 | 116 | # Actor ID specified in the [Actor] condition. 117 | attr_accessor :actor_id 118 | 119 | # HP percentage specified in the [Actor] condition. 120 | attr_accessor :actor_hp 121 | 122 | # Switch ID specified in the [Switch] condition. 123 | attr_accessor :switch_id 124 | end 125 | end 126 | end 127 | end -------------------------------------------------------------------------------- /lib/rpg/weapon.rb: -------------------------------------------------------------------------------- 1 | module RPG 2 | # Data class for weapons. 3 | class Weapon 4 | def initialize 5 | @id = 0 6 | @name = "" 7 | @icon_name = "" 8 | @description = "" 9 | @animation1_id = 0 10 | @animation2_id = 0 11 | @price = 0 12 | @atk = 0 13 | @pdef = 0 14 | @mdef = 0 15 | @str_plus = 0 16 | @dex_plus = 0 17 | @agi_plus = 0 18 | @int_plus = 0 19 | @element_set = [] 20 | @plus_state_set = [] 21 | @minus_state_set = [] 22 | end 23 | 24 | # The weapon ID. 25 | attr_accessor :id 26 | 27 | # The weapon name. 28 | attr_accessor :name 29 | 30 | # The weapon's icon graphic file name. 31 | attr_accessor :icon_name 32 | 33 | # The weapon description. 34 | attr_accessor :description 35 | 36 | # The animation ID when using the weapon. 37 | attr_accessor :animation1_id 38 | 39 | # The animation ID when on the receiving end of the weapon. 40 | attr_accessor :animation2_id 41 | 42 | # The weapon's price. 43 | attr_accessor :price 44 | 45 | # The weapon's attack power. 46 | attr_accessor :atk 47 | 48 | # The weapon's physical defense rating. 49 | attr_accessor :pdef 50 | 51 | # The weapon's magic defense rating. 52 | attr_accessor :mdef 53 | 54 | # The weapon's strength bonus. 55 | attr_accessor :str_plus 56 | 57 | # The weapon's dexterity bonus. 58 | attr_accessor :dex_plus 59 | 60 | # The weapon's agility bonus. 61 | attr_accessor :agi_plus 62 | 63 | # The weapon's intelligence bonus. 64 | attr_accessor :int_plus 65 | 66 | # The weapon's element. An Elemental ID array. 67 | attr_accessor :element_set 68 | 69 | # States to add. A State ID array. 70 | attr_accessor :plus_state_set 71 | 72 | # States to cancel. A State ID array. 73 | attr_accessor :minus_state_set 74 | end 75 | end -------------------------------------------------------------------------------- /lib/rpg/weather.rb: -------------------------------------------------------------------------------- 1 | require 'bitmap' 2 | require 'color' 3 | require 'sprite' 4 | 5 | module RPG 6 | # Class for weather effects (rain, storm, snow) 7 | # displayed via RPGXP's Event command. 8 | class Weather 9 | # Weather type: 10 | # 0:: none 11 | # 1:: rain 12 | # 2:: storm 13 | # 3:: snow 14 | attr_reader :type 15 | 16 | # Amount of weather to be shown at once (0..40). 17 | attr_reader :max 18 | 19 | # The X-coordinate of the effect's starting point. 20 | # Correlates with the tilemap starting point and scrolls. 21 | attr_reader :ox 22 | 23 | # The Y-coordinate of the effect's starting point. 24 | # Correlates with the tilemap starting point and scrolls. 25 | attr_reader :oy 26 | 27 | def initialize(viewport = nil) 28 | @type = 0 29 | @max = 0 30 | @ox = 0 31 | @oy = 0 32 | color1 = Color.new(255, 255, 255, 255) 33 | color2 = Color.new(255, 255, 255, 128) 34 | @rain_bitmap = Bitmap.new(7, 56) 35 | for i in 0..6 36 | @rain_bitmap.fill_rect(6-i, i*8, 1, 8, color1) 37 | end 38 | @storm_bitmap = Bitmap.new(34, 64) 39 | for i in 0..31 40 | @storm_bitmap.fill_rect(33-i, i*2, 1, 2, color2) 41 | @storm_bitmap.fill_rect(32-i, i*2, 1, 2, color1) 42 | @storm_bitmap.fill_rect(31-i, i*2, 1, 2, color2) 43 | end 44 | @snow_bitmap = Bitmap.new(6, 6) 45 | @snow_bitmap.fill_rect(0, 1, 6, 4, color2) 46 | @snow_bitmap.fill_rect(1, 0, 4, 6, color2) 47 | @snow_bitmap.fill_rect(1, 2, 4, 2, color1) 48 | @snow_bitmap.fill_rect(2, 1, 2, 4, color1) 49 | @sprites = [] 50 | for i in 1..40 51 | sprite = Sprite.new(viewport) 52 | sprite.z = 1000 53 | sprite.visible = false 54 | sprite.opacity = 0 55 | @sprites.push(sprite) 56 | end 57 | end 58 | 59 | # Frees a weather effect. 60 | def dispose 61 | for sprite in @sprites 62 | sprite.dispose 63 | end 64 | @rain_bitmap.dispose 65 | @storm_bitmap.dispose 66 | @snow_bitmap.dispose 67 | end 68 | 69 | # Weather type: 70 | # 0:: none 71 | # 1:: rain 72 | # 2:: storm 73 | # 3:: snow 74 | def type=(type) 75 | return if @type == type 76 | @type = type 77 | case @type 78 | when 1 79 | bitmap = @rain_bitmap 80 | when 2 81 | bitmap = @storm_bitmap 82 | when 3 83 | bitmap = @snow_bitmap 84 | else 85 | bitmap = nil 86 | end 87 | for i in 1..40 88 | sprite = @sprites[i] 89 | if sprite != nil 90 | sprite.visible = (i <= @max) 91 | sprite.bitmap = bitmap 92 | end 93 | end 94 | end 95 | 96 | # The X-coordinate of the effect's starting point. 97 | # Correlates with the tilemap starting point and scrolls. 98 | def ox=(ox) 99 | return if @ox == ox; 100 | @ox = ox 101 | for sprite in @sprites 102 | sprite.ox = @ox 103 | end 104 | end 105 | 106 | # The Y-coordinate of the effect's starting point. 107 | # Correlates with the tilemap starting point and scrolls. 108 | def oy=(oy) 109 | return if @oy == oy; 110 | @oy = oy 111 | for sprite in @sprites 112 | sprite.oy = @oy 113 | end 114 | end 115 | 116 | # Amount of weather to be shown at once (0..40). 117 | def max=(max) 118 | return if @max == max; 119 | @max = [[max, 0].max, 40].min 120 | for i in 1..40 121 | sprite = @sprites[i] 122 | if sprite != nil 123 | sprite.visible = (i <= @max) 124 | end 125 | end 126 | end 127 | 128 | # Advances the weather effect. 129 | # As a rule, this method is called once per frame. 130 | def update 131 | return if @type == 0 132 | for i in 1..@max 133 | sprite = @sprites[i] 134 | if sprite == nil 135 | break 136 | end 137 | if @type == 1 138 | sprite.x -= 2 139 | sprite.y += 16 140 | sprite.opacity -= 8 141 | end 142 | if @type == 2 143 | sprite.x -= 8 144 | sprite.y += 16 145 | sprite.opacity -= 12 146 | end 147 | if @type == 3 148 | sprite.x -= 2 149 | sprite.y += 8 150 | sprite.opacity -= 8 151 | end 152 | x = sprite.x - @ox 153 | y = sprite.y - @oy 154 | if sprite.opacity < 64 or x < -50 or x > 750 or y < -300 or y > 500 155 | sprite.x = rand(800) - 50 + @ox 156 | sprite.y = rand(800) - 200 + @oy 157 | sprite.opacity = 255 158 | end 159 | end 160 | end 161 | end 162 | end -------------------------------------------------------------------------------- /lib/sprite.rb: -------------------------------------------------------------------------------- 1 | # The sprite class. 2 | # Sprites are the basic concept used to display 3 | # characters, etc. on the game screen. 4 | class Sprite 5 | # Refers to the {Bitmap} used for the sprite's starting point. 6 | attr_accessor :bitmap 7 | 8 | # The box (Rect) taken from a bitmap. 9 | attr_accessor :src_rect 10 | 11 | # The sprite's visibility. If TRUE, the sprite is visible. 12 | attr_accessor :visible 13 | 14 | # The sprite's X-coordinate. 15 | attr_accessor :x 16 | 17 | # The sprite's Y-coordinate. 18 | attr_accessor :y 19 | 20 | # The viewport's Z-coordinate. The larger this value, the closer 21 | # to the player the viewport will be displayed. If multiple objects share 22 | # the same Z-coordinate, the more recently created object will be displayed 23 | # closest to the player. 24 | attr_accessor :z 25 | 26 | # The X-coordinate of the sprite's starting point. 27 | attr_accessor :ox 28 | 29 | # The Y-coordinate of the sprite's starting point. 30 | attr_accessor :oy 31 | 32 | # The sprite's X-axis zoom level. 1.0 denotes actual pixel size. 33 | attr_accessor :zoom_x 34 | 35 | # The sprite's Y-axis zoom level. 1.0 denotes actual pixel size. 36 | attr_accessor :zoom_y 37 | 38 | # The sprite's angle of rotation. Specifies up to 360 degrees of 39 | # counterclockwise rotation. However, drawing a rotated sprite is 40 | # time-consuming, so avoid overuse. 41 | attr_accessor :angle 42 | 43 | # Flag denoting the sprite has been flipped horizontally. 44 | # If TRUE, the sprite will be drawn flipped. 45 | attr_accessor :mirror 46 | 47 | # The Bush depth for that sprite. This is a pixel value denoting how much of 48 | # the sprite's lower portion will be displayed as semitransparent. 49 | # A simple way to convey a sense of a character's feet being obscured by 50 | # foliage and the like. 51 | attr_accessor :bush_depth 52 | 53 | # The sprite's opacity (0-255). Values out of range are automatically corrected. 54 | attr_accessor :opacity 55 | 56 | # The sprite's blending mode (0: normal, 1: addition, 2: subtraction). 57 | attr_accessor :blend_type 58 | 59 | # The color (Color) to be blended with the sprite. 60 | # Alpha values are used in the blending ratio. 61 | # 62 | # Handled separately from the color blended into a flash effect. 63 | # However, the color with the higher alpha value when displayed will 64 | # have the higher priority when blended. 65 | attr_accessor :color 66 | 67 | # The sprite's color {Tone}. 68 | attr_accessor :tone 69 | 70 | # Gets the {Viewport} specified when the tilemap was created. 71 | attr_reader :viewport 72 | 73 | def initialize(viewport = nil) 74 | raise "not implemented" 75 | 76 | @viewport = viewport 77 | end 78 | 79 | # Frees the sprite. If the sprite has already been freed, does nothing. 80 | def dispose 81 | raise "not implemented" 82 | 83 | @disposed = true 84 | end 85 | 86 | # Returns TRUE if the sprite has been freed. 87 | def disposed? 88 | @disposed 89 | end 90 | 91 | # Begins flashing the sprite. 92 | # duration specifies the number of frames the flash will last. 93 | # 94 | # If color is set to nil, the sprite will disappear while flashing. 95 | def flash(color, duration) 96 | raise "not implemented" 97 | end 98 | 99 | # Refreshes the sprite flash. As a rule, this method is called once per frame. 100 | # 101 | # It is not necessary to call this method if no flash effect is needed. 102 | def update 103 | raise "not implemented" 104 | end 105 | end -------------------------------------------------------------------------------- /lib/table.rb: -------------------------------------------------------------------------------- 1 | # The multidimensional array class. Each element takes up 2 signed bytes, ranging from -32,768 to 32,767. 2 | # 3 | # Ruby's Array class does not run efficiently when handling large amounts of data, hence the inclusion of this class. 4 | class Table 5 | attr_reader :xsize, :ysize, :zsize 6 | 7 | def initialize(xsize, ysize=nil, zsize=nil) 8 | raise "invalid params - expected (xsize[, ysize[, zsize]])" unless params_valid?(xsize, ysize, zsize) 9 | 10 | @dimensions = dimensions(xsize, ysize, zsize) 11 | @items = [] 12 | 13 | resize(xsize, ysize, zsize) 14 | end 15 | 16 | # Change the size of the array. All data from before the size change is retained. 17 | def resize(xsize, ysize=nil, zsize=nil) 18 | raise "invalid params - expected (xsize[, ysize[, zsize]])" unless params_valid?(xsize, ysize, zsize) 19 | raise "wrong # of sizes" if dimensions(xsize, ysize, zsize) != @dimensions 20 | 21 | # Set and coerce the nsize variables 22 | @xsize, @ysize, @zsize = xsize || 1, ysize || 1, zsize || 1 23 | end 24 | 25 | # Accesses the array's elements. Pulls the same number of arguments as there 26 | # are dimensions in the created array. Returns nil if the specified element does not exist. 27 | def [](x, y=nil, z=nil) 28 | raise unless params_valid?(x, y, z) 29 | raise "wrong # of indecies" if dimensions(x, y, z) != @dimensions 30 | 31 | return nil unless (0..@xsize).include?(x || 0) and 32 | (0..@ysize).include?(y || 0) and 33 | (0..@zsize).include?(z || 0) 34 | 35 | case @dimensions 36 | when 1 37 | return @items[x] 38 | when 2 39 | return @items.fetch(x){ [] }[y] 40 | when 3 41 | return @items.fetch(x){ [] }.fetch(y){ [] }[z] 42 | end 43 | end 44 | 45 | def []=(*args) 46 | raise "wrong # of indecies" if not args.size == (@dimensions + 1) 47 | x, y, z = args.first(@dimensions) 48 | raise if not params_valid?(x, y, z) 49 | raise "wrong # of indecies" if dimensions(x, y, z) != @dimensions 50 | 51 | item = args[-1] 52 | 53 | case @dimensions 54 | when 1 55 | @items[x] = item 56 | when 2 57 | @items.fetch(x){ @items[x]=[] }[y] = item 58 | when 3 59 | @items.fetch(x){ @items[x]=[] }.fetch(y){ @items[x][y]=[] }[z] = item 60 | end 61 | end 62 | 63 | private 64 | 65 | def params_valid?(x, y, z) 66 | return !x.nil? && !(y.nil? && !z.nil?) 67 | end 68 | 69 | def dimensions(x, y, z) 70 | return (x == nil ? 0 : 1) + 71 | (y == nil ? 0 : 1) + 72 | (z == nil ? 0 : 1) 73 | end 74 | 75 | end -------------------------------------------------------------------------------- /lib/tilemap.rb: -------------------------------------------------------------------------------- 1 | # The class governing tilemaps. Tilemaps are a specialized concept used in 2D 2 | # game map displays, created internally from multiple sprites. 3 | class Tilemap 4 | # Refers to the {Bitmap} used as a tileset. 5 | # @return [Bitmap] 6 | attr_accessor :tileset 7 | 8 | # Refers to the {Bitmap} used as an autotile with an index number from 0 to 6. 9 | # @return [Bitmap] 10 | attr_accessor :autotiles 11 | 12 | # Refers to the map data {Table}. Defines a 3-dimensional array measuring 13 | # [ horizontal size * vertical size * 3 ]. 14 | # @return [Table] the map data in the form of a 3-dimensional array measuring 15 | # [ horizontal size * vertical size * 3 ]. 16 | attr_accessor :map_data 17 | 18 | # Refers to the flash data {Table} used when showing range of possible 19 | # movement in simulation games, etc. Defines a 2-dimensional array measuring 20 | # [ horizontal size * vertical size ]. This array must be the same size as the 21 | # map data. Each element uses 4 bits to represent a tile's flash color in RGB; 22 | # for example, 0xf84 flashes in RGB(15,8,4). 23 | # @return [Table] 24 | attr_accessor :flash_data 25 | 26 | # Reference to the priority {Table}. Defines a 1-dimensional array 27 | # containing elements corresponding to tile IDs. 28 | # @return [Bitmap] 29 | attr_accessor :priorities 30 | 31 | # The tilemap's visibility. If TRUE, the tilemap is visible. 32 | attr_accessor :visible 33 | 34 | # The X-coordinate of the tilemap's starting point. 35 | # Change this value to scroll the tilemap. 36 | attr_accessor :ox 37 | 38 | # The Y-coordinate of the tilemap's starting point. 39 | # Change this value to scroll the tilemap. 40 | attr_accessor :oy 41 | 42 | def initialize(viewport = nil) 43 | raise "not implemented" 44 | 45 | @viewport = viewport 46 | end 47 | 48 | # Frees the tilemap. If the tilemap has already been freed, does nothing. 49 | def disposed() 50 | raise "not implemented" 51 | 52 | @disposed = true 53 | end 54 | 55 | # Returns TRUE if the tilemap has been freed. 56 | def disposed?() 57 | @disposed 58 | end 59 | end -------------------------------------------------------------------------------- /lib/tone.rb: -------------------------------------------------------------------------------- 1 | class Tone 2 | attr_reader :red, :green, :blue, :gray 3 | 4 | # The red balance adjustment value (-255 to 255). 5 | # Values out of range are automatically corrected. 6 | def red=(num) 7 | @red = constrain num, -255..255 8 | end 9 | 10 | # The red balance adjustment value (-255 to 255). 11 | # Values out of range are automatically corrected. 12 | def green=(num) 13 | @green = constrain num, -255..255 14 | end 15 | 16 | # The blue balance adjustment value (-255 to 255). 17 | # Values out of range are automatically corrected. 18 | def blue=(num) 19 | @blue = constrain num, -255..255 20 | end 21 | 22 | # The grayscale filter strength (0 to 255). 23 | # Values out of range are automatically corrected. 24 | # 25 | # When this value is not 0, processing time is significantly longer than when using tone balance adjustment values alone. 26 | def gray=(num) 27 | @gray = constrain num, 0..255 28 | end 29 | 30 | def initialize(red, green, blue, gray=0) 31 | set red, green, blue, gray 32 | end 33 | 34 | # Sets all components at once. 35 | def set(red, green, blue, gray=0) 36 | self.red = red 37 | self.green = green 38 | self.blue = blue 39 | self.gray = gray 40 | end 41 | 42 | private 43 | 44 | def constrain(val, range) 45 | if val < range.min 46 | range.min 47 | elsif val > range.max 48 | range.max 49 | else 50 | val 51 | end 52 | end 53 | 54 | end -------------------------------------------------------------------------------- /lib/viewport.rb: -------------------------------------------------------------------------------- 1 | # The viewport class. Used when displaying sprites in one portion of the screen, 2 | # with no overflow into other regions. 3 | class Viewport 4 | # The {Rect} defining the viewport. 5 | # @returns [Rect] 6 | attr_accessor :rect 7 | 8 | # The viewport's visibility. If TRUE, the viewport is visible. 9 | attr_accessor :visible 10 | 11 | # The viewport's Z-coordinate. The larger this value, the closer to the 12 | # player the viewport will be displayed. If multiple objects share the same 13 | # Z-coordinate, the more recently created object will be 14 | # displayed closest to the player. 15 | attr_accessor :z 16 | 17 | # The X-coordinate of the viewport's starting point. 18 | # Change this value to shake the screen, etc. 19 | attr_accessor :ox 20 | 21 | # The Y-coordinate of the viewport's starting point. 22 | # Change this value to shake the screen, etc. 23 | attr_accessor :oy 24 | 25 | # The {Color} to be blended with the viewport. Alpha values are used in the blending ratio. 26 | # 27 | # Handled separately from the color blended into a flash effect. 28 | # @returns [Color] 29 | attr_accessor :color 30 | 31 | # The viewport's color {Tone}. 32 | # @returns [Tone] 33 | attr_accessor :tone 34 | 35 | # new(x, y, width, height) 36 | # new(rect) 37 | def initialize 38 | raise "not implemented" 39 | end 40 | 41 | # Frees the viewport. If the viewport has already been freed, does nothing. 42 | def dispose 43 | @disposed = true 44 | end 45 | 46 | # Returns TRUE if the viewport has been freed. 47 | def disposed? 48 | @disposed 49 | end 50 | 51 | # Begins flashing the viewport. duration specifies the number of frames the flash will last. 52 | # 53 | # If color is set to nil, the viewport will disappear while flashing. 54 | def flash(color, duration) 55 | raise "not implemented" 56 | end 57 | 58 | # Refreshes the viewport flash. As a rule, this method is called once per frame. 59 | # 60 | # It is not necessary to call this method if no flash effect is needed. 61 | def update 62 | raise "not implemented" 63 | end 64 | end -------------------------------------------------------------------------------- /lib/window.rb: -------------------------------------------------------------------------------- 1 | # The game window class. Created internally from multiple sprites. 2 | class Window 3 | # Refers to the {Bitmap} used as a windowskin. 4 | # @returns [Bitmap] 5 | attr_accessor :windowskin 6 | 7 | # Refers to the {Bitmap} used for the window's contents. 8 | # @returns [Bitmap] 9 | attr_accessor :contents 10 | 11 | # The wallpaper display method. If TRUE, stretches the wallpaper graphic; 12 | # if FALSE, tiles it. The default value is TRUE. 13 | attr_accessor :stretch 14 | 15 | # The cursor box (Rect). Sets the window's upper left corner using 16 | # relative coordinates (-16, -16). 17 | # @returns [Rect] 18 | attr_accessor :cursor_rect 19 | 20 | # Cursor blink status. If TRUE, the cursor is blinking. 21 | attr_accessor :active 22 | 23 | # The window's visibility. If TRUE, the window is visible. 24 | attr_accessor :visible 25 | 26 | # The pause graphic's visibility. This is a symbol that appears in the message 27 | # window when waiting for the player to press a button. 28 | # If TRUE, the graphic is visible. 29 | attr_accessor :pause 30 | 31 | # The window's X-coordinate. 32 | attr_accessor :x 33 | 34 | # The window's Y-coordinate. 35 | attr_accessor :y 36 | 37 | # The window's width. 38 | attr_accessor :width 39 | 40 | # The window's height. 41 | attr_accessor :height 42 | 43 | # The window's Z-coordinate. The larger this value, the closer to the player 44 | # the window will be displayed. If multiple objects share the 45 | # same Z-coordinate, the more recently created object will be displayed 46 | # closest to the player. The Z-coordinate of the window's contents equals 47 | # the window background's Z-coordinate plus 2. 48 | attr_accessor :z 49 | 50 | # The X-coordinate of the starting point of the window's contents. 51 | # Change this value to scroll the window's contents. 52 | attr_accessor :ox 53 | 54 | # The Y-coordinate of the starting point of the window's contents. 55 | # Change this value to scroll the window's contents. 56 | attr_accessor :oy 57 | 58 | # The window's opacity (0-255). 59 | # Values out of range are automatically corrected. 60 | attr_accessor :opacity 61 | 62 | # The window background's opacity (0-255). 63 | # Values out of range are automatically corrected. 64 | attr_accessor :back_opacity 65 | 66 | # The opacity of the window's contents (0-255). 67 | # Values out of range are automatically corrected. 68 | attr_accessor :contents_opacity 69 | 70 | # Gets the {Viewport} specified when the window was created. 71 | # @returns [Viewport] 72 | attr_reader :viewport 73 | 74 | def initialize(viewport = nil) 75 | raise "not implemented" 76 | 77 | @viewport = viewport 78 | end 79 | 80 | # Frees the window. If the window has already been freed, does nothing. 81 | def dispose 82 | raise "not implemented" 83 | 84 | @disposed = true 85 | end 86 | 87 | # Returns TRUE if the window has been freed. 88 | def disposed? 89 | @disposed 90 | end 91 | 92 | # Refreshes the cursor blink and the pause graphic animation. 93 | # As a rule, this method is called once per frame. 94 | def update 95 | raise "not implemented" 96 | end 97 | 98 | end -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Open RPG Maker 2 | ============== 3 | 4 | 5 | About 6 | ----- 7 | 8 | **Open RPG Maker** is a clone of [RPG Maker XP][1]. The goal is to create a cross platform re-implementation of the RMXP library, written in 100% Ruby. All GUI related code is modular so as to support platform-specific forks. 9 | 10 | **Additional Links:** 11 | 12 | - [Documentation][2] (via [yardoc][3]) 13 | - [Code metrics][4] (via [Caliper][5]) 14 | 15 | Supported Platforms 16 | ------------------- 17 | 18 | Linux, OSX and Windows are all supported. These are the following primary GUI platforms we are targeting: 19 | 20 | - [Rubygame][6] 21 | - Silverlight/IronRuby 22 | 23 | Status 24 | ------ 25 | 26 | A majority of the core library is implemented, leaving the intricacies of the GUI code for last. As they say, the last 10% of functionality represents 90% of the development time. 27 | 28 | Roadmap 29 | ------- 30 | 31 | There's still a *lot* to do right now: 32 | 33 | 1. Recreate the resource files (*.rxdata) in an unencrypted format. 34 | 2. Finish the *RPG* module, and create the *load_data(filename)* and *save_data(obj, filename)* bult-ins. 35 | 3. Redefine *p* and *print* for use in message box output. 36 | 4. Document the *RPG* module. 37 | 5. Create the bootstrapper for WPF, Silverlight, and WinForms. 38 | 6. Create unit tests. 39 | 7. Figure out what this is (from troop.rb): RPG::BattleEventPage.new 40 | 41 | 42 | [1]: http://tkool.jp/products/rpgxp/eng 43 | [2]: http://yardoc.org/docs/cstrahan-open-rpg-maker 44 | [3]: http://yardoc.org/ 45 | [4]: http://getcaliper.com/caliper/project?repo=git%3A%2F%2Fgithub.com%2Fcstrahan%2Fopen-rpg-maker.git 46 | [5]: http://getcaliper.com/ 47 | [6]: http://rubygame.org/ 48 | -------------------------------------------------------------------------------- /test/color_test.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'test/unit' 3 | require 'shoulda' 4 | require 'lib/color' 5 | 6 | class ColorTest < Test::Unit::TestCase 7 | context "An instantiated color" do 8 | should "have attributes set" do 9 | color = Color.new(10,20,30,40) 10 | 11 | assert color.red == 10 12 | assert color.green == 20 13 | assert color.blue == 30 14 | assert color.alpha == 40 15 | end 16 | 17 | should "have alpha default to 255" do 18 | color = Color.new(10,20,30) 19 | assert color.alpha == 255 20 | end 21 | 22 | should "constrain color channels to 0..255" do 23 | color = Color.new(-25,999,-9, 256) 24 | 25 | assert color.red == 0 26 | assert color.green == 255 27 | assert color.blue == 0 28 | assert color.alpha == 255 29 | end 30 | 31 | should "be settable via Color#set" do 32 | color = Color.new(10,20,30,40) 33 | color.set 40, 30, 20, 10 34 | 35 | assert color.red == 40 36 | assert color.green == 30 37 | assert color.blue == 20 38 | assert color.alpha == 10 39 | end 40 | 41 | should "be settable via attributes" do 42 | color = Color.new(0,0,0,0) 43 | 44 | color.red = 40 45 | color.green = 30 46 | color.blue = 20 47 | color.alpha = 10 48 | 49 | assert color.red == 40 50 | assert color.green == 30 51 | assert color.blue == 20 52 | assert color.alpha == 10 53 | end 54 | end 55 | end -------------------------------------------------------------------------------- /test/font_test.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'test/unit' 3 | require 'shoulda' 4 | require 'lib/font' 5 | 6 | class FontTest < Test::Unit::TestCase 7 | should "honor defaults when instantiated" do 8 | font = Font.new 9 | 10 | assert font.name == Font.default_name 11 | assert font.size == Font.default_size 12 | assert font.bold == Font.default_bold 13 | assert font.italic == Font.default_italic 14 | assert font.color == Font.default_color 15 | end 16 | 17 | should "execute exist? without error" do 18 | Font.exist? "MS PGothic" 19 | end 20 | end -------------------------------------------------------------------------------- /test/input_test.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'test/unit' 3 | require 'shoulda' 4 | require 'lib/input' 5 | 6 | class InputTest < Test::Unit::TestCase 7 | should "define correct constants" do 8 | assert Input::A == 11 9 | assert Input::B == 12 10 | assert Input::C == 13 11 | assert Input::X == 14 12 | assert Input::Y == 15 13 | assert Input::Z == 16 14 | assert Input::L == 17 15 | assert Input::R == 18 16 | 17 | assert Input::SHIFT == 21 18 | assert Input::CTRL == 22 19 | assert Input::ALT == 23 20 | 21 | assert Input::F5 == 25 22 | assert Input::F6 == 26 23 | assert Input::F7 == 27 24 | assert Input::F8 == 28 25 | assert Input::F9 == 29 26 | end 27 | end -------------------------------------------------------------------------------- /test/rect_test.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'test/unit' 3 | require 'shoulda' 4 | require 'lib/rect' 5 | 6 | class RectTest < Test::Unit::TestCase 7 | context "An instantiated Rect" do 8 | should "have attributes set" do 9 | rect = Rect.new(10,20,30,40) 10 | 11 | assert rect.x == 10 12 | assert rect.y == 20 13 | assert rect.width == 30 14 | assert rect.height == 40 15 | end 16 | 17 | should "be settable via Rect#set" do 18 | rect = Rect.new(10,20,30,40) 19 | rect.set 40, 30, 20, 10 20 | 21 | assert rect.x == 40 22 | assert rect.y == 30 23 | assert rect.width == 20 24 | assert rect.height == 10 25 | end 26 | 27 | should "be settable via attributes" do 28 | rect = Rect.new(0,0,0,0) 29 | 30 | rect.x = 40 31 | rect.y = 30 32 | rect.width = 20 33 | rect.height = 10 34 | 35 | assert rect.x == 40 36 | assert rect.y == 30 37 | assert rect.width == 20 38 | assert rect.height == 10 39 | end 40 | end 41 | end -------------------------------------------------------------------------------- /test/table_test.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'test/unit' 3 | require 'shoulda' 4 | require 'lib/table' 5 | 6 | class TableTest < Test::Unit::TestCase 7 | 8 | def assert_size(table, x=1, y=1, z=1) 9 | assert table.xsize == x 10 | assert table.ysize == y 11 | assert table.zsize == z 12 | end 13 | 14 | context "A table" do 15 | 16 | should "support one to three dimensions" do 17 | Table.new(0) 18 | Table.new(1) 19 | 20 | Table.new(0,0) 21 | Table.new(1,2) 22 | 23 | Table.new(0,0,0) 24 | Table.new(1,2,3) 25 | end 26 | 27 | should "report correct nsize" do 28 | table = Table.new(10) 29 | assert_size table, 10 30 | 31 | table = Table.new(0) 32 | assert_size table, 0 33 | 34 | table = Table.new(5,10) 35 | assert_size table, 5, 10 36 | 37 | table = Table.new(10,20,30) 38 | assert_size table, 10, 20, 30 39 | end 40 | 41 | should "set/get correct value" do 42 | table = Table.new(10) 43 | table[3] = 23 44 | table[9] = 45 45 | assert table[3] == 23 46 | assert table[9] == 45 47 | 48 | table = Table.new(2,2) 49 | table[0,1] = 16 50 | assert table[0,1] == 16 51 | 52 | table = Table.new(10,20,30) 53 | table[4,1,4] = 15 54 | assert table[4,1,4] == 15 55 | end 56 | 57 | should "be resizable" do 58 | table = Table.new(0) 59 | table.resize(10) 60 | assert_size table, 10 61 | 62 | table = Table.new(10,5) 63 | table.resize(5,10) 64 | assert_size table, 5, 10 65 | 66 | table = Table.new(5,10,15) 67 | table.resize(15,10,5) 68 | assert_size table, 15, 10, 5 69 | end 70 | 71 | should "keep values before and after resize" do 72 | # Create table with xsize of zero, set item `1' to `45' 73 | table = Table.new(0) 74 | table[1] = 45 75 | 76 | # `1' is outside the range - should return nil 77 | assert table[1] == nil 78 | 79 | # resizing should allow us to get the item 80 | table.resize(1) 81 | assert table[1] == 45 82 | 83 | # resizing down to `0' and back to `1' should still return the item 84 | table.resize(0) 85 | table.resize(1) 86 | assert table[1] == 45 87 | end 88 | 89 | end 90 | end -------------------------------------------------------------------------------- /test/tone_test.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'test/unit' 3 | require 'shoulda' 4 | require 'lib/tone' 5 | 6 | class ToneTest < Test::Unit::TestCase 7 | context "An instantiated Tone" do 8 | should "have attributes set" do 9 | tone = Tone.new(10,20,30,40) 10 | 11 | assert tone.red == 10 12 | assert tone.green == 20 13 | assert tone.blue == 30 14 | assert tone.gray == 40 15 | end 16 | 17 | should "have gray default to 0" do 18 | tone = Tone.new(10,20,30) 19 | assert tone.gray == 0 20 | end 21 | 22 | should "constrain rgb to -255..255 and gray to 0..255" do 23 | tone = Tone.new(-999,-32,32, 256) 24 | 25 | assert tone.red == -255 26 | assert tone.green == -32 27 | assert tone.blue == 32 28 | assert tone.gray == 255 29 | end 30 | 31 | should "be settable via Tone#set" do 32 | tone = Tone.new(10,20,30,40) 33 | tone.set 40, 30, 20, 10 34 | 35 | assert tone.red == 40 36 | assert tone.green == 30 37 | assert tone.blue == 20 38 | assert tone.gray == 10 39 | end 40 | 41 | should "be settable via attributes" do 42 | tone = Tone.new(0,0,0,0) 43 | 44 | tone.red = 40 45 | tone.green = 30 46 | tone.blue = 20 47 | tone.gray = 10 48 | 49 | assert tone.red == 40 50 | assert tone.green == 30 51 | assert tone.blue == 20 52 | assert tone.gray == 10 53 | end 54 | end 55 | end --------------------------------------------------------------------------------