fusion icons

This commit is contained in:
infinitefusion
2021-07-14 19:20:37 -04:00
parent 086577c6f5
commit abfad12b0a
6 changed files with 501 additions and 274 deletions

View File

@@ -9,6 +9,9 @@ module Settings
GAME_VERSION = '5.0.0' GAME_VERSION = '5.0.0'
GAME_VERSION_NUMBER = "5.0 - beta" GAME_VERSION_NUMBER = "5.0 - beta"
#
FUSION_ICON_SPRITE_OFFSET = 10
#Infinite fusion settings #Infinite fusion settings
NB_POKEMON = 420 NB_POKEMON = 420
CUSTOM_BATTLERS_FOLDER="Graphics/CustomBattlers/" CUSTOM_BATTLERS_FOLDER="Graphics/CustomBattlers/"

View File

@@ -2,102 +2,216 @@
# SpriteWrapper is a class which wraps (most of) Sprite's properties. # SpriteWrapper is a class which wraps (most of) Sprite's properties.
#=============================================================================== #===============================================================================
class SpriteWrapper class SpriteWrapper
def initialize(viewport=nil) def initialize(viewport = nil)
@sprite = Sprite.new(viewport) @sprite = Sprite.new(viewport)
end end
def dispose; @sprite.dispose; end def dispose
def disposed?; return @sprite.disposed?; end @sprite.dispose;
def viewport; return @sprite.viewport; end end
def flash(color,duration); return @sprite.flash(color,duration); end
def update; return @sprite.update; end def disposed?
def x; @sprite.x; end return @sprite.disposed?;
def x=(value); @sprite.x = value; end end
def y; @sprite.y; end
def y=(value); @sprite.y = value; end def viewport
def bitmap; @sprite.bitmap; end return @sprite.viewport;
def bitmap=(value); @sprite.bitmap = value; end end
def src_rect; @sprite.src_rect; end
def src_rect=(value); @sprite.src_rect = value; end def flash(color, duration)
def visible; @sprite.visible; end ; return @sprite.flash(color, duration);
def visible=(value); @sprite.visible = value; end end
def z; @sprite.z; end
def z=(value); @sprite.z = value; end def update
def ox; @sprite.ox; end return @sprite.update;
def ox=(value); @sprite.ox = value; end end
def oy; @sprite.oy; end
def oy=(value); @sprite.oy = value; end def x
def zoom_x; @sprite.zoom_x; end @sprite.x;
def zoom_x=(value); @sprite.zoom_x = value; end end
def zoom_y; @sprite.zoom_y; end
def zoom_y=(value); @sprite.zoom_y = value; end def x=(value)
def angle; @sprite.angle; end ; @sprite.x = value;
def angle=(value); @sprite.angle = value; end end
def mirror; @sprite.mirror; end
def mirror=(value); @sprite.mirror = value; end def y
def bush_depth; @sprite.bush_depth; end @sprite.y;
def bush_depth=(value); @sprite.bush_depth = value; end end
def opacity; @sprite.opacity; end
def opacity=(value); @sprite.opacity = value; end def y=(value)
def blend_type; @sprite.blend_type; end ; @sprite.y = value;
def blend_type=(value); @sprite.blend_type = value; end end
def color; @sprite.color; end
def color=(value); @sprite.color = value; end def bitmap
def tone; @sprite.tone; end @sprite.bitmap;
def tone=(value); @sprite.tone = value; end end
def bitmap=(value)
; @sprite.bitmap = value;
end
def src_rect
@sprite.src_rect;
end
def src_rect=(value)
; @sprite.src_rect = value;
end
def visible
@sprite.visible;
end
def visible=(value)
; @sprite.visible = value;
end
def z
@sprite.z;
end
def z=(value)
; @sprite.z = value;
end
def ox
@sprite.ox;
end
def ox=(value)
; @sprite.ox = value;
end
def oy
@sprite.oy;
end
def oy=(value)
; @sprite.oy = value;
end
def zoom_x
@sprite.zoom_x;
end
def zoom_x=(value)
; @sprite.zoom_x = value;
end
def zoom_y
@sprite.zoom_y;
end
def zoom_y=(value)
; @sprite.zoom_y = value;
end
def angle
@sprite.angle;
end
def angle=(value)
; @sprite.angle = value;
end
def mirror
@sprite.mirror;
end
def mirror=(value)
; @sprite.mirror = value;
end
def bush_depth
@sprite.bush_depth;
end
def bush_depth=(value)
; @sprite.bush_depth = value;
end
def opacity
@sprite.opacity;
end
def opacity=(value)
; @sprite.opacity = value;
end
def blend_type
@sprite.blend_type;
end
def blend_type=(value)
; @sprite.blend_type = value;
end
def color
@sprite.color;
end
def color=(value)
; @sprite.color = value;
end
def tone
@sprite.tone;
end
def tone=(value)
; @sprite.tone = value;
end
def viewport=(value) def viewport=(value)
return if self.viewport==value return if self.viewport == value
bitmap = @sprite.bitmap bitmap = @sprite.bitmap
src_rect = @sprite.src_rect src_rect = @sprite.src_rect
visible = @sprite.visible visible = @sprite.visible
x = @sprite.x x = @sprite.x
y = @sprite.y y = @sprite.y
z = @sprite.z z = @sprite.z
ox = @sprite.ox ox = @sprite.ox
oy = @sprite.oy oy = @sprite.oy
zoom_x = @sprite.zoom_x zoom_x = @sprite.zoom_x
zoom_y = @sprite.zoom_y zoom_y = @sprite.zoom_y
angle = @sprite.angle angle = @sprite.angle
mirror = @sprite.mirror mirror = @sprite.mirror
bush_depth = @sprite.bush_depth bush_depth = @sprite.bush_depth
opacity = @sprite.opacity opacity = @sprite.opacity
blend_type = @sprite.blend_type blend_type = @sprite.blend_type
color = @sprite.color color = @sprite.color
tone = @sprite.tone tone = @sprite.tone
@sprite.dispose @sprite.dispose
@sprite = Sprite.new(value) @sprite = Sprite.new(value)
@sprite.bitmap = bitmap @sprite.bitmap = bitmap
@sprite.src_rect = src_rect @sprite.src_rect = src_rect
@sprite.visible = visible @sprite.visible = visible
@sprite.x = x @sprite.x = x
@sprite.y = y @sprite.y = y
@sprite.z = z @sprite.z = z
@sprite.ox = ox @sprite.ox = ox
@sprite.oy = oy @sprite.oy = oy
@sprite.zoom_x = zoom_x @sprite.zoom_x = zoom_x
@sprite.zoom_y = zoom_y @sprite.zoom_y = zoom_y
@sprite.angle = angle @sprite.angle = angle
@sprite.mirror = mirror @sprite.mirror = mirror
@sprite.bush_depth = bush_depth @sprite.bush_depth = bush_depth
@sprite.opacity = opacity @sprite.opacity = opacity
@sprite.blend_type = blend_type @sprite.blend_type = blend_type
@sprite.color = color @sprite.color = color
@sprite.tone = tone @sprite.tone = tone
end end
end end
#=============================================================================== #===============================================================================
# Sprite class that maintains a bitmap of its own. # Sprite class that maintains a bitmap of its own.
# This bitmap can't be changed to a different one. # This bitmap can't be changed to a different one.
#=============================================================================== #===============================================================================
class BitmapSprite < SpriteWrapper class BitmapSprite < SpriteWrapper
def initialize(width,height,viewport=nil) def initialize(width, height, viewport = nil)
super(viewport) super(viewport)
self.bitmap=Bitmap.new(width,height) self.bitmap = Bitmap.new(width, height)
@initialized=true @initialized = true
end end
def bitmap=(value) def bitmap=(value)
@@ -110,8 +224,6 @@ class BitmapSprite < SpriteWrapper
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -122,82 +234,82 @@ class AnimatedSprite < SpriteWrapper
attr_reader :framecount attr_reader :framecount
attr_reader :animname attr_reader :animname
def initializeLong(animname,framecount,framewidth,frameheight,frameskip) def initializeLong(animname, framecount, framewidth, frameheight, frameskip)
@animname=pbBitmapName(animname) @animname = pbBitmapName(animname)
@realframes=0 @realframes = 0
@frameskip=[1,frameskip].max @frameskip = [1, frameskip].max
@frameskip *= Graphics.frame_rate/20 @frameskip *= Graphics.frame_rate / 20
raise _INTL("Frame width is 0") if framewidth==0 raise _INTL("Frame width is 0") if framewidth == 0
raise _INTL("Frame height is 0") if frameheight==0 raise _INTL("Frame height is 0") if frameheight == 0
begin begin
@animbitmap=AnimatedBitmap.new(animname).deanimate @animbitmap = AnimatedBitmap.new(animname).deanimate
rescue rescue
@animbitmap=Bitmap.new(framewidth,frameheight) @animbitmap = Bitmap.new(framewidth, frameheight)
end end
if @animbitmap.width%framewidth!=0 if @animbitmap.width % framewidth != 0
raise _INTL("Bitmap's width ({1}) is not a multiple of frame width ({2}) [Bitmap={3}]", raise _INTL("Bitmap's width ({1}) is not a multiple of frame width ({2}) [Bitmap={3}]",
@animbitmap.width,framewidth,animname) @animbitmap.width, framewidth, animname)
end end
if @animbitmap.height%frameheight!=0 if @animbitmap.height % frameheight != 0
raise _INTL("Bitmap's height ({1}) is not a multiple of frame height ({2}) [Bitmap={3}]", raise _INTL("Bitmap's height ({1}) is not a multiple of frame height ({2}) [Bitmap={3}]",
@animbitmap.height,frameheight,animname) @animbitmap.height, frameheight, animname)
end end
@framecount=framecount @framecount = framecount
@framewidth=framewidth @framewidth = framewidth
@frameheight=frameheight @frameheight = frameheight
@framesperrow=@animbitmap.width/@framewidth @framesperrow = @animbitmap.width / @framewidth
@playing=false @playing = false
self.bitmap=@animbitmap self.bitmap = @animbitmap
self.src_rect.width=@framewidth self.src_rect.width = @framewidth
self.src_rect.height=@frameheight self.src_rect.height = @frameheight
self.frame=0 self.frame = 0
end end
# Shorter version of AnimationSprite. All frames are placed on a single row # Shorter version of AnimationSprite. All frames are placed on a single row
# of the bitmap, so that the width and height need not be defined beforehand # of the bitmap, so that the width and height need not be defined beforehand
def initializeShort(animname,framecount,frameskip) def initializeShort(animname, framecount, frameskip)
@animname=pbBitmapName(animname) @animname = pbBitmapName(animname)
@realframes=0 @realframes = 0
@frameskip=[1,frameskip].max @frameskip = [1, frameskip].max
@frameskip *= Graphics.frame_rate/20 @frameskip *= Graphics.frame_rate / 20
begin begin
@animbitmap=AnimatedBitmap.new(animname).deanimate @animbitmap = AnimatedBitmap.new(animname).deanimate
rescue rescue
@animbitmap=Bitmap.new(framecount*4,32) @animbitmap = Bitmap.new(framecount * 4, 32)
end end
if @animbitmap.width%framecount!=0 if @animbitmap.width % framecount != 0
raise _INTL("Bitmap's width ({1}) is not a multiple of frame count ({2}) [Bitmap={3}]", raise _INTL("Bitmap's width ({1}) is not a multiple of frame count ({2}) [Bitmap={3}]",
@animbitmap.width,framewidth,animname) @animbitmap.width, framewidth, animname)
end end
@framecount=framecount @framecount = framecount
@framewidth=@animbitmap.width/@framecount @framewidth = @animbitmap.width / @framecount
@frameheight=@animbitmap.height @frameheight = @animbitmap.height
@framesperrow=framecount @framesperrow = framecount
@playing=false @playing = false
self.bitmap=@animbitmap self.bitmap = @animbitmap
self.src_rect.width=@framewidth self.src_rect.width = @framewidth
self.src_rect.height=@frameheight self.src_rect.height = @frameheight
self.frame=0 self.frame = 0
end end
def initialize(*args) def initialize(*args)
if args.length==1 if args.length == 1
super(args[0][3]) super(args[0][3])
initializeShort(args[0][0],args[0][1],args[0][2]) initializeShort(args[0][0], args[0][1], args[0][2])
else else
super(args[5]) super(args[5])
initializeLong(args[0],args[1],args[2],args[3],args[4]) initializeLong(args[0], args[1], args[2], args[3], args[4])
end end
end end
def self.create(animname,framecount,frameskip,viewport=nil) def self.create(animname, framecount, frameskip, viewport = nil)
return self.new([animname,framecount,frameskip,viewport]) return self.new([animname, framecount, frameskip, viewport])
end end
def dispose def dispose
return if disposed? return if disposed?
@animbitmap.dispose @animbitmap.dispose
@animbitmap=nil @animbitmap = nil
super super
end end
@@ -206,38 +318,36 @@ class AnimatedSprite < SpriteWrapper
end end
def frame=(value) def frame=(value)
@frame=value @frame = value
@realframes=0 @realframes = 0
self.src_rect.x=@frame%@framesperrow*@framewidth self.src_rect.x = @frame % @framesperrow * @framewidth
self.src_rect.y=@frame/@framesperrow*@frameheight self.src_rect.y = @frame / @framesperrow * @frameheight
end end
def start def start
@playing=true @playing = true
@realframes=0 @realframes = 0
end end
alias play start alias play start
def stop def stop
@playing=false @playing = false
end end
def update def update
super super
if @playing if @playing
@realframes+=1 @realframes += 1
if @realframes==@frameskip if @realframes == @frameskip
@realframes=0 @realframes = 0
self.frame+=1 self.frame += 1
self.frame%=self.framecount self.frame %= self.framecount
end end
end end
end end
end end
#=============================================================================== #===============================================================================
# Displays an icon bitmap in a sprite. Supports animated images. # Displays an icon bitmap in a sprite. Supports animated images.
#=============================================================================== #===============================================================================
@@ -245,23 +355,23 @@ class IconSprite < SpriteWrapper
attr_reader :name attr_reader :name
def initialize(*args) def initialize(*args)
if args.length==0 if args.length == 0
super(nil) super(nil)
self.bitmap=nil self.bitmap = nil
elsif args.length==1 elsif args.length == 1
super(args[0]) super(args[0])
self.bitmap=nil self.bitmap = nil
elsif args.length==2 elsif args.length == 2
super(nil) super(nil)
self.x=args[0] self.x = args[0]
self.y=args[1] self.y = args[1]
else else
super(args[2]) super(args[2])
self.x=args[0] self.x = args[0]
self.y=args[1] self.y = args[1]
end end
@name="" @name = ""
@_iconbitmap=nil @_iconbitmap = nil
end end
def dispose def dispose
@@ -274,59 +384,66 @@ class IconSprite < SpriteWrapper
setBitmap(value) setBitmap(value)
end end
# Sets the icon's filename. def setBitmapDirectly(bitmap)
def setBitmap(file,hue=0) oldrc = self.src_rect
oldrc=self.src_rect
clearBitmaps() clearBitmaps()
@name=file @name = ""
return if file==nil return if bitmap == nil
if file!="" @_iconbitmap = bitmap
@_iconbitmap=AnimatedBitmap.new(file,hue) # for compatibility
self.bitmap = @_iconbitmap ? @_iconbitmap.bitmap : nil
self.src_rect = oldrc
end
# Sets the icon's filename.
def setBitmap(file, hue = 0)
oldrc = self.src_rect
clearBitmaps()
@name = file
return if file == nil
if file != ""
@_iconbitmap = AnimatedBitmap.new(file, hue)
# for compatibility # for compatibility
self.bitmap=@_iconbitmap ? @_iconbitmap.bitmap : nil self.bitmap = @_iconbitmap ? @_iconbitmap.bitmap : nil
self.src_rect=oldrc self.src_rect = oldrc
else else
@_iconbitmap=nil @_iconbitmap = nil
end end
end end
def clearBitmaps def clearBitmaps
@_iconbitmap.dispose if @_iconbitmap @_iconbitmap.dispose if @_iconbitmap
@_iconbitmap=nil @_iconbitmap = nil
self.bitmap=nil if !self.disposed? self.bitmap = nil if !self.disposed?
end end
def update def update
super super
return if !@_iconbitmap return if !@_iconbitmap
@_iconbitmap.update @_iconbitmap.update
if self.bitmap!=@_iconbitmap.bitmap if self.bitmap != @_iconbitmap.bitmap
oldrc=self.src_rect oldrc = self.src_rect
self.bitmap=@_iconbitmap.bitmap self.bitmap = @_iconbitmap.bitmap
self.src_rect=oldrc self.src_rect = oldrc
end end
end end
end end
#=============================================================================== #===============================================================================
# Old GifSprite class, retained for compatibility # Old GifSprite class, retained for compatibility
#=============================================================================== #===============================================================================
class GifSprite < IconSprite class GifSprite < IconSprite
def initialize(path) def initialize(path)
super(0,0) super(0, 0)
setBitmap(path) setBitmap(path)
end end
end end
#=============================================================================== #===============================================================================
# SpriteWrapper that stores multiple bitmaps, and displays only one at once. # SpriteWrapper that stores multiple bitmaps, and displays only one at once.
#=============================================================================== #===============================================================================
class ChangelingSprite < SpriteWrapper class ChangelingSprite < SpriteWrapper
def initialize(x=0,y=0,viewport=nil) def initialize(x = 0, y = 0, viewport = nil)
super(viewport) super(viewport)
self.x = x self.x = x
self.y = y self.y = y
@@ -334,7 +451,7 @@ class ChangelingSprite < SpriteWrapper
@currentBitmap = nil @currentBitmap = nil
end end
def addBitmap(key,path) def addBitmap(key, path)
@bitmaps[key].dispose if @bitmaps[key] @bitmaps[key].dispose if @bitmaps[key]
@bitmaps[key] = AnimatedBitmap.new(path) @bitmaps[key] = AnimatedBitmap.new(path)
end end
@@ -346,14 +463,18 @@ class ChangelingSprite < SpriteWrapper
def dispose def dispose
return if disposed? return if disposed?
for bm in @bitmaps.values; bm.dispose; end for bm in @bitmaps.values;
bm.dispose;
end
@bitmaps.clear @bitmaps.clear
super super
end end
def update def update
return if disposed? return if disposed?
for bm in @bitmaps.values; bm.update; end for bm in @bitmaps.values;
bm.update;
end
self.bitmap = (@currentBitmap) ? @currentBitmap.bitmap : nil self.bitmap = (@currentBitmap) ? @currentBitmap.bitmap : nil
end end
end end

