Rubocop-inspired style tweaks

This commit is contained in:
Maruno17
2020-09-06 01:10:02 +01:00
parent 5073f86190
commit 6c4670eaa3
7 changed files with 329 additions and 365 deletions

View File

@@ -87,8 +87,8 @@ NO_SIGNPOSTS = []
# * The maximum length, in characters, that the player's name can be. # * The maximum length, in characters, that the player's name can be.
#=============================================================================== #===============================================================================
INITIAL_MONEY = 3000 INITIAL_MONEY = 3000
MAX_MONEY = 999999 MAX_MONEY = 999_999
MAX_COINS = 99999 MAX_COINS = 99_999
MAX_PLAYER_NAME_SIZE = 10 MAX_PLAYER_NAME_SIZE = 10
#=============================================================================== #===============================================================================
@@ -97,9 +97,9 @@ MAX_PLAYER_NAME_SIZE = 10
# associated trainer type will be named as whatever is in that variable. # associated trainer type will be named as whatever is in that variable.
#=============================================================================== #===============================================================================
RIVAL_NAMES = [ RIVAL_NAMES = [
[:RIVAL1,12], [:RIVAL1, 12],
[:RIVAL2,12], [:RIVAL2, 12],
[:CHAMPION,12] [:CHAMPION, 12]
] ]
#=============================================================================== #===============================================================================
@@ -155,7 +155,7 @@ SCALED_EXP_FORMULA = true
SPLIT_EXP_BETWEEN_GAINERS = false SPLIT_EXP_BETWEEN_GAINERS = false
ENABLE_CRITICAL_CAPTURES = false ENABLE_CRITICAL_CAPTURES = false
GAIN_EXP_FOR_CAPTURE = true GAIN_EXP_FOR_CAPTURE = true
MEGA_RINGS = [:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM] MEGA_RINGS = [:MEGARING, :MEGABRACELET, :MEGACUFF, :MEGACHARM]
#=============================================================================== #===============================================================================
# * The names of each pocket of the Bag. Leave the first entry blank. # * The names of each pocket of the Bag. Leave the first entry blank.
@@ -166,18 +166,18 @@ MEGA_RINGS = [:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM]
# first entry (the 0). # first entry (the 0).
#=============================================================================== #===============================================================================
def pbPocketNames; return ["", def pbPocketNames; return ["",
_INTL("Items"), _INTL("Items"),
_INTL("Medicine"), _INTL("Medicine"),
_INTL("Poké Balls"), _INTL("Poké Balls"),
_INTL("TMs & HMs"), _INTL("TMs & HMs"),
_INTL("Berries"), _INTL("Berries"),
_INTL("Mail"), _INTL("Mail"),
_INTL("Battle Items"), _INTL("Battle Items"),
_INTL("Key Items") _INTL("Key Items")
]; end ]; end
BAG_MAX_POCKET_SIZE = [0,-1,-1,-1,-1,-1,-1,-1,-1] BAG_MAX_POCKET_SIZE = [0, -1, -1, -1, -1, -1, -1, -1, -1]
BAG_MAX_PER_SLOT = 999 BAG_MAX_PER_SLOT = 999
BAG_POCKET_AUTO_SORT = [0,false,false,false,true,true,false,false,false] BAG_POCKET_AUTO_SORT = [0, false, false, false, true, true, false, false, false]
#=============================================================================== #===============================================================================
# * A set of arrays each containing details of a graphic to be shown on the # * A set of arrays each containing details of a graphic to be shown on the
@@ -190,8 +190,8 @@ BAG_POCKET_AUTO_SORT = [0,false,false,false,true,true,false,false,false]
# - The graphic will always (true) or never (false) be shown on a wall map. # - The graphic will always (true) or never (false) be shown on a wall map.
#=============================================================================== #===============================================================================
REGION_MAP_EXTRAS = [ REGION_MAP_EXTRAS = [
[0,51,16,15,"mapHiddenBerth",false], [0, 51, 16, 15, "mapHiddenBerth", false],
[0,52,20,14,"mapHiddenFaraday",false] [0, 52, 20, 14, "mapHiddenFaraday", false]
] ]
#=============================================================================== #===============================================================================
@@ -229,9 +229,9 @@ NUM_STORAGE_BOXES = 30
#=============================================================================== #===============================================================================
USE_CURRENT_REGION_DEX = false USE_CURRENT_REGION_DEX = false
def pbDexNames; return [ def pbDexNames; return [
[_INTL("Kanto Pokédex"),0], [_INTL("Kanto Pokédex"), 0],
[_INTL("Johto Pokédex"),1], [_INTL("Johto Pokédex"), 1],
_INTL("National Pokédex") _INTL("National Pokédex")
]; end ]; end
DEX_SHOWS_ALL_FORMS = false DEX_SHOWS_ALL_FORMS = false
DEXES_WITH_OFFSETS = [] DEXES_WITH_OFFSETS = []
@@ -250,27 +250,27 @@ DEXES_WITH_OFFSETS = []
# - Roaming areas specifically for this Pokémon (optional). # - Roaming areas specifically for this Pokémon (optional).
#=============================================================================== #===============================================================================
RoamingAreas = { RoamingAreas = {
5 => [21,28,31,39,41,44,47,66,69], 5 => [ 21, 28, 31, 39, 41, 44, 47, 66, 69],
21 => [5,28,31,39,41,44,47,66,69], 21 => [5, 28, 31, 39, 41, 44, 47, 66, 69],
28 => [5,21,31,39,41,44,47,66,69], 28 => [5, 21, 31, 39, 41, 44, 47, 66, 69],
31 => [5,21,28,39,41,44,47,66,69], 31 => [5, 21, 28, 39, 41, 44, 47, 66, 69],
39 => [5,21,28,31,41,44,47,66,69], 39 => [5, 21, 28, 31, 41, 44, 47, 66, 69],
41 => [5,21,28,31,39,44,47,66,69], 41 => [5, 21, 28, 31, 39, 44, 47, 66, 69],
44 => [5,21,28,31,39,41,47,66,69], 44 => [5, 21, 28, 31, 39, 41, 47, 66, 69],
47 => [5,21,28,31,39,41,44,66,69], 47 => [5, 21, 28, 31, 39, 41, 44, 66, 69],
66 => [5,21,28,31,39,41,44,47,69], 66 => [5, 21, 28, 31, 39, 41, 44, 47, 69],
69 => [5,21,28,31,39,41,44,47,66] 69 => [5, 21, 28, 31, 39, 41, 44, 47, 66 ]
} }
RoamingSpecies = [ RoamingSpecies = [
[:LATIAS, 30, 53, 0, "Battle roaming"], [:LATIAS, 30, 53, 0, "Battle roaming"],
[:LATIOS, 30, 53, 0, "Battle roaming"], [:LATIOS, 30, 53, 0, "Battle roaming"],
[:KYOGRE, 40, 54, 2, nil, { [:KYOGRE, 40, 54, 2, nil, {
2 => [21,31], 2 => [ 21, 31 ],
21 => [2,31,69], 21 => [2, 31, 69],
31 => [2,21,69], 31 => [2, 21, 69],
69 => [21,31] 69 => [ 21, 31 ]
}], }],
[:ENTEI, 40, 55, 1, nil] [:ENTEI, 40, 55, 1, nil]
] ]
#=============================================================================== #===============================================================================
@@ -283,10 +283,10 @@ RoamingSpecies = [
# - Maximum possible level (optional). # - Maximum possible level (optional).
#=============================================================================== #===============================================================================
POKE_RADAR_ENCOUNTERS = [ POKE_RADAR_ENCOUNTERS = [
[5, 20, :STARLY, 12, 15], [5, 20, :STARLY, 12, 15],
[21, 10, :STANTLER, 14], [21, 10, :STANTLER, 14],
[28, 20, :BUTTERFREE, 15, 18], [28, 20, :BUTTERFREE, 15, 18],
[28, 20, :BEEDRILL, 15, 18] [28, 20, :BEEDRILL, 15, 18]
] ]
#=============================================================================== #===============================================================================
@@ -348,6 +348,6 @@ PLANT_SPARKLE_ANIMATION_ID = 7
# languages to choose from. # languages to choose from.
#=============================================================================== #===============================================================================
LANGUAGES = [ LANGUAGES = [
# ["English","english.dat"], # ["English", "english.dat"],
# ["Deutsch","deutsch.dat"] # ["Deutsch", "deutsch.dat"]
] ]

View File

@@ -7,24 +7,20 @@ class Class
end end
end end
#=============================================================================== #===============================================================================
# module Comparable # module Comparable
#=============================================================================== #===============================================================================
unless Comparable.method_defined? :clamp unless Comparable.method_defined? :clamp
module Comparable module Comparable
def clamp(min, max) def clamp(min, max)
if max-min<0 if max - min < 0
raise ArgumentError("min argument must be smaller than max argument") raise ArgumentError("min argument must be smaller than max argument")
end end
return (self>max) ? max : (self<min) ? min : self return (self > max) ? max : (self < min) ? min : self
end end
end end
end end
#=============================================================================== #===============================================================================
# class Boolean # class Boolean
#=============================================================================== #===============================================================================
@@ -34,32 +30,30 @@ class Boolean
end end
end end
#=============================================================================== #===============================================================================
# class String # class String
#=============================================================================== #===============================================================================
class String class String
def starts_with?(str) def starts_with?(str)
proc = (self[0...str.length] == str) if self.length >= str.length proc = (self[0...str.length] == str) if self.length >= str.length
return proc ? proc : false return proc || false
end end
def ends_with?(str) def ends_with?(str)
e = self.length - 1 e = self.length - 1
proc = (self[(e-str.length)...e] == str) if self.length >= str.length proc = (self[(e-str.length)...e] == str) if self.length >= str.length
return proc ? proc : false return proc || false
end end
def starts_with_vowel? def starts_with_vowel?
return ['a','e','i','o','u'].include?(self[0,1].downcase) return ['a', 'e', 'i', 'o', 'u'].include?(self[0, 1].downcase)
end end
def first(n=1) def first(n = 1)
return self[0...n] return self[0...n]
end end
def last(n=1) def last(n = 1)
return self[-n..-1] || self return self[-n..-1] || self
end end
@@ -90,14 +84,14 @@ class String
return blank return blank
end end
def cut(bitmap,width) def cut(bitmap, width)
string = self string = self
width -= bitmap.text_size("...").width width -= bitmap.text_size("...").width
string_width = 0 string_width = 0
text = [] text = []
for char in string.scan(/./) for char in string.scan(/./)
wdh = bitmap.text_size(char).width wdh = bitmap.text_size(char).width
next if (wdh+string_width) > width next if (wdh + string_width) > width
string_width += wdh string_width += wdh
text.push(char) text.push(char)
end end
@@ -110,8 +104,6 @@ class String
end end
end end
#=============================================================================== #===============================================================================
# class Numeric # class Numeric
#=============================================================================== #===============================================================================
@@ -122,21 +114,17 @@ class Numeric
end end
end end
#=============================================================================== #===============================================================================
# class Integer # class Integer
#=============================================================================== #===============================================================================
class Integer class Integer
# Returns an array containing each digit of the number in turn. # Returns an array containing each digit of the number in turn.
def digits(base=10) def digits(base = 10)
quotient, remainder = divmod(base) quotient, remainder = divmod(base)
(quotient==0) ? [remainder] : quotient.digits(base).push(remainder) return (quotient == 0) ? [remainder] : quotient.digits(base).push(remainder)
end end
end end
#=============================================================================== #===============================================================================
# class Array # class Array
#=============================================================================== #===============================================================================
@@ -150,7 +138,7 @@ class Array
end end
def ^(other) # xor of two arrays def ^(other) # xor of two arrays
return (self|other)-(self&other) return (self|other) - (self&other)
end end
def shuffle def shuffle
@@ -158,15 +146,14 @@ class Array
end unless method_defined? :shuffle end unless method_defined? :shuffle
def shuffle! def shuffle!
(size-1).times do |i| (size - 1).times do |i|
r = i+rand(size-i) r = i + rand(size - i)
self[i], self[r] = self[r], self[i] self[i], self[r] = self[r], self[i]
end end
self self
end unless method_defined? :shuffle! end unless method_defined? :shuffle!
end end
#=============================================================================== #===============================================================================
# module Enumerable # module Enumerable
#=============================================================================== #===============================================================================
@@ -178,8 +165,6 @@ module Enumerable
end end
end end
#=============================================================================== #===============================================================================
# Kernel methods # Kernel methods
#=============================================================================== #===============================================================================

View File

@@ -1,308 +1,302 @@
################################################################################ #===============================================================================
# "Duel" mini-game # "Duel" mini-game
# Based on the Duel minigame by Alael # Based on the Duel minigame by Alael
################################################################################ #===============================================================================
begin
class DuelWindow < Window_AdvancedTextPokemon class DuelWindow < Window_AdvancedTextPokemon
attr_accessor :hp attr_reader :hp
attr_accessor :name attr_reader :name
attr_accessor :isEnemy attr_reader :is_enemy
def initialize(name,isEnemy) def initialize(name, is_enemy)
@hp = 10 @hp = 10
@name = name @name = name
@isEnemy = isEnemy @is_enemy = is_enemy
super("") super()
self.width = 160 self.width = 160
self.height = 96 self.height = 96
duelRefresh duel_refresh
end end
def hp=(value) def hp=(value)
@hp = value @hp = value
duelRefresh duel_refresh
end end
def name=(value) def name=(value)
@name = value @name = value
duelRefresh duel_refresh
end end
def isEnemy=(value) def is_enemy=(value)
@isEnemy = value @is_enemy = value
duelRefresh duel_refresh
end end
def duelRefresh def duel_refresh
nameColor = @isEnemy ? "<ar><c3=E00808,F8B870>" : "<c3=3050C8,A0C0F0>" name_color = @is_enemy ? "<ar><c3=E00808,F8B870>" : "<c3=3050C8,A0C0F0>"
hpColor = "<c3=209808,90F090>" hp_color = "<c3=209808,90F090>"
self.text = _INTL("{1}{2}\r\n{3}HP: {4}",nameColor,fmtescape(@name),hpColor,@hp) self.text = _INTL("{1}{2}\r\n{3}HP: {4}", name_color, fmtescape(@name), hp_color, @hp)
end end
end end
#===============================================================================
#
#===============================================================================
class PokemonDuel class PokemonDuel
def pbStartDuel(opponent,event) def pbStartDuel(opponent, event)
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height) @event = event
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999 @viewport.z = 99999
@sprites = {} @sprites = {}
@event = event @sprites["player"] = IconSprite.new(-128 - 32, 96, @viewport)
@sprites["player"] = IconSprite.new(-128-32,96,@viewport)
@sprites["player"].setBitmap(pbTrainerSpriteFile($Trainer.trainertype)) @sprites["player"].setBitmap(pbTrainerSpriteFile($Trainer.trainertype))
@sprites["opponent"] = IconSprite.new(Graphics.width+32,96,@viewport) @sprites["opponent"] = IconSprite.new(Graphics.width + 32, 96, @viewport)
@sprites["opponent"].setBitmap(pbTrainerSpriteFile(opponent.trainertype)) @sprites["opponent"].setBitmap(pbTrainerSpriteFile(opponent.trainertype))
@sprites["playerwindow"] = DuelWindow.new($Trainer.name,false) @sprites["playerwindow"] = DuelWindow.new($Trainer.name, false)
@sprites["playerwindow"].x = -@sprites["playerwindow"].width @sprites["playerwindow"].x = -@sprites["playerwindow"].width
@sprites["playerwindow"].viewport = @viewport @sprites["playerwindow"].viewport = @viewport
@sprites["opponentwindow"] = DuelWindow.new(opponent.name,true) @sprites["opponentwindow"] = DuelWindow.new(opponent.name, true)
@sprites["opponentwindow"].x = Graphics.width @sprites["opponentwindow"].x = Graphics.width
@sprites["opponentwindow"].viewport = @viewport @sprites["opponentwindow"].viewport = @viewport
pbWait(Graphics.frame_rate/2) pbWait(Graphics.frame_rate / 2)
distancePerFrame = 8*20/Graphics.frame_rate distance_per_frame = 8 * 20 / Graphics.frame_rate
while @sprites["player"].x<0 while @sprites["player"].x < 0
@sprites["player"].x += distancePerFrame @sprites["player"].x += distance_per_frame
@sprites["playerwindow"].x += distancePerFrame @sprites["playerwindow"].x += distance_per_frame
@sprites["opponent"].x -= distancePerFrame @sprites["opponent"].x -= distance_per_frame
@sprites["opponentwindow"].x -= distancePerFrame @sprites["opponentwindow"].x -= distandistance_per_framecePerFrame
Graphics.update Graphics.update
Input.update Input.update
pbUpdateSceneMap pbUpdateSceneMap
end end
@oldmovespeed = $game_player.move_speed @oldmovespeed = $game_player.move_speed
@oldeventspeed = event.move_speed @oldeventspeed = event.move_speed
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::DirectionFixOn]) PBMoveRoute::DirectionFixOn])
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::DirectionFixOn]) PBMoveRoute::DirectionFixOn])
pbWait(Graphics.frame_rate*3/4) pbWait(Graphics.frame_rate * 3 / 4)
end end
def pbDuel(opponent,event,speeches) def pbDuel(opponent, event, speeches)
pbStartDuel(opponent,event) pbStartDuel(opponent, event)
@hp = [10,10] @hp = [10, 10]
@special = [false,false] @special = [false, false]
decision = nil decision = nil
loop do loop do
@hp[0] = 0 if @hp[0]<0 @hp[0] = 0 if @hp[0] < 0
@hp[1] = 0 if @hp[1]<0 @hp[1] = 0 if @hp[1] < 0
pbRefresh pbRefresh
if @hp[0]<=0 if @hp[0] <= 0
decision = false decision = false
break break
elsif @hp[1]<=0 elsif @hp[1] <= 0
decision = true decision = true
break break
end end
action = 0 action = 0
scores = [3,4,4,2] scores = [3, 4, 4, 2]
choices = (@special[1]) ? 3 : 4 choices = (@special[1]) ? 3 : 4
scores[3] = 0 if @special[1] scores[3] = 0 if @special[1]
total = scores[0]+scores[1]+scores[2]+scores[3] total = scores[0] + scores[1] + scores[2] + scores[3]
if total<=0 if total <= 0
action = rand(choices) action = rand(choices)
else else
num = rand(total) num = rand(total)
cumtotal = 0 cumtotal = 0
for i in 0...4 for i in 0...4
cumtotal += scores[i] cumtotal += scores[i]
if num<cumtotal if num < cumtotal
action = i action = i
break break
end end
end end
end end
@special[1] = true if action==3 @special[1] = true if action == 3
pbMessage(_INTL("{1}: {2}",opponent.name,speeches[action*3+rand(3)])) pbMessage(_INTL("{1}: {2}", opponent.name, speeches[action * 3 + rand(3)]))
command = rand(4)
list = [ list = [
_INTL("DEFEND"), _INTL("DEFEND"),
_INTL("PRECISE ATTACK"), _INTL("PRECISE ATTACK"),
_INTL("FIERCE ATTACK") _INTL("FIERCE ATTACK")
] ]
if !@special[0] list.push(_INTL("SPECIAL ATTACK")) if !@special[0]
list.push(_INTL("SPECIAL ATTACK")) command = pbMessage(_INTL("Choose a command."), list, 0)
end @special[0] = true if command == 3
command = pbMessage(_INTL("Choose a command."),list,0) if action == 0 && command == 0
if command==3 pbMoveRoute($game_player, [
@special[0] = true PBMoveRoute::ScriptAsync, "moveRight90",
end PBMoveRoute::ScriptAsync, "moveLeft90",
if action==0 && command==0 PBMoveRoute::ScriptAsync, "moveLeft90",
pbMoveRoute($game_player,[ PBMoveRoute::ScriptAsync, "moveRight90"])
PBMoveRoute::ScriptAsync,"moveRight90", pbMoveRoute(event, [
PBMoveRoute::ScriptAsync,"moveLeft90", PBMoveRoute::ScriptAsync, "moveLeft90",
PBMoveRoute::ScriptAsync,"moveLeft90", PBMoveRoute::ScriptAsync, "moveRight90",
PBMoveRoute::ScriptAsync,"moveRight90"]) PBMoveRoute::ScriptAsync, "moveRight90",
pbMoveRoute(event,[ PBMoveRoute::ScriptAsync, "moveLeft90"])
PBMoveRoute::ScriptAsync,"moveLeft90", pbWait(Graphics.frame_rate / 2)
PBMoveRoute::ScriptAsync,"moveRight90",
PBMoveRoute::ScriptAsync,"moveRight90",
PBMoveRoute::ScriptAsync,"moveLeft90"])
pbWait(Graphics.frame_rate/2)
pbMessage(_INTL("You study each other's movements...")) pbMessage(_INTL("You study each other's movements..."))
elsif action==0 && command==1 elsif action == 0 && command == 1
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
pbWait(Graphics.frame_rate*4/10) pbWait(Graphics.frame_rate * 4 / 10)
pbShake(9,9,8) pbShake(9, 9, 8)
pbFlashScreens(false,true) pbFlashScreens(false, true)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Backward]) PBMoveRoute::Backward])
@hp[1] -= 1 @hp[1] -= 1
pbMessage(_INTL("Your attack was not blocked!")) pbMessage(_INTL("Your attack was not blocked!"))
elsif action==0 && command==2 elsif action == 0 && command == 2
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::ScriptAsync,"jumpForward"]) PBMoveRoute::ScriptAsync, "jumpForward"])
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::Backward]) PBMoveRoute::Backward])
pbWait(Graphics.frame_rate) pbWait(Graphics.frame_rate)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Backward]) PBMoveRoute::Backward])
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
pbMessage(_INTL("Your attack was evaded!")) pbMessage(_INTL("Your attack was evaded!"))
elsif (action==0 || action==1 || action==2) && command==3 elsif (action == 0 || action == 1 || action == 2) && command == 3
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::ScriptAsync,"jumpForward"]) PBMoveRoute::ScriptAsync, "jumpForward"])
pbWait(Graphics.frame_rate*4/10) pbWait(Graphics.frame_rate * 4 / 10)
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,5, PBMoveRoute::ChangeSpeed, 5,
PBMoveRoute::Backward, PBMoveRoute::Backward,
PBMoveRoute::ChangeSpeed,2]) PBMoveRoute::ChangeSpeed, 2])
pbWait(Graphics.frame_rate/2) pbWait(Graphics.frame_rate / 2)
pbShake(9,9,8) pbShake(9, 9, 8)
pbFlashScreens(false,true) pbFlashScreens(false, true)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Backward]) PBMoveRoute::Backward])
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
@hp[1] -= 3 @hp[1] -= 3
pbMessage(_INTL("You pierce through the opponent's defenses!")) pbMessage(_INTL("You pierce through the opponent's defenses!"))
elsif action==1 && command==0 elsif action == 1 && command == 0
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
pbWait(Graphics.frame_rate*4/10) pbWait(Graphics.frame_rate * 4 / 10)
pbShake(9,9,8) pbShake(9, 9, 8)
pbFlashScreens(true,false) pbFlashScreens(true, false)
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Backward]) PBMoveRoute::Backward])
@hp[0] -= 1 @hp[0] -= 1
pbMessage(_INTL("You fail to block the opponent's attack!")) pbMessage(_INTL("You fail to block the opponent's attack!"))
elsif action==1 && command==1 elsif action == 1 && command == 1
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
pbWait(Graphics.frame_rate*6/10) pbWait(Graphics.frame_rate * 6 / 10)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Backward]) PBMoveRoute::Backward])
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
pbWait(Graphics.frame_rate*6/10) pbWait(Graphics.frame_rate * 6 / 10)
pbMoveRoute(event,[PBMoveRoute::Backward]) pbMoveRoute(event, [PBMoveRoute::Backward])
pbMoveRoute($game_player,[PBMoveRoute::Forward]) pbMoveRoute($game_player, [PBMoveRoute::Forward])
pbWait(Graphics.frame_rate*6/10) pbWait(Graphics.frame_rate * 6 / 10)
pbMoveRoute($game_player,[PBMoveRoute::Backward]) pbMoveRoute($game_player, [PBMoveRoute::Backward])
pbMessage(_INTL("You cross blades with the opponent!")) pbMessage(_INTL("You cross blades with the opponent!"))
elsif (action==1 && command==2) || elsif (action == 1 && command == 2) ||
(action==2 && command==1) || (action == 2 && command == 1) ||
(action==2 && command==2) (action == 2 && command == 2)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::Backward, PBMoveRoute::Backward,
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::ScriptAsync,"jumpForward"]) PBMoveRoute::ScriptAsync, "jumpForward"])
pbWait(Graphics.frame_rate*8/10) pbWait(Graphics.frame_rate * 8 / 10)
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
pbWait(Graphics.frame_rate*9/10) pbWait(Graphics.frame_rate * 9 / 10)
pbShake(9,9,8) pbShake(9, 9, 8)
pbFlashScreens(true,true) pbFlashScreens(true, true)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::Backward, PBMoveRoute::Backward,
PBMoveRoute::ChangeSpeed,2]) PBMoveRoute::ChangeSpeed, 2])
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::Backward, PBMoveRoute::Backward,
PBMoveRoute::Backward, PBMoveRoute::Backward,
PBMoveRoute::ChangeSpeed,2]) PBMoveRoute::ChangeSpeed, 2])
pbWait(Graphics.frame_rate) pbWait(Graphics.frame_rate)
pbMoveRoute(event,[PBMoveRoute::Forward]) pbMoveRoute(event, [PBMoveRoute::Forward])
pbMoveRoute($game_player,[PBMoveRoute::Forward]) pbMoveRoute($game_player, [PBMoveRoute::Forward])
@hp[0] -= action # Enemy action @hp[0] -= action # Enemy action
@hp[1] -= command # Player command @hp[1] -= command # Player command
pbMessage(_INTL("You hit each other!")) pbMessage(_INTL("You hit each other!"))
elsif action==2 && command==0 elsif action == 2 && command == 0
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::ScriptAsync,"jumpBackward"]) PBMoveRoute::ScriptAsync, "jumpBackward"])
pbWait(Graphics.frame_rate) pbWait(Graphics.frame_rate)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Backward]) PBMoveRoute::Backward])
pbMessage(_INTL("You evade the opponent's attack!")) pbMessage(_INTL("You evade the opponent's attack!"))
elsif action==3 && (command==0 || command==1 || command==2) elsif action == 3 && (command == 0 || command == 1 || command == 2)
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::ScriptAsync,"jumpForward"]) PBMoveRoute::ScriptAsync, "jumpForward"])
pbWait(Graphics.frame_rate*4/10) pbWait(Graphics.frame_rate * 4 / 10)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,5, PBMoveRoute::ChangeSpeed, 5,
PBMoveRoute::Backward, PBMoveRoute::Backward,
PBMoveRoute::ChangeSpeed,2]) PBMoveRoute::ChangeSpeed, 2])
pbWait(Graphics.frame_rate/2) pbWait(Graphics.frame_rate / 2)
pbShake(9,9,8) pbShake(9, 9, 8)
pbFlashScreens(true,false) pbFlashScreens(true, false)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Forward]) PBMoveRoute::Forward])
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,2, PBMoveRoute::ChangeSpeed, 2,
PBMoveRoute::Backward]) PBMoveRoute::Backward])
@hp[0] -= 3 @hp[0] -= 3
pbMessage(_INTL("The opponent pierces through your defenses!")) pbMessage(_INTL("The opponent pierces through your defenses!"))
elsif action==3 && command==3 elsif action == 3 && command == 3
pbMoveRoute($game_player,[PBMoveRoute::Backward]) pbMoveRoute($game_player, [PBMoveRoute::Backward])
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::ScriptAsync,"jumpForward"]) PBMoveRoute::ScriptAsync, "jumpForward"])
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::Wait,15, PBMoveRoute::Wait, 15,
PBMoveRoute::ChangeSpeed,4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::ScriptAsync,"jumpForward"]) PBMoveRoute::ScriptAsync, "jumpForward"])
pbWait(Graphics.frame_rate) pbWait(Graphics.frame_rate)
pbMoveRoute(event,[ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed,5, PBMoveRoute::ChangeSpeed, 5,
PBMoveRoute::Backward, PBMoveRoute::Backward,
PBMoveRoute::ChangeSpeed,2]) PBMoveRoute::ChangeSpeed, 2])
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed,5, PBMoveRoute::ChangeSpeed, 5,
PBMoveRoute::Backward, PBMoveRoute::Backward,
PBMoveRoute::ChangeSpeed,2]) PBMoveRoute::ChangeSpeed, 2])
pbShake(9,9,8) pbShake(9, 9, 8)
pbFlash(Color.new(255,255,255,255),20) pbFlash(Color.new(255, 255, 255, 255), 20)
pbFlashScreens(true,true) pbFlashScreens(true, true)
pbMoveRoute($game_player,[PBMoveRoute::Forward]) pbMoveRoute($game_player, [PBMoveRoute::Forward])
@hp[0] -= 4 @hp[0] -= 4
@hp[1] -= 4 @hp[1] -= 4
pbMessage(_INTL("Your special attacks collide!")) pbMessage(_INTL("Your special attacks collide!"))
@@ -313,22 +307,22 @@ class PokemonDuel
end end
def pbEndDuel def pbEndDuel
pbWait(Graphics.frame_rate*3/4) pbWait(Graphics.frame_rate * 3 / 4)
pbMoveRoute($game_player,[ pbMoveRoute($game_player, [
PBMoveRoute::DirectionFixOff, PBMoveRoute::DirectionFixOff,
PBMoveRoute::ChangeSpeed,@oldmovespeed]) PBMoveRoute::ChangeSpeed, @oldmovespeed])
pbMoveRoute(@event,[ pbMoveRoute(@event, [
PBMoveRoute::DirectionFixOff, PBMoveRoute::DirectionFixOff,
PBMoveRoute::ChangeSpeed,@oldeventspeed]) PBMoveRoute::ChangeSpeed, @oldeventspeed])
fadeTime = Graphics.frame_rate*4/10 fade_time = Graphics.frame_rate * 4 / 10
alphaDiff = (255.0/fadeTime).ceil alpha_diff = (255.0 / fade_time).ceil
fadeTime.times do fade_time.times do
@sprites["player"].opacity -= alphaDiff @sprites["player"].opacity -= alpha_diff
@sprites["opponent"].opacity -= alphaDiff @sprites["opponent"].opacity -= alpha_diff
@sprites["playerwindow"].contents_opacity -= alphaDiff @sprites["playerwindow"].contents_opacity -= alpha_diff
@sprites["opponentwindow"].contents_opacity -= alphaDiff @sprites["opponentwindow"].contents_opacity -= alpha_diff
@sprites["playerwindow"].opacity -= alphaDiff @sprites["playerwindow"].opacity -= alpha_diff
@sprites["opponentwindow"].opacity -= alphaDiff @sprites["opponentwindow"].opacity -= alpha_diff
Graphics.update Graphics.update
Input.update Input.update
pbUpdateSceneMap pbUpdateSceneMap
@@ -337,71 +331,61 @@ class PokemonDuel
@viewport.dispose @viewport.dispose
end end
def pbFlashScreens(player,opponent) def pbFlashScreens(player, opponent)
i = 0 i = 0
flashTime = Graphics.frame_rate*2/10 flash_time = Graphics.frame_rate * 2 / 10
alphaDiff = (2*255.0/flashTime).ceil alpha_diff = (2 * 255.0 / flash_time).ceil
flashTime.times do flash_time.times do
i += 1 i += 1
if player if player
@sprites["player"].color = Color.new(255,255,255,i*alphaDiff) @sprites["player"].color = Color.new(255, 255, 255, i * alpha_diff)
@sprites["playerwindow"].color = Color.new(255,255,255,i*alphaDiff) @sprites["playerwindow"].color = Color.new(255, 255, 255, i * alpha_diff)
end end
if opponent if opponent
@sprites["opponent"].color = Color.new(255,255,255,i*alphaDiff) @sprites["opponent"].color = Color.new(255, 255, 255, i * alpha_diff)
@sprites["opponentwindow"].color = Color.new(255,255,255,i*alphaDiff) @sprites["opponentwindow"].color = Color.new(255, 255, 255, i * alpha_diff)
end end
Graphics.update Graphics.update
Input.update Input.update
pbUpdateSceneMap pbUpdateSceneMap
end end
flashTime.times do flash_time.times do
i -= 1 i -= 1
if player if player
@sprites["player"].color = Color.new(255,255,255,i*alphaDiff) @sprites["player"].color = Color.new(255, 255, 255, i * alpha_diff)
@sprites["playerwindow"].color = Color.new(255,255,255,i*alphaDiff) @sprites["playerwindow"].color = Color.new(255, 255, 255, i * alpha_diff)
end end
if opponent if opponent
@sprites["opponent"].color = Color.new(255,255,255,i*alphaDiff) @sprites["opponent"].color = Color.new(255, 255, 255, i * alpha_diff)
@sprites["opponentwindow"].color = Color.new(255,255,255,i*alphaDiff) @sprites["opponentwindow"].color = Color.new(255, 255, 255, i * alpha_diff)
end end
Graphics.update Graphics.update
Input.update Input.update
pbUpdateSceneMap pbUpdateSceneMap
end end
pbWait(Graphics.frame_rate*4/10) if !player || !opponent pbWait(Graphics.frame_rate * 4 / 10) if !player || !opponent
end end
def pbRefresh def pbRefresh
@sprites["playerwindow"].hp = @hp[0] @sprites["playerwindow"].hp = @hp[0]
@sprites["opponentwindow"].hp = @hp[1] @sprites["opponentwindow"].hp = @hp[1]
pbWait(Graphics.frame_rate/4) pbWait(Graphics.frame_rate / 4)
end end
end end
# Starts a duel. # Starts a duel.
# trainerid - ID or symbol of the opponent's trainer type. # trainer_id - ID or symbol of the opponent's trainer type.
# trainername - Name of the opponent # trainer_name - Name of the opponent
# event - Game_Event object for the character's event # event - Game_Event object for the character's event
# speeches - Array of 12 speeches # speeches - Array of 12 speeches
def pbDuel(trainerID,trainerName,event,speeches) def pbDuel(trainer_id, trainer_name, event, speeches)
trainerID = getID(PBTrainers,trainerID) trainer_id = getID(PBTrainers, trainer_id)
duel = PokemonDuel.new duel = PokemonDuel.new
opponent = PokeBattle_Trainer.new( opponent = PokeBattle_Trainer.new(
pbGetMessageFromHash(MessageTypes::TrainerNames,trainerName),trainerID) pbGetMessageFromHash(MessageTypes::TrainerNames,trainer_name), trainer_id)
speechTexts = [] speech_texts = []
for i in 0...12 for i in 0...12
speechTexts.push(_I(speeches[i])) speech_texts.push(_I(speeches[i]))
end
duel.pbDuel(opponent,event,speechTexts)
end
rescue Exception
if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset"
raise $!
end end
duel.pbDuel(opponent, event, speech_texts)
end end

