ARMS Script
#1
ARMS Script
by El Conductor
v 2.0
Aug 4, 2007

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


The ARM's script is now finished. If you don't know what ARM's are,
they are special gun type weapons featured in the game Wild Arms.
This script lets you use these weapons in battle. The ARM's work
like skills. Each ARM has a different ATP, # of targets, Hit %, and
ammo. So if you have a game that features a gun user, instead of just
using skills for that character, with this script you can have that character
use ARM's.

You can also create and define your own ARMs in this script! Also, the
script has an ARM shop function built into it. The actual game didn't have
a shop, but since I added a shop to my Orb script, and it was pretty much
the same to add here, I put a shop. It's up to you if you want to use it or not.
There are 2 things you must do before the script will work. The script will
explain that.

One more important thing, to access the ARMs menu, just do the same
as if you were accessing a characters 'skills'. I did it this way because
the actual game was like that.

Just copy the script and place it above Main.

Code:
#|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

# ARM's Script |
#|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

# Author: El Conducter
# Date: August/06/07
# Version: 2.0
#|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


#----------------------------------------------------------------------------
# What it Does:
# For those of you not familiar with the Wild Arms series, ARM stands
# for Anceint Relic Machine, according to the first game. The ARM's in
# the game were powerful gun type weapons. In the game series, not
# all characters could use ARM's, only ones who knew how to use them.
#
# In this script I've created ARM's that are usable in battle by the
# character of your choosing! ARM's work like skills.
#
# With this script you can also create and define your own ARM's!
# All but one of the ARM's I included as default are ARM's from the
# first Wild Arms game.
#
# Unlike the game, where players could only find ARM's, I've added
# an ARM shop to this script as well! Use the shop if you want, or if you
# don't, that's fine too. It is just a function I added.
#----------------------------------------------------------------------------

#----------------------------------------------------------------------------
# How it Works: This script is organized into 5 parts.
#
# Part 1 defines ARM's and sets up the ARM database. The main points in Part 1 are:
#
# class Arm: defines a new object (an ARM)
# - id: The ARM's ID Number.
# - name: The Name of the ARM.
# - type: How many targets the ARM effects.
# There are three types; 1 = single; 2 = all; 3 = three targets.
# - accuracy: Chance the ARM will hit its target, from 0 to 100 percent.
# - arm_atp: The attack power of the ARM. The higher this number, the more damage it does.
# - ammo: Amount of ammo currently in ARM.
# - max_ammo: Total amount on ammo the ARM can carry.
# - animation1_id: The ARM users animation when firing
# - animation2_id: The target animation when being fired on
# - price: The amount of money the ARM buys and sells for
# - info: A discription of the ARM
#
# class Arms_Data: is the database where all the games ARM's are defined.
# The ARMs are set up in an array and assigned to the Constant, ARM_Database.
#
# - Define your ARMs within the ARM_Database array like so:
# Arm.new(id, name, type, accuracy, arm_atp, ammo, max_ammo, animation1_id, animation2_id, price, info)
#
# Part 2 consists of the window classes and scene that deals displaying ARMs.
# The classes that make up Part 2 are:
#
# - Scene_Arms
# - Window_Arms
#
# Part 3 contains the altered original code that deals with using ARMs in battle.
# Classes that had to altered are:
#
# - Scene_Battle 3
# - Scene_Battle 4
# - Scene_Battle 5 was added
# - Scene_BattleAction
# - Game_Battler 3
#
# Part 4 is made up of various altered original code that is necessary for the ARMs script
# These classes are:
#
# - Game_Party
# - Scene_Title
# - Scene_Menu
#
# Part 5 has all the classes that handle the buying and selling Arms:
#
# - Game_Temp
# - Scene_Arm_Shop
# - Window_Arm_Buy
# - Window_Arm_Sell
#----------------------------------------------------------------------------

