Merge branch 'master' into refactor

This commit is contained in:
Maruno17
2020-11-09 19:17:24 +00:00
15 changed files with 201 additions and 140 deletions

View File

@@ -432,48 +432,34 @@ class Game_Character
end end
end end
def move_up(turn_enabled = true) def move_generic(dir, turn_enabled = true)
turn_up if turn_enabled turn_generic(dir) if turn_enabled
if passable?(@x, @y, 8) x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
turn_up y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
@y -= 1 if passable?(@x, @y, dir)
turn_generic(dir)
@x += x_offset
@y += y_offset
increase_steps increase_steps
else else
check_event_trigger_touch(@x, @y-1) check_event_trigger_touch(@x + x_offset, @y + y_offset)
end end
end end
def move_down(turn_enabled = true) def move_down(turn_enabled = true)
turn_down if turn_enabled move_generic(2, turn_enabled)
if passable?(@x, @y, 2)
turn_down
@y += 1
increase_steps
else
check_event_trigger_touch(@x, @y+1)
end
end end
def move_left(turn_enabled = true) def move_left(turn_enabled = true)
turn_left if turn_enabled move_generic(4, turn_enabled)
if passable?(@x, @y, 4)
turn_left
@x -= 1
increase_steps
else
check_event_trigger_touch(@x-1, @y)
end
end end
def move_right(turn_enabled = true) def move_right(turn_enabled = true)
turn_right if turn_enabled move_generic(6, turn_enabled)
if passable?(@x, @y, 6)
turn_right
@x += 1
increase_steps
else
check_event_trigger_touch(@x+1, @y)
end end
def move_up(turn_enabled = true)
move_generic(8, turn_enabled)
end end
def move_upper_left def move_upper_left
@@ -696,7 +682,7 @@ class Game_Character
end end
end end
def turnGeneric(dir) def turn_generic(dir)
return if @direction_fix return if @direction_fix
oldDirection = @direction oldDirection = @direction
@direction = dir @direction = dir
@@ -704,10 +690,10 @@ class Game_Character
pbCheckEventTriggerAfterTurning if dir != oldDirection pbCheckEventTriggerAfterTurning if dir != oldDirection
end end
def turn_up; turnGeneric(8); end def turn_down; turn_generic(2); end
def turn_down; turnGeneric(2); end def turn_left; turn_generic(4); end
def turn_left; turnGeneric(4); end def turn_right; turn_generic(6); end
def turn_right; turnGeneric(6); end def turn_up; turn_generic(8); end
def turn_right_90 def turn_right_90
case @direction case @direction

View File

