trainers rematch

This commit is contained in:
infinitefusion
2021-08-01 13:45:50 -04:00
parent 960867dc7d
commit cd5a2caf94
20 changed files with 276 additions and 204 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -104,7 +104,7 @@ module Settings
#=============================================================================
# Whether poisoned Pokémon will lose HP while walking around in the field.
POISON_IN_FIELD = (MECHANICS_GENERATION <= 4)
POISON_IN_FIELD = true#(MECHANICS_GENERATION <= 4)
# Whether poisoned Pokémon will faint while walking around in the field
# (true), or survive the poisoning with 1 HP (false).
POISON_FAINT_IN_FIELD = (MECHANICS_GENERATION >= 3)

View File

@@ -129,10 +129,13 @@ module GameData
trainer.id = $Trainer.make_foreign_ID
trainer.items = @items.clone
trainer.lose_text = self.lose_text
isRematch = $game_switches[200]
rematchId = getRematchId(trainer.name,trainer.trainer_type)
# Create each Pokémon owned by the trainer
@pokemon.each do |pkmn_data|
#infinite fusion edit
#replace placeholder species infinite fusion edit
species = GameData::Species.get(pkmn_data[:species]).species
if placeholder_species.include?(species)
species = replace_species_with_placeholder(species)
@@ -145,6 +148,14 @@ module GameData
end
end
####
#trainer rematch infinite fusion edit
if isRematch
nbRematch = getNumberRematch(rematchId)
level = getRematchLevel(level,nbRematch)
species = evolveRematchPokemon(nbRematch,species)
end
#
pkmn = Pokemon.new(species, level, trainer, false)
trainer.party.push(pkmn)

View File

@@ -336,6 +336,7 @@ class PokeBattle_Battle
# End of battle
#=============================================================================
def pbGainMoney
return if $game_switches[200] #is rematch
return if !@internalBattle || !@moneyGain
# Money rewarded from opposing trainers
if trainerBattle?
@@ -452,6 +453,21 @@ class PokeBattle_Battle
end
# Register captured Pokémon in the Pokédex, and store them
pbRecordAndStoreCaughtPokemon
isRematch = $game_switches[200]
if isRematch
if @opponent.is_a?(Array)
for trainer in @opponent
rematchId = getRematchId(trainer.name,trainer.trainer_type)
incrNbRematches(rematchId)
end
else
rematchId = getRematchId(@opponent.name,@opponent.trainer_type)
incrNbRematches(rematchId)
end
end
# Collect Pay Day money in a wild battle that ended in a capture
pbGainMoney if @decision==4
# Pass on Pokérus within the party

View File

@@ -130,6 +130,8 @@ class PokeBattle_Scene
# playerBase = "Graphics/Battlebacks/"+baseFilename+"_base0"
# enemyBase = "Graphics/Battlebacks/"+baseFilename+"_base1"
# messageBG = "Graphics/Battlebacks/"+messageFilename+"_message"
battleBG = "Graphics/Battlebacks/battlebg/"+backdropFilename
playerBase = "Graphics/Battlebacks/playerbase/"+baseFilename
enemyBase = "Graphics/Battlebacks/enemybase/"+baseFilename

View File

