Migration - more progress

This commit is contained in:
chardub
2025-04-25 22:06:46 -04:00
parent 7de024dafd
commit b412ad7b39
67 changed files with 3243 additions and 108 deletions

View File

@@ -0,0 +1,63 @@
class PokemonBag
def pbQuantity(item)
return quantity(item)
end
def pbHasItem?(item, qty = 1)
return has?(item, qty)
end
def pbCanStore?(item, qty = 1)
return can_add?(item, qty = 1)
end
def pbStoreItem(item, qty = 1)
return add(item, qty = 1)
end
def pbStoreAllOrNone(item, qty = 1)
add_all(item, qty = 1)
end
def pbChangeItem(old_item, new_item)
replace_item(old_item, new_item)
end
def pbDeleteItem(item, qty = 1)
remove(item, qty = 1)
end
def pbIsRegistered?(item)
registered?(item)
end
def pbRegisterItem(item)
register(item)
end
def pbUnregisterItem(item)
unregister(item)
end
end
#Shortcut methods
def pbQuantity(*args)
return $bag.pbQuantity(*args)
end
def pbHasItem?(*args)
return $bag.pbHasItem?(*args)
end
def pbCanStore?(*args)
return $bag.pbCanStore?(*args)
end
def pbStoreItem(*args)
return $bag.pbStoreItem(*args)
end
def pbStoreAllOrNone(*args)
return $bag.pbStoreAllOrNone(*args)
end

View File

@@ -0,0 +1,29 @@
# frozen_string_literal: true
class Scene_Map
def cacheNeedsClearing
return RPG::Cache.size >= 100
end
def reset_switches_for_map_transfer
$game_switches[SWITCH_ILEX_FOREST_SPOOKED_POKEMON] = false
end
def clear_quest_icons()
for sprite in $scene.spriteset.character_sprites
if sprite.is_a?(Sprite_Character) && sprite.questIcon
sprite.removeQuestIcon
end
end
end
alias pokemonEssentials_SceneMap_transfer_player transfer_player
def transfer_playerr(cancel_swimming = true)
pokemonEssentials_SceneMap_transfer_player(cancel_swimming)
reset_switches_for_map_transfer()
clear_quest_icons()
end
end

View File

@@ -0,0 +1,3 @@
UI_FOLDER = "Graphics/UI/"
# frozen_string_literal: true

View File

@@ -113,7 +113,7 @@ def getEasterEggHeldItem()
return "secrets/HOTDOG" if [141, 194].include?(map) #restaurant
return "secrets/SNOWBALL" if [670, 693, 698, 694].include?(map)
return "secrets/WALLET" if [432, 433, 434, 435, 436, 292].include?(map) #dept. store
return "secrets/ALARMCLOCK" if [43, 48, 67, 68, 69, 70, 71, 73].include?(map) #Player room
return "secrets/ALARMCLOCK" if [43, 48, 67, 68, 69, 70, 71, 73].include?(map) #Overrides room
return "SAFARIBALL" if [445, 484, 485, 486, 107, 487, 488, 717, 82, 75, 74].include?(map) #Safari Zone
return "secrets/WISP" if [401,402,403,467,468,469].include?(map) #Pokemon Tower
return "secrets/SKULL" if [400].include?(map) #Pokemon Tower ground floor

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
class Scene_Map
def reset_player_sprite
@spritesetGlobal.playersprite.updateBitmap
end
end

View File

@@ -0,0 +1,176 @@
# frozen_string_literal: true
class Sprite_Character
attr_accessor :pending_bitmap
attr_accessor :bitmap_override
attr_accessor :charbitmap
alias pokemonEssentials_spriteCharacter_initialize initialize
def initialize(viewport, character = nil)
pokemonEssentials_spriteCharacter_initialize(viewport, character)
checkModifySpriteGraphics(@character) if @character
end
def setSpriteToAppearance(trainerAppearance)
#return if !@charbitmap || !@charbitmap.bitmap
begin
new_bitmap = AnimatedBitmap.new(getBaseOverworldSpriteFilename()) #@charbitmap
new_bitmap.bitmap = generateNPCClothedBitmapStatic(trainerAppearance)
@bitmap_override = new_bitmap
updateBitmap
rescue
end
end
def clearBitmapOverride()
@bitmap_override = nil
updateBitmap
end
def setSurfingPokemon(pokemonSpecies)
@surfingPokemon = pokemonSpecies
@surfbase.setPokemon(pokemonSpecies) if @surfbase
end
def updateBitmap
@manual_refresh = true
end
def pbLoadOutfitBitmap(outfitFileName)
# Construct the file path for the outfit bitmap based on the given value
#outfitFileName = sprintf("Graphics/Outfits/%s", value)
# Attempt to load the outfit bitmap
begin
outfitBitmap = RPG::Cache.load_bitmap("", outfitFileName)
return outfitBitmap
rescue
return nil
end
end
def generateClothedBitmap()
return
end
def applyDayNightTone()
if @character.is_a?(Game_Event) && @character.name[/regulartone/i]
self.tone.set(0, 0, 0, 0)
else
pbDayNightTint(self)
end
end
def updateCharacterBitmap
AnimatedBitmap.new('Graphics/Characters/' + @character_name, @character_hue)
end
def should_update?
return @tile_id != @character.tile_id ||
@character_name != @character.character_name ||
@character_hue != @character.character_hue ||
@oldbushdepth != @character.bush_depth ||
@manual_refresh
end
def refreshOutfit()
self.pending_bitmap = getClothedPlayerSprite(true)
end
def checkModifySpriteGraphics(character)
return if character == $game_player || !character.name
if TYPE_EXPERTS_APPEARANCES.keys.include?(character.name.to_sym)
typeExpert = character.name.to_sym
setSpriteToAppearance(TYPE_EXPERTS_APPEARANCES[typeExpert])
end
end
# def update
# if self.pending_bitmap
# self.bitmap = self.pending_bitmap
# self.pending_bitmap = nil
# end
# return if @character.is_a?(Game_Event) && !@character.should_update?
# super
# if should_update?
# @manual_refresh = false
# @tile_id = @character.tile_id
# @character_name = @character.character_name
# @character_hue = @character.character_hue
# @oldbushdepth = @character.bush_depth
# if @tile_id >= 384
# @charbitmap.dispose if @charbitmap
# @charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id,
# @character_hue, @character.width, @character.height)
# @charbitmapAnimated = false
# @bushbitmap.dispose if @bushbitmap
# @bushbitmap = nil
# @spriteoffset = false
# @cw = Game_Map::TILE_WIDTH * @character.width
# @ch = Game_Map::TILE_HEIGHT * @character.height
# self.src_rect.set(0, 0, @cw, @ch)
# self.ox = @cw / 2
# self.oy = @ch
# @character.sprite_size = [@cw, @ch]
# else
# @charbitmap.dispose if @charbitmap
#
# @charbitmap = updateCharacterBitmap()
# @charbitmap = @bitmap_override.clone if @bitmap_override
#
# RPG::Cache.retain('Graphics/Characters/', @character_name, @character_hue) if @charbitmapAnimated = true
# @bushbitmap.dispose if @bushbitmap
# @bushbitmap = nil
# #@spriteoffset = @character_name[/offset/i]
# @spriteoffset = @character_name[/fish/i] || @character_name[/dive/i] || @character_name[/surf/i]
# @cw = @charbitmap.width / 4
# @ch = @charbitmap.height / 4
# self.ox = @cw / 2
# @character.sprite_size = [@cw, @ch]
# end
# end
# @charbitmap.update if @charbitmapAnimated
# bushdepth = @character.bush_depth
# if bushdepth == 0
# if @character == $game_player
# self.bitmap = getClothedPlayerSprite() #generateClothedBitmap()
# else
# self.bitmap = (@charbitmapAnimated) ? @charbitmap.bitmap : @charbitmap
# end
# else
# @bushbitmap = BushBitmap.new(@charbitmap, (@tile_id >= 384), bushdepth) if !@bushbitmap
# self.bitmap = @bushbitmap.bitmap
# end
# self.visible = !@character.transparent
# if @tile_id == 0
# sx = @character.pattern * @cw
# sy = ((@character.direction - 2) / 2) * @ch
# self.src_rect.set(sx, sy, @cw, @ch)
# self.oy = (@spriteoffset rescue false) ? @ch - 16 : @ch
# self.oy -= @character.bob_height
# end
# if self.visible
# applyDayNightTone()
# end
# self.x = @character.screen_x
# self.y = @character.screen_y
# self.z = @character.screen_z(@ch)
# # self.zoom_x = Game_Map::TILE_WIDTH / 32.0
# # self.zoom_y = Game_Map::TILE_HEIGHT / 32.0
# self.opacity = @character.opacity
# self.blend_type = @character.blend_type
# # self.bush_depth = @character.bush_depth
# if @character.animation_id != 0
# animation = $data_animations[@character.animation_id]
# animation(animation, true)
# @character.animation_id = 0
# end
# @reflection.update if @reflection
# @surfbase.update if @surfbase
# end
end

View File

@@ -0,0 +1,131 @@
class Sprite_Player < Sprite_Character
def initialize(viewport, character = nil)
super(viewport,character)
@initialized_player=false
end
def initialize_player()
#@viewport = viewport
@outfit_bitmap = nil
hatFilename = ""
hairFilename = ""
@hat = Sprite_Hat.new(self, hatFilename, @character_name, @viewport,3)
@hat2 = Sprite_Hat.new(self, hatFilename, @character_name, @viewport,2)
@hair = Sprite_Hair.new(self, hairFilename, @character_name, @viewport)
@previous_skinTone = 0
@current_bitmap = nil
@previous_action =nil
echoln "initialized player sprite"
getClothedPlayerSprite(true)
end
def update
super
if !@initialized_custom && @charbitmap
initialize_player
@initialized_custom = true
end
end
def applyDayNightTone
super
pbDayNightTint(@hat.sprite) if @hat && @hat.sprite.bitmap
pbDayNightTint(@hat2.sprite) if @hat2 && @hat2.sprite.bitmap
pbDayNightTint(@hair.sprite) if @hair && @hair.sprite.bitmap
end
def opacity=(value)
super
@hat.sprite.opacity= value if @hat && @hat.sprite.bitmap
@hat2.sprite.opacity= value if @hat2 && @hat2.sprite.bitmap
@hair.sprite.opacity= value if @hair && @hair.sprite.bitmap
end
alias pokemon_essentials_spritePlayer_dispose dispose
def dispose
pokemon_essentials_spritePlayer_dispose
super
@hat.dispose if @hat
@hat2.dispose if @hat2
@hair.dispose if @hair
end
###############
# New methods #
##############
def updateCharacterBitmap
skinTone = $player.skin_tone ? $player.skin_tone : 0
baseBitmapFilename = getBaseOverworldSpriteFilename(@character_name, skinTone)
if !pbResolveBitmap(baseBitmapFilename)
baseBitmapFilename = Settings::PLAYER_GRAPHICS_FOLDER + @character_name
end
AnimatedBitmap.new(baseBitmapFilename, @character_hue)
end
def getClothedPlayerSprite(forceUpdate=false)
if @previous_action != @character_name || forceUpdate
@current_bitmap = generateClothedBitmap
end
@previous_action = @character_name
@hair.animate(@character_name) if @hair
@hat.animate(@character_name) if @hat
@hat2.animate(@character_name) if @hat2
return @current_bitmap
end
def generateClothedBitmap()
return if !@charbitmap
@charbitmap.bitmap.clone #nekkid sprite
baseBitmap = @charbitmap.bitmap.clone #nekkid sprite
outfitFilename = getOverworldOutfitFilename($player.clothes, @character_name) #
outfitFilename = getOverworldOutfitFilename(Settings::PLAYER_TEMP_OUTFIT_FALLBACK) if !pbResolveBitmap(outfitFilename)
hairFilename = getOverworldHairFilename($player.hair)
hatFilename = getOverworldHatFilename($player.hat)
hat2Filename = getOverworldHatFilename($player.hat2)
hair_color_shift = $player.hair_color
hat_color_shift = $player.hat_color
hat2_color_shift = $player.hat2_color
clothes_color_shift = $player.clothes_color
hair_color_shift = 0 if !hair_color_shift
hat_color_shift = 0 if !hat_color_shift
hat2_color_shift = 0 if !hat2_color_shift
clothes_color_shift = 0 if !clothes_color_shift
@hair.update(@character_name, hairFilename, hair_color_shift) if @hair
@hat.update(@character_name, hatFilename, hat_color_shift) if @hat
@hat2.update(@character_name, hat2Filename, hat2_color_shift) if @hat2
if !pbResolveBitmap(outfitFilename)
raise "No temp clothes graphics available"
end
outfitBitmap = AnimatedBitmap.new(outfitFilename, clothes_color_shift) if pbResolveBitmap(outfitFilename)
baseBitmap.blt(0, 0, outfitBitmap.bitmap, outfitBitmap.bitmap.rect) if outfitBitmap
@previous_action = @character_name
return baseBitmap
end
def pbLoadOutfitBitmap(outfitFileName)
begin
outfitBitmap = RPG::Cache.load_bitmap("", outfitFileName)
return outfitBitmap
rescue
return nil
end
end
end

View File

@@ -0,0 +1,19 @@
class Spriteset_Global
###################
#Overwritten methods
# #################
def initialize
@map_id = $game_map&.map_id || 0
@follower_sprites = FollowerSprites.new(Spriteset_Map.viewport)
@playersprite = Sprite_Player.new(Spriteset_Map.viewport, $game_player)
@weather = RPG::Weather.new(Spriteset_Map.viewport)
@picture_sprites = []
(1..100).each do |i|
@picture_sprites.push(Sprite_Picture.new(@@viewport2, $game_screen.pictures[i]))
end
@timer_sprite = Sprite_Timer.new
update
end
end