#----------------------------------------------------------------------------
# How to Use This Script:
# Just copy it and paste it above Main.
#
# You need to specify which characters will be able to use ARMs. There
# are two things you must do.
#
# First, go to 'Scene_Battle' under
# - def update_phase3_basic_command; then look for
# - if Input.trigger?(Input::C); then look for;
# - when 1 # skill or ARM
# # If the active battler's ID is an ARM user, call ARM instead of skill
# if @active_battler.id == X
# In the code line that looks like the one above put the ID of the character
# you want to be able to use the ARM.
#
# Second, go to 'Scene_Menu', under 'def update_status' look for
# - if Input.trigger?(Input::C), now look for;
# - when 1 # skill or arm
# if $game_party.actors[@status_window.index].id == X
# Like in the first step you put the ID where X is.
#
# To add ARMs to your party's inventory while playing the game, use
# events Call Script function like this:
# - $game_party.gain_arm($data_arms[X])
# Where X stands, put the id of the ARM you want to add.
# ARM's ID's in the ARM database start with 0 and up.
#
# To reload ammo, use an Event Call Script; and type the following
#
# for i in 0...$game_party.arms.size
# $game_party.arms[i].ammo = $data_arms[i].max_ammo
# end
#
# To use the Shop function of this script, use events Call Script function
# like this:
# - $game_temp.shop_arms = [$data_arms[X], $data_arms[X]]
# - $scene = Scene_Arm_Shop.new
# Where X stands, put the id of the ARM you want to add. Just
# keep adding to the array how many ARMs you want to be able
# to buy. The second line actually calls the shop itself; using the
# ARMs you specified to buy.
#----------------------------------------------------------------------------

#----------------------------------------------------------------------------
# Modifications:
# The Arms script is fully customizable to fit the users needs. Alterations
# may be difficult though.
# - To be more true to the game, I plan on creating an ARM
# upgrade shop in the future.
#----------------------------------------------------------------------------

#----------------------------------------------------------------------------
# Comments:
# I design and comment my scripts to be easily understandable and modifiable.
# Use this script to learn RGSS better and become a better scriptor yourself.
#----------------------------------------------------------------------------


#******************************************************************************
# I Part One
#------------------------------------------------------------------------------
# This part deals with the construction of ARMs and sets up the ARM Database.
#******************************************************************************


#==============================================================================
# ** Arm
#------------------------------------------------------------------------------
# This class defines the ARM object.
#==============================================================================

module RPG

class Arm
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :id
attr_accessor :name
attr_accessor :type
attr_accessor :accuracy
attr_accessor :arm_atp
attr_accessor :ammo
attr_accessor :max_ammo
attr_accessor :animation1_id
attr_accessor :animation2_id
attr_accessor :price
attr_accessor :info
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(id, name, type, accuracy, arm_atp, ammo, max_ammo, animation1_id, animation2_id, price, info)
# Set parameters
@id = id
@name = name
@type = type
@accuracy = accuracy
@arm_atp = arm_atp
@ammo = ammo
@max_ammo = max_ammo
@animation1_id = animation1_id
@animation2_id = animation2_id
@price = price
@info = info
end
end

#==============================================================================
# ** Arms_Data
#------------------------------------------------------------------------------
# Stores all the games ARMs' data.
#==============================================================================

class Arms_Data

# This is the ARM database
# Define new Arms like so;
# Arm.new(id, name, type, accuracy, arm_atp, ammo, max_ammo, animation1_id, animation2_id, price, info)

