update 6.7

This commit is contained in:
chardub
2025-09-28 15:53:01 -04:00
parent ef5e023ae0
commit 318ff90d8d
696 changed files with 111759 additions and 198230 deletions

View File

@@ -4,6 +4,7 @@ class BattledTrainer
attr_accessor :trainerType
attr_accessor :trainerName
attr_accessor :trainerKey
attr_accessor :currentTeam #list of Pokemon. The game selects in this list for trade offers. They can increase levels & involve as you rebattle them.
@@ -19,8 +20,6 @@ class BattledTrainer
#Healing items that are in that list can be used by the trainer in rematches
#
attr_accessor :foundItems
attr_accessor :nb_rematches
#What the trainer currently wants to do
@@ -47,7 +46,8 @@ class BattledTrainer
attr_accessor :friendship #increases the more you interact with them, unlocks more interact options
attr_accessor :friendship_level
def initialize(trainerType,trainerName,trainerVersion)
def initialize(trainerType,trainerName,trainerVersion,trainerKey)
@trainerKey = trainerKey
@trainerType = trainerType
@trainerName = trainerName
@currentTeam = loadOriginalTrainerTeam(trainerVersion)
@@ -83,7 +83,7 @@ class BattledTrainer
@friendship_level += 1
trainerClassName = GameData::TrainerType.get(@trainerType).real_name
pbMessage(_INTL("\\C[3]Friendship increased with #{trainerClassName} #{@trainerName}!"))
pbMessage(_INTL("\\C[3]Friendship increased with {1} {2}!",trainerClassName,@trainerName))
case @friendship_level
when 1
pbMessage(_INTL("You can now trade with each other!"))

View File

@@ -30,7 +30,7 @@ end
def registerBattledTrainer(event_id, mapId, trainerType, trainerName, trainerVersion=0)
key = [event_id,mapId]
$PokemonGlobal.battledTrainers = {} unless $PokemonGlobal.battledTrainers
trainer = BattledTrainer.new(trainerType, trainerName, trainerVersion)
trainer = BattledTrainer.new(trainerType, trainerName, trainerVersion,key)
$PokemonGlobal.battledTrainers[key] = trainer
return trainer
end
@@ -58,13 +58,24 @@ end
def updateRebattledTrainer(event_id,map_id,updated_trainer)
key = [event_id,map_id]
updateRebattledTrainerWithKey(key,updated_trainer)
end
def updateRebattledTrainerWithKey(key,updated_trainer)
$PokemonGlobal.battledTrainers = {} if !$PokemonGlobal.battledTrainers
$PokemonGlobal.battledTrainers[key] = updated_trainer
end
def getRebattledTrainer(event_id,map_id)
key = [event_id,map_id]
def getRebattledTrainerKey(event_id, map_id)
return [event_id,map_id]
end
def getRebattledTrainerFromKey(key)
$PokemonGlobal.battledTrainers = {} if !$PokemonGlobal.battledTrainers
return $PokemonGlobal.battledTrainers[key]
end
def getRebattledTrainer(event_id,map_id)
key = getRebattledTrainerKey(event_id, map_id)
return getRebattledTrainerFromKey(key)
end

View File

@@ -59,16 +59,18 @@ def generateTrainerRematch(trainer)
trainer_data = GameData::Trainer.try_get(trainer.trainerType, trainer.trainerName, 0)
loseDialog = trainer_data&.loseText_rematch ? trainer_data.loseText_rematch : "..."
player_won = false
if customTrainerBattle(trainer.trainerName,trainer.trainerType, trainer.currentTeam,nil,loseDialog)
updated_trainer = makeRebattledTrainerTeamGainExp(trainer,true)
updated_trainer = healRebattledTrainerPokemon(updated_trainer)
player_won=true
else
updated_trainer =makeRebattledTrainerTeamGainExp(trainer,false)
end
updated_trainer.set_pending_action(false)
updated_trainer = evolveRebattledTrainerPokemon(updated_trainer)
trainer.increase_friendship(5)
return updated_trainer
return updated_trainer, player_won
end
def showPrerematchDialog()
@@ -116,6 +118,7 @@ def showPrerematchDialog()
split_messages = message_text.split("<br>")
split_messages.each do |msg|
pbCallBub(2,event.id)
pbCallBub(3) if isPartneredWithTrainer(trainer)
pbMessage(msg)
end
end

View File