View File

@@ -0,0 +1,170 @@
class Sprite_Wearable < RPG::Sprite
attr_accessor :filename
attr_accessor :action
attr_accessor :sprite
def initialize(player_sprite, filename, action, viewport, relative_z=0)
@player_sprite = player_sprite
@viewport = viewport
@sprite = Sprite.new(@viewport)
@wearableBitmap = AnimatedBitmap.new(filename) if pbResolveBitmap(filename)
@filename = filename
@sprite.bitmap = @wearableBitmap.bitmap if @wearableBitmap
@action = action
@color = 0
@frameWidth = 80 #@sprite.width
@frameHeight = 80 #@sprite.height / 4
@sprite.z = 0
@relative_z=relative_z #relative to player
echoln(_INTL("init had at z = {1}, player sprite at {2}",@sprite.z,@player_sprite.z))
#Unused position offset
# @x_pos_base_offset = 0
# @y_pos_base_offset = 0
end
def apply_sprite_offset(offsets_array, current_frame)
@sprite.x += offsets_array[current_frame][0]
@sprite.y += offsets_array[current_frame][1]
end
def adjustPositionForScreenScrolling
return if !$game_map.scrolling? && !@was_just_scrolling
if $game_map.scrolling?
@was_just_scrolling=true
else
@was_just_scrolling=false
end
offset_x = 0
offset_y = 0
case $game_map.scroll_direction
when DIRECTION_RIGHT
offset_x=-8
when DIRECTION_LEFT
offset_x=8
when DIRECTION_UP
offset_y=8
@sprite.z+=50 #weird layering glitch for some reason otherwise. It's reset to the correct value in the next animation frame
when DIRECTION_DOWN
offset_y=-8
end
@sprite.x+=offset_x
@sprite.y+=offset_y
end
def set_sprite_position(action, direction, current_frame)
@sprite.x = @player_sprite.x - @player_sprite.ox
@sprite.y = @player_sprite.y - @player_sprite.oy
case action
when "run"
if direction == DIRECTION_DOWN
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_DOWN, current_frame)
elsif direction == DIRECTION_LEFT
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_LEFT, current_frame)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_RIGHT, current_frame)
elsif direction == DIRECTION_UP
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_UP, current_frame)
end
when "surf"
if direction == DIRECTION_DOWN
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_DOWN,current_frame)
elsif direction == DIRECTION_LEFT
apply_sprite_offset( Outfit_Offsets::SURF_OFFSETS_LEFT,current_frame)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset( Outfit_Offsets::SURF_OFFSETS_RIGHT,current_frame)
elsif direction == DIRECTION_UP
apply_sprite_offset( Outfit_Offsets::SURF_OFFSETS_UP,current_frame)
end
when "dive"
if direction == DIRECTION_DOWN
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_DOWN,current_frame)
elsif direction == DIRECTION_LEFT
apply_sprite_offset( Outfit_Offsets::DIVE_OFFSETS_LEFT,current_frame)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset( Outfit_Offsets::DIVE_OFFSETS_RIGHT,current_frame)
elsif direction == DIRECTION_UP
apply_sprite_offset( Outfit_Offsets::DIVE_OFFSETS_UP,current_frame)
end
when "bike"
if direction == DIRECTION_DOWN
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_DOWN,current_frame)
elsif direction == DIRECTION_LEFT
apply_sprite_offset( Outfit_Offsets::BIKE_OFFSETS_LEFT,current_frame)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset( Outfit_Offsets::BIKE_OFFSETS_RIGHT,current_frame)
elsif direction == DIRECTION_UP
apply_sprite_offset( Outfit_Offsets::BIKE_OFFSETS_UP,current_frame)
end
when "fish"
if direction == DIRECTION_DOWN
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_DOWN,current_frame)
elsif direction == DIRECTION_LEFT
apply_sprite_offset( Outfit_Offsets::FISH_OFFSETS_LEFT,current_frame)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset( Outfit_Offsets::FISH_OFFSETS_RIGHT,current_frame)
elsif direction == DIRECTION_UP
apply_sprite_offset( Outfit_Offsets::FISH_OFFSETS_UP,current_frame)
end
else
@sprite.x = @player_sprite.x - @player_sprite.ox
@sprite.y = @player_sprite.y - @player_sprite.oy
end
adjustPositionForScreenScrolling()
@sprite.y -= 2 if current_frame % 2 == 1
end
def animate(action, frame=nil)
@action = action
current_frame = @player_sprite.character.pattern if !frame
direction = @player_sprite.character.direction
crop_spritesheet(direction)
adjust_layer()
set_sprite_position(@action, direction, current_frame)
end
def update(action, filename,color)
@sprite.opacity = @player_sprite.opacity if @wearableBitmap
if filename != @filename || color != @color
if pbResolveBitmap(filename)
#echoln pbResolveBitmap(filename)
@wearableBitmap = AnimatedBitmap.new(filename,color)
@sprite.bitmap = @wearableBitmap.bitmap
else
@wearableBitmap = nil
@sprite.bitmap = nil
end
@color =color
@filename = filename
end
animate(action)
end
def adjust_layer()
if @sprite.z != @player_sprite.z+@relative_z
@sprite.z = @player_sprite.z+@relative_z
end
end
def crop_spritesheet(direction)
sprite_x = 0
sprite_y = ((direction - 2) / 2) * @frameHeight
@sprite.src_rect.set(sprite_x, sprite_y, @frameWidth, @frameHeight)
end
def dispose
return if @disposed
@sprite.dispose if @sprite
@sprite = nil
@disposed = true
end
def disposed?
@disposed
end
end

View File

@@ -0,0 +1,85 @@
class Sprite_Hair < Sprite_Wearable
def initialize(player_sprite, filename, action, viewport)
super
@relative_z = 1
#@sprite.z = @player_sprite.z + 1
end
def animate(action, frame = nil)
@action = action
current_frame = @player_sprite.character.pattern if !frame
direction = @player_sprite.character.direction
crop_spritesheet(direction, current_frame, action)
adjust_layer()
set_sprite_position(@action, direction, current_frame)
end
def crop_spritesheet(direction, current_frame, action)
sprite_x = ((current_frame)) * @frameWidth
# Don't animate surf
sprite_x = 0 if action == "surf"
sprite_y = ((direction - 2) / 2) * @frameHeight
@sprite.src_rect.set(sprite_x, sprite_y, @frameWidth, @frameHeight)
end
def set_sprite_position(action, direction, current_frame)
@sprite.x = @player_sprite.x - @player_sprite.ox
@sprite.y = @player_sprite.y - @player_sprite.oy
case action
when "run"
if direction == DIRECTION_DOWN
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_DOWN, current_frame)
elsif direction == DIRECTION_LEFT
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_LEFT, current_frame)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_RIGHT, current_frame)
elsif direction == DIRECTION_UP
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_UP, current_frame)
end
when "surf"
if direction == DIRECTION_DOWN # Always animate as if on the first frame
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_DOWN, 0)
elsif direction == DIRECTION_LEFT
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_LEFT, 0)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_RIGHT, 0)
elsif direction == DIRECTION_UP
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_UP, 0)
end
when "dive"
if direction == DIRECTION_DOWN
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_DOWN, current_frame)
elsif direction == DIRECTION_LEFT
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_LEFT, current_frame)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_RIGHT, current_frame)
elsif direction == DIRECTION_UP
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_UP, current_frame)
end
when "bike"
if direction == DIRECTION_DOWN
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_DOWN, current_frame)
elsif direction == DIRECTION_LEFT
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_LEFT, current_frame)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_RIGHT, current_frame)
elsif direction == DIRECTION_UP
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_UP, current_frame)
end
when "fish"
if direction == DIRECTION_DOWN
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_DOWN, current_frame)
elsif direction == DIRECTION_LEFT
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_LEFT, current_frame)
elsif direction == DIRECTION_RIGHT
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_RIGHT, current_frame)
elsif direction == DIRECTION_UP
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_UP, current_frame)
end
end
adjustPositionForScreenScrolling()
end
end

View File

@@ -0,0 +1,6 @@
class Sprite_Hat < Sprite_Wearable
def initialize(player_sprite, filename, action, viewport, relative_z=2)
super
@relative_z = relative_z
end
end

View File

@@ -0,0 +1,158 @@
class TrainerAppearance
attr_accessor :skin_color
attr_accessor :hat
attr_accessor :hat2
attr_accessor :clothes
attr_accessor :hair
attr_accessor :hair_color
attr_accessor :clothes_color
attr_accessor :hat_color
attr_accessor :hat2_color
def initialize(skin_color, hat, clothes, hair, hair_color = 0, clothes_color = 0, hat_color = 0, hat2=nil, hat2_color=0)
@skin_color = skin_color
@hat = hat
@hat2 = hat2
@clothes = clothes
@hair = hair
@hair_color = hair_color
@clothes_color = clothes_color
@hat_color = hat_color
@hat2_color = hat2_color
end
end
def getTypeExpertAppearance(trainer_type)
return TYPE_EXPERTS_APPEARANCES[trainer_type]
end
TYPE_EXPERTS_APPEARANCES = {
:TYPE_EXPERT_NORMAL => TrainerAppearance.new(5, "snorlaxhat", "normal", "1_painter", 0, 0, 0), #todo TEAM
:TYPE_EXPERT_FIGHTING => TrainerAppearance.new(1, "karateHeadband", "fighting", "4_samurai", 0, 0, 0), #OK
# TYPE_EXPERT_FLYING =>#TODO NEEDS OUTFIT, LOCATION, TEAM
:TYPE_EXPERT_POISON => TrainerAppearance.new(5, "parashroom", "deadlypoisondanger", "3_lowbraids", 270, 0, 0), #todo TEAM
:TYPE_EXPERT_GROUND => TrainerAppearance.new(5, "sandshrewbeanie", "groundcowboy", "3_shortspike", 0, 0, 0), #todo TEAM
# TYPE_EXPERT_ROCK =>#TODO NEEDS OUTFIT, LOCATION, TEAM
:TYPE_EXPERT_BUG => TrainerAppearance.new("0", "bugantenna", "bughakama", "3_hime", 60, 0,), #OK
#:TYPE_EXPERT_GHOST => TrainerAppearance.new(6,"duskullmask","gothhoodie","4_hime",0,0,0), #NO CLOTHES - DISABLED #TODO NEEDS OUTFIT, TEAM
:TYPE_EXPERT_STEEL => TrainerAppearance.new(2, "veteranM", "steelworkerF", "4_highpony", 0, 0, 0), #todo TEAM
:TYPE_EXPERT_FIRE => TrainerAppearance.new(4, "firefigther", "fire", "2_bob", 330, 0, 0), #todo TEAM
:TYPE_EXPERT_WATER => TrainerAppearance.new(5, "waterdress", "waterdress", "1_pixie", 180, 0, 0),
# TYPE_EXPERT_GRASS => TrainerAppearance.new("0","aerodactylSkull","red","","","") , #TODO NEEDS OUTFIT, LOCATION, TEAM
:TYPE_EXPERT_ELECTRIC => TrainerAppearance.new(3, "designerheadphones", "urbanelectric", "1_dancer", 10, 0, 0), #OK
# TYPE_EXPERT_PSYCHIC =># TODO NEEDS OUTFIT, LOCATION, TEAM
:TYPE_EXPERT_ICE => TrainerAppearance.new(6,"skierF","iceoutfit","1_wavy",0,0,210),
:TYPE_EXPERT_DRAGON => TrainerAppearance.new(5, "aerodactylSkull", "dragonconqueror", "2_SpecialLatias", 670, 0, 510), #todo NEEDS LOCATION, TEAM
# TYPE_EXPERT_DARK => #TODO NEEDS OUTFIT, LOCATION, TEAM
:TYPE_EXPERT_FAIRY => TrainerAppearance.new(6, "mikufairy", "mikufairyf", "5_mikufairy", 0, 0, 0) #OK
}
TYPE_EXPERT_TRAINERS = {
:QMARK => ["name", "loseText"],
:ELECTRIC => ["Ray", "What a shocking turn of events!"],
:BUG => ["Bea", "Im bugging out of here!"],
:FAIRY => ["Luna", "You outshined me!"],
:DRAGON => ["Draco", "I shall scale back my plans."],
:FIGHTING => ["Floyd", "I have to throw in the towel."],
:GROUND => ["Pedro", "Im buried under this loss."],
:FIRE => ["Blaze", "I guess I got burned out."],
:GRASS => ["Ivy", "ou really cut me down to size!"],
:ICE => ["Crystal", "Im skating on thin ice!"],
:ROCK => ["Slate", "Looks like Ive hit rock bottom..."],
:WATER => ["Marina", "You really made a splash!"],
:FLYING => ["Gale", "I guess Im grounded for now."],
:DARK => ["Raven", "Ill slip back into the shadows"],
:STEEL => ["Silvia", "I guess I was a bit rusty..."],
:PSYCHIC => ["Carl", "I could not foresee this defeat."],
:GHOST => ["Evangeline", "I can feel myself disappearing into thin air!"],
:POISON => ["Marie", "I got a taste of my own medicine!"],
:NORMAL => ["Tim", "This was anything but normal!"],
}
TYPE_EXPERT_REWARDS = {
:QMARK => [],
:ELECTRIC => [CLOTHES_ELECTRIC],
:BUG => [CLOTHES_BUG_1,CLOTHES_BUG_2],
:FAIRY => [CLOTHES_FAIRY_F,CLOTHES_FAIRY_M],
:DRAGON => [CLOTHES_DRAGON],
:FIGHTING => [CLOTHES_FIGHTING],
:GROUND => [CLOTHES_GROUND],
:FIRE => [CLOTHES_FIRE],
:GRASS => [CLOTHES_GRASS],
:ICE => [CLOTHES_ICE],
:ROCK => [CLOTHES_ROCK],
:WATER => [CLOTHES_WATER],
:FLYING => [CLOTHES_FLYING],
:DARK => [CLOTHES_DARK],
:STEEL => [CLOTHES_STEEL_F,CLOTHES_STEEL_M],
:PSYCHIC => [CLOTHES_PSYCHIC],
:GHOST => [CLOTHES_GHOST],
:POISON => [CLOTHES_POISON],
:NORMAL => [CLOTHES_NORMAL],
}
TOTAL_NB_TYPE_EXPERTS = 12
def type_expert_battle(type_id)
type = GameData::Type.get(type_id)
pbCallBub(2, @event_id)
pbMessage("Ah! Can you feel the energy in here? This place is great for #{type.real_name}-Pokémon!")
pbCallBub(2, @event_id)
pbMessage("I'm what you could call an expert on #{type.real_name}-Pokémon. I've grown with them for all of my life.")
pbCallBub(2, @event_id)
pbMessage("I'll give you my \\C[5]special outfit\\C[0] if you can defeat my team using only #{type.real_name}-type Pokémon. ")
pbCallBub(2, @event_id)
if pbConfirmMessage("Do you think you can handle that?")
pbCallBub(2, @event_id)
pbMessage("Select your team! Remember, only #{type.real_name}-type Pokémon are allowed!")
gym_randomizer_index = GYM_TYPES_CLASSIC.index(type_id)
echoln gym_randomizer_index
pbSet(VAR_CURRENT_GYM_TYPE, gym_randomizer_index)
if PokemonSelection.choose(1, 4, true, true, proc { |poke| poke.hasType?(type_id) })
#Level is equal to the highest level in player's party
$game_switches[Settings::OVERRIDE_BATTLE_LEVEL_SWITCH]=true
$game_switches[SWITCH_DONT_RANDOMIZE]=true
pbSet(Settings::OVERRIDE_BATTLE_LEVEL_VALUE_VAR, $player.highest_level_pokemon_in_party)
trainer_class = "TYPE_EXPERT_#{type_id.to_s}".to_sym
trainer_name = TYPE_EXPERT_TRAINERS[type_id][0]
lose_text = TYPE_EXPERT_TRAINERS[type_id][1]
if pbTrainerBattle(trainer_class, trainer_name, lose_text, false, 0, false)
pbSet(VAR_TYPE_EXPERTS_BEATEN,pbGet(VAR_TYPE_EXPERTS_BEATEN)+1)
pbCallBub(2, @event_id)
pbMessage("Woah! You beat me at my own specialty! ")
pbCallBub(2, @event_id)
pbMessage("It's a true testament to your mastery of Pokémon typings!")
pbCallBub(2, @event_id)
pbMessage("Well then, I'll keep my word. You can have this very special outfit!")
for clothes in TYPE_EXPERT_REWARDS[type_id]
obtainClothes(clothes)
end
pbCallBub(2, @event_id)
pbMessage("When you wear it, you can sometimes find #{type.real_name}-type related items after battles!")
show_nb_type_experts_defeated()
PokemonSelection.restore
$game_switches[Settings::OVERRIDE_BATTLE_LEVEL_SWITCH]=false
$game_switches[SWITCH_DONT_RANDOMIZE]=false
pbSet(VAR_CURRENT_GYM_TYPE, -1)
return true
end
else
pbCallBub(2, @event_id)
pbMessage("Remember, you're only allowed to use #{type.real_name}-type Pokémon!")
end
end
PokemonSelection.restore
$game_switches[Settings::OVERRIDE_BATTLE_LEVEL_SWITCH]=false
$game_switches[SWITCH_DONT_RANDOMIZE]=false
pbSet(VAR_CURRENT_GYM_TYPE, -1)
return false
end
def show_nb_type_experts_defeated()
pbMEPlay("Register phone")
pbCallBub(3)
Kernel.pbMessage("Type experts defeated: #{pbGet(VAR_TYPE_EXPERTS_BEATEN)}/#{TOTAL_NB_TYPE_EXPERTS}")
end