ARM_Database = [

Arm.new(0, "Hand Cannon", 1, 99, 100, 8, 8, 1, 87, 1000, ".55 cal. magnum gun."),
Arm.new(1, "Shot Gun", 3, 70, 70, 7, 7, 1, 12, 1500, "30 gauge shot gun, hit multiple targets."),
Arm.new(2, "Rocket Launcher", 1, 90, 130, 6, 6, 1, 90, 2000, "Launches small explosive projectiles, one target."),
Arm.new(3, "Prisim Laser", 3, 75, 90, 6, 6, 1, 51, 3000, "Emits a spectrum of lasers, hit multiple targets."),
Arm.new(4, "Bazooka", 2, 70, 125, 4, 4, 1, 100, 4000, "Launches large explosive projectiles, hit all targets."),
Arm.new(5, "Wild Bunch", 1, 65, 220, 5, 5, 1, 67, 5000, "Creates an energy blade, single target."),
Arm.new(6, "Phaser", 1, 95, 180, 4, 4, 1, 73, 7000, "High energy weapon, hits one target."),
Arm.new(7, "Arch Smash", 2, 85, 175, 3, 3, 1, 52, 10000, "High energy weapon, hits all targets.")

]
end
end


#******************************************************************************
# II Part Two
#------------------------------------------------------------------------------
# This part deals with the windows and scene for displaying ARMs.
#******************************************************************************


#==============================================================================
# ** Scene_Arms
#------------------------------------------------------------------------------
# This class handles the windows that display the ARMS currently owned.
#==============================================================================

class Scene_Arms
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make help window
@arms_window = Window_Arms.new
# Make arms window
@help_window = Window_Help.new
# Associate help window to arms window
@arms_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
@arms_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@arms_window.update
@help_window.update
# If arms window is active: call update_arm
if @arms_window.active
update_arm
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when arm window is active)
#--------------------------------------------------------------------------
def update_arm
# 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
$scene = Scene_Menu.new(1)
return
end
end
end

#==============================================================================
# ** Window_Arms
#------------------------------------------------------------------------------
# This window displays ARMS in possession on the menu and battle screens.
#==============================================================================

