mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-10 14:44:58 +00:00
update 6.7
This commit is contained in:
232
Data/Scripts/052_InfiniteFusion/Gameplay/Battles/BattleLounge.rb
Normal file
232
Data/Scripts/052_InfiniteFusion/Gameplay/Battles/BattleLounge.rb
Normal file
@@ -0,0 +1,232 @@
|
||||
def get_opponent_level
|
||||
return $Trainer.highest_level_pokemon_in_party
|
||||
end
|
||||
|
||||
def get_egg_group_from_id(id)
|
||||
case id
|
||||
when 0;
|
||||
return nil
|
||||
when 1;
|
||||
return :Monster
|
||||
when 2;
|
||||
return :Water1
|
||||
when 3;
|
||||
return :Bug
|
||||
when 4;
|
||||
return :Flying
|
||||
when 5;
|
||||
return :Field
|
||||
when 6;
|
||||
return :Fairy
|
||||
when 7;
|
||||
return :Grass
|
||||
when 8;
|
||||
return :Humanlike
|
||||
when 9;
|
||||
return :Water3
|
||||
when 10;
|
||||
return :Mineral
|
||||
when 11;
|
||||
return :Amorphous
|
||||
when 12;
|
||||
return :Water2
|
||||
when 13;
|
||||
return :Ditto
|
||||
when 14;
|
||||
return :Dragon
|
||||
when 15;
|
||||
return :Undiscovered
|
||||
end
|
||||
end
|
||||
|
||||
def get_egg_group_name(id)
|
||||
case id
|
||||
when 0;
|
||||
return nil
|
||||
when 1;
|
||||
return "Monster Pokémon"
|
||||
when 2;
|
||||
return :"Aquatic Pokémon"
|
||||
when 3;
|
||||
return :"Bug Pokémon"
|
||||
when 4;
|
||||
return :"Bird Pokémon"
|
||||
when 5;
|
||||
return :"Land Pokémon"
|
||||
when 6;
|
||||
return :"Cute Pokémon"
|
||||
when 7;
|
||||
return :"Plant Pokémon"
|
||||
when 8;
|
||||
return :"Human-like Pokémon"
|
||||
when 9;
|
||||
return :"Aquatic Pokémon"
|
||||
when 10;
|
||||
return :"Mineral Pokémon"
|
||||
when 11;
|
||||
return :"Blob Pokémon"
|
||||
when 12;
|
||||
return :"Fish Pokémon"
|
||||
when 13;
|
||||
return :"Ditto"
|
||||
when 14;
|
||||
return :"Dragon Pokémon"
|
||||
when 15;
|
||||
return :"Legendary Pokémon"
|
||||
end
|
||||
end
|
||||
|
||||
def get_random_trainer_name(trainer_class)
|
||||
#0: male, 1: female
|
||||
gender = GameData::TrainerType.get(trainer_class).gender
|
||||
if (gender == 0)
|
||||
return RandTrainerNames_male[rand(RandTrainerNames_male.length)]
|
||||
else
|
||||
return RandTrainerNames_female[rand(RandTrainerNames_female.length)]
|
||||
end
|
||||
end
|
||||
|
||||
def get_random_battle_lounge_egg_group
|
||||
_DISABLED_EGG_GROUPS = [0, 13, 15]
|
||||
group = 0
|
||||
while _DISABLED_EGG_GROUPS.include?(group)
|
||||
group = rand(0, 15)
|
||||
end
|
||||
return group
|
||||
end
|
||||
|
||||
GENERIC_PRIZES_MULTI = [:HEARTSCALE, :HEARTSCALE,:HEARTSCALE,:HEARTSCALE,:HEARTSCALE,
|
||||
:LEMONADE, :PERFECTBALL, :TRADEBALL,
|
||||
:GENDERBALL, :ABILITYBALL, :VIRUSBALL, :SHINYBALL]
|
||||
GENERIC_PRIZES_SINGLE = [:RARECANDY, :RARECANDY,:RARECANDY, :PPUP, :EJECTBUTTON, :FOCUSBAND, :FOCUSSASH,
|
||||
:RESETURGE, :ABILITYURGE, :ITEMURGE, :ITEMDROP, :HPUP, :INCUBATOR, :LUCKYEGG]
|
||||
MONSTER_PRIZES = [:RAREBONE, :LAGGINGTAIL, :RAZORFANG, :RAZORCLAW, :GRIPCLAW, :MANKEYPAW]
|
||||
WATER_PRIZES = [:MYSTICWATER, :BIGPEARL, :SHELLBELL]
|
||||
BUG_PRIZES = [:SILVERPOWDER, :SHEDSHELL, :EVIOLITE]
|
||||
FLYING_PRIZES = [:AIRBALLOON, :FLOATSTONE, :COMETSHARD]
|
||||
FIELD_PRIZES = [:MOOMOOMILK, :IRONBALL, :RAREBONE, :MANKEYPAW, :FLAMEORB]
|
||||
FAIRY_PRIZES = [:STARPIECE, :DESTINYKNOT, :MAXELIXIR, :LIFEORB]
|
||||
HUMAN_PRIZES = [:BLACKBELT, :RINGTARGET, :EXPERTBELT, :GOLDRING, :AMULETCOIN]
|
||||
GRASS_PRIZES = [:REVIVALHERB, :POWERHERB, :HEALPOWDER, :ABSORBBULB, :BIGMUSHROOM]
|
||||
MINERAL_PRIZES = [:CELLBATTERY, :SHINYSTONE, :BIGNUGGET, :RELICCOPPER, :RELICGOLD, :RELICSILVER, :DIAMOND, :ROCKYHELMET]
|
||||
AMORPHOUS_PRIZES = [:SPELLTAG, :WIDELENS, :ZOOMLENS, :SCOPELENS, :TOXICORB]
|
||||
DRAGON_PRIZES = [:DRAGONSCALE, :DRAGONFANG, :RARECANDY, :GOLDRING]
|
||||
UNDISCOVERED_PRIZES = [:MASTERBALL, :SACREDASH]
|
||||
#todo: prizes related to the group (ex: dragon fang for dragon types, TMs, etc. )
|
||||
# todo: if heartscale, give a random amount from 10-20
|
||||
def get_random_battle_lounge_prize(group_type)
|
||||
generic_prizes = [GENERIC_PRIZES_MULTI, GENERIC_PRIZES_SINGLE]
|
||||
is_generic_prize = rand(3) == 1
|
||||
if is_generic_prize
|
||||
type = generic_prizes.sample
|
||||
return type.sample
|
||||
else
|
||||
case get_egg_group_from_id(group_type)
|
||||
when :Monster;
|
||||
return MONSTER_PRIZES.sample
|
||||
when :Water1, :Water2, :Water3;
|
||||
return WATER_PRIZES.sample
|
||||
when :Bug;
|
||||
return BUG_PRIZES.sample
|
||||
when :Flying;
|
||||
return FLYING_PRIZES.sample
|
||||
when :Field;
|
||||
return FIELD_PRIZES.sample
|
||||
when :Fairy;
|
||||
return FAIRY_PRIZES.sample
|
||||
when :Grass;
|
||||
return GRASS_PRIZES.sample
|
||||
when :Mineral;
|
||||
return MINERAL_PRIZES.sample
|
||||
when :Humanlike;
|
||||
return HUMAN_PRIZES.sample
|
||||
when :Amorphous;
|
||||
return AMORPHOUS_PRIZES.sample
|
||||
when :Dragon;
|
||||
return DRAGON_PRIZES.sample
|
||||
when :Undiscovered;
|
||||
return UNDISCOVERED_PRIZES.sample
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def generateSameEggGroupFusionsTeam(eggGroup_id)
|
||||
eggGroup = get_egg_group_from_id(eggGroup_id)
|
||||
teamComplete = false
|
||||
generatedTeam = []
|
||||
while !teamComplete
|
||||
foundFusionPartner = false
|
||||
species1 = rand(Settings::NB_POKEMON) + 1
|
||||
if getPokemonEggGroups(species1).include?(eggGroup)
|
||||
foundFusionPartner = false
|
||||
while !foundFusionPartner
|
||||
species2 = rand(Settings::NB_POKEMON) + 1
|
||||
if getPokemonEggGroups(species2).include?(eggGroup)
|
||||
generatedTeam << getFusionSpeciesSymbol(species1, species2)
|
||||
foundFusionPartner = true
|
||||
end
|
||||
end
|
||||
end
|
||||
teamComplete = generatedTeam.length == 3
|
||||
end
|
||||
return generatedTeam
|
||||
end
|
||||
|
||||
def listLegendaryPokemonIds()
|
||||
return [144, 145, 146, 150, 151, 245, 243, 244, 245, 249, 250, 251, 315, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 378, 379, 380, 381]
|
||||
end
|
||||
|
||||
def pokemonIsPartLegendary(species)
|
||||
head = getBasePokemonID(species, false)
|
||||
body = getBasePokemonID(species, true)
|
||||
return listLegendaryPokemonIds().include?(head) || listLegendaryPokemonIds().include?(body)
|
||||
end
|
||||
|
||||
|
||||
def generateRandomFusionFromPokemon(dexNum, onlyCustomSprites = false, allowLegendaries=true)
|
||||
excluded = allowLegendaries ? [] : listLegendaryPokemonIds()
|
||||
customsList = getCustomSpeciesList(downloadAllowed?())
|
||||
i=0
|
||||
while i < customsList.length
|
||||
comparedPoke = customsList.sample
|
||||
next if excluded.include?(comparedPoke)
|
||||
if Kernel.isPartPokemon(comparedPoke, dexNum)
|
||||
return comparedPoke
|
||||
end
|
||||
i+=1
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
def getRandomBasePokemon(includeLegendaries = false,maxNb=NB_POKEMON)
|
||||
legendaries =listLegendaryPokemonIds()
|
||||
poke = rand(maxNb + 1)
|
||||
return poke if includeLegendaries
|
||||
while legendaries.include?(poke)
|
||||
poke = rand(maxNb + 1)
|
||||
end
|
||||
return poke
|
||||
end
|
||||
|
||||
def getAllPokemonWithBase(dexNum)
|
||||
#todo Unimplemented
|
||||
return [25]
|
||||
end
|
||||
|
||||
def getCustomSpeciesListForPokemon(dexNum,allowLegendaries=true)
|
||||
excluded = allowLegendaries ? [] : listLegendaryPokemonIds()
|
||||
customsList = getCustomSpeciesList(downloadAllowed?())
|
||||
speciesList = []
|
||||
for comparedPoke in customsList
|
||||
next if excluded.include?(comparedPoke)
|
||||
if Kernel.isPartPokemon(comparedPoke, dexNum)
|
||||
speciesList << comparedPoke
|
||||
end
|
||||
|
||||
end
|
||||
if speciesList.length == 0
|
||||
speciesList << dexNum
|
||||
end
|
||||
return speciesList
|
||||
end
|
||||
@@ -0,0 +1,232 @@
|
||||
# # ------------------------------------------------------------------------------
|
||||
# # Written by Stochastic, except for customTrainerBattle method which is a
|
||||
# # modified version of pbTrainerBattle method.
|
||||
# # ------------------------------------------------------------------------------
|
||||
#
|
||||
# BR_DRAW = 5
|
||||
# BR_LOSS = 2
|
||||
# BR_WIN = 1
|
||||
#
|
||||
# # ------------------------------------------------------------------------------
|
||||
# # species - Name of the species, e.g. "PIKACHU"
|
||||
# # level - Level
|
||||
# # moveset - Optional. Array of moves, e.g. [:MUDSLAP, :THUNDERBOLT, :VINEWHIP]
|
||||
# # If not specified, pokemon will be created with moves learned by leveling.
|
||||
# # The pokemon doesn't need to be able to learn the given moves, they can be
|
||||
# # arbitary.
|
||||
# # ------------------------------------------------------------------------------
|
||||
# def createPokemon(species, level, helditem=nil, moveset=nil, ability=nil, form=nil, nature=nil, hpev=nil, atkev=nil, defev=nil, speev=nil, spaev=nil, spdev=nil)
|
||||
# begin
|
||||
# poke = Pokemon.new(species, level)
|
||||
# poke.item=(helditem) if helditem
|
||||
# poke.moves = convertMoves(moveset) if moveset
|
||||
# poke.ability=(ability) if ability
|
||||
# poke.form = form if form
|
||||
# poke.shiny = false
|
||||
# poke.nature =(nature) if nature
|
||||
# poke.happiness=0
|
||||
# poke.iv[0]=hpev
|
||||
# poke.iv[1]=atkev
|
||||
# poke.iv[2]=defev
|
||||
# poke.iv[3]=speev
|
||||
# poke.iv[4]=spaev
|
||||
# poke.iv[5]=spdev
|
||||
#
|
||||
# poke.calc_stats
|
||||
# return poke
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def convertMoves(moves)
|
||||
# moves.map! {|m| PBMove.new(getMoveID(m))}
|
||||
# return moves
|
||||
# end
|
||||
#
|
||||
# # provide move like this; :TACKLE
|
||||
# def getMoveID(move)
|
||||
# return getConst(PBMoves,move)
|
||||
# end
|
||||
#
|
||||
# # ------------------------------------------------------------------------------
|
||||
# # Creates a trainer with specified id, name, party, and optionally, items.
|
||||
# # Does not depend on defined trainers, only on trainer types
|
||||
# # ------------------------------------------------------------------------------
|
||||
# def createTrainer(trainerid,trainername,party,items=[])
|
||||
#
|
||||
# name = pbGetMessageFromHash(MessageTypes::TrainerNames, trainername)
|
||||
#
|
||||
# trainer_hash = {
|
||||
# :id_number => 999,
|
||||
# :trainer_type => trainerid,
|
||||
# :name => name,
|
||||
# :version => 0,
|
||||
# :pokemon => party,
|
||||
# :items => items
|
||||
# }
|
||||
# opponent = GameData::Trainer.new(trainer_hash)
|
||||
# #opponent.setForeignID($Trainer) if $Trainer
|
||||
# # opponent.party = party
|
||||
# return [opponent.to_trainer,items,party]
|
||||
# end
|
||||
#
|
||||
# def init_trainer(trainer_data)
|
||||
# return (trainer_data) ? trainer_data.to_trainer : nil
|
||||
# end
|
||||
#
|
||||
# # ------------------------------------------------------------------------------
|
||||
# # Initiates trainer battle. This is a modified pbTrainerBattle method.
|
||||
# #
|
||||
# # trainer - custom PokeBattle_Trainer provided by the user
|
||||
# # endspeech - what the trainer says in-battle when defeated
|
||||
# # doublebattle - Optional. Set it to true if you want a double battle
|
||||
# # canlose - Optional. Set it to true if you want your party to be healed after battle,and if you don't want to be sent to a pokemon center if you lose
|
||||
# # ------------------------------------------------------------------------------
|
||||
#
|
||||
# def customTrainerBattle(trainer,endSpeech,doubleBattle=false,canLose=false,outcomeVar=1)
|
||||
# # If there is another NPC trainer who spotted the player at the same time, and
|
||||
# # it is possible to have a double battle (the player has 2+ able Pokémon or
|
||||
# # has a partner trainer), then record this first NPC trainer into
|
||||
# # $PokemonTemp.waitingTrainer and end this method. That second NPC event will
|
||||
# # then trigger and cause the battle to happen against this first trainer and
|
||||
# # themselves.
|
||||
# if !$PokemonTemp.waitingTrainer && pbMapInterpreterRunning? &&
|
||||
# ($Trainer.able_pokemon_count > 1 ||
|
||||
# ($Trainer.able_pokemon_count > 0 && $PokemonGlobal.partner))
|
||||
# thisEvent = pbMapInterpreter.get_character(0)
|
||||
# # Find all other triggered trainer events
|
||||
# triggeredEvents = $game_player.pbTriggeredTrainerEvents([2],false)
|
||||
# otherEvent = []
|
||||
# for i in triggeredEvents
|
||||
# next if i.id==thisEvent.id
|
||||
# next if $game_self_switches[[$game_map.map_id,i.id,"A"]]
|
||||
# otherEvent.push(i)
|
||||
# end
|
||||
# return false if !trainer
|
||||
# Events.onTrainerPartyLoad.trigger(nil,trainer)
|
||||
# # If there is exactly 1 other triggered trainer event, and this trainer has
|
||||
# # 6 or fewer Pokémon, record this trainer for a double battle caused by the
|
||||
# # other triggered trainer event
|
||||
# if otherEvent.length == 1 && trainer.party.length <= Settings::MAX_PARTY_SIZE
|
||||
# trainer.lose_text = endSpeech if endSpeech && !endSpeech.empty?
|
||||
# $PokemonTemp.waitingTrainer = [trainer, thisEvent.id]
|
||||
# return false
|
||||
# end
|
||||
# end
|
||||
# # Set some battle rules
|
||||
# setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1
|
||||
# setBattleRule("canLose") if canLose
|
||||
# setBattleRule("double") if doubleBattle || $PokemonTemp.waitingTrainer
|
||||
# # Perform the battle
|
||||
# if $PokemonTemp.waitingTrainer
|
||||
# decision = pbTrainerBattleCore($PokemonTemp.waitingTrainer[0],
|
||||
# [trainer[0].trainer_type,trainer[0].name,endSpeech]
|
||||
# )
|
||||
# else
|
||||
# decision = pbTrainerCustomBattleCore(trainer,[trainer[0].trainer_type,trainer[0].name,endSpeech]) #trainerPartyID
|
||||
# end
|
||||
# # Finish off the recorded waiting trainer, because they have now been battled
|
||||
# if decision==1 && $PokemonTemp.waitingTrainer # Win
|
||||
# pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[1], "A", true)
|
||||
# end
|
||||
# $PokemonTemp.waitingTrainer = nil
|
||||
# # Return true if the player won the battle, and false if any other result
|
||||
# return (decision==1)
|
||||
# end
|
||||
#
|
||||
#
|
||||
# def pbTrainerCustomBattleCore(trainer,*args)
|
||||
# outcomeVar = $PokemonTemp.battleRules["outcomeVar"] || 1
|
||||
# canLose = $PokemonTemp.battleRules["canLose"] || false
|
||||
# # Skip battle if the player has no able Pokémon, or if holding Ctrl in Debug mode
|
||||
# if $Trainer.able_pokemon_count == 0 || ($DEBUG && Input.press?(Input::CTRL))
|
||||
# pbMessage("SKIPPING BATTLE...") if $DEBUG
|
||||
# pbMessage("AFTER WINNING...") if $DEBUG && $Trainer.able_pokemon_count > 0
|
||||
# pbSet(outcomeVar,($Trainer.able_pokemon_count == 0) ? 0 : 1) # Treat it as undecided/a win
|
||||
# $PokemonTemp.clearBattleRules
|
||||
# $PokemonGlobal.nextBattleBGM = nil
|
||||
# $PokemonGlobal.nextBattleME = nil
|
||||
# $PokemonGlobal.nextBattleCaptureME = nil
|
||||
# $PokemonGlobal.nextBattleBack = nil
|
||||
# pbMEStop
|
||||
# return ($Trainer.able_pokemon_count == 0) ? 0 : 1 # Treat it as undecided/a win
|
||||
# end
|
||||
# # Record information about party Pokémon to be used at the end of battle (e.g.
|
||||
# # comparing levels for an evolution check)
|
||||
# Events.onStartBattle.trigger(nil)
|
||||
# # Generate trainers and their parties based on the arguments given
|
||||
# foeTrainers = []
|
||||
# foeItems = []
|
||||
# foeEndSpeeches = []
|
||||
# foeParty = []
|
||||
# foePartyStarts = []
|
||||
# for arg in args
|
||||
# if arg.is_a?(NPCTrainer)
|
||||
# foeTrainers.push(arg)
|
||||
# foePartyStarts.push(foeParty.length)
|
||||
# arg.party.each { |pkmn| foeParty.push(pkmn) }
|
||||
# foeEndSpeeches.push(arg.lose_text)
|
||||
# foeItems.push(arg.items)
|
||||
# elsif arg.is_a?(Array) # [trainer type, trainer name, ID, speech (optional)]
|
||||
# pbMissingTrainer(arg[0],arg[1],arg[2]) if !trainer
|
||||
# return 0 if !trainer
|
||||
# Events.onTrainerPartyLoad.trigger(nil,trainer)
|
||||
# foeTrainers.push(trainer)
|
||||
# foePartyStarts.push(foeParty.length)
|
||||
# trainer.party.each { |pkmn| foeParty.push(pkmn) }
|
||||
# foeEndSpeeches.push(arg[3] || trainer.lose_text)
|
||||
# foeItems.push(trainer.items)
|
||||
# else
|
||||
# raise "Expected NPCTrainer or array of trainer data, got {1}.", arg
|
||||
# end
|
||||
# end
|
||||
# # Calculate who the player trainer(s) and their party are
|
||||
# playerTrainers = [$Trainer]
|
||||
# playerParty = $Trainer.party
|
||||
# playerPartyStarts = [0]
|
||||
# room_for_partner = (foeParty.length > 1)
|
||||
# if !room_for_partner && $PokemonTemp.battleRules["size"] &&
|
||||
# !["single", "1v1", "1v2", "1v3"].include?($PokemonTemp.battleRules["size"])
|
||||
# room_for_partner = true
|
||||
# end
|
||||
# if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && room_for_partner
|
||||
# ally = NPCTrainer.new($PokemonGlobal.partner[1], $PokemonGlobal.partner[0])
|
||||
# ally.id = $PokemonGlobal.partner[2]
|
||||
# ally.party = $PokemonGlobal.partner[3]
|
||||
# playerTrainers.push(ally)
|
||||
# playerParty = []
|
||||
# $Trainer.party.each { |pkmn| playerParty.push(pkmn) }
|
||||
# playerPartyStarts.push(playerParty.length)
|
||||
# ally.party.each { |pkmn| playerParty.push(pkmn) }
|
||||
# setBattleRule("double") if !$PokemonTemp.battleRules["size"]
|
||||
# end
|
||||
# # Create the battle scene (the visual side of it)
|
||||
# scene = pbNewBattleScene
|
||||
# # Create the battle class (the mechanics side of it)
|
||||
# battle = PokeBattle_Battle.new(scene,playerParty,foeParty,playerTrainers,foeTrainers)
|
||||
# battle.party1starts = playerPartyStarts
|
||||
# battle.party2starts = foePartyStarts
|
||||
# battle.items = foeItems
|
||||
# battle.endSpeeches = foeEndSpeeches
|
||||
# # Set various other properties in the battle class
|
||||
# pbPrepareBattle(battle)
|
||||
# $PokemonTemp.clearBattleRules
|
||||
# # End the trainer intro music
|
||||
# Audio.me_stop
|
||||
# # Perform the battle itself
|
||||
# decision = 0
|
||||
# pbBattleAnimation(pbGetTrainerBattleBGM(foeTrainers),(battle.singleBattle?) ? 1 : 3,foeTrainers) {
|
||||
# pbSceneStandby {
|
||||
# decision = battle.pbStartBattle
|
||||
# }
|
||||
# pbAfterBattle(decision,canLose)
|
||||
# }
|
||||
# Input.update
|
||||
# # 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
|
||||
# # 5 - Draw
|
||||
# pbSet(outcomeVar,decision)
|
||||
# return decision
|
||||
# end
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
def pick_trainer_sprite(spriter_name)
|
||||
possible_types = "abcd"
|
||||
trainer_type_index = select_number_from_seed(spriter_name,0,3)
|
||||
path = _INTL("Graphics/Trainers/trainer116{1}",possible_types[trainer_type_index].to_s)
|
||||
return path
|
||||
end
|
||||
|
||||
def select_number_from_seed(seed, min_value, max_value)
|
||||
hash = 137
|
||||
seed.each_byte do |byte|
|
||||
hash = ((hash << 5) + hash) + byte
|
||||
end
|
||||
srand(hash)
|
||||
selected_number = rand(min_value..max_value)
|
||||
selected_number
|
||||
end
|
||||
|
||||
def pick_spriter_losing_dialog(spriter_name)
|
||||
possible_dialogs = [
|
||||
_INTL("Oh... I lost..."),
|
||||
_INTL("I did my best!"),
|
||||
_INTL("You're too strong!"),
|
||||
_INTL("You win!"),
|
||||
_INTL("What a fight!"),
|
||||
_INTL("That was fun!"),
|
||||
_INTL("Ohh, that's too bad"),
|
||||
_INTL("I should've sprited some stronger Pokémon!"),
|
||||
_INTL("So much for that!"),
|
||||
_INTL("Should've seen that coming!"),
|
||||
_INTL("I can't believe it!"),
|
||||
_INTL("What a surprise!")
|
||||
]
|
||||
index = select_number_from_seed(spriter_name,0,possible_dialogs.size-1)
|
||||
return possible_dialogs[index]
|
||||
end
|
||||
@@ -0,0 +1,300 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
class RematchTrainer
|
||||
attr_reader :id
|
||||
attr_reader :nbTimesRematched
|
||||
|
||||
def initialize(id)
|
||||
@id = id
|
||||
@nbTimesRematched = 0
|
||||
end
|
||||
|
||||
def incrementNbTimes()
|
||||
@nbTimesRematched += 1
|
||||
end
|
||||
|
||||
def removeNbTimes()
|
||||
@nbTimesRematched -= 1
|
||||
end
|
||||
end
|
||||
|
||||
#Methods called from elsewhere in the code
|
||||
#
|
||||
# called from pbEndOfBattle
|
||||
#
|
||||
def incrNbRematches(trainerId)
|
||||
$PokemonGlobal.rematchedTrainers.each do |key, trainer|
|
||||
if (trainer.id == trainerId)
|
||||
trainer.incrementNbTimes()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# called from Trainer.to_trainer
|
||||
def getNumberRematch(trainerId)
|
||||
if $PokemonGlobal.rematchedTrainers == nil
|
||||
$PokemonGlobal.rematchedTrainers = Hash.new
|
||||
addNewTrainerRematch(trainerId)
|
||||
end
|
||||
trainer = $PokemonGlobal.rematchedTrainers[trainerId.to_sym]
|
||||
if trainer == nil
|
||||
addNewTrainerRematch(trainerId)
|
||||
return 0
|
||||
end
|
||||
return (trainer.nbTimesRematched)
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
# #garder un list de cette classe en mem. globale
|
||||
#
|
||||
# #quand lance un combat: check si le switch pour rematch est actif.
|
||||
# #si oui, check dans l'array globale si on trouve le trainer id.
|
||||
# #si oui on maj, si non on l'ajoute
|
||||
#
|
||||
# #overload la classe qui lance les combats et ajuste les niveaux
|
||||
# #selon le nb. de fois rematched
|
||||
#
|
||||
#
|
||||
# # levelCap = originalLevel + (nbBadges*2) +2
|
||||
#
|
||||
# # on incremente le level a chaque x (jusqu'au levelcap)
|
||||
# # nb = (level/10).ceil
|
||||
#
|
||||
#
|
||||
def addNewTrainerRematch(trainerId)
|
||||
#$PokemonGlobal.rematchedTrainers[:trainerId]
|
||||
newTrainer = RematchTrainer.new(trainerId)
|
||||
$PokemonGlobal.rematchedTrainers[trainerId.to_sym] = newTrainer
|
||||
|
||||
end
|
||||
|
||||
def getNumberRematchOld(trainerId)
|
||||
if $PokemonGlobal.rematchedTrainers == nil
|
||||
$PokemonGlobal.rematchedTrainers = Hash.new
|
||||
addNewTrainerRematch(trainerId)
|
||||
end
|
||||
|
||||
$PokemonGlobal.rematchedTrainers.each do |key, trainer|
|
||||
if (trainer.id == trainerId)
|
||||
return (trainer.nbTimesRematched)
|
||||
end
|
||||
end
|
||||
addNewTrainerRematch(trainerId)
|
||||
return 0
|
||||
end
|
||||
|
||||
def getRematchLevel(originalLevel, nbRematch)
|
||||
levelCap = getLevelCap(originalLevel, $Trainer.numbadges)
|
||||
expRate = getLevelRate(originalLevel)
|
||||
levelIncr = 0
|
||||
for i in 0..nbRematch
|
||||
if i % expRate == 0
|
||||
levelIncr += 1
|
||||
end
|
||||
end
|
||||
newLevel = originalLevel + levelIncr
|
||||
#printDebugRematchInfo(nbRematch,expRate,newLevel,levelCap,originalLevel)
|
||||
return (newLevel < levelCap) ? newLevel : levelCap
|
||||
end
|
||||
|
||||
def getLevelRate(originalLevel)
|
||||
return 2 + (originalLevel / 20).ceil
|
||||
end
|
||||
|
||||
def getLevelCap(originalLevel, nbBadges)
|
||||
return 100 if $game_switches[599] #no cap in battle arena
|
||||
cap = originalLevel + nbBadges + 2
|
||||
return cap < 100 ? cap : 100
|
||||
end
|
||||
|
||||
def decreaseRematchNumber(trainerId)
|
||||
$PokemonGlobal.rematchedTrainers.each do |key, trainer|
|
||||
if (trainer.id == trainerId)
|
||||
trainer.removeNbTimes()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# def evolveRematchPokemon(nbRematch, speciesSymbol)
|
||||
# species = getDexNumberForSpecies(speciesSymbol)
|
||||
# if (nbRematch >= 10 && $Trainer.numbadges >= 3)
|
||||
# evospecies = getEvolution(species)
|
||||
# return species if evospecies == -1
|
||||
# if (nbRematch >= 20 && $Trainer.numbadges >= 8)
|
||||
# secondEvoSpecies = getEvolution(evospecies)
|
||||
# return secondEvoSpecies == -1 ? evospecies : secondEvoSpecies
|
||||
# end
|
||||
# return evospecies
|
||||
# end
|
||||
# return species
|
||||
# end
|
||||
def evolveRematchPokemon(nbRematch, speciesSymbol)
|
||||
species = getDexNumberForSpecies(speciesSymbol)
|
||||
if (nbRematch >= 30 && $Trainer.numbadges >= 6)
|
||||
species = getEvolution(species,:HEAD)
|
||||
species = getEvolution(species,:BODY)
|
||||
species = getEvolution(species,:HEAD)
|
||||
species = getEvolution(species,:BODY)
|
||||
elsif (nbRematch >= 20 && $Trainer.numbadges >= 3)
|
||||
species = getEvolution(species,:HEAD)
|
||||
species = getEvolution(species,:BODY)
|
||||
species = getEvolution(species,:HEAD)
|
||||
elsif (nbRematch >= 10 && $Trainer.numbadges >= 3)
|
||||
species = getEvolution(species,:HEAD)
|
||||
species = getEvolution(species,:BODY)
|
||||
elsif (nbRematch >= 5)
|
||||
species = getEvolution(species,:HEAD)
|
||||
end
|
||||
return species
|
||||
end
|
||||
|
||||
|
||||
def getEvolution(speciesParam, halfToEvolve=nil)
|
||||
species = dexNum(speciesParam)
|
||||
begin
|
||||
prioritizeHead = halfToEvolve == :HEAD
|
||||
prioritizeBody = halfToEvolve == :BODY
|
||||
|
||||
if species >= Settings::NB_POKEMON
|
||||
body = getBasePokemonID(species)
|
||||
head = getBasePokemonID(species, false)
|
||||
|
||||
bodyPossibleEvolutions = GameData::Species.get(body).get_evolutions(true)
|
||||
headPossibleEvolutions = GameData::Species.get(head).get_evolutions(true)
|
||||
|
||||
bodyCanEvolve = !bodyPossibleEvolutions.empty?
|
||||
headCanEvolve = !headPossibleEvolutions.empty?
|
||||
|
||||
evoBodySpecies = bodyCanEvolve ? bodyPossibleEvolutions[rand(bodyPossibleEvolutions.length - 1)][0] : nil
|
||||
evoHeadSpecies = headCanEvolve ? headPossibleEvolutions[rand(headPossibleEvolutions.length - 1)][0] : nil
|
||||
if evoBodySpecies != nil
|
||||
evoBody = getDexNumberForSpecies(evoBodySpecies)
|
||||
end
|
||||
if evoHeadSpecies != nil
|
||||
evoHead = getDexNumberForSpecies(evoHeadSpecies)
|
||||
end
|
||||
|
||||
return species if evoBody == nil && evoHead == nil
|
||||
if prioritizeBody
|
||||
if evoBody == nil
|
||||
return body * Settings::NB_POKEMON + evoHead #only head evolves
|
||||
else
|
||||
return evoBody * Settings::NB_POKEMON + head #only body evolves
|
||||
end
|
||||
end
|
||||
|
||||
if prioritizeHead
|
||||
if evoHead == nil
|
||||
return evoBody * Settings::NB_POKEMON + head #only body evolves
|
||||
else
|
||||
return body * Settings::NB_POKEMON + evoHead #only head evolves
|
||||
end
|
||||
end
|
||||
|
||||
return body * Settings::NB_POKEMON + evoHead if evoBody == nil #only head evolves
|
||||
return evoBody * Settings::NB_POKEMON + head if evoHead == nil #only body evolves
|
||||
return evoBody * Settings::NB_POKEMON + evoHead #both evolve
|
||||
else
|
||||
evo = pbGetEvolvedFormData(species)
|
||||
newSpecies = evo[rand(evo.length - 1)][0]
|
||||
return evo.any? ? getDexNumberForSpecies(newSpecies) : species
|
||||
end
|
||||
rescue
|
||||
return species
|
||||
end
|
||||
end
|
||||
|
||||
#just a shortcut
|
||||
def fusionOf(head,body)
|
||||
return getFusionSpeciesSymbol(body,head)
|
||||
end
|
||||
|
||||
def getFusionSpeciesSymbol(body, head)
|
||||
body_num = dexNum(body)
|
||||
head_num = dexNum(head)
|
||||
nb_pokemon = Settings::NB_POKEMON
|
||||
id = body_num * nb_pokemon + head_num
|
||||
if id > (nb_pokemon*nb_pokemon)+nb_pokemon
|
||||
displayRandomizerErrorMessage()
|
||||
return body
|
||||
end
|
||||
|
||||
return GameData::Species.get(id).species
|
||||
end
|
||||
|
||||
|
||||
|
||||
#
|
||||
def evolveHead(species)
|
||||
species_id = getDexNumberForSpecies(species)
|
||||
if species_id <= Settings::NB_POKEMON
|
||||
evo = getEvolution(species_id)
|
||||
return evo == -1 ? species_id : evo
|
||||
end
|
||||
head = getBasePokemonID(species_id, false)
|
||||
body = getBasePokemonID(species_id)
|
||||
headEvo = getEvolution(head)
|
||||
return headEvo == -1 ? species_id : getFusionSpeciesSymbol(body, headEvo)
|
||||
end
|
||||
|
||||
def evolveBody(species)
|
||||
species_id = getDexNumberForSpecies(species)
|
||||
if species_id <= Settings::NB_POKEMON
|
||||
evo = getEvolution(species_id)
|
||||
return evo == -1 ? species_id : evo
|
||||
end
|
||||
head = getBasePokemonID(species_id, false)
|
||||
body = getBasePokemonID(species_id)
|
||||
bodyEvo = getEvolution(body)
|
||||
return bodyEvo == -1 ? species_id : getFusionSpeciesSymbol(bodyEvo, head)
|
||||
end
|
||||
|
||||
def getCorrectEvolvedSpecies(pokemon)
|
||||
if pokemon.species >= Settings::NB_POKEMON
|
||||
body = getBasePokemonID(pokemon.species)
|
||||
head = getBasePokemonID(pokemon.species, false)
|
||||
ret1 = -1; ret2 = -1
|
||||
for form in pbGetEvolvedFormData(body)
|
||||
retB = yield pokemon, form[0], form[1], form[2]
|
||||
break if retB > 0
|
||||
end
|
||||
for form in pbGetEvolvedFormData(head)
|
||||
retH = yield pokemon, form[0], form[1], form[2]
|
||||
break if retH > 0
|
||||
end
|
||||
return ret if ret == retB && ret == retH
|
||||
return fixEvolutionOverflow(retB, retH, pokemon.species)
|
||||
else
|
||||
for form in pbGetEvolvedFormData(pokemon.species)
|
||||
newspecies = form[2]
|
||||
end
|
||||
return newspecies;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def printDebugRematchInfo(nbRematch, expRate, newLevel, levelCap, originalLevel)
|
||||
info = ""
|
||||
info << _INTL("total rematched trainers: ") + $PokemonGlobal.rematchedTrainers.length.to_s + "\n"
|
||||
|
||||
info << _INTL("nb times: ") + nbRematch.to_s + "\n"
|
||||
info << _INTL("lvl up every {1} times",expRate.to_s) + "\n"
|
||||
info << _INTL("original level: ") << originalLevel.to_s + "\n"
|
||||
info << _INTL("new level: ") + newLevel.to_s + "\n"
|
||||
info << _INTL("level cap: ") + levelCap.to_s
|
||||
print info
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
# class PokeBattle_Trainer
|
||||
# attr_accessor(:name)
|
||||
# def name()
|
||||
# return @name
|
||||
# end
|
||||
# end
|
||||
Reference in New Issue
Block a user