View File

@@ -53,14 +53,14 @@ class CharacterSelectionMenuView
@sprites["select"].y = OPTIONS_START_Y
@sprites["select"].visible = true
@sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow", 8, 40, 28, 2, @viewport)
@sprites["leftarrow"] = AnimatedSprite.new(UI_FOLDER + "left_arrow", 8, 40, 28, 2, @viewport)
@sprites["leftarrow"].x = ARROW_LEFT_X_POSITION
@sprites["leftarrow"].y = 0
@sprites["leftarrow"].visible = false
@sprites["leftarrow"].play
@sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow", 8, 40, 28, 2, @viewport)
@sprites["rightarrow"] = AnimatedSprite.new(UI_FOLDER + "right_arrow", 8, 40, 28, 2, @viewport)
@sprites["rightarrow"].x = ARROW_RIGHT_X_POSITION
@sprites["rightarrow"].y = 0
@sprites["rightarrow"].visible = false

View File

@@ -0,0 +1,71 @@
class Trainer
attr_accessor :quests
attr_accessor :sprite_override
attr_accessor :custom_appearance
attr_accessor :lowest_difficulty
attr_accessor :selected_difficulty
attr_accessor :game_mode
alias pokemonEssentials_Trainer_initialize initialize
def initialize(name, trainer_type, sprite_override=nil, custom_appearance=nil)
pokemonEssentials_Trainer_initialize(name, trainer_type)
@sprite_override = sprite_override
@custom_appearance = custom_appearance
@lowest_difficulty=2 #On hard by default, lowered whenever the player selects another difficulty
@selected_difficulty=2 #On hard by default, lowered whenever the player selects another difficulty
@game_mode =0 #classic
end
def trainer_type_name
return GameData::TrainerType.get(@trainer_type).name;
end
def base_money
return GameData::TrainerType.get(@trainer_type).base_money;
end
def gender
return GameData::TrainerType.get(@trainer_type).gender;
end
def male?
return GameData::TrainerType.get(@trainer_type).male?;
end
def female?
return GameData::TrainerType.get(@trainer_type).female?;
end
def skill_level
if $game_switches[SWITCH_GAME_DIFFICULTY_HARD]
return 100
end
return GameData::TrainerType.get(@trainer_type).skill_level;
end
def skill_code
return GameData::TrainerType.get(@trainer_type).skill_code;
end
def highest_level_pokemon_in_party
max_level = 0
for pokemon in @party
if pokemon.level > max_level
max_level = pokemon.level
end
end
return max_level
end
def has_species_or_fusion?(species, form = -1)
return pokemon_party.any? { |p| p && p.isSpecies?(species) || p.isFusionOf(species) }
end
end

View File

@@ -0,0 +1,198 @@
################################################################################
# Randomized Pokemon Script
# By Umbreon
################################################################################
# Used for a randomized pokemon challenge mainly.
#
# By randomized, I mean EVERY pokemon will be random, even interacted pokemon
# like legendaries. (You may easily disable the randomizer for certain
# situations like legendary battles and starter selecting.)
#
# To use: simply activate Switch Number X
# (X = the number listed After "Switch = ", default is switch number 36.)
#
# If you want certain pokemon to NEVER appear, add them inside the black list.
# (This does not take into effect if the switch stated above is off.)
#
# If you want ONLY certain pokemon to appear, add them to the whitelist. This
# is only recommended when the amount of random pokemon available is around
# 32 or less.(This does not take into effect if the switch stated above is off.)
#
################################################################################
########################## You may edit any settings below this freely.
# module RandomizedChallenge
# Switch = 36 # switch ID to randomize a pokemon, if it's on then ALL
# # pokemon will be randomized. No exceptions.
#
# BlackListedPokemon = [] #[PBSpecies::MEW, PBSpecies::ARCEUS]
# # Pokemon to Black List. Any pokemon in here will NEVER appear.
#
# WhiteListedPokemon = []
# # Leave this empty if all pokemon are allowed, otherwise only pokemon listed
# # above will be selected.
# end
#
# ######################### Do not edit anything below here.
# class PokeBattle_Pokemon
#
# alias randomized_init initialize
#
# def initialize(species, level, player = nil, withMoves = true)
#
# if $game_switches && $game_switches[RandomizedChallenge::Switch]
# if $game_switches[991]
# species = rand(PBSpecies.maxValue - 1) + 1
# basestatsum = $pkmn_dex[species][5][0] # HP
# basestatsum += $pkmn_dex[species][5][1] # Attack
# basestatsum += $pkmn_dex[species][5][2] # Defense
# basestatsum += $pkmn_dex[species][5][3] # Speed
# basestatsum += $pkmn_dex[species][5][4] # Special Attack
# basestatsum += $pkmn_dex[species][5][5] # Special Defense
#
# while basestatsum > $game_variables[53] || basestatsum < $game_variables[87]
# species = rand(PBSpecies.maxValue - 1) + 1
# basestatsum = $pkmn_dex[species][5][0] # HP
# basestatsum += $pkmn_dex[species][5][1] # Attack
# basestatsum += $pkmn_dex[species][5][2] # Defense
# basestatsum += $pkmn_dex[species][5][3] # Speed
# basestatsum += $pkmn_dex[species][5][4] # Special Attack
# basestatsum += $pkmn_dex[species][5][5] # Special Defense
# end
# #Kernel.pbMessage(_INTL("total = {1}, {2}",basestatsum, PBSpecies.getName(species)))
# else
# if $game_switches[841]
# species = getRandomCustomSprite()
# else
# species = rand(PBSpecies.maxValue - 1) + 1
# end
# end
# end
#
# randomized_init(species, level, player, withMoves)
# end
# end
#
#
# def getRandomCustomSprite()
# filesList = Dir["./Graphics/CustomBattlers/*"]
# i = rand(filesList.length - 1)
# path = filesList[i]
# file = File.basename(path, ".*")
# splitPoke = file.split(".")
# head = splitPoke[0].to_i
# body = splitPoke[1].to_i
# return (body * NB_POKEMON) + head
# end
=begin
##########################
# Trainer house shit
#########################
#Battleformat : 0 = single
# 1 = double
def Kernel.pbTrainerHouse(bstMin,bstMax,level,battleformat)
return false if !validateLevel()
#activate random Pokemon
$game_switches[991] = true
#Set game variables
$game_variables[87]=bstMin
$game_variabes[53]=bstMax
#initialize variables
trainerHouse=true
currentStreak=0
backupTeamLevels()
doubleBattle = battleformat == 1 ? true : false
while trainerHouse
currentStreak += 1
TrainerHouseVictory(currentStreak) if TrainerHouseBattle(level)
end
end
def backupTeamLevels()
$game_variables[91] = $player.pokemonParty[0].level
$game_variables[92] = $player.pokemonParty[1].level
$game_variables[93] = $player.pokemonParty[2].level
end
#choisir le trainer a combattre en fonction du level
def TrainerHouseBattle(level,battleformat)
victoryMessage = getVictoryMessage()
getTrainerHouseBattle(rand(1),level,battleformat)
return
end
#initialiser background & musique pour le combat
def setBattleConstants()
$PokemonGlobal.nextBattleBGM="SubwayTrainerBattle"
$PokemonGlobal.nextBattleBack="IndoorC"
end
#Ajouter les TP après un victoire
def TrainerHouseVictory(currentStreak)
tp_won = currentStreak + 1
$game_variables[49] = tp_won
end
#Valider si le niveau est un challenge possible
def validateLevel(level)
validLevels=[25,50,100]
return validLevels.include?(level)
end
def getVictoryMessage()
return "You're good!"
end
def getTrainerHouseBattle(IsMale,level,single=true)
victoryMessage = getVictoryMessage()
LV25MALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Matthew",_I(victoryMessage),false,0,true)
LV25FEMALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Jessica",_I(victoryMessage),false,0,true)
LV25MALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Alex",_I(victoryMessage),false,0,true)
LV25FEMALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Laurie",_I(victoryMessage),false,0,true)
LV50MALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Alberto",_I(victoryMessage),false,0,true)
LV50FEMALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Skyler",_I(victoryMessage),true,0,true)
LV50MALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Patrick",_I(victoryMessage),false,0,true)
LV50FEMALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Heather",_I(victoryMessage),true,0,true)
LV100MALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Joe",_I(victoryMessage),false,0,true)
LV100FEMALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Melissa",_I(victoryMessage),true,0,true)
LV100MALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Stephen",_I(victoryMessage),false,0,true)
LV100FEMALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Kim",_I(victoryMessage),true,0,true)
if single #SINGLE
if level == 25
return LV25MALE_SINGLE if IsMale == 1
return LV25FEMALE_SINGLE
elsif level == 50
return LV50MALE_SINGLE if IsMale == 1
return LV50FEMALE_SINGLE
else
return LV100MALE_SINGLE if IsMale == 1
return LV100FEMALE_SINGLE
end
else #DOUBLE
if level == 25
return LV25MALE_DOUBLE if IsMale == 1
return LV25FEMALE_DOUBLE
elsif level == 50
return LV50MALE_DOUBLE if IsMale == 1
return LV50FEMALE_DOUBLE
else
return LV100MALE_DOUBLE if IsMale == 1
return LV100FEMALE_DOUBLE
end
end
end
=end

View File