View File

@@ -18,6 +18,15 @@ class AnimatedBitmap
end end
end end
# def initialize(file,hue=0)
# raise "filename is nil" if file==nil
# if file[/^\[(\d+)\]/]
# @bitmap=PngAnimatedBitmap.new(file,hue)
# else
# @bitmap=GifBitmap.new(file,hue)
# end
# end
def pbSetColor(r = 0, g = 0, b = 0, a = 255) def pbSetColor(r = 0, g = 0, b = 0, a = 255)
for i in 0..@bitmap.bitmap.width for i in 0..@bitmap.bitmap.width
for j in 0..@bitmap.bitmap.height for j in 0..@bitmap.bitmap.height

View File

@@ -2,7 +2,7 @@
# Pokémon sprite (used out of battle) # Pokémon sprite (used out of battle)
#=============================================================================== #===============================================================================
class PokemonSprite < SpriteWrapper class PokemonSprite < SpriteWrapper
def initialize(viewport=nil) def initialize(viewport = nil)
super(viewport) super(viewport)
@_iconbitmap = nil @_iconbitmap = nil
end end
@@ -20,7 +20,7 @@ class PokemonSprite < SpriteWrapper
self.bitmap = nil self.bitmap = nil
end end
def setOffset(offset=PictureOrigin::Center) def setOffset(offset = PictureOrigin::Center)
@offset = offset @offset = offset
changeOrigin changeOrigin
end end
@@ -32,7 +32,7 @@ class PokemonSprite < SpriteWrapper
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
self.ox = 0 self.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
self.ox = self.bitmap.width/2 self.ox = self.bitmap.width / 2
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
self.ox = self.bitmap.width self.ox = self.bitmap.width
end end
@@ -40,29 +40,29 @@ class PokemonSprite < SpriteWrapper
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
self.oy = 0 self.oy = 0
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
self.oy = self.bitmap.height/2 self.oy = self.bitmap.height / 2
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
self.oy = self.bitmap.height self.oy = self.bitmap.height
end end
end end
def setPokemonBitmap(pokemon,back=false) def setPokemonBitmap(pokemon, back = false)
@_iconbitmap.dispose if @_iconbitmap @_iconbitmap.dispose if @_iconbitmap
@_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back) : nil @_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back) : nil
self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil
self.color = Color.new(0,0,0,0) self.color = Color.new(0, 0, 0, 0)
changeOrigin changeOrigin
end end
def setPokemonBitmapFromId(id,back=false) def setPokemonBitmapFromId(id, back = false)
@_iconbitmap.dispose if @_iconbitmap @_iconbitmap.dispose if @_iconbitmap
@_iconbitmap = GameData::Species.sprite_bitmap_from_pokemon_id(id, back) @_iconbitmap = GameData::Species.sprite_bitmap_from_pokemon_id(id, back)
self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil
self.color = Color.new(0,0,0,0) self.color = Color.new(0, 0, 0, 0)
changeOrigin changeOrigin
end end
def setPokemonBitmapSpecies(pokemon,species,back=false) def setPokemonBitmapSpecies(pokemon, species, back = false)
@_iconbitmap.dispose if @_iconbitmap @_iconbitmap.dispose if @_iconbitmap
@_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back, species) : nil @_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back, species) : nil
self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil
@@ -85,28 +85,26 @@ class PokemonSprite < SpriteWrapper
end end
end end
#=============================================================================== #===============================================================================
# Pokémon icon (for defined Pokémon) # Pokémon icon (for defined Pokémon)
#=============================================================================== #===============================================================================
class PokemonIconSprite < SpriteWrapper class PokemonIconSprite < SpriteWrapper
attr_accessor :selected attr_accessor :selected
attr_accessor :active attr_accessor :active
attr_reader :pokemon attr_reader :pokemon
def initialize(pokemon,viewport=nil) def initialize(pokemon, viewport = nil)
super(viewport) super(viewport)
@selected = false @selected = false
@active = false @active = false
@numFrames = 0 @numFrames = 0
@currentFrame = 0 @currentFrame = 0
@counter = 0 @counter = 0
self.pokemon = pokemon self.pokemon = pokemon
@logical_x = 0 # Actual x coordinate @logical_x = 0 # Actual x coordinate
@logical_y = 0 # Actual y coordinate @logical_y = 0 # Actual y coordinate
@adjusted_x = 0 # Offset due to "jumping" animation in party screen @adjusted_x = 0 # Offset due to "jumping" animation in party screen
@adjusted_y = 0 # Offset due to "jumping" animation in party screen @adjusted_y = 0 # Offset due to "jumping" animation in party screen
end end
def dispose def dispose
@@ -114,17 +112,22 @@ class PokemonIconSprite < SpriteWrapper
super super
end end
def x; return @logical_x; end def x
def y; return @logical_y; end return @logical_x;
end
def y
return @logical_y;
end
def x=(value) def x=(value)
@logical_x = value @logical_x = value
super(@logical_x+@adjusted_x) super(@logical_x + @adjusted_x)
end end
def y=(value) def y=(value)
@logical_y = value @logical_y = value
super(@logical_y+@adjusted_y) super(@logical_y + @adjusted_y)
end end
def pokemon=(value) def pokemon=(value)
@@ -137,16 +140,50 @@ class PokemonIconSprite < SpriteWrapper
@counter = 0 @counter = 0
return return
end end
@animBitmap = AnimatedBitmap.new(GameData::Species.icon_filename_from_pokemon(value)) if useRegularIcon(@pokemon.species) || @pokemon.egg?
@animBitmap = AnimatedBitmap.new(GameData::Species.icon_filename_from_pokemon(value))
else
@animBitmap = createFusionIcon()
end
self.bitmap = @animBitmap.bitmap self.bitmap = @animBitmap.bitmap
self.src_rect.width = @animBitmap.height self.src_rect.width = @animBitmap.height
self.src_rect.height = @animBitmap.height self.src_rect.height = @animBitmap.height
@numFrames = @animBitmap.width/@animBitmap.height @numFrames = @animBitmap.width / @animBitmap.height
@currentFrame = 0 if @currentFrame>=@numFrames @currentFrame = 0 if @currentFrame >= @numFrames
changeOrigin changeOrigin
end end
def setOffset(offset=PictureOrigin::Center) def useRegularIcon(species)
dexNum = getDexNumberFromSpecies(species)
return true if dexNum <= Settings::NB_POKEMON
return false if $game_variables == nil
return true if $game_variables[220] != 0
bitmapFileName = sprintf("Graphics/Icons/icon%03d", dexNum)
return true if pbResolveBitmap(bitmapFileName)
return false
end
SPRITE_OFFSET = 10
def createFusionIcon()
bodyPoke_number = getBodyID(pokemon.species)
headPoke_number = getHeadID(pokemon.species, bodyPoke_number)
bodyPoke = GameData::Species.get(bodyPoke_number).species
headPoke = GameData::Species.get(headPoke_number).species
icon1 = AnimatedBitmap.new(GameData::Species.icon_filename(headPoke))
icon2 = AnimatedBitmap.new(GameData::Species.icon_filename(bodyPoke))
for i in 0..icon1.width-1
for j in ((icon1.height / 2) + Settings::FUSION_ICON_SPRITE_OFFSET)..icon1.height-1
temp = icon2.bitmap.get_pixel(i, j)
icon1.bitmap.set_pixel(i, j, temp)
end
end
return icon1
end
def setOffset(offset = PictureOrigin::Center)
@offset = offset @offset = offset
changeOrigin changeOrigin
end end
@@ -158,7 +195,7 @@ class PokemonIconSprite < SpriteWrapper
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
self.ox = 0 self.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
self.ox = self.src_rect.width/2 self.ox = self.src_rect.width / 2
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
self.ox = self.src_rect.width self.ox = self.src_rect.width
end end
@@ -168,7 +205,7 @@ class PokemonIconSprite < SpriteWrapper
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
# NOTE: This assumes the top quarter of the icon is blank, so oy is placed # NOTE: This assumes the top quarter of the icon is blank, so oy is placed
# in the middle of the lower three quarters of the image. # in the middle of the lower three quarters of the image.
self.oy = self.src_rect.height*5/8 self.oy = self.src_rect.height * 5 / 8
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
self.oy = self.src_rect.height self.oy = self.src_rect.height
end end
@@ -176,15 +213,17 @@ class PokemonIconSprite < SpriteWrapper
# How long to show each frame of the icon for # How long to show each frame of the icon for
def counterLimit def counterLimit
return 0 if @pokemon.fainted? # Fainted - no animation return 0 if @pokemon.fainted? # Fainted - no animation
# ret is initially the time a whole animation cycle lasts. It is divided by # ret is initially the time a whole animation cycle lasts. It is divided by
# the number of frames in that cycle at the end. # the number of frames in that cycle at the end.
ret = Graphics.frame_rate/4 # Green HP - 0.25 seconds ret = Graphics.frame_rate / 4 # Green HP - 0.25 seconds
if @pokemon.hp<=@pokemon.totalhp/4; ret *= 4 # Red HP - 1 second if @pokemon.hp <= @pokemon.totalhp / 4;
elsif @pokemon.hp<=@pokemon.totalhp/2; ret *= 2 # Yellow HP - 0.5 seconds ret *= 4 # Red HP - 1 second
elsif @pokemon.hp <= @pokemon.totalhp / 2;
ret *= 2 # Yellow HP - 0.5 seconds
end end
ret /= @numFrames ret /= @numFrames
ret = 1 if ret<1 ret = 1 if ret < 1
return ret return ret
end end
@@ -195,20 +234,20 @@ class PokemonIconSprite < SpriteWrapper
self.bitmap = @animBitmap.bitmap self.bitmap = @animBitmap.bitmap
# Update animation # Update animation
cl = self.counterLimit cl = self.counterLimit
if cl==0 if cl == 0
@currentFrame = 0 @currentFrame = 0
else else
@counter += 1 @counter += 1
if @counter>=cl if @counter >= cl
@currentFrame = (@currentFrame+1)%@numFrames @currentFrame = (@currentFrame + 1) % @numFrames
@counter = 0 @counter = 0
end end
end end
self.src_rect.x = self.src_rect.width*@currentFrame self.src_rect.x = self.src_rect.width * @currentFrame
# Update "jumping" animation (used in party screen) # Update "jumping" animation (used in party screen)
if @selected if @selected
@adjusted_x = 4 @adjusted_x = 4
@adjusted_y = (@currentFrame>=@numFrames/2) ? -2 : 6 @adjusted_y = (@currentFrame >= @numFrames / 2) ? -2 : 6
else else
@adjusted_x = 0 @adjusted_x = 0
@adjusted_y = 0 @adjusted_y = 0
@@ -218,8 +257,6 @@ class PokemonIconSprite < SpriteWrapper
end end
end end
#=============================================================================== #===============================================================================
# Pokémon icon (for species) # Pokémon icon (for species)
#=============================================================================== #===============================================================================
@@ -229,15 +266,15 @@ class PokemonSpeciesIconSprite < SpriteWrapper
attr_reader :form attr_reader :form
attr_reader :shiny attr_reader :shiny
def initialize(species,viewport=nil) def initialize(species, viewport = nil)
super(viewport) super(viewport)
@species = species @species = species
@gender = 0 @gender = 0
@form = 0 @form = 0
@shiny = 0 @shiny = 0
@numFrames = 0 @numFrames = 0
@currentFrame = 0 @currentFrame = 0
@counter = 0 @counter = 0
refresh refresh
end end
@@ -266,15 +303,15 @@ class PokemonSpeciesIconSprite < SpriteWrapper
refresh refresh
end end
def pbSetParams(species,gender,form,shiny=false) def pbSetParams(species, gender, form, shiny = false)
@species = species @species = species
@gender = gender @gender = gender
@form = form @form = form
@shiny = shiny @shiny = shiny
refresh refresh
end end
def setOffset(offset=PictureOrigin::Center) def setOffset(offset = PictureOrigin::Center)
@offset = offset @offset = offset
changeOrigin changeOrigin
end end
@@ -286,7 +323,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
self.ox = 0 self.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
self.ox = self.src_rect.width/2 self.ox = self.src_rect.width / 2
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
self.ox = self.src_rect.width self.ox = self.src_rect.width
end end
@@ -296,7 +333,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
# NOTE: This assumes the top quarter of the icon is blank, so oy is placed # NOTE: This assumes the top quarter of the icon is blank, so oy is placed
# in the middle of the lower three quarters of the image. # in the middle of the lower three quarters of the image.
self.oy = self.src_rect.height*5/8 self.oy = self.src_rect.height * 5 / 8
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
self.oy = self.src_rect.height self.oy = self.src_rect.height
end end
@@ -306,9 +343,9 @@ class PokemonSpeciesIconSprite < SpriteWrapper
def counterLimit def counterLimit
# ret is initially the time a whole animation cycle lasts. It is divided by # ret is initially the time a whole animation cycle lasts. It is divided by
# the number of frames in that cycle at the end. # the number of frames in that cycle at the end.
ret = Graphics.frame_rate/4 # 0.25 seconds ret = Graphics.frame_rate / 4 # 0.25 seconds
ret /= @numFrames ret /= @numFrames
ret = 1 if ret<1 ret = 1 if ret < 1
return ret return ret
end end
@@ -319,10 +356,10 @@ class PokemonSpeciesIconSprite < SpriteWrapper
return if !bitmapFileName return if !bitmapFileName
@animBitmap = AnimatedBitmap.new(bitmapFileName) @animBitmap = AnimatedBitmap.new(bitmapFileName)
self.bitmap = @animBitmap.bitmap self.bitmap = @animBitmap.bitmap
self.src_rect.width = @animBitmap.height self.src_rect.width = @animBitmap.height
self.src_rect.height = @animBitmap.height self.src_rect.height = @animBitmap.height
@numFrames = @animBitmap.width / @animBitmap.height @numFrames = @animBitmap.width / @animBitmap.height
@currentFrame = 0 if @currentFrame>=@numFrames @currentFrame = 0 if @currentFrame >= @numFrames
changeOrigin changeOrigin
end end
@@ -333,10 +370,10 @@ class PokemonSpeciesIconSprite < SpriteWrapper
self.bitmap = @animBitmap.bitmap self.bitmap = @animBitmap.bitmap
# Update animation # Update animation
@counter += 1 @counter += 1
if @counter>=self.counterLimit if @counter >= self.counterLimit
@currentFrame = (@currentFrame+1)%@numFrames @currentFrame = (@currentFrame + 1) % @numFrames
@counter = 0 @counter = 0
end end
self.src_rect.x = self.src_rect.width*@currentFrame self.src_rect.x = self.src_rect.width * @currentFrame
end end
end end