@@ -32,7 +32,7 @@ def doPostBattleAction(actionType)
return if !trainer
case actionType
when :BATTLE
trainer = doNPCTrainerRematch(trainer)
trainer,player_won = doNPCTrainerRematch(trainer)
when :TRADE
trainer = doNPCTrainerTrade(trainer)
when :PARTNER
@@ -46,7 +46,7 @@ def setTrainerFriendship(trainer)
params = ChooseNumberParams.new
params.setRange(0,100)
params.setDefaultValue($game_map.map_id)
number = pbMessageChooseNumber("Frienship (0-100)?",params)
number = pbMessageChooseNumber(_INTL("Frienship (0-100)?"),params)
trainer.friendship = number
trainer.increase_friendship(0)
return trainer
@@ -57,15 +57,15 @@ end
#
#def customTrainerBattle(trainerName, trainerType, party_array, default_level=50, endSpeech="", sprite_override=nil,custom_appearance=nil)
def postBattleActionsMenu()
rematchCommand = "Rematch"
tradeCommand = "Trade Offer"
partnerCommand = "Partner up"
cancelCommand = "See ya!"
rematchCommand = _INTL("Rematch")
tradeCommand = _INTL("Trade Offer")
partnerCommand = _INTL("Partner up")
cancelCommand = _INTL("See ya!")
updateTeamDebugCommand = "(Debug) Simulate random event"
resetTrainerDebugCommand = "(Debug) Reset trainer"
setFriendshipDebugCommand = "(Debug) Set Friendship"
printTrainerTeamDebugCommand = "(Debug) Print team"
updateTeamDebugCommand = _INTL("(Debug) Simulate random event")
resetTrainerDebugCommand = _INTL("(Debug) Reset trainer")
setFriendshipDebugCommand = _INTL("(Debug) Set Friendship")
printTrainerTeamDebugCommand = _INTL("(Debug) Print team")
event = pbMapInterpreter.get_character(0)
@@ -116,3 +116,22 @@ def postBattleActionsMenu()
end
end
#leave event_type empty for random
def forceRandomRematchEventOnTrainer(event_type=nil)
event = pbMapInterpreter.get_character(0)
map_id = $game_map.map_id if map_id.nil?
trainer = getRebattledTrainer(event.id,map_id)
while !trainer.has_pending_action
trainer = applyTrainerRandomEvents(trainer,event_type)
end
updateRebattledTrainer(event.id,map_id,trainer)
end
def forceTrainerFriendshipOnTrainer(friendship=0)
event = pbMapInterpreter.get_character(0)
map_id = $game_map.map_id if map_id.nil?
trainer = getRebattledTrainer(event.id,map_id)
trainer.friendship = friendship
trainer.increase_friendship(0)
updateRebattledTrainer(event.id,map_id,trainer)
end

View File

@@ -1,7 +1,13 @@
COMMON_EVENT_TRAINER_REMATCH_PARTNER = 200
def partnerWithTrainer(eventId, mapID, trainer)
Kernel.pbAddDependency2(eventId,trainer.trainerName,COMMON_EVENT_TRAINER_REMATCH_PARTNER)
SWITCH_PARTNERED_WITH_NPC_TRAINER = 2049
class Trainer
attr_accessor :npcPartner
end
def partnerWithTrainer(eventId, mapID, trainer,trainer_key=nil ,common_event=nil)
common_event = COMMON_EVENT_TRAINER_REMATCH_PARTNER if !common_event
Kernel.pbAddDependency2(eventId,trainer.trainerName,common_event)
pbCancelVehicles
originalTrainer = pbLoadTrainer(trainer.trainerType, trainer.trainerName, 0)
Events.onTrainerPartyLoad.trigger(nil, originalTrainer)
@@ -9,5 +15,51 @@ def partnerWithTrainer(eventId, mapID, trainer)
i.owner = Pokemon::Owner.new_from_trainer(originalTrainer)
i.calc_stats
end
trainer_key = getRebattledTrainerKey(eventId,mapID) if !trainer_key
$PokemonGlobal.partner = [trainer.trainerType, trainer.trainerName, 0, trainer.currentTeam]
$Trainer.npcPartner = trainer_key
end
def unpartnerWithTrainer()
pbRemoveDependencies
$game_switches[SWITCH_PARTNERED_WITH_NPC_TRAINER]=false
$Trainer.npcPartner=nil
end
def promptGiveToPartner(caughtPokemon)
return false if !$Trainer.npcPartner
return false if $Trainer.npcPartner == BATTLED_TRAINER_WALLY_KEY && $game_switches[SWITCH_WALLY_GAVE_POKEMON]
if $Trainer.npcPartner == BATTLED_TRAINER_WALLY_KEY && caughtPokemon.isFusion?
pbMessage(_INTL("I... I don't think I can handle a fused Pokémon. Can we try to catch a different one?"))
return
end
partnerTrainer = getRebattledTrainerFromKey($Trainer.npcPartner)
return false if $Trainer.npcPartner == BATTLED_TRAINER_WALLY_KEY && partnerTrainer.currentTeam.length > 0
return false if !partnerTrainer
command = pbMessage(_INTL("Would you like to give the newly caught {1} to {2}?",caughtPokemon.name,partnerTrainer.trainerName),
[_INTL("Keep"),_INTL("Give to {1}",partnerTrainer.trainerName)], 2)
case command
when 0 # Keep
return
else
# Give
pbMessage(_INTL("You gave the {1} to {2}!",caughtPokemon.name,partnerTrainer.trainerName))
if partnerTrainer.currentTeam.length == 6
partnerTrainer.currentTeam[-1] = caughtPokemon
else
partnerTrainer.currentTeam << caughtPokemon
end
partnerTrainer.increase_friendship(10)
updateRebattledTrainerWithKey($Trainer.npcPartner,partnerTrainer)
if $Trainer.npcPartner == BATTLED_TRAINER_WALLY_KEY
$game_switches[SWITCH_WALLY_GAVE_POKEMON_DIALOGUE]=true
end
end
end
def isPartneredWithTrainer(trainer)
return $Trainer.npcPartner == trainer.trainerKey
end
def isPartneredWithAnyTrainer()
return $Trainer.npcPartner != nil
end