@@ -0,0 +1,535 @@
module OptionTypes
WILD_POKE = 0
TRAINER_POKE = 1
end
class RandomizerOptionsScene < PokemonOption_Scene
def initialize
super
@openTrainerOptions = false
@openWildOptions = false
@openGymOptions = false
@openItemOptions = false
$game_switches[SWITCH_RANDOMIZED_AT_LEAST_ONCE] = true
end
def getDefaultDescription
return _INTL("Set the randomizer settings")
end
def pbStartScene(inloadscreen = false)
super
@changedColor = true
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
_INTL("Randomizer settings"), 0, 0, Graphics.width, 64, @viewport)
@sprites["textbox"].text = getDefaultDescription
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbGetOptions(inloadscreen = false)
options = [
EnumOption.new(_INTL("Pokémon"), [_INTL("On"), _INTL("Off")],
proc {
$game_switches[SWITCH_RANDOM_WILD] ? 0 : 1
},
proc { |value|
if !$game_switches[SWITCH_RANDOM_WILD] && value == 0
@openWildOptions = true
openWildPokemonOptionsMenu()
end
$game_switches[SWITCH_RANDOM_WILD] = value == 0
}, "Select the randomizer options for Pokémon"
),
EnumOption.new(_INTL("NPC Trainers"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_TRAINERS] ? 0 : 1 },
proc { |value|
if !$game_switches[SWITCH_RANDOM_TRAINERS] && value == 0
@openTrainerOptions = true
openTrainerOptionsMenu()
end
$game_switches[SWITCH_RANDOM_TRAINERS] = value == 0
}, "Select the randomizer options for trainers"
),
EnumOption.new(_INTL("Gym trainers"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOMIZE_GYMS_SEPARATELY] ? 0 : 1 },
proc { |value|
if !$game_switches[SWITCH_RANDOMIZE_GYMS_SEPARATELY] && value == 0
@openGymOptions = true
openGymOptionsMenu()
end
$game_switches[SWITCH_RANDOMIZE_GYMS_SEPARATELY] = value == 0
}, "Limit gym trainers to a single type"
),
EnumOption.new(_INTL("Items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_ITEMS_GENERAL] ? 0 : 1 },
proc { |value|
if !$game_switches[SWITCH_RANDOM_ITEMS_GENERAL] && value == 0
@openItemOptions = true
openItemOptionsMenu()
end
$game_switches[SWITCH_RANDOM_ITEMS_GENERAL] = value == 0
}, "Select the randomizer options for items"
),
]
return options
end
def openGymOptionsMenu()
return if !@openGymOptions
pbFadeOutIn {
scene = RandomizerGymOptionsScene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen
}
@openGymOptions = false
end
def openItemOptionsMenu()
return if !@openItemOptions
pbFadeOutIn {
scene = RandomizerItemOptionsScene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen
}
@openItemOptions = false
end
def openTrainerOptionsMenu()
return if !@openTrainerOptions
pbFadeOutIn {
scene = RandomizerTrainerOptionsScene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen
}
@openTrainerOptions = false
end
def openWildPokemonOptionsMenu()
return if !@openWildOptions
pbFadeOutIn {
scene = RandomizerWildPokemonOptionsScene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen
}
@openWildOptions = false
end
end
class RandomizerTrainerOptionsScene < PokemonOption_Scene
RANDOM_TEAMS_CUSTOM_SPRITES = 600
RANDOM_GYM_TYPES = 921
def initialize
@changedColor = false
end
def pbStartScene(inloadscreen = false)
super
@sprites["option"].nameBaseColor = MessageConfig::BLUE_TEXT_MAIN_COLOR
@sprites["option"].nameShadowColor = MessageConfig::BLUE_TEXT_SHADOW_COLOR
@changedColor = true
for i in 0...@PokemonOptions.length
@sprites["option"][i] = (@PokemonOptions[i].get || 0)
end
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
_INTL("Randomizer settings: Trainers"), 0, 0, Graphics.width, 64, @viewport)
@sprites["textbox"].text = _INTL("Set the randomizer settings for trainers")
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbFadeInAndShow(sprites, visiblesprites = nil)
return if !@changedColor
super
end
def pbGetOptions(inloadscreen = false)
options = []
if !$game_switches[SWITCH_DURING_INTRO]
options << SliderOption.new(_INTL("Randomness degree"), 25, 500, 5,
proc { $game_variables[VAR_RANDOMIZER_TRAINER_BST] },
proc { |value|
$game_variables[VAR_RANDOMIZER_TRAINER_BST] = value
})
end
options << EnumOption.new(_INTL("Custom Sprites only"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_TEAMS_CUSTOM_SPRITES] ? 0 : 1 },
proc { |value|
$game_switches[RANDOM_TEAMS_CUSTOM_SPRITES] = value == 0
},
"Use only Pokémon that have custom sprites in trainer teams"
)
# options << EnumOption.new(_INTL("Allow legendaries"), [_INTL("On"), _INTL("Off")],
# proc { $game_switches[SWITCH_RANDOM_TRAINER_LEGENDARIES] ? 0 : 1 },
# proc { |value|
# $game_switches[SWITCH_RANDOM_TRAINER_LEGENDARIES] = value == 0
# }, "Regular Pokémon can also be randomized into legendaries"
# )
return options
end
end
class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
RANDOM_WILD_AREA = 777
RANDOM_WILD_GLOBAL = 956
RANDOM_STATIC = 955
REGULAR_TO_FUSIONS = 953
GIFT_POKEMON = 780
def initialize
@changedColor = false
end
def pbStartScene(inloadscreen = false)
super
@sprites["option"].nameBaseColor = Color.new(70, 170, 40)
@sprites["option"].nameShadowColor = Color.new(40, 100, 20)
@changedColor = true
for i in 0...@PokemonOptions.length
@sprites["option"][i] = (@PokemonOptions[i].get || 0)
end
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
_INTL("Randomizer settings: Pokémon"), 0, 0, Graphics.width, 64, @viewport)
@sprites["textbox"].text = _INTL("Set the randomizer settings for wild Pokémon")
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbFadeInAndShow(sprites, visiblesprites = nil)
return if !@changedColor
super
end
def pbGetOptions(inloadscreen = false)
options = []
if !$game_switches[SWITCH_DURING_INTRO]
options << SliderOption.new(_INTL("Randomness degree"), 25, 500, 5,
proc { $game_variables[VAR_RANDOMIZER_WILD_POKE_BST] },
proc { |value|
$game_variables[VAR_RANDOMIZER_WILD_POKE_BST] = value
})
end
options << EnumOption.new(_INTL("Type"), [_INTL("Global"), _INTL("Area")],
proc {
if $game_switches[RANDOM_WILD_AREA]
1
else
0
end
},
proc { |value|
if value == 0
$game_switches[RANDOM_WILD_GLOBAL] = true
$game_switches[RANDOM_WILD_AREA] = false
else
value == 1
$game_switches[RANDOM_WILD_GLOBAL] = false
$game_switches[RANDOM_WILD_AREA] = true
end
},
[
"Randomizes Pokémon using a one-to-one mapping of the Pokedex",
"Randomizes the encounters in each route individually"
]
)
options << EnumOption.new(_INTL("Custom sprites only"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] = value == 0
}, "['Fuse everything' & starters] Include only Pokémon with a custom sprite."
)
options << EnumOption.new(_INTL("Allow legendaries"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_WILD_LEGENDARIES] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_WILD_LEGENDARIES] = value == 0
}, ["Regular wild Pokémon can also be randomized into legendaries.",
"Only legendaries can be randomized into legendaries"]
)
options << EnumOption.new(_INTL("Starters"), [_INTL("1st Stage"), _INTL("Any"), _INTL("Off")],
proc {
getStarterRandomizerSelectedOption() },
proc { |value|
case value
when 0
$game_switches[SWITCH_RANDOM_STARTERS] = true
$game_switches[SWITCH_RANDOM_STARTER_FIRST_STAGE] = true
when 1
$game_switches[SWITCH_RANDOM_STARTERS] = true
$game_switches[SWITCH_RANDOM_STARTER_FIRST_STAGE] = false
else
$game_switches[SWITCH_RANDOM_STARTERS] = false
$game_switches[SWITCH_RANDOM_STARTER_FIRST_STAGE] = false
end
echoln "random starters: #{$game_switches[SWITCH_RANDOM_STARTERS]}"
echoln "random 1st stage: #{$game_switches[SWITCH_RANDOM_STARTER_FIRST_STAGE]}"
}, ["The starters will always be a first evolution Pokémon",
"The starters can be any Pokémon",
"The starters are not randomized"]
)
options << EnumOption.new(_INTL("Static encounters"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_STATIC] ? 0 : 1 },
proc { |value|
$game_switches[RANDOM_STATIC] = value == 0
},
"Randomize Pokémon that appear in the overworld (including legendaries)"
)
options << EnumOption.new(_INTL("Gift Pokémon"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[GIFT_POKEMON] ? 0 : 1 },
proc { |value|
$game_switches[GIFT_POKEMON] = value == 0
}, "Randomize Pokémon that are gifted to the player"
)
options << EnumOption.new(_INTL("Fuse everything"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[REGULAR_TO_FUSIONS] ? 0 : 1 },
proc { |value|
$game_switches[REGULAR_TO_FUSIONS] = value == 0
}, "All wild Pokémon will already be pre-fused"
)
return options
end
def getStarterRandomizerSelectedOption()
return 0 if $game_switches[SWITCH_RANDOM_STARTERS] && $game_switches[SWITCH_RANDOM_STARTER_FIRST_STAGE]
return 1 if $game_switches[SWITCH_RANDOM_STARTERS]
return 2
end
end
class RandomizerGymOptionsScene < PokemonOption_Scene
RANDOM_GYM_TYPES = 921
def initialize
@changedColor = false
end
def pbStartScene(inloadscreen = false)
super
@sprites["option"].nameBaseColor = MessageConfig::BLUE_TEXT_MAIN_COLOR
@sprites["option"].nameShadowColor = MessageConfig::BLUE_TEXT_SHADOW_COLOR
@changedColor = true
for i in 0...@PokemonOptions.length
@sprites["option"][i] = (@PokemonOptions[i].get || 0)
end
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
_INTL("Randomizer settings: Gyms"), 0, 0, Graphics.width, 64, @viewport)
@sprites["textbox"].text = _INTL("Set the randomizer settings for gyms")
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbFadeInAndShow(sprites, visiblesprites = nil)
return if !@changedColor
super
end
def pbGetOptions(inloadscreen = false)
options = []
if !$game_switches[SWITCH_DURING_INTRO]
options << SliderOption.new(_INTL("Randomness degree"), 25, 500, 5,
proc { $game_variables[VAR_RANDOMIZER_TRAINER_BST] },
proc { |value|
$game_variables[VAR_RANDOMIZER_TRAINER_BST] = value
})
end
options << EnumOption.new(_INTL("Custom sprites only"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_GYM_CUSTOMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_GYM_CUSTOMS] = value == 0
}, ["Use only Pokémon that have custom sprites in gym trainers or gym leader teams",
"Pick any possible fusion, including auto-generated sprites."]
)
options << EnumOption.new(_INTL("Gym types"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_GYM_TYPES] ? 0 : 1 },
proc { |value|
$game_switches[RANDOM_GYM_TYPES] = value == 0
}, "Shuffle the gym types"
)
# options << EnumOption.new(_INTL("Allow legendaries"), [_INTL("On"), _INTL("Off")],
# proc { $game_switches[SWITCH_RANDOM_GYM_LEGENDARIES] ? 0 : 1 },
# proc { |value|
# $game_switches[SWITCH_RANDOM_GYM_LEGENDARIES] = value == 0
# }, "Regular Pokémon can also be randomized into legendaries"
# )
options << EnumOption.new(_INTL("Rerandomize each battle"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_GYM_RANDOM_EACH_BATTLE] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_GYM_RANDOM_EACH_BATTLE] = value == 0
$game_switches[SWITCH_RANDOM_GYM_PERSIST_TEAMS] = !$game_switches[SWITCH_GYM_RANDOM_EACH_BATTLE]
}, "Gym trainers and leaders have a new team each try instead of keeping the same one"
)
return options
end
end
class RandomizerItemOptionsScene < PokemonOption_Scene
RANDOM_HELD_ITEMS = 843
def initialize
@changedColor = false
end
def pbStartScene(inloadscreen = false)
super
@sprites["option"].nameBaseColor = MessageConfig::BLUE_TEXT_MAIN_COLOR
@sprites["option"].nameShadowColor = MessageConfig::BLUE_TEXT_SHADOW_COLOR
@changedColor = true
for i in 0...@PokemonOptions.length
@sprites["option"][i] = (@PokemonOptions[i].get || 0)
end
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
_INTL("Randomizer settings: Items"), 0, 0, Graphics.width, 64, @viewport)
@sprites["textbox"].text = _INTL("Set the randomizer settings for items")
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbFadeInAndShow(sprites, visiblesprites = nil)
return if !@changedColor
super
end
def pbGetOptions(inloadscreen = false)
options = [
EnumOption.new(_INTL("Found items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_FOUND_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_FOUND_ITEMS] = value == 0
$game_switches[SWITCH_RANDOM_ITEMS_MAPPED] = value == 0
$game_switches[SWITCH_RANDOM_ITEMS] = $game_switches[SWITCH_RANDOM_FOUND_ITEMS] || $game_switches[SWITCH_RANDOM_GIVEN_ITEMS]
}, "Randomize the items picked up on the ground"
),
EnumOption.new(_INTL("Found TMs"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_FOUND_TMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_FOUND_TMS] = value == 0
$game_switches[SWITCH_RANDOM_TMS] = $game_switches[SWITCH_RANDOM_FOUND_TMS] || $game_switches[SWITCH_RANDOM_GIVEN_TMS]
}, "Randomize the TMs picked up on the ground"
),
EnumOption.new(_INTL("Given items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_GIVEN_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_GIVEN_ITEMS] = value == 0
$game_switches[SWITCH_RANDOM_ITEMS] = $game_switches[SWITCH_RANDOM_FOUND_ITEMS] || $game_switches[SWITCH_RANDOM_GIVEN_ITEMS]
}, "Randomize the items given by NPCs (may make some quests impossible to complete)"
),
EnumOption.new(_INTL("Given TMs"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_GIVEN_TMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_GIVEN_TMS] = value == 0
$game_switches[SWITCH_RANDOM_TMS] = $game_switches[SWITCH_RANDOM_FOUND_TMS] || $game_switches[SWITCH_RANDOM_GIVEN_TMS]
}, "Randomize the TMs given by NPCs"
),
EnumOption.new(_INTL("Shop items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_SHOP_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_SHOP_ITEMS] = value == 0
}, "Randomizes the items available in shops (always mapped)"
),
EnumOption.new(_INTL("Trainer Held items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_HELD_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[RANDOM_HELD_ITEMS] = value == 0
}, "Give random held items to all trainers"
)
]
return options
end
end
class RandomizerItemOptionsScene < PokemonOption_Scene
RANDOM_HELD_ITEMS = 843
def initialize
@changedColor = false
end
def pbStartScene(inloadscreen = false)
super
@sprites["option"].nameBaseColor = MessageConfig::BLUE_TEXT_MAIN_COLOR
@sprites["option"].nameShadowColor = MessageConfig::BLUE_TEXT_SHADOW_COLOR
@changedColor = true
for i in 0...@PokemonOptions.length
@sprites["option"][i] = (@PokemonOptions[i].get || 0)
end
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
_INTL("Randomizer settings: Items"), 0, 0, Graphics.width, 64, @viewport)
@sprites["textbox"].text = _INTL("Set the randomizer settings for items")
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbFadeInAndShow(sprites, visiblesprites = nil)
return if !@changedColor
super
end
def pbGetOptions(inloadscreen = false)
options = [
EnumOption.new(_INTL("Found items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_FOUND_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_FOUND_ITEMS] = value == 0
$game_switches[SWITCH_RANDOM_ITEMS_MAPPED] = value == 0
$game_switches[SWITCH_RANDOM_ITEMS] = $game_switches[SWITCH_RANDOM_FOUND_ITEMS] || $game_switches[SWITCH_RANDOM_GIVEN_ITEMS]
}, "Randomize the items picked up on the ground"
),
EnumOption.new(_INTL("Found TMs"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_FOUND_TMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_FOUND_TMS] = value == 0
$game_switches[SWITCH_RANDOM_TMS] = $game_switches[SWITCH_RANDOM_FOUND_TMS] || $game_switches[SWITCH_RANDOM_GIVEN_TMS]
}, "Randomize the TMs picked up on the ground"
),
EnumOption.new(_INTL("Given items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_GIVEN_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_GIVEN_ITEMS] = value == 0
$game_switches[SWITCH_RANDOM_ITEMS] = $game_switches[SWITCH_RANDOM_FOUND_ITEMS] || $game_switches[SWITCH_RANDOM_GIVEN_ITEMS]
}, "Randomize the items given by NPCs (may make some quests impossible to complete)"
),
EnumOption.new(_INTL("Given TMs"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_GIVEN_TMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_GIVEN_TMS] = value == 0
$game_switches[SWITCH_RANDOM_TMS] = $game_switches[SWITCH_RANDOM_FOUND_TMS] || $game_switches[SWITCH_RANDOM_GIVEN_TMS]
}, "Randomize the TMs given by NPCs"
),
EnumOption.new(_INTL("Shop items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_SHOP_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_SHOP_ITEMS] = value == 0
}, "Randomizes the items available in shops (always mapped)"
),
EnumOption.new(_INTL("Trainer Held items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_HELD_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[RANDOM_HELD_ITEMS] = value == 0
}, "Give random held items to all trainers"
)
]
return options
end
end