@@ -94,7 +94,7 @@ Events.onStepTakenTransferPossible += proc { |_sender,e|
for i in $Trainer.able_party
if i.status == :POISON && !i.hasAbility?(:IMMUNITY)
if !flashed
pbFlash(Color.new(255, 0, 0, 128), 8)
pbFlash(Color.new(163, 73, 164, 128), 8)
flashed = true
end
i.hp -= 1 if i.hp>1 || Settings::POISON_FAINT_IN_FIELD

View File

@@ -85,6 +85,37 @@ def pbNewBattleScene
return PokeBattle_Scene.new
end
def getBattleBackgroundFromMetadata(metadata)
#if battle bg specified, return that
battle_bg = metadata.battle_background
return battle_bg if battle_bg
#if no battle bg specified, dedude from environment
battle_env = metadata.battle_environment
case battle_env
when :Cave
return "Cave1"
when :Grass
return "Field"
when :Rock
return "Mountain"
when :Underwater
return "Underwater"
when :StillWater
return "Water"
when :MovingWater
return "Water"
when :Forest
return "Forest"
end
#if is city
if metadata.teleport_destination && metadata.announce_location && metadata.outdoor_map
return "City"
end
end
# Sets up various battle parameters and applies special rules.
def pbPrepareBattle(battle)
battleRules = $PokemonTemp.battleRules
@@ -137,7 +168,7 @@ def pbPrepareBattle(battle)
elsif $PokemonGlobal.surfing
backdrop = "water" # This applies wherever you are, including in caves
elsif GameData::MapMetadata.exists?($game_map.map_id)
back = GameData::MapMetadata.get($game_map.map_id).battle_background
back = getBattleBackgroundFromMetadata(GameData::MapMetadata.get($game_map.map_id))
backdrop = back if back && back != ""
end
if !backdrop
@@ -145,8 +176,6 @@ def pbPrepareBattle(battle)
backdrop = "indoorA" if !isOutdoor
backdrop = "Field" if isOutdoor
end
backdrop = "indoorA" if !backdrop
battle.backdrop = backdrop
# Choose a name for bases depending on environment
if battleRules["base"].nil?

View File

@@ -54,6 +54,8 @@ class PokemonGlobalMetadata
attr_accessor :pokerusTime
# Save file
attr_accessor :safesave
#Trainers rematch
attr_accessor :rematchedTrainers
def initialize
# Movement

View File

@@ -354,13 +354,13 @@ class PokemonOption_Scene
MessageConfig.pbSetSpeechFrame("Graphics/Windowskins/" + Settings::SPEECH_WINDOWSKINS[value])
}
),
NumberOption.new(_INTL("Menu Frame"),1,Settings::MENU_WINDOWSKINS.length,
proc { $PokemonSystem.frame },
proc { |value|
$PokemonSystem.frame = value
MessageConfig.pbSetSystemFrame("Graphics/Windowskins/" + Settings::MENU_WINDOWSKINS[value])
}
),
# NumberOption.new(_INTL("Menu Frame"),1,Settings::MENU_WINDOWSKINS.length,
# proc { $PokemonSystem.frame },
# proc { |value|
# $PokemonSystem.frame = value
# MessageConfig.pbSetSystemFrame("Graphics/Windowskins/" + Settings::MENU_WINDOWSKINS[value])
# }
# ),
EnumOption.new(_INTL("Text Entry"),[_INTL("Cursor"),_INTL("Keyboard")],
proc { $PokemonSystem.textinput },
proc { |value| $PokemonSystem.textinput = value }

View File

@@ -1,23 +1,50 @@
#
#
#
# class RematchTrainer
# attr_reader :id
# attr_reader :nbTimesRematched
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
#
# def initialize(id)
# @id = id
# @nbTimesRematched = 0
# end
# called from pbEndOfBattle
#
# def incrementNbTimes()
# @nbTimesRematched += 1
# end
#
# def removeNbTimes()
# @nbTimesRematched -= 1
# end
# end
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
#
#
#
@@ -37,186 +64,169 @@
# # nb = (level/10).ceil
#
#
# def addNewTrainerRematch(trainerId)
# #$PokemonGlobal.rematchedTrainers[:trainerId]
# newTrainer = RematchTrainer.new(trainerId)
# $PokemonGlobal.rematchedTrainers[trainerId.to_sym] = newTrainer
#
# end
#
#
# 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
#
#
#
# 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 incrNbRematches(trainerId)
# $PokemonGlobal.rematchedTrainers.each do |key, trainer|
# if(trainer.id == trainerId)
# trainer.incrementNbTimes()
# end
# end
# 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,species)
# 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 getEvolution(species)
# if species >= Settings::NB_POKEMON
# pokemon = PokeBattle_Pokemon.new(species,1)
# body = getBasePokemonID(species)
# head = getBasePokemonID(species,false)
# ret_evoB = pbGetEvolvedFormData(body)
# ret_evoH = pbGetEvolvedFormData(head)
#
# evoBody = ret_evoB.any? ? ret_evoB[0][2] : -1
# evoHead = ret_evoH.any? ? ret_evoH[0][2] : -1
#
# return -1 if isNegativeOrNull(evoBody) && isNegativeOrNull(evoHead)
# return body*Settings::NB_POKEMON+evoHead if isNegativeOrNull(evoBody) #only head evolves
# return evoBody*Settings::NB_POKEMON + head if isNegativeOrNull(evoHead) #only body evolves
# return evoBody*Settings::NB_POKEMON+evoHead #both evolve
# else
# evo = pbGetEvolvedFormData(species)
# return evo.any? ? evo[0][2] : -1
# end
# end
#
#
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,species)
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 getEvolution(species)
if species >= Settings::NB_POKEMON
pokemon = PokeBattle_Pokemon.new(species,1)
body = getBasePokemonID(species)
head = getBasePokemonID(species,false)
ret_evoB = pbGetEvolvedFormData(body)
ret_evoH = pbGetEvolvedFormData(head)
evoBody = ret_evoB.any? ? ret_evoB[0][2] : -1
evoHead = ret_evoH.any? ? ret_evoH[0][2] : -1
return -1 if isNegativeOrNull(evoBody) && isNegativeOrNull(evoHead)
return body*Settings::NB_POKEMON+evoHead if isNegativeOrNull(evoBody) #only head evolves
return evoBody*Settings::NB_POKEMON + head if isNegativeOrNull(evoHead) #only body evolves
return evoBody*Settings::NB_POKEMON+evoHead #both evolve
else
evo = pbGetEvolvedFormData(species)
return evo.any? ? evo[0][2] : -1
end
end
def getFusionSpecies(body,head)
id = body * Settings::NB_POKEMON + head
return GameData::Species.get(id).species
end
#
# def evolveHead(species)
# if species <= Settings::NB_POKEMON
# evo = getEvolution(species)
# return evo == -1 ? species : evo
# end
# head = getBasePokemonID(species,false)
# body = getBasePokemonID(species)
# headEvo = getEvolution(head)
# return headEvo == -1 ? species : getFusionSpecies(body,headEvo)
# end
#
# def evolveBody(species)
# if species <= Settings::NB_POKEMON
# evo = getEvolution(species)
# return evo == -1 ? species : evo
# end
# head = getBasePokemonID(species,false)
# body = getBasePokemonID(species)
# bodyEvo = getEvolution(body)
# return bodyEvo == -1 ? species : getFusionSpecies(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 << "total rematched trainers: "+ $PokemonGlobal.rematchedTrainers.length.to_s + "\n"
#
# info << "nb times: "+ nbRematch.to_s + "\n"
# info << "lvl up every " + expRate.to_s + " times" + "\n"
# info << "original level: " << originalLevel.to_s + "\n"
# info << "new level: " + newLevel.to_s + "\n"
# info << "level cap: "+ levelCap.to_s
# print info
# end
def evolveHead(species)
if species <= Settings::NB_POKEMON
evo = getEvolution(species)
return evo == -1 ? species : evo
end
head = getBasePokemonID(species,false)
body = getBasePokemonID(species)
headEvo = getEvolution(head)
return headEvo == -1 ? species : getFusionSpecies(body,headEvo)
end
def evolveBody(species)
if species <= Settings::NB_POKEMON
evo = getEvolution(species)
return evo == -1 ? species : evo
end
head = getBasePokemonID(species,false)
body = getBasePokemonID(species)
bodyEvo = getEvolution(body)
return bodyEvo == -1 ? species : getFusionSpecies(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 << "total rematched trainers: "+ $PokemonGlobal.rematchedTrainers.length.to_s + "\n"
info << "nb times: "+ nbRematch.to_s + "\n"
info << "lvl up every " + expRate.to_s + " times" + "\n"
info << "original level: " << originalLevel.to_s + "\n"
info << "new level: " + newLevel.to_s + "\n"
info << "level cap: "+ levelCap.to_s
print info
end
#
#
#

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -70,8 +70,10 @@ Removed features that will be coming back eventually
- Modern Mode compatibility
- Quest log
- Hidden abilities routes
- Pokeradar special encounters
- In-game clock
- Hard mode, Easy mode
- Some quests probably don't work
Removed features that probably won't be coming back
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