View File

@@ -12,7 +12,7 @@ def printNPCTrainerCurrentTeam(trainer)
echoln "Trainer's current team is: #{team_string}"
end
def applyTrainerRandomEvents(trainer)
def applyTrainerRandomEvents(trainer,event_type=nil)
if trainer.has_pending_action
echoln "Trainer has pending action"
end
@@ -28,20 +28,21 @@ def applyTrainerRandomEvents(trainer)
[:CATCH, 3],
[:FUSE, 6],
[:REVERSE, 1],
[:UNFUSE, 20]
[:UNFUSE, 2]
]
# Create a flat array of events based on weight
event_pool = weighted_events.flat_map { |event, weight| [event] * weight }
selected_event = event_pool.sample
selected_event = event_type if event_type
if selected_event
echoln "Trying to do random event: #{selected_event}"
end
return trainer if selected_event.nil?
original_team = trainer.currentTeam.clone
case selected_event
when :CATCH
@@ -53,7 +54,12 @@ def applyTrainerRandomEvents(trainer)
when :REVERSE
trainer = reverse_random_team_pokemon(trainer)
end
trainer.set_pending_action(true)
new_team = trainer.currentTeam
echoln original_team
echoln new_team
team_changed = original_team != new_team
trainer.set_pending_action(team_changed)
printNPCTrainerCurrentTeam(trainer)
return trainer
end

View File

@@ -217,7 +217,7 @@ def generateTrainerTradeOffer(trainer)
wanted_type_name = GameData::Type.get(wanted_type).real_name
trainerClassName = GameData::TrainerType.get(trainer.trainerType).real_name
pbMessage(_INTL("#{trainerClassName} #{trainer.trainerName} is looking for \\C[1]#{wanted_type_name}-type Pokémon\\C[0]. Which Pokémon do you want to trade?."),)
pbMessage(_INTL("{1} {2} is looking for {3}-type Pokémon. Which Pokémon do you want to trade?.", trainerClassName, trainer.trainerName, wanted_type_name))
pbChoosePokemon(1,2,
proc {|pokemon|
pokemon.hasType?(wanted_type)
@@ -229,17 +229,17 @@ def generateTrainerTradeOffer(trainer)
chosen_pokemon = $Trainer.party[chosen_index]
offered_pokemon = offerPokemonForTrade(chosen_pokemon,trainer.currentTeam,trainer.trainerType)
if !offered_pokemon
pbMessage(_INTL("#{trainerClassName} #{trainer.trainerName} does not want to trade..."))
pbMessage(_INTL("{1} {2} does not want to trade...", trainerClassName, trainer.trainerName))
return trainer
end
pif_sprite = BattleSpriteLoader.new.get_pif_sprite_from_species(offered_pokemon.species)
pif_sprite.dump_info()
message = _INTL("#{trainerClassName} #{trainer.trainerName} is offering #{offered_pokemon.name} (Level #{offered_pokemon.level}) for your #{chosen_pokemon.name}.")
message = _INTL("{1} {2} is offering {3} (Level {4}) for your {5}.", trainerClassName, trainer.trainerName, offered_pokemon.name, offered_pokemon.level, chosen_pokemon.name)
showPokemonInPokeballWithMessage(pif_sprite, message)
if pbConfirmMessage(_INTL("Trade away #{chosen_pokemon.name} for #{trainerClassName} #{trainer.trainerName}'s #{offered_pokemon.name}?"))
if pbConfirmMessage(_INTL("Trade away {1} for {2} {3}'s {4}?", chosen_pokemon.name, trainerClassName, trainer.trainerName, offered_pokemon.name))
pbStartTrade(chosen_index, offered_pokemon,offered_pokemon.name,trainer.trainerName,0)
updated_party = trainer.currentTeam
updated_party.delete(offered_pokemon)