class Window_Arms < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 416)
@column_max = 1
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 ARM
#--------------------------------------------------------------------------
def gun
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# For every ARM in party's inventory, they are sent to @data array
for i in 0...$game_party.arms.size
# @data is the array the window will use
@data.push($data_arms[i])
end
# If item count is not 0, make a bitmap 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
#--------------------------------------------------------------------------
def draw_item(index)
gun = @data[index]
x = 4
y = index * 32
rect = Rect.new(x, y, self.width, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon('006-Weapon06')
# if gun is out of ammo draw text in dark color
if gun.ammo == 0
self.contents.font.color = disabled_color
else
self.contents.font.color = normal_color
end
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, 250, 32, gun.name, 0)
self.contents.draw_text(x + 230, y, 100, 32, gun.arm_atp.to_s, 2)
self.contents.draw_text(x + 370, y, 100, 32, gun.accuracy.to_s, 2)
self.contents.draw_text(x + 500, y, 100, 32, gun.ammo.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(x + 195, y, 100, 32, "ATP", 2)
self.contents.draw_text(x + 345, y, 100, 32, "HIT%", 2)
self.contents.draw_text(x + 475, y, 100, 32, "AMMO", 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.gun == nil ? "" : self.gun.info)
end
end


#*******************************************************************************
****************
# III Part Three
#------------------------------------------------------------------------------
# This part contains all the changes to the original script that deal with using ARMs in battle.
#*******************************************************************************
****************


#==============================================================================
# ** Scene_Battle (part 3 and 4)
#------------------------------------------------------------------------------
# This contains the altered methods for ARM's.
#==============================================================================

class Scene_Battle
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : basic command)
#--------------------------------------------------------------------------
def update_phase3_basic_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Go to command input for previous actor
phase3_prior_actor
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by actor command window cursor position
case @actor_command_window.index
when 0 # attack
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
# Start enemy selection
start_enemy_select
when 1 # skill or ARM
# If the active battler's ID is an ARM user, call ARM instead of skill
if @active_battler.id == X
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 3
# Start ARM selection
start_arm_select
else # Call skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 1
# Start skill selection
start_skill_select
end
when 2 # guard
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
# Go to command input for next actor
phase3_next_actor
when 3 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 2
# Start item selection
start_item_select
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase)
#--------------------------------------------------------------------------
def update_phase3
# If enemy arrow is enabled
if @enemy_arrow != nil
update_phase3_enemy_select
# If actor arrow is enabled
elsif @actor_arrow != nil
update_phase3_actor_select
# If skill window is enabled
elsif @skill_window != nil
update_phase3_skill_select
# If item window is enabled
elsif @item_window != nil
update_phase3_item_select
# If arm window is enabled
elsif @arm_window != nil
update_phase3_arm_select
# If actor command window is enabled
elsif @actor_command_window.active
update_phase3_basic_command
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : actor selection)
#--------------------------------------------------------------------------
def update_phase3_actor_select
# Update actor arrow
@actor_arrow.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# End actor selection
end_actor_select
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.target_index = @actor_arrow.index
# End actor selection
end_actor_select
# If skill window is showing
if @skill_window != nil
# End skill selection
end_skill_select
end
# If item window is showing
if @item_window != nil
# End item selection
end_item_select
end
# If arm window is showing
if @arm_window != nil
# End arm selection
end_arm_select
end
# Go to command input for next actor
phase3_next_actor
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : enemy selection)
#--------------------------------------------------------------------------
def update_phase3_enemy_select
# Update enemy arrow
@enemy_arrow.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# End enemy selection
end_enemy_select
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.target_index = @enemy_arrow.index
# End enemy selection
end_enemy_select
# If skill window is showing
if @skill_window != nil
# End skill selection
end_skill_select
end
# If item window is showing
if @item_window != nil
# End item selection
end_item_select
end
# If arm window is showing
if @arm_window != nil
# End arm selection
end_arm_select
end
# Go to command input for next actor
phase3_next_actor
end
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 2 : start action)
#--------------------------------------------------------------------------
def update_phase4_step2
# If not a forcing action
unless @active_battler.current_action.forcing
# If restriction is [normal attack enemy] or [normal attack ally]
if @active_battler.restriction == 2 or @active_battler.restriction == 3
# Set attack as an action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
end
# If restriction is [cannot perform action]
if @active_battler.restriction == 4
# Clear battler being forced into action
$game_temp.forcing_battler = nil
# Shift to step 1
@phase4_step = 1
return
end
end
# Clear target battlers
@target_battlers = []
# Branch according to each action
case @active_battler.current_action.kind
when 0 # basic
make_basic_action_result
when 1 # skill
make_skill_action_result
when 2 # item
make_item_action_result
when 3 # arm
make_arm_action_result
end
# Shift to step 3
if @phase4_step == 2
@phase4_step = 3
end
end
end

#==============================================================================
# ** Scene_Battle (part 5)
#------------------------------------------------------------------------------
# New methods for ARM's system.
#==============================================================================