@@ -64,75 +64,36 @@ class Game_Player < Game_Character
@bump_se = Graphics.frame_rate/4 @bump_se = Graphics.frame_rate/4
end end
def move_down(turn_enabled = true) def move_generic(dir, turn_enabled = true)
turn_down if turn_enabled turn_generic(dir, true) if turn_enabled
if passable?(@x, @y, 2) if !$PokemonTemp.encounterTriggered
return if pbLedge(0,1) x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
return if pbEndSurf(0,1) y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
turn_down if passable?(@x, @y, dir)
@y += 1 return if pbLedge(x_offset, y_offset)
return if pbEndSurf(x_offset, y_offset)
turn_generic(dir, true)
if !$PokemonTemp.encounterTriggered
@x += x_offset
@y += y_offset
$PokemonTemp.dependentEvents.pbMoveDependentEvents $PokemonTemp.dependentEvents.pbMoveDependentEvents
increase_steps increase_steps
end
else else
if !check_event_trigger_touch(@x, @y+1) if !check_event_trigger_touch(@x + x_offset, @y + y_offset)
bump_into_object bump_into_object
end end
end end
end end
$PokemonTemp.encounterTriggered = false
def move_left(turn_enabled = true)
turn_left if turn_enabled
if passable?(@x, @y, 4)
return if pbLedge(-1,0)
return if pbEndSurf(-1,0)
turn_left
@x -= 1
$PokemonTemp.dependentEvents.pbMoveDependentEvents
increase_steps
else
if !check_event_trigger_touch(@x-1, @y)
bump_into_object
end
end
end end
def move_right(turn_enabled = true) def turn_generic(dir, keep_enc_indicator = false)
turn_right if turn_enabled
if passable?(@x, @y, 6)
return if pbLedge(1,0)
return if pbEndSurf(1,0)
turn_right
@x += 1
$PokemonTemp.dependentEvents.pbMoveDependentEvents
increase_steps
else
if !check_event_trigger_touch(@x+1, @y)
bump_into_object
end
end
end
def move_up(turn_enabled = true)
turn_up if turn_enabled
if passable?(@x, @y, 8)
return if pbLedge(0,-1)
return if pbEndSurf(0,-1)
turn_up
@y -= 1
$PokemonTemp.dependentEvents.pbMoveDependentEvents
increase_steps
else
if !check_event_trigger_touch(@x, @y-1)
bump_into_object
end
end
end
def turnGeneric(dir)
old_direction = @direction old_direction = @direction
super super(dir)
if @direction != old_direction && !@move_route_forcing && !pbMapInterpreterRunning? if @direction != old_direction && !@move_route_forcing && !pbMapInterpreterRunning?
Events.onChangeDirection.trigger(self, self) Events.onChangeDirection.trigger(self, self)
$PokemonTemp.encounterTriggered = false if !keep_enc_indicator
end end
end end
@@ -170,8 +131,7 @@ class Game_Player < Game_Character
return result return result
end end
def pbCheckEventTriggerAfterTurning def pbCheckEventTriggerAfterTurning; end
end
def pbCheckEventTriggerFromDistance(triggers) def pbCheckEventTriggerFromDistance(triggers)
ret = pbTriggeredTrainerEvents(triggers) ret = pbTriggeredTrainerEvents(triggers)
@@ -385,10 +345,11 @@ class Game_Player < Game_Character
def update_command_new def update_command_new
dir = Input.dir4 dir = Input.dir4
unless pbMapInterpreterRunning? or $game_temp.message_window_showing or unless pbMapInterpreterRunning? || $game_temp.message_window_showing ||
$PokemonTemp.miniupdate or $game_temp.in_menu $PokemonTemp.miniupdate || $game_temp.in_menu
# Move player in the direction the directional button is being pressed # Move player in the direction the directional button is being pressed
if @moved_last_frame || (dir==@lastdir && Graphics.frame_count-@lastdirframe>Graphics.frame_rate/20) if @moved_last_frame ||
(dir > 0 && dir == @lastdir && Graphics.frame_count - @lastdirframe > Graphics.frame_rate / 20)
case dir case dir
when 2; move_down when 2; move_down
when 4; move_left when 4; move_left

View File

@@ -8,7 +8,8 @@ class PokeBattle_Battler
if tryFlee && @battle.wildBattle? && opposes? && if tryFlee && @battle.wildBattle? && opposes? &&
@battle.rules["alwaysflee"] && @battle.pbCanRun?(@index) @battle.rules["alwaysflee"] && @battle.pbCanRun?(@index)
pbBeginTurn(choice) pbBeginTurn(choice)
@battle.pbDisplay(_INTL("{1} fled from battle!",pbThis)) { pbSEPlay("Battle flee") } pbSEPlay("Battle flee")
@battle.pbDisplay(_INTL("{1} fled from battle!",pbThis))
@battle.decision = 3 @battle.decision = 3
pbEndTurn(choice) pbEndTurn(choice)
return true return true

View File