View File

@@ -0,0 +1,223 @@
##### by route
#
# Randomize encounter by routes
# Script by Frogman
#
def Kernel.randomizeWildPokemonByRoute()
bstRange = $game_variables[VAR_RANDOMIZER_WILD_POKE_BST]
randomizeToFusions = $game_switches[SWITCH_RANDOM_WILD_TO_FUSION]
onlyCustoms = $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] && randomizeToFusions
customsList = onlyCustoms ? getCustomSpeciesList() : []
maxSpecies = randomizeToFusions ? PBSpecies.maxValue : NB_POKEMON
GameData::EncounterRandom::DATA.clear
GameData::Encounter.each do |enc_data|
encounters_hash = {}
encounters_hash[:id] = enc_data.id
encounters_hash[:map] = enc_data.map
encounters_hash[:version] = enc_data.version
encounters_hash[:step_chances] = enc_data.step_chances
types_hash = {}
enc_data.types.each do |key, value|
pokemonList = value
newType = randomizePokemonList(pokemonList,bstRange,maxSpecies,onlyCustoms,customsList)
types_hash[key]= newType
end
encounters_hash[:types] = types_hash
GameData::EncounterRandom.register(encounters_hash)
end
# Save all data
GameData::EncounterRandom.save
Graphics.update
GameData::EncounterRandom.load
end
#input: [[60, :TENTACOOL,5,40, [30, :GOLDEEN, 5, 35], etc.]]
def randomizePokemonList(encountersList,bstRange=50,maxSpecies=NB_POKEMON,customOnly=false,customsList=[])
includeLegendaries = $game_switches[SWITCH_RANDOM_WILD_LEGENDARIES]
newList=[]
for encounter in encountersList
oldPokemon = encounter[1]
if customOnly
newPokemon = getNewCustomSpecies(oldPokemon,customsList,bstRange,false,includeLegendaries)
else
newPokemon = getNewSpecies(oldPokemon,bstRange,false,maxSpecies,includeLegendaries)
end
newEntry =[]
newEntry << encounter[0]
newEntry << getSpecies(newPokemon).species
newEntry << encounter[2]
newEntry << encounter[3]
newList << newEntry
end
return newList
end
#
# def Kernel.randomizeWildPokemonByRouteOld()
# bstRange = $game_variables[VAR_RANDOMIZER_WILD_POKE_BST]
# randomizeToFusions = $game_switches[SWITCH_RANDOM_WILD_TO_FUSION]
# $game_switches[SWITCH_RANDOMIZED_WILD_POKEMON_TO_FUSIONS] = randomizeToFusions #unused mais probab. utile pour débugger les inévitables bugs quand les gens vont se partager leurs fichiers
# maxSpecies = randomizeToFusions ? PBSpecies.maxValue : NB_POKEMON
# data=load_data("Data/encounters.dat")
# map_index = 0
# nb_maps= data.size
# if data.is_a?(Hash)
# for map in data
# map_index += 1
# displayProgress(map_index,nb_maps,bstRange)
# map_id = map[0]
#
# encountersList = GameData::Encounter.get(map_id)
# p encountersList
# next if encountersList== nil
# type_index =-1
# for encounterType in encountersList
# type_index +=1
# next if encounterType == nil
# previousSpecies = -1
# previousNewSpecies = -1
# encounter_index = 0
# for encounter in encounterType
# species = encounter[0]
# if species != previousSpecies
# newSpecies= getNewSpecies(species,bstRange,true,maxSpecies)
# previousSpecies = species
# previousNewSpecies = newSpecies
# else
# newSpecies = previousNewSpecies
# end
# if data[map_id][1][type_index][encounter_index] != nil
# data[map_id][1][type_index][encounter_index][0] = newSpecies
# end
# encounter_index +=1
# end #for -encounter
# end #for encountertype
# end #for - map
# end #if
# filename = "Data/encounters_randomized.dat"
# save_data(Marshal.load(Marshal.dump(data)),filename)
# $PokemonEncounters.setup($game_map.map_id)
# end
#file = File.new('Data/test.txt', 'w')
#file.puts data.inspect
# def displayProgress(current,total,bst)
# return if bst >= 100
# return if bst >= 20 && current % 10 != 0
# Kernel.pbMessageNoSound(_INTL("\\ts[]Generating encounters file...\\n Map {1}/{2}\\^",current,total))
# end
#
# class PokemonEncounters
#
# def setup(mapID)
# @density=nil
# @stepcount=0
# @enctypes=[]
# begin
#
# data=load_data(getEncountersFilePath())
# if data.is_a?(Hash) && data[mapID]
# @density=data[mapID][0]
# @enctypes=data[mapID][1]
# else
# @density=nil
# @enctypes=[]
# end
# rescue
# @density=nil
# @enctypes=[]
# end
# end
#
# def getEncountersFilePath()
# if $game_switches[777] && $game_switches[778] #[777] = random-by-area [778] = wildpokerandom activated
# return "Data/encounters_randomized.dat"
# else
# return "Data/encounters.dat"
# end
# end
#
# def pbMapEncounter(mapID,enctype)
# if enctype<0 || enctype>EncounterTypes::EnctypeChances.length
# raise ArgumentError.new(_INTL("Encounter type out of range"))
# end
# data=load_data(getEncountersFilePath())
# if data.is_a?(Hash) && data[mapID]
# enctypes=data[mapID][1]
# else
# return nil
# end
# return nil if enctypes[enctype]==nil
# chances=EncounterTypes::EnctypeChances[enctype]
# chancetotal=0
# chances.each {|a| chancetotal+=a}
# rnd=rand(chancetotal)
# chosenpkmn=0
# chance=0
# for i in 0...chances.length
# chance+=chances[i]
# if rnd<chance
# chosenpkmn=i
# break
# end
# end
# encounter=enctypes[enctype][chosenpkmn]
# level=encounter[1]+rand(1+encounter[2]-encounter[1])
# return [encounter[0],level]
# end
# end
#
# def getRandomPokemon(originalPokemon,bstRange,maxDexNumber)
# originalBst = getBaseStatsTotal(originalPokemon)
# bstMin = originalBst-bstRange
# bstMax = originalBst+bstRange
#
# foundAPokemon = false
# int i=0
# while ! foundAPokemon
# newPoke = rand(maxDexNumber-1)+1
# newPokeBST = getBaseStatsTotal(newPoke)
# if newPokeBST >= bstMin && newPokeBST <= bstMax
# foundAPokemon = true
# end
# i+=1
# if i %10 ==0
# bstMin-=5
# bstMax+=5
# end
# end
# return newPoke
# end
#
# def getBaseStatsTotal(species)
# baseStats=$pkmn_dex[species][5]
# baseStat_temp = 0
# for i in 0...baseStats.length
# baseStat_temp+=baseStats[i]
# end
# return (baseStat_temp/range).floor
# end
######################################################

View File

@@ -0,0 +1,773 @@
#A l'entrée d'un gym: mettre $game_variables[113] = au numéro du gym
#pewter = 0, ceruean = 1 etc.
#Le remettre a -1 à la sortie du gym
#Le mettre a -1 au début du jeu
#
#Aussi des trucs modifiés dans le dude qui donne les freshwater au début
#Faudrait aussi s'assurer que il dise pas n'importe quoi en pas randomized
#
#Voir cerulean gym pour implantation
#
#
#
#
#initialiser la RANDOM_TYPE_ARRAY au début du jeu en runnant Kernel.initRandomTypeArray(8)
#
#
#
#
#
#
##################################################################
# TODO:
#
#
#
###
###############################################################
#
#GYM_TYPES_ARRAY = [0,5,11,13,12,3,14,10,4,1,0,6,2,16,7,15,1,8,15,1,7,16,18,17,7,16]
GYM_TYPES_CLASSIC = [:NORMAL, :ROCK, :WATER, :ELECTRIC, :GRASS, :POISON, :PSYCHIC, :FIRE, :GROUND, :FIGHTING, :NORMAL, :BUG, :FLYING, :DRAGON, :GHOST, :ICE, :FIGHTING, :STEEL, :ICE, :FIGHTING, :GHOST, :DRAGON, :FAIRY, :DARK, :GHOST, :ROCK]
GYM_TYPES_MODERN = [:NORMAL, :STEEL, :ICE, :FIGHTING, :BUG, :DARK, :FAIRY, :PSYCHIC, :NORMAL, :FIGHTING, :FAIRY, :GRASS, :BUG, :DRAGON, :FIRE, :GHOST, :GROUND, :ELECTRIC, :WATER, :ROCK, :POISON, :FLYING, :FAIRY, :DARK, :GHOST, :DRAGON]
GYM_TYPES_ARRAY = ($game_switches && $game_switches[SWITCH_MODERN_MODE]) ? GYM_TYPES_MODERN : GYM_TYPES_CLASSIC
#$randomTrainersArray = []
#[fighting dojo est 9eme (1), 0 au debut pour pasavoir a faire -1]
def Kernel.initRandomTypeArray()
typesArray = GYM_TYPES_ARRAY.shuffle #ne pas remettre 10 (QMARKS)
$game_variables[VAR_GYM_TYPES_ARRAY] = $game_switches[SWITCH_RANDOMIZED_GYM_TYPES] ? typesArray : GYM_TYPES_ARRAY
end
# def setRivalStarter(starter1, starter2, starter3, choice)
# starters = [starter1, starter2, starter3]
# starters.delete_at(choice)
# if starters[0] > NB_POKEMON || starters[1] > NB_POKEMON
# rivalStarter = starters[0]
# else
# rivalStarter = starters[0] * NB_POKEMON + starters[1]
# end
# pbSet(VAR_RIVAL_STARTER, rivalStarter)
# $game_switches[SWITCH_DEFINED_RIVAL_STARTER] = true
# end
def setRivalStarterSpecific(rivalStarter)
pbSet(VAR_RIVAL_STARTER, rivalStarter)
$game_switches[SWITCH_DEFINED_RIVAL_STARTER] = true
end
class PokeBattle_Battle
CONST_BST_RANGE = 25 #unused. $game_variables[197] a la place
def randomize_opponent_party(party)
for pokemon in party
next if !pokemon
newspecies = rand(PBSpecies.maxValue - 1) + 1
while !gymLeaderOk(newspecies) || bstNotOk(newspecies, pokemon.species, $game_variables[VAR_RANDOMIZER_WILD_POKE_BST])
newspecies = rand(PBSpecies.maxValue - 1) + 1
end
pokemon.species = newspecies
pokemon.name = PBSpecies.getName(newspecies)
pokemon.resetMoves
pokemon.calcStats
end
return party
end
def randomizedRivalFirstBattle(party)
return party if $game_switches[953] #full random
starter1 = $PokemonGlobal.psuedoBSTHash[1]
starter2 = $PokemonGlobal.psuedoBSTHash[4]
starter3 = $PokemonGlobal.psuedoBSTHash[7]
playerChoice = $game_variables[7]
for m in party
next if !m
case playerChoice
when 0 then
newspecies = starter2 * NB_POKEMON + starter3
when 1 then
newspecies = starter1 * NB_POKEMON + starter3
when 2 then
newspecies = starter1 * NB_POKEMON + starter2
else
end
m.species = newspecies
m.name = PBSpecies.getName(newspecies)
m.resetMoves
m.calcStats
end
return party
end
end
#######
# end of class
######
####methodes utilitaires
# def getBaseStats(species)
# basestatsum = $pkmn_dex[species][5][0] # HP
# basestatsum +=$pkmn_dex[species][5][1] # Attack
# basestatsum +=$pkmn_dex[species][5][2] # Defense
# basestatsum +=$pkmn_dex[species][5][3] # Speed
# basestatsum +=$pkmn_dex[species][5][4] # Special Attack
# basestatsum +=$pkmn_dex[species][5][5] # Special Defense
# return basestatsum
# end
#
def legendaryOk(oldspecies,newspecies,includeLegendaries)
oldSpeciesIsLegendary = is_legendary(oldspecies)
if oldSpeciesIsLegendary #legendaries always randomize to legendaries
return is_legendary(newspecies)
else
return true if includeLegendaries
return !is_legendary(newspecies)
end
end
def bstNotOk(newspecies, oldPokemonSpecies, bst_range = 50)
newBST = calcBaseStatsSum(newspecies)
originalBST = calcBaseStatsSum(oldPokemonSpecies)
return newBST < originalBST - bst_range || newBST > originalBST + bst_range
end
def gymLeaderOk(newspecies)
return true if $game_variables[VAR_CURRENT_GYM_TYPE] == -1 #not in a gym
leaderType = getLeaderType()
if leaderType == nil
return true
else
return true if SpeciesHasType?(leaderType, newspecies)
end
return false
end
def getLeaderType()
currentGym = $game_variables[VAR_CURRENT_GYM_TYPE]
if currentGym > $game_variables[151].length
return nil
else
typeIndex = $game_variables[151][currentGym]
type = PBTypes.getName(typeIndex)
end
return typeIndex
end
##Version alternatives de fonctions pour fonctionner avec numero de species
def SpeciesHasType?(type, species)
if type.is_a?(String) || type.is_a?(Symbol)
return isConst?(getSpeciesType1(species), PBTypes, type) || isConst?(getSpeciesType2(species), PBTypes, type)
else
return getSpeciesType1(species) == type || getSpeciesType2(species) == type
end
end
# Returns this Pokémon's first type.
def getSpeciesType1(species)
return $pkmn_dex[species][3]
end
# Returns this Pokémon's second type.
def getSpeciesType2(species)
return $pkmn_dex[species][4]
end
############
#summarize random options
def Kernel.sumRandomOptions()
answer = $game_switches[SWITCH_RANDOM_STARTERS] ? "On" : "Off"
stringOptions = "\nStarters: " << answer
answer = $game_switches[SWITCH_RANDOM_WILD] ? "On" : "Off"
stringOptions << "\nWild Pokémon: " << answer << " "
if $game_switches[SWITCH_RANDOM_WILD_AREA]
stringOptions << "(Area)"
else
stringOptions << "(Global)"
end
answer = $game_switches[SWITCH_RANDOM_TRAINERS] ? "On" : "Off"
stringOptions << "\nTrainers: " << answer
answer = $game_switches[SWITCH_RANDOM_STATIC_ENCOUNTERS] ? "On" : "Off"
stringOptions << "\nStatic encounters: " << answer
answer = $game_switches[SWITCH_RANDOM_GIFT_POKEMON] ? "On" : "Off"
stringOptions << "\nGift Pokémon: " << answer
answer = $game_switches[SWITCH_RANDOM_ITEMS] ? "On" : "Off"
stringOptions << "\nItems: " << answer
answer = $game_switches[SWITCH_RANDOM_TMS] ? "On" : "Off"
stringOptions << "\nTMs: " << answer
return stringOptions
end
def countVisitedMaps
count = 0
for i in 0..$PokemonGlobal.visitedMaps.length
count += 1 if $PokemonGlobal.visitedMaps[i]
end
return count
end
def Kernel.sumGameStats()
stringStats = ""
stringStats << "Seen " << $player.pokedexSeen.to_s << " Pokémon"
stringStats << "\nCaught " << $player.pokedexOwned.to_s << " Pokémon"
stringStats << "\nBeat the Elite Four " << $game_variables[VAR_STAT_NB_ELITE_FOUR].to_s << " times"
stringStats << "\nFused " << $game_variables[VAR_STAT_NB_FUSIONS].to_s << " Pokémon"
stringStats << "\nRematched " << $game_variables[VAR_STAT_LEADER_REMATCH].to_s << " Gym Leaders"
stringStats << "\nTook " << $PokemonGlobal.stepcount.to_s << " steps"
stringStats << "\nVisited " << countVisitedMaps.to_s << " different areas"
stringStats << "\nUsed " << $game_variables[VAR_STAT_RARE_CANDY] << " Rare Candies"
if $game_switches[910]
stringStats << "\nMade " << $game_variables[VAR_STAT_NB_WONDERTRADES].to_s << " Wonder Trades"
end
stringStats << "\nTipped $" << $game_variables[VAR_STAT_CLOWN_TIP_TOTAL].to_s << " to clowns"
stringStats << "\nDestroyed " << $game_variables[VAR_STAT_NB_SANDCASTLES].to_s << " sandcastles"
stringStats << "\nReported " << $game_variables[VAR_NB_CRIMES_REPORTED].to_s << " crimes" if $game_variables[VAR_NB_CRIMES_REPORTED] > 0
if $game_variables[VAR_STAT_GAMBLER_WINS] > 0 || $game_variables[VAR_STAT_GAMBLER_LOSSES] > 0
stringStats << "\nWon $" << $game_variables[VAR_STAT_GAMBLER_WINS].to_s << " against gamblers"
stringStats << "\nLost $" << $game_variables[VAR_STAT_GAMBLER_LOSSES].to_s << " against gamblers"
end
stringStats << "\nSpent $" << $game_variables[VAR_STAT_HOTELS_SPENT].to_s << " at hotels"
stringStats << "\nAccepted " << $game_variables[VAR_STAT_QUESTS_ACCEPTED].to_s << " quests"
stringStats << "\nCompleted " << $game_variables[VAR_STAT_QUESTS_COMPLETED].to_s << " quests"
stringStats << "\nDiscovered " << $game_variables[VAR_STAT_NB_SECRETS].to_s << " secrets"
if $game_switches[912]
stringStats << "\nDied " << $game_variables[191].to_s << " times in Pikachu's adventure"
if $game_variables[193] >= 1
stringStats << "\nCollected " << $game_variables[194].to_s << " coins with Pikachu"
end
end
return stringStats
end
def Kernel.pbRandomizeTM()
tmList = []
for item in $itemData
#machine=$ItemData[item][ITEMMACHINE]
#movename=PBMoves.getName(machine)
#Kernel.pbMessage(_INTL("It contained {1}.\1",item))
tmList << item if pbIsHiddenMachine?(item)
end
end
def getNewSpecies(oldSpecies, bst_range = 50, ignoreRivalPlaceholder = false, maxDexNumber = PBSpecies.maxValue, includeLegendaries=true)
oldSpecies_dex = dexNum(oldSpecies)
return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
newspecies_dex = rand(maxDexNumber - 1) + 1
i = 0
while bstNotOk(newspecies_dex, oldSpecies_dex, bst_range) || !(legendaryOk(oldSpecies_dex,newspecies_dex,includeLegendaries))
newspecies_dex = rand(maxDexNumber - 1) + 1
i += 1
if i % 10 == 0
bst_range += 5
end
end
return newspecies_dex
end
def getNewCustomSpecies(oldSpecies, customSpeciesList, bst_range = 50, ignoreRivalPlaceholder = false,includeLegendaries=true)
oldSpecies_dex = dexNum(oldSpecies)
return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
i = rand(customSpeciesList.length - 1) + 1
n = 0
newspecies_dex = customSpeciesList[i]
while bstNotOk(newspecies_dex, oldSpecies_dex, bst_range) || !(legendaryOk(oldSpecies_dex,newspecies_dex,includeLegendaries))
i = rand(customSpeciesList.length - 1) #+1
newspecies_dex = customSpeciesList[i]
n += 1
if n % 10 == 0
bst_range += 5
end
end
return newspecies_dex
end
def playShuffleSE(i)
if i % 40 == 0 || i == 0
pbSEPlay("Charm", 60)
end
end
def getTrainersDataMode
mode = GameData::Trainer
if $game_switches && $game_switches[SWITCH_MODERN_MODE]
mode = GameData::TrainerModern
elsif $game_switches && $game_switches[SWITCH_EXPERT_MODE]
mode = GameData::TrainerExpert
end
return mode
end
def Kernel.pbShuffleTrainers(bst_range = 50, customsOnly = false, customsList = nil)
bst_range = pbGet(VAR_RANDOMIZER_TRAINER_BST)
if customsOnly && customsList == nil
customsOnly = false
end
randomTrainersHash = Hash.new
trainers_data = GameData::Trainer.list_all
trainers_data.each do |key, value|
trainer = trainers_data[key]
i = 0
new_party = []
for poke in trainer.pokemon
old_poke = GameData::Species.get(poke[:species]).id_number
new_poke = customsOnly ? getNewCustomSpecies(old_poke, customsList, bst_range) : getNewSpecies(old_poke, bst_range)
new_party << new_poke
end
randomTrainersHash[trainer.id] = new_party
playShuffleSE(i)
i += 1
if i % 2 == 0
n = (i.to_f / trainers.length) * 100
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling trainers...\\n {1}%\\^", sprintf('%.2f', n), PBSpecies.maxValue))
end
end
$PokemonGlobal.randomTrainersHash = randomTrainersHash
end
# def Kernel.pbShuffleTrainers(bst_range = 50)
# randomTrainersHash = Hash.new
#
# trainers=load_data("Data/trainers.dat")
# i=0
# for trainer in trainers
# for poke in trainer[3]
# poke[TPSPECIES]=getNewSpecies(poke[TPSPECIES])
# end
# randomTrainersHash[i] = (trainer)
# playShuffleSE(i)
# i += 1
# if i % 2 == 0
# n = (i.to_f/trainers.length)*100
# Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling trainers...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
# end
# #Kernel.pbMessage(_INTL("pushing trainer {1}: {2} ",i,trainer))
# end
# $PokemonGlobal.randomTrainersHash = randomTrainersHash
# end
def Kernel.pbShuffleTrainersCustom(bst_range = 50)
randomTrainersHash = Hash.new
bst_range = pbGet(VAR_RANDOMIZER_TRAINER_BST)
Kernel.pbMessage(_INTL("Parsing custom sprites folder"))
customsList = getCustomSpeciesList(true, true)
Kernel.pbMessage(_INTL("{1} sprites found", customsList.length.to_s))
if customsList.length == 0
Kernel.pbMessage(_INTL("To use custom sprites, please place correctly named sprites in the /CustomBattlers folder. See readMe.txt for more information"))
Kernel.pbMessage(_INTL("Trainer Pokémon will include auto-generated sprites."))
return Kernel.pbShuffleTrainers(bst_range)
elsif customsList.length < 200
if Kernel.pbConfirmMessage(_INTL("Too few custom sprites were found. This will result in a very low Pokémon variety for trainers. Would you like to disable the Custom Sprites only option?"))
Kernel.pbMessage(_INTL("Trainer Pokémon will include auto-generated sprites."))
return Kernel.pbShuffleTrainers(bst_range) ##use regular shuffle if not enough sprites
end
if Kernel.pbConfirmMessage(_INTL("This will result in a very low Pokémon variety for trainers. Continue anyway?"))
bst_range = 999
else
Kernel.pbMessage(_INTL("Trainer Pokémon will include auto-generated sprites."))
return Kernel.pbShuffleTrainers(bst_range) ##use regular shuffle if not enough sprites
end
end
Kernel.pbShuffleTrainers(bst_range, true, customsList)
end
# trainers=load_data("Data/trainers.dat")
# i=0
# for trainer in trainers
# for poke in trainer[3]
# poke[TPSPECIES]=getNewCustomSpecies(poke[TPSPECIES],customsList)
# end
# randomTrainersHash[i] = (trainer)
# playShuffleSE(i)
# i += 1
# if i % 2 == 0
# n = (i.to_f/trainers.length)*100
# Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling trainers (custom sprites only)...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
# end
# #Kernel.pbMessage(_INTL("pushing trainer {1}: {2} ",i,trainer))
# end
# $PokemonGlobal.randomTrainersHash = randomTrainersHash
#def getRandomCustomSprite()
# filesList = Dir["./Graphics/CustomBattlers/*"]
# i = rand(filesList.length-1)
# path = filesList[i]
# file = File.basename(path, ".*")
# splitPoke = file.split(".")
# head = splitPoke[0].to_i
# body = splitPoke[1].to_i
# return (body*NB_POKEMON)+head
#end
def getCustomSpeciesList(allowOnline = true, redownload_file = false)
speciesList = []
for num in 1..NB_POKEMON
path = Settings::CUSTOM_BATTLERS_FOLDER_INDEXED + num.to_s + "/*"
filesList = Dir[path]
maxDexNumber = (NB_POKEMON * NB_POKEMON) + NB_POKEMON
maxVal = filesList.length - 1
for i in 0..maxVal
path = filesList[i]
file = File.basename(path, ".*")
fused = getDexNumFromFilename(file)
if fused && (fused <= maxDexNumber && fused > 0)
speciesList << fused
end
end
end
# if speciesList.length <= 20000 && allowOnline
# if redownload_file && Kernel.pbConfirmMessage(_INTL("Not enough local sprites found. Attempt to fetch list from the internet?"))
# updateOnlineCustomSpritesFile
# end
#try to get list from github
online_list = list_online_custom_sprites(true)
return speciesList if !online_list
species_id_list = []
for file in online_list
dexnum = getDexNumFromFilename(file)
species_id_list << dexnum if dexnum && dexnum <= maxDexNumber && dexnum > 0
end
return species_id_list
#end
return speciesList
end
def is_file_alt(file)
filename = file.split(".")[0]
return filename.match(/[a-zA-Z]/)
end
#input: ex: 10.10.png
def getDexNumFromFilename(filename)
begin
splitPoke = filename.split(".")
head = splitPoke[0].to_i
body = splitPoke[1].to_i
return nil if (body * NB_POKEMON) + head > (NB_POKEMON * NB_POKEMON) + NB_POKEMON
return (body * NB_POKEMON) + head
rescue
return nil
end
end
# def getCustomSpeciesList()
# filesList = Dir["./Graphics/CustomBattlers/*"]
# maxDexNumber = (NB_POKEMON * NB_POKEMON) + NB_POKEMON
# maxVal = filesList.length - 1
# for i in 0..maxVal
# path = filesList[i]
# file = File.basename(path, ".*")
# splitPoke = file.split(".")
# head = splitPoke[0].to_i
# body = splitPoke[1].to_i
# fused = (body * NB_POKEMON) + head
# if fused <= maxDexNumber && fused > 0
# speciesList << fused
# end
#
# end
# end
def Kernel.getBaseStats(species)
if $pkmn_dex[species] == nil
print species
end
basestatsum = $pkmn_dex[species][5][0] # HP
basestatsum += $pkmn_dex[species][5][1] # Attack
basestatsum += $pkmn_dex[species][5][2] # Defense
basestatsum += $pkmn_dex[species][5][3] # Speed
basestatsum += $pkmn_dex[species][5][4] # Special Attack
basestatsum += $pkmn_dex[species][5][5] # Special Defense
return basestatsum
end
def Kernel.gymLeaderRematchHint()
hints = [
"I heard that Brock has a huge interest in Pokémon fossils. He donated a lot of fossils he excavated to the Pewter City Museum.",
"Misty is a pro at swimming. I heard she trains every single morning.",
"Did you know that Lt. Surge used the magnetic fields generated by his Pokémon to navigate his plane back when he was in the army. He still loves a good magnetic field.",
"Erika is a lover of nature. She loves going to parks to relax during the day.",
"Koga has been seen leaving Fuschia city in the evenings. The rumors say he's preparing for a new job somewhere else...",
"People say that Sabrina never sleeps. I wonder where she goes when she leaves her gym at night.",
"The hot-headed Blaine is a man of extremes. He likes to explore around his hometown during the day.",
"Giovanni is a mysterious man. I wonder where he goes in the evening. Probably somewhere as remote as possible to meditate in peace...",
"I heard that Whitney went to school in one of the towns near Goldenrod before becoming a Gym Leader. She kept in touch with her old teacher and she goes to visit sometimes in the evening.",
"Kurt is always on the lookout for Bug-type Pokémon. He goes hunting early in the morning.",
"Falkner rises up early in the morning. You can usually find him in high places.",
"Clair is a member of a famous clan of dragon masters. She goes to a special place to pray at night.",
"Chuck is a martial arts pro. I've seen him train with Saffron City's dojo master back in the days.",
"Morty is a mysterious man. He's been known to be one of the few people who dare enter Pokémon Tower at night.",
"Pryce is an ice-type expert who has been around for a long time. He used to train in the Ice Tunnel between Mahogany Town and Blackthorn City before it froze over.",
"Jasmine is on vacation in the Sevii Islands. She likes to rise up early to explore around the islands when no one's around."
]
arr = []
n = 0
for i in 426..437
if !$game_switches[i]
arr.push(n)
end
n += 1
end
arr.push(508); arr.push(509); arr.push(510); arr.push(511);
n += 4
if arr.length > 0
return hints[arr[rand(arr.length)]]
end
return "You got every Gym Leader to come here. This place is more popular than ever!\nNow go and battle them!"
end
def getTrainerParty(trainer)
if $game_switches[47]
for poke in trainer[3]
inverseFusion(poke)
end
end
return trainer[3]
end
def inverseFusion(pokemon)
species = pokemon[TPSPECIES]
return pokemon if species <= CONST_NB_POKE
return pokemon if species > (CONST_NB_POKE * CONST_NB_POKE) + CONST_NB_POKE
body = getBasePokemonID(species, true)
head = getBasePokemonID(species, false)
newspecies = (head) * CONST_NB_POKE + body
pokemon[TPSPECIES] = newspecies
return pokemon
end
def addRandomHeldItems(trainerParty)
for poke in trainerParty
if poke.item == nil
poke.item = PBItems::ORANBERRY #PBItems.sample
end
end
end
def addHealingItem(items)
if $player.numbadges < 1
items << PBItems::ORANBERRY
elsif $player.numbadges <= 2
items << PBItems::POTION
elsif $player.numbadges <= 4
items << PBItems::SUPERPOTION
elsif $player.numbadges <= 6
items << PBItems::FULLHEAL
items << PBItems::SUPERPOTION
elsif $player.numbadges <= 8
items << PBItems::FULLHEAL
items << PBItems::HYPERPOTION
elsif $player.numbadges >= 9
items << PBItems::FULLRESTORE
end
return items
end
#####Overload de pbLoadTrainer
#
# def pbLoadTrainer(trainerid,trainername,partyid=0)
# if trainerid.is_a?(String) || trainerid.is_a?(Symbol)
# if !hasConst?(PBTrainers,trainerid)
# raise _INTL("Trainer type does not exist ({1}, {2}, ID {3})",trainerid,trainername,partyid)
# end
# trainerid=getID(PBTrainers,trainerid)
# end
# success=false
# items=[]
# party=[]
# opponent=nil
# trainers=load_data("Data/trainers.dat")
# trainerIndex=-1
#
# for trainer in trainers
# trainerIndex+=1
# name=trainer[1]
# thistrainerid=trainer[0]
# thispartyid=trainer[4]
# next if trainerid!=thistrainerid || name!=trainername || partyid!=thispartyid
# items=trainer[2].clone
#
# if $game_switches[666] #hard mode
# items = addHealingItem(items)
# end
#
#
# name=pbGetMessageFromHash(MessageTypes::TrainerNames,name)
# for i in RIVALNAMES
# if isConst?(trainerid,PBTrainers,i[0]) && $game_variables[i[1]]!=0
# name=$game_variables[i[1]]
# end
# end
# opponent=PokeBattle_Trainer.new(name,thistrainerid)
# opponent.setForeignID($player) if $player
#
#
# #use le random Array si randomized starters (et pas 1ere rival battle)
# isPlayingRandomized = $game_switches[987] && !$game_switches[46]
# if isPlayingRandomized && $PokemonGlobal.randomTrainersHash[trainerIndex] == nil
# Kernel.pbMessage(_INTL("The trainers need to be re-shuffled."))
# Kernel.pbShuffleTrainers()
# end
# trainerParty = isPlayingRandomized ? $PokemonGlobal.randomTrainersHash[trainerIndex][3] : getTrainerParty(trainer)
#
#
# isRematch = $game_switches[200]
# rematchId = getRematchId(trainername,trainerid)
# for poke in trainerParty
# ##
# species=poke[TPSPECIES]
# species = replaceRivalStarterIfNecessary(species)
#
#
# level= $game_switches[666] ? (poke[TPLEVEL]*1.1).ceil : poke[TPLEVEL]
#
# if isRematch
# nbRematch = getNumberRematch(rematchId)
# level = getRematchLevel(level,nbRematch)
# species = evolveRematchPokemon(nbRematch,species)
# end
#
# pokemon=PokeBattle_Pokemon.new(species,level,opponent)
# #pokemon.form=poke[TPFORM]
# pokemon.resetMoves
#
#
# pokemon.setItem( $game_switches[843] ? rand(PBItems.maxValue) : poke[TPITEM])
#
# if poke[TPMOVE1]>0 || poke[TPMOVE2]>0 || poke[TPMOVE3]>0 || poke[TPMOVE4]>0
# k=0
# for move in [TPMOVE1,TPMOVE2,TPMOVE3,TPMOVE4]
# pokemon.moves[k]=PBMove.new(poke[move])
# k+=1
# end
# pokemon.moves.compact!
# end
# pokemon.setAbility(poke[TPABILITY])
# pokemon.setGender(poke[TPGENDER])
# if poke[TPSHINY] # if this is a shiny Pokémon
# pokemon.makeShiny
# else
# pokemon.makeNotShiny
# end
# pokemon.setNature(poke[TPNATURE])
# iv=poke[TPIV]
# for i in 0...6
# pokemon.iv[i]=iv&0x1F
# pokemon.ev[i]=[85,level*3/2].min
# end
# pokemon.happiness=poke[TPHAPPINESS]
# pokemon.name=poke[TPNAME] if poke[TPNAME] && poke[TPNAME]!=""
# if poke[TPSHADOW] # if this is a Shadow Pokémon
# pokemon.makeShadow rescue nil
# pokemon.pbUpdateShadowMoves(true) rescue nil
# pokemon.makeNotShiny
# end
# pokemon.ballused=poke[TPBALL]
# pokemon.calcStats
# party.push(pokemon)
# end
# success=true
# break
# end
# return success ? [opponent,items,party] : nil
# end
def getRematchId(trainername, trainerid)
return trainername + trainerid.to_s
end
def replaceRivalStarterIfNecessary(species)
if species == RIVAL_STARTER_PLACEHOLDER_SPECIES
if !$game_switches[840] || pbGet(250) == 0 #not DEFINED_RIVAL_STARTER
fixRivalStarter()
end
rivalStarter = pbGet(250)
if rivalStarter > 0
species = pbGet(250)
end
end
return species
end
def fixRivalStarter()
#set starter baseform
if $PokemonGlobal.psuedoBSTHash == nil
psuedoHash = Hash.new
for i in 0..NB_POKEMON
psuedoHash[i] = i
end
$PokemonGlobal.psuedoBSTHash = psuedoHash
end
starterChoice = pbGet(7)
setRivalStarter(0, 1) if starterChoice == 2
setRivalStarter(0, 2) if starterChoice == 1
setRivalStarter(1, 2) if starterChoice == 0
setRivalStarter(0, 1) if starterChoice > 2
echoln pbGet(VAR_RIVAL_STARTER)
#evolve en fct des badges
rivalStarter = pbGet(VAR_RIVAL_STARTER)
if $game_switches[68] #beat blue cerulean
rivalStarter = evolveBody(rivalStarter)
end
if $game_switches[89] #beat blue SS Anne
rivalStarter = evolveHead(rivalStarter)
end
if $game_switches[228] #beat silph co
rivalStarter = evolveBody(rivalStarter)
end
if $game_switches[11] #got badge 8
rivalStarter = evolveHead(rivalStarter)
end
if $game_switches[12] #beat league
rivalStarter = evolveBody(rivalStarter)
rivalStarter = evolveHead(rivalStarter)
end
#RIVAL_STARTER_IS_DEFINED
pbSet(250, rivalStarter)
$game_switches[840] = true
end

