diff --git a/Data/Scripts/010_Data/002_PBS data/006_Item.rb b/Data/Scripts/010_Data/002_PBS data/006_Item.rb index 2389c13c2..6bb6b9ada 100644 --- a/Data/Scripts/010_Data/002_PBS data/006_Item.rb +++ b/Data/Scripts/010_Data/002_PBS data/006_Item.rb @@ -45,6 +45,10 @@ module GameData return "Graphics/Items/000" end + def self.list_all() + return self::DATA + end + def self.held_icon_filename(item) item_data = self.try_get(item) return nil if !item_data @@ -77,6 +81,8 @@ module GameData @move = hash[:move] end + + # @return [String] the translated name of this item def name return pbGetMessage(MessageTypes::Items, @id_number) diff --git a/Data/Scripts/012_Overworld/001_Overworld.rb b/Data/Scripts/012_Overworld/001_Overworld.rb index 45e0a8f61..f73004b4e 100644 --- a/Data/Scripts/012_Overworld/001_Overworld.rb +++ b/Data/Scripts/012_Overworld/001_Overworld.rb @@ -757,7 +757,11 @@ end # Picking up an item found on the ground #=============================================================================== def pbItemBall(item, quantity = 1, item_name = "", canRandom = true) - item = GameData::Item.get(item) + if canRandom + item = pbGetRandomItem(item) if canRandom #fait rien si pas activé + else + item = GameData::Item.get(item) + end return false if !item || quantity < 1 itemname = (quantity > 1) ? item.name_plural : item.name pocket = item.pocket diff --git a/Data/Scripts/025-Randomizer/RandomizerUtils.rb b/Data/Scripts/025-Randomizer/RandomizerUtils.rb index 4a7e37324..c257ed391 100644 --- a/Data/Scripts/025-Randomizer/RandomizerUtils.rb +++ b/Data/Scripts/025-Randomizer/RandomizerUtils.rb @@ -1,37 +1,54 @@ -def pbGetRandomItem(item) +NON_RANDOMIZE_ITEMS = [:CELLBATTERY,:MAGNETSTONE] + + +def pbGetRandomItem(item_id) + item = GameData::Item.get(item_id) + #keyItem ou HM -> on randomize pas - return item if $ItemData[item][ITEMTYPE] == 6 || $ItemData[item][ITEMUSE] == 4 - return item if isConst?(item, PBItems, :CELLBATTERY) - return item if isConst?(item, PBItems, :MAGNETSTONE) + return item if item.is_key_item? + return item if item.is_HM? + return item if NON_RANDOMIZE_ITEMS.include?(item.id) #TM - if ($ItemData[item][ITEMUSE] == 3) - return $game_switches[959] ? pbGetRandomTM() : item + if (item.is_TM?) + return $game_switches[SWITCH_RANDOM_TMS] ? pbGetRandomTM() : item end #item normal - return item if !$game_switches[958] + return item if !$game_switches[SWITCH_RANDOM_ITEMS] + #berries - return pbGetRandomBerry() if $ItemData[item][ITEMTYPE] == 5 - newItem = rand(PBItems.maxValue) - #on veut pas de tm ou keyitem - while ($ItemData[newItem][ITEMUSE] == 3 || $ItemData[newItem][ITEMUSE] == 4 || $ItemData[newItem][ITEMTYPE] == 6) - newItem = rand(PBItems.maxValue) + return pbGetRandomBerry() if item.is_berry? + + items_list = GameData::Item.list_all + newItem_id = items_list.keys.sample + newItem = GameData::Item.get(newItem_id) + while (newItem.is_machine? || newItem.is_key_item?) + newItem_id = items_list.keys.sample + newItem = GameData::Item.get(newItem_id) end return newItem end + + def pbGetRandomBerry() - newItem = rand(PBItems.maxValue) - while (!($ItemData[newItem][ITEMTYPE] == 5)) - newItem = rand(PBItems.maxValue) + items_list = GameData::Item.list_all + newItem_id = items_list.keys.sample + newItem = GameData::Item.get(newItem_id) + while (!newItem.is_berry?) + newItem_id = items_list.keys.sample + newItem = GameData::Item.get(newItem_id) end return newItem end def pbGetRandomTM() - newItem = rand(PBItems.maxValue) - while (!($ItemData[newItem][ITEMUSE] == 3)) # || $ItemData[newItem][ITEMUSE]==4)) - newItem = rand(PBItems.maxValue) + items_list = GameData::Item.list_all + newItem_id = items_list.keys.sample + newItem = GameData::Item.get(newItem_id) + while (!newItem.is_TM?) + newItem_id = items_list.keys.sample + newItem = GameData::Item.get(newItem_id) end return newItem end diff --git a/Data/System.rxdata b/Data/System.rxdata index 132d89d22..f086bd980 100644 Binary files a/Data/System.rxdata and b/Data/System.rxdata differ diff --git a/PBS/trainers.txt b/PBS/trainers.txt index 8eb0b5bd0..68cd3aff9 100644 --- a/PBS/trainers.txt +++ b/PBS/trainers.txt @@ -1542,7 +1542,7 @@ Pokemon = B69H100,21 #bellsprout + voltorb, #-------------------------------------- [GENTLEMAN,Tucker] -Pokemon = B66H8,23 #Machop + magnemite, +Pokemon = B66H81,23 #Machop + magnemite, #######################