@@ -83,7 +83,7 @@ class PokeBattle_Battle
end end
end end
# Uses an item on a Pokémon in the player's party. # Uses an item on a Pokémon in the trainer's party.
def pbUseItemOnPokemon(item,idxParty,userBattler) def pbUseItemOnPokemon(item,idxParty,userBattler)
trainerName = pbGetOwnerName(userBattler.index) trainerName = pbGetOwnerName(userBattler.index)
pbUseItemMessage(item,trainerName) pbUseItemMessage(item,trainerName)
@@ -100,14 +100,14 @@ class PokeBattle_Battle
pbReturnUnusedItemToBag(item,userBattler.index) pbReturnUnusedItemToBag(item,userBattler.index)
end end
# Uses an item on a Pokémon in battle that belongs to the player. # Uses an item on a Pokémon in battle that belongs to the trainer.
def pbUseItemOnBattler(item,idxParty,userBattler) def pbUseItemOnBattler(item,idxBattler,userBattler)
trainerName = pbGetOwnerName(userBattler.index) trainerName = pbGetOwnerName(userBattler.index)
pbUseItemMessage(item,trainerName) pbUseItemMessage(item,trainerName)
pkmn = pbParty(userBattler.index)[idxParty] idxBattler = userBattler.index if idxBattler<0
battler = pbFindBattler(idxParty,userBattler.index) battler = @battlers[idxBattler]
ch = @choices[userBattler.index] ch = @choices[userBattler.index]
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false) if ItemHandlers.triggerCanUseInBattle(item,battler.pokemon,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene) ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene)
ch[1] = nil # Delete item from choice ch[1] = nil # Delete item from choice
return return

View File

@@ -52,7 +52,8 @@ class PokeBattle_Battle
elsif @internalBattle elsif @internalBattle
pbDisplayPaused(_INTL("No! There's no running from a Trainer battle!")) pbDisplayPaused(_INTL("No! There's no running from a Trainer battle!"))
elsif pbDisplayConfirm(_INTL("Would you like to forfeit the match and quit now?")) elsif pbDisplayConfirm(_INTL("Would you like to forfeit the match and quit now?"))
pbDisplay(_INTL("{1} forfeited the match!",self.pbPlayer.name)) { pbSEPlay("Battle flee") } pbSEPlay("Battle flee")
pbDisplay(_INTL("{1} forfeited the match!",self.pbPlayer.name))
@decision = 3 @decision = 3
return 1 return 1
end end
@@ -60,7 +61,8 @@ class PokeBattle_Battle
end end
# Fleeing from wild battles # Fleeing from wild battles
if $DEBUG && Input.press?(Input::CTRL) if $DEBUG && Input.press?(Input::CTRL)
pbDisplayPaused(_INTL("You got away safely!")) { pbSEPlay("Battle flee") } pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = 3
return 1 return 1
end end
@@ -70,7 +72,8 @@ class PokeBattle_Battle
end end
if !duringBattle if !duringBattle
if battler.pbHasType?(:GHOST) && NEWEST_BATTLE_MECHANICS if battler.pbHasType?(:GHOST) && NEWEST_BATTLE_MECHANICS
pbDisplayPaused(_INTL("You got away safely!")) { pbSEPlay("Battle flee") } pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = 3
return 1 return 1
end end
@@ -79,7 +82,8 @@ class PokeBattle_Battle
if BattleHandlers.triggerRunFromBattleAbility(battler.ability,battler) if BattleHandlers.triggerRunFromBattleAbility(battler.ability,battler)
pbShowAbilitySplash(battler,true) pbShowAbilitySplash(battler,true)
pbHideAbilitySplash(battler) pbHideAbilitySplash(battler)
pbDisplayPaused(_INTL("You got away safely!")) { pbSEPlay("Battle flee") } pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = 3
return 1 return 1
end end
@@ -87,8 +91,9 @@ class PokeBattle_Battle
# Held items that guarantee escape # Held items that guarantee escape
if battler.itemActive? if battler.itemActive?
if BattleHandlers.triggerRunFromBattleItem(battler.item,battler) if BattleHandlers.triggerRunFromBattleItem(battler.item,battler)
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("{1} fled using its {2}!", pbDisplayPaused(_INTL("{1} fled using its {2}!",
battler.pbThis,battler.itemName)) { pbSEPlay("Battle flee") } battler.pbThis,battler.itemName))
@decision = 3 @decision = 3
return 1 return 1
end end
@@ -135,7 +140,8 @@ class PokeBattle_Battle
rate += @runCommand*30 rate += @runCommand*30
end end
if rate>=256 || @battleAI.pbAIRandom(256)<rate if rate>=256 || @battleAI.pbAIRandom(256)<rate
pbDisplayPaused(_INTL("You got away safely!")) { pbSEPlay("Battle flee") } pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = 3
return 1 return 1
end end

View File