View File

@@ -0,0 +1,366 @@
LEGENDARIES_LIST = [:ARTICUNO, :ZAPDOS, :MOLTRES, :MEWTWO, :MEW,
:ENTEI, :RAIKOU, :SUICUNE, :HOOH, :LUGIA, :CELEBI,
:GROUDON, :KYOGRE, :RAYQUAZA, :DEOXYS, :JIRACHI, :LATIAS, :LATIOS,
:REGIGIGAS, :DIALGA, :PALKIA, :GIRATINA, :DARKRAI, :CRESSELIA, :ARCEUS,
:GENESECT, :RESHIRAM, :ZEKROM, :KYUREM, :MELOETTA,
:NECROZMA]
class PokemonGlobalMetadata
attr_accessor :psuedoHash
attr_accessor :psuedoBSTHash
attr_accessor :randomTrainersHash
attr_accessor :randomGymTrainersHash
attr_accessor :randomItemsHash
attr_accessor :randomTMsHash
alias random_init initialize
def initialize
random_init
@randomGymTrainersHash = nil
@psuedoHash = nil
@psuedoBSTHash = nil
@randomItemsHash = nil
@randomTMsHash = nil
end
end
#pense pas que c'est utilisé mais bon...
def get_pokemon_list(include_fusions = false)
#Create array of all pokemon dex numbers
pokeArray = []
monLimit = include_fusions ? PBSpecies.maxValue : NB_POKEMON - 1
for i in 1..monLimit
pokeArray.push(i)
end
#randomize hash
return pokeArray
end
def get_randomized_bst_hash(poke_list, bst_range, show_progress = true)
bst_hash = Hash.new
for i in 1..NB_POKEMON - 1
show_shuffle_progress(i) if show_progress
baseStats = getBaseStatsFormattedForRandomizer(i)
statsTotal = getStatsTotal(baseStats)
targetStats_max = statsTotal + bst_range
targetStats_min = statsTotal - bst_range
max_bst_allowed = targetStats_max
min_bst_allowed = targetStats_min
#if a match, add to hash, remove from array, and cycle to next poke in dex
#only randomize legendaries to legendaries if Allow Legendaries not enabled
#
#
# if !$game_switches[SWITCH_RANDOM_WILD_LEGENDARIES]
# current_species = GameData::Species.get(i).id
# random_poke_species = GameData::Species.get(random_poke).id
# next if !legendaryOk(current_species,random_poke_species,$game_switches[SWITCH_RANDOM_WILD_LEGENDARIES])
#
# if !is_legendary(current_species)
# next if is_legendary(random_poke_species,true)
# else
# next if !is_legendary(random_poke_species,true)
# end
# end
playShuffleSE(i)
random_poke = poke_list.sample
random_poke_bst = getStatsTotal(getBaseStatsFormattedForRandomizer(random_poke))
j = 0
includeLegendaries = $game_switches[SWITCH_RANDOM_WILD_LEGENDARIES]
current_species = GameData::Species.get(i).id
random_poke_species = GameData::Species.get(random_poke).id
while (random_poke_bst <= min_bst_allowed || random_poke_bst >= max_bst_allowed) || !legendaryOk(current_species,random_poke_species,includeLegendaries)
random_poke = poke_list.sample
random_poke_species = GameData::Species.get(random_poke).id
#todo: right now, the main function uses dex numbers, but the legendaryOK check needs the ids.
# This can be a hit on performance to recalculate the ids from the dex numbers.
# The function should be optimized to just use the ids everywhere
random_poke_bst = getStatsTotal(getBaseStatsFormattedForRandomizer(random_poke))
j += 1
if j % 5 == 0 #to avoid infinite loops if can't find anything
min_bst_allowed -= 1
max_bst_allowed += 1
end
end
bst_hash[i] = random_poke
end
return bst_hash
end
def is_legendary(dex_num,printInfo=false)
pokemon_id = getPokemon(dex_num).id
is_legendary = is_fusion_of_any(pokemon_id,LEGENDARIES_LIST)
#echoln "#{pokemon_id} is legendary? : #{is_legendary}"
#echoln _INTL("{1} ({2}) {3}",dex_num,pokemon_id,is_legendary) if printInfo
return is_legendary
end
def show_shuffle_progress(i)
if i % 2 == 0
n = (i.to_f / NB_POKEMON) * 100
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling wild Pokémon...\\n {1}%\\^", sprintf('%.2f', n), NB_POKEMON))
end
end
##############
# randomizer shuffle
# ##############
def Kernel.pbShuffleDex(range = 50, type = 0)
$game_switches[SWITCH_RANDOMIZED_AT_LEAST_ONCE] = true
#type 0: BST
#type 1: full random
range = 1 if range == 0
should_include_fusions = $game_switches[SWITCH_RANDOM_WILD_TO_FUSION]
only_customs = $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] && should_include_fusions
# create hash
pokemon_list = only_customs ? getCustomSpeciesList(true) : get_pokemon_list(should_include_fusions)
if !pokemon_list #when not enough custom sprites
pokemon_list = get_pokemon_list(should_include_fusions)
end
$PokemonGlobal.psuedoBSTHash = get_randomized_bst_hash(pokemon_list, range, should_include_fusions)
end
def itemCanBeRandomized(item)
return false if item.is_machine?
return false if item.is_key_item?
return false if INVALID_ITEMS.include?(item.id)
return false if RANDOM_ITEM_EXCEPTIONS.include?(item.id)
return true
end
def pbShuffleItems()
randomItemsHash = Hash.new
available_items = []
for itemElement in GameData::Item.list_all
item = itemElement[1]
if itemCanBeRandomized(item)
if !available_items.include?(item.id)
available_items << item.id
end
end
end
remaining_items = available_items.clone
for itemId in available_items
if itemCanBeRandomized(GameData::Item.get(itemId))
chosenItem = remaining_items.sample
randomItemsHash[itemId] = chosenItem
remaining_items.delete(chosenItem)
end
end
$PokemonGlobal.randomItemsHash = randomItemsHash
end
def pbShuffleTMs()
randomItemsHash = Hash.new
available_items = []
for itemElement in GameData::Item.list_all
item = itemElement[1]
if item.is_TM?
if !available_items.include?(item.id)
available_items << item.id
end
end
end
remaining_items = available_items.clone
for itemId in available_items
if GameData::Item.get(itemId).is_TM?
chosenItem = remaining_items.sample
randomItemsHash[itemId] = chosenItem
remaining_items.delete(chosenItem)
end
end
$PokemonGlobal.randomTMsHash = randomItemsHash
end
#
# # ######
# # #on remet arceus a la fin
# # pokeArray.push(NB_POKEMON)
#
# # fill random hash
# #random hash will have to be accessed by number, not internal name
#
# #use pokeArrayRand to fill in the BST hash also
# #loop through the actual dex, and use the first mon in pokeArrayRand with
# #BST in the same 100 range
#
#
#
#
# for i in 1..NB_POKEMON-1
# baseStats=getBaseStatsFormattedForRandomizer(i)
# baseStat_target = 0
# for k in 0...baseStats.length
# baseStat_target+=baseStats[k]
# end
# baseStat_target = (baseStat_target+range).floor
# for j in 1...pokeArrayRand.length
# if $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] && $game_switches[SWITCH_RANDOM_WILD_TO_FUSION] && !customSpriteExists(pokeArrayRand[j])
# next
# end
# baseStats=getBaseStatsFormattedForRandomizer(pokeArrayRand[j])
# baseStat_temp = 0
# for l in 0...baseStats.length
# baseStat_temp+=baseStats[l]
# end
# baseStat_temp = (baseStat_temp+range).floor
#
#
# playShuffleSE(i)
#
# #if a match, add to hash, remove from array, and cycle to next poke in dex
# if (baseStat_temp == baseStat_target)
# psuedoBSTHash[i]=pokeArrayRand[j]
# pokeArrayRand.delete(pokeArrayRand[j])
# if i % 2 == 0 && type == 1
# n = (i.to_f/NB_POKEMON)*100
# Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling wild Pokémon...\\n {1}%\\^",sprintf('%.2f', n),NB_POKEMON))
# end
# break
# end
# end
# end
# psuedoBSTHash[NB_POKEMON] = NB_POKEMON
# #add hashes to global data
# $PokemonGlobal.psuedoHash = psuedoHash
# $PokemonGlobal.psuedoBSTHash = psuedoBSTHash
# end
def getStatsTotal(baseStats)
bst = 0
for k in 0...baseStats.length
bst += baseStats[k]
end
return bst
end
def isPartArceus(poke, type = 0)
return true if poke == NB_POKEMON
if type == 1
return true if getBasePokemonID(poke, true) == NB_POKEMON
return true if getBasePokemonID(poke, false) == NB_POKEMON
end
return false
end
#ajoute x happiness a tous les party member
def Kernel.raisePartyHappiness(increment)
return
# for poke in $player.party
# next if poke.isEgg?
# poke.happiness += increment
# end
end
#Randomizer code is shit. Too lazy to redo it.
# Here is a cheap workaround lol
def getBaseStatsFormattedForRandomizer(dex_num)
statsArray = []
stats = GameData::Species.get(dex_num).base_stats
statsArray << stats[:HP]
statsArray << stats[:ATTACK]
statsArray << stats[:DEFENSE]
statsArray << stats[:SPECIAL_ATTACK]
statsArray << stats[:SPECIAL_DEFENSE]
statsArray << stats[:SPEED]
return statsArray
end
# def Kernel.pbShuffleDexTrainers()
# # create hash
# psuedoHash = Hash.new
# psuedoBSTHash = Hash.new
#
# #Create array of all pokemon dex numbers
# pokeArray = []
# for i in 1..PBSpecies.maxValue
# pokeArray.push(i)
# end
# #randomize hash
# pokeArrayRand = pokeArray.dup
# pokeArrayRand.shuffle!
# pokeArray.insert(0,nil)
# # fill random hash
# #random hash will have to be accessed by number, not internal name
# for i in 1...pokeArrayRand.length
# psuedoHash[i]=pokeArrayRand[i]
# end
#
# #use pokeArrayRand to fill in the BST hash also
# #loop through the actual dex, and use the first mon in pokeArrayRand with
# #BST in the same 100 range
# for i in 1..PBSpecies.maxValue
# if i % 20 == 0
# n = (i.to_f/PBSpecies.maxValue)*100
# #Kernel.pbMessage(_INTL("\\ts[]Shuffling...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
# end
#
# baseStats=calcBaseStats(i)
# baseStat_target = 0
# for k in 0...baseStats.length
# baseStat_target+=baseStats[k]
# end
# baseStat_target = (baseStat_target/50).floor
# for j in 1...pokeArrayRand.length
# baseStats=calcBaseStats([pokeArrayRand[j]])
# baseStat_temp = 0
# for l in 0...baseStats.length
# baseStat_temp+=baseStats[l]
# end
# baseStat_temp = (baseStat_temp/50).floor
# #if a match, add to hash, remove from array, and cycle to next poke in dex
# if baseStat_temp == baseStat_target
# psuedoBSTHash[i]=pokeArrayRand[j]
# pokeArrayRand.delete(pokeArrayRand[j])
# break
# end
# end
# end
#
# #add hashes to global data0
# #$PokemonGlobal.psuedoHash = psuedoHash
# $PokemonGlobal.pseudoBSTHashTrainers = psuedoBSTHash
# end
def getRandomizedTo(species)
return species if !$PokemonGlobal.psuedoBSTHash
return $PokemonGlobal.psuedoBSTHash[dexNum(species)]
# code here
end
def tryRandomizeGiftPokemon(pokemon, dontRandomize = false)
if $game_switches[SWITCH_RANDOM_GIFT_POKEMON] && $game_switches[SWITCH_RANDOM_WILD] && !dontRandomize
oldSpecies = pokemon.is_a?(Pokemon) ? dexNum(pokemon) : dexNum(pokemon.species)
if $PokemonGlobal.psuedoBSTHash[oldSpecies]
pokemon.species = getSpecies($PokemonGlobal.psuedoBSTHash[oldSpecies])
end
end
end
def obtainRandomizedStarter(starterIndex)
case starterIndex
when 0
dexNumber =1
when 1
dexNumber = 4
else
dexNumber = 7
end
random_starter = $PokemonGlobal.psuedoBSTHash[dexNumber]
if $game_switches[SWITCH_RANDOM_STARTER_FIRST_STAGE]
species = GameData::Species.get(random_starter)
random_starter = GameData::Species.get(species.get_baby_species(false)).id_number
end
return random_starter
end

