- 30
- Posts
- 5
- Years
- Seen Jan 16, 2024
This is the code for who want to who want to make Poketch "horizontal"
Credit:
- Marin (obliged)
- Halo Route (optional)
Sorry for bad English
Poketch_0
Poketch_1
# WARNING: RPG.Net is a bit buggy. You may get "RGSS Player stopped working"
# when using an app that uses RPG.Net. I can sadly not do anything about this.
# Process of creating your own application:
# -> Create the class
# -> Make sure it inherits from "PoketchApp"
# -> "Register" the app in the PoketchApps module by adding a unique ID and
# the classname.
# Why to inherit PoketchApp and call "super" in some methods:
# class "PoketchApp"'s intention is to make your code as small as possible.
# It will make you an @bg sprite and an @viewport if you call "super" in
# the constructor of your class (def initialize). Make sure to call this first.
# It will also handle "def click?", which is a method that handles normal
# button clicks. To use, make sure to call "super" in the update method of your
# class (def update).
# To make sure everything (including the actual $Poketch.app), @bg, and @viewport
# disposes correctly, call "super" LAST in your dispose method (def dispose).
# If you only want the app to be available under certain circumstances (ON TOP OF
# THE APP ENABLED STATE), you can overwrite "def self.usable?". Apps that need
# RPG.Net to function, for example, have "return RNET".
# Additional Utility: (more can be found in Pokétch_Utility)
# <Sprite>.poketch_average: Will average out your sprite's colors to be of the
# same 4 colors the Pokétch originally has. (used for party icons)
# pbFormat(integer, digits): Better to show some examples:
# -> pbFormat(27,3) # => "027"
# -> pbFormat(12,2) # => "12"
#==============================================================================#
# Pokétch Clock. Shows the computer's time. #
#==============================================================================#
class PoketchClock < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Clock/background")
@time = Time.now
@numbers = []
draw_time
end
def update
if @time.hour != Time.now.hour || @time.min != Time.now.min
draw_time
@time = Time.now
end
end
def draw_time
n = pbFormat(@time.hour,2).split("")
n.concat(pbFormat(@time.min,2).split(""))
for i in 0...4
@numbers.dispose if @numbers
@numbers = nil
@numbers = Sprite.new(@viewport)
@numbers.bmp("Graphics/Pictures/Poketch/Clock/numbers")
@numbers.src_rect.width = 64
@numbers.src_rect.x = n.to_i * 64
@numbers.x = [15,97,208,290]
@numbers.y = 82
end
end
def dispose
for n in @numbers
n.dispose
end
super
end
end
#==============================================================================#
# Pokétch Clicker. Click your heart away. #
#==============================================================================#
class PokemonTemp
attr_accessor :click_count
end
class PoketchClicker < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Clicker/background")
@numbers = []
@btn = Sprite.new(@viewport)
@btn.bmp("Graphics/Pictures/Poketch/Clicker/btn")
@btn.x = 128
@btn.y = 166
$PokemonTemp.click_count = 0 if !$PokemonTemp.click_count
draw_count
end
def draw_count
n = pbFormat($PokemonTemp.click_count, 4).split("")
for i in 0...4
@numbers.dispose if @numbers
@numbers = nil
@numbers = Sprite.new(@viewport)
@numbers.bmp("Graphics/Pictures/Poketch/Clicker/numbers")
@numbers.src_rect.width = 24
@numbers.src_rect.x = n.to_i * 24
@numbers.x = 135 + 30 * i
@numbers.y = 68
end
end
def update
super
if click?(@btn, "Graphics/Pictures/Poketch/Clicker", "btn")
$PokemonTemp.click_count += 1
$PokemonTemp.click_count = 0 if $PokemonTemp.click_count > 9999
draw_count
end
end
def dispose
$PokemonTemp.click_count = 0
super
end
end
#==============================================================================#
# Pokétch Calculator. You can do basic math with this. #
#==============================================================================#
class Float
def round_to(x)
return (self * 10 ** x).round.to_f / 10 ** x
end
end
# This one's rather complex. Ignore this.
class PoketchCalculator < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Calculator/background")
@buttons = []
@buttons[0] = []
@buttons[0][0] = 0
@buttons[0][1] = Sprite.new(@viewport)
@buttons[0][1].bmp("Graphics/Pictures/Poketch/Calculator/btnLarge")
@buttons[0][1].x = 32
@buttons[0][1].y = 256
@buttons[0][2] = Sprite.new(@viewport)
@buttons[0][2].bmp("Graphics/Pictures/Poketch/Calculator/buttonnumbers")
@buttons[0][2].src_rect.width = 16
@buttons[0][2].x = @buttons[0][1].x + 24
@buttons[0][2].y = @buttons[0][1].y + 16
for i in 0...9
@buttons[i+1] = []
@buttons[i+1][0] = i+1
@buttons[i+1][1] = Sprite.new(@viewport)
@buttons[i+1][1].bmp("Graphics/Pictures/Poketch/Calculator/btnSmall")
@buttons[i+1][1].x = 32 + 64 * (i % 3)
@buttons[i+1][1].y = 192 - 64 * (i / 3).floor
@buttons[i+1][2] = Sprite.new(@viewport)
@buttons[i+1][2].bmp("Graphics/Pictures/Poketch/Calculator/buttonnumbers")
@buttons[i+1][2].src_rect.width = 16
@buttons[i+1][2].src_rect.x = 16 * (i + 1)
@buttons[i+1][2].x = @buttons[i+1][1].x + 24
@buttons[i+1][2].y = @buttons[i+1][1].y + 16
end
@operators = []
for i in 0...6
@operators = []
@operators[0] = ["+","-","*","/","=","."]
@operators[1] = Sprite.new(@viewport)
@operators[1].bmp("Graphics/Pictures/Poketch/Calculator/btn#{i == 4 ? "Large" : "Small"}")
@operators[1].x = [224,288][i % 2]
@operators[1].y = 128 + 64 * (i / 2).floor
@operators[1].x = 160 if i == 5
@operators[1].y = 256 if i == 5
@operators[2] = Sprite.new(@viewport)
@operators[2].bmp("Graphics/Pictures/Poketch/Calculator/operators")
@operators[2].src_rect.width = 24
@operators[2].src_rect.x = i * 24
@operators[2].x = @operators[1].x + 17
@operators[2].y = @operators[1].y + 14
end
@cbtn = []
@cbtn[0] = nil
@cbtn[1] = Sprite.new(@viewport)
@cbtn[1].bmp("Graphics/Pictures/Poketch/Calculator/btnLarge")
@cbtn[1].x = 224
@cbtn[1].y = 64
@cbtn[2] = Sprite.new(@viewport)
@cbtn[2].bmp("Graphics/Pictures/Poketch/Calculator/cbtn")
@cbtn[2].x = @cbtn[1].x + 19
@cbtn[2].y = @cbtn[1].y + 16
@activeoperator = []
@activeoperator[0] = nil
@activeoperator[1] = Sprite.new(@viewport)
@activeoperator[1].x = 20
@activeoperator[1].y = 18
@activenums = []
for i in 0...10
@activenums = []
@activenums[0] = nil
@activenums[1] = Sprite.new(@viewport)
@activenums[1].bmp("Graphics/Pictures/Poketch/Calculator/empty")
@activenums[1].x = 344 - 32 * i
@activenums[1].y = 18
end
@old = ""
@stillactive = false
@error = false
@oldop = nil
@reset_on_next = false
end
def click?(btn,path,unclicked,clicked=unclicked+"Click")
return false if !$mouse || !$mouse.click?(btn[1]) || @cooldown > -1
@tmp = [btn,path,unclicked]
@tmp[0][1].bmp(@tmp[1]+"/"+clicked)
@tmp[0][2].y += 12
@cooldown = 3
return true
end
def update
@cooldown -= 1 if @cooldown > -1
if @cooldown == 0
@tmp[0][1].bmp(@tmp[1]+"/"+@tmp[2])
@tmp[0][2].y -= 12
end
for i in [email protected]
p = (i == 0 ? "btnLarge" : "btnSmall")
if click?(@buttons,"Graphics/Pictures/Poketch/Calculator",p)
if @error
reset_numbers
end
if @activeoperator[0] && @stillactive || @reset_on_next
@stillactive = false
@old = @activenums.map { |n| n[0] }.join.reverse
reset_numbers
@reset_on_next = false
end
if !@activenums[9][0]
@activenums[9][1].dispose
@activenums[9] = nil
@activenums.compact!
for j in [email protected]
@activenums[j][1].x -= 32
end
n = []
n[0] = @buttons[0]
n[1] = Sprite.new(@viewport)
n[1].bmp("Graphics/Pictures/Poketch/Calculator/numbers")
n[1].src_rect.width = 20
n[1].src_rect.x = 20 * i
n[1].x = 344
n[1].y = 18
@activenums.insert(0,n)
end
end
end
for i in [email protected]
p = (i == 4 ? "btnLarge" : "btnSmall")
if click?(@operators,"Graphics/Pictures/Poketch/Calculator",p)
if @operators[0] == "."
if !@activenums[9][0]
@activenums[9][1].dispose
@activenums[9] = nil
@activenums.compact!
for j in [email protected]
@activenums[j][1].x -= 32
end
n = []
n[0] = "."
n[1] = Sprite.new(@viewport)
n[1].bmp("Graphics/Pictures/Poketch/Calculator/dot")
n[1].x = 344
n[1].y = 18
@activenums.insert(0,n)
@reset_on_next = false
end
elsif @operators[0] == "="
cur = @activenums.map { |n| n[0] }.join.reverse
if !@old || @old == ""
return
end
ex = nil
@old = @old.to_f.to_s
cur = cur.to_f.to_s
if @activeoperator[0]
ex = @old + @activeoperator[0] + cur
else
ex = cur + @oldop + @old
end
if ex.size == 1 || ex.size == 0
throw_error
return
end
n = (eval(ex) rescue nil)
if !n
throw_error
return
end
reset_numbers
# Some trickery to perform float operations properly, but also cut
# the .0 if it's a whole numbers (all calculations are done with floats)
n = n.to_f
slots = 9 - n.to_s.split('.')[0].size
n = n.round_to(slots).to_s
n = n.chomp('.0') if n[n.size - 2..n.size] == '.0'
n = n.reverse.split("") rescue nil
if !n || n.size == 0 || n.size > 10
throw_error
return
end
for j in 0...n.size
if n[j] == "-"
@activenums[j][0] = "-"
@activenums[j][1].bmp("Graphics/Pictures/Poketch/Calculator/operators")
@activenums[j][1].src_rect.width = 24
@activenums[j][1].src_rect.x = 24
elsif n[j] == "."
@activenums[j][0] = "."
@activenums[j][1].bmp("Graphics/Pictures/Poketch/Calculator/dot")
else
@activenums[j][0] = n[j].to_i
@activenums[j][1].bmp("Graphics/Pictures/Poketch/Calculator/numbers")
@activenums[j][1].src_rect.width = 20
@activenums[j][1].src_rect.x = 20 * n[j].to_i
end
end
@old = cur if @activeoperator[0]
@oldop = @activeoperator[0] if @activeoperator[0]
@activeoperator[0] = nil
@activeoperator[1].bitmap = nil
@reset_on_next = true
else
@activeoperator[0] = @operators[0]
@activeoperator[1].bmp("Graphics/Pictures/Poketch/Calculator/operators")
@activeoperator[1].src_rect.width = 24
@activeoperator[1].src_rect.x = 24 * i
@stillactive = true
@reset_on_next = false
end
end
end
if click?(@cbtn,"Graphics/Pictures/Poketch/Calculator","btnLarge")
reset_numbers
@old = ""
@stillactive = false
@activeoperator[0] = nil
@activeoperator[1].bitmap = nil
@oldop = nil
@error = false
@reset_on_next = false
end
end
def reset_numbers
for i in 0...10
@activenums[0] = nil
@activenums[1].bmp("Graphics/Pictures/Poketch/Calculator/empty")
end
end
def throw_error
@old = ""
@stillactive = false
@activeoperator[0] = nil
@activeoperator[1].bitmap = nil
for i in 0...10
@activenums[1].bmp("Graphics/Pictures/Poketch/Calculator/error")
end
@error = true
end
def dispose
for btn in @buttons
btn[0] = nil
btn[1].dispose if btn[1]
btn[2].dispose if btn[2]
end
for op in @operators
op[0] = nil
op[1].dispose if op[1]
op[2].dispose if op[2]
end
for n in @activenums
n[0] = nil
n[1].dispose if n[1]
@activeoperator[0] = nil
@activeoperator[1].dispose if @activeoperator
end
@cbtn[0] = nil
@cbtn[1].dispose if @cbtn[1]
@cbtn[2].dispose if @cbtn[2]
@bg.dispose
super
end
end
#==============================================================================#
# Pokétch Item Finder. AKA Dowsing Machine. #
#==============================================================================#
# For an item to be picked up by the Itemfinder, make sure it has ".hidden"
# (without the quotation marks) in the event name.
# How you should make your item ball events:
# -> Kernel.pbItemBall(item)
# -> Script: pbUnlist(event_id)
# -> Erase event
class Game_Event
attr_accessor :listed
alias poketch_init initialize
def initialize(map_id, event, map = nil)
poketch_init(map_id, event, map)
@listed = true # Set to true, but whether it's actually listed or not
# depends on the name.
end
end
# If you call this on an event, it'll be no longer listed in the Itemfinder
# (if it even was)
def pbUnlist(event_id)
$game_map.events[event_id].listed = false if $game_map.events[event_id]
end
# The Itemfinder will show this event (but still only if it has .hidden in name)
def pbList(event_id)
$game_map.events[event_id].listed = true if $game_map.events[event_id]
end
class PoketchItemFinder < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Item Finder/background")
@circles = []
@items = []
end
def update
super
if $mouse && $mouse.inAreaLeftPress?(POKETCH_X+32,POKETCH_Y+32,384,320) && @cooldown == -1
@cooldown = 16
x = $mouse.x - 32
y = $mouse.y - POKETCH_Y - 32
if x < 384 && y < 320
c = Sprite.new(@viewport)
c.bmp("Graphics/Pictures/Poketch/Item Finder/circle")
c.ox = c.bitmap.width / 2
c.oy = c.bitmap.height / 2
c.x = x
c.y = y
c.zoom_x = 0
c.zoom_y = 0
@circles << [40, c]
redraw((x - 11) / 22, (y - 11) / 22)
end
end
for i in [email protected]
@circles[0] -= 1
@circles[1].zoom_x += 0.06
@circles[1].zoom_y += 0.06
if @circles[0] < 16
@circles[1].opacity -= 16
end
if @circles[0] == 0
@circles[1].dispose
@circles[1] = nil
@circles = nil
end
end
@circles.compact!
for i in [email protected]
@items[0] -= 1
@items[1].opacity += 255 / (@items[0] > 48 ? 16.0 : @items[0] < 32 ? -32.0 : 255)
if @items[0] == 0
@items[1].dispose
@items[1] = nil
@items = nil
end
end
@items.compact!
$Poketch.click_up if $mouse.click?($Poketch.btnUp)
$Poketch.click_down if $mouse.click?($Poketch.btnDown)
end
def redraw(cx, cy)
for i in [email protected]
@items[1].dispose
@items = nil
end
@items.compact!
for k in $game_map.events.keys
e = $game_map.events[k]
# This one line below is the statement that decides if an event should be
# shown as a dot. The rest is just positioning, locating, and other crap.
if e.name.include?(".hidden") && e.listed
if $game_player.x - e.x >= -8 && $game_player.x - e.x <= 8
if $game_player.y - e.y >= -7 && $game_player.y - e.y <= 7
x = e.x - $game_player.x + 8
y = e.y - $game_player.y + 7
if cx - x >= -5 && cx - x <= 5
if cy - y >= -4 && cy - y <= 4
item = Sprite.new(@viewport)
item.bmp("Graphics/Pictures/Poketch/Item Finder/item")
item.x = 11 + 22 * x
item.y = 11 + 22 * y
item.opacity = 0
@items << [64, item]
end
end
end
end
end
end
end
def dispose
for c in @circles
c[1].dispose
end
for i in @items
i[1].dispose
end
super
end
end
#==============================================================================#
# Pokétch Rotom. Tells you things depending on what you predefine. #
#==============================================================================#
# Normal Rotom Text:
# Array of message rotom can send by random.
# Forced Rotom Text:
# Array of messages rotom can send by random.
# If there are any messages in this array, it will always pick from this array.
# This will delete all other normal rotom messages.
def pbSetRotomText(array_of_messages)
array_of_messages = [array_of_messages] if !array_of_messages.is_a?(Array)
$Trainer.poketch_rotom_text = array_of_messages
end
# This will add to all other normal rotom messages.
def pbAddRotomText(text)
$Trainer.poketch_rotom_text = [] if !$Trainer.poketch_rotom_text
$Trainer.poketch_rotom_text << text
end
# This will delete a message that equals the passed "text" from the normal rotom messages
def pbDeleteRotomText(text)
$Trainer.poketch_rotom_text = [] if !$Trainer.poketch_rotom_text
$Trainer.poketch_rotom_text.delete(text) if $Trainer.poketch_rotom_text.include?(text)
end
# This will delete all other forced rotom messages
def pbSetForcedRotomText(array_of_message)
array_of_messages = [array_of_messages] if !array_of_messages.is_a?(Array)
$Trainer.poketch_rotom_text_forced = array_of_messages
end
# This will add to all other forced rotom messages
def pbAddForcedRotomText(text)
$Trainer.poketch_rotom_text_forced = [] if !$Trainer.poketch_rotom_text_forced
$Trainer.poketch_rotom_text_forced << text
end
# This will delete a message that equals the passed "text" from the forced rotom messages
def pbDeleteForcedRotomText(text)
$Trainer.poketch_rotom_text_forced = [] if !$Trainer.poketch_rotom_text_forced
if $Trainer.poketch_rotom_text_forced.include?(text)
$Trainer.poketch_rotom_text_forced.delete(text)
end
end
class PokeBattle_Trainer
attr_accessor :poketch_rotom_text
attr_accessor :poketch_rotom_text_forced
alias poketch_rotom_init initialize
def initialize(name, trainertype)
poketch_rotom_init(name, trainertype)
end
end
class PoketchRotom < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Rotom/idle")
@bg.src_rect.width = 384
@txtbar = Sprite.new(@viewport)
@txtbar.bmp("Graphics/Pictures/Poketch/Rotom/speech")
@txtbar.y = 320
@txtsprite = Sprite.new(@viewport)
@txtsprite.bmp(384,320)
pbSetSystemFont(@txtsprite.bitmap)
@txtsprite.bitmap.font.size += 10
if !$Trainer.poketch_rotom_text
# Default Normal Rotom Text
$Trainer.poketch_rotom_text = [
"Bzzt! I'm here to help you out on your journey!",
"Z-zzt! Where will we go next?"
]
end
# Default Forced Rotom Text (if you enter anything in here, this will override
# all messages you wrote in the Normal Rotom Text array).
if !$Trainer.poketch_rotom_text_forced
$Trainer.poketch_rotom_text_forced = [
# "Message here",
]
end
@txt = nil
@i = 0
end
def update
if $mouse && $mouse.click?(@bg) && @cooldown == -1
if @draw
@cooldown = 1
else
draw
end
end
if @draw && @txt && @txt.size > 0
if @i < @txt.size
@cooldown = 0
@bg.y -= 4 if @bg.y > -52
@txtbar.y -= 5 if @txtbar.y > 210
@txtsprite.bitmap.clear
pbSetSystemFont(@txtsprite.bitmap)
@txtsprite.bitmap.font.size += 2
t = @txt[0..@i].join
if @txtbar.y <= 220
@bg.src_rect.x += 384 if @i % 7 == 0
@bg.src_rect.x = 0 if @bg.src_rect.x >= @bg.bitmap.width
drawTextEx(@txtsprite.bitmap,14,248,362,2,t,Color.new(16,41,24),
Color.new(57,82,49))
@i += 1
end
else
@cooldown = -1
@txt = nil
@i = 0
@bg.src_rect.x = 0
end
end
if @cooldown == 1
@bg.y += 4 unless @bg.y == 0
@txtbar.y += 5 unless @txtbar.y == 320
@txtsprite.y += 5 unless @txtbar.y == 320
if @txtbar.y == 320
@draw = false
@cooldown = -1
@txtsprite.bitmap.clear
@txtsprite.y = 0
end
end
end
def draw
t = []
if $Trainer.poketch_rotom_text_forced.size > 0
t = $Trainer.poketch_rotom_text_forced
else
t = $Trainer.poketch_rotom_text
end
@txt = t[rand(t.size)].split("")
@draw = true
end
def dispose
@txtbar.dispose
@txtsprite.dispose
super
end
end
#==============================================================================#
# Pokétch Move Tester. Test type effectivenesses. #
#==============================================================================#
class PokeBattle_Trainer
attr_accessor :poketch_move_tester_move
attr_accessor :poketch_move_tester_type1
attr_accessor :poketch_move_tester_type2
end
class PoketchMoveTester < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Move Tester/background")
@moveBtnLeft = Sprite.new(@viewport)
@moveBtnLeft.bmp("Graphics/Pictures/Poketch/Move Tester/btnLeft")
@moveBtnLeft.y = 191
@moveBtnRight = Sprite.new(@viewport)
@moveBtnRight.bmp("Graphics/Pictures/Poketch/Move Tester/btnRight")
@moveBtnRight.x = 176
@moveBtnRight.y = 192
@type1BtnLeft = Sprite.new(@viewport)
@type1BtnLeft.bmp("Graphics/Pictures/Poketch/Move Tester/btnLeft")
@type1BtnLeft.x = 160
@type1BtnLeft.y = 16
@type1BtnRight = Sprite.new(@viewport)
@type1BtnRight.bmp("Graphics/Pictures/Poketch/Move Tester/btnRight")
@type1BtnRight.x = 336
@type1BtnRight.y = 16
@type2BtnLeft = Sprite.new(@viewport)
@type2BtnLeft.bmp("Graphics/Pictures/Poketch/Move Tester/btnLeft")
@type2BtnLeft.x = 160
@type2BtnLeft.y = 80
@type2BtnRight = Sprite.new(@viewport)
@type2BtnRight.bmp("Graphics/Pictures/Poketch/Move Tester/btnRight")
@type2BtnRight.x = 336
@type2BtnRight.y = 80
@move = $Trainer.poketch_move_tester_move || 0
@type1 = $Trainer.poketch_move_tester_type1 || 0
@type2 = $Trainer.poketch_move_tester_type2 || -1
@txtsprite = Sprite.new(@viewport)
@txtsprite.bmp(384,320)
@txt = @txtsprite.bitmap
@excl = []
refresh
end
def update
super
if click?(@moveBtnLeft,"Graphics/Pictures/Poketch/Move Tester","btnLeft")
@move -= 1
@move = PBTypes.maxValue if @move == -1
@move -= 1 if PBTypes.isPseudoType?(@move)
$Trainer.poketch_move_tester_move = @move
refresh
end
if click?(@moveBtnRight,"Graphics/Pictures/Poketch/Move Tester","btnRight")
@move += 1
@move = 0 if @move > PBTypes.maxValue
@move += 1 if PBTypes.isPseudoType?(@move)
$Trainer.poketch_move_tester_move = @move
refresh
end
if click?(@type1BtnLeft,"Graphics/Pictures/Poketch/Move Tester","btnLeft")
@type1 -= 1
@type1 = PBTypes.maxValue if @type1 == -1
@type1 -= 1 if PBTypes.isPseudoType?(@type1)
$Trainer.poketch_move_tester_type1 = @type1
refresh
end
if click?(@type1BtnRight,"Graphics/Pictures/Poketch/Move Tester","btnRight")
@type1 += 1
@type1 = 0 if @type1 > PBTypes.maxValue
@type1 += 1 if PBTypes.isPseudoType?(@type1)
$Trainer.poketch_move_tester_type1 = @type1
refresh
end
if click?(@type2BtnLeft,"Graphics/Pictures/Poketch/Move Tester","btnLeft")
@type2 -= 1
if @type2 == -2
@type2 = PBTypes.maxValue
elsif PBTypes.isPseudoType?(@type2)
@type2 -= 1
end
$Trainer.poketch_move_tester_type2 = @type2
refresh
end
if click?(@type2BtnRight,"Graphics/Pictures/Poketch/Move Tester","btnRight")
@type2 += 1
@type2 = -1 if @type2 > PBTypes.maxValue
@type2 += 1 if PBTypes.isPseudoType?(@type2)
$Trainer.poketch_move_tester_type2 = @type2
refresh
end
end
def refresh
@txt.clear
pbSetSystemFont(@txt)
name2 = (@type2 == -1 ? "None" : PBTypes.getName(@type2).upcase)
pbDrawTextPositions(@txt,[
[PBTypes.getName(@move).upcase,112,207,2,Color.new(16,41,24),Color.new(57,82,49)],
[PBTypes.getName(@type1).upcase,272,31,2,Color.new(16,41,24),Color.new(57,82,49)],
[name2,272,95,2,Color.new(16,41,24),Color.new(57,82,49)]
])
eff = PBTypes.getCombinedEffectiveness(@move, @type1, (@type2 == -1 ? nil : @type2))
txt = _INTL("Regularly effective")
txt = _INTL("Super effective") if eff > 8
txt = _INTL("Not very effective") if eff < 8
txt = _INTL("Not effective") if eff == 0
pbDrawTextPositions(@txt,[
[txt,16,271,0,Color.new(16,41,24),Color.new(57,82,49)]
])
# Determines how many exclamation marks to put
e = 0 if eff == 0
e = 1 if eff == 1 || eff == 2
e = 2 if eff == 4
e = 3 if eff == 8
e = 4 if eff == 16
e = 5 if eff == 32
for i in 0...6
@excl.dispose if @excl
if i < e
@excl = Sprite.new(@viewport)
@excl.bmp("Graphics/Pictures/Poketch/Move Tester/effectiveness")
@excl.x = 48 + 16 * i
@excl.y = 40
end
end
end
def dispose
for e in @excl
e.dispose
end
@moveBtnLeft.dispose
@moveBtnRight.dispose
@type1BtnRight.dispose
@type1BtnLeft.dispose
@type2BtnRight.dispose
@type2BtnLeft.dispose
@txtsprite.dispose
super
end
end
#==============================================================================#
# Pokétch Pedometer. Counts your steps. #
#==============================================================================#
class PokeBattle_Trainer
attr_accessor :steps
end
Events.onStepTaken += proc do
$Trainer.steps = 0 if !$Trainer.steps
$Trainer.steps += 1
$Poketch.refresh if $Poketch && $Poketch.app.is_a?(PoketchPedometer)
end
class PoketchPedometer < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Pedometer/background")
@btn = Sprite.new(@viewport)
@btn.bmp("Graphics/Pictures/Poketch/Pedometer/btn")
@btn.x = 133
@btn.y = 161
$Trainer.steps = 0 if !$Trainer.steps
@numbers = []
refresh
end
def update
super
if click?(@btn, "Graphics/Pictures/Poketch/Pedometer", "btn")
$Trainer.steps = 0
refresh
end
end
def refresh
n = pbFormat($Trainer.steps, 5)
n = n.to_s.split("")
for i in 0...5
@numbers.dispose if @numbers
@numbers = nil
@numbers = Sprite.new(@viewport)
@numbers.bmp("Graphics/Pictures/Poketch/Pedometer/numbers")
@numbers.src_rect.width = 24
@numbers.src_rect.x = n.to_i * 24
@numbers.x = 117 + 32 * i
@numbers.y = 66
end
end
def dispose
@btn.dispose
for n in @numbers
n.dispose
end
super
end
end
#==============================================================================#
# Pokétch Marking Map. Allows you to draw markers onto the map. #
#==============================================================================#
class PokeBattle_Trainer
attr_accessor :poketch_markingmap_circle
attr_accessor :poketch_markingmap_star
attr_accessor :poketch_markingmap_cube
attr_accessor :poketch_markingmap_triangle
attr_accessor :poketch_markingmap_heart
attr_accessor :poketch_markingmap_diamond
end
class PoketchMarkingMap < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Marking Map/background")
@circle = Sprite.new(@viewport)
@circle.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@circle.src_rect.width = 20
@circle.x = 208
@circle.y = 304
@circle.ox = @circle.bitmap.width / 6
@circle.oy = @circle.bitmap.height / 2
@star = Sprite.new(@viewport)
@star.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@star.src_rect.width = 20
@star.src_rect.x = 20
@star.x = 240
@star.y = 304
@star.ox = @star.bitmap.width / 6
@star.oy = @star.bitmap.height / 2
@cube = Sprite.new(@viewport)
@cube.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@cube.src_rect.width = 20
@cube.src_rect.x = 40
@cube.x = 272
@cube.y = 304
@cube.ox = @circle.bitmap.width / 6
@cube.oy = @cube.bitmap.height / 2
@triangle = Sprite.new(@viewport)
@triangle.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@triangle.src_rect.width = 20
@triangle.src_rect.x = 60
@triangle.x = 304
@triangle.y = 304
@triangle.ox = @triangle.bitmap.width / 6
@triangle.oy = @triangle.bitmap.height / 2
@heart = Sprite.new(@viewport)
@heart.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@heart.src_rect.width = 20
@heart.src_rect.x = 80
@heart.x = 336
@heart.y = 304
@heart.ox = @heart.bitmap.width / 6
@heart.oy = @heart.bitmap.height / 2
@diamond = Sprite.new(@viewport)
@diamond.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@diamond.src_rect.width = 20
@diamond.src_rect.x = 100
@diamond.x = 368
@diamond.y = 304
@diamond.ox = @diamond.bitmap.width / 6
@diamond.oy = @diamond.bitmap.height / 2
@circle.x, @circle.y = $Trainer.poketch_markingmap_circle if $Trainer.poketch_markingmap_circle
@star.x, @star.y = $Trainer.poketch_markingmap_star if $Trainer.poketch_markingmap_star
@cube.x, @cube.y = $Trainer.poketch_markingmap_cube if $Trainer.poketch_markingmap_cube
@triangle.x, @triangle.y = $Trainer.poketch_markingmap_triangle if $Trainer.poketch_markingmap_triangle
@heart.x, @heart.y = $Trainer.poketch_markingmap_heart if $Trainer.poketch_markingmap_heart
@diamond.x, @diamond.y = $Trainer.poketch_markingmap_diamond if $Trainer.poketch_markingmap_diamond
@obj = [@circle, @star, @cube, @triangle, @heart, @diamond]
@active = nil
end
def update
super
for i in [email protected]
if @cooldown == -1 && $mouse && $mouse.click?(@obj) && !@active
@active = i
end
end
if @active && $mouse.x - POKETCH_X - 32 > 0 && $mouse.x - POKETCH_X - 32 < 384 &&
$mouse.y - POKETCH_Y - 32 > 0 && $mouse.y - POKETCH_Y - 32 < 320
@obj[@active].zoom_x = 2
@obj[@active].zoom_y = 2
@obj[@active].x = $mouse.x - POKETCH_X - 32
@obj[@active].y = $mouse.y - POKETCH_Y - 32
$Trainer.poketch_markingmap_circle = @circle.x, @circle.y if @active == 0
$Trainer.poketch_markingmap_star = @star.x, @star.y if @active == 1
$Trainer.poketch_markingmap_cube = @cube.x, @cube.y if @active == 2
$Trainer.poketch_markingmap_triangle = @triangle.x, @triangle.y if @active == 3
$Trainer.poketch_markingmap_heart = @heart.x, @heart.y if @active == 4
$Trainer.poketch_markingmap_diamond = @diamond.x, @diamond.y if @active == 5
if $mouse.press?
@obj[@active].x = $mouse.x - POKETCH_X - 32
@obj[@active].y = $mouse.y - POKETCH_Y - 32
@obj[@active].zoom_x = 1
@obj[@active].zoom_y = 1
@active = nil
@cooldown = 5
end
end
end
def dispose
for obj in @obj
obj.dispose
end
super
end
end
#==============================================================================#
# Pokétch Matchup Checker. Check how your Pokémon match up with one another. #
#==============================================================================#
def pbGetCompat(poke1, poke2)
temp1 = $PokemonGlobal.daycare[0].clone
temp2 = $PokemonGlobal.daycare[1].clone
$PokemonGlobal.daycare[0] = [poke1,poke1.level]
$PokemonGlobal.daycare[1] = [poke2,poke2.level]
compat = pbDayCareGetCompat
$PokemonGlobal.daycare[0] = temp1
$PokemonGlobal.daycare[1] = temp2
return compat
end
class PoketchMatchupChecker < PoketchApp
def self.usable?
return $Trainer.party.size > 1
end
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Matchup Checker/background")
@btn = Sprite.new(@viewport)
@btn.bmp("Graphics/Pictures/Poketch/Matchup Checker/btn")
@btn.x = 144
@btn.y = 232
@poke1 = 0
@poke2 = 1
@icons = [nil, nil]
draw_pokes
@hearts = []
@luvdiscLeft = Sprite.new(@viewport)
@luvdiscLeft.bmp("Graphics/Pictures/Poketch/Matchup Checker/luvdisc")
@luvdiscLeft.x = 36
@luvdiscLeft.y = 104
@luvdiscRight = Sprite.new(@viewport)
@luvdiscRight.bmp("Graphics/Pictures/Poketch/Matchup Checker/luvdisc")
@luvdiscRight.x = 288
@luvdiscRight.y = 104
@luvdiscRight.mirror = true
@n = nil
end
def update
super
if !@n
if click?(@btn, "Graphics/Pictures/Poketch/Matchup Checker", "btn")
redraw
c = pbGetCompat($Trainer.party[@poke1], $Trainer.party[@poke2])
@n = [[72,29,59,69][c], c, -1]
end
if $mouse.inAreaLeftPress?(POKETCH_X+32+16,POKETCH_Y+32+228,96,72) && @cooldown == -1
@poke1 += 1
@poke1 = 0 if @poke1 >= $Trainer.party.size
@poke1 += 1 if @poke1 == @poke2
@poke1 = 0 if @poke1 >= $Trainer.party.size
pbPlayCry($Trainer.party[@poke1].species)
@cooldown = 5
redraw
elsif $mouse.inAreaLeftPress?(POKETCH_X+32+272,POKETCH_Y+32+228,96,72) && @cooldown == -1
@poke2 += 1
@poke2 = 0 if @poke2 >= $Trainer.party.size
@poke2 += 1 if @poke2 == @poke1
@poke2 = 0 if @poke2 >= $Trainer.party.size
pbPlayCry($Trainer.party[@poke2].species)
@cooldown = 5
redraw
end
end
if @n
if @n[1] == 0
if @n[0] >= 40
@luvdiscLeft.x += 1
@luvdiscRight.x -= 1
elsif @n[0] <= 24
@luvdiscRight.mirror = false
@luvdiscLeft.mirror = true
@luvdiscLeft.x -= 2
@luvdiscRight.x += 2
end
elsif @n[1] > 0
@luvdiscLeft.x += 1
@luvdiscRight.x -= 1
end
@n[0] -= 1
if @n[1] > 0 && @n[0] % 30 == 0
@n[2] += 1
@hearts[@n[2]] = Sprite.new(@viewport)
@hearts[@n[2]].bmp("Graphics/Pictures/Poketch/Matchup Checker/heart")
@hearts[@n[2]].x = 100 + 64 * @n[2]
@hearts[@n[2]].y = 4
end
@n = nil if @n[0] == 0
end
end
def redraw
draw_pokes
@luvdiscLeft.x = 36
@luvdiscLeft.mirror = false
@luvdiscRight.x = 288
@luvdiscRight.mirror = true
for i in 0...3
@hearts.dispose if @hearts
end
end
def draw_pokes
for i in [email protected]
@icons.dispose if @icons
@icons = nil
@icons = Sprite.new(@viewport)
sp = pbFormat($Trainer.party[[@poke1,@poke2]].species)
@icons.bmp("Graphics/Icons/icon#{sp}")
@icons.poketch_average
@icons.src_rect.width = @icons.bitmap.width / 2
@icons.ox = @icons.bitmap.width / 4
@icons.oy = @icons.bitmap.height / 2
@icons.x = [64,320]
@icons.y = 264
end
end
def dispose
for i in @icons
i.dispose
end
@luvdiscLeft.dispose
@luvdiscRight.dispose
for h in @hearts
h.dispose
end
super
end
end
#==============================================================================#
# Pokétch Party app. Displays your team with their items. #
#==============================================================================#
class PoketchParty < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/blank")
@pokemon = []
refresh
end
def update
super
# Refresh every 80 frames
if @cooldown == -1
refresh
@cooldown = 80
end
for p in @pokemon
if $mouse.press?(p[1])
pbPlayCry(p[0])
end
end
end
def refresh
for i in 0...6
if @pokemon
@pokemon[1].dispose if @pokemon[1]
@pokemon[2].dispose if @pokemon[2]
@pokemon[3].dispose if @pokemon[3]
@pokemon[4].dispose if @pokemon[4]
@pokemon = nil
end
if $Trainer.party
@pokemon = []
@pokemon[0] = $Trainer.party.species
@pokemon[1] = Sprite.new(@viewport)
@pokemon[1].bmp("Graphics/Icons/icon#{pbFormat($Trainer.party.species)}")
if $Trainer.party[0].eggsteps == 0 && $Trainer.party[0].hp <= 0
@pokemon[1].color = Color.new(82,132,82)
else
@pokemon[1].poketch_average
end
@pokemon[1].src_rect.width = @pokemon[1].bitmap.width / 2
@pokemon[1].ox = @pokemon[1].bitmap.width / 4
@pokemon[1].oy = @pokemon[1].bitmap.height / 2
@pokemon[1].zoom_x = 1.5
@pokemon[1].zoom_y = 1.5
@pokemon[1].x = [95,287][i % 2]
@pokemon[1].y = [46,142,238][(i / 2).floor]
@pokemon[1].z = 1
@pokemon[2] = Sprite.new(@viewport)
@pokemon[2].bmp("Graphics/Pictures/Poketch/Party/hpbar")
@pokemon[2].x = [28,220][i % 2]
@pokemon[2].y = [86,182,270][(i / 2).floor]
@pokemon[3] = Sprite.new(@viewport)
@pokemon[3].bmp("Graphics/Pictures/Poketch/Party/hp")
perc = $Trainer.party.hp.to_f / $Trainer.party.totalhp.to_f
@pokemon[3].src_rect.width = perc * @pokemon[3].bitmap.width
@pokemon[3].x = @pokemon[2].x + 4
@pokemon[3].y = @pokemon[2].y + 4
if $Trainer.party.item && $Trainer.party.item > 0
@pokemon[4] = Sprite.new(@viewport)
@pokemon[4].bmp("Graphics/Pictures/Poketch/Party/item")
@pokemon[4].x = @pokemon[2].x + 112
@pokemon[4].y = @pokemon[2].y - 26
end
end
end
end
def dispose
for i in 0...6
if @pokemon
@pokemon[1].dispose if @pokemon[1]
@pokemon[2].dispose if @pokemon[2]
@pokemon[3].dispose if @pokemon[3]
@pokemon[4].dispose if @pokemon[4]
@pokemon = nil
end
end
super
end
end
#==============================================================================#
# Pokétch Color Changer. Changes the overlay color of the screen. #
#==============================================================================#
class PokeBattle_Trainer
attr_accessor :poketch_color
end
class PoketchColorChanger < PoketchApp
def initialize
super
@pos = [48,80,144,176,240,272]
@bg.bmp("Graphics/Pictures/Poketch/Color Changer/background")
@sel = $Trainer.poketch_color || 0
@slider = Sprite.new(@viewport)
@slider.bmp("Graphics/Pictures/Poketch/Color Changer/slider")
@slider.ox = 64
@slider.x = @pos[@sel]
@slider.y = 232
end
def update
if $mouse && $mouse.drag_object_x?(@slider)
@slider.x = 48 if @slider.x < 48
@slider.x = 272 if @slider.x > 272
case @slider.x
when 48..64
@sel = 0
when 65..112
@sel = 1
when 113..160
@sel = 2
when 161..208
@sel = 3
when 209..256
@sel = 4
else
@sel = 5
end
@slider.x = @pos[@sel]
if @sel == 0
$Poketch.no_color
else
$Poketch.set_color("Graphics/Pictures/Poketch/Color Changer/overlay#{@sel}")
end
$Trainer.poketch_color = @sel
end
end
def dispose
@slider.dispose
super
end
end
#==============================================================================#
# Pokétch Kitchen Timer. Can count down from 99 minutes max. #
#==============================================================================#
class PokemonTemp
attr_reader :poketch_timer
attr_accessor :poketch_timer_running
def poketch_timer=(value)
@poketch_timer = value
@poketch_timer = 0 if @poketch_timer < 0
end
end
module Graphics
class << Graphics
alias poketch_timer_update update
end
def self.update
poketch_timer_update
return if !$Poketch
return if !$PokemonTemp || !$PokemonTemp.poketch_timer || !$PokemonTemp.poketch_timer_running
if Graphics.frame_count % Graphics.frame_rate == 0
$PokemonTemp.poketch_timer -= 1
$Poketch.app.refresh if $Poketch.app.is_a?(PoketchKitchenTimer)
end
end
end
class PoketchKitchenTimer < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/#{$PokemonTemp.poketch_timer_running ? "active" : "idle"}")
@startBtn = Sprite.new(@viewport)
$PokemonTemp.poketch_timer = 0 if !$PokemonTemp.poketch_timer
path = "startBtn"
path = "startBtnClick" if $PokemonTemp.poketch_timer_running ||
$PokemonTemp.poketch_timer == 0
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/#{path}")
@startBtn.y = 256
@stopBtn = Sprite.new(@viewport)
path = $PokemonTemp.poketch_timer_running ? "stopBtn" : "stopBtnClick"
@stopBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/#{path}")
@stopBtn.x = 128
@stopBtn.y = 256
@resetBtn = Sprite.new(@viewport)
@resetBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/resetBtn")
@resetBtn.x = 256
@resetBtn.y = 256
@numbers = []
@arrows = []
refresh
for i in 0...8
@arrows = Sprite.new(@viewport)
path = ["up","down"][(i / 4).floor]
@arrows.bmp("Graphics/Pictures/Poketch/Kitchen Timer/arrow#{path}")
@arrows.x = [114,146,210,242][i % 4]
@arrows.y = [136,224][(i / 4).floor]
@arrows.visible = !$PokemonTemp.poketch_timer_running
end
@canstart = false if $PokemonTemp.poketch_timer_running || $PokemonTemp.poketch_timer == 0
@frame = 0
@i = nil
end
def update
super
if @i
@i += 1
if @i == 8
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/done1")
elsif @i == 16
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/done2")
end
@i = 0 if @i == 16
end
@frame += 1
@frame = 0 if @frame == 41
unless $PokemonTemp.poketch_timer_running
for i in 0...8
if $mouse.click?(@arrows)
increment = [600,60,10,1][i % 4]
$PokemonTemp.poketch_timer += [1,-1][(i / 4).floor] * increment
$PokemonTemp.poketch_timer = 0 if $PokemonTemp.poketch_timer >= 6000
update_can_start
refresh
end
@arrows.visible = @frame < 20
end
end
if click?(@resetBtn,"Graphics/Pictures/Poketch/Kitchen Timer","resetBtn")
$PokemonTemp.poketch_timer_running = false
$PokemonTemp.poketch_timer = 0
for i in 0...8
@arrows.visible = true
end
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/idle")
update_can_start
@stopBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/stopBtnClick")
refresh
@frame = 20
@i = nil
end
if $mouse.click?(@startBtn) && !$PokemonTemp.poketch_timer_running && @canstart
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/startBtnClick")
@stopBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/stopBtn")
$PokemonTemp.poketch_timer_running = true
for i in 0...8
@arrows.visible = false
end
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/active")
@i = nil
end
if $mouse.click?(@stopBtn) && $PokemonTemp.poketch_timer_running
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/startBtn")
@stopBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/stopBtnClick")
for i in 0...8
@arrows.visible = true
end
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/idle")
update_can_start
$PokemonTemp.poketch_timer_running = false
@frame = 20
@i = nil
end
end
def update_can_start
if $PokemonTemp.poketch_timer > 0
@canstart = true
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/startBtn")
else
@canstart = false
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/startBtnClick")
end
end
def refresh
n = [0,0,0,0]
begin
mins = ($PokemonTemp.poketch_timer / 60).floor
secs = $PokemonTemp.poketch_timer % 60
nmin = pbFormat(mins, 2).split("")
nsec = pbFormat(secs, 2).split("")
n = nmin.concat(nsec)
rescue; end
for i in 0...4
@numbers.dispose if @numbers
@numbers = nil
@numbers = Sprite.new(@viewport)
@numbers.bmp("Graphics/Pictures/Poketch/Kitchen Timer/numbers")
@numbers.src_rect.width = 24
@numbers.src_rect.x = 24 * n.to_i
@numbers.x = [116,148,212,244]
@numbers.y = 160
end
@i = 0 if $PokemonTemp.poketch_timer <= 0 && !@i && $PokemonTemp.poketch_timer_running
end
def dispose
@startBtn.dispose
@stopBtn.dispose
@resetBtn.dispose
for n in @numbers
n.dispose
end
super
end
end
#==============================================================================#
# Pokétch Analog Watch. Displays the current time, but analog. #
#==============================================================================#
class PoketchAnalogWatch < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Analog Watch/background")
@long = Sprite.new(@viewport)
@long.bmp("Graphics/Pictures/Poketch/Analog Watch/long")
@long.ox = @long.bitmap.width / 2
@long.oy = @long.bitmap.height
@long.x = 192
@long.y = 168
@short = Sprite.new(@viewport)
@short.bmp("Graphics/Pictures/Poketch/Analog Watch/short")
@short.ox = @short.bitmap.width / 2
@short.oy = @short.bitmap.height
@short.x = 192
@short.y = 168
@time = Time.now
position
end
def position
@short.angle = (@time.hour % 12) / 12.0 * -360
@long.angle = @time.min / 60.0 * -360
end
def update
if @time.hour != Time.now.hour || @time.min != Time.now.min
@time = Time.now
position
end
end
def dispose
@long.dispose
@short.dispose
super
end
end
#==============================================================================#
# Pokétch Stat Display. Shows party members' EVs/IVs. #
#==============================================================================#
class PoketchStatDisplay < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Stat Display/background")
@evBtn = Sprite.new(@viewport)
@evBtn.bmp("Graphics/Pictures/Poketch/Stat Display/evBtnClick")
@evBtn.x = 268
@evBtn.y = 108
@ivBtn = Sprite.new(@viewport)
@ivBtn.bmp("Graphics/Pictures/Poketch/Stat Display/ivBtn")
@ivBtn.x = 268
@ivBtn.y = 188
@sel = 0
@mode = :ev
@icon = Sprite.new(@viewport)
@icon.bmp("Graphics/Icons/icon#{pbFormat($Trainer.party[@sel].species)}")
@icon.poketch_average
@icon.src_rect.width = @icon.bitmap.width / 2
@icon.ox = @icon.bitmap.width / 4
@icon.oy = @icon.bitmap.height / 2
@icon.x = 312
@icon.y = 52
@txtsprite = Sprite.new(@viewport)
@txtsprite.bmp(384,320)
@txt = @txtsprite.bitmap
pbSetSystemFont(@txt)
@stats = []
draw
end
def update
super
if $mouse.click?(@ivBtn)
@ivBtn.bmp("Graphics/Pictures/Poketch/Stat Display/ivBtnClick")
@evBtn.bmp("Graphics/Pictures/Poketch/Stat Display/evBtn")
@mode = :iv
draw
end
if $mouse.click?(@evBtn)
@evBtn.bmp("Graphics/Pictures/Poketch/Stat Display/evBtnClick")
@ivBtn.bmp("Graphics/Pictures/Poketch/Stat Display/ivBtn")
@mode = :ev
draw
end
if $mouse.inAreaLeftPress?(POKETCH_X+296,POKETCH_Y+48,98,72) && @cooldown == -1
@cooldown = 8
@sel += 1
@sel = 0 if @sel >= $Trainer.party.size
pbPlayCry($Trainer.party[@sel].species)
@icon.bmp("Graphics/Icons/icon#{pbFormat($Trainer.party[@sel].species)}")
@icon.poketch_average
@icon.src_rect.width = @icon.bitmap.width / 2
@icon.ox = @icon.bitmap.width / 4
@icon.oy = @icon.bitmap.height / 2
draw
end
end
def draw
@txt.clear
pbDrawTextPositions(@txt,[
[_INTL("HP"),102,12,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("Atk."),102,64,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("Def."),102,116,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("SpAtk."),102,168,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("SpDef."),102,220,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("Speed"),102,272,0,Color.new(16,41,24),Color.new(57,82,49)]
])
a = (@mode == :ev ? $Trainer.party[@sel].ev : $Trainer.party[@sel].iv)
# Sorting it to [HP,Atk,Def,SpAtk,SpDef,Speed]
t = a[3]
a[3] = nil
a.compact!
a << t
for i in 0...a.size
@stats = [] if !@stats
n = pbFormat(a, a.to_s.size).split("")
for j in 0...3
@stats[j].dispose if @stats[j]
if j < n.size
@stats[j] = Sprite.new(@viewport)
@stats[j].bmp("Graphics/Pictures/Poketch/Stat Display/numbers")
@stats[j].src_rect.width = 20
@stats[j].src_rect.x = 20 * n[j].to_i
@stats[j].x = [[40],[24,56],[16,40,64]][n.size - 1][j]
@stats[j].y = 12 + 52 * i
end
end
end
end
def dispose
@evBtn.dispose
@ivBtn.dispose
for i in 0...6
next if !@stats
for j in 0...3
@stats[j].dispose if @stats[j]
end
@stats = nil
end
@icon.dispose
@txtsprite.dispose
super
end
end
#==============================================================================#
# Pokétch Roulette. Spins an arrow and stops when you tell it to. #
#==============================================================================#
class PoketchRoulette < PoketchApp
# Only usable if RPG.Net is found
# RNET is a boolean; true if RPG.Net.dll is found, false if not.
def self.usable?
return RNET
end
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Roulette/background")
@arrow = Sprite.new(@viewport)
@arrow.bmp("Graphics/Pictures/Poketch/Roulette/arrow")
@arrow.ox = @arrow.bitmap.width / 2
@arrow.oy = @arrow.bitmap.height / 2
@arrow.x = 160
@arrow.y = 160
@arrow.z = 2
@playBtn = Sprite.new(@viewport)
@playBtn.bmp("Graphics/Pictures/Poketch/Roulette/playBtn")
@playBtn.x = 310
@playBtn.y = 28
@stopBtn = Sprite.new(@viewport)
@stopBtn.bmp("Graphics/Pictures/Poketch/Roulette/stopBtnClick")
@stopBtn.x = 310
@stopBtn.y = 120
@clearBtn = Sprite.new(@viewport)
@clearBtn.bmp("Graphics/Pictures/Poketch/Roulette/clearBtn")
@clearBtn.x = 310
@clearBtn.y = 212
@board = Sprite.new(@viewport)
@board.bmp(280,280)
@board.x = 20
@board.y = 20
@overlays = []
@overlays[0] = Sprite.new(@viewport)
@overlays[0].bmp("Graphics/Pictures/Poketch/Roulette/circleOverlay1")
@overlays[0].x = 128
@overlays[0].y = 128
@overlays[0].z = 1
@overlays[1] = Sprite.new(@viewport)
@overlays[1].bmp("Graphics/Pictures/Poketch/Roulette/circleOverlay2")
@overlays[1].x = 20
@overlays[1].y = 20
@overlays[1].z = 1
@playing = false
@stopping = false
@frame = 0
@olddata = []
@newdata = []
end
def update
super
if $mouse.click?(@playBtn) && !@playing
@playBtn.bmp("Graphics/Pictures/Poketch/Roulette/playBtnClick")
@stopBtn.bmp("Graphics/Pictures/Poketch/Roulette/stopBtn")
@clearBtn.bmp("Graphics/Pictures/Poketch/Roulette/clearBtnClick")
@playing = true
end
if @playing
if @stopping
@arrow.angle -= 3 * [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16][[(@frame / 4).floor - 1,0].max]
@frame -= 1
if @frame <= 0
@frame = 0
@playing = false
@stopping = false
@playBtn.bmp("Graphics/Pictures/Poketch/Roulette/playBtn")
@stopBtn.bmp("Graphics/Pictures/Poketch/Roulette/stopBtnClick")
@clearBtn.bmp("Graphics/Pictures/Poketch/Roulette/clearBtn")
end
else
@arrow.angle -= 3 * [(@frame / 2).floor,16].min
@frame += 1
end
end
if !@playing && click?(@clearBtn,"Graphics/Pictures/Poketch/Roulette","clearBtn")
@board.bitmap.clear
end
if $mouse.click?(@stopBtn) && @playing
@stopBtn.bmp("Graphics/Pictures/Poketch/Roulette/stopBtnClick")
@frame = 64
@stopping = true
end
if !@playing
if $mouse.press?(@board) && !@player
@newdata = [$mouse.x-POKETCH_X-52,$mouse.y-POKETCH_Y-52]
else
@olddata.clear
@newdata.clear
end
end
if @newdata.size > 0
if @olddata.size > 0
@board.bitmap.draw_line(@olddata[0],@olddata[1],@newdata[0],@newdata[1],
Color.new(16,41,24),4)
end
@olddata = @newdata.clone
@newdata.clear
end
end
def dispose
@playBtn.dispose
@stopBtn.dispose
@clearBtn.dispose
@arrow.dispose
for o in @overlays
o.dispose
end
@board.dispose
super
end
end
#==============================================================================#
# Pokétch Day-Care Checker. Shows you what you got going on in the Day-care. #
#==============================================================================#
class PoketchDayCareChecker < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Day Care Checker/background")
@pokes = []
refresh
@frame = 0
end
def update
@frame += 1
if @frame % 50 == 0
@egg.dispose if @egg
if pbEggGenerated?
@egg = Sprite.new(@viewport)
@egg.bmp("Graphics/Pictures/Poketch/Day Care Checker/egg")
@egg.x = 166
@egg.y = 204
end
end
if @frame == 100
refresh
@frame = 0
end
end
def refresh
for i in 0...2
@pokes = [] if !@pokes
if $PokemonGlobal.daycare && $PokemonGlobal.daycare[0].is_a?(PokeBattle_Pokemon)
p = $PokemonGlobal.daycare
@pokes[0].dispose if @pokes[0]
@pokes[0] = Sprite.new(@viewport)
@pokes[0].bmp("Graphics/Icons/icon#{pbFormat(p[0].species)}")
@pokes[0].poketch_average
@pokes[0].src_rect.width = @pokes[0].bitmap.width / 2
@pokes[0].mirror = true
@pokes[0].ox = @pokes[0].bitmap.width / 4
@pokes[0].oy = @pokes[0].bitmap.height / 2
@pokes[0].zoom_x = 2
@pokes[0].zoom_y = 2
@pokes[0].x = [82,304]
@pokes[0].y = 224
n = pbFormat(p[1]).split("")
for j in 0...3
@pokes[j+1].dispose if @pokes[j+1]
@pokes[j+1] = Sprite.new(@viewport)
@pokes[j+1].bmp("Graphics/Pictures/Poketch/Day Care Checker/numbers")
@pokes[j+1].src_rect.width = 16
@pokes[j+1].src_rect.x = n[j].to_i * 16
@pokes[j+1].x = [56,264] + 32 * j
@pokes[j+1].y = 40
Credit:
- Marin (obliged)
- Halo Route (optional)
Sorry for bad English
Poketch_0
Code:
#==============================================================================#
# Pokétch for Pokémon Essentials v16.X | v17.X #
# v1.1 #
# #
# by Marin #
#==============================================================================#
# Dual-screen usage #
# #
# Double DEFAULTSCREENHEIGHT (usually 384; 384 * 2 = 768) #
# Set DUAL_SCREEN to true #
# Set POKETCH_Y to 384 #
# Make sure NO_POKETCH_BACKGROUND has a value #
# #
# This Dual-screen script has most likely messed up your battle scene #
# You will have to do some repositioning in PokeBattle_SceneConstants #
# #
# To give or take the Pokétch, use pbObtainPoketch and pbTakePoketch #
#==============================================================================#
# Single-screen usage #
# #
# Set DEFAULTSCREENHEIGHT to 384 or whatever height you want #
# Set DUAL_SCREEN to false #
# Set POKETCH_Y to 0 #
# #
# To call the Pokétch, use pbPoketch #
# You can use this method to call it from other menus #
#==============================================================================#
# Apps #
# #
# To enable or disable an app, use pbEnableApp(id) or pbDisableApp(id) #
# To enable or disable all apps, use pbEnableAll or pbDisableAll #
# To determine if an app is enabled or not, use pbAppEnabled?(id) #
# #
# To get the ID of an app, you could do, say, "PoketchApps::PoketchRotom" #
# This will get you the ID of an app called "PoketchRotom" #
# #
# Alternative: #
# Scroll to the bottom of Pokétch_Apps. #
# You'll see a module with the number before the app. #
# #
# If you want to change the Pokétch to a specific app, you can use #
# pbChangeApp(app_id) #
# This method bypasses usability and availability. #
#==============================================================================#
# Making your own apps #
# #
# The top of Pokétch_Apps contains a small tutorial as to how to make your own #
# apps. #
# #
# Did you successfully make your own app? Feel free to share it in the #
# PokéCommunity or RelicCastle thread for others to use! #
#==============================================================================#
# Please give credit when using this. #
#==============================================================================#
# Set this to false if you don't want two screens. You'll also have to set
# DEFAULTSCREENHEIGHT to 384.
DUAL_SCREEN = true
# If you want this Pokétch to be on a single screen or elsewhere on the screen,
# You'll likely want to set this value to 0. If not, set it to 384.
POKETCH_Y = 0
POKETCH_X = 512
# If you don't have the Pokétch, this is the image that will be displayed instead
# (because it's not ideal to have just a black screen) (DUAL_SCREEN ONLY)
NO_POKETCH_BACKGROUND = "Graphics/Pictures/Poketch/background"
$Poketch = nil if $Poketch # F12 soft reset fix
$no_poketch_bg = nil if $no_poketch_bg # F12 soft reset fix
def pbPoketch # (NON-DUAL_SCREEN ONLY)
return if $Poketch
$Poketch = Poketch.new
$Poketch.show
if $Poketch.app
$Poketch.run_app
$Poketch.hideOverlay
end
loop do
Graphics.update
Input.update
$Poketch.update
break if Input.trigger?(Input::B)
end
if $Poketch.app
$Poketch.showOverlay(proc { $Poketch.app.dispose } )
24.times { Graphics.update; Input.update; $Poketch.update }
end
$Poketch.hide
$Poketch.dispose
end
def pbChangeApp(id)
return if $Poketch
$Poketch.changeApp(id)
end
# Give the Pokétch (DUAL_SCREEN ONLY)
def pbObtainPoketch(animate = true)
return if $Poketch
$Trainer.poketch = true
pbEnableApp(PoketchApps::PoketchClock)
pbEnableApp(PoketchApps::PoketchClicker)
pbEnableApp(PoketchApps::PoketchCalculator)
pbEnableApp(PoketchApps::PoketchAnalogWatch)
$Poketch = Poketch.new
$Poketch.show(animate)
if $Poketch.app
$Poketch.run_app
$Poketch.hideOverlay
end
$no_poketch_bg.dispose if $no_poketch_bg
end
# Take away the Pokétch (DUAL_SCREEN ONLY)
def pbTakePoketch(animate = true)
return if !$Poketch
if $Poketch.app
$Poketch.showOverlay(proc { $Poketch.app.dispose } )
24.times { Graphics.update; Input.update; $Poketch.update }
end
make_background
$Poketch.overlay.dispose
$Poketch.hide(animate)
$Poketch.dispose
$Poketch = nil
$Trainer.poketch = false
end
def pbEnableAll
for const in PoketchApps.constants
key = appID(const)
$Trainer.poketch_app_access << key if !$Trainer.poketch_app_access.include?(key)
end
$Poketch.refresh if $Poketch
end
def pbDisableAll
$Trainer.poketch_app_access.clear
$Poketch.refresh if $Poketch
end
def pbEnableApp(id)
$Trainer.poketch_app_access << id if !$Trainer.poketch_app_access.include?(id)
$Poketch.refresh if $Poketch
end
def pbDisableApp(id)
$Trainer.poketch_app_access.delete(id)
$Poketch.refresh if $Poketch
end
def pbAppEnabled?(id)
return $Trainer.poketch_app_access.include?(id)
end
class Poketch
attr_accessor :app
attr_accessor :apps
attr_accessor :updated_frame
attr_accessor :overlay
def initialize
@viewport = Viewport.new(POKETCH_X,POKETCH_Y,Graphics.width,Graphics.height)
@viewport.z = 100000
@viewport2 = Viewport.new(POKETCH_X,POKETCH_Y,Graphics.width,Graphics.height)
@viewport2.z = 100002
@overlay = Sprite.new(@viewport2)
@overlay.x = 32
@overlay.y = 32
@poketch = Sprite.new(@viewport)
@poketch.bmp("Graphics/Pictures/Poketch/poketch#{["Male","Female"][$Trainer.gender]}")
@btnUp = Sprite.new(@viewport)
@btnUp.bmp("Graphics/Pictures/Poketch/btnUp")
@btnUp.x = 448
@btnUp.y = 66
@btnDown = Sprite.new(@viewport)
@btnDown.bmp("Graphics/Pictures/Poketch/btnDown")
@btnDown.x = 448
@btnDown.y = 191
@transUp = Sprite.new(@viewport2)
@transUp.bmp("Graphics/Pictures/Poketch/transition")
@transUp.x = 32
@transUp.y = 32
@transUp.zoom_y = 160
@transUp.opacity = 0
@transUp.z = 1
@transDown = Sprite.new(@viewport2)
@transDown.bmp("Graphics/Pictures/Poketch/transition")
@transDown.x = 32
@transDown.y = 352
@transDown.zoom_y = 160
@transDown.oy = @transDown.bitmap.height
@transDown.opacity = 0
@transDown.z = 1
@i = 0
@proc = nil
@showOverlay = false
@hideOverlay = false
hide(false)
@transUp.zoom_y = 170
@transDown.zoom_y = 170
@sel = 0
sort_apps
if $Trainer.poketch_last_app
update_selection
if @apps[$Trainer.poketch_last_app]
@sel = $Trainer.poketch_last_app
end
end
@app = @apps[@sel] if @apps[@sel]
if !$Trainer.poketch_color || $Trainer.poketch_color == 0
no_color
else
set_color("Graphics/Pictures/Poketch/Color Changer/overlay#{$Trainer.poketch_color}")
end
end
def update_selection
if $Trainer.poketch_last_app.is_a?(Symbol)
$Trainer.poketch_last_app = appID($Trainer.poketch_last_app)
end
end
def show(animate = true)
unless @poketch.opacity >= 255
for i in 0...25
if animate
Graphics.update
Input.update
end
@poketch.opacity += 256 / 24.0
@btnUp.opacity += 256 / 24.0
@btnDown.opacity += 256 / 24.0
@transUp.opacity += 256 / 23.0
@transDown.opacity += 256 / 23.0
@overlay.opacity += 256 / 23.0 rescue nil
end
@transDown.zoom_y = 160
@transUp.zoom_y = 160
showOverlay
end
end
def hide(animate = true)
unless @poketch.opacity == 0
for i in 0...25
if animate
Graphics.update
Input.update
end
@poketch.opacity -= 256 / 24.0
@btnUp.opacity -= 256 / 24.0
@btnDown.opacity -= 256 / 24.0
@transUp.opacity -= 256 / 24.0
@transDown.opacity -= 256 / 24.0
@overlay.opacity -= 256 / 20.0 rescue nil
end
end
end
def showOverlay(proc = nil)
@showOverlay = true
@proc = proc
end
def hideOverlay(proc = nil)
@hideOverlay = true
@proc = proc
end
def sort_apps
@apps = {}
for const in PoketchApps.constants
key = appID(const)
cls = eval(const.to_s)
@apps[key] = cls if pbAppEnabled?(key) && cls.usable?
end
end
def refresh
sort_apps
@app.refresh if @app.respond_to?("refresh")
if @apps.size == 0
showOverlay
@proc = proc { @app.dispose if @app && @app.respond_to?("dispose") }
else
if !@app
for const in PoketchApps.constants
key = appID(const)
if @apps[key]
@sel = key
update_selection
break
end
end
run_app
hideOverlay
else
if [email protected] { |app| app[1] }.include?(@app.class)
showOverlay
@proc = proc do
@app.dispose if @app.respond_to?("dispose")
move_up
run_app
hideOverlay
end
end
end
end
end
def run_app
update_selection
@app = @apps[@sel].new if @apps[@sel]
end
def update
if @showOverlay
if @transUp.zoom_y != 160
@transUp.zoom_y += 10
@transDown.zoom_y += 10
end
@i += 1
if @i == 6
@btnDown.bmp("Graphics/Pictures/Poketch/btnDown")
@btnUp.bmp("Graphics/Pictures/Poketch/btnUp")
end
if @i == 24
@showOverlay = false
@proc.call if @proc
@proc = nil
@i = 0
end
return
end
if @hideOverlay
if @transUp.zoom_y != 0
@transUp.zoom_y -= 10
@transDown.zoom_y -= 10
end
@i += 1
if @i == 6
@btnDown.bmp("Graphics/Pictures/Poketch/btnDown")
@btnUp.bmp("Graphics/Pictures/Poketch/btnUp")
end
if @i == 16
@hideOverlay = false
@proc.call if @proc
@proc = nil
@i = 0
end
return
end
@app.update if @app.respond_to?("update")
return if @apps.size == 0
if $mouse && $mouse.click?(@btnUp)
click_up
end
if $mouse && $mouse.click?(@btnDown)
click_down
end
end
# Change the app to something else. Bypasses usability/availability.
def changeApp(id)
@sel = id
update_selection
refresh
showOverlay
@proc = proc do
@app.dispose if @app && @app.respond_to?("dispose")
run_app
$Trainer.poketch_last_app = @sel
update_selection
hideOverlay
end
end
# For the Itemfinder/Notepad to be able to read these buttons.
attr_reader :btnUp
attr_reader :btnDown
def click_up(animate = true)
@btnUp.bmp("Graphics/Pictures/Poketch/btnUpClick") if animate
refresh
showOverlay
@proc = proc do
@app.dispose if @app && @app.respond_to?("dispose")
move_up
run_app
$Trainer.poketch_last_app = @sel
update_selection
hideOverlay
end
end
def click_down(animate = true)
@btnDown.bmp("Graphics/Pictures/Poketch/btnDownClick") if animate
refresh
showOverlay
@proc = proc do
@app.dispose if @app && @app.respond_to?("dispose")
move_down
run_app
$Trainer.poketch_last_app = @sel
update_selection
hideOverlay
end
end
def move_up
s = false
i = @sel
if @apps.size > 1
while !s
i += 1
if @apps[i]
s = true
@sel = i
end
if i >= PoketchApps.constants.size
i = -1
end
end
end
update_selection
end
def move_down
s = false
i = @sel
if @apps.size > 1
while !s
i -= 1
if @apps[i]
s = true
@sel = i
end
if i < 0
i = PoketchApps.constants.size
end
end
end
update_selection
end
def set_color(path)
@overlay.bmp(path)
end
def no_color
@overlay.bitmap = nil
end
def dispose
showOverlay
@proc = proc do
@app.dispose if @app && @app.respond_to?("dispose")
end
@poketch.dispose
@overlay.dispose
@btnUp.dispose
@btnDown.dispose
@transUp.dispose
@transDown.dispose
$Poketch = nil
end
end
# Do not change.
ERRORTEXT += "[Pokétch v1.1]\r\n" if defined?(ERRORTEXT)
Code:
# This is what actually makes the game dual-screen. DEFAULTSCREENHEIGHT still
# has to be doubled (384 * 2) = 768. Don't change this code below.
if DUAL_SCREEN
module Graphics
@@height = DEFAULTSCREENHEIGHT
@@width = DEFAULTSCREENWIDTH / 2
end
end
class PokeBattle_Trainer
attr_accessor :poketch
attr_accessor :poketch_last_app
attr_writer :poketch_app_access
alias poketch_init initialize
def initialize(name, trainertype)
poketch_init(name, trainertype)
@poketch = false
@poketch_last_app = PoketchClock
@poketch_app_access = []
end
def poketch_app_access
@poketch_app_access = [] if !@poketch_app_access
return @poketch_app_access
end
end
# Converts integers to string with N digits. Examples:
# -> pbFormat(19,4) => "0019"
# -> pbFormat(7) => "007"
# -> pbFormat(321,3) => "321"
def pbFormat(int, n = 3)
strInt = int.to_s
numLeading = n - strInt.length
return strInt if numLeading <= 0
leadingZeroes = "0" * numLeading
return leadingZeroes + strInt
end
class Sprite
unless (pbMarinUtility rescue false)
def bmp(arg1 = nil, arg2 = nil)
if arg1
if arg1.is_a?(Bitmap)
self.bitmap = arg1
elsif arg2
self.bitmap = Bitmap.new(arg1, arg2)
else
self.bitmap = BitmapCache.load_bitmap(arg1)
end
else
return self.bitmap
end
end
end
end
if DUAL_SCREEN
class Spriteset_Map
alias poketch_init initialize
def initialize(map = nil)
poketch_init(map)
if $Trainer && $Trainer.poketch && !$Poketch
pbObtainPoketch(false)
else
return if $no_poketch_bg
make_background
end
end
alias poketch_update update
def update
poketch_update
# Ensuring the Pokétch only updates once per frame (bug fix for map transfer)
if $Poketch && $Poketch.updated_frame != Graphics.frame_count
$Poketch.update
$Poketch.updated_frame = Graphics.frame_count
end
end
end
end
def make_background
$no_poketch_bg.dispose if $no_poketch_bg
$no_poketch_bg = Sprite.new((v=Viewport.new(POKETCH_X,POKETCH_Y,Graphics.width,Graphics.height);v.z=99999;v))
$no_poketch_bg.bmp(NO_POKETCH_BACKGROUND)
end
class PoketchApp
def self.usable?
return true
end
def initialize
@viewport = Viewport.new(POKETCH_X+32,POKETCH_Y+32,384,320)
@viewport.z = 100001
@cooldown = -1
@tmp = []
@bg = Sprite.new(@viewport)
end
def update
@cooldown -= 1 if @cooldown > -1
if @cooldown == 0 && @tmp[0]
@tmp[0].bmp(@tmp[1]+"/"+@tmp[2])
end
end
# "sprite": The sprite that is clicked on
# "path": Used for "unclicked" and "clicked"
# "unclicked": The path "sprite" will get when the cooldown ends (path is "path"/"unclicked")
# "clicked": The path "sprite" will get when clicked on (path is "path"/"clicked")
# "cooldown": How long other mouse input in this app will be disabled
def click?(sprite, path, unclicked, clicked = unclicked + "Click", cooldown = 3)
return false if !$mouse || !$mouse.click?(sprite) || @cooldown > -1
@tmp = [sprite,path,unclicked]
@tmp[0].bmp(@tmp[1]+"/"+clicked)
@cooldown = cooldown
return true
end
def refresh
end
def dispose
@bg.dispose
@viewport.dispose
$Poketch.app = nil
end
end
class Sprite
def poketch_average
bmp = self.bitmap.clone
for x in 0...bmp.width
for y in 0...bmp.height
px = bmp.get_pixel(x, y)
next if px.alpha == 0
av = (px.red + px.green + px.blue) / 3
if av < 96
color = Color.new(57,82,49)
elsif av < 128
color = Color.new(76,120,74)
elsif av < 170
color = Color.new(82,132,82)
else
color = Color.new(115,181,115)
end
bmp.set_pixel(x, y, color)
end
end
self.bitmap = bmp.clone
end
end
# Drawing method
RNET = File.file?("RPG.Net.dll")
if RNET
Win32API.new('RPG.Net.dll', 'Initialize', 'i', '').call(4)
class Bitmap
DrawLine = Win32API.new('RPG.Net.dll', 'BmDrawLine', 'iiiiiii', '')
def draw_line(x1, y1, x2, y2, color, thickness = 4)
c = color
c = [c.red.to_i.chr, c.green.to_i.chr, c.blue.to_i.chr, c.alpha.to_i.chr].join.unpack('L').shift
DrawLine.call(__id__, x1, y1, x2, y2, c, thickness)
end
end
end
def appID(const)
return PoketchApps.const_get(const) rescue nil
end
[CODE]
Poketch_2
# when using an app that uses RPG.Net. I can sadly not do anything about this.
# Process of creating your own application:
# -> Create the class
# -> Make sure it inherits from "PoketchApp"
# -> "Register" the app in the PoketchApps module by adding a unique ID and
# the classname.
# Why to inherit PoketchApp and call "super" in some methods:
# class "PoketchApp"'s intention is to make your code as small as possible.
# It will make you an @bg sprite and an @viewport if you call "super" in
# the constructor of your class (def initialize). Make sure to call this first.
# It will also handle "def click?", which is a method that handles normal
# button clicks. To use, make sure to call "super" in the update method of your
# class (def update).
# To make sure everything (including the actual $Poketch.app), @bg, and @viewport
# disposes correctly, call "super" LAST in your dispose method (def dispose).
# If you only want the app to be available under certain circumstances (ON TOP OF
# THE APP ENABLED STATE), you can overwrite "def self.usable?". Apps that need
# RPG.Net to function, for example, have "return RNET".
# Additional Utility: (more can be found in Pokétch_Utility)
# <Sprite>.poketch_average: Will average out your sprite's colors to be of the
# same 4 colors the Pokétch originally has. (used for party icons)
# pbFormat(integer, digits): Better to show some examples:
# -> pbFormat(27,3) # => "027"
# -> pbFormat(12,2) # => "12"
#==============================================================================#
# Pokétch Clock. Shows the computer's time. #
#==============================================================================#
class PoketchClock < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Clock/background")
@time = Time.now
@numbers = []
draw_time
end
def update
if @time.hour != Time.now.hour || @time.min != Time.now.min
draw_time
@time = Time.now
end
end
def draw_time
n = pbFormat(@time.hour,2).split("")
n.concat(pbFormat(@time.min,2).split(""))
for i in 0...4
@numbers.dispose if @numbers
@numbers = nil
@numbers = Sprite.new(@viewport)
@numbers.bmp("Graphics/Pictures/Poketch/Clock/numbers")
@numbers.src_rect.width = 64
@numbers.src_rect.x = n.to_i * 64
@numbers.x = [15,97,208,290]
@numbers.y = 82
end
end
def dispose
for n in @numbers
n.dispose
end
super
end
end
#==============================================================================#
# Pokétch Clicker. Click your heart away. #
#==============================================================================#
class PokemonTemp
attr_accessor :click_count
end
class PoketchClicker < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Clicker/background")
@numbers = []
@btn = Sprite.new(@viewport)
@btn.bmp("Graphics/Pictures/Poketch/Clicker/btn")
@btn.x = 128
@btn.y = 166
$PokemonTemp.click_count = 0 if !$PokemonTemp.click_count
draw_count
end
def draw_count
n = pbFormat($PokemonTemp.click_count, 4).split("")
for i in 0...4
@numbers.dispose if @numbers
@numbers = nil
@numbers = Sprite.new(@viewport)
@numbers.bmp("Graphics/Pictures/Poketch/Clicker/numbers")
@numbers.src_rect.width = 24
@numbers.src_rect.x = n.to_i * 24
@numbers.x = 135 + 30 * i
@numbers.y = 68
end
end
def update
super
if click?(@btn, "Graphics/Pictures/Poketch/Clicker", "btn")
$PokemonTemp.click_count += 1
$PokemonTemp.click_count = 0 if $PokemonTemp.click_count > 9999
draw_count
end
end
def dispose
$PokemonTemp.click_count = 0
super
end
end
#==============================================================================#
# Pokétch Calculator. You can do basic math with this. #
#==============================================================================#
class Float
def round_to(x)
return (self * 10 ** x).round.to_f / 10 ** x
end
end
# This one's rather complex. Ignore this.
class PoketchCalculator < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Calculator/background")
@buttons = []
@buttons[0] = []
@buttons[0][0] = 0
@buttons[0][1] = Sprite.new(@viewport)
@buttons[0][1].bmp("Graphics/Pictures/Poketch/Calculator/btnLarge")
@buttons[0][1].x = 32
@buttons[0][1].y = 256
@buttons[0][2] = Sprite.new(@viewport)
@buttons[0][2].bmp("Graphics/Pictures/Poketch/Calculator/buttonnumbers")
@buttons[0][2].src_rect.width = 16
@buttons[0][2].x = @buttons[0][1].x + 24
@buttons[0][2].y = @buttons[0][1].y + 16
for i in 0...9
@buttons[i+1] = []
@buttons[i+1][0] = i+1
@buttons[i+1][1] = Sprite.new(@viewport)
@buttons[i+1][1].bmp("Graphics/Pictures/Poketch/Calculator/btnSmall")
@buttons[i+1][1].x = 32 + 64 * (i % 3)
@buttons[i+1][1].y = 192 - 64 * (i / 3).floor
@buttons[i+1][2] = Sprite.new(@viewport)
@buttons[i+1][2].bmp("Graphics/Pictures/Poketch/Calculator/buttonnumbers")
@buttons[i+1][2].src_rect.width = 16
@buttons[i+1][2].src_rect.x = 16 * (i + 1)
@buttons[i+1][2].x = @buttons[i+1][1].x + 24
@buttons[i+1][2].y = @buttons[i+1][1].y + 16
end
@operators = []
for i in 0...6
@operators = []
@operators[0] = ["+","-","*","/","=","."]
@operators[1] = Sprite.new(@viewport)
@operators[1].bmp("Graphics/Pictures/Poketch/Calculator/btn#{i == 4 ? "Large" : "Small"}")
@operators[1].x = [224,288][i % 2]
@operators[1].y = 128 + 64 * (i / 2).floor
@operators[1].x = 160 if i == 5
@operators[1].y = 256 if i == 5
@operators[2] = Sprite.new(@viewport)
@operators[2].bmp("Graphics/Pictures/Poketch/Calculator/operators")
@operators[2].src_rect.width = 24
@operators[2].src_rect.x = i * 24
@operators[2].x = @operators[1].x + 17
@operators[2].y = @operators[1].y + 14
end
@cbtn = []
@cbtn[0] = nil
@cbtn[1] = Sprite.new(@viewport)
@cbtn[1].bmp("Graphics/Pictures/Poketch/Calculator/btnLarge")
@cbtn[1].x = 224
@cbtn[1].y = 64
@cbtn[2] = Sprite.new(@viewport)
@cbtn[2].bmp("Graphics/Pictures/Poketch/Calculator/cbtn")
@cbtn[2].x = @cbtn[1].x + 19
@cbtn[2].y = @cbtn[1].y + 16
@activeoperator = []
@activeoperator[0] = nil
@activeoperator[1] = Sprite.new(@viewport)
@activeoperator[1].x = 20
@activeoperator[1].y = 18
@activenums = []
for i in 0...10
@activenums = []
@activenums[0] = nil
@activenums[1] = Sprite.new(@viewport)
@activenums[1].bmp("Graphics/Pictures/Poketch/Calculator/empty")
@activenums[1].x = 344 - 32 * i
@activenums[1].y = 18
end
@old = ""
@stillactive = false
@error = false
@oldop = nil
@reset_on_next = false
end
def click?(btn,path,unclicked,clicked=unclicked+"Click")
return false if !$mouse || !$mouse.click?(btn[1]) || @cooldown > -1
@tmp = [btn,path,unclicked]
@tmp[0][1].bmp(@tmp[1]+"/"+clicked)
@tmp[0][2].y += 12
@cooldown = 3
return true
end
def update
@cooldown -= 1 if @cooldown > -1
if @cooldown == 0
@tmp[0][1].bmp(@tmp[1]+"/"+@tmp[2])
@tmp[0][2].y -= 12
end
for i in [email protected]
p = (i == 0 ? "btnLarge" : "btnSmall")
if click?(@buttons,"Graphics/Pictures/Poketch/Calculator",p)
if @error
reset_numbers
end
if @activeoperator[0] && @stillactive || @reset_on_next
@stillactive = false
@old = @activenums.map { |n| n[0] }.join.reverse
reset_numbers
@reset_on_next = false
end
if !@activenums[9][0]
@activenums[9][1].dispose
@activenums[9] = nil
@activenums.compact!
for j in [email protected]
@activenums[j][1].x -= 32
end
n = []
n[0] = @buttons[0]
n[1] = Sprite.new(@viewport)
n[1].bmp("Graphics/Pictures/Poketch/Calculator/numbers")
n[1].src_rect.width = 20
n[1].src_rect.x = 20 * i
n[1].x = 344
n[1].y = 18
@activenums.insert(0,n)
end
end
end
for i in [email protected]
p = (i == 4 ? "btnLarge" : "btnSmall")
if click?(@operators,"Graphics/Pictures/Poketch/Calculator",p)
if @operators[0] == "."
if !@activenums[9][0]
@activenums[9][1].dispose
@activenums[9] = nil
@activenums.compact!
for j in [email protected]
@activenums[j][1].x -= 32
end
n = []
n[0] = "."
n[1] = Sprite.new(@viewport)
n[1].bmp("Graphics/Pictures/Poketch/Calculator/dot")
n[1].x = 344
n[1].y = 18
@activenums.insert(0,n)
@reset_on_next = false
end
elsif @operators[0] == "="
cur = @activenums.map { |n| n[0] }.join.reverse
if !@old || @old == ""
return
end
ex = nil
@old = @old.to_f.to_s
cur = cur.to_f.to_s
if @activeoperator[0]
ex = @old + @activeoperator[0] + cur
else
ex = cur + @oldop + @old
end
if ex.size == 1 || ex.size == 0
throw_error
return
end
n = (eval(ex) rescue nil)
if !n
throw_error
return
end
reset_numbers
# Some trickery to perform float operations properly, but also cut
# the .0 if it's a whole numbers (all calculations are done with floats)
n = n.to_f
slots = 9 - n.to_s.split('.')[0].size
n = n.round_to(slots).to_s
n = n.chomp('.0') if n[n.size - 2..n.size] == '.0'
n = n.reverse.split("") rescue nil
if !n || n.size == 0 || n.size > 10
throw_error
return
end
for j in 0...n.size
if n[j] == "-"
@activenums[j][0] = "-"
@activenums[j][1].bmp("Graphics/Pictures/Poketch/Calculator/operators")
@activenums[j][1].src_rect.width = 24
@activenums[j][1].src_rect.x = 24
elsif n[j] == "."
@activenums[j][0] = "."
@activenums[j][1].bmp("Graphics/Pictures/Poketch/Calculator/dot")
else
@activenums[j][0] = n[j].to_i
@activenums[j][1].bmp("Graphics/Pictures/Poketch/Calculator/numbers")
@activenums[j][1].src_rect.width = 20
@activenums[j][1].src_rect.x = 20 * n[j].to_i
end
end
@old = cur if @activeoperator[0]
@oldop = @activeoperator[0] if @activeoperator[0]
@activeoperator[0] = nil
@activeoperator[1].bitmap = nil
@reset_on_next = true
else
@activeoperator[0] = @operators[0]
@activeoperator[1].bmp("Graphics/Pictures/Poketch/Calculator/operators")
@activeoperator[1].src_rect.width = 24
@activeoperator[1].src_rect.x = 24 * i
@stillactive = true
@reset_on_next = false
end
end
end
if click?(@cbtn,"Graphics/Pictures/Poketch/Calculator","btnLarge")
reset_numbers
@old = ""
@stillactive = false
@activeoperator[0] = nil
@activeoperator[1].bitmap = nil
@oldop = nil
@error = false
@reset_on_next = false
end
end
def reset_numbers
for i in 0...10
@activenums[0] = nil
@activenums[1].bmp("Graphics/Pictures/Poketch/Calculator/empty")
end
end
def throw_error
@old = ""
@stillactive = false
@activeoperator[0] = nil
@activeoperator[1].bitmap = nil
for i in 0...10
@activenums[1].bmp("Graphics/Pictures/Poketch/Calculator/error")
end
@error = true
end
def dispose
for btn in @buttons
btn[0] = nil
btn[1].dispose if btn[1]
btn[2].dispose if btn[2]
end
for op in @operators
op[0] = nil
op[1].dispose if op[1]
op[2].dispose if op[2]
end
for n in @activenums
n[0] = nil
n[1].dispose if n[1]
@activeoperator[0] = nil
@activeoperator[1].dispose if @activeoperator
end
@cbtn[0] = nil
@cbtn[1].dispose if @cbtn[1]
@cbtn[2].dispose if @cbtn[2]
@bg.dispose
super
end
end
#==============================================================================#
# Pokétch Item Finder. AKA Dowsing Machine. #
#==============================================================================#
# For an item to be picked up by the Itemfinder, make sure it has ".hidden"
# (without the quotation marks) in the event name.
# How you should make your item ball events:
# -> Kernel.pbItemBall(item)
# -> Script: pbUnlist(event_id)
# -> Erase event
class Game_Event
attr_accessor :listed
alias poketch_init initialize
def initialize(map_id, event, map = nil)
poketch_init(map_id, event, map)
@listed = true # Set to true, but whether it's actually listed or not
# depends on the name.
end
end
# If you call this on an event, it'll be no longer listed in the Itemfinder
# (if it even was)
def pbUnlist(event_id)
$game_map.events[event_id].listed = false if $game_map.events[event_id]
end
# The Itemfinder will show this event (but still only if it has .hidden in name)
def pbList(event_id)
$game_map.events[event_id].listed = true if $game_map.events[event_id]
end
class PoketchItemFinder < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Item Finder/background")
@circles = []
@items = []
end
def update
super
if $mouse && $mouse.inAreaLeftPress?(POKETCH_X+32,POKETCH_Y+32,384,320) && @cooldown == -1
@cooldown = 16
x = $mouse.x - 32
y = $mouse.y - POKETCH_Y - 32
if x < 384 && y < 320
c = Sprite.new(@viewport)
c.bmp("Graphics/Pictures/Poketch/Item Finder/circle")
c.ox = c.bitmap.width / 2
c.oy = c.bitmap.height / 2
c.x = x
c.y = y
c.zoom_x = 0
c.zoom_y = 0
@circles << [40, c]
redraw((x - 11) / 22, (y - 11) / 22)
end
end
for i in [email protected]
@circles[0] -= 1
@circles[1].zoom_x += 0.06
@circles[1].zoom_y += 0.06
if @circles[0] < 16
@circles[1].opacity -= 16
end
if @circles[0] == 0
@circles[1].dispose
@circles[1] = nil
@circles = nil
end
end
@circles.compact!
for i in [email protected]
@items[0] -= 1
@items[1].opacity += 255 / (@items[0] > 48 ? 16.0 : @items[0] < 32 ? -32.0 : 255)
if @items[0] == 0
@items[1].dispose
@items[1] = nil
@items = nil
end
end
@items.compact!
$Poketch.click_up if $mouse.click?($Poketch.btnUp)
$Poketch.click_down if $mouse.click?($Poketch.btnDown)
end
def redraw(cx, cy)
for i in [email protected]
@items[1].dispose
@items = nil
end
@items.compact!
for k in $game_map.events.keys
e = $game_map.events[k]
# This one line below is the statement that decides if an event should be
# shown as a dot. The rest is just positioning, locating, and other crap.
if e.name.include?(".hidden") && e.listed
if $game_player.x - e.x >= -8 && $game_player.x - e.x <= 8
if $game_player.y - e.y >= -7 && $game_player.y - e.y <= 7
x = e.x - $game_player.x + 8
y = e.y - $game_player.y + 7
if cx - x >= -5 && cx - x <= 5
if cy - y >= -4 && cy - y <= 4
item = Sprite.new(@viewport)
item.bmp("Graphics/Pictures/Poketch/Item Finder/item")
item.x = 11 + 22 * x
item.y = 11 + 22 * y
item.opacity = 0
@items << [64, item]
end
end
end
end
end
end
end
def dispose
for c in @circles
c[1].dispose
end
for i in @items
i[1].dispose
end
super
end
end
#==============================================================================#
# Pokétch Rotom. Tells you things depending on what you predefine. #
#==============================================================================#
# Normal Rotom Text:
# Array of message rotom can send by random.
# Forced Rotom Text:
# Array of messages rotom can send by random.
# If there are any messages in this array, it will always pick from this array.
# This will delete all other normal rotom messages.
def pbSetRotomText(array_of_messages)
array_of_messages = [array_of_messages] if !array_of_messages.is_a?(Array)
$Trainer.poketch_rotom_text = array_of_messages
end
# This will add to all other normal rotom messages.
def pbAddRotomText(text)
$Trainer.poketch_rotom_text = [] if !$Trainer.poketch_rotom_text
$Trainer.poketch_rotom_text << text
end
# This will delete a message that equals the passed "text" from the normal rotom messages
def pbDeleteRotomText(text)
$Trainer.poketch_rotom_text = [] if !$Trainer.poketch_rotom_text
$Trainer.poketch_rotom_text.delete(text) if $Trainer.poketch_rotom_text.include?(text)
end
# This will delete all other forced rotom messages
def pbSetForcedRotomText(array_of_message)
array_of_messages = [array_of_messages] if !array_of_messages.is_a?(Array)
$Trainer.poketch_rotom_text_forced = array_of_messages
end
# This will add to all other forced rotom messages
def pbAddForcedRotomText(text)
$Trainer.poketch_rotom_text_forced = [] if !$Trainer.poketch_rotom_text_forced
$Trainer.poketch_rotom_text_forced << text
end
# This will delete a message that equals the passed "text" from the forced rotom messages
def pbDeleteForcedRotomText(text)
$Trainer.poketch_rotom_text_forced = [] if !$Trainer.poketch_rotom_text_forced
if $Trainer.poketch_rotom_text_forced.include?(text)
$Trainer.poketch_rotom_text_forced.delete(text)
end
end
class PokeBattle_Trainer
attr_accessor :poketch_rotom_text
attr_accessor :poketch_rotom_text_forced
alias poketch_rotom_init initialize
def initialize(name, trainertype)
poketch_rotom_init(name, trainertype)
end
end
class PoketchRotom < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Rotom/idle")
@bg.src_rect.width = 384
@txtbar = Sprite.new(@viewport)
@txtbar.bmp("Graphics/Pictures/Poketch/Rotom/speech")
@txtbar.y = 320
@txtsprite = Sprite.new(@viewport)
@txtsprite.bmp(384,320)
pbSetSystemFont(@txtsprite.bitmap)
@txtsprite.bitmap.font.size += 10
if !$Trainer.poketch_rotom_text
# Default Normal Rotom Text
$Trainer.poketch_rotom_text = [
"Bzzt! I'm here to help you out on your journey!",
"Z-zzt! Where will we go next?"
]
end
# Default Forced Rotom Text (if you enter anything in here, this will override
# all messages you wrote in the Normal Rotom Text array).
if !$Trainer.poketch_rotom_text_forced
$Trainer.poketch_rotom_text_forced = [
# "Message here",
]
end
@txt = nil
@i = 0
end
def update
if $mouse && $mouse.click?(@bg) && @cooldown == -1
if @draw
@cooldown = 1
else
draw
end
end
if @draw && @txt && @txt.size > 0
if @i < @txt.size
@cooldown = 0
@bg.y -= 4 if @bg.y > -52
@txtbar.y -= 5 if @txtbar.y > 210
@txtsprite.bitmap.clear
pbSetSystemFont(@txtsprite.bitmap)
@txtsprite.bitmap.font.size += 2
t = @txt[0..@i].join
if @txtbar.y <= 220
@bg.src_rect.x += 384 if @i % 7 == 0
@bg.src_rect.x = 0 if @bg.src_rect.x >= @bg.bitmap.width
drawTextEx(@txtsprite.bitmap,14,248,362,2,t,Color.new(16,41,24),
Color.new(57,82,49))
@i += 1
end
else
@cooldown = -1
@txt = nil
@i = 0
@bg.src_rect.x = 0
end
end
if @cooldown == 1
@bg.y += 4 unless @bg.y == 0
@txtbar.y += 5 unless @txtbar.y == 320
@txtsprite.y += 5 unless @txtbar.y == 320
if @txtbar.y == 320
@draw = false
@cooldown = -1
@txtsprite.bitmap.clear
@txtsprite.y = 0
end
end
end
def draw
t = []
if $Trainer.poketch_rotom_text_forced.size > 0
t = $Trainer.poketch_rotom_text_forced
else
t = $Trainer.poketch_rotom_text
end
@txt = t[rand(t.size)].split("")
@draw = true
end
def dispose
@txtbar.dispose
@txtsprite.dispose
super
end
end
#==============================================================================#
# Pokétch Move Tester. Test type effectivenesses. #
#==============================================================================#
class PokeBattle_Trainer
attr_accessor :poketch_move_tester_move
attr_accessor :poketch_move_tester_type1
attr_accessor :poketch_move_tester_type2
end
class PoketchMoveTester < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Move Tester/background")
@moveBtnLeft = Sprite.new(@viewport)
@moveBtnLeft.bmp("Graphics/Pictures/Poketch/Move Tester/btnLeft")
@moveBtnLeft.y = 191
@moveBtnRight = Sprite.new(@viewport)
@moveBtnRight.bmp("Graphics/Pictures/Poketch/Move Tester/btnRight")
@moveBtnRight.x = 176
@moveBtnRight.y = 192
@type1BtnLeft = Sprite.new(@viewport)
@type1BtnLeft.bmp("Graphics/Pictures/Poketch/Move Tester/btnLeft")
@type1BtnLeft.x = 160
@type1BtnLeft.y = 16
@type1BtnRight = Sprite.new(@viewport)
@type1BtnRight.bmp("Graphics/Pictures/Poketch/Move Tester/btnRight")
@type1BtnRight.x = 336
@type1BtnRight.y = 16
@type2BtnLeft = Sprite.new(@viewport)
@type2BtnLeft.bmp("Graphics/Pictures/Poketch/Move Tester/btnLeft")
@type2BtnLeft.x = 160
@type2BtnLeft.y = 80
@type2BtnRight = Sprite.new(@viewport)
@type2BtnRight.bmp("Graphics/Pictures/Poketch/Move Tester/btnRight")
@type2BtnRight.x = 336
@type2BtnRight.y = 80
@move = $Trainer.poketch_move_tester_move || 0
@type1 = $Trainer.poketch_move_tester_type1 || 0
@type2 = $Trainer.poketch_move_tester_type2 || -1
@txtsprite = Sprite.new(@viewport)
@txtsprite.bmp(384,320)
@txt = @txtsprite.bitmap
@excl = []
refresh
end
def update
super
if click?(@moveBtnLeft,"Graphics/Pictures/Poketch/Move Tester","btnLeft")
@move -= 1
@move = PBTypes.maxValue if @move == -1
@move -= 1 if PBTypes.isPseudoType?(@move)
$Trainer.poketch_move_tester_move = @move
refresh
end
if click?(@moveBtnRight,"Graphics/Pictures/Poketch/Move Tester","btnRight")
@move += 1
@move = 0 if @move > PBTypes.maxValue
@move += 1 if PBTypes.isPseudoType?(@move)
$Trainer.poketch_move_tester_move = @move
refresh
end
if click?(@type1BtnLeft,"Graphics/Pictures/Poketch/Move Tester","btnLeft")
@type1 -= 1
@type1 = PBTypes.maxValue if @type1 == -1
@type1 -= 1 if PBTypes.isPseudoType?(@type1)
$Trainer.poketch_move_tester_type1 = @type1
refresh
end
if click?(@type1BtnRight,"Graphics/Pictures/Poketch/Move Tester","btnRight")
@type1 += 1
@type1 = 0 if @type1 > PBTypes.maxValue
@type1 += 1 if PBTypes.isPseudoType?(@type1)
$Trainer.poketch_move_tester_type1 = @type1
refresh
end
if click?(@type2BtnLeft,"Graphics/Pictures/Poketch/Move Tester","btnLeft")
@type2 -= 1
if @type2 == -2
@type2 = PBTypes.maxValue
elsif PBTypes.isPseudoType?(@type2)
@type2 -= 1
end
$Trainer.poketch_move_tester_type2 = @type2
refresh
end
if click?(@type2BtnRight,"Graphics/Pictures/Poketch/Move Tester","btnRight")
@type2 += 1
@type2 = -1 if @type2 > PBTypes.maxValue
@type2 += 1 if PBTypes.isPseudoType?(@type2)
$Trainer.poketch_move_tester_type2 = @type2
refresh
end
end
def refresh
@txt.clear
pbSetSystemFont(@txt)
name2 = (@type2 == -1 ? "None" : PBTypes.getName(@type2).upcase)
pbDrawTextPositions(@txt,[
[PBTypes.getName(@move).upcase,112,207,2,Color.new(16,41,24),Color.new(57,82,49)],
[PBTypes.getName(@type1).upcase,272,31,2,Color.new(16,41,24),Color.new(57,82,49)],
[name2,272,95,2,Color.new(16,41,24),Color.new(57,82,49)]
])
eff = PBTypes.getCombinedEffectiveness(@move, @type1, (@type2 == -1 ? nil : @type2))
txt = _INTL("Regularly effective")
txt = _INTL("Super effective") if eff > 8
txt = _INTL("Not very effective") if eff < 8
txt = _INTL("Not effective") if eff == 0
pbDrawTextPositions(@txt,[
[txt,16,271,0,Color.new(16,41,24),Color.new(57,82,49)]
])
# Determines how many exclamation marks to put
e = 0 if eff == 0
e = 1 if eff == 1 || eff == 2
e = 2 if eff == 4
e = 3 if eff == 8
e = 4 if eff == 16
e = 5 if eff == 32
for i in 0...6
@excl.dispose if @excl
if i < e
@excl = Sprite.new(@viewport)
@excl.bmp("Graphics/Pictures/Poketch/Move Tester/effectiveness")
@excl.x = 48 + 16 * i
@excl.y = 40
end
end
end
def dispose
for e in @excl
e.dispose
end
@moveBtnLeft.dispose
@moveBtnRight.dispose
@type1BtnRight.dispose
@type1BtnLeft.dispose
@type2BtnRight.dispose
@type2BtnLeft.dispose
@txtsprite.dispose
super
end
end
#==============================================================================#
# Pokétch Pedometer. Counts your steps. #
#==============================================================================#
class PokeBattle_Trainer
attr_accessor :steps
end
Events.onStepTaken += proc do
$Trainer.steps = 0 if !$Trainer.steps
$Trainer.steps += 1
$Poketch.refresh if $Poketch && $Poketch.app.is_a?(PoketchPedometer)
end
class PoketchPedometer < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Pedometer/background")
@btn = Sprite.new(@viewport)
@btn.bmp("Graphics/Pictures/Poketch/Pedometer/btn")
@btn.x = 133
@btn.y = 161
$Trainer.steps = 0 if !$Trainer.steps
@numbers = []
refresh
end
def update
super
if click?(@btn, "Graphics/Pictures/Poketch/Pedometer", "btn")
$Trainer.steps = 0
refresh
end
end
def refresh
n = pbFormat($Trainer.steps, 5)
n = n.to_s.split("")
for i in 0...5
@numbers.dispose if @numbers
@numbers = nil
@numbers = Sprite.new(@viewport)
@numbers.bmp("Graphics/Pictures/Poketch/Pedometer/numbers")
@numbers.src_rect.width = 24
@numbers.src_rect.x = n.to_i * 24
@numbers.x = 117 + 32 * i
@numbers.y = 66
end
end
def dispose
@btn.dispose
for n in @numbers
n.dispose
end
super
end
end
#==============================================================================#
# Pokétch Marking Map. Allows you to draw markers onto the map. #
#==============================================================================#
class PokeBattle_Trainer
attr_accessor :poketch_markingmap_circle
attr_accessor :poketch_markingmap_star
attr_accessor :poketch_markingmap_cube
attr_accessor :poketch_markingmap_triangle
attr_accessor :poketch_markingmap_heart
attr_accessor :poketch_markingmap_diamond
end
class PoketchMarkingMap < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Marking Map/background")
@circle = Sprite.new(@viewport)
@circle.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@circle.src_rect.width = 20
@circle.x = 208
@circle.y = 304
@circle.ox = @circle.bitmap.width / 6
@circle.oy = @circle.bitmap.height / 2
@star = Sprite.new(@viewport)
@star.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@star.src_rect.width = 20
@star.src_rect.x = 20
@star.x = 240
@star.y = 304
@star.ox = @star.bitmap.width / 6
@star.oy = @star.bitmap.height / 2
@cube = Sprite.new(@viewport)
@cube.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@cube.src_rect.width = 20
@cube.src_rect.x = 40
@cube.x = 272
@cube.y = 304
@cube.ox = @circle.bitmap.width / 6
@cube.oy = @cube.bitmap.height / 2
@triangle = Sprite.new(@viewport)
@triangle.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@triangle.src_rect.width = 20
@triangle.src_rect.x = 60
@triangle.x = 304
@triangle.y = 304
@triangle.ox = @triangle.bitmap.width / 6
@triangle.oy = @triangle.bitmap.height / 2
@heart = Sprite.new(@viewport)
@heart.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@heart.src_rect.width = 20
@heart.src_rect.x = 80
@heart.x = 336
@heart.y = 304
@heart.ox = @heart.bitmap.width / 6
@heart.oy = @heart.bitmap.height / 2
@diamond = Sprite.new(@viewport)
@diamond.bmp("Graphics/Pictures/Poketch/Marking Map/markings")
@diamond.src_rect.width = 20
@diamond.src_rect.x = 100
@diamond.x = 368
@diamond.y = 304
@diamond.ox = @diamond.bitmap.width / 6
@diamond.oy = @diamond.bitmap.height / 2
@circle.x, @circle.y = $Trainer.poketch_markingmap_circle if $Trainer.poketch_markingmap_circle
@star.x, @star.y = $Trainer.poketch_markingmap_star if $Trainer.poketch_markingmap_star
@cube.x, @cube.y = $Trainer.poketch_markingmap_cube if $Trainer.poketch_markingmap_cube
@triangle.x, @triangle.y = $Trainer.poketch_markingmap_triangle if $Trainer.poketch_markingmap_triangle
@heart.x, @heart.y = $Trainer.poketch_markingmap_heart if $Trainer.poketch_markingmap_heart
@diamond.x, @diamond.y = $Trainer.poketch_markingmap_diamond if $Trainer.poketch_markingmap_diamond
@obj = [@circle, @star, @cube, @triangle, @heart, @diamond]
@active = nil
end
def update
super
for i in [email protected]
if @cooldown == -1 && $mouse && $mouse.click?(@obj) && !@active
@active = i
end
end
if @active && $mouse.x - POKETCH_X - 32 > 0 && $mouse.x - POKETCH_X - 32 < 384 &&
$mouse.y - POKETCH_Y - 32 > 0 && $mouse.y - POKETCH_Y - 32 < 320
@obj[@active].zoom_x = 2
@obj[@active].zoom_y = 2
@obj[@active].x = $mouse.x - POKETCH_X - 32
@obj[@active].y = $mouse.y - POKETCH_Y - 32
$Trainer.poketch_markingmap_circle = @circle.x, @circle.y if @active == 0
$Trainer.poketch_markingmap_star = @star.x, @star.y if @active == 1
$Trainer.poketch_markingmap_cube = @cube.x, @cube.y if @active == 2
$Trainer.poketch_markingmap_triangle = @triangle.x, @triangle.y if @active == 3
$Trainer.poketch_markingmap_heart = @heart.x, @heart.y if @active == 4
$Trainer.poketch_markingmap_diamond = @diamond.x, @diamond.y if @active == 5
if $mouse.press?
@obj[@active].x = $mouse.x - POKETCH_X - 32
@obj[@active].y = $mouse.y - POKETCH_Y - 32
@obj[@active].zoom_x = 1
@obj[@active].zoom_y = 1
@active = nil
@cooldown = 5
end
end
end
def dispose
for obj in @obj
obj.dispose
end
super
end
end
#==============================================================================#
# Pokétch Matchup Checker. Check how your Pokémon match up with one another. #
#==============================================================================#
def pbGetCompat(poke1, poke2)
temp1 = $PokemonGlobal.daycare[0].clone
temp2 = $PokemonGlobal.daycare[1].clone
$PokemonGlobal.daycare[0] = [poke1,poke1.level]
$PokemonGlobal.daycare[1] = [poke2,poke2.level]
compat = pbDayCareGetCompat
$PokemonGlobal.daycare[0] = temp1
$PokemonGlobal.daycare[1] = temp2
return compat
end
class PoketchMatchupChecker < PoketchApp
def self.usable?
return $Trainer.party.size > 1
end
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Matchup Checker/background")
@btn = Sprite.new(@viewport)
@btn.bmp("Graphics/Pictures/Poketch/Matchup Checker/btn")
@btn.x = 144
@btn.y = 232
@poke1 = 0
@poke2 = 1
@icons = [nil, nil]
draw_pokes
@hearts = []
@luvdiscLeft = Sprite.new(@viewport)
@luvdiscLeft.bmp("Graphics/Pictures/Poketch/Matchup Checker/luvdisc")
@luvdiscLeft.x = 36
@luvdiscLeft.y = 104
@luvdiscRight = Sprite.new(@viewport)
@luvdiscRight.bmp("Graphics/Pictures/Poketch/Matchup Checker/luvdisc")
@luvdiscRight.x = 288
@luvdiscRight.y = 104
@luvdiscRight.mirror = true
@n = nil
end
def update
super
if !@n
if click?(@btn, "Graphics/Pictures/Poketch/Matchup Checker", "btn")
redraw
c = pbGetCompat($Trainer.party[@poke1], $Trainer.party[@poke2])
@n = [[72,29,59,69][c], c, -1]
end
if $mouse.inAreaLeftPress?(POKETCH_X+32+16,POKETCH_Y+32+228,96,72) && @cooldown == -1
@poke1 += 1
@poke1 = 0 if @poke1 >= $Trainer.party.size
@poke1 += 1 if @poke1 == @poke2
@poke1 = 0 if @poke1 >= $Trainer.party.size
pbPlayCry($Trainer.party[@poke1].species)
@cooldown = 5
redraw
elsif $mouse.inAreaLeftPress?(POKETCH_X+32+272,POKETCH_Y+32+228,96,72) && @cooldown == -1
@poke2 += 1
@poke2 = 0 if @poke2 >= $Trainer.party.size
@poke2 += 1 if @poke2 == @poke1
@poke2 = 0 if @poke2 >= $Trainer.party.size
pbPlayCry($Trainer.party[@poke2].species)
@cooldown = 5
redraw
end
end
if @n
if @n[1] == 0
if @n[0] >= 40
@luvdiscLeft.x += 1
@luvdiscRight.x -= 1
elsif @n[0] <= 24
@luvdiscRight.mirror = false
@luvdiscLeft.mirror = true
@luvdiscLeft.x -= 2
@luvdiscRight.x += 2
end
elsif @n[1] > 0
@luvdiscLeft.x += 1
@luvdiscRight.x -= 1
end
@n[0] -= 1
if @n[1] > 0 && @n[0] % 30 == 0
@n[2] += 1
@hearts[@n[2]] = Sprite.new(@viewport)
@hearts[@n[2]].bmp("Graphics/Pictures/Poketch/Matchup Checker/heart")
@hearts[@n[2]].x = 100 + 64 * @n[2]
@hearts[@n[2]].y = 4
end
@n = nil if @n[0] == 0
end
end
def redraw
draw_pokes
@luvdiscLeft.x = 36
@luvdiscLeft.mirror = false
@luvdiscRight.x = 288
@luvdiscRight.mirror = true
for i in 0...3
@hearts.dispose if @hearts
end
end
def draw_pokes
for i in [email protected]
@icons.dispose if @icons
@icons = nil
@icons = Sprite.new(@viewport)
sp = pbFormat($Trainer.party[[@poke1,@poke2]].species)
@icons.bmp("Graphics/Icons/icon#{sp}")
@icons.poketch_average
@icons.src_rect.width = @icons.bitmap.width / 2
@icons.ox = @icons.bitmap.width / 4
@icons.oy = @icons.bitmap.height / 2
@icons.x = [64,320]
@icons.y = 264
end
end
def dispose
for i in @icons
i.dispose
end
@luvdiscLeft.dispose
@luvdiscRight.dispose
for h in @hearts
h.dispose
end
super
end
end
#==============================================================================#
# Pokétch Party app. Displays your team with their items. #
#==============================================================================#
class PoketchParty < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/blank")
@pokemon = []
refresh
end
def update
super
# Refresh every 80 frames
if @cooldown == -1
refresh
@cooldown = 80
end
for p in @pokemon
if $mouse.press?(p[1])
pbPlayCry(p[0])
end
end
end
def refresh
for i in 0...6
if @pokemon
@pokemon[1].dispose if @pokemon[1]
@pokemon[2].dispose if @pokemon[2]
@pokemon[3].dispose if @pokemon[3]
@pokemon[4].dispose if @pokemon[4]
@pokemon = nil
end
if $Trainer.party
@pokemon = []
@pokemon[0] = $Trainer.party.species
@pokemon[1] = Sprite.new(@viewport)
@pokemon[1].bmp("Graphics/Icons/icon#{pbFormat($Trainer.party.species)}")
if $Trainer.party[0].eggsteps == 0 && $Trainer.party[0].hp <= 0
@pokemon[1].color = Color.new(82,132,82)
else
@pokemon[1].poketch_average
end
@pokemon[1].src_rect.width = @pokemon[1].bitmap.width / 2
@pokemon[1].ox = @pokemon[1].bitmap.width / 4
@pokemon[1].oy = @pokemon[1].bitmap.height / 2
@pokemon[1].zoom_x = 1.5
@pokemon[1].zoom_y = 1.5
@pokemon[1].x = [95,287][i % 2]
@pokemon[1].y = [46,142,238][(i / 2).floor]
@pokemon[1].z = 1
@pokemon[2] = Sprite.new(@viewport)
@pokemon[2].bmp("Graphics/Pictures/Poketch/Party/hpbar")
@pokemon[2].x = [28,220][i % 2]
@pokemon[2].y = [86,182,270][(i / 2).floor]
@pokemon[3] = Sprite.new(@viewport)
@pokemon[3].bmp("Graphics/Pictures/Poketch/Party/hp")
perc = $Trainer.party.hp.to_f / $Trainer.party.totalhp.to_f
@pokemon[3].src_rect.width = perc * @pokemon[3].bitmap.width
@pokemon[3].x = @pokemon[2].x + 4
@pokemon[3].y = @pokemon[2].y + 4
if $Trainer.party.item && $Trainer.party.item > 0
@pokemon[4] = Sprite.new(@viewport)
@pokemon[4].bmp("Graphics/Pictures/Poketch/Party/item")
@pokemon[4].x = @pokemon[2].x + 112
@pokemon[4].y = @pokemon[2].y - 26
end
end
end
end
def dispose
for i in 0...6
if @pokemon
@pokemon[1].dispose if @pokemon[1]
@pokemon[2].dispose if @pokemon[2]
@pokemon[3].dispose if @pokemon[3]
@pokemon[4].dispose if @pokemon[4]
@pokemon = nil
end
end
super
end
end
#==============================================================================#
# Pokétch Color Changer. Changes the overlay color of the screen. #
#==============================================================================#
class PokeBattle_Trainer
attr_accessor :poketch_color
end
class PoketchColorChanger < PoketchApp
def initialize
super
@pos = [48,80,144,176,240,272]
@bg.bmp("Graphics/Pictures/Poketch/Color Changer/background")
@sel = $Trainer.poketch_color || 0
@slider = Sprite.new(@viewport)
@slider.bmp("Graphics/Pictures/Poketch/Color Changer/slider")
@slider.ox = 64
@slider.x = @pos[@sel]
@slider.y = 232
end
def update
if $mouse && $mouse.drag_object_x?(@slider)
@slider.x = 48 if @slider.x < 48
@slider.x = 272 if @slider.x > 272
case @slider.x
when 48..64
@sel = 0
when 65..112
@sel = 1
when 113..160
@sel = 2
when 161..208
@sel = 3
when 209..256
@sel = 4
else
@sel = 5
end
@slider.x = @pos[@sel]
if @sel == 0
$Poketch.no_color
else
$Poketch.set_color("Graphics/Pictures/Poketch/Color Changer/overlay#{@sel}")
end
$Trainer.poketch_color = @sel
end
end
def dispose
@slider.dispose
super
end
end
#==============================================================================#
# Pokétch Kitchen Timer. Can count down from 99 minutes max. #
#==============================================================================#
class PokemonTemp
attr_reader :poketch_timer
attr_accessor :poketch_timer_running
def poketch_timer=(value)
@poketch_timer = value
@poketch_timer = 0 if @poketch_timer < 0
end
end
module Graphics
class << Graphics
alias poketch_timer_update update
end
def self.update
poketch_timer_update
return if !$Poketch
return if !$PokemonTemp || !$PokemonTemp.poketch_timer || !$PokemonTemp.poketch_timer_running
if Graphics.frame_count % Graphics.frame_rate == 0
$PokemonTemp.poketch_timer -= 1
$Poketch.app.refresh if $Poketch.app.is_a?(PoketchKitchenTimer)
end
end
end
class PoketchKitchenTimer < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/#{$PokemonTemp.poketch_timer_running ? "active" : "idle"}")
@startBtn = Sprite.new(@viewport)
$PokemonTemp.poketch_timer = 0 if !$PokemonTemp.poketch_timer
path = "startBtn"
path = "startBtnClick" if $PokemonTemp.poketch_timer_running ||
$PokemonTemp.poketch_timer == 0
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/#{path}")
@startBtn.y = 256
@stopBtn = Sprite.new(@viewport)
path = $PokemonTemp.poketch_timer_running ? "stopBtn" : "stopBtnClick"
@stopBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/#{path}")
@stopBtn.x = 128
@stopBtn.y = 256
@resetBtn = Sprite.new(@viewport)
@resetBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/resetBtn")
@resetBtn.x = 256
@resetBtn.y = 256
@numbers = []
@arrows = []
refresh
for i in 0...8
@arrows = Sprite.new(@viewport)
path = ["up","down"][(i / 4).floor]
@arrows.bmp("Graphics/Pictures/Poketch/Kitchen Timer/arrow#{path}")
@arrows.x = [114,146,210,242][i % 4]
@arrows.y = [136,224][(i / 4).floor]
@arrows.visible = !$PokemonTemp.poketch_timer_running
end
@canstart = false if $PokemonTemp.poketch_timer_running || $PokemonTemp.poketch_timer == 0
@frame = 0
@i = nil
end
def update
super
if @i
@i += 1
if @i == 8
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/done1")
elsif @i == 16
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/done2")
end
@i = 0 if @i == 16
end
@frame += 1
@frame = 0 if @frame == 41
unless $PokemonTemp.poketch_timer_running
for i in 0...8
if $mouse.click?(@arrows)
increment = [600,60,10,1][i % 4]
$PokemonTemp.poketch_timer += [1,-1][(i / 4).floor] * increment
$PokemonTemp.poketch_timer = 0 if $PokemonTemp.poketch_timer >= 6000
update_can_start
refresh
end
@arrows.visible = @frame < 20
end
end
if click?(@resetBtn,"Graphics/Pictures/Poketch/Kitchen Timer","resetBtn")
$PokemonTemp.poketch_timer_running = false
$PokemonTemp.poketch_timer = 0
for i in 0...8
@arrows.visible = true
end
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/idle")
update_can_start
@stopBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/stopBtnClick")
refresh
@frame = 20
@i = nil
end
if $mouse.click?(@startBtn) && !$PokemonTemp.poketch_timer_running && @canstart
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/startBtnClick")
@stopBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/stopBtn")
$PokemonTemp.poketch_timer_running = true
for i in 0...8
@arrows.visible = false
end
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/active")
@i = nil
end
if $mouse.click?(@stopBtn) && $PokemonTemp.poketch_timer_running
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/startBtn")
@stopBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/stopBtnClick")
for i in 0...8
@arrows.visible = true
end
@bg.bmp("Graphics/Pictures/Poketch/Kitchen Timer/idle")
update_can_start
$PokemonTemp.poketch_timer_running = false
@frame = 20
@i = nil
end
end
def update_can_start
if $PokemonTemp.poketch_timer > 0
@canstart = true
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/startBtn")
else
@canstart = false
@startBtn.bmp("Graphics/Pictures/Poketch/Kitchen Timer/startBtnClick")
end
end
def refresh
n = [0,0,0,0]
begin
mins = ($PokemonTemp.poketch_timer / 60).floor
secs = $PokemonTemp.poketch_timer % 60
nmin = pbFormat(mins, 2).split("")
nsec = pbFormat(secs, 2).split("")
n = nmin.concat(nsec)
rescue; end
for i in 0...4
@numbers.dispose if @numbers
@numbers = nil
@numbers = Sprite.new(@viewport)
@numbers.bmp("Graphics/Pictures/Poketch/Kitchen Timer/numbers")
@numbers.src_rect.width = 24
@numbers.src_rect.x = 24 * n.to_i
@numbers.x = [116,148,212,244]
@numbers.y = 160
end
@i = 0 if $PokemonTemp.poketch_timer <= 0 && !@i && $PokemonTemp.poketch_timer_running
end
def dispose
@startBtn.dispose
@stopBtn.dispose
@resetBtn.dispose
for n in @numbers
n.dispose
end
super
end
end
#==============================================================================#
# Pokétch Analog Watch. Displays the current time, but analog. #
#==============================================================================#
class PoketchAnalogWatch < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Analog Watch/background")
@long = Sprite.new(@viewport)
@long.bmp("Graphics/Pictures/Poketch/Analog Watch/long")
@long.ox = @long.bitmap.width / 2
@long.oy = @long.bitmap.height
@long.x = 192
@long.y = 168
@short = Sprite.new(@viewport)
@short.bmp("Graphics/Pictures/Poketch/Analog Watch/short")
@short.ox = @short.bitmap.width / 2
@short.oy = @short.bitmap.height
@short.x = 192
@short.y = 168
@time = Time.now
position
end
def position
@short.angle = (@time.hour % 12) / 12.0 * -360
@long.angle = @time.min / 60.0 * -360
end
def update
if @time.hour != Time.now.hour || @time.min != Time.now.min
@time = Time.now
position
end
end
def dispose
@long.dispose
@short.dispose
super
end
end
#==============================================================================#
# Pokétch Stat Display. Shows party members' EVs/IVs. #
#==============================================================================#
class PoketchStatDisplay < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Stat Display/background")
@evBtn = Sprite.new(@viewport)
@evBtn.bmp("Graphics/Pictures/Poketch/Stat Display/evBtnClick")
@evBtn.x = 268
@evBtn.y = 108
@ivBtn = Sprite.new(@viewport)
@ivBtn.bmp("Graphics/Pictures/Poketch/Stat Display/ivBtn")
@ivBtn.x = 268
@ivBtn.y = 188
@sel = 0
@mode = :ev
@icon = Sprite.new(@viewport)
@icon.bmp("Graphics/Icons/icon#{pbFormat($Trainer.party[@sel].species)}")
@icon.poketch_average
@icon.src_rect.width = @icon.bitmap.width / 2
@icon.ox = @icon.bitmap.width / 4
@icon.oy = @icon.bitmap.height / 2
@icon.x = 312
@icon.y = 52
@txtsprite = Sprite.new(@viewport)
@txtsprite.bmp(384,320)
@txt = @txtsprite.bitmap
pbSetSystemFont(@txt)
@stats = []
draw
end
def update
super
if $mouse.click?(@ivBtn)
@ivBtn.bmp("Graphics/Pictures/Poketch/Stat Display/ivBtnClick")
@evBtn.bmp("Graphics/Pictures/Poketch/Stat Display/evBtn")
@mode = :iv
draw
end
if $mouse.click?(@evBtn)
@evBtn.bmp("Graphics/Pictures/Poketch/Stat Display/evBtnClick")
@ivBtn.bmp("Graphics/Pictures/Poketch/Stat Display/ivBtn")
@mode = :ev
draw
end
if $mouse.inAreaLeftPress?(POKETCH_X+296,POKETCH_Y+48,98,72) && @cooldown == -1
@cooldown = 8
@sel += 1
@sel = 0 if @sel >= $Trainer.party.size
pbPlayCry($Trainer.party[@sel].species)
@icon.bmp("Graphics/Icons/icon#{pbFormat($Trainer.party[@sel].species)}")
@icon.poketch_average
@icon.src_rect.width = @icon.bitmap.width / 2
@icon.ox = @icon.bitmap.width / 4
@icon.oy = @icon.bitmap.height / 2
draw
end
end
def draw
@txt.clear
pbDrawTextPositions(@txt,[
[_INTL("HP"),102,12,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("Atk."),102,64,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("Def."),102,116,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("SpAtk."),102,168,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("SpDef."),102,220,0,Color.new(16,41,24),Color.new(57,82,49)],
[_INTL("Speed"),102,272,0,Color.new(16,41,24),Color.new(57,82,49)]
])
a = (@mode == :ev ? $Trainer.party[@sel].ev : $Trainer.party[@sel].iv)
# Sorting it to [HP,Atk,Def,SpAtk,SpDef,Speed]
t = a[3]
a[3] = nil
a.compact!
a << t
for i in 0...a.size
@stats = [] if !@stats
n = pbFormat(a, a.to_s.size).split("")
for j in 0...3
@stats[j].dispose if @stats[j]
if j < n.size
@stats[j] = Sprite.new(@viewport)
@stats[j].bmp("Graphics/Pictures/Poketch/Stat Display/numbers")
@stats[j].src_rect.width = 20
@stats[j].src_rect.x = 20 * n[j].to_i
@stats[j].x = [[40],[24,56],[16,40,64]][n.size - 1][j]
@stats[j].y = 12 + 52 * i
end
end
end
end
def dispose
@evBtn.dispose
@ivBtn.dispose
for i in 0...6
next if !@stats
for j in 0...3
@stats[j].dispose if @stats[j]
end
@stats = nil
end
@icon.dispose
@txtsprite.dispose
super
end
end
#==============================================================================#
# Pokétch Roulette. Spins an arrow and stops when you tell it to. #
#==============================================================================#
class PoketchRoulette < PoketchApp
# Only usable if RPG.Net is found
# RNET is a boolean; true if RPG.Net.dll is found, false if not.
def self.usable?
return RNET
end
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Roulette/background")
@arrow = Sprite.new(@viewport)
@arrow.bmp("Graphics/Pictures/Poketch/Roulette/arrow")
@arrow.ox = @arrow.bitmap.width / 2
@arrow.oy = @arrow.bitmap.height / 2
@arrow.x = 160
@arrow.y = 160
@arrow.z = 2
@playBtn = Sprite.new(@viewport)
@playBtn.bmp("Graphics/Pictures/Poketch/Roulette/playBtn")
@playBtn.x = 310
@playBtn.y = 28
@stopBtn = Sprite.new(@viewport)
@stopBtn.bmp("Graphics/Pictures/Poketch/Roulette/stopBtnClick")
@stopBtn.x = 310
@stopBtn.y = 120
@clearBtn = Sprite.new(@viewport)
@clearBtn.bmp("Graphics/Pictures/Poketch/Roulette/clearBtn")
@clearBtn.x = 310
@clearBtn.y = 212
@board = Sprite.new(@viewport)
@board.bmp(280,280)
@board.x = 20
@board.y = 20
@overlays = []
@overlays[0] = Sprite.new(@viewport)
@overlays[0].bmp("Graphics/Pictures/Poketch/Roulette/circleOverlay1")
@overlays[0].x = 128
@overlays[0].y = 128
@overlays[0].z = 1
@overlays[1] = Sprite.new(@viewport)
@overlays[1].bmp("Graphics/Pictures/Poketch/Roulette/circleOverlay2")
@overlays[1].x = 20
@overlays[1].y = 20
@overlays[1].z = 1
@playing = false
@stopping = false
@frame = 0
@olddata = []
@newdata = []
end
def update
super
if $mouse.click?(@playBtn) && !@playing
@playBtn.bmp("Graphics/Pictures/Poketch/Roulette/playBtnClick")
@stopBtn.bmp("Graphics/Pictures/Poketch/Roulette/stopBtn")
@clearBtn.bmp("Graphics/Pictures/Poketch/Roulette/clearBtnClick")
@playing = true
end
if @playing
if @stopping
@arrow.angle -= 3 * [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16][[(@frame / 4).floor - 1,0].max]
@frame -= 1
if @frame <= 0
@frame = 0
@playing = false
@stopping = false
@playBtn.bmp("Graphics/Pictures/Poketch/Roulette/playBtn")
@stopBtn.bmp("Graphics/Pictures/Poketch/Roulette/stopBtnClick")
@clearBtn.bmp("Graphics/Pictures/Poketch/Roulette/clearBtn")
end
else
@arrow.angle -= 3 * [(@frame / 2).floor,16].min
@frame += 1
end
end
if !@playing && click?(@clearBtn,"Graphics/Pictures/Poketch/Roulette","clearBtn")
@board.bitmap.clear
end
if $mouse.click?(@stopBtn) && @playing
@stopBtn.bmp("Graphics/Pictures/Poketch/Roulette/stopBtnClick")
@frame = 64
@stopping = true
end
if !@playing
if $mouse.press?(@board) && !@player
@newdata = [$mouse.x-POKETCH_X-52,$mouse.y-POKETCH_Y-52]
else
@olddata.clear
@newdata.clear
end
end
if @newdata.size > 0
if @olddata.size > 0
@board.bitmap.draw_line(@olddata[0],@olddata[1],@newdata[0],@newdata[1],
Color.new(16,41,24),4)
end
@olddata = @newdata.clone
@newdata.clear
end
end
def dispose
@playBtn.dispose
@stopBtn.dispose
@clearBtn.dispose
@arrow.dispose
for o in @overlays
o.dispose
end
@board.dispose
super
end
end
#==============================================================================#
# Pokétch Day-Care Checker. Shows you what you got going on in the Day-care. #
#==============================================================================#
class PoketchDayCareChecker < PoketchApp
def initialize
super
@bg.bmp("Graphics/Pictures/Poketch/Day Care Checker/background")
@pokes = []
refresh
@frame = 0
end
def update
@frame += 1
if @frame % 50 == 0
@egg.dispose if @egg
if pbEggGenerated?
@egg = Sprite.new(@viewport)
@egg.bmp("Graphics/Pictures/Poketch/Day Care Checker/egg")
@egg.x = 166
@egg.y = 204
end
end
if @frame == 100
refresh
@frame = 0
end
end
def refresh
for i in 0...2
@pokes = [] if !@pokes
if $PokemonGlobal.daycare && $PokemonGlobal.daycare[0].is_a?(PokeBattle_Pokemon)
p = $PokemonGlobal.daycare
@pokes[0].dispose if @pokes[0]
@pokes[0] = Sprite.new(@viewport)
@pokes[0].bmp("Graphics/Icons/icon#{pbFormat(p[0].species)}")
@pokes[0].poketch_average
@pokes[0].src_rect.width = @pokes[0].bitmap.width / 2
@pokes[0].mirror = true
@pokes[0].ox = @pokes[0].bitmap.width / 4
@pokes[0].oy = @pokes[0].bitmap.height / 2
@pokes[0].zoom_x = 2
@pokes[0].zoom_y = 2
@pokes[0].x = [82,304]
@pokes[0].y = 224
n = pbFormat(p[1]).split("")
for j in 0...3
@pokes[j+1].dispose if @pokes[j+1]
@pokes[j+1] = Sprite.new(@viewport)
@pokes[j+1].bmp("Graphics/Pictures/Poketch/Day Care Checker/numbers")
@pokes[j+1].src_rect.width = 16
@pokes[j+1].src_rect.x = n[j].to_i * 16
@pokes[j+1].x = [56,264] + 32 * j
@pokes[j+1].y = 40