@@ -326,7 +326,7 @@ class PokemonDataBox < SpriteWrapper
if @expFlash==0 if @expFlash==0
pbSEStop pbSEStop
@expFlash = Graphics.frame_rate/5 @expFlash = Graphics.frame_rate/5
pbSEPlay("Exp full") pbSEPlay("Pkmn exp full")
self.flash(Color.new(64,200,248,192),@expFlash) self.flash(Color.new(64,200,248,192),@expFlash)
for i in @sprites for i in @sprites
i[1].flash(Color.new(64,200,248,192),@expFlash) if !i[1].disposed? i[1].flash(Color.new(64,200,248,192),@expFlash) if !i[1].disposed?

View File

@@ -25,8 +25,8 @@ class PokeBattle_FakeBattler
def shiny?; return @pokemon.shiny?; end def shiny?; return @pokemon.shiny?; end
alias isShiny? shiny? alias isShiny? shiny?
def isSpecies?(checK_species) def isSpecies?(check_species)
return @pokemon && @pokemon.isSpecies?(checK_species) return @pokemon && @pokemon.isSpecies?(check_species)
end end
def fainted?; return false; end def fainted?; return false; end
@@ -462,7 +462,8 @@ class PokeBattle_SafariZone
catchFactor *= 2 # Easier to catch catchFactor *= 2 # Easier to catch
escapeFactor *= 2 if pbRandom(100)<90 # More likely to escape escapeFactor *= 2 if pbRandom(100)<90 # More likely to escape
when 3 # Run when 3 # Run
pbDisplayPaused(_INTL("You got away safely!")) { pbSEPlay("Battle flee") } pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = 3
end end
catchFactor = [[catchFactor,3].max,20].min catchFactor = [[catchFactor,3].max,20].min
@@ -473,7 +474,8 @@ class PokeBattle_SafariZone
pbDisplay(_INTL("PA: You have no Safari Balls left! Game over!")) pbDisplay(_INTL("PA: You have no Safari Balls left! Game over!"))
@decision = 2 @decision = 2
elsif pbRandom(100)<5*escapeFactor elsif pbRandom(100)<5*escapeFactor
pbDisplay(_INTL("{1} fled!",wildpoke.name)) { pbSEPlay("Battle flee") } pbSEPlay("Battle flee")
pbDisplay(_INTL("{1} fled!",wildpoke.name))
@decision = 3 @decision = 3
elsif cmd==1 # Bait elsif cmd==1 # Bait
pbDisplay(_INTL("{1} is eating!",wildpoke.name)) pbDisplay(_INTL("{1} is eating!",wildpoke.name))

View File

@@ -83,7 +83,8 @@ BattleHandlers::AbilityOnHPDroppedBelowHalf.add(:EMERGENCYEXIT,
next false if !battle.pbCanRun?(battler.index) next false if !battle.pbCanRun?(battler.index)
battle.pbShowAbilitySplash(battler,true) battle.pbShowAbilitySplash(battler,true)
battle.pbHideAbilitySplash(battler) battle.pbHideAbilitySplash(battler)
battle.pbDisplay(_INTL("{1} fled from battle!",battler.pbThis)) { pbSEPlay("Battle flee") } pbSEPlay("Battle flee")
battle.pbDisplay(_INTL("{1} fled from battle!",battler.pbThis))
battle.decision = 3 # Escaped battle.decision = 3 # Escaped
next true next true
end end

View File

@@ -368,6 +368,7 @@ def pbOnStepTaken(eventTriggered)
Events.onStepTakenTransferPossible.trigger(nil,handled) Events.onStepTakenTransferPossible.trigger(nil,handled)
return if handled[0] return if handled[0]
pbBattleOnStepTaken(repel) if !eventTriggered && !$game_temp.in_menu pbBattleOnStepTaken(repel) if !eventTriggered && !$game_temp.in_menu
$PokemonTemp.encounterTriggered = false # This info isn't needed
end end
# Start wild encounters while turning on the spot # Start wild encounters while turning on the spot
@@ -394,6 +395,7 @@ def pbBattleOnStepTaken(repel=false)
pbWildBattle(encounter[0], encounter[1]) pbWildBattle(encounter[0], encounter[1])
end end
$PokemonTemp.encounterType = -1 $PokemonTemp.encounterType = -1
$PokemonTemp.encounterTriggered = true
end end
$PokemonTemp.forceSingleBattle = false $PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd EncounterModifier.triggerEncounterEnd

View File

@@ -11,6 +11,7 @@ end
class PokemonTemp class PokemonTemp
attr_accessor :encounterTriggered
attr_accessor :encounterType attr_accessor :encounterType
attr_accessor :evolutionLevels attr_accessor :evolutionLevels
@@ -251,7 +252,12 @@ def pbWildBattleCore(*args)
playerTrainers = [$Trainer] playerTrainers = [$Trainer]
playerParty = $Trainer.party playerParty = $Trainer.party
playerPartyStarts = [0] playerPartyStarts = [0]
if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && foeParty.length>1 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 = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0]) ally = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
ally.id = $PokemonGlobal.partner[2] ally.id = $PokemonGlobal.partner[2]
ally.party = $PokemonGlobal.partner[3] ally.party = $PokemonGlobal.partner[3]
@@ -391,7 +397,12 @@ def pbTrainerBattleCore(*args)
playerTrainers = [$Trainer] playerTrainers = [$Trainer]
playerParty = $Trainer.party playerParty = $Trainer.party
playerPartyStarts = [0] playerPartyStarts = [0]
if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && foeParty.length>1 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 = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0]) ally = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
ally.id = $PokemonGlobal.partner[2] ally.id = $PokemonGlobal.partner[2]
ally.party = $PokemonGlobal.partner[3] ally.party = $PokemonGlobal.partner[3]
@@ -553,6 +564,7 @@ def pbAfterBattle(decision,canLose)
end end
end end
Events.onEndBattle.trigger(nil,decision,canLose) Events.onEndBattle.trigger(nil,decision,canLose)
$game_player.straighten
end end
Events.onEndBattle += proc { |_sender,e| Events.onEndBattle += proc { |_sender,e|

View File

@@ -41,7 +41,8 @@ class PokemonGlobalMetadata
attr_writer :dependentEvents attr_writer :dependentEvents
def dependentEvents def dependentEvents
return @dependentEvents || [] @dependentEvents = [] if !@dependentEvents
return @dependentEvents
end end
end end

View File

@@ -953,6 +953,7 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc { |item,pkmn,scene|
end end
if pkmn.fainted? if pkmn.fainted?
scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
next false
end end
# Fusing # Fusing
if pkmn.fused==nil if pkmn.fused==nil
@@ -961,13 +962,17 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc { |item,pkmn,scene|
poke2 = $Trainer.party[chosen] poke2 = $Trainer.party[chosen]
if pkmn==poke2 if pkmn==poke2
scene.pbDisplay(_INTL("It cannot be fused with itself.")) scene.pbDisplay(_INTL("It cannot be fused with itself."))
next false
elsif poke2.egg? elsif poke2.egg?
scene.pbDisplay(_INTL("It cannot be fused with an Egg.")) scene.pbDisplay(_INTL("It cannot be fused with an Egg."))
next false
elsif poke2.fainted? elsif poke2.fainted?
scene.pbDisplay(_INTL("It cannot be fused with that fainted Pokémon.")) scene.pbDisplay(_INTL("It cannot be fused with that fainted Pokémon."))
next false
elsif !poke2.isSpecies?(:RESHIRAM) && elsif !poke2.isSpecies?(:RESHIRAM) &&
!poke2.isSpecies?(:ZEKROM) !poke2.isSpecies?(:ZEKROM)
scene.pbDisplay(_INTL("It cannot be fused with that Pokémon.")) scene.pbDisplay(_INTL("It cannot be fused with that Pokémon."))
next false
end end
newForm = 0 newForm = 0
newForm = 1 if poke2.isSpecies?(:RESHIRAM) newForm = 1 if poke2.isSpecies?(:RESHIRAM)
@@ -995,12 +1000,13 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc { |item,pkmn,scene|
}) })
ItemHandlers::UseOnPokemon.add(:NSOLARIZER,proc { |item,pkmn,scene| ItemHandlers::UseOnPokemon.add(:NSOLARIZER,proc { |item,pkmn,scene|
if !pkmn.isSpecies?(:NECROZMA) || pkmn.form==0 if !pkmn.isSpecies?(:NECROZMA) || pkmn.form == 2
scene.pbDisplay(_INTL("It had no effect.")) scene.pbDisplay(_INTL("It had no effect."))
next false next false
end end
if pkmn.fainted? if pkmn.fainted?
scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
next false
end end
# Fusing # Fusing
if pkmn.fused==nil if pkmn.fused==nil
@@ -1009,12 +1015,16 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZER,proc { |item,pkmn,scene|
poke2 = $Trainer.party[chosen] poke2 = $Trainer.party[chosen]
if pkmn==poke2 if pkmn==poke2
scene.pbDisplay(_INTL("It cannot be fused with itself.")) scene.pbDisplay(_INTL("It cannot be fused with itself."))
next false
elsif poke2.egg? elsif poke2.egg?
scene.pbDisplay(_INTL("It cannot be fused with an Egg.")) scene.pbDisplay(_INTL("It cannot be fused with an Egg."))
next false
elsif poke2.fainted? elsif poke2.fainted?
scene.pbDisplay(_INTL("It cannot be fused with that fainted Pokémon.")) scene.pbDisplay(_INTL("It cannot be fused with that fainted Pokémon."))
next false
elsif !poke2.isSpecies?(:SOLGALEO) elsif !poke2.isSpecies?(:SOLGALEO)
scene.pbDisplay(_INTL("It cannot be fused with that Pokémon.")) scene.pbDisplay(_INTL("It cannot be fused with that Pokémon."))
next false
end end
pkmn.setForm(1) { pkmn.setForm(1) {
pkmn.fused = poke2 pkmn.fused = poke2
@@ -1045,6 +1055,7 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item,pkmn,scene|
end end
if pkmn.fainted? if pkmn.fainted?
scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
next false
end end
# Fusing # Fusing
if pkmn.fused==nil if pkmn.fused==nil
@@ -1053,12 +1064,16 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item,pkmn,scene|
poke2 = $Trainer.party[chosen] poke2 = $Trainer.party[chosen]
if pkmn==poke2 if pkmn==poke2
scene.pbDisplay(_INTL("It cannot be fused with itself.")) scene.pbDisplay(_INTL("It cannot be fused with itself."))
next false
elsif poke2.egg? elsif poke2.egg?
scene.pbDisplay(_INTL("It cannot be fused with an Egg.")) scene.pbDisplay(_INTL("It cannot be fused with an Egg."))
next false
elsif poke2.fainted? elsif poke2.fainted?
scene.pbDisplay(_INTL("It cannot be fused with that fainted Pokémon.")) scene.pbDisplay(_INTL("It cannot be fused with that fainted Pokémon."))
next false
elsif !poke2.isSpecies?(:LUNALA) elsif !poke2.isSpecies?(:LUNALA)
scene.pbDisplay(_INTL("It cannot be fused with that Pokémon.")) scene.pbDisplay(_INTL("It cannot be fused with that Pokémon."))
next false
end end
pkmn.setForm(2) { pkmn.setForm(2) {
pkmn.fused = poke2 pkmn.fused = poke2

View File

@@ -77,7 +77,7 @@ def pbAddPokemon(pokemon,level=nil,seeform=true)
pokemon = Pokemon.new(pokemon,level) pokemon = Pokemon.new(pokemon,level)
end end
speciesname = PBSpecies.getName(pokemon.species) speciesname = PBSpecies.getName(pokemon.species)
pbMessage(_INTL("\\me[Pkmn get]{1} obtained {2}!\1",$Trainer.name,speciesname)) pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1",$Trainer.name,speciesname))
pbNicknameAndStore(pokemon) pbNicknameAndStore(pokemon)
pbSeenForm(pokemon) if seeform pbSeenForm(pokemon) if seeform
return true return true
@@ -113,7 +113,7 @@ def pbAddToParty(pokemon,level=nil,seeform=true)
pokemon = Pokemon.new(pokemon,level) pokemon = Pokemon.new(pokemon,level)
end end
speciesname = PBSpecies.getName(pokemon.species) speciesname = PBSpecies.getName(pokemon.species)
pbMessage(_INTL("\\me[Pkmn get]{1} obtained {2}!\1",$Trainer.name,speciesname)) pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1",$Trainer.name,speciesname))
pbNicknameAndStore(pokemon) pbNicknameAndStore(pokemon)
pbSeenForm(pokemon) if seeform pbSeenForm(pokemon) if seeform
return true return true

View File

@@ -208,6 +208,8 @@ def pbDebugMenuCommands(showall=true)
_INTL("Fully compile all data.")) _INTL("Fully compile all data."))
commands.add("othermenu","debugconsole",_INTL("Debug Console"), commands.add("othermenu","debugconsole",_INTL("Debug Console"),
_INTL("Open the Debug Console.")) _INTL("Open the Debug Console."))
commands.add("othermenu","invalidtiles",_INTL("Fix Invalid Tiles"),
_INTL("Scans all maps and erases non-existent tiles."))
return commands return commands
end end
@@ -366,7 +368,7 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
battle = pbListScreen(_INTL("SINGLE TRAINER"),TrainerBattleLister.new(0,false)) battle = pbListScreen(_INTL("SINGLE TRAINER"),TrainerBattleLister.new(0,false))
if battle if battle
trainerdata = battle[1] trainerdata = battle[1]
pbTrainerBattle(trainerdata[0],trainerdata[1],"...",false,trainerdata[4],true) pbTrainerBattle(trainerdata[0],trainerdata[1],nil,false,trainerdata[4],true)
end end
when "testtrainerbattleadvanced" when "testtrainerbattleadvanced"
trainers = [] trainers = []
@@ -791,6 +793,8 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
pbDisposeMessageWindow(msgwindow) pbDisposeMessageWindow(msgwindow)
when "debugconsole" when "debugconsole"
Console::setup_console Console::setup_console
when "invalidtiles"
pbDebugFixInvalidTiles
end end
return false return false
end end

View File

@@ -796,6 +796,76 @@ def pbImportAllAnimations
end end
end end
#===============================================================================
# Properly erases all non-existent tiles in maps (including event graphics)
#===============================================================================
def pbDebugFixInvalidTiles
num_errors = 0
num_error_maps = 0
@tilesets = pbLoadRxData("Data/Tilesets")
mapData = MapData.new
t = Time.now.to_i
Graphics.update
for id in mapData.mapinfos.keys.sort
if Time.now.to_i - t >= 5
Graphics.update
t = Time.now.to_i
end
changed = false
map = mapData.getMap(id)
next if !map || !mapData.mapinfos[id]
Win32API.SetWindowText(_INTL("Processing map {1} ({2})", id, mapData.mapinfos[id].name))
passages = mapData.getTilesetPassages(map, id)
# Check all tiles in map for non-existent tiles
for x in 0...map.data.xsize
for y in 0...map.data.ysize
for i in 0...map.data.zsize
tile_id = map.data[x, y, i]
next if pbCheckTileValidity(tile_id, map, @tilesets, passages)
map.data[x, y, i] = 0
changed = true
num_errors += 1
end
end
end
# Check all events in map for page graphics using a non-existent tile
for key in map.events.keys
event = map.events[key]
for page in event.pages
next if page.graphic.tile_id <= 0
next if pbCheckTileValidity(page.graphic.tile_id, map, @tilesets, passages)
page.graphic.tile_id = 0
changed = true
num_errors += 1
end
end
next if !changed
# Map was changed; save it
num_error_maps += 1
mapData.saveMap(id)
end
if num_error_maps == 0
pbMessage(_INTL("No invalid tiles were found."))
else
pbMessage(_INTL("{1} error(s) were found across {2} map(s) and fixed.", num_errors, num_error_maps))
pbMessage(_INTL("Close RPG Maker XP to ensure the changes are applied properly."))
end
end
def pbCheckTileValidity(tile_id, map, tilesets, passages)
return false if !tile_id
if tile_id > 0 && tile_id < 384
# Check for defined autotile
autotile_id = tile_id / 48 - 1
autotile_name = tilesets[map.tileset_id].autotile_names[autotile_id]
return true if autotile_name && autotile_name != ""
else
# Check for tileset data
return true if passages[tile_id]
end
return false
end
#=============================================================================== #===============================================================================