View File

@@ -261,7 +261,6 @@ class TriadScene
preview.y = 60 preview.y = 60
preview.z = 4 preview.z = 4
index = -1 index = -1
chosenSprites = []
for i in 0...@battle.maxCards for i in 0...@battle.maxCards
@sprites["player#{i}"] = Sprite.new(@viewport) @sprites["player#{i}"] = Sprite.new(@viewport)
@sprites["player#{i}"].x = Graphics.width-92 @sprites["player#{i}"].x = Graphics.width-92
@@ -443,9 +442,8 @@ class TriadScene
return choice return choice
end end
def pbPlayerPlaceCard(card,cardIndex) def pbPlayerPlaceCard(cardIndex)
@sprites["helpwindow"].text = _INTL("Place the card.") @sprites["helpwindow"].text = _INTL("Place the card.")
choice = 0
boardX = 0 boardX = 0
boardY = 0 boardY = 0
doRefresh = true doRefresh = true
@@ -733,9 +731,10 @@ class TriadScreen
for i in 0...@width*@height for i in 0...@width*@height
square = TriadSquare.new square = TriadSquare.new
if @elements if @elements
begin loop do
square.type = rand(PBTypes.maxValue+1) square.type = rand(PBTypes.maxValue+1)
end until !PBTypes.isPseudoType?(square.type) break if !PBTypes.isPseudoType?(square.type)
end
end end
@board.push(square) @board.push(square)
end end
@@ -793,7 +792,7 @@ class TriadScreen
minIndex = minLevel*20 minIndex = minLevel*20
maxIndex = maxLevel*20+20 maxIndex = maxLevel*20+20
opponentCards = [] opponentCards = []
for i in 0...self.maxCards self.maxCards.times do
# generate random card based on level # generate random card based on level
index = minIndex+rand(maxIndex-minIndex) index = minIndex+rand(maxIndex-minIndex)
opponentCards.push(candidates[index][0]) opponentCards.push(candidates[index][0])
@@ -821,7 +820,7 @@ class TriadScreen
while !position while !position
cardIndex = @scene.pbPlayerChooseCard(cards.length) cardIndex = @scene.pbPlayerChooseCard(cards.length)
triadCard = TriadCard.new(cards[cardIndex]) triadCard = TriadCard.new(cards[cardIndex])
position = @scene.pbPlayerPlaceCard(triadCard,cardIndex) position = @scene.pbPlayerPlaceCard(cardIndex)
end end
else else
# Opponent's turn # Opponent's turn
@@ -990,7 +989,7 @@ end
# Card storage # Card storage
#=============================================================================== #===============================================================================
class PokemonGlobalMetadata class PokemonGlobalMetadata
attr_accessor :triads attr_writer :triads
def triads def triads
@triads = TriadStorage.new if !@triads @triads = TriadStorage.new if !@triads

