mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
battles
This commit is contained in:
@@ -21,69 +21,69 @@
|
||||
################################################################################
|
||||
|
||||
########################## 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
|
||||
# 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
|
||||
|
||||
|
||||
@@ -59,66 +59,66 @@ def displayProgress(current,total,bst)
|
||||
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
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -521,112 +521,113 @@ def addHealingItem(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($Trainer) if $Trainer
|
||||
|
||||
|
||||
#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 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($Trainer) if $Trainer
|
||||
#
|
||||
#
|
||||
# #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
|
||||
|
||||
Reference in New Issue
Block a user