View File

@@ -14,6 +14,35 @@ class PokemonBoxIcon < IconSprite
return @release.tweening? return @release.tweening?
end end
def useRegularIcon(species)
dexNum = getDexNumberFromSpecies(species)
return true if dexNum <= Settings::NB_POKEMON
return false if $game_variables == nil
return true if $game_variables[220] != 0
bitmapFileName = sprintf("Graphics/Icons/icon%03d", dexNum)
return true if pbResolveBitmap(bitmapFileName)
return false
end
def createFusionIcon(species)
bodyPoke_number = getBodyID(species)
headPoke_number = getHeadID(species, bodyPoke_number)
bodyPoke = GameData::Species.get(bodyPoke_number).species
headPoke = GameData::Species.get(headPoke_number).species
icon1 = AnimatedBitmap.new(GameData::Species.icon_filename(headPoke))
icon2 = AnimatedBitmap.new(GameData::Species.icon_filename(bodyPoke))
for i in 0..icon1.width-1
for j in ((icon1.height / 2) + Settings::FUSION_ICON_SPRITE_OFFSET)..icon1.height-1
temp = icon2.bitmap.get_pixel(i, j)
icon1.bitmap.set_pixel(i, j, temp)
end
end
return icon1
end
def release def release
self.ox = self.src_rect.width/2 # 32 self.ox = self.src_rect.width/2 # 32
self.oy = self.src_rect.height/2 # 32 self.oy = self.src_rect.height/2 # 32
@@ -27,9 +56,14 @@ class PokemonBoxIcon < IconSprite
@startRelease = true @startRelease = true
end end
def refresh def refresh
return if !@pokemon return if !@pokemon
self.setBitmap(GameData::Species.icon_filename_from_pokemon(@pokemon)) if useRegularIcon(@pokemon.species) || @pokemon.egg?
self.setBitmap(GameData::Species.icon_filename_from_pokemon(@pokemon))
else
self.setBitmapDirectly(createFusionIcon(@pokemon.species))
end
self.src_rect = Rect.new(0,0,self.bitmap.height,self.bitmap.height) self.src_rect = Rect.new(0,0,self.bitmap.height,self.bitmap.height)
end end

View File

@@ -24,7 +24,6 @@ def pbAddPokemonID(pokemon, level = nil, seeform = true, dontRandomize = false)
return true return true
end end
def pbAddPokemonID(pokemon_id, level = 1, see_form = true, skip_randomize = false) def pbAddPokemonID(pokemon_id, level = 1, see_form = true, skip_randomize = false)
return false if !pokemon_id return false if !pokemon_id
if pbBoxesFull? if pbBoxesFull?
@@ -37,7 +36,6 @@ def pbAddPokemonID(pokemon_id, level = 1, see_form = true, skip_randomize = fals
species_name = pokemon.speciesName species_name = pokemon.speciesName
end end
#random species if randomized gift pokemon & wild poke #random species if randomized gift pokemon & wild poke
if $game_switches[780] && $game_switches[778] && !skip_randomize if $game_switches[780] && $game_switches[778] && !skip_randomize
oldSpecies = pokemon.species oldSpecies = pokemon.species
@@ -50,7 +48,6 @@ def pbAddPokemonID(pokemon_id, level = 1, see_form = true, skip_randomize = fals
return true return true
end end
def pbGenerateEgg(pokemon, text = "") def pbGenerateEgg(pokemon, text = "")
return false if !pokemon || !$Trainer # || $Trainer.party.length>=6 return false if !pokemon || !$Trainer # || $Trainer.party.length>=6
if pokemon.is_a?(String) || pokemon.is_a?(Symbol) if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
@@ -79,9 +76,6 @@ def pbGenerateEgg(pokemon, text = "")
return true return true
end end
def pbHasSpecies?(species) def pbHasSpecies?(species)
if species.is_a?(String) || species.is_a?(Symbol) if species.is_a?(String) || species.is_a?(Symbol)
species = getID(PBSpecies, species) species = getID(PBSpecies, species)
@@ -93,27 +87,59 @@ def pbHasSpecies?(species)
return false return false
end end
#Check if the Pokemon can learn a TM #Check if the Pokemon can learn a TM
def CanLearnMove(pokemon, move) def CanLearnMove(pokemon, move)
species = getID(PBSpecies, pokemon) species = getID(PBSpecies, pokemon)
ret = false
return false if species <= 0 return false if species <= 0
data = load_data("Data/tm.dat") data = load_data("Data/tm.dat")
return false if !data[move] return false if !data[move]
return data[move].any? { |item| item == species } return data[move].any? { |item| item == species }
end end
def pbPokemonIconFile(pokemon)
bitmapFileName=pbCheckPokemonIconFiles(pokemon.species, pokemon.isEgg?)
return bitmapFileName
end
def pbCheckPokemonIconFiles(speciesNum,egg=false, dna=false)
if egg
bitmapFileName=sprintf("Graphics/Icons/iconEgg")
return pbResolveBitmap(bitmapFileName)
else
bitmapFileName=sprintf("Graphics/Icons/icon%03d",speciesNum)
ret=pbResolveBitmap(bitmapFileName)
return ret if ret
end
ret=pbResolveBitmap("Graphics/Icons/iconDNA.png")
return ret if ret
return pbResolveBitmap("Graphics/Icons/iconDNA.png")
end
def getDexNumberFromSpecies(species)
if species.is_a?(Symbol)
dexNum = GameData::Species.get(species).id_number
elsif species.is_a?(Pokemon)
dexNum = GameData::Species.get(species.species).id_number
else
dexNum = species
end
return dexNum
end
def getBodyID(species) def getBodyID(species)
return (species / NB_POKEMON).round dexNum = getDexNumberFromSpecies(species)
return (dexNum / NB_POKEMON).round
end end
def getHeadID(species, bodyId) def getHeadID(species, bodyId)
return (species - (bodyId * NB_POKEMON)).round head_dexNum = getDexNumberFromSpecies(species)
body_dexNum = getDexNumberFromSpecies(bodyId)
return (head_dexNum - (body_dexNum * NB_POKEMON)).round
end end
def getAllNonLegendaryPokemon() def getAllNonLegendaryPokemon()
list= [] list = []
for i in 1..143 for i in 1..143
list.push(i) list.push(i)
end end
@@ -144,8 +170,8 @@ end
def getPokemonEggGroups(species) def getPokemonEggGroups(species)
groups = [] groups = []
compat10=$pkmn_dex[species][13][0] compat10 = $pkmn_dex[species][13][0]
compat11=$pkmn_dex[species][13][1] compat11 = $pkmn_dex[species][13][1]
groups << compat10 groups << compat10
groups << compat11 groups << compat11
@@ -165,15 +191,14 @@ def generateEggGroupTeam(eggGroup)
return generatedTeam return generatedTeam
end end
def pbGetSelfSwitch(eventId,switch) def pbGetSelfSwitch(eventId, switch)
return $game_self_switches[[@map_id,eventId,switch]] return $game_self_switches[[@map_id, eventId, switch]]
end end
def obtainBadgeMessage(badgeName) def obtainBadgeMessage(badgeName)
Kernel.pbMessage(_INTL("\\me[Badge get]{1} obtained the {2}!",$Trainer.name,badgeName)) Kernel.pbMessage(_INTL("\\me[Badge get]{1} obtained the {2}!", $Trainer.name, badgeName))
end end
def generateSameEggGroupFusionsTeam(eggGroup) def generateSameEggGroupFusionsTeam(eggGroup)
teamComplete = false teamComplete = false
generatedTeam = [] generatedTeam = []
@@ -185,7 +210,7 @@ def generateSameEggGroupFusionsTeam(eggGroup)
while !foundFusionPartner while !foundFusionPartner
species2 = rand(NB_POKEMON) species2 = rand(NB_POKEMON)
if getPokemonEggGroups(species2).include?(eggGroup) if getPokemonEggGroups(species2).include?(eggGroup)
generatedTeam << getFusionSpecies(species1,species2) generatedTeam << getFusionSpecies(species1, species2)
foundFusionPartner = true foundFusionPartner = true
end end
end end
@@ -196,7 +221,7 @@ def generateSameEggGroupFusionsTeam(eggGroup)
end end
def getAllNonLegendaryPokemon() def getAllNonLegendaryPokemon()
list= [] list = []
for i in 1..143 for i in 1..143
list.push(i) list.push(i)
end end
@@ -224,7 +249,7 @@ def getAllNonLegendaryPokemon()
return list return list
end end
def generateSimpleTrainerParty(teamSpecies,level) def generateSimpleTrainerParty(teamSpecies, level)
team = [] team = []
for species in teamSpecies for species in teamSpecies
poke = Pokemon.new(species, level) poke = Pokemon.new(species, level)
@@ -233,24 +258,22 @@ def generateSimpleTrainerParty(teamSpecies,level)
return team return team
end end
def isSinnohPokemon(species) def isSinnohPokemon(species)
list = list =
[254,255,256,257,258,259,260,261,262,263,264,265, [254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
266,267,268,269,270,271,272,273,274,275,288,294, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 288, 294,
295,296,297,298,299,305,306,307,308,315,316,317, 295, 296, 297, 298, 299, 305, 306, 307, 308, 315, 316, 317,
318,319,320,321,322,323,324,326,332,343,344,345, 318, 319, 320, 321, 322, 323, 324, 326, 332, 343, 344, 345,
346,347,352,353,354,358,383,384,388,389,400,402,403] 346, 347, 352, 353, 354, 358, 383, 384, 388, 389, 400, 402, 403]
return list.include?(species) return list.include?(species)
end end
def isHoennPokemon(species) def isHoennPokemon(species)
list=[252,253,276,277,278,279,280,281,282,283,284, list = [252, 253, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285,286,287,289,290,291,292,293,300,301,302,303, 285, 286, 287, 289, 290, 291, 292, 293, 300, 301, 302, 303,
304,309,310,311,312,313,314,333,334,335,336,340, 304, 309, 310, 311, 312, 313, 314, 333, 334, 335, 336, 340,
341,342,355,356,357,378,379,380,381,382,385,386,387,390, 341, 342, 355, 356, 357, 378, 379, 380, 381, 382, 385, 386, 387, 390,
391,392,393,394,395,396,401,404,405] 391, 392, 393, 394, 395, 396, 401, 404, 405]
return list.include?(species) return list.include?(species)
end end