View File

@@ -431,7 +431,7 @@ class VoltorbFlip
# Create and split a string for the number, with padded 0s # Create and split a string for the number, with padded 0s
zeroes=2-num.to_s.length zeroes=2-num.to_s.length
numText="" numText=""
for j in 0...zeroes zeroes.times do
numText+="0" numText+="0"
end end
numText+=num.to_s numText+=num.to_s
@@ -449,7 +449,7 @@ class VoltorbFlip
# Create and split a string for the number, with padded 0s # Create and split a string for the number, with padded 0s
zeroes=2-num.to_s.length zeroes=2-num.to_s.length
numText="" numText=""
for j in 0...zeroes zeroes.times do
numText+="0" numText+="0"
end end
numText+=num.to_s numText+=num.to_s
@@ -466,7 +466,7 @@ class VoltorbFlip
def pbCreateCoins(source,y) def pbCreateCoins(source,y)
zeroes=5-source.to_s.length zeroes=5-source.to_s.length
coinText="" coinText=""
for i in 0...zeroes zeroes.times do
coinText+="0" coinText+="0"
end end
coinText+=source.to_s coinText+=source.to_s

View File

@@ -32,7 +32,7 @@ def pbLottery(winnum,nameVar=2,positionVar=3,matchedVar=4)
winmatched=thismatched winmatched=thismatched
end end
end end
pbEachPokemon { |poke,box| pbEachPokemon { |poke,_box|
thismatched=0 thismatched=0
id=poke.publicID id=poke.publicID
for j in 0...5 for j in 0...5

View File

@@ -339,8 +339,6 @@ class MiningGameScene
prepattern=ITEMS[i[0]][6] prepattern=ITEMS[i[0]][6]
next if provx+provwidth<=prex || provx>=prex+prewidth || next if provx+provwidth<=prex || provx>=prex+prewidth ||
provy+provheight<=prey || provy>=prey+preheight provy+provheight<=prey || provy>=prey+preheight
dx=prex-provx
dy=prey-provy
for j in 0...prepattern.length for j in 0...prepattern.length
next if prepattern[j]==0 next if prepattern[j]==0
xco=prex+(j%prewidth) xco=prex+(j%prewidth)
@@ -359,8 +357,6 @@ class MiningGameScene
prepattern=IRON[i[0]][4] prepattern=IRON[i[0]][4]
next if provx+provwidth<=prex || provx>=prex+prewidth || next if provx+provwidth<=prex || provx>=prex+prewidth ||
provy+provheight<=prey || provy>=prey+preheight provy+provheight<=prey || provy>=prey+preheight
dx=prex-provx
dy=prey-provy
for j in 0...prepattern.length for j in 0...prepattern.length
next if prepattern[j]==0 next if prepattern[j]==0
xco=prex+(j%prewidth) xco=prex+(j%prewidth)