class Scene_Battle
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : ARM selection)
#--------------------------------------------------------------------------
def update_phase3_arm_select
# Make arm window visible
@arm_window.visible = true
# Update arm window
@arm_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# End skill selection
end_arm_select
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected ARM in the arm window
@gun = @arm_window.gun
# If ARM is out of ammo
if @gun.ammo == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.arm_id = @gun.id
# Make arm window invisible
@arm_window.visible = false
# Branch for gun type
case @gun.type
# When ARM type is one enemy
when 1
# Start enemy selection
start_enemy_select
# When ARM type is all enemies
when 2
# End arm selection
end_arm_select
# Go to command input for next actor
phase3_next_actor
# When ARM type is multiple targets
when 3
# Start enemy selection
start_enemy_select
end
return
end
end
#--------------------------------------------------------------------------
# * Start Arm Selection
#--------------------------------------------------------------------------
def start_arm_select
# Make arm window
@arm_window = Window_Arms.new
# Associate help window
@arm_window.help_window = @help_window
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# * End Arm Selection
#--------------------------------------------------------------------------
def end_arm_select
# Dispose of arm window
@arm_window.dispose
@arm_window = nil
# Hide help window
@help_window.visible = false
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
end
#--------------------------------------------------------------------------
# * Set Targeted Battler for ARM
# type : effect scope for ARM
#--------------------------------------------------------------------------
def set_gun_target_battlers(type)
# If battler performing action is actor
if @active_battler.is_a?(Game_Actor)
# Branch by type
case type
when 1 # Single enemy
index = @active_battler.current_action.target_index
@target_battlers.push($game_troop.smooth_target_enemy(index))
when 2 # All enemies
for enemy in $game_troop.enemies
if enemy.exist?
@target_battlers.push(enemy)
end
end
when 3 # Multiple enemies
index = @active_battler.current_action.target_index
index2 = @active_battler.current_action.target_index + 1
index3 = @active_battler.current_action.target_index - 1
@target_battlers.push($game_troop.smooth_target_enemy(index))
@target_battlers.push($game_troop.smooth_target_enemy(index2))
@target_battlers.push($game_troop.smooth_target_enemy(index3))
end
end
end
#--------------------------------------------------------------------------
# * Make ARM Action Results
#--------------------------------------------------------------------------
def make_arm_action_result
# Get ARM
@gun = $data_arms[@active_battler.current_action.arm_id]
# ARM lose 1 ammo per shot
@gun.ammo -= 1
# Refresh status window
@status_window.refresh
# Show Arm name on help window
@help_window.set_text(@gun.name, 1)
# Set animation ID
@animation1_id = @gun.animation1_id
@animation2_id = @gun.animation2_id
# Set target battlers
set_gun_target_battlers(@gun.type)
# Apply Arm effect
for target in @target_battlers
target.arm_effect(@active_battler, @gun)
end
end
end

#==============================================================================
# ** Game_Battler (part 3)
#------------------------------------------------------------------------------
# Added method; battle formula for ARM's
#==============================================================================

class Game_Battler
#--------------------------------------------------------------------------
# * Apply ARM Effects
# user : the one using ARM (battler)
# gun : ARM
#--------------------------------------------------------------------------
def arm_effect(user, gun)
# Set critical hit to false
self.critical = false
# First hit detection
hit_result = (rand(100) < user.hit)
# If attack hits
if hit_result == true
# Calculate damage
wp = gun.arm_atp
atk = [user.atk - self.pdef / 2, 0].max
self.damage = (atk + wp) * (user.int + user.dex) / 20
# If damage value is strictly positive
if self.damage > 0
# Critical factor
if rand(100) < 4 * user.dex / self.agi
self.damage *= 2
self.critical = true
end
# Guard factor
if self.guarding?
self.damage /= 2
end
end
# Dispersion
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# Second hit detection
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : gun.accuracy # ARMs' accuracy determines hit rate
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
# If hit occurs
if hit_result == true
# Remove Shock State
remove_states_shock
# Substract damage from HP
self.hp -= self.damage
else
# Set damage to "Miss"
self.damage = "Miss"
# Clear critical flag
self.critical = false
end
# End Method
return true
end
end

#==============================================================================
# ** Game_BattleAction
#==============================================================================

class Game_BattleAction
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
# Added variable
attr_accessor :arm_id
#--------------------------------------------------------------------------
# * Alias Method
#--------------------------------------------------------------------------
alias arm_game_battleaction_clear clear
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original initialize method
arm_game_battleaction_clear
# Added variable
@arm_id= 0
end
end


#******************************************************************************
# IV Part Four
#------------------------------------------------------------------------------
# This part contains all the changes to the original script that are non-battle related.
#******************************************************************************


#==============================================================================
# ** Game_Party
#==============================================================================

