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

@@ -6,45 +6,161 @@ class SpriteWrapper
@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
@@ -87,8 +203,6 @@ class SpriteWrapper
end
end
#===============================================================================
# Sprite class that maintains a bitmap of its own.
# This bitmap can't be changed to a different one.
@@ -110,8 +224,6 @@ class BitmapSprite < SpriteWrapper
end
end
#===============================================================================
#
#===============================================================================
@@ -236,8 +348,6 @@ class AnimatedSprite < SpriteWrapper
end
end
#===============================================================================
# Displays an icon bitmap in a sprite. Supports animated images.
#===============================================================================
@@ -274,6 +384,17 @@ class IconSprite < SpriteWrapper
setBitmap(value)
end
def setBitmapDirectly(bitmap)
oldrc = self.src_rect
clearBitmaps()
@name = ""
return if bitmap == nil
@_iconbitmap = bitmap
# 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
@@ -308,8 +429,6 @@ class IconSprite < SpriteWrapper
end
end
#===============================================================================
# Old GifSprite class, retained for compatibility
#===============================================================================
@@ -320,8 +439,6 @@ class GifSprite < IconSprite
end
end
#===============================================================================
# SpriteWrapper that stores multiple bitmaps, and displays only one at once.
#===============================================================================
@@ -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

@@ -85,8 +85,6 @@ class PokemonSprite < SpriteWrapper
end
end
#===============================================================================
# Pokémon icon (for defined Pokémon)
#===============================================================================
@@ -114,8 +112,13 @@ 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
@@ -137,7 +140,11 @@ 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
@@ -146,6 +153,36 @@ class PokemonIconSprite < SpriteWrapper
changeOrigin
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
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
@@ -180,8 +217,10 @@ class PokemonIconSprite < SpriteWrapper
# 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
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
@@ -218,8 +257,6 @@ class PokemonIconSprite < SpriteWrapper
end
end
#===============================================================================
# Pokémon icon (for species)
#===============================================================================

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,23 +87,55 @@ 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()
@@ -173,7 +199,6 @@ def obtainBadgeMessage(badgeName)
Kernel.pbMessage(_INTL("\\me[Badge get]{1} obtained the {2}!", $Trainer.name, badgeName))
end
def generateSameEggGroupFusionsTeam(eggGroup)
teamComplete = false
generatedTeam = []
@@ -233,7 +258,6 @@ def generateSimpleTrainerParty(teamSpecies,level)
return team
end
def isSinnohPokemon(species)
list =
[254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
@@ -244,7 +268,6 @@ def isSinnohPokemon(species)
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,