#============================================================================== # [ZTBS] -Zenith Tactical Battle System- タクティカルバトルシステム #  〜2:ZTBS用 各種スプライト&ウィンドウ詰め合わせ〜   by 水夜 #  ver1.02  Zenith Creation (http://zenith.ifdef.jp/) #------------------------------------------------------------------------------ # マップ上での戦略的なバトルを実現。 #============================================================================== #============================================================================== # ■ Sprite_Cursor #============================================================================== class Sprite_Cursor < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :map_x # マップ X 座標 (論理座標) attr_reader :map_y # マップ Y 座標 (論理座標) attr_reader :real_x # マップ X 座標 (実座標 * 128) attr_reader :real_y # マップ Y 座標 (実座標 * 128) #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # character : キャラクター (Game_Character) #-------------------------------------------------------------------------- def initialize(viewport, x, y) super(viewport) self.bitmap = RPG::Cache.picture(ZTBS::CURSOR) self.ox = self.bitmap.width / 2 self.oy = self.bitmap.height moveto(x, y) update end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end #-------------------------------------------------------------------------- # ● 指定位置に移動 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def moveto(x, y) @map_x = x % $game_map.width @map_y = y % $game_map.height @real_x = @map_x * 128 @real_y = @map_y * 128 end #-------------------------------------------------------------------------- # ● 画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x # 実座標とマップの表示位置から画面座標を求める return (@real_x - $game_map.display_x + 3) / 4 + 16 end #-------------------------------------------------------------------------- # ● 画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y # 実座標とマップの表示位置から画面座標を求める y = (@real_y - $game_map.display_y + 3) / 4 + 32 end #-------------------------------------------------------------------------- # ● 画面 Z 座標の取得 #-------------------------------------------------------------------------- def screen_z # 実座標とマップの表示位置から画面座標を求める z = (@real_y - $game_map.display_y + 3) / 4 + 32 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super moveto($game_player.x, $game_player.y) # スプライトの座標を設定 self.x = screen_x self.y = screen_y self.z = screen_z + 1 end end #============================================================================== # ■ Sprite_Area #============================================================================== class Sprite_Area < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :map_x # マップ X 座標 (論理座標) attr_reader :map_y # マップ Y 座標 (論理座標) attr_reader :real_x # マップ X 座標 (実座標 * 128) attr_reader :real_y # マップ Y 座標 (実座標 * 128) #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # character : キャラクター (Game_Character) #-------------------------------------------------------------------------- def initialize(viewport, type, x, y, invisible = false) super(viewport) case type when 0 self.bitmap = RPG::Cache.picture(ZTBS::ACTOR_AREA) when 1 self.bitmap = RPG::Cache.picture(ZTBS::ENEMY_AREA) end self.ox = self.bitmap.width / 2 self.oy = self.bitmap.height self.opacity = 0 if invisible moveto(x, y) update end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end #-------------------------------------------------------------------------- # ● 指定位置に移動 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def moveto(x, y) @map_x = x @map_y = y @real_x = @map_x * 128 @real_y = @map_y * 128 end #-------------------------------------------------------------------------- # ● 画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x # 実座標とマップの表示位置から画面座標を求める return (@real_x - $game_map.display_x + 3) / 4 + 16 end #-------------------------------------------------------------------------- # ● 画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y # 実座標とマップの表示位置から画面座標を求める y = (@real_y - $game_map.display_y + 3) / 4 + 32 end #-------------------------------------------------------------------------- # ● 画面 Z 座標の取得 #-------------------------------------------------------------------------- def screen_z # 実座標とマップの表示位置から画面座標を求める z = (@real_y - $game_map.display_y + 3) / 4 + 32 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # スプライトの座標を設定 self.x = screen_x self.y = screen_y self.z = screen_z end end #============================================================================== # ■ Sprite_Range #============================================================================== class Sprite_Range < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :map_x # マップ X 座標 (論理座標) attr_reader :map_y # マップ Y 座標 (論理座標) attr_reader :real_x # マップ X 座標 (実座標 * 128) attr_reader :real_y # マップ Y 座標 (実座標 * 128) #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # character : キャラクター (Game_Character) #-------------------------------------------------------------------------- def initialize(viewport, type, x, y, invisible = false) super(viewport) case type when 0 self.bitmap = RPG::Cache.picture(ZTBS::ACTOR_TARGET_AREA) when 1 self.bitmap = RPG::Cache.picture(ZTBS::ENEMY_TARGET_AREA) end self.ox = self.bitmap.width / 2 self.oy = self.bitmap.height self.opacity = 0 if invisible @plus_map_x = x - $game_player.x @plus_map_y = y - $game_player.y moveto(x, y) update end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end #-------------------------------------------------------------------------- # ● 指定位置に移動 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def moveto(x, y) @map_x = x @map_y = y @real_x = @map_x * 128 @real_y = @map_y * 128 end #-------------------------------------------------------------------------- # ● 画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x # 実座標とマップの表示位置から画面座標を求める return (@real_x - $game_map.display_x + 3) / 4 + 16 end #-------------------------------------------------------------------------- # ● 画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y # 実座標とマップの表示位置から画面座標を求める y = (@real_y - $game_map.display_y + 3) / 4 + 32 end #-------------------------------------------------------------------------- # ● 画面 Z 座標の取得 #-------------------------------------------------------------------------- def screen_z # 実座標とマップの表示位置から画面座標を求める z = (@real_y - $game_map.display_y + 3) / 4 + 32 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super @map_x = $game_player.x + @plus_map_x @map_y = $game_player.y + @plus_map_y @real_x = @map_x * 128 @real_y = @map_y * 128 # スプライトの座標を設定 self.x = screen_x self.y = screen_y self.z = screen_z end end #============================================================================== # ■ RPG::Skill #============================================================================== module RPG class Skill def name name = @name.gsub("[T]", "") return name end def tactical? return @name.include?("[T]") end end end #============================================================================== # ■ Window_TSkill #============================================================================== class Window_TSkill < Window_Selectable #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :data # データ #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor : アクター #-------------------------------------------------------------------------- def initialize(actor) super(0, 64, 320, 256) if $game_player.y < 4 self.y = 416 - self.height end if $game_player.x < 10 self.x = 640 - self.width end @actor = actor refresh self.index = 0 end #-------------------------------------------------------------------------- # ● スキルの取得 #-------------------------------------------------------------------------- def skill return @data[self.index] end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 0...@actor.skills.size skill = $data_skills[@actor.skills[i]] if skill != nil and skill.tactical? @data.push(skill) end end # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) skill = @data[index] if @actor.skill_can_use?(skill.id) self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(skill.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0) self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.skill == nil ? "" : self.skill.description) end end #============================================================================== # ■ RPG::Item #============================================================================== module RPG class Item def name name = @name.gsub("[T]", "") return name end def tactical? return @name.include?("[T]") end end end #============================================================================== # ■ Window_TItem #============================================================================== class Window_TItem < Window_Selectable #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :data # データ #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor : アクター #-------------------------------------------------------------------------- def initialize super(0, 64, 320, 256) if $game_player.y < 4 self.y = 416 - self.height end if $game_player.x < 10 self.x = 640 - self.width end refresh self.index = 0 end #-------------------------------------------------------------------------- # ● アイテムの取得 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # アイテムを追加 for i in 1...$data_items.size if $game_party.item_number(i) > 0 and $data_items[i].tactical? @data.push($data_items[i]) end end # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id) self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end #============================================================================== # ■ Window_TActors #============================================================================== class Window_TActors < Window_Selectable #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :data # データ #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor : アクター #-------------------------------------------------------------------------- def initialize super(0, 64, 640, 352) refresh self.index = 0 end #-------------------------------------------------------------------------- # ● アクターの取得 #-------------------------------------------------------------------------- def actor return @data[self.index] end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] actors = $game_system.tactics_actors.keys + $game_system.tactics_dead_actors.keys for actor in actors @data.push(actor) end @data.sort! # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) if $game_system.tactics_actors.keys.include?(@data[index]) actor = $game_system.tactics_actors[@data[index]] else actor = $game_system.tactics_dead_actors[@data[index]] end x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 32, 32) draw_actor_name(actor, x, y) draw_actor_state(actor, x + 136, y) draw_actor_hp(actor, x + 280, y) draw_actor_sp(actor, x + 456, y) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help return end end