Advertisement
SundialShark

Pokemon Item Find Description 20.1

Jul 26th, 2023
1,505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.11 KB | Gaming | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Item Find
  3. # v2.0
  4. # By Boonzeet
  5. #-------------------------------------------------------------------------------
  6. # A script to show a helpful message with item name, icon and description
  7. # when an item is found for the first time.
  8. #-------------------------------------------------------------------------------
  9.  
  10. WINDOWSKIN_NAME = "" # set for custom windowskin
  11.  
  12. #-------------------------------------------------------------------------------
  13. # Save data registry
  14. #-------------------------------------------------------------------------------
  15. SaveData.register(:item_log) do
  16.   save_value { $item_log }
  17.   load_value { |value|  $item_log = value }
  18.   new_game_value { ItemLog.new }
  19. end
  20.  
  21. #-------------------------------------------------------------------------------
  22. # Base Class
  23. #-------------------------------------------------------------------------------
  24.  
  25. class PokemonItemFind_Scene
  26.   def pbStartScene
  27.     @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  28.     @viewport.z = 99999
  29.     @sprites = {}
  30.     skin = WINDOWSKIN_NAME == "" ? MessageConfig.pbGetSystemFrame : "Graphics/Windowskins/" + WINDOWSKIN_NAME
  31.    
  32.    
  33.     @sprites["background"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, Graphics.width, 0, @viewport)
  34.     @sprites["background"].z = @viewport.z - 1
  35.     @sprites["background"].visible = false
  36.     @sprites["background"].setSkin(skin)
  37.    
  38.     colors = getDefaultTextColors(@sprites["background"].windowskin)
  39.  
  40.     @sprites["itemicon"] = ItemIconSprite.new(42, Graphics.height - 48, nil, @viewport)
  41.     @sprites["itemicon"].visible = false
  42.     @sprites["itemicon"].z = @viewport.z + 2
  43.    
  44.     @sprites["descwindow"] = Window_UnformattedTextPokemon.newWithSize("", 64, 0, Graphics.width - 64, 64, @viewport)
  45.     @sprites["descwindow"].windowskin = nil
  46.     @sprites["descwindow"].z = @viewport.z
  47.     @sprites["descwindow"].visible = false
  48.     @sprites["descwindow"].baseColor = colors[0]
  49.     @sprites["descwindow"].shadowColor = colors[1]
  50.  
  51.     @sprites["titlewindow"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 128, 16, @viewport)
  52.     @sprites["titlewindow"].visible = false
  53.     @sprites["titlewindow"].z = @viewport.z + 1
  54.     @sprites["titlewindow"].windowskin = nil
  55.     @sprites["titlewindow"].baseColor = colors[0]
  56.     @sprites["titlewindow"].shadowColor = colors[1]
  57.   end
  58.  
  59.   def pbShow(item)
  60.     item_object = GameData::Item.get(item)
  61.     name = item_object.name
  62.     description = item_object.description
  63.  
  64.     descwindow = @sprites["descwindow"]
  65.     descwindow.resizeToFit(description, Graphics.width - 64)
  66.     descwindow.text = description
  67.     descwindow.y = Graphics.height - descwindow.height
  68.     descwindow.visible = true
  69.  
  70.     titlewindow = @sprites["titlewindow"]
  71.     titlewindow.resizeToFit(name, Graphics.height)
  72.     titlewindow.text = name
  73.     titlewindow.y = Graphics.height - descwindow.height - 32
  74.     titlewindow.visible = true
  75.  
  76.     background = @sprites["background"]
  77.     background.height = descwindow.height + 32
  78.     background.y = Graphics.height - background.height
  79.     background.visible = true
  80.  
  81.     itemicon = @sprites["itemicon"]
  82.     itemicon.item = item
  83.     itemicon.y = Graphics.height - (descwindow.height / 2).floor
  84.     itemicon.visible = true
  85.  
  86.     loop do
  87.       background.update
  88.       itemicon.update
  89.       descwindow.update
  90.       titlewindow.update
  91.       Graphics.update
  92.       Input.update
  93.       pbUpdateSceneMap
  94.       if Input.trigger?(Input::B) || Input.trigger?(Input::C)
  95.         pbEndScene
  96.         break
  97.       end
  98.     end
  99.   end
  100.  
  101.   def pbEndScene
  102.     pbDisposeSpriteHash(@sprites)
  103.     @viewport.dispose
  104.   end
  105. end
  106.  
  107.  
  108. #-------------------------------------------------------------------------------
  109. # Item Log class
  110. #-------------------------------------------------------------------------------
  111. # The store of found items
  112. #-------------------------------------------------------------------------------
  113. class ItemLog
  114.   def initialize()
  115.     @found_items = []
  116.   end
  117.  
  118.   def register(item)
  119.     if !@found_items.include?(item)
  120.       @found_items.push(item)
  121.       scene = PokemonItemFind_Scene.new
  122.       scene.pbStartScene
  123.       scene.pbShow(item)
  124.     end
  125.   end
  126. end
  127.  
  128. #-------------------------------------------------------------------------------
  129. # Overrides of pbItemBall and pbReceiveItem
  130. #-------------------------------------------------------------------------------
  131. # Picking up an item found on the ground
  132. #-------------------------------------------------------------------------------
  133.  
  134. alias pbItemBall_itemfind pbItemBall
  135. def pbItemBall(item,quantity=1)
  136.   result = pbItemBall_itemfind(item,quantity)
  137.   $item_log.register(item) if result
  138.   return result
  139. end
  140.  
  141. alias pbReceiveItem_itemfind pbReceiveItem
  142. def pbReceiveItem(item,quantity=1)
  143.   result = pbReceiveItem_itemfind(item,quantity)
  144.   $item_log.register(item) if result
  145.   return result
  146. end
  147.  
  148. alias pbPickBerry_itemfind pbPickBerry
  149. def pbPickBerry(berry, qty = 1)
  150.   pbPickBerry_itemfind(berry,qty)
  151.   $item_log.register(berry) if $PokemonBag.pbHasItem?(berry)
  152. end
Tags: Pokémon
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement