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

@@ -45,8 +45,11 @@ module Kernel
end
def echoln(string)
echo string
echo "\n"
caller_info = caller(1..1).first
file, line, method = caller_info.split(":")
echo "#{file}, #{line}:\t"
echo(string)
echo("\r\n")
end
end

View File

@@ -35,6 +35,8 @@ module Game
# Called when starting a new game. Initializes global variables
# and transfers the player into the map scene.
def start_new
# Essentials 21 renamed the global variable $Trainer
# It's still used everywhere in events, global events so this makes things simpler
if $game_map&.events
$game_map.events.each_value { |event| event.clear_starting }
end
@@ -58,6 +60,11 @@ module Game
# @param save_data [Hash] hash containing the save data
# @raise [SaveData::InvalidValueError] if an invalid value is being loaded
def load(save_data)
# Essentials 21 renamed the global variable $Trainer
# It's still used everywhere in events, global events so this makes things simpler
$Trainer = $player
validate save_data => Hash
SaveData.load_all_values(save_data)
$game_temp.last_uptime_refreshed_play_time = System.uptime

View File

@@ -51,7 +51,7 @@ class Interpreter
when 134 then return command_134 # Change Save Access
when 135 then return command_135 # Change Menu Access
when 136 then return command_136 # Change Encounter
when 201 then return command_201 # Transfer Player
when 201 then return command_201 # Transfer Overrides
when 202 then return command_202 # Set Event Location
when 203 then return command_203 # Scroll Map
when 204 then return command_204 # Change Map Settings
@@ -731,7 +731,7 @@ class Interpreter
end
#-----------------------------------------------------------------------------
# * Transfer Player
# * Transfer Overrides
#-----------------------------------------------------------------------------
def command_201
return true if $game_temp.in_battle

View File

@@ -28,7 +28,7 @@ class Game_Temp
attr_accessor :force_single_battle # force next battle to be 1v1 flag
attr_accessor :waiting_trainer # [trainer, event ID] or nil
attr_accessor :last_battle_record # record of actions in last recorded battle
# Player transfers
# Overrides transfers
attr_accessor :player_transferring # player place movement flag
attr_accessor :player_new_map_id # player destination: map ID
attr_accessor :player_new_x # player destination: x-coordinate
@@ -67,7 +67,7 @@ class Game_Temp
# Battle
@battleback_name = ""
@force_single_battle = false
# Player transfers
# Overrides transfers
@player_transferring = false
@player_new_map_id = 0
@player_new_x = 0

View File

@@ -118,7 +118,7 @@ class Game_Player < Game_Character
def bump_into_object
return if @bump_time_start && (System.uptime - @bump_time_start < @move_time)
pbSEPlay("Player bump") if !@move_route_forcing
pbSEPlay("Overrides bump") if !@move_route_forcing
$stats.bump_count += 1
@bump_time_start = System.uptime
end
@@ -143,7 +143,7 @@ class Game_Player < Game_Character
# Jump over ledges
if pbFacingTerrainTag.ledge
if jumpForward(2)
pbSEPlay("Player jump")
pbSEPlay("Overrides jump")
increase_steps
end
return
@@ -389,7 +389,7 @@ class Game_Player < Game_Character
x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
$game_map.events.each_value do |event|
next if ![1, 2].include?(event.trigger) # Player touch, event touch
next if ![1, 2].include?(event.trigger) # Overrides touch, event touch
# If event coordinates and triggers are consistent
next if !event.at_coordinate?(@x + x_offset, @y + y_offset)
if event.name[/(?:sight|trainer)\((\d+)\)/i]

View File

@@ -111,6 +111,7 @@ class Sprite_Character < RPG::Sprite
@charbitmap = nil
@bushbitmap&.dispose
@bushbitmap = nil
if @tile_id >= 384
@charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id,
@character_hue, @character.width, @character.height)

View File

@@ -1466,7 +1466,7 @@ module Transitions
@rear_black_sprite.zoom_y = 2.0
@rear_black_sprite.opacity = 192
@rear_black_sprite.visible = false
# Player's bar sprite
# Overrides's bar sprite
@player_bar_x = -BAR_X_INDENT
@player_bar_start_x = @player_bar_x - (@bar_bitmap.width / 2)
@player_bar_y = BAR_Y_INDENT
@@ -1483,7 +1483,7 @@ module Transitions
@foe_bar_sprite.src_rect.x = @bar_bitmap.width / 2
@foe_bar_sprite.src_rect.width = @bar_bitmap.width / 2
@foe_bar_sprite.src_rect.height = BAR_HEIGHT
# Player sprite
# Overrides sprite
@player_sprite = new_sprite(@player_bar_sprite.x + TRAINER_X_OFFSET,
@player_bar_sprite.y + BAR_HEIGHT - TRAINER_Y_OFFSET,
@player_bitmap, @player_bitmap.width / 2, @player_bitmap.height)

View File

@@ -75,7 +75,7 @@ module GameData
def apply_metrics_to_sprite(sprite, index, shadow = false)
if shadow
sprite.x += @shadow_x * 2 if (index & 1) == 1 # Foe Pokémon
elsif (index & 1) == 0 # Player's Pokémon
elsif (index & 1) == 0 # Overrides's Pokémon
sprite.x += @back_sprite[0] * 2
sprite.y += @back_sprite[1] * 2
else # Foe Pokémon

View File

@@ -44,7 +44,7 @@ module GameData
["ID", ReadOnlyProperty, _INTL("ID of this Trainer Type (used as a symbol like :XXX).")],
["Name", StringProperty, _INTL("Name of this Trainer Type as displayed by the game.")],
["Gender", EnumProperty.new(gender_array), _INTL("Gender of this Trainer Type.")],
["BaseMoney", LimitProperty.new(9999), _INTL("Player earns this much money times the highest level among the trainer's Pokémon.")],
["BaseMoney", LimitProperty.new(9999), _INTL("Overrides earns this much money times the highest level among the trainer's Pokémon.")],
["SkillLevel", LimitProperty2.new(9999), _INTL("Skill level of this Trainer Type.")],
["PokeBall", ItemProperty, _INTL("Default Poké Ball that all Pokémon of trainers of this Trainer Type are in.")],
["Flags", StringListProperty, _INTL("Words/phrases that can be used to make trainers of this type behave differently to others.")],

View File

@@ -1,9 +1,9 @@
#===============================================================================
# Results of battle (see module Outcome):
# 0 - Undecided or aborted
# 1 - Player won
# 2 - Player lost
# 3 - Player or wild Pokémon ran from battle, or player forfeited the match
# 1 - Overrides won
# 2 - Overrides lost
# 3 - Overrides or wild Pokémon ran from battle, or player forfeited the match
# 4 - Wild Pokémon was caught
# 5 - Draw
# Possible actions a battler can take in a round:
@@ -43,7 +43,7 @@ class Battle
UNDECIDED = 0
WIN = 1
LOSE = 2 # Also used when player forfeits a trainer battle
FLEE = 3 # Player or wild Pokémon ran away, count as a win
FLEE = 3 # Overrides or wild Pokémon ran away, count as a win
CATCH = 4 # Counts as a win
DRAW = 5
@@ -75,7 +75,7 @@ class Battle
attr_accessor :environment # Battle surroundings (for mechanics purposes)
attr_reader :turnCount
attr_accessor :decision # Outcome of battle
attr_reader :player # Player trainer (or array of trainers)
attr_reader :player # Overrides trainer (or array of trainers)
attr_reader :opponent # Opponent trainer (or array of trainers)
attr_accessor :items # Items held by opponents
attr_accessor :ally_items # Items held by allies
@@ -127,7 +127,7 @@ class Battle
@scene = scene
@peer = Peer.new
@field = ActiveField.new # Whole field (gravity/rooms)
@sides = [ActiveSide.new, # Player's side
@sides = [ActiveSide.new, # Overrides's side
ActiveSide.new] # Foe's side
@positions = [] # Battler positions
@battlers = []
@@ -141,7 +141,7 @@ class Battle
@caughtPokemon = []
player = [player] if !player.nil? && !player.is_a?(Array)
opponent = [opponent] if !opponent.nil? && !opponent.is_a?(Array)
@player = player # Array of Player/NPCTrainer objects, or nil
@player = player # Array of Overrides/NPCTrainer objects, or nil
@opponent = opponent # Array of NPCTrainer objects, or nil
@items = nil
@ally_items = nil # Array of items held by ally. This is just used for Mega Evolution for now.
@@ -288,7 +288,7 @@ class Battle
idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler)
return @opponent[idxTrainer].full_name if opposes?(idxBattler) # Opponent
return @player[idxTrainer].full_name if idxTrainer > 0 # Ally trainer
return @player[idxTrainer].name # Player
return @player[idxTrainer].name # Overrides
end
def pbGetOwnerItems(idxBattler)

View File