View File

@@ -0,0 +1,60 @@
module Game
class << self
alias_method :original_start_new, :start_new
def start_new
original_start_new
onLoadSaveFile
end
alias_method :original_load, :load
def load(save_data)
original_load(save_data)
onLoadSaveFile
end
def onLoadSaveFile
# Essentials 21 renamed the global variable $Trainer
# It's still used everywhere in events, global events so this makes things simpler
$Trainer = $player
$PokemonBag = $bag
migrateOldSavesToCharacterCustomization()
clear_all_images()
loadDateSpecificChanges()
end
end
end
def loadDateSpecificChanges()
current_date = Time.new
if (current_date.day == 1 && current_date.month == 4)
$Trainer.hat2=HAT_CLOWN if $Trainer.unlocked_hats.include?(HAT_CLOWN)
end
end
def migrateOldSavesToCharacterCustomization()
if !$Trainer.unlocked_clothes
$Trainer.unlocked_clothes = [DEFAULT_OUTFIT_MALE,
DEFAULT_OUTFIT_FEMALE,
STARTING_OUTFIT]
end
if !$Trainer.unlocked_hats
$Trainer.unlocked_hats = [DEFAULT_OUTFIT_MALE, DEFAULT_OUTFIT_FEMALE]
end
if !$Trainer.unlocked_hairstyles
$Trainer.unlocked_hairstyles = [DEFAULT_OUTFIT_MALE, DEFAULT_OUTFIT_FEMALE]
end
if !$Trainer.clothes || !$Trainer.hair #|| !$Trainer.hat
setupStartingOutfit()
end
end
def clear_all_images()
for i in 1..99
# echoln i.to_s + " : " + $game_screen.pictures[i].name
$game_screen.pictures[i].erase
end
end

View File

@@ -0,0 +1,51 @@
def Kernel.pbDisplayText(message,xposition,yposition,z=nil, baseColor=nil, shadowColor=nil)
if @hud==nil
@hud = []
end
# Draw the text
baseColor= baseColor ? baseColor : Color.new(72,72,72)
shadowColor= shadowColor ? shadowColor : Color.new(160,160,160)
sprite = BitmapSprite.new(Graphics.width,Graphics.height,@viewport1)
if z != nil
sprite.z=z
end
@hud.push(sprite)
text1=_INTL(message)
textPosition=[
[text1,xposition,yposition,2,baseColor,shadowColor],
]
pbSetSystemFont(@hud[-1].bitmap)
pbDrawTextPositions(@hud[0].bitmap,textPosition)
end
def Kernel.pbDisplayNumber(number,xposition,yposition)
@numT = []
# Draw the text
baseColor=Color.new(72,72,72)
shadowColor=Color.new(160,160,160)
@numT.push(BitmapSprite.new(Graphics.width,Graphics.height,@viewport1))
text1=_INTL(number.to_s)
textPosition=[
[text1,xposition,yposition,2,baseColor,shadowColor],
]
pbSetSystemFont(@numT[-1].bitmap)
pbDrawTextPositions(@numT[0].bitmap,textPosition)
end
def Kernel.pbClearNumber()
if @numT != nil then
for sprite in @numT
sprite.dispose
end
@numT.clear
end
end
def Kernel.pbClearText()
if @hud != nil then
for sprite in @hud
sprite.dispose
end
@hud.clear
end
end