- Pokémon Essentials Version
- v18 ➖
Short and sweet script to show an icon and description with the item name when discovering an item for the first time, like in Sword & Shield.
Instructions
Place this script above Main, or above FollowingPokemon if using.
Essentials v18
To add support for Berry Plants, search for this line in
And ABOVE both instances, add this line:
Essentials v17 (No longer actively supported)
If using FollowingPokemon, replace all of
Instructions
Place this script above Main, or above FollowingPokemon if using.
Essentials v18
Ruby:
#-------------------------------------------------------------------------------
# Item Find
# v1.2.1
# By Boonzeet
#-------------------------------------------------------------------------------
# A script to show a helpful message with item name, icon and description
# when an item is found for the first time.
#-------------------------------------------------------------------------------
PluginManager.register({
:name => "Item Find",
:version => "1.2.1",
:credits => "Boonzeet",
:link => "https://reliccastle.com/resources/371/"
})
#-------------------------------------------------------------------------------
# Config
#-------------------------------------------------------------------------------
WINDOWSKIN_NAME = "" # set for custom windowskin
#-------------------------------------------------------------------------------
# Base Class
#-------------------------------------------------------------------------------
class PokemonItemFind_Scene
def pbStartScene
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
skin = WINDOWSKIN_NAME == "" ? MessageConfig.pbGetSystemFrame : "Graphics/Windowskins/" + WINDOWSKIN_NAME
@sprites["background"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, Graphics.width, 0, @viewport)
@sprites["background"].z = @viewport.z - 1
@sprites["background"].visible = false
@sprites["background"].setSkin(skin)
colors = getDefaultTextColors(@sprites["background"].windowskin)
@sprites["itemicon"] = ItemIconSprite.new(42, Graphics.height - 48, -1, @viewport)
@sprites["itemicon"].visible = false
@sprites["itemicon"].z = @viewport.z + 2
@sprites["descwindow"] = Window_UnformattedTextPokemon.newWithSize("", 64, 0, Graphics.width - 64, 64, @viewport)
@sprites["descwindow"].windowskin = nil
@sprites["descwindow"].z = @viewport.z
@sprites["descwindow"].visible = false
@sprites["descwindow"].baseColor = colors[0]
@sprites["descwindow"].shadowColor = colors[1]
@sprites["titlewindow"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 128, 16, @viewport)
@sprites["titlewindow"].visible = false
@sprites["titlewindow"].z = @viewport.z + 1
@sprites["titlewindow"].setSkin(skin)
end
def pbShow(item)
name = PBItems.getName(item)
description = pbGetMessage(MessageTypes::ItemDescriptions, item)
descwindow = @sprites["descwindow"]
descwindow.resizeToFit(description, Graphics.width - 64)
descwindow.text = description
descwindow.y = Graphics.height - descwindow.height
descwindow.visible = true
background = @sprites["background"]
background.height = descwindow.height + 16
background.y = Graphics.height - background.height
background.visible = true
titlewindow = @sprites["titlewindow"]
titlewindow.resizeToFit(name, Graphics.height)
titlewindow.text = name
titlewindow.y = Graphics.height - descwindow.height - 48
titlewindow.visible = true
itemicon = @sprites["itemicon"]
itemicon.item = item
itemicon.y = Graphics.height - (descwindow.height / 2).floor
itemicon.visible = true
loop do
background.update
itemicon.update
descwindow.update
titlewindow.update
Graphics.update
Input.update
pbUpdateSceneMap
if Input.trigger?(Input::B) || Input.trigger?(Input::C)
pbEndScene
break
end
end
end
def pbEndScene
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end
#-------------------------------------------------------------------------------
# Game Player changes
#-------------------------------------------------------------------------------
# Adds a list of found items to the Game Player which is maintained over saves
#-------------------------------------------------------------------------------
class Game_Player
alias initialize_itemfind initialize
def initialize(*args)
@found_items = []
initialize_itemfind(*args)
end
def addFoundItem(item)
if !defined?(@found_items)
@found_items = []
end
if !@found_items.include?(item)
@found_items.push(item)
scene = PokemonItemFind_Scene.new
scene.pbStartScene
scene.pbShow(item)
end
end
end
#-------------------------------------------------------------------------------
# Overrides of pbItemBall and pbReceiveItem
#-------------------------------------------------------------------------------
# Picking up an item found on the ground
#-------------------------------------------------------------------------------
def pbItemBall(item, quantity = 1)
item = getID(PBItems,item)
return false if !item || item<=0 || quantity<1
itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
pocket = pbGetPocket(item)
meName = (pbIsKeyItem?(item)) ? "Key item get" : "Item get"
if isConst?(item, PBItems, :LEFTOVERS)
pbMessage(_INTL("\\me[{1}]You found some \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname))
elsif pbIsMachine?(item) # TM or HM
pbMessage(_INTL("\\me[{1}]You found \\c[1]{2} {3}\\c[0]!\\wtnp[30]", meName, itemname, PBMoves.getName(pbGetMachine(item))))
elsif quantity > 1
pbMessage(_INTL("\\me[{1}]You found {2} \\c[1]{3}\\c[0]!\\wtnp[30]", meName, quantity, itemname))
elsif ["a", "e", "i", "o", "u"].include?(itemname[0, 1].downcase)
pbMessage(_INTL("\\me[{1}]You found an \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname))
else
pbMessage(_INTL("\\me[{1}]You found a \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname))
end
if $PokemonBag.pbStoreItem(item, quantity) # If item can be picked up
pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
itemname, pocket, PokemonBag.pocketNames()[pocket]))
$game_player.addFoundItem(item)
return true
else
pbMessage(_INTL("But your Bag is full..."))
return false
end
end
#-------------------------------------------------------------------------------
# Being given an item
#-------------------------------------------------------------------------------
def pbReceiveItem(item, quantity = 1)
item = getID(PBItems,item)
return false if !item || item<=0 || quantity<1
itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
pocket = pbGetPocket(item)
meName = (pbIsKeyItem?(item)) ? "Key item get" : "Item get"
if isConst?(item, PBItems, :LEFTOVERS)
pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname))
elsif pbIsMachine?(item) # TM or HM
pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]", meName, itemname, PBMoves.getName(pbGetMachine(item))))
elsif quantity > 1
pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]", meName, quantity, itemname))
elsif ["a", "e", "i", "o", "u"].include?(itemname[0, 1].downcase)
pbMessage(_INTL("\\me[{1}]You obtained an \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname))
else
pbMessage(_INTL("\\me[{1}]You obtained a \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname))
end
if $PokemonBag.pbStoreItem(item, quantity) # If item can be added
pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
itemname, pocket, PokemonBag.pocketNames()[pocket]))
$game_player.addFoundItem(item)
return true
end
return false # Can't add the item
end
To add support for Berry Plants, search for this line in
PField_BerryPlants
: pocket = pbGetPocket(berry)
And ABOVE both instances, add this line:
$game_player.addFoundItem(berry)
Essentials v17 (No longer actively supported)
Ruby:
# ========================================================================
# Item Find
# v1.0
# By Boonzeet
# ========================================================================
# A script to show a helpful message with item name, icon and description
# when an item is found for the first time.
# ========================================================================
WINDOWSKIN_NAME = "" # set for custom windowskin
# Base Class
class PokemonItemFind_Scene
def pbStartScene
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
@sprites["background"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, Graphics.width, 0, @viewport)
@sprites["background"].z = @viewport.z - 1
@sprites["background"].visible = false
if WINDOWSKIN_NAME != ""
@sprites["background"].setSkin("Graphics/Windowskins/" + WINDOWSKIN_NAME)
end
@sprites["itemicon"] = ItemIconSprite.new(42, Graphics.height - 48, -1, @viewport)
@sprites["itemicon"].visible = false
@sprites["itemicon"].z = @viewport.z + 2
@sprites["descwindow"] = Window_UnformattedTextPokemon.newWithSize("", 64, 0, Graphics.width - 64, 64, @viewport)
@sprites["descwindow"].windowskin = nil
@sprites["descwindow"].z = @viewport.z
@sprites["descwindow"].visible = false
@sprites["titlewindow"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 128, 16, @viewport)
@sprites["titlewindow"].visible = false
@sprites["titlewindow"].z = @viewport.z + 1
if WINDOWSKIN_NAME != ""
@sprites["titlewindow"].setSkin("Graphics/Windowskins/" + WINDOWSKIN_NAME)
end
end
def pbShow(item)
name = PBItems.getName(item)
description = pbGetMessage(MessageTypes::ItemDescriptions, item)
descwindow = @sprites["descwindow"]
# descwindow.baseColor = Color.new(255, 255, 255) # set if dark windowskin
descwindow.resizeToFit(description, Graphics.width - 64)
descwindow.text = description
descwindow.y = Graphics.height - descwindow.height
descwindow.visible = true
titlewindow = @sprites["titlewindow"]
# titlewindow.baseColor = Color.new(255, 255, 255) # set if dark windowskin
titlewindow.resizeToFit(name, Graphics.height)
titlewindow.text = name
titlewindow.y = Graphics.height - descwindow.height - 46#32
titlewindow.visible = true
background = @sprites["background"]
background.height = descwindow.height# + 32
background.y = Graphics.height - background.height
background.visible = true
itemicon = @sprites["itemicon"]
itemicon.item = item
itemicon.y = Graphics.height - (descwindow.height / 2).floor
itemicon.visible = true
loop do
background.update
itemicon.update
descwindow.update
titlewindow.update
Graphics.update
Input.update
pbUpdateSceneMap
if Input.trigger?(Input::B) || Input.trigger?(Input::C)
pbEndScene
break
end
end
end
def pbEndScene
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end
# Game Player changes
# ---
# Adds a list of found items to the Game Player which is maintained over saves
class Game_Player
alias initialize_itemfind initialize
def initialize(*args)
@found_items = []
initialize_itemfind(*args)
end
def addFoundItem(item)
if !defined?(@found_items)
@found_items = []
end
if !@found_items.include?(item)
@found_items.push(item)
scene = PokemonItemFind_Scene.new
scene.pbStartScene
scene.pbShow(item)
end
end
end
# Overrides of pbItemBall and pbReceiveItem
#===============================================================================
# Picking up an item found on the ground
#===============================================================================
def Kernel.pbItemBall(item, quantity = 1)
if item.is_a?(String) || item.is_a?(Symbol)
item = getID(PBItems, item)
end
return false if !item || item <= 0 || quantity < 1
itemname = (quantity > 1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
pocket = pbGetPocket(item)
if isConst?(item, PBItems, :LEFTOVERS)
Kernel.pbMessage(_INTL("\\me[Item get]You found some \\c[1]{1}\\c[0]!\\wtnp[30]", itemname))
elsif pbIsMachine?(item) # TM or HM
Kernel.pbMessage(_INTL("\\me[Item get]You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]", itemname, PBMoves.getName(pbGetMachine(item))))
elsif quantity > 1
Kernel.pbMessage(_INTL("\\me[Item get]You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]", quantity, itemname))
elsif ["a", "e", "i", "o", "u"].include?(itemname[0, 1].downcase)
Kernel.pbMessage(_INTL("\\me[Item get]You found an \\c[1]{1}\\c[0]!\\wtnp[30]", itemname))
else
Kernel.pbMessage(_INTL("\\me[Item get]You found a \\c[1]{1}\\c[0]!\\wtnp[30]", itemname))
end
if $PokemonBag.pbStoreItem(item, quantity) # If item can be picked up
Kernel.pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
itemname, pocket, PokemonBag.pocketNames()[pocket]))
$game_player.addFoundItem(item)
return true
else
Kernel.pbMessage(_INTL("But your Bag is full..."))
return false
end
end
#===============================================================================
# Being given an item
#===============================================================================
def Kernel.pbReceiveItem(item, quantity = 1)
if item.is_a?(String) || item.is_a?(Symbol)
item = getID(PBItems, item)
end
return false if !item || item <= 0 || quantity < 1
itemname = (quantity > 1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
pocket = pbGetPocket(item)
if isConst?(item, PBItems, :LEFTOVERS)
Kernel.pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]", itemname))
elsif pbIsMachine?(item) # TM or HM
Kernel.pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]", itemname, PBMoves.getName(pbGetMachine(item))))
elsif quantity > 1
Kernel.pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]", quantity, itemname))
elsif ["a", "e", "i", "o", "u"].include?(itemname[0, 1].downcase)
Kernel.pbMessage(_INTL("\\me[Item get]You obtained an \\c[1]{1}\\c[0]!\\wtnp[30]", itemname))
else
Kernel.pbMessage(_INTL("\\me[Item get]You obtained a \\c[1]{1}\\c[0]!\\wtnp[30]", itemname))
end
if $PokemonBag.pbStoreItem(item, quantity) # If item can be added
Kernel.pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
itemname, pocket, PokemonBag.pocketNames()[pocket]))
$game_player.addFoundItem(item)
return true
end
return false # Can't add the item
end
If using FollowingPokemon, replace all of
def Kernel.pbPokemonFound
with this (contains other fixes and improvements):
Code:
def Kernel.pbPokemonFound(item, quantity = 1)
itemname = (quantity > 1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
pocket = pbGetPocket(item)
pokename = $Trainer.party[0].name
pbWait(5)
if isConst?(item, PBItems, :LEFTOVERS)
Kernel.pbMessage(_INTL("\\me[Item get]{1} found some \\c[1]{2}\\c[0]!\\wt[30]", pokename, itemname))
elsif pbIsMachine?(item) # TM or HM
Kernel.pbMessage(_INTL("\\me[Item get]{1} found \\c[1]{2} {3}\\c[0]!\\wt[30]", pokename, itemname,
PBMoves.getName(pbGetMachine(item))))
elsif quantity > 1
Kernel.pbMessage(_INTL("\\me[Item get]{1} found {2} \\c[1]{3}\\c[0]!\\wt[30]", pokename, quantity, itemname))
elsif ["a", "e", "i", "o", "u"].include?(itemname[0, 1].downcase)
Kernel.pbMessage(_INTL("\\me[Item get]{1} found an \\c[1]{2}\\c[0]!\\wt[30]", pokename, itemname))
else
Kernel.pbMessage(_INTL("\\me[Item get]{1} found a \\c[1]{2}\\c[0]!\\wt[30]", pokename, itemname))
end
if $PokemonBag.pbStoreItem(item, quantity)
Kernel.pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
itemname, pocket, PokemonBag.pocketNames()[pocket]))
$game_player.addFoundItem(item)
return true
else
Kernel.pbMessage(_INTL("But your Bag is full..."))
return false
end
end
- Credits
-
Boonzeet