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_NUMBER = "5.0 - beta"
#
FUSION_ICON_SPRITE_OFFSET = 10
#Infinite fusion settings
NB_POKEMON = 420
CUSTOM_BATTLERS_FOLDER="Graphics/CustomBattlers/"

View File

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

View File

@@ -18,6 +18,15 @@ class AnimatedBitmap
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)
for i in 0..@bitmap.bitmap.width
for j in 0..@bitmap.bitmap.height

View File

@@ -2,7 +2,7 @@
# Pokémon sprite (used out of battle)
#===============================================================================
class PokemonSprite < SpriteWrapper
def initialize(viewport=nil)
def initialize(viewport = nil)
super(viewport)
@_iconbitmap = nil
end
@@ -20,7 +20,7 @@ class PokemonSprite < SpriteWrapper
self.bitmap = nil
end
def setOffset(offset=PictureOrigin::Center)
def setOffset(offset = PictureOrigin::Center)
@offset = offset
changeOrigin
end
@@ -32,7 +32,7 @@ class PokemonSprite < SpriteWrapper
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
self.ox = 0
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
self.ox = self.bitmap.width
end
@@ -40,29 +40,29 @@ class PokemonSprite < SpriteWrapper
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
self.oy = 0
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
self.oy = self.bitmap.height
end
end
def setPokemonBitmap(pokemon,back=false)
def setPokemonBitmap(pokemon, back = false)
@_iconbitmap.dispose if @_iconbitmap
@_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back) : nil
self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil
self.color = Color.new(0,0,0,0)
self.color = Color.new(0, 0, 0, 0)
changeOrigin
end
def setPokemonBitmapFromId(id,back=false)
def setPokemonBitmapFromId(id, back = false)
@_iconbitmap.dispose if @_iconbitmap
@_iconbitmap = GameData::Species.sprite_bitmap_from_pokemon_id(id, back)
self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil
self.color = Color.new(0,0,0,0)
self.color = Color.new(0, 0, 0, 0)
changeOrigin
end
def setPokemonBitmapSpecies(pokemon,species,back=false)
def setPokemonBitmapSpecies(pokemon, species, back = false)
@_iconbitmap.dispose if @_iconbitmap
@_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back, species) : nil
self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil
@@ -85,8 +85,6 @@ class PokemonSprite < SpriteWrapper
end
end
#===============================================================================
# Pokémon icon (for defined Pokémon)
#===============================================================================
@@ -95,7 +93,7 @@ class PokemonIconSprite < SpriteWrapper
attr_accessor :active
attr_reader :pokemon
def initialize(pokemon,viewport=nil)
def initialize(pokemon, viewport = nil)
super(viewport)
@selected = false
@active = false
@@ -114,17 +112,22 @@ class PokemonIconSprite < SpriteWrapper
super
end
def x; return @logical_x; end
def y; return @logical_y; end
def x
return @logical_x;
end
def y
return @logical_y;
end
def x=(value)
@logical_x = value
super(@logical_x+@adjusted_x)
super(@logical_x + @adjusted_x)
end
def y=(value)
@logical_y = value
super(@logical_y+@adjusted_y)
super(@logical_y + @adjusted_y)
end
def pokemon=(value)
@@ -137,16 +140,50 @@ class PokemonIconSprite < SpriteWrapper
@counter = 0
return
end
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.src_rect.width = @animBitmap.height
self.src_rect.height = @animBitmap.height
@numFrames = @animBitmap.width/@animBitmap.height
@currentFrame = 0 if @currentFrame>=@numFrames
@numFrames = @animBitmap.width / @animBitmap.height
@currentFrame = 0 if @currentFrame >= @numFrames
changeOrigin
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
changeOrigin
end
@@ -158,7 +195,7 @@ class PokemonIconSprite < SpriteWrapper
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
self.ox = 0
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
self.ox = self.src_rect.width
end
@@ -168,7 +205,7 @@ class PokemonIconSprite < SpriteWrapper
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
# 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.
self.oy = self.src_rect.height*5/8
self.oy = self.src_rect.height * 5 / 8
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
self.oy = self.src_rect.height
end
@@ -179,12 +216,14 @@ class PokemonIconSprite < SpriteWrapper
return 0 if @pokemon.fainted? # Fainted - no animation
# ret is initially the time a whole animation cycle lasts. It is divided by
# the number of frames in that cycle at the end.
ret = Graphics.frame_rate/4 # Green HP - 0.25 seconds
if @pokemon.hp<=@pokemon.totalhp/4; ret *= 4 # Red HP - 1 second
elsif @pokemon.hp<=@pokemon.totalhp/2; ret *= 2 # Yellow HP - 0.5 seconds
ret = Graphics.frame_rate / 4 # Green HP - 0.25 seconds
if @pokemon.hp <= @pokemon.totalhp / 4;
ret *= 4 # Red HP - 1 second
elsif @pokemon.hp <= @pokemon.totalhp / 2;
ret *= 2 # Yellow HP - 0.5 seconds
end
ret /= @numFrames
ret = 1 if ret<1
ret = 1 if ret < 1
return ret
end
@@ -195,20 +234,20 @@ class PokemonIconSprite < SpriteWrapper
self.bitmap = @animBitmap.bitmap
# Update animation
cl = self.counterLimit
if cl==0
if cl == 0
@currentFrame = 0
else
@counter += 1
if @counter>=cl
@currentFrame = (@currentFrame+1)%@numFrames
if @counter >= cl
@currentFrame = (@currentFrame + 1) % @numFrames
@counter = 0
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)
if @selected
@adjusted_x = 4
@adjusted_y = (@currentFrame>=@numFrames/2) ? -2 : 6
@adjusted_y = (@currentFrame >= @numFrames / 2) ? -2 : 6
else
@adjusted_x = 0
@adjusted_y = 0
@@ -218,8 +257,6 @@ class PokemonIconSprite < SpriteWrapper
end
end
#===============================================================================
# Pokémon icon (for species)
#===============================================================================
@@ -229,7 +266,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper
attr_reader :form
attr_reader :shiny
def initialize(species,viewport=nil)
def initialize(species, viewport = nil)
super(viewport)
@species = species
@gender = 0
@@ -266,7 +303,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper
refresh
end
def pbSetParams(species,gender,form,shiny=false)
def pbSetParams(species, gender, form, shiny = false)
@species = species
@gender = gender
@form = form
@@ -274,7 +311,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper
refresh
end
def setOffset(offset=PictureOrigin::Center)
def setOffset(offset = PictureOrigin::Center)
@offset = offset
changeOrigin
end
@@ -286,7 +323,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
self.ox = 0
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
self.ox = self.src_rect.width
end
@@ -296,7 +333,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
# 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.
self.oy = self.src_rect.height*5/8
self.oy = self.src_rect.height * 5 / 8
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
self.oy = self.src_rect.height
end
@@ -306,9 +343,9 @@ class PokemonSpeciesIconSprite < SpriteWrapper
def counterLimit
# ret is initially the time a whole animation cycle lasts. It is divided by
# 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 = 1 if ret<1
ret = 1 if ret < 1
return ret
end
@@ -322,7 +359,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper
self.src_rect.width = @animBitmap.height
self.src_rect.height = @animBitmap.height
@numFrames = @animBitmap.width / @animBitmap.height
@currentFrame = 0 if @currentFrame>=@numFrames
@currentFrame = 0 if @currentFrame >= @numFrames
changeOrigin
end
@@ -333,10 +370,10 @@ class PokemonSpeciesIconSprite < SpriteWrapper
self.bitmap = @animBitmap.bitmap
# Update animation
@counter += 1
if @counter>=self.counterLimit
@currentFrame = (@currentFrame+1)%@numFrames
if @counter >= self.counterLimit
@currentFrame = (@currentFrame + 1) % @numFrames
@counter = 0
end
self.src_rect.x = self.src_rect.width*@currentFrame
self.src_rect.x = self.src_rect.width * @currentFrame
end
end

View File

@@ -14,6 +14,35 @@ class PokemonBoxIcon < IconSprite
return @release.tweening?
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
self.ox = self.src_rect.width/2 # 32
self.oy = self.src_rect.height/2 # 32
@@ -27,9 +56,14 @@ class PokemonBoxIcon < IconSprite
@startRelease = true
end
def refresh
return if !@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)
end

View File

@@ -24,7 +24,6 @@ def pbAddPokemonID(pokemon, level = nil, seeform = true, dontRandomize = false)
return true
end
def pbAddPokemonID(pokemon_id, level = 1, see_form = true, skip_randomize = false)
return false if !pokemon_id
if pbBoxesFull?
@@ -37,7 +36,6 @@ def pbAddPokemonID(pokemon_id, level = 1, see_form = true, skip_randomize = fals
species_name = pokemon.speciesName
end
#random species if randomized gift pokemon & wild poke
if $game_switches[780] && $game_switches[778] && !skip_randomize
oldSpecies = pokemon.species
@@ -50,7 +48,6 @@ def pbAddPokemonID(pokemon_id, level = 1, see_form = true, skip_randomize = fals
return true
end
def pbGenerateEgg(pokemon, text = "")
return false if !pokemon || !$Trainer # || $Trainer.party.length>=6
if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
@@ -79,9 +76,6 @@ def pbGenerateEgg(pokemon, text = "")
return true
end
def pbHasSpecies?(species)
if species.is_a?(String) || species.is_a?(Symbol)
species = getID(PBSpecies, species)
@@ -93,27 +87,59 @@ def pbHasSpecies?(species)
return false
end
#Check if the Pokemon can learn a TM
def CanLearnMove(pokemon, move)
species = getID(PBSpecies, pokemon)
ret = false
return false if species <= 0
data = load_data("Data/tm.dat")
return false if !data[move]
return data[move].any? { |item| item == species }
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)
return (species / NB_POKEMON).round
dexNum = getDexNumberFromSpecies(species)
return (dexNum / NB_POKEMON).round
end
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
def getAllNonLegendaryPokemon()
list= []
list = []
for i in 1..143
list.push(i)
end
@@ -144,8 +170,8 @@ end
def getPokemonEggGroups(species)
groups = []
compat10=$pkmn_dex[species][13][0]
compat11=$pkmn_dex[species][13][1]
compat10 = $pkmn_dex[species][13][0]
compat11 = $pkmn_dex[species][13][1]
groups << compat10
groups << compat11
@@ -165,15 +191,14 @@ def generateEggGroupTeam(eggGroup)
return generatedTeam
end
def pbGetSelfSwitch(eventId,switch)
return $game_self_switches[[@map_id,eventId,switch]]
def pbGetSelfSwitch(eventId, switch)
return $game_self_switches[[@map_id, eventId, switch]]
end
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
def generateSameEggGroupFusionsTeam(eggGroup)
teamComplete = false
generatedTeam = []
@@ -185,7 +210,7 @@ def generateSameEggGroupFusionsTeam(eggGroup)
while !foundFusionPartner
species2 = rand(NB_POKEMON)
if getPokemonEggGroups(species2).include?(eggGroup)
generatedTeam << getFusionSpecies(species1,species2)
generatedTeam << getFusionSpecies(species1, species2)
foundFusionPartner = true
end
end
@@ -196,7 +221,7 @@ def generateSameEggGroupFusionsTeam(eggGroup)
end
def getAllNonLegendaryPokemon()
list= []
list = []
for i in 1..143
list.push(i)
end
@@ -224,7 +249,7 @@ def getAllNonLegendaryPokemon()
return list
end
def generateSimpleTrainerParty(teamSpecies,level)
def generateSimpleTrainerParty(teamSpecies, level)
team = []
for species in teamSpecies
poke = Pokemon.new(species, level)
@@ -233,24 +258,22 @@ def generateSimpleTrainerParty(teamSpecies,level)
return team
end
def isSinnohPokemon(species)
list =
[254,255,256,257,258,259,260,261,262,263,264,265,
266,267,268,269,270,271,272,273,274,275,288,294,
295,296,297,298,299,305,306,307,308,315,316,317,
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]
[254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 288, 294,
295, 296, 297, 298, 299, 305, 306, 307, 308, 315, 316, 317,
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]
return list.include?(species)
end
def isHoennPokemon(species)
list=[252,253,276,277,278,279,280,281,282,283,284,
285,286,287,289,290,291,292,293,300,301,302,303,
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,
391,392,393,394,395,396,401,404,405]
list = [252, 253, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 289, 290, 291, 292, 293, 300, 301, 302, 303,
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,
391, 392, 393, 394, 395, 396, 401, 404, 405]
return list.include?(species)
end