@@ -65,7 +65,7 @@ class Battle
if !requireds[i] || requireds[i] == 0
case side
when 0
raise _INTL("Player-side trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
raise _INTL("Overrides-side trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i + 1, @sideSizes[0], @sideSizes[1])
when 1
raise _INTL("Opposing trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
@@ -74,7 +74,7 @@ class Battle
end
next if requireds[i] <= sideCounts[i] # Trainer has enough Pokémon to fill their positions
if requireds[i] == 1
raise _INTL("Player-side trainer {1} has no able Pokémon", i + 1) if side == 0
raise _INTL("Overrides-side trainer {1} has no able Pokémon", i + 1) if side == 0
raise _INTL("Opposing trainer {1} has no able Pokémon", i + 1) if side == 1
end
# Not enough Pokémon, try lowering the number of battler positions
@@ -393,7 +393,7 @@ class Battle
def pbLoseMoney
return if !@internalBattle || !@moneyGain
return if $game_switches[Settings::NO_MONEY_LOSS]
maxLevel = pbMaxLevelInTeam(0, 0) # Player's Pokémon only, not partner's
maxLevel = pbMaxLevelInTeam(0, 0) # Overrides's Pokémon only, not partner's
multiplier = [8, 16, 24, 36, 48, 64, 80, 100, 120]
idxMultiplier = [pbPlayer.badge_count, multiplier.length - 1].min
tMoney = maxLevel * multiplier[idxMultiplier]
@@ -417,7 +417,7 @@ class Battle
case oldDecision
when Outcome::WIN
PBDebug.log("")
PBDebug.log_header("===== Player won =====")
PBDebug.log_header("===== Overrides won =====")
PBDebug.log("")
if trainerBattle?
@scene.pbTrainerBattleSuccess
@@ -445,8 +445,8 @@ class Battle
@scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length > 0
when Outcome::LOSE, Outcome::DRAW
PBDebug.log("")
PBDebug.log_header("===== Player lost =====") if @decision == Outcome::LOSE
PBDebug.log_header("===== Player drew with opponent =====") if @decision == Outcome::DRAW
PBDebug.log_header("===== Overrides lost =====") if @decision == Outcome::LOSE
PBDebug.log_header("===== Overrides drew with opponent =====") if @decision == Outcome::DRAW
PBDebug.log("")
if @internalBattle
if pbPlayerBattlerCount == 0

View File

@@ -186,11 +186,11 @@ class Battle
end
pbRecallAndReplace(idxBattler, idxPartyNew)
switched.push(idxBattler)
elsif trainerBattle? # Player switches in in a trainer battle
elsif trainerBattle? # Overrides switches in in a trainer battle
idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses
pbRecallAndReplace(idxBattler, idxPlayerPartyNew)
switched.push(idxBattler)
else # Player's Pokémon has fainted in a wild battle
else # Overrides's Pokémon has fainted in a wild battle
switch = false
if pbDisplayConfirm(_INTL("Use next Pokémon?"))
switch = true

View File

@@ -194,7 +194,7 @@ class Battle
end
end
# Choose actions for the round (player first, then AI)
pbCommandPhaseLoop(true) # Player chooses their actions
pbCommandPhaseLoop(true) # Overrides chooses their actions
if decided? # Battle ended, stop choosing actions
@command_phase = false
return
@@ -223,7 +223,7 @@ class Battle
@battleAI.pbDefaultChooseEnemyCommand(idxBattler)
next
end
# Player chooses an action
# Overrides chooses an action
actioned.push(idxBattler)
commandsEnd = false # Whether to cancel choosing all other actions this round
loop do

View File

@@ -55,7 +55,7 @@ class Battle::Scene
partyBar = pbAddSprite("partyBar_#{side}", 0, 0,
"Graphics/UI/Battle/overlay_lineup", @viewport)
partyBar.z = 10120
partyBar.mirror = true if side == 0 # Player's lineup bar only
partyBar.mirror = true if side == 0 # Overrides's lineup bar only
partyBar.visible = false
NUM_BALLS.times do |i|
ball = pbAddSprite("partyBall_#{side}_#{i}", 0, 0, nil, @viewport)
@@ -67,7 +67,7 @@ class Battle::Scene
@sprites["abilityBar_#{side}"] = AbilitySplashBar.new(side, @viewport)
end
end
# Player's and partner trainer's back sprite
# Overrides's and partner trainer's back sprite
@battle.player.each_with_index do |p, i|
pbCreateTrainerBackSprite(i, p.trainer_type, @battle.player.length)
end
@@ -155,7 +155,7 @@ class Battle::Scene
end
def pbCreateTrainerBackSprite(idxTrainer, trainerType, numTrainers = 1)
if idxTrainer == 0 # Player's sprite
if idxTrainer == 0 # Overrides's sprite
trainerFile = GameData::TrainerType.player_back_sprite_filename(trainerType)
else # Partner trainer's sprite
trainerFile = GameData::TrainerType.back_sprite_filename(trainerType)

View File

@@ -17,7 +17,7 @@ class Battle::Scene::Animation::Intro < Battle::Scene::Animation
# Bases
makeSlideSprite("base_0", 1, appearTime, PictureOrigin::BOTTOM)
makeSlideSprite("base_1", -1, appearTime, PictureOrigin::CENTER)
# Player sprite, partner trainer sprite
# Overrides sprite, partner trainer sprite
@battle.player.each_with_index do |_p, i|
makeSlideSprite("player_#{i + 1}", 1, appearTime, PictureOrigin::BOTTOM)
end
@@ -96,7 +96,7 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
def resetGraphics(sprites)
bar = sprites["partyBar_#{@side}"]
case @side
when 0 # Player's lineup
when 0 # Overrides's lineup
barX = Graphics.width - BAR_DISPLAY_WIDTH
barY = Graphics.height - 142
ballX = barX + 44
@@ -124,7 +124,7 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
end
def getPartyIndexFromBallIndex(idxBall)
# Player's lineup (just show balls for player's party)
# Overrides's lineup (just show balls for player's party)
if @side == 0
return idxBall if @partyStarts.length < 2
return idxBall if idxBall < @partyStarts[1]

View File

@@ -201,7 +201,7 @@ class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation
# Show anger appearing
delay = ball.totalDuration + 5
2.times do
anger.setSE(delay, "Player jump")
anger.setSE(delay, "Overrides jump")
anger.setVisible(delay, true)
anger.moveZoom(delay, 3, 130)
anger.moveZoom(delay + 3, 3, 100)

View File

@@ -271,7 +271,7 @@ module RecordedBattle::PlaybackHelper
return nil if !trainer
ret = []
trainer.each do |tr|
if tr.length == 4 # Player
if tr.length == 4 # Overrides
t = Player.new(tr[1], tr[0])
t.badges = tr[3]
else # NPCTrainer

View File

@@ -566,7 +566,7 @@ def pbWait(duration)
end
#===============================================================================
# Player/event movement in the field.
# Overrides/event movement in the field.
#===============================================================================
def pbSlideOnIce
if !$DEBUG || !Input.press?(Input::CTRL)

View File

@@ -324,9 +324,9 @@ module BattleCreationHelperMethods
# Save the result of the battle in a Game Variable (1 by default)
# 0 - Undecided or aborted
# 1 - Player won
# 2 - Player lost
# 3 - Player or wild Pokémon ran from battle, or player forfeited the match
# 1 - Overrides won
# 2 - Overrides lost
# 3 - Overrides or wild Pokémon ran from battle, or player forfeited the match
# 4 - Wild Pokémon was caught
# 5 - Draw
def set_outcome(outcome, outcome_variable = 1, trainer_battle = false)

View File

@@ -11,7 +11,7 @@ class PokemonGlobalMetadata
attr_accessor :descending_waterfall
attr_accessor :ascending_waterfall
attr_accessor :fishing
# Player data
# Overrides data
attr_accessor :startTime
attr_accessor :stepcount
attr_accessor :pcItemStorage
@@ -64,7 +64,7 @@ class PokemonGlobalMetadata
@descending_waterfall = false
@ascending_waterfall = false
@fishing = false
# Player data
# Overrides data
@startTime = Time.now
@stepcount = 0
@pcItemStorage = nil

View File

@@ -116,7 +116,7 @@ class PokemonEntryScene
@sprites["helpwindow"].shadowColor = Color.new(168, 184, 184)
addBackgroundPlane(@sprites, "background", "Naming/bg_2", @viewport)
case subject
when 1 # Player
when 1 # Overrides
meta = GameData::PlayerMetadata.get($player.character_ID)
if meta
@sprites["shadow"] = IconSprite.new(0, 0, @viewport)
@@ -397,7 +397,7 @@ class PokemonEntryScene2
@sprites["bg"] = IconSprite.new(0, 0, @viewport)
@sprites["bg"].setBitmap("Graphics/UI/Naming/bg")
case subject
when 1 # Player
when 1 # Overrides
meta = GameData::PlayerMetadata.get($player.character_ID)
if meta
@sprites["shadow"] = IconSprite.new(0, 0, @viewport)

View File

@@ -115,7 +115,7 @@ class UI::TownMapVisuals < UI::BaseVisuals
create_pin(key, @pins_pos[key][0], @pins_pos[key][1], graphics_folder + roamer[:icon], 80)
end
end
# Player's head showing their current location
# Overrides's head showing their current location
if !@pins_pos[:player]
create_pin(:player, 0, 0, GameData::TrainerType.player_map_icon_filename($player.trainer_type), 100)
end
@@ -403,7 +403,7 @@ class UI::TownMapVisuals < UI::BaseVisuals
def update_pin_positions_while_zooming
@sprites[:cursor].x, @sprites[:cursor].y = point_to_screen(@cursor_pos[:x], @cursor_pos[:y])
# Player, roamers, markings
# Overrides, roamers, markings
@pins_pos.each_pair do |key, pos|
@sprites[key].x, @sprites[key].y = point_to_screen(*pos)
end

View File

@@ -15,7 +15,7 @@ class UI::TrainerCardVisuals < UI::BaseVisuals
def initialize_sprites
# Trainer card
add_icon_sprite(:card, 0, 0, graphics_folder + gendered_filename(_INTL("trainer_card")))
# Player sprite (coordinates are the bottom middle of the sprite)
# Overrides sprite (coordinates are the bottom middle of the sprite)
add_icon_sprite(:player, 400, 240, GameData::TrainerType.player_front_sprite_filename($player.trainer_type))
if !@sprites[:player].bitmap
raise _INTL("No trainer front sprite exists for the player character, expected a file at {1}.",

View File

@@ -146,7 +146,7 @@ class UI::LoadContinuePanel < UI::LoadPanel
filename = pbGetPlayerCharset(meta.walk_charset, @save_data[:player], true)
@sprites[:player] = TrainerWalkingCharSprite.new(filename, @viewport)
if !@sprites[:player].bitmap
raise _INTL("Player character {1}'s walking charset was not found (filename: \"{2}\").",
raise _INTL("Overrides character {1}'s walking charset was not found (filename: \"{2}\").",
@save_data[:player].character_ID, filename)
end
@sprites[:player].x = 48 - (@sprites[:player].bitmap.width / 8)
@@ -223,7 +223,7 @@ class UI::LoadContinuePanel < UI::LoadPanel
filename = pbGetPlayerCharset(meta.walk_charset, @save_data[:player], true)
@sprites[:player].charset = filename
if !@sprites[:player].bitmap
raise _INTL("Player character {1}'s walking charset was not found (filename: \"{2}\").",
raise _INTL("Overrides character {1}'s walking charset was not found (filename: \"{2}\").",
@save_data[:player].character_ID, filename)
end
end
@@ -255,7 +255,7 @@ class UI::LoadContinuePanel < UI::LoadPanel
elsif @save_data[:player].female?
gender_theme = :female
end
# Player's name
# Overrides's name
draw_text(@save_data[:player].name, 78, 66, theme: gender_theme)
# Location
map_id = @save_data[:map_factory].map.map_id

View File

@@ -48,7 +48,7 @@ class UI::SavePanel < UI::SpriteContainer
filename = pbGetPlayerCharset(meta.walk_charset, @save_data[:player], true)
@sprites[:player] = TrainerWalkingCharSprite.new(filename, @viewport)
if !@sprites[:player].bitmap
raise _INTL("Player character {1}'s walking charset was not found (filename: \"{2}\").",
raise _INTL("Overrides character {1}'s walking charset was not found (filename: \"{2}\").",
@save_data[:player].character_ID, filename)
end
@sprites[:player].x = 44 - (@sprites[:player].bitmap.width / 8)
@@ -130,7 +130,7 @@ class UI::SavePanel < UI::SpriteContainer
filename = pbGetPlayerCharset(meta.walk_charset, @save_data[:player], true)
@sprites[:player].charset = filename
if !@sprites[:player].bitmap
raise _INTL("Player character {1}'s walking charset was not found (filename: \"{2}\").",
raise _INTL("Overrides character {1}'s walking charset was not found (filename: \"{2}\").",
@save_data[:player].character_ID, filename)
end
end
@@ -165,7 +165,7 @@ class UI::SavePanel < UI::SpriteContainer
elsif @save_data[:player].female?
gender_theme = :female
end
# Player's name
# Overrides's name
draw_text(@save_data[:player].name, 78, 30, theme: gender_theme)
# Location
map_id = @save_data[:map_factory].map.map_id

View File

@@ -171,7 +171,7 @@ class PokemonLoad_Scene
filename = pbGetPlayerCharset(meta.walk_charset, trainer, true)
@sprites["player"] = TrainerWalkingCharSprite.new(filename, @viewport)
if !@sprites["player"].bitmap
raise _INTL("Player character {1}'s walking charset was not found (filename: \"{2}\").", trainer.character_ID, filename)
raise _INTL("Overrides character {1}'s walking charset was not found (filename: \"{2}\").", trainer.character_ID, filename)
end
charwidth = @sprites["player"].bitmap.width
charheight = @sprites["player"].bitmap.height

View File

@@ -29,7 +29,7 @@ class PokemonSave_Scene
end
location_tag = shadowc3tag(LOCATION_TEXT_BASE, LOCATION_TEXT_SHADOW)
loctext = location_tag + "<ac>" + mapname + "</ac></c3>"
loctext += _INTL("Player") + "<r>" + text_tag + $player.name + "</c3><br>"
loctext += _INTL("Overrides") + "<r>" + text_tag + $player.name + "</c3><br>"
if hour > 0
loctext += _INTL("Time") + "<r>" + text_tag + _INTL("{1}h {2}m", hour, min) + "</c3><br>"
else

View File

@@ -249,7 +249,7 @@ class PokemonDuel
pbMoveRoute(event, [PBMoveRoute::FORWARD])
pbMoveRoute($game_player, [PBMoveRoute::FORWARD])
@hp[0] -= action # Enemy action
@hp[1] -= command # Player command
@hp[1] -= command # Overrides command
pbMessage(_INTL("You hit each other!"))
elsif action == 2 && command == 0
pbMoveRoute(event,

View File

@@ -107,7 +107,7 @@ class TriadCard
bitmap = Bitmap.new(80, 96)
if owner == 2 # Opponent
cardbitmap = AnimatedBitmap.new("Graphics/UI/Triple Triad/card_opponent")
else # Player
else # Overrides
cardbitmap = AnimatedBitmap.new("Graphics/UI/Triple Triad/card_player")
end
typebitmap = AnimatedBitmap.new(_INTL("Graphics/UI/types"))
@@ -811,7 +811,7 @@ class TriadScreen
triadCard = nil
cardIndex = 0
if playerTurn
# Player's turn
# Overrides's turn
until position
cardIndex = @scene.pbPlayerChooseCard(cards.length)
triadCard = TriadCard.new(cards[cardIndex])

View File

@@ -146,8 +146,8 @@ def pbSafariBattle(pkmn, level = 1)
end
# Save the result of the battle in Game Variable 1
# 0 - Undecided or aborted
# 2 - Player ran out of Safari Balls
# 3 - Player or wild Pokémon ran from battle, or player forfeited the match
# 2 - Overrides ran out of Safari Balls
# 3 - Overrides or wild Pokémon ran from battle, or player forfeited the match
# 4 - Wild Pokémon was caught
if outcome == Battle::Outcome::CATCH
$stats.safari_pokemon_caught += 1

View File

@@ -222,7 +222,7 @@ def pbNoticePlayer(event, always_show_exclaim = false)
end
#===============================================================================
# Player-related utilities, random name generator.
# Overrides-related utilities, random name generator.
#===============================================================================
# Unused
def pbGetPlayerGraphic

View File

@@ -77,7 +77,7 @@ def pbPlayTrainerIntroBGM(trainer_type)
pbBGMPlay(bgm)
end
# Can be a Player, NPCTrainer or an array of them.
# Can be a Overrides, NPCTrainer or an array of them.
def pbGetTrainerBattleBGM(trainer)
return $PokemonGlobal.nextBattleBGM.clone if $PokemonGlobal.nextBattleBGM
ret = nil
@@ -120,7 +120,7 @@ def pbGetTrainerBattleBGMFromType(trainertype)
return ret
end
# Can be a Player, NPCTrainer or an array of them.
# Can be a Overrides, NPCTrainer or an array of them.
def pbGetTrainerVictoryBGM(trainer)
if $PokemonGlobal.nextBattleVictoryBGM
return $PokemonGlobal.nextBattleVictoryBGM.clone

View File

@@ -753,7 +753,7 @@ def pbEditPlayerMetadata(player_id = 1)
val = property[1].defaultValue if val.nil? && property[1].respond_to?(:defaultValue)
data.push(val)
end
if pbPropertyList(_INTL("Player {1}", metadata.id), data, properties, true)
if pbPropertyList(_INTL("Overrides {1}", metadata.id), data, properties, true)
# Construct player metadata hash
schema = GameData::PlayerMetadata.schema
metadata_hash = {}

View File

@@ -21,7 +21,7 @@ def pbAutoPositionAll
metrics = GameData::SpeciesMetrics.get_species_form(sp.species, sp.form)
bitmap1 = GameData::Species.sprite_bitmap(sp.species, sp.form, nil, nil, nil, true)
bitmap2 = GameData::Species.sprite_bitmap(sp.species, sp.form)
if bitmap1&.bitmap # Player's y
if bitmap1&.bitmap # Overrides's y
metrics.back_sprite[0] = 0
metrics.back_sprite[1] = (bitmap1.height - (findBottom(bitmap1.bitmap) + 1)) / 2
end

View File

@@ -842,11 +842,11 @@ MenuHandlers.add(:debug_menu, :empty_bag, {
})
#===============================================================================
# Player options.
# Overrides options.
#===============================================================================
MenuHandlers.add(:debug_menu, :player_menu, {
"name" => _INTL("Player options..."),
"name" => _INTL("Overrides options..."),
"parent" => :main,
"description" => _INTL("Set money, badges, Pokédexes, player's appearance and name, etc."),
"always_show" => false
@@ -1114,7 +1114,7 @@ MenuHandlers.add(:debug_menu, :change_outfit, {
params.setRange(0, 99)
params.setDefaultValue(oldoutfit)
$player.outfit = pbMessageChooseNumber(_INTL("Set the player's outfit."), params)
pbMessage(_INTL("Player's outfit was changed.")) if $player.outfit != oldoutfit
pbMessage(_INTL("Overrides's outfit was changed.")) if $player.outfit != oldoutfit
}
})

View File

@@ -9,7 +9,7 @@ MenuHandlers.add(:battle_debug_menu, :battlers, {
})
MenuHandlers.add(:battle_debug_menu, :list_player_battlers, {
"name" => _INTL("Player-side battlers"),
"name" => _INTL("Overrides-side battlers"),
"parent" => :battlers,
"description" => _INTL("Edit Pokémon on the player's side of battle."),
"effect" => proc { |battle|
@@ -103,7 +103,7 @@ MenuHandlers.add(:battle_debug_menu, :pokemon_teams, {
first_index = player_party_starts[i]
last_index = (i < player_party_starts.length - 1) ? player_party_starts[i + 1] : battle.pbParty(0).length
num_pkmn = last_index - first_index
if i == 0 # Player
if i == 0 # Overrides
commands.push(_INTL("You: {1} ({2} Pokémon)", trainer.full_name, num_pkmn))
else
commands.push(_INTL("Ally {1}: {2} ({3} Pokémon)", i, trainer.full_name, num_pkmn))
@@ -162,7 +162,7 @@ MenuHandlers.add(:battle_debug_menu, :trainer_items, {
end
if battle.player.length > 1
battle.player.each_with_index do |trainer, i|
next if i == 0 # Player
next if i == 0 # Overrides
items = battle.ally_items ? battle.ally_items[i].clone : []
commands.push(_INTL("Ally {1}: {2} ({3} items)", i, trainer.full_name, items.length))
item_arrays.push(items)
@@ -436,7 +436,7 @@ MenuHandlers.add(:battle_debug_menu, :set_field_effects, {
})
MenuHandlers.add(:battle_debug_menu, :player_side, {
"name" => _INTL("Player's side effects..."),
"name" => _INTL("Overrides's side effects..."),
"parent" => :field,
"description" => _INTL("Effects that apply to the side the player is on."),
"effect" => proc { |battle|

View File

@@ -920,7 +920,7 @@ MenuHandlers.add(:pokemon_debug_menu, :ownership, {
gender_text = _INTL("Male") if pkmn.owner.male?
gender_text = _INTL("Female") if pkmn.owner.female?
public_id_text = sprintf("%05d", pkmn.owner.public_id)
msg = [_INTL("Player's Pokémon\n{1}\n{2}\n{3} ({4})",
msg = [_INTL("Overrides's Pokémon\n{1}\n{2}\n{3} ({4})",
pkmn.owner.name, gender_text, public_id_text, pkmn.owner.id),
_INTL("Foreign Pokémon\n{1}\n{2}\n{3} ({4})",
pkmn.owner.name, gender_text, public_id_text, pkmn.owner.id)][pkmn.foreign?($player) ? 1 : 0]

View File

@@ -269,7 +269,7 @@ class MetadataLister
def commands
@commands.clear
@commands.push(_INTL("[GLOBAL METADATA]"))
@player_ids.each { |id| @commands.push(_INTL("Player {1}", id)) }
@player_ids.each { |id| @commands.push(_INTL("Overrides {1}", id)) }
@commands.push(_INTL("[ADD NEW PLAYER]")) if @new_player
return @commands
end
@@ -277,7 +277,7 @@ class MetadataLister
# Cancel: -1
# New player: -2
# Global metadata: 0
# Player character: 1+ (the player ID itself)
# Overrides character: 1+ (the player ID itself)
def value(index)
return index if index < 1
return -2 if @new_player && index == @commands.length - 1

View File

@@ -1344,7 +1344,7 @@ module Compiler
else
validate_compiled_player_metadata(data_hash)
if GameData::PlayerMetadata.exists?(data_hash[:id])
raise _INTL("Player metadata ID '{1}' is used twice.", data_hash[:id]) + "\n" + FileLineData.linereport
raise _INTL("Overrides metadata ID '{1}' is used twice.", data_hash[:id]) + "\n" + FileLineData.linereport
end
end
# Add section's data to records

View File

@@ -880,12 +880,12 @@ module Compiler
changed = true
end
# If the last page's Switch condition uses a Switch named 's:tsOff?("A")',
# check the penultimate page. If it contains exactly 1 "Transfer Player"
# check the penultimate page. If it contains exactly 1 "Transfer Overrides"
# command and does NOT contain a "Change Transparent Flag" command, rewrite
# both the penultimate page and the last page.
if mapData.switchName(lastPage.condition.switch1_id) == 's:tsOff?("A")'
list = event.pages[event.pages.length - 2].list
transferCommand = list.find_all { |cmd| cmd.code == 201 } # Transfer Player
transferCommand = list.find_all { |cmd| cmd.code == 201 } # Transfer Overrides
if transferCommand.length == 1 && list.none? { |cmd| cmd.code == 208 } # Change Transparent Flag
# Rewrite penultimate page
list.clear
@@ -913,7 +913,7 @@ module Compiler
push_event(list, 223, [Tone.new(-255, -255, -255), 6]) # Change Screen Color Tone
push_wait(list, 8) # Wait
push_event(list, 208, [1]) # Change Transparent Flag (visible)
push_event(list, transferCommand[0].code, transferCommand[0].parameters) # Transfer Player
push_event(list, transferCommand[0].code, transferCommand[0].parameters) # Transfer Overrides
push_event(list, 223, [Tone.new(0, 0, 0), 6]) # Change Screen Color Tone
push_end(list)
# Rewrite last page
@@ -957,7 +957,7 @@ module Compiler
end
# Checks if the event has exactly 1 page, said page has no graphic, it has
# less than 12 commands and at least one is a Transfer Player, and the tiles
# less than 12 commands and at least one is a Transfer Overrides, and the tiles
# to the left/right/upper left/upper right are not passable but the event's
# tile is. Causes a second page to be added to the event which is the "is
# player on me?" check that occurs when the map is entered.
@@ -966,7 +966,7 @@ module Compiler
return false if thisEvent.pages.length != 1
if thisEvent.pages[0].graphic.character_name == "" &&
thisEvent.pages[0].list.length <= 12 &&
thisEvent.pages[0].list.any? { |cmd| cmd.code == 201 } && # Transfer Player
thisEvent.pages[0].list.any? { |cmd| cmd.code == 201 } && # Transfer Overrides
# mapData.isPassable?(mapID, thisEvent.x, thisEvent.y + 1) &&
mapData.isPassable?(mapID, thisEvent.x, thisEvent.y) &&
!mapData.isPassable?(mapID, thisEvent.x - 1, thisEvent.y) &&
@@ -1272,12 +1272,12 @@ module Compiler
list.delete_at(i)
changed = true
end
when 201 # Transfer Player
when 201 # Transfer Overrides
if list.length <= 8
=begin
if params[0]==0
# Look for another event just above the position this Transfer
# Player command will transfer to - it may be a door, in which case
# Overrides command will transfer to - it may be a door, in which case
# this command should transfer the player onto the door instead of
# in front of it.
e = mapData.getEventFromXY(params[1],params[2],params[3]-1)
@@ -1295,7 +1295,7 @@ module Compiler
mapData.saveMap(params[1])
changed = true
end
# Checks if the found event is a simple Transfer Player one nestled
# Checks if the found event is a simple Transfer Overrides one nestled
# between tiles that aren't passable - it is likely a door, so give
# it a second page with an "is player on me?" check.
if likely_passage?(e,params[1],mapData) # Checks the first page
@@ -1339,30 +1339,30 @@ module Compiler
# If the next event command is a Move Route that moves the player,
# check whether all it does is turn the player in a direction (or
# its first item is to move the player in a direction). If so, this
# Transfer Player command may as well set the player's direction
# Transfer Overrides command may as well set the player's direction
# instead; make it do so and delete that Move Route.
if params[4]==0 && # Retain direction
i+1<list.length && list[i+1].code==209 && list[i+1].parameters[0]==-1 # Set Move Route
route = list[i+1].parameters[1]
if route && route.list.length<=2
# Delete superfluous move route command if necessary
if route.list[0].code==16 # Player Turn Down
if route.list[0].code==16 # Overrides Turn Down
deleteMoveRouteAt.call(list,i+1)
params[4] = 2
changed = true
elsif route.list[0].code==17 # Player Turn Left
elsif route.list[0].code==17 # Overrides Turn Left
deleteMoveRouteAt.call(list,i+1)
params[4] = 4
changed = true
elsif route.list[0].code==18 # Player Turn Right
elsif route.list[0].code==18 # Overrides Turn Right
deleteMoveRouteAt.call(list,i+1)
params[4] = 6
changed = true
elsif route.list[0].code==19 # Player Turn Up
elsif route.list[0].code==19 # Overrides Turn Up
deleteMoveRouteAt.call(list,i+1)
params[4] = 8
changed = true
elsif (route.list[0].code==1 || route.list[0].code==2 || # Player Move (4-dir)
elsif (route.list[0].code==1 || route.list[0].code==2 || # Overrides Move (4-dir)
route.list[0].code==3 || route.list[0].code==4) && list.length==4
params[4] = [0,2,4,6,8][route.list[0].code]
deletedRoute = deleteMoveRouteAt.call(list,i+1)
@@ -1370,10 +1370,10 @@ module Compiler
end
end
# If an event command before this one is a Move Route that just
# turns the player, delete it and make this Transfer Player command
# turns the player, delete it and make this Transfer Overrides command
# set the player's direction instead.
# (I don't know if it makes sense to do this, as there could be a
# lot of commands between then and this Transfer Player which this
# lot of commands between then and this Transfer Overrides which this
# code can't recognise and deal with, so I've quoted this code out.)
elsif params[4]==0 && i>3 # Retain direction
# for j in 0...i
@@ -1382,22 +1382,22 @@ module Compiler
# if route && route.list.length<=2
# oldlistlength = list.length
# # Delete superfluous move route command if necessary
# if route.list[0].code==16 # Player Turn Down
# if route.list[0].code==16 # Overrides Turn Down
# deleteMoveRouteAt.call(list,j)
# params[4] = 2
# changed = true
# i -= (oldlistlength-list.length)
# elsif route.list[0].code==17 # Player Turn Left
# elsif route.list[0].code==17 # Overrides Turn Left
# deleteMoveRouteAt.call(list,j)
# params[4] = 4
# changed = true
# i -= (oldlistlength-list.length)
# elsif route.list[0].code==18 # Player Turn Right
# elsif route.list[0].code==18 # Overrides Turn Right
# deleteMoveRouteAt.call(list,j)
# params[4] = 6
# changed = true
# i -= (oldlistlength-list.length)
# elsif route.list[0].code==19 # Player Turn Up
# elsif route.list[0].code==19 # Overrides Turn Up
# deleteMoveRouteAt.call(list,j)
# params[4] = 8
# changed = true
@@ -1408,7 +1408,7 @@ module Compiler
# end
# If the next event command changes the screen color, and the one
# after that is a Move Route which only turns the player in a
# direction, this Transfer Player command may as well set the
# direction, this Transfer Overrides command may as well set the
# player's direction instead; make it do so and delete that Move
# Route.
elsif params[4]==0 && # Retain direction
@@ -1419,19 +1419,19 @@ module Compiler
route = list[i+2].parameters[1]
if route && route.list.length<=2
# Delete superfluous move route command if necessary
if route.list[0].code==16 # Player Turn Down
if route.list[0].code==16 # Overrides Turn Down
deleteMoveRouteAt.call(list,i+2)
params[4] = 2
changed = true
elsif route.list[0].code==17 # Player Turn Left
elsif route.list[0].code==17 # Overrides Turn Left
deleteMoveRouteAt.call(list,i+2)
params[4] = 4
changed = true
elsif route.list[0].code==18 # Player Turn Right
elsif route.list[0].code==18 # Overrides Turn Right
deleteMoveRouteAt.call(list,i+2)
params[4] = 6
changed = true
elsif route.list[0].code==19 # Player Turn Up
elsif route.list[0].code==19 # Overrides Turn Up
deleteMoveRouteAt.call(list,i+2)
params[4] = 8
changed = true

View File

@@ -9,7 +9,7 @@ class AnimationEditor
else
@settings = {
:color_scheme => :light,
:side_sizes => [1, 1], # Player's side, opposing side
:side_sizes => [1, 1], # Overrides's side, opposing side
:user_index => 0, # 0, 2, 4
:target_indices => [1], # There must be at least one valid target
:user_opposes => false,

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