#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# * Pokémon System
# "The base for Pokémon Games"
#==============================================================================
# Author Freakboy
# Version 1.0
#------------------------------------------------------------------------------
# This Version Includes
#
# * Game Datebase
# - Pokemon
# - Items
# - Moves
# * Game Classes
# - Trainer
# - Settings
# * Modules
# - Battle (Formula / Calculating)
# * System
# - Menu
# * Additional Scripts
#
#==============================================================================
# Last Updated 28/11/06 (DD/MM/YYYY)
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# ** Start Game Database
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
#==============================================================================
# ** Pokémon
#------------------------------------------------------------------------------
# This class handles pokémon data
#==============================================================================
class Pokemon
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :name, :nickname, :id, :level, :trainer_id,
:hp, :attack, :defence, :speed,
:special_attack, :special_defence,
:special,
:skills, :skills_learned,
:base_stats, :exp_now, :exp_next,
:stats_plus,
:height, :weight, :gender,
:catch_rate, :growth_rate,
:bitmap
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(object_id, level)
@id = object_id
@level = level
@trainer_id = $game_trainer.id
@skills = [ ]
@skills_learned = [ ]
@base_stats = { }
@stats_plus = { }
@height = 0
@weight = 0
@gender = 'Male'
# Call Setup Method to Define each stats, moves, etc.
setup()
end
#--------------------------------------------------------------------------
# * Health Points | Returns the Current HP
#--------------------------------------------------------------------------
def hp
# Sets a minimum of 0 health and maximum maxhp (method)
@hp = [[@hp, 0].max, maxhp()].min
end
#--------------------------------------------------------------------------
# * Maximum Health Points | Returns the Maximum HP
#--------------------------------------------------------------------------
def maxhp
stat = @base_stats['HP']
return Integer(((stat*2)*@level/100)+10) + @stats_plus['HP']
end
#--------------------------------------------------------------------------
# * Level | Returns the Current Level
#--------------------------------------------------------------------------
def level
# Set a minimum of 0 and a maximum of 99
@level = [[@level, 0].max, 99].min
end
#--------------------------------------------------------------------------
# * Skill | Get a Skill by Index
#--------------------------------------------------------------------------
def skill(index)
return @skills[index]
end
#--------------------------------------------------------------------------
# * Setup | Define each Pokémon by ID
#--------------------------------------------------------------------------
def setup
# Branch each Pokémon by ID
case @id
when 1
@name = 'Bulbasaur'
@base_stats = { 'HP' =>45, 'ATK'=>49, 'DEF'=>49, 'SPD'=>65,
'SPATK'=>65, 'SPDEF'=>65, 'SPC'=>65 }
@catch_rate = 45
@growth_rate = 'Parabolic'
end
# Setup each Stats
setup_variables()
end
#--------------------------------------------------------------------------
# * Setup Stats
#--------------------------------------------------------------------------
def setup_stats
# Check if Stats Plus is defined
if (@stats_plus.empty?)
# Get each stat point
for key in ['HP', 'ATK', 'DEF', 'SPD', 'SPATK', 'SPDEF', 'SPC']
# Set each stat points to 0
@stats_plus[key] = 0
end
end
end
#--------------------------------------------------------------------------
# * Setup Variables
#--------------------------------------------------------------------------
def setup_variables
# Setup each variable (hp, attack, defence)
setup_stats()
setup_health()
setup_attack()
setup_defence()
setup_speed()
setup_special_attack()
setup_special_defence()
setup_special()
end
#--------------------------------------------------------------------------
# * Setup Health
#--------------------------------------------------------------------------
def setup_health
# Only change HP if it's empty
if (@hp == nil)
@hp = maxhp()
end
end
#--------------------------------------------------------------------------
# * Setup Attack
#--------------------------------------------------------------------------
def setup_attack
stat = @base_stats['ATK']
@attack = Integer((stat*2)*@level/100) + @stats_plus['ATK']
end
#--------------------------------------------------------------------------
# * Setup Defence
#--------------------------------------------------------------------------
def setup_defence
stat = @base_stats['DEF']
@defence = Integer((stat*2)*@level/100) + @stats_plus['DEF']
end
#--------------------------------------------------------------------------
# * Setup Speed
#--------------------------------------------------------------------------
def setup_speed
stat = @base_stats['SPD']
@speed = Integer((stat*2)*@level/100) + @stats_plus['SPD']
end
#--------------------------------------------------------------------------
# * Setup Special Attack
#--------------------------------------------------------------------------
def setup_special_attack
stat = @base_stats['SPATK']
@special_attack = Integer((stat*2)*@level/100) + @stats_plus['SPATK']
end
#--------------------------------------------------------------------------
# * Setup Special Defence
#--------------------------------------------------------------------------
def setup_special_defence
stat = @base_stats['SPDEF']
@special_defence = Integer((stat*2)*@level/100) + @stats_plus['SPDEF']
end
#--------------------------------------------------------------------------
# * Setup Special
#--------------------------------------------------------------------------
def setup_special
stat = @base_stats['SPC']
@special = Integer((stat*2)*@level/100) + @stats_plus['SPC']
end
#--------------------------------------------------------------------------
# * Setup EXP
#--------------------------------------------------------------------------
def setup_exp
l = @level
case @growth_rate
when 'Medium'
@exp_now = (l ** 3)
@exp_next = ((l + 1) ** 3)
when 'Fast'
@exp_now = (4 / 5 * (l ** 3))
@exp_next = (4 / 5 * ((l + 1) ** 3))
when 'Slow'
@exp_now = (5 / 4 * (l ** 3))
@exp_next = (5 / 4 * ((l + 1) ** 3))
when 'Parabolic'
@exp_now = ((6 / 5) * (l ** 3) - (15 * (l ** 2) - (100 * l) - 140)
@exp_next = ((6 / 5) * (l + 1) ** 3) - (15 * (l + 1) ** 2) - (100 * (l + 1)) - 140)
end
end
#--------------------------------------------------------------------------
# * Setup Moves
#--------------------------------------------------------------------------
def setup_moves
# Add each Move by Pokémon ID
case @id
when 1 # Bulbasaur
# Define Move : Tackle
move = Move.new(1)
# Add Move
@moves.push(move) if @moves.size
# Set Move Learned to 'true'
@skill_learn[move.id] = true
# If Level is Equal or Above 4
if (@level >= 4 && !@skill_learned[2])
# Define Move : Growl
move = Move.new(2)
# Add Move
@moves.push(move)
# Set Move Learned to 'true'
@skill_learn[move.id] = true
end
# If the Level is Equal or Above
if (@level >= 7 && !@skill_learned[5])
# Define Move : Leech Seed
move = Move.new(5)
# Add Move
@moves.push(move)
# Set Move Learned to 'true'
@skill_learn[move.id] = true
end
# If the Level is Equal or Above 10
if (@level >= 10 && !@skill_learned[10])
# Define Move : Vine Whip
move = Move.new(6)
# Add Move
@moves.push(move)
# Set Move Learned to 'true'
@skill_learn[move.id] = true
end
else
print 'Pokemon Moves not Defined! [class Pokemon, method setup_moves]'
return
end
end
#--------------------------------------------------------------------------
# * Add Stat Points | Additional Stat Points
#--------------------------------------------------------------------------
def add_stats(key, value)
# Get the original value
n = @stats_plus[key]
# Add New Value
@stats_plus[key] = [[n+value, 0].max, 5].min
end
#--------------------------------------------------------------------------
# * Remove Stat Points
#--------------------------------------------------------------------------
def remove_stats(key, value)
# Reverse the value and call add_stats
add_stats(key, -value)
end
#--------------------------------------------------------------------------
# * Next EXP
#--------------------------------------------------------------------------
def next_exp
l = @level
case @growth_rate
when 'Medium'
@exp_next = ((l + 1) ** 3)
when 'Fast'
@exp_next = (4 / 5 * ((l + 1) ** 3))
when 'Slow'
@exp_next = (5 / 4 * ((l + 1) ** 3))
when 'Parabolic'
@exp_next = (((6 / 5) * (l + 1) ** 3) - (15 * (l + 1) ** 2) - (100 * (l + 1)) - 140)
end
end
#--------------------------------------------------------------------------
# * Set Bitmap | Load Bitmaps From Game/Graphics/Battlers/(Front/Back)
#--------------------------------------------------------------------------
def bitmap=(file, view='back')
@bitmap = RPG::Cache.battler("/#{view}/#{file}")
end
#--------------------------------------------------------------------------
# * Level Up ?
#--------------------------------------------------------------------------
def level_up?
# Check if the Pokémon levels up
if (@exp_now >= @exp_next)
# The Pokemon does level up
return true
end
# The Pokémon doesn't level up
return false
end
end
#==============================================================================
# ** Moves
#------------------------------------------------------------------------------
# This class handles pokémon movement data.
#==============================================================================
class Move
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :id, :name, :pp, :maxhp,
:damage, :accuracy, :type,
:animation
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(object_id)
@id = object_id
setup_moves()
end
#--------------------------------------------------------------------------
# * Setup Moves
#--------------------------------------------------------------------------
def setup_moves
# Branch each Move by ID
case @id
when 1
@name = 'Tackle'
@pp = 35
@maxpp = 35
@damage = 40
@accuracy = 255
@type = ['normal']
when 2
@name = 'Growl'
@pp = 40
@maxpp = 40
@damage = 0
@accuracy = 255
@type = ['normal']
when 3
@name = 'Leer'
@pp = 30
@maxpp = 30
@damage = 0
@accuracy = 255
@type = ['normal']
when 4
@name = 'Scratch'
@pp = 35
@maxpp = 35
@damage = 40
@accuracy = 255
@type = ['normal']
when 5
@name = 'Leech Seed'
@pp = 10
@maxpp = 10
@damage = 0
@accuracy = 229
@type = ['grass']
when 6
@name = 'Vine Whip'
@pp = 10
@maxpp = 10
@damage = 35
@accuracy = 255
@type = ['grass']
end
end
end
#==============================================================================
# ** Items
#------------------------------------------------------------------------------
# This class handles pokémon item data.
#==============================================================================
class Item
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :id, :name, :effect, :icon
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(object_id)
@id = object_id
setup_items()
end
#--------------------------------------------------------------------------
# * Setup Items
#--------------------------------------------------------------------------
def setup_items
# Branch each Item by ID
case @id
when 0
@name = 'Potion'
@effect = { 'hp' => 20 }
when 1
@name = 'Super Potion'
@effect = { 'hp' => 50 }
end
@icon = @name.dup
end
end
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# ** End Game DataBase
#------------------------------------------------------------------------------
# ** Start Game Classes
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
#==============================================================================
# ** Game Trainer
#------------------------------------------------------------------------------
# This class handles trainer data
#==============================================================================
class Game_Trainer
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :name, :id, :money
attr_accessor :pokemon
attr_accessor :items, :keyitems, :pokeballs
attr_accessor :storage, :fishing
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@name = ''
@id = generate_id(6)
@money = 0
@pokemon = [ ]
@items = { }
@keyitems = { }
@pokeballs = { }
@fishing = false
setup_storage(10)
end
#--------------------------------------------------------------------------
# * Trainer Name
#--------------------------------------------------------------------------
def name
# Returns the name of the first actor in party
return $game_party.actors[0].name
end
#--------------------------------------------------------------------------
# * Generate Trainer ID
#--------------------------------------------------------------------------
def generate_id(digits)
# Set an empty string
id = ''
# Create a small loop depending on the number of digits
digits.times do
# Add a number from 1 to 9
id += (rand(8)+1).to_s
end
# Return a random ID (Integer)
return id.to_i
end
#--------------------------------------------------------------------------
# * Setup Storage Boxes | Size is Number of Storage Boxes
#--------------------------------------------------------------------------
def setup_storage(size)
# Create an Array to get hold of each Storage Box
@storage = [ ]
# Start at the First Box
index = 0
# Create a loop untill the Last Storage Box is reached
while (index <= size)
# Set each storage box an Array
@storage[index] = [ ]
# Go to the Next Storage Box
index += 1
end
end
#--------------------------------------------------------------------------
# * Party Full?
#--------------------------------------------------------------------------
def party_full?
# If the Party Size is 6
if (@pokemon.size == 6)
# The Party is Full
return true
end
# The Party is not Full
return false
end
#--------------------------------------------------------------------------
# * Fishing?
#--------------------------------------------------------------------------
def fishing?
return @fishing
end
#--------------------------------------------------------------------------
# * Add Pokemon
#--------------------------------------------------------------------------
def add_pokemon(id, level)
# Get the Pokemon
pokemon = Pokemon.new(id, level)
# Check wether the part is full or not
if (not party_full?)
# Add the pokemon in the Party
@pokemon.push(pokemon)
else
# Index is the ID-Number of the Storage Box
index = 0
# If the Storage Box is full
while (@storage[index].size == 30)
# Get the next Box
index += 1
end
# Add the Pokemon in the Storage Box
@storage[index].push(pokemon)
end
end
#--------------------------------------------------------------------------
# * Remove Pokemon
#--------------------------------------------------------------------------
def remove_pokemon(index)
# If the Pokemon is does excist in the party
unless (@pokemon[index] == nil)
# Remove it from the party
@pokemon.delete_at(index)
end
end
#--------------------------------------------------------------------------
# * Add Item
#--------------------------------------------------------------------------
def add_item(item_id, number)
# If the item is not created
if (@items[item_id] == nil)
# Set the quantity to 0
@items[item_id] = 0
end
# Update quantity data in the hash.
@items[item_id] = [[item_number(item_id) + number, 0].max, 99].min
end
#--------------------------------------------------------------------------
# * Item Number
#--------------------------------------------------------------------------
def item_number(item_id)
# If quantity data is in the hash, use it. If not, return 0
return @items.include?(item_id) ? @items[item_id] : 0
end
#--------------------------------------------------------------------------
# * Lose Item
#--------------------------------------------------------------------------
def lose_item(item_id, number)
# Reverse the numerical value and call it add_item
add_item(item_id, -number)
end
#--------------------------------------------------------------------------
# * Add Keyitem
#--------------------------------------------------------------------------
def add_keyitem(item_id)
# If the keyitem is not in the hash
unless (@keyitems.include?(item_id))
# Add it in the hash
@keyitems[item_id] = true
end
end
#--------------------------------------------------------------------------
# * Remove Keyitem
#--------------------------------------------------------------------------
def remove_keyitem(item_id)
# If the Keyitem is in the hash
if (@keyitems.include?(item_id))
@keyitems[item_id] = false
end
end
#--------------------------------------------------------------------------
# * Add Pokeball
#--------------------------------------------------------------------------
def add_pokeball(item_id, number)
# If the pokeball is not created
if (@pokeball[item_id] == nil)
# Set the quantity to 0
@pokeballs[item_id] = 0
end
# Update quantity data in the hash.
@pokeballs[item_id] = [[pokeball_number(item_id) + number, 0].max, 99].min
end
#--------------------------------------------------------------------------
# * Pokeball Number
#--------------------------------------------------------------------------
def pokeball_number(item_id)
return @pokeballs.include?(item_id) ? @pokeballs[item_id] : 0
end
#--------------------------------------------------------------------------
# * Remove Pokeball
#--------------------------------------------------------------------------
def remove_pokeball(item_id, number)
# Reverse the numerical value and call it add_pokeball
add_pokeball(item_id, -number)
end
end
#==============================================================================
# ** Game Settings
#------------------------------------------------------------------------------
# This class handles various game settings
#==============================================================================
class Game_Settings
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :pokedex
attr_accessor :save
attr_accessor :menu_index
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@pokedex = false # Enable Pokedex in the Menu ?
@save = true # Enable / Disable Game Save
@menu_index = 0 # Store Menu Index (for callback)
end
#--------------------------------------------------------------------------
# * Returns if the Player can Save the Game
#--------------------------------------------------------------------------
def save_enabled?
return @save
end
end
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# ** End Game Classes
#------------------------------------------------------------------------------
# ** Start Module
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
#==============================================================================
# ** Module Battle
#------------------------------------------------------------------------------
# This module calculates battle formulas
#==============================================================================
module Battle
#--------------------------------------------------------------------------
# * EXP Given after Battle
# *link removed*
#--------------------------------------------------------------------------
def self.exp(opponent, type='wild')
# get the opponent's base experiance points, level
# and the battle type (either 'wild' or 'trainer')
e = opponent.base_exp
l = opponent.level
b = type == 'wild' ? 1 : 1.5
return Integer(((e * l) * b) / 7)
end
#--------------------------------------------------------------------------
# * Battle Damage Calculating
# *link removed*
#--------------------------------------------------------------------------
def self.damage(attacker, attacker_move, defender)
# Calculate Raw Damage
l = attacker.level
a = attacker_move.special == true ? attacker.attack : attacker.special_attack
b = attacker.base_damage
d = attacker_move.special == true ? attacker.defence : defender.special_defence
raw_damage = Integer(((2 * l / 5 + 2) * a * b / d) / 50 + 2)
# If Attacker's Type matches the Attack Move's Type
t = attacker.type == attacker_move.type ? 1.5 : 1.0
m = self.multiply(attack_move, defender)
r = Integer(rand(255-217)+217)
damage = Integer(((raw_damage * t) * m / 10) * r / 255)
return damage
end
#--------------------------------------------------------------------------
# * Battle Damage Multipliër
# *link removed*
#--------------------------------------------------------------------------
def self.multiply(attack_move, defender)
# If the multiply hash is not created
if @multiply == nil
# Create a New Multiply Hash
self.setup_multiply()
end
# Unless the Attacker's Move Type and Opponent's Type doesnt match
unless @multiply[attacker_move.type].has_key?(defender.type)
# Return the Multiply Value (Damage will Multiply with the Value)
return @multiply[attacker_move.type][defender.type]
else
# Otherwise nothing happens (Damage will Multiply with 1)
return 1
end
end
#--------------------------------------------------------------------------
# * Setup Multiply Hash
# *link removed*
#--------------------------------------------------------------------------
def self.setup_multiply
# Create an empty Hash
@multiply = { }
# Setup Multiply for 'Normal' Type Attacks
@multiply['normal'] = {
['bug', 'rock'] => 0.5, ['dark', 'rock'] => 0.5, ['fire', 'rock'] => 0.5,
['ghost'] => 0, ['ghost', 'posion'] => 0, ['ground', 'rock'] => 0.5,
['rock'] => 0.5, ['rock', 'flying'] => 0.5, ['rock', 'water'] => 0.5,
['steel', 'bug'] => 0.5, ['steel', 'electrick'] => 0.5,
['steel', 'flying'] => 0.5, ['steel', 'ground'] => 0.5
}
# Setup Multiply for 'Fire' Type Attacks
@multiply['fire'] = {
['bug'] => 2, ['bug', 'flying'] => 2, ['dark', 'fire'] => 0.5,
['dark', 'ice'] => 2, ['dark', 'rock'] => 0.5, ['dragon'] => 0.5,
['dragon', 'flying'] => 0.5, ['dragon', 'water'] => 0.25,
['electric', 'water'] => 0.5, ['fighting', 'bug'] => 2,
['fighting', 'water'] => 0.5, ['fire'] => 0.5,
['fire', 'flying'] => 0.5, ['fire', 'rock'] => 0.25,
['grass'] => 2, ['grass', 'bug'] => 4, ['grass', 'flying'] => 2,
['grass', 'posion'] => 2, ['ground', 'rock'] => 0.5,
['ground', 'water'] => 0.5, ['ice', 'flying'] => 2,
['posion', 'bug'] => 2, ['psychic', 'grass'] => 2,
['psychic', 'ice'] => 2, ['psychic', 'water'] => 0.5,
['rock'] => 0.5, ['rock', 'flying'] => 0.5, ['rock', 'water'] => 0.5,
['steel', 'bug'] => 4, ['steel', 'electric'] => 2,
['steel', 'flying'] => 2, ['steel', 'ground'] => 2,
['water'] => 0.5, ['water', 'flying'] => 0.5, ['water', 'posion'] => 0.5
}
# Setup Multiply for 'Water' Type Attacks
@multiply['water'] = {
}
# Setup Multiply for 'Electric' Type Attacks
@multiply['electric'] = {
}
# Setup Multiply for 'Grass' Type Attacks
@multiply['grass'] = {
}
# Setup Multiply for 'Ice' Type Attacks
@multiply['ice'] = {
}
# Setup Multiply for 'Fighting' Type Attacks
@multiply['fighting'] = {
}
# Setup Multiply for 'Posion' Type Attacks
@multiply['posion'] = {
}
# Setup Multiply for 'Ground' Type Attacks
@multiply['ground'] = {
}
# Setup Multiply for 'Flying' Type Attacks
@multiply['flying'] = {
}
# Setup Multiply for 'Psychic' Type Attacks
@multiply['psychic'] = {
}
# Setup Multiply for 'Bug' Type Attacks
@multiply['bug'] = {
}
# Setup Multiply for 'Rock' Type Attacks
@multiply['rock'] = {
}
# Setup Multiply for 'Ghost' Type Attacks
@multiply['ghost'] = {
}
# Setup Multiply for 'Dragon' Type Attacks
@multiply['dragon'] = {
}
# Setup Multiply for 'Dark' Type Attacks
@multiply['dark'] = {
}
# Setup Multiply for 'Steel' Type Attacks
@multiply['steel'] = {
}
end
#--------------------------------------------------------------------------
# * Catch?
#--------------------------------------------------------------------------
def self.catch?(pokemon, opponent, ball_type)
return rand(255) < self.catch_rate(pokemon, opponent, ball_type)
end
#--------------------------------------------------------------------------
# * Returns the Catch Rate
# *link removed*
#--------------------------------------------------------------------------
def self.catch_rate(pokemon, opponent, ball_type)
# Calculate the Catch Rate for Catching Wild Pokemons
a = pokemon.hp <= 255 ? pokemon.hp : ((pokemon.hp / 2) / 2)
b = pokemon.maxhp <= 255 ? pokemon.maxhp : ((pokemon.maxhp / 2) / 2)
c = opponent.catch_rate
case ball_type.name
when 'Master Ball'; return 255
when 'Poke Ball'; c *= 1
when 'Great Ball'; c *= 1.5
when 'Ultra Ball'; c *= 2
when 'Heavy Ball'
if (opponent.weight.between?(0, 100))
c += -20
elsif (opponent.weight.between?(100, 200))
c += 0
elsif (opponent.weight.between?(200, 300))
c += 20
elsif (opponent.weight >= 300)
c += 30
end
when 'Lure Ball'
if ($game_trainer.fishing?)
c *= 3
end
when 'Friend Ball' # loyalty = 200
when 'Fast Ball'
names = [
'Magnemite', 'Grimer', 'Tangela',
'Mr.Mime', 'Eevee', 'Porygon',
'Dratini', 'Dragonair'
]
if (names.include?(opponent.name))
c *= 4
end
when 'Moon Ball'
names = [
'Clefairy', 'Jigglypuff',
'Nidorino', 'Nidorina'
]
if (names.include?(opponent.name))
c *= 4
end
when 'Park Ball'; c *= 1.5
when 'Love Ball'
if (pokemon.gender != opponent.gender)
c *= 8
end
when 'Level Ball'
if (pokemon.hp > opponent.hp)
c *= 2
elsif ((pokemon.hp / 2) > opponent.hp)
c *= 4
elsif ((pokemon.hp / 4) > opponent.hp)
c *= 8
end
end
status = {
'asleep' => 10, 'frozen' => 10, 'paralyzed' => 5,
'posioned' => 5, 'burned' => 5
}
d = status.has_key?(opponent.status) ? status[opponent.status] : 0
return [Integer((((( (b * 4) - ( a * 2 )) * c ) / b ) + d + 1 ) / 256), 255].min
end
end
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# ** End Formula Modules
#------------------------------------------------------------------------------
# ** Start System Classes
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make Command Window
main_command_window
# Make Spriteset
main_spriteset_map
# 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 Window & Spriteset
@command_window.dispose
@spriteset.dispose
end
#--------------------------------------------------------------------------
# * Main Command Window
#--------------------------------------------------------------------------
def main_command_window
# Create an Array with the Standard functions
commands = [ $game_party.actors[0].name, 'Bag', 'Save', 'Options', 'Exit' ]
# Add "Pokemon" if the party size is bigger then 1
commands.insert(0, 'Pokemon') if $game_party.actors.size > 1
# Add "Pokedex" when Enabled
commands.insert(0, 'Pokedex') if $game_settings.pokedex
# Create the Command Window ( width, commands )
@command_window = Window_Command.new(124, commands)
# Change the 'x' position of the Command Window
@command_window.x = 640 - 124
# Change the 'z' layer of the Command Window
@command_window.z = 1000
# Change the Index of the Command Window
@command_window.index = $game_settings.menu_index
end
#--------------------------------------------------------------------------
# * Main Spriteset Map
#--------------------------------------------------------------------------
def main_spriteset_map
# Create a Spriteset
@spriteset = Spriteset_Map.new
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update Command Window
@command_window.update
# Update Spriteset
@spriteset.update
# 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)
# Remember the current menu index
$game_settings.menu_index = @command_window.index
# Branch by command window cursor position
case @command_window.commands[@command_window.index]
when 'Pokedex'
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Pokedex Scene
$scene = Scene_Pokedex
when 'Pokemon'
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Pokemon Selection Scene
$scene = Scene_Pokemon
when $game_party.actors[0].name
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Player Info Scene (Trainercard if not mistaken)
$scene = Scene_TrainerCard.new
when 'Bag'
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Item Scene
$scene = Scene_Item.new
when 'Save'
# If Save is Disabled
if !$game_settings.save_enabled?
# 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 Scene
$scene = Scene_Save.new
when 'Option'
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Option Scene
$scene = Scene_Option.new
when 'Exit'
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch back to Map
$scene = Scene_Map.new
end
return
end
end
end
#==============================================================================
# ** Window_TrainerCard
#------------------------------------------------------------------------------
# This window is used to display text in the trainercard
#==============================================================================
class Window_TrainerCard < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = 'Arial'
self.contents.font.size = 22
refresh()
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
w = 124
h = self.contents.font.size
# Draw Trainer Name
name = $game_trainer.name
self.contents.draw_text(0, 0, w, h, "Name")
self.contents.draw_text(0, 0, w, h, name, 2)
# Draw Amount of Money
money = $game_trainer.money
self.contents.draw_text(0, 32, w, h, "Money")
self.contents.draw_text(0, 32, w, h, money, 2)
# Draw Amount of Pokemon (including Storage)
number = 0
number += $game_trainer.pokemon.size
for i in 0...$game_trainer.storage.size
storage = $game_trainer.storage
number += storage.size
end
self.contents.draw_text(0, 64, w, h, "No. of Pokemon")
self.contents.draw_text(0, 64, w, h, number.to_s, 2)
end
end
#==============================================================================
# ** Scene_TrainerCard
#------------------------------------------------------------------------------
# This class performs trainercard screen processing.
#==============================================================================
class Scene_TrainerCard
def main
# Create a Viewport
@viewport = Viewport.new(0, 0, 640, 480)
# Create the Trainer Card Sprite
@trainercard_sprite = Sprite.new(@viewport)
@trainercard_sprite.bitmap = RPG::Cache.picture('trainercard')
# Create the Trainer Card Window
@trainercard_window = Window_TrainerCard.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 Viewport, Window & Sprite
@viewport.dispose
@trainercard_sprite.dispose
@trainercard_window.dispose
end
end
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# ** End System Classes
#------------------------------------------------------------------------------
# ** Start Additional Scripts
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :commands
end
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Alias
#--------------------------------------------------------------------------
alias scene_title_game_settings command_new_game
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
# Initialize $game_settings variable
$game_settings = Game_Settings.new
# Initialize $game_trainer variable
$game_trainer = Game_Trainer.new
# Call original Command New Game
scene_title_game_settings
end
end
#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Alias
#--------------------------------------------------------------------------
alias scene_save_game_settings write_save_data
#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
def write_save_data(file)
# Save $game_settings variable
Marshal.dump($game_settings, file)
# Save $game_trainer variable
Marshal.dump($game_trainer, file)
# Call original Write Save Data
scene_save_game_settings(file)
end
end
#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * Alias
#--------------------------------------------------------------------------
alias scene_load_game_settings read_save_data
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(file)
# Load $game_settings variable
$game_settings = Marshal.load(file)
# Load $game_settings variable
$game_trainer = Marshal.load(file)
# Call original Read Save Data
scene_load_game_settings(file)
end
end
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# ** End Additional Scripts
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