class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
# Added variable
attr_accessor :arms
#--------------------------------------------------------------------------
# * Alias Method
#--------------------------------------------------------------------------
alias arm_game_party_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original initialize method
arm_game_party_init
# Added arms array
# This array stores all the Arms in the party's inventory
@arms = []
end
#--------------------------------------------------------------------------
# Add an ARM to players inventory
#--------------------------------------------------------------------------
def gain_arm(arm_id)
@arms.push(arm_id)
@arms.sort! {|a, z| a.id <=> z.id}
end
end

#==============================================================================
# ** Scene_Menu
#==============================================================================

class Scene_Menu
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Status"
s5 = "Save"
s6 = "End Game"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
@command_window.disable_item(4)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(4)
end
# Make play time window
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 224
# Make steps window
@steps_window = Window_Steps.new
@steps_window.x = 0
@steps_window.y = 320
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# 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
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 1 # skill or arm
if $game_party.actors[@status_window.index].id == X
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to arms screen
$scene = Scene_Arms.new
else
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
end
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end

#==============================================================================
# ** Scene_Title
#==============================================================================

class Scene_Title
#--------------------------------------------------------------------------
# Alias Methods
#--------------------------------------------------------------------------
alias arm_scene_title_main main
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Load ARM database
$data_arms = RPG::Arms_Data::ARM_Database
# Original script
arm_scene_title_main
end
end


#******************************************************************************
# V Part Five
#------------------------------------------------------------------------------
# This part contains all classes that deal with buying and selling ARMs.
#******************************************************************************


#==============================================================================
# ** Game_Temp
#==============================================================================

class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
# Added variable
attr_accessor :shop_arms
#--------------------------------------------------------------------------
# * Alias Method
#--------------------------------------------------------------------------
alias arm_game_temp_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original method
arm_game_temp_init
# Added array for ARMs that the shop will sell
@shop_arms = []
end
end


#==============================================================================
# ** Scene_Arm_Shop
#------------------------------------------------------------------------------
# This class handles buying and selling Arms.
#==============================================================================

class Scene_Arm_Shop
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get arms for sale from $game_temp array
@arms_for_sale = $game_temp.shop_arms
# Make help window
@help_window = Window_Help.new
# Make command window
@command_window = Window_ShopCommand.new
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
# Make blank window
@blank_window = Window_Base.new(0, 128, 640, 352)
# Make buy window
@arm_buy_window = Window_Arm_Buy.new(@arms_for_sale)
@arm_buy_window.active = false
@arm_buy_window.visible = false
@arm_buy_window.help_window = @help_window
# Make sell window
@arm_sell_window = Window_Arm_Sell.new
@arm_sell_window.active = false
@arm_sell_window.visible = false
@arm_sell_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
@command_window.dispose
@gold_window.dispose
@blank_window.dispose
@arm_buy_window.dispose
@arm_sell_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@help_window.update
@command_window.update
@gold_window.update
@blank_window.update
@arm_buy_window.update
@arm_sell_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If buy window is active: call update_arm_buy
if @arm_buy_window.active
update_arm_buy
return
end
# If sell window is active: call update_arm_sell
if @arm_sell_window.active
update_arm_sell
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # buy
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to buy mode
@command_window.active = false
@blank_window.visible = false
@arm_buy_window.active = true
@arm_buy_window.visible = true
@arm_buy_window.refresh
when 1 # sell
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Change windows to sell mode
@command_window.active = false
@blank_window.visible = false
@arm_sell_window.active = true
@arm_sell_window.visible = true
@arm_sell_window.refresh
when 2 # quit
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to map screen
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when buy window is active)
#--------------------------------------------------------------------------
def update_arm_buy
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Go back to command window
@command_window.active = true
@blank_window.visible = true
@arm_buy_window.active = false
@arm_buy_window.visible = false
# Set help text to nothing
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get arm to buy
@gun = @arm_buy_window.gun
# If arm is nothing, or the if it costs more money than the player has
if @gun == nil or @gun.price > $game_party.gold
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play shop SE
$game_system.se_play($data_system.shop_se)
# Add Arm to players inventory
$game_party.gain_arm(@gun)
# Subtract money for purchase
$game_party.lose_gold(@gun.price)
# Remake gold and sell window contents
@gold_window.refresh
@arm_buy_window.refresh
end
end
#--------------------------------------------------------------------------
# * Frame Update (when sell window is active)
#--------------------------------------------------------------------------
def update_arm_sell
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Go back to command window
@command_window.active = true
@blank_window.visible = true
@arm_sell_window.active = false
@arm_sell_window.visible = false
# Set help text to nothing
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get ARM to sell
@gun = @arm_sell_window.gun
@index = @arm_sell_window.index
# If ARM is invalid, or ARM price is 0 (unable to sell)
if @gun == nil or @gun.price == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play shop SE
$game_system.se_play($data_system.shop_se)
# Add money from ARM sale
$game_party.gain_gold(@gun.price)
# Get rid of ARM from players inventory
$game_party.arms.delete_at(@index)
# Remake gold and sell window contents
@gold_window.refresh
@arm_sell_window.refresh
end
end
end

