Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # v0.3 (28/08/14)
- # Created by Chris Swire (Tarsus)
- # All work is my own
- # not required but recommended
- Graphics.resize_screen(640,480)
- ##### global ship variables #####
- module SHIP
- ##### editable options #####
- SHIPID = 10 # the variable id holding the actor id of your ship
- PARTYSIZE = 4 # size of normal party while in battle
- MENULABEL = "Ship" # the text you want to appear on main menu
- MENUWIDTH = 160 # 160/216 is the default size for game 640x480
- MENUHEIGHT = 216 # these 2 options are for people with custom menus
- SHIPSKILL = 3 # the id of the ship skill type
- SHIPCOL = 1 # the amout of columns to show for skills and items
- SHIPBACK = "Clouds" # custom battleback1 to use in ship battles, 2 is empty
- # replacment labels for the ships equip slots
- SHIPSLOTS = ["Cannons","Deck Gun","Figurehead","Armour","Decoration"]
- ##### edit after here at own risk #####
- NEWITEMS = {
- # "Option Label" => [Event Switch ID,Common Event ID]
- MENULABEL => [0,0],}
- ## returns the actor set as ship ##
- def self.shipactor
- id = $game_variables[SHIPID].to_i
- return $game_actors[id]
- end
- def self.shipactorid
- return $game_variables[SHIPID]
- end
- def self.shipactive
- id = $game_variables[SHIPID].to_i
- return id >= 1
- end
- def self.shipbattle
- return shipactive && $data_enemies[$game_troop.members[0].enemy_id].note =~ /<shipbattle>/i
- end
- def self.captainbattle
- if shipactive && $data_enemies[$game_troop.members[0].enemy_id].note =~ /<captain (.*)>/i
- return $1.to_i
- else
- return 0
- end
- end
- end
- ##### Small window in bottom left to preview ship #####
- class Window_Ship_Preview < Window_Base
- ## creates window ##
- def initialize
- super(0, y, window_width, window_height)
- refresh
- end
- ## returns width taken from variables at top ##
- def window_width
- return SHIP::MENUWIDTH
- end
- ## same for height ##
- def window_height
- return SHIP::MENUHEIGHT
- end
- ## moves window so it matchs existing windows ##
- def y
- return Graphics.height - fitting_height(1) - window_height
- end
- ## refresh ##
- def refresh
- contents.clear
- @actor = SHIP.shipactor
- xcentre = window_width/2 - standard_padding - 48
- barwidth = SHIP::MENUWIDTH - standard_padding*2
- #draw_actor_bust(@actor, xcentre - 24, 0)
- draw_actor_icons(@actor, 0, 0)
- draw_actor_face(@actor, xcentre, 15)
- draw_actor_name(@actor, xcentre, 120 + line_height * 0)
- draw_actor_hp(@actor, 0, 120 + line_height * 1, barwidth)
- draw_actor_mp(@actor, 0, 120 + line_height * 2, barwidth)
- end
- ## open ##
- def open
- refresh
- super
- end
- end
- ##### New main menu command for ship options #####
- class Window_MenuCommand < Window_Command
- alias ship_commands add_original_commands
- ## adds command using label from variable list ##
- def add_original_commands
- ship_commands()
- SHIP::NEWITEMS.each_key do |label|
- switch_id = SHIP::NEWITEMS[label][0]
- enabled = (switch_id > 0) ? $game_switches[switch_id] : SHIP.shipactive
- add_command(label, label.to_sym, enabled)
- end
- end
- end
- ##### Rewrote main menu to add ship command #####
- class Scene_Menu < Scene_MenuBase
- alias ship_window create_command_window
- ## rewrote ##
- def start
- super
- create_command_window
- create_gold_window
- create_status_window
- if SHIP.shipactive
- create_ship_window
- end
- end
- def create_command_window
- ship_window()
- SHIP::NEWITEMS.each_key do |label|
- @command_window.set_handler(label.to_sym, method(:command_ship))
- end
- end
- def create_ship_window
- @ship_window = Window_Ship_Preview.new
- end
- def command_ship
- SceneManager.call(Scene_Ship)
- end
- end
- ##### Ship scene basic processing #####
- class Scene_Ship < Scene_MenuBase
- ## starts scene ##
- def start
- super
- create_help_window
- create_status_window
- create_command_window
- create_slot_window
- create_item_window
- create_skill_window
- @item_window.hide
- @skill_window.hide
- @skill_window.stype_id = SHIP::SHIPSKILL
- @actor = SHIP.shipactor
- @status_window.actor = @actor
- @slot_window.actor = @actor
- @item_window.actor = @actor
- @command_window.activate
- end
- ## creates window ##
- def create_status_window
- @status_window = Window_ShipStatus.new(0, @help_window.height)
- @status_window.viewport = @viewport
- @status_window.actor = SHIP.shipactor
- end
- ## creates window ##
- def create_command_window
- wx = @status_window.width
- wy = @help_window.height
- ww = Graphics.width - @status_window.width
- @command_window = Window_ShipCommand.new(wx, wy, ww)
- @command_window.viewport = @viewport
- @command_window.help_window = @help_window
- @command_window.set_handler(:equip, method(:command_equip))
- @command_window.set_handler(:repair, method(:command_repair))
- @command_window.set_handler(:skills, method(:command_skills))
- @command_window.set_handler(:cancel, method(:return_scene))
- end
- ## creates window ##
- def create_slot_window
- wx = @status_window.width
- wy = @command_window.y + @command_window.height
- ww = Graphics.width - @status_window.width
- @slot_window = Window_ShipEquipSlot.new(wx, wy, ww)
- @slot_window.viewport = @viewport
- @slot_window.help_window = @help_window
- @slot_window.status_window = @status_window
- @slot_window.set_handler(:ok, method(:on_slot_ok))
- @slot_window.set_handler(:cancel, method(:on_slot_cancel))
- end
- ## creates window ##
- def create_item_window
- wx = @status_window.width
- wy = @slot_window.y + @slot_window.height
- ww = Graphics.width - @status_window.width
- wh = Graphics.height - wy
- @item_window = Window_ShipEquipItem.new(wx, wy, ww, wh)
- @item_window.viewport = @viewport
- @item_window.help_window = @help_window
- @item_window.status_window = @status_window
- @item_window.set_handler(:ok, method(:on_item_ok))
- @item_window.set_handler(:cancel, method(:on_item_cancel))
- @slot_window.item_window = @item_window
- end
- ## creates window ##
- def create_skill_window
- wx = @status_window.width
- wy = @slot_window.y + @slot_window.height
- ww = Graphics.width - @status_window.width
- wh = Graphics.height - wy
- @skill_window = Window_ShipSkillList.new(wx, wy, ww, wh)
- @item_window.viewport = @viewport
- @skill_window.help_window = @help_window
- @skill_window.set_handler(:ok, method(:on_skill_ok))
- @skill_window.set_handler(:cancel, method(:on_skill_cancel))
- end
- ## command processing for all new windows ##
- def command_equip
- @item_window.show
- @slot_window.activate
- @slot_window.select(0)
- end
- def command_repair
- Sound.play_equip
- @command_window.activate
- end
- def command_skills
- @skill_window.show
- @skill_window.activate
- @skill_window.select(0)
- end
- def on_slot_ok
- @item_window.activate
- @item_window.select(0)
- end
- def on_slot_cancel
- @slot_window.unselect
- @command_window.activate
- @item_window.hide
- end
- def on_item_ok
- Sound.play_equip
- @actor.change_equip(@slot_window.index, @item_window.item)
- @slot_window.activate
- @slot_window.refresh
- @item_window.unselect
- @item_window.refresh
- end
- def on_item_cancel
- @slot_window.activate
- @item_window.unselect
- end
- def on_skill_ok
- @actor.last_skill.object = item
- determine_item
- end
- def on_skill_cancel
- @skill_window.unselect
- @command_window.activate
- @skill_window.hide
- end
- end
- ##### rewrote #####
- class Game_System
- attr_accessor :battle_member_size
- alias :gamesysteminit :initialize
- def initialize
- gamesysteminit
- @battle_member_size = SHIP::PARTYSIZE
- end
- end
- ##### rewrote #####
- class Game_Party
- def max_battle_members
- return $game_system.battle_member_size
- end
- end
- ##### Rewrote to use custom ship battleback #####
- class Spriteset_Battle
- def battleback1_bitmap
- if SHIP.shipbattle
- Cache.battleback1(SHIP::SHIPBACK)
- elsif battleback1_name
- Cache.battleback1(battleback1_name)
- else
- create_blurry_background_bitmap
- end
- end
- def battleback2_bitmap
- if SHIP.shipbattle
- Bitmap.new(1, 1)
- elsif battleback2_name
- Cache.battleback2(battleback2_name)
- else
- Bitmap.new(1, 1)
- end
- end
- end
- ##### Rewrote battle scene to swap in/out ship #####
- class Scene_Battle < Scene_Base
- ## start battle ##
- alias ship_start start
- def start
- @partysize = $game_party.all_members
- @partylast = @partysize.size
- if SHIP.shipbattle #$data_enemies[$game_troop.members[0].enemy_id].note =~ /<shipbattle>/i
- $game_party.add_actor(SHIP.shipactorid)
- $game_system.battle_member_size = 1
- $game_party.swap_order(0,@partylast)
- end
- ship_start
- end
- ## end battle ##
- def terminate
- super
- dispose_spriteset
- @info_viewport.dispose
- RPG::ME.stop
- if SHIP.shipbattle #$data_enemies[$game_troop.members[0].enemy_id].note =~ /<shipbattle>/i
- $game_system.battle_member_size = SHIP::PARTYSIZE
- $game_party.swap_order(0,@partylast)
- $game_party.remove_actor(SHIP.shipactorid)
- end
- if SHIP.captainbattle >= 1
- BattleManager.setup(SHIP.captainbattle, true, true)
- BattleManager.save_bgm_and_bgs
- BattleManager.play_battle_bgm
- SceneManager.call(Scene_Battle)
- end
- end
- end
- ##### ship version of the normal status screen #####
- class Window_ShipStatus < Window_Selectable
- ## Initialization ##
- def initialize(x, y)
- super(x, y, 204, Graphics.height-y)
- @actor = SHIP.shipactor
- @temp_actor = nil
- refresh
- end
- ## get lines to show ##
- def visible_line_number
- return 7
- end
- ## sets actor ##
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- ## refresh ##
- def refresh
- contents.clear
- #draw_actor_bust(@actor, 4, 0)
- draw_actor_icons(@actor, 0, 0)
- draw_actor_face(@actor, 40, 15)
- draw_actor_name(@actor, 40, 120 + line_height * 0)
- draw_actor_hp(@actor, 0, 120 + line_height * 1, 180)
- draw_actor_mp(@actor, 0, 120 + line_height * 2, 180)
- 6.times {|i| draw_item(0, line_height * (1 + i) + 120 + line_height * 2, 2 + i) }
- end
- ## temp actor to show changes ##
- def set_temp_actor(temp_actor)
- return if @temp_actor == temp_actor
- @temp_actor = temp_actor
- refresh
- end
- ## draw item ##
- def draw_item(x, y, param_id)
- draw_param_name(x + 4, y, param_id)
- draw_current_param(x + 94, y, param_id) if @actor
- draw_right_arrow(x + 126, y)
- draw_new_param(x + 150, y, param_id) if @temp_actor
- end
- ## draw name, current, arrow and new ##
- def draw_param_name(x, y, param_id)
- change_color(system_color)
- draw_text(x, y, 80, line_height, Vocab::param(param_id))
- end
- def draw_current_param(x, y, param_id)
- change_color(normal_color)
- draw_text(x, y, 32, line_height, @actor.param(param_id), 2)
- end
- def draw_right_arrow(x, y)
- change_color(system_color)
- draw_text(x, y, 22, line_height, "→", 1)
- end
- def draw_new_param(x, y, param_id)
- new_value = @temp_actor.param(param_id)
- change_color(param_change_color(new_value - @actor.param(param_id)))
- draw_text(x, y, 32, line_height, new_value, 2)
- end
- end
- ##### new window with ship commands #####
- class Window_ShipCommand < Window_HorzCommand
- ## Initialization##
- def initialize(x, y, width)
- @window_width = width
- super(x, y)
- end
- ## Window Width ##
- def window_width
- @window_width
- end
- ## column count ##
- def col_max
- return 3
- end
- ## adds commands ##
- def make_command_list
- add_command("Equipment", :equip)
- add_command("Repair", :repair)
- add_command("Skills", :skills)
- end
- end
- ##### creates new window showing ship skills #####
- class Window_ShipSkillList < Window_SkillList
- ## Initialization ##
- def initialize(x, y, width, height)
- super
- @actor = SHIP.shipactor
- @stype_id = 0
- @data = []
- end
- ## column count ##
- def col_max
- return SHIP::SHIPCOL
- end
- end
- ##### rewrote to reduce column amount #####
- class Window_ShipEquipItem < Window_EquipItem
- def col_max
- return SHIP::SHIPCOL
- end
- end
- ##### creates new window whowing ships equipment slots #####
- class Window_ShipEquipSlot < Window_EquipSlot
- ## Initialization ##
- def initialize(x, y, width)
- super(x, y, width)
- @actor = SHIP.shipactor
- refresh
- end
- ## draws new ship slots ##
- def draw_item(index)
- rect = item_rect_for_text(index)
- change_color(system_color, enable?(index))
- draw_text(rect.x, rect.y, 120, line_height, slot_name(index))
- draw_item_name(@actor.equips[index], rect.x + 120, rect.y, enable?(index))
- end
- ## gets new ship slots form variables ##
- def slot_name(index)
- return SHIP::SHIPSLOTS[index]
- end
- end
RAW Paste Data