RPGVX.net
Alternative RPG-Maker => RPG-Maker XP => Thema gestartet von: GR-FoxDie am Januar 21, 2008, 19:02:36
-
Ein Coliseum wo man GP zu EXP umwandeln kann.
SDK wird gebraucht.
#==============================================================================
# ** FF3/6 Coliseum Script
#------------------------------------------------------------------------------
# Dargor
# 2006-11-11
# Version 1
#------------------------------------------------------------------------------
# * Instructions
# ~ To call the Scene
# - Iuse the call script command and type $scene = Scene_ColiseumItem.new
#
# For more instructions on how to use, refer to Module Coliseum
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('FF3/6 Coliseum Script', 'Dargor', 1, '2006-11-11')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('FF3/6 Coliseum Script') == true
#==========================================================================
====
# ** Module Coliseum
#------------------------------------------------------------------------------
# This module handles the coliseum items and rewards.
# To setup an item. follow the instructions bellow:
#------------------------------------------------------------------------------
# * Setup of Items/Weapons/Armors to exchange:
# @items[1] = [10,"W",20] This line means that if you select item #1 (@items[1]), thje you will fight
# troop #10 to win a weapon ("W") and the id of this weapon will be 20
# @items[id] = [troop, kind, id]
# Do the same thing for @armors & @weapons
#
# * Kind list:
# "I" => Item
# "W" => Weapon
# "A" => Armor
#
# * Changing Gold for Exp:
# The formula used to change Gold to Exp is: gp_amount /= 15
#
# * Changing the troops encountered for "Gold to Exp":
# Look for the gold_to_troop(gold) methode.
# when 0...100
# return 1
# The lines above means that if you selected an amount of gold between 0 and 100, you will fight
# against troop # 1
# If the script encounters an unspecified amount, you will fight against the default troop.
#
# * Changing the default settings:
# @default troop, @default_item & @default_kind are the variables used if the selected item has
# not been setup for the coliseum.
#==========================================================================
====
module Coliseum
#--------------------------------------------------------------------------
# ** Coliseum::Items
#--------------------------------------------------------------------------
class Items
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@items = []
@armors = []
@weapons = []
@item_to_win = nil
@gold_to_win = nil
@exp_to_win = nil
#--------------------------------------------------------------------------
# * Modify the variables bellow
#--------------------------------------------------------------------------
@default_troop = 1
@default_item = 1
@default_kind = "I"
@items[1] = [10,"W",20]
@weapons[1] = [5,"A",10]
@armors[1] = [15,"I",1]
end
attr_accessor :items
attr_accessor :armors
attr_accessor :weapons
attr_accessor :item_to_win
attr_accessor :gold_to_win
attr_accessor :exp_to_win
attr_accessor :default_troop
attr_accessor :default_item
attr_accessor :default_kind
#--------------------------------------------------------------------------
# * Gold To Troop
#--------------------------------------------------------------------------
def gold_to_troop(gold)
case gold
when 0...100
return 1
when 101...1000
return 2
when 1001...2000
return 3
when 2001...3000
return 4
when 3001...5000
return 5
when 5001...10000
return 6
when 10001...9999999
return 10
else
return @default_troop
end
end
end
#--------------------------------------------------------------------------
# ** Coliseum::Text
#--------------------------------------------------------------------------
class Text
def initialize
@command_item_help = "Select an item to exchange for another item."
@command_gold_help = "Select an amount of gold to exchange for experience points."
@win_message = "Congratulation! You win!"
@lose_message = "Sorry, you failed."
@cancel_message = "Come back anytime!"
end
attr_accessor :command_item_help
attr_accessor :command_gold_help
attr_accessor :win_message
attr_accessor :lose_message
attr_accessor :cancel_message
end
end
#==========================================================================
====
# ** Window_ItemToWin
#------------------------------------------------------------------------------
# This window displays the item to win.
#==========================================================================
====
class Window_ItemToWin < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# item : item
#--------------------------------------------------------------------------
def initialize(item)
super(24, 24, 240, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
@item = item
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
item_to_win
self.contents.font.color = normal_color
if $coliseum_items.exp_to_win != nil
text = $coliseum_items.exp_to_win /=15
self.contents.draw_text(28, 0, 240, 32, text.to_s)
else
self.contents.draw_text(28, 0, 240, 32, $coliseum_items.item_to_win.name)
end
end
def item_to_win
case @item
when RPG::Item
case $coliseum_items.items[@item.id][1]
when "I", "i"
$coliseum_items.item_to_win = $data_items[$coliseum_items.items[@item.id][2]]
when "W", "w"
$coliseum_items.item_to_win = $data_weapons[$coliseum_items.items[@item.id][2]]
when "A","a"
$coliseum_items.item_to_win = $data_armors[$coliseum_items.items[@item.id][2]]
end
when RPG::Weapon
case $coliseum_items.weapons[@item.id][1]
when "I", "i"
$coliseum_items.item_to_win = $data_items[$coliseum_items.items[@item.id][2]]
when "W", "w"
$coliseum_items.item_to_win = $data_weapons[$coliseum_items.items[@item.id][2]]
when "A","a"
$coliseum_items.item_to_win = $data_armors[$coliseum_items.items[@item.id][2]]
end
when RPG::Armor
case $coliseum_items.armors[@item.id][1]
when "I", "i"
$coliseum_items.item_to_win = $data_items[$coliseum_items.items[@item.id][2]]
when "W", "w"
$coliseum_items.item_to_win = $data_weapons[$coliseum_items.items[@item.id][2]]
when "A","a"
$coliseum_items.item_to_win = $data_armors[$coliseum_items.items[@item.id][2]]
end
end
rect = Rect.new(0, 0, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
item = $coliseum_items.item_to_win
if $coliseum_items.exp_to_win != nil
bitmap = RPG::Cache.icon("050-Skill07")
else
bitmap = RPG::Cache.icon(item.icon_name)
end
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
end
end
#==========================================================================
====
# ** Window_Status
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==========================================================================
====
class Window_SelectedItem < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(item)
super(640-264, 24, 240, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
@item = item
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
rect = Rect.new(0, 0, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
if $coliseum_items.exp_to_win != nil
self.contents.draw_text(28, 0, 240, 32, $coliseum_items.exp_to_win.to_s)
else
self.contents.draw_text(28,0,240,32,@item.name)
end
item = @item
if $coliseum_items.exp_to_win != nil
bitmap = RPG::Cache.icon("032-Item01")
else
bitmap = RPG::Cache.icon(item.icon_name)
end
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
end
end
class Window_TroopName < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(item)
super(200, 128, 240, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
@item = item
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
case @item
when RPG::Item
self.contents.draw_text(0,0,440,32,$data_troops[$coliseum_items.items[@item.id][0]].name)
when RPG::Weapon
self.contents.draw_text(0,0,440,32,$data_troops[$coliseum_items.weapons[@item.id][0]].name)
when RPG::Armor
self.contents.draw_text(0,0,440,32,$data_troops[$coliseum_items.armors[@item.id][0]].name)
end
end
end
#==========================================================================
====
# ** Window_PartyCommand
#------------------------------------------------------------------------------
# This window is used to select whether to fight or escape on the battle
# screen.
#==========================================================================
====
class Window_ColiseumCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
@commands = ["Item", "Gold"]#, "Exp"]
@item_max = 2
@column_max = 2
draw_item(0, normal_color)
draw_item(1, normal_color)
#draw_item(2, normal_color)
self.index = 0
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text character color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(160 + index * 160 + 4, 0, 128 - 10, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(160 + index * 160, 0, 128, 32)
end
end
#==========================================================================
====
# ** Window_Item
#------------------------------------------------------------------------------
# This window displays items in possession on the item and battle screens.
#==========================================================================
====
class Window_ColiseumItem < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 128, 640, 480-128)
@column_max = 2
refresh
self.index = 0
# If in battle, move window to center of screen
# and make it semi-transparent
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add item
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
# Also add weapons and items if outside of battle
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
end
# If item count is not 0, make a bit map and draw all items
@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
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
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 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 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
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==========================================================================
====
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs item screen processing.
#==========================================================================
====
class Scene_ColiseumItem
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make help window, item window
@help_window = Window_Help.new
@item_window = Window_ColiseumItem.new
@item_window.index = -1
@item_window.active = false
@command_window = Window_ColiseumCommand.new
@command_window.back_opacity = 255
@gold_window = Window_InputNumber.new(7)
@gold_window.x = 320 - @gold_window.width / 2
@gold_window.y = 240 - @gold_window.height / 2
@gold_window.opacity = 255
@gold_window.visible = false
@gold_window.active = false
# Associate help window
@item_window.help_window = @help_window
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@item_window.dispose
@command_window.dispose
@gold_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@help_window.update
@item_window.update
@command_window.update
@gold_window.update
# If item window is active: call update_item
if @item_window.active
update_item
return
end
# If gold window is active: call update_item
if @gold_window.active
update_gold
return
end
# If command window is active: call update_command
if @command_window.active
update_command
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
@item_window.active = true
@item_window.visible = true
@command_window.active = false
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
@item_window.active = false
@item_window.visible = false
@command_window.active = true
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
@item = @item_window.item
if $coliseum_items.items[@item.id] == nil
$coliseum_items.items[@item.id] = [$coliseum_items.default_troop,$coliseum_items.default_kind,$coliseum_items.default_item]
end
if $coliseum_items.weapons[@item.id] == nil
$coliseum_items.weapons[@item.id] = [$coliseum_items.default_troop,$coliseum_items.default_kind,$coliseum_items.default_item]
end
if $coliseum_items.armors[@item.id] == nil
$coliseum_items.armors[@item.id] = [$coliseum_items.default_troop,$coliseum_items.default_kind,$coliseum_items.default_item]
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
case @item
when RPG::Item
@troop = $coliseum_items.items[@item.id][0]
when RPG::Weapon
@troop = $coliseum_items.weapons[@item.id][0]
when RPG::Armor
@troop = $coliseum_items.armors[@item.id][0]
end
$scene = Scene_Coliseum.new(@item, @troop,nil)
end
end
def update_gold
@command_window.active = false
@gold_window.active = true
@gold_window.visible = true
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
@gold_window.active = false
@gold_window.visible = false
@command_window.active = true
return
end
# If C button was pressed
if Input.trigger?(Input::C)
$coliseum_items.exp_to_win = @gold_window.number
@troop = $coliseum_items.gold_to_troop($coliseum_items.exp_to_win) #transfer the amount of gold to a troop ID
$scene = Scene_Coliseum.new(nil, @troop,$coliseum_items.exp_to_win)
end
end
def update_command
case @command_window.index
when 0
@help_window.set_text($coliseum_text.command_item_help)
@item_window.visible = true
@gold_window.visible = false
when 1
@help_window.set_text($coliseum_text.command_gold_help)
@item_window.visible = false
@gold_window.visible = true
end
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
case @command_window.index
when 0
@item_window.index = 0
@item_window.active = true
@command_window.active = false
when 1
@gold_window.active = true
@command_window.active = false
end
end
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
end
end
#==========================================================================
====
# ** Scene_Battle (part 1)
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==========================================================================
====
class Scene_Coliseum
def initialize(item, troop,exp=nil)
@item = item
@troop = troop
@exp = exp
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Initialize each kind of temporary battle data
$game_temp.in_coliseum = true
$game_temp.battleback_name = $game_map.battleback_name
# Prepare troop
@troop_id = @troop
$game_troop.setup(@troop_id)
@window_status = Window_BattleStatus.new
if $coliseum_items.exp_to_win != nil
@selected_item = Window_SelectedItem.new(@exp)
@item_to_win = Window_ItemToWin.new(@exp/=15)
else
@selected_item = Window_SelectedItem.new(@item)
@item_to_win = Window_ItemToWin.new(@item)
end
@window_troop_name = Window_TroopName.new(@item)
@actors = []
for i in 0...$game_party.actors.size
@actors.push($game_party.actors[i].name)
end
@actor_window = Window_Command.new(160,@actors)
@actor_window.x = 240
@actor_window.y = 192
@actor_window.back_opacity = 160
@actor_window.height = 1 * 32 + 32
# Make sprite set
@spriteset = Spriteset_Battle.new
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@window_status.dispose
@item_to_win.dispose
@selected_item.dispose
@window_troop_name.dispose
@actor_window.dispose
# Dispose of sprite set
@spriteset.dispose
end
def update
# Update sprite set
@spriteset.update
@actor_window.update
if Input.trigger?(Input::C)
$temp_actors = []
$temp_actors = $game_party.actors.dup
# Set troop ID, can escape flag, and battleback
$game_temp.battle_troop_id = @troop
$game_temp.battle_can_escape = false
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
$game_party.actors = [$temp_actors[@actor_window.index]]
# Remove the selected things
if $coliseum_items.exp_to_win != nil
$game_party.lose_gold($coliseum_items.exp_to_win)
elsif @item.is_a?(RPG::Item)
$game_party.lose_item(@item.id,1)
elsif @item.is_a?(RPG::Weapon)
$game_party.lose_weapon(@item.id,1)
elsif @item.is_a?(RPG::Armor)
$game_party.lose_armor(@item.id,1)
end
# Switch to battle screen
$scene = Scene_Battle.new
end
end
end
#==========================================================================
====
# ** Game_Party
#==========================================================================
====
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :actors
end
#==========================================================================
====
# ** Game_Temp
#==========================================================================
====
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :in_coliseum # Returns to Battle Arena after Battle
attr_accessor :coliseum_win
alias coliseum_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Old Initialize Method
coliseum_init
# Adds Battle Arena Variables
@in_coliseum = false
@coliseum_win = false
end
end
#==========================================================================
====
# ** Scene_Battle (part 1)
#==========================================================================
====
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias coliseum_battle_end battle_end
alias coliseum_start_phase5 start_phase5
alias coliseum_judge judge
#--------------------------------------------------------------------------
# * Battle Ends
# result : results (0:win 1:lose 2:escape)
#--------------------------------------------------------------------------
def battle_end(result)
if $game_temp.in_coliseum
$game_party.actors = $temp_actors
# Clear in battle flag
$game_temp.in_battle = false
# Clear entire party actions flag
$game_party.clear_actions
# Remove battle states
for actor in $game_party.actors
actor.remove_states_battle
end
# Clear enemies
$game_troop.enemies.clear
# Call battle callback
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
# If Win
if result == 0
$game_temp.coliseum_win = true
# If Lose
else
$game_temp.coliseum_win = false
end
$game_system.bgm_play($game_temp.map_bgm)
# Proceeds to Coliseum
$scene = Scene_Map.new
return
end
# Old Battle End Method
coliseum_battle_end(result)
end
#--------------------------------------------------------------------------
# * Start After Battle Phase
#--------------------------------------------------------------------------
def start_phase5
if $game_temp.in_coliseum
#@treasures = []
if $coliseum_items.item_to_win != nil
treasures = $coliseum_items.item_to_win
case treasures
when RPG::Item
$game_party.gain_item(treasures.id, 1)
when RPG::Weapon
$game_party.gain_weapon(treasures.id, 1)
when RPG::Armor
$game_party.gain_armor(treasures.id, 1)
end
elsif $coliseum_items.exp_to_win != nil
$game_party.actors[0].exp += $coliseum_items.exp_to_win
end
# Make battle result window
#@result_window = Window_BattleResult.new(0, 0, treasures)
# Set wait count
@phase5_wait_count = 100
battle_end(0)
else
coliseum_start_phase5
end
end
#--------------------------------------------------------------------------
# * Determine Battle Win/Loss Results
#--------------------------------------------------------------------------
def judge
if $game_temp.in_coliseum
# If all dead determinant is true, or number of members in party is 0
if $game_party.all_dead? or $game_party.actors.size == 0
# If possible to lose
if $game_temp.battle_can_lose
# Return to BGM before battle starts
$game_system.bgm_play($game_temp.map_bgm)
# Battle ends
battle_end(2)
# Return true
return true
end
# Set game over flag
$game_party.actors = $temp_actors
$scene = Scene_Map.new
# Return true
return true
end
# Return false if even 1 enemy exists
for enemy in $game_troop.enemies
if enemy.exist?
return false
end
end
# Start after battle phase (win)
start_phase5
# Return true
return true
else
coliseum_judge
end
end
end
class Scene_Title
alias coliseum_new_game command_new_game
def command_new_game
$coliseum_items = Coliseum::Items.new
$coliseum_text = Coliseum::Text.new
coliseum_new_game
end
end
#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
end