#==============================================================================
# ** Window_Arm_Buy
#------------------------------------------------------------------------------
# This window displays buyable Arms on the shop screen.
#==============================================================================

class Window_Arm_Buy < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(arms_for_sale)
super(0, 128, 368, 352)
@arms_for_sale = arms_for_sale
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Get the gun
#--------------------------------------------------------------------------
def gun
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# For every ARM in @arms_for_sale array send them to window array
for i in 0..@arms_for_sale.size
arm = @arms_for_sale[i]
if arm != nil
@data.push(arm)
end
end
# Sort Arms in alphabetical order by name
@data.sort! {|a, z| a.name <=> z.name}
# 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
#--------------------------------------------------------------------------
def draw_item(index)
arm = @data[index]
# If price is less than money in possession,
if arm.price <= $game_party.gold
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('006-Weapon06')
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, arm.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, arm.price.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.gun == nil ? "" : self.gun.info)
end
end

#==============================================================================
# ** Window_Arm_Sell
#------------------------------------------------------------------------------
# This window displays sellable Arms on the shop screen.
#==============================================================================

class Window_Arm_Sell < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(272, 128, 368, 352)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Arm Acquisition
#--------------------------------------------------------------------------
def gun
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# For every ARM in party's inventory, they are sent to @data array
for i in 0...$game_party.arms.size
@data.push($game_party.arms[i])
end
# If item count is not 0, make a bitmap 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
#--------------------------------------------------------------------------
def draw_item(index)
arm = @data[index]
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('006-Weapon06')
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, arm.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, arm.price.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.gun == nil ? "" : self.gun.info)
end
end
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Steal and Mug Script Lethrface 0 3,039 08-08-2011, 01:00 PM
Last Post: Lethrface
  Book Script and Utility Bruth 0 2,736 06-10-2009, 01:00 PM
Last Post: Bruth
  Custom EXP Script Dargor 0 2,557 11-24-2007, 01:00 PM
Last Post: Dargor
  Clan Script ShockWave 0 2,611 08-27-2007, 01:00 PM
Last Post: ShockWave
  Juke Box Script polraudio 0 2,728 06-17-2007, 01:00 PM
Last Post: polraudio
  Quest Script Samo the thief 0 2,558 03-12-2007, 01:00 PM
Last Post: Samo the thief
  Quest Script by SAMO Samo the thief 0 2,519 12-29-2006, 01:00 PM
Last Post: Samo the thief
  An easier WORKING party change script The Ghost 0 2,490 07-09-2006, 01:00 PM
Last Post: The Ghost
  Mission Script Leon Westbrooke 0 2,723 07-04-2006, 01:00 PM
Last Post: Leon Westbrooke
  Mining Script GoldenShadow 0 2,500 03-05-2006, 01:00 PM
Last Post: GoldenShadow



Users browsing this thread: 1 Guest(s)