From f3c4893dbb829c21d530939637a149e9c3b2c462 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Wed, 29 Dec 2021 22:07:10 +0000 Subject: [PATCH] Repels now have a flag in items.txt which determines if they can be reused when one runs out --- Data/Scripts/013_Items/002_Item_Effects.rb | 35 ++++++++++------------ PBS/Gen 5/items.txt | 3 ++ PBS/Gen 7/items.txt | 3 ++ PBS/Gen 8/items.txt | 5 +++- PBS/items.txt | 7 +++-- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index 644b0a2cf..563c92ea7 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -135,26 +135,23 @@ ItemHandlers::UseInField.add(:MAXREPEL, proc { |item| }) Events.onStepTaken += proc { - if $PokemonGlobal.repel > 0 && !$game_player.terrain_tag.ice # Shouldn't count down if on ice - $PokemonGlobal.repel -= 1 - if $PokemonGlobal.repel <= 0 - if $bag.has?(:REPEL) || $bag.has?(:SUPERREPEL) || $bag.has?(:MAXREPEL) - if pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?")) - ret = nil - pbFadeOutIn { - scene = PokemonBag_Scene.new - screen = PokemonBagScreen.new(scene, $bag) - ret = screen.pbChooseItemScreen(proc { |item| - [:REPEL, :SUPERREPEL, :MAXREPEL].include?(item) - }) - } - pbUseItem($bag, ret) if ret - end - else - pbMessage(_INTL("The repellent's effect wore off!")) - end - end + next if $PokemonGlobal.repel <= 0 || $game_player.terrain_tag.ice # Shouldn't count down if on ice + $PokemonGlobal.repel -= 1 + next if $PokemonGlobal.repel > 0 + repels = [] + GameData::Item.each { |itm| repels.push(itm.id) if itm.has_flag?("Repel") } + if repels.none? { |item| $bag.has?(item) } + pbMessage(_INTL("The repellent's effect wore off!")) + next end + next if !pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?")) + ret = nil + pbFadeOutIn { + scene = PokemonBag_Scene.new + screen = PokemonBagScreen.new(scene, $bag) + ret = screen.pbChooseItemScreen(proc { |item| repels.include?(item) }) + } + pbUseItem($bag, ret) if ret } ItemHandlers::UseInField.add(:BLACKFLUTE, proc { |item| diff --git a/PBS/Gen 5/items.txt b/PBS/Gen 5/items.txt index f1c3a81c8..162e8a527 100644 --- a/PBS/Gen 5/items.txt +++ b/PBS/Gen 5/items.txt @@ -6,6 +6,7 @@ NamePlural = Repels Pocket = 1 Price = 350 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 100 steps after its use. #------------------------------- [SUPERREPEL] @@ -14,6 +15,7 @@ NamePlural = Super Repels Pocket = 1 Price = 500 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 200 steps after its use. #------------------------------- [MAXREPEL] @@ -22,6 +24,7 @@ NamePlural = Max Repels Pocket = 1 Price = 700 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 250 steps after its use. #------------------------------- [BLACKFLUTE] diff --git a/PBS/Gen 7/items.txt b/PBS/Gen 7/items.txt index 6e3d9146e..9a2b1f08c 100644 --- a/PBS/Gen 7/items.txt +++ b/PBS/Gen 7/items.txt @@ -6,6 +6,7 @@ NamePlural = Repels Pocket = 1 Price = 400 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 100 steps after its use. #------------------------------- [SUPERREPEL] @@ -14,6 +15,7 @@ NamePlural = Super Repels Pocket = 1 Price = 700 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 200 steps after its use. #------------------------------- [MAXREPEL] @@ -22,6 +24,7 @@ NamePlural = Max Repels Pocket = 1 Price = 900 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 250 steps after its use. #------------------------------- [BLACKFLUTE] diff --git a/PBS/Gen 8/items.txt b/PBS/Gen 8/items.txt index a85867ffc..838be3343 100644 --- a/PBS/Gen 8/items.txt +++ b/PBS/Gen 8/items.txt @@ -6,6 +6,7 @@ NamePlural = Repels Pocket = 1 Price = 400 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 100 steps after its use. #------------------------------- [SUPERREPEL] @@ -14,6 +15,7 @@ NamePlural = Super Repels Pocket = 1 Price = 700 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 200 steps after its use. #------------------------------- [MAXREPEL] @@ -22,6 +24,7 @@ NamePlural = Max Repels Pocket = 1 Price = 900 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 250 steps after its use. #------------------------------- [BLACKFLUTE] @@ -5623,7 +5626,7 @@ Name = Mega Ring NamePlural = Mega Rings Pocket = 8 Price = 0 -Flags = KeyItem +Flags = KeyItem, MegaRing Description = This ring contains an untold power that somehow enables Pokémon carrying Mega Stones to Mega Evolve. #------------------------------- [POKEMONBOXLINK] diff --git a/PBS/items.txt b/PBS/items.txt index 057981960..838be3343 100644 --- a/PBS/items.txt +++ b/PBS/items.txt @@ -1,4 +1,4 @@ -# See the documentation on the wiki to learn how to edit this file. +# See the documentation on the wiki to learn how to edit this file. #------------------------------- [REPEL] Name = Repel @@ -6,6 +6,7 @@ NamePlural = Repels Pocket = 1 Price = 400 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 100 steps after its use. #------------------------------- [SUPERREPEL] @@ -14,6 +15,7 @@ NamePlural = Super Repels Pocket = 1 Price = 700 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 200 steps after its use. #------------------------------- [MAXREPEL] @@ -22,6 +24,7 @@ NamePlural = Max Repels Pocket = 1 Price = 900 FieldUse = Direct +Flags = Repel Description = An item that prevents weak wild Pokémon from appearing for 250 steps after its use. #------------------------------- [BLACKFLUTE] @@ -5648,4 +5651,4 @@ NamePlural = Old Sea Maps Pocket = 8 Price = 0 Flags = KeyItem -Description = A faded sea chart that shows the way to a certain island. \ No newline at end of file +Description = A faded sea chart that shows the way to a certain island.