Custom appearances for art gallery spriters

This commit is contained in:
chardub
2025-02-21 12:30:56 -05:00
parent 0f416eecaf
commit 80eef3b1c4
25 changed files with 406 additions and 15 deletions

View File

@@ -230,9 +230,17 @@ def generateNPCClothedBitmapStatic(trainerAppearance,action = "walk")
hair_color_shift = trainerAppearance.hair_color || 0
hairBitmap = AnimatedBitmap.new(hairFilename, hair_color_shift).bitmap if pbResolveBitmap(hairFilename)
baseBitmap.blt(0, 0, hairBitmap, hairBitmap.rect)
#Hat
hat_color_shift = trainerAppearance.hat_color || 0
hat2_color_shift = trainerAppearance.hat2_color || 0
hatFilename = getOverworldHatFilename(trainerAppearance.hat)
hat2Filename = getOverworldHatFilename(trainerAppearance.hat2)
hatBitmapWrapper = AnimatedBitmap.new(hatFilename, hat_color_shift) if pbResolveBitmap(hatFilename)
hat2BitmapWrapper = AnimatedBitmap.new(hat2Filename, hat2_color_shift) if pbResolveBitmap(hat2Filename)
if hatBitmapWrapper
frame_count = 4 # Assuming 4 frames for hair animation; adjust as needed
hat_frame_bitmap = duplicateHatForFrames(hatBitmapWrapper.bitmap, frame_count)
@@ -247,6 +255,22 @@ def generateNPCClothedBitmapStatic(trainerAppearance,action = "walk")
positionHat(baseBitmap, hat_frame_bitmap, frame_offset, i, frame_width)
end
end
if hat2BitmapWrapper
frame_count = 4 # Assuming 4 frames for hair animation; adjust as needed
hat2_frame_bitmap = duplicateHatForFrames(hat2BitmapWrapper.bitmap, frame_count)
frame_width = baseSprite.bitmap.width / frame_count # Calculate frame width
frame_count.times do |i|
# Calculate offset for each frame
frame_offset = [i * frame_width, 0]
# Adjust Y offset if frame index is odd
frame_offset[1] -= 2 if i.odd?
positionHat(baseBitmap, hat2_frame_bitmap, frame_offset, i, frame_width)
end
end
return baseBitmap
end

View File

@@ -53,12 +53,12 @@ class HatsMartAdapter < OutfitsMartAdapter
def updateTrainerPreview(item, previewWindow)
if item.is_a?(Outfit)
previewWindow.hat = item.id
previewWindow.set_hat(item.id,@is_secondary_hat)
$Trainer.set_hat(item.id,@is_secondary_hat)# unless $Trainer.hat==nil
set_dye_color(item,previewWindow)
else
$Trainer.set_hat(nil,@is_secondary_hat)
previewWindow.hat= nil
previewWindow.set_hat(nil,@is_secondary_hat)
end

View File

@@ -312,6 +312,71 @@ def randomizePlayerOutfitUnlocked()
end
def convert_letter_to_number(letter, max_number = nil)
return letter.ord if !max_number
return letter.ord % max_number
end
def generate_appearance_from_name(name)
name_seed_length = 15
seed = name[0, name_seed_length] # Truncate if longer than 8
seed += seed[0, name_seed_length - seed.length] while seed.length < name_seed_length # Repeat first characters if shorter
echoln seed
hats_list = $PokemonGlobal.hats_data.keys
clothes_list = $PokemonGlobal.clothes_data.keys
hairstyles_list = $PokemonGlobal.hairstyles_data.keys
hat = hats_list[convert_letter_to_number(seed[0],hats_list.length)]
hat2 = hats_list[convert_letter_to_number(seed[1],hats_list.length)]
hat2 = nil if convert_letter_to_number(seed[2]) % 3 == 0 #1/3 chance of no 2nd hat
hat_color = convert_letter_to_number(seed[3],255)
hat_color = 0 if convert_letter_to_number(seed[4]) % 2 == 0 #1/2 chance of no dyed hat
hat2_color = convert_letter_to_number(seed[5],255)
hat2_color = 0 if convert_letter_to_number(seed[6]) % 2 == 0
clothes = clothes_list[convert_letter_to_number(seed[7],clothes_list.length)]
clothes_color = convert_letter_to_number(seed[8],255)
clothes_color = 0 if convert_letter_to_number(seed[9]) % 2 == 0 #1/2 chance of no dyed clothes
hair_base = hairstyles_list[convert_letter_to_number(seed[10],hairstyles_list.length)]
hair_number = [1,2,3,4][convert_letter_to_number(seed[11],3)]
hair=getFullHairId(hair_base,hair_number)
hair_color = convert_letter_to_number(seed[12],255)
hair_color = 0 if convert_letter_to_number(seed[13]) % 2 == 0 #1/2 chance of no dyed hair
skin_tone = [1,2,3,4,5,6][convert_letter_to_number(seed[14],5)]
echoln clothes
return TrainerAppearance.new(skin_tone,hat,clothes, hair,
hair_color, clothes_color, hat_color,hat2,hat2_color)
end
def get_random_appearance()
hat = $PokemonGlobal.hats_data.keys.sample
hat2 = $PokemonGlobal.hats_data.keys.sample
hat2 = nil if(rand(3)==0)
clothes = $PokemonGlobal.clothes_data.keys.sample
hat_color = rand(2)==0 ? rand(255) : 0
hat2_color = rand(2)==0 ? rand(255) : 0
clothes_color = rand(2)==0 ? rand(255) : 0
hair_color = rand(2)==0 ? rand(255) : 0
hair_id = $PokemonGlobal.hairstyles_data.keys.sample
hair_color = [1,2,3,4].sample
skin_tone = [1,2,3,4,5,6].sample
hair = getFullHairId(hair_id,hair_color)
return TrainerAppearance.new(skin_tone,hat,clothes, hair,
hair_color, clothes_color, hat_color,hat2)
end
def randomizePlayerOutfit()
$Trainer.hat = $PokemonGlobal.hats_data.keys.sample
$Trainer.hat2 = $PokemonGlobal.hats_data.keys.sample