Implemented usage of GameData::Item

This commit is contained in:
Maruno17
2020-11-08 22:45:59 +00:00
parent ff70791104
commit 1955d3698e
82 changed files with 1986 additions and 2195 deletions

View File

@@ -184,14 +184,14 @@ class PokemonPauseMenu
return
end
elsif cmdBag>=0 && command==cmdBag
item = 0
item = nil
pbFadeOutIn {
scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag)
item = screen.pbStartScreen
(item>0) ? @scene.pbEndScene : @scene.pbRefresh
(item) ? @scene.pbEndScene : @scene.pbRefresh
}
if item>0
if item
$game_temp.in_menu = false
pbUseKeyItemInField(item)
return

View File

@@ -642,25 +642,26 @@ class PokemonParty_Scene
end
def pbChooseItem(bag)
ret = 0
ret = nil
pbFadeOutIn {
scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,bag)
ret = screen.pbChooseItemScreen(Proc.new { |item| pbCanHoldItem?(item) })
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? })
yield if block_given?
}
return ret
end
def pbUseItem(bag,pokemon)
ret = 0
ret = nil
pbFadeOutIn {
scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,bag)
ret = screen.pbChooseItemScreen(Proc.new { |item|
next false if !pbCanUseOnPokemon?(item)
if pbIsMachine?(item)
move = pbGetMachine(item)
itm = GameData::Item.get(item)
next false if !pbCanUseOnPokemon?(itm)
if itm.is_machine?
move = itm.move
next false if pokemon.hasMove?(move) || !pokemon.compatibleWithMove?(move)
end
next true
@@ -1250,14 +1251,15 @@ class PokemonPartyScreen
itemcommands[cmdUseItem=itemcommands.length] = _INTL("Use")
itemcommands[cmdGiveItem=itemcommands.length] = _INTL("Give")
itemcommands[cmdTakeItem=itemcommands.length] = _INTL("Take") if pkmn.hasItem?
itemcommands[cmdMoveItem=itemcommands.length] = _INTL("Move") if pkmn.hasItem? && !pbIsMail?(pkmn.item)
itemcommands[cmdMoveItem=itemcommands.length] = _INTL("Move") if pkmn.hasItem? &&
!GameData::Item.get(pkmn.item).is_mail?
itemcommands[itemcommands.length] = _INTL("Cancel")
command = @scene.pbShowCommands(_INTL("Do what with an item?"),itemcommands)
if cmdUseItem>=0 && command==cmdUseItem # Use
item = @scene.pbUseItem($PokemonBag,pkmn) {
@scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
}
if item>0
if item
pbUseItemOnPokemon(item,pkmn,self)
pbRefreshSingle(pkmnid)
end
@@ -1265,7 +1267,7 @@ class PokemonPartyScreen
item = @scene.pbChooseItem($PokemonBag) {
@scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
}
if item>0
if item
if pbGiveItemToPokemon(item,pkmn,self,pkmnid)
pbRefreshSingle(pkmnid)
end
@@ -1276,7 +1278,7 @@ class PokemonPartyScreen
end
elsif cmdMoveItem>=0 && command==cmdMoveItem # Move
item = pkmn.item
itemname = PBItems.getName(item)
itemname = item.name
@scene.pbSetHelpText(_INTL("Move {1} to where?",itemname))
oldpkmnid = pkmnid
loop do
@@ -1284,23 +1286,22 @@ class PokemonPartyScreen
pkmnid = @scene.pbChoosePokemon(true,pkmnid)
break if pkmnid<0
newpkmn = @party[pkmnid]
if pkmnid==oldpkmnid
break
elsif newpkmn.egg?
break if pkmnid==oldpkmnid
if newpkmn.egg?
pbDisplay(_INTL("Eggs can't hold items."))
elsif !newpkmn.hasItem?
newpkmn.setItem(item)
pkmn.setItem(0)
pkmn.setItem(nil)
@scene.pbClearSwitching
pbRefresh
pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname))
break
elsif pbIsMail?(newpkmn.item)
elsif GameData::Item.get(newpkmn.item).is_mail?
pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.",newpkmn.name))
else
newitem = newpkmn.item
newitemname = PBItems.getName(newitem)
if isConst?(newitem,PBItems,:LEFTOVERS)
newitemname = newitem.name
if newitem == :LEFTOVERS
pbDisplay(_INTL("{1} is already holding some {2}.\1",newpkmn.name,newitemname))
elsif newitemname.starts_with_vowel?
pbDisplay(_INTL("{1} is already holding an {2}.\1",newpkmn.name,newitemname))

View File

@@ -123,7 +123,7 @@ class PokemonSummary_Scene
@sprites["pokeicon"].x = 46
@sprites["pokeicon"].y = 92
@sprites["pokeicon"].visible = false
@sprites["itemicon"] = ItemIconSprite.new(30,320,@pokemon.item,@viewport)
@sprites["itemicon"] = ItemIconSprite.new(30,320,@pokemon.item_id,@viewport)
@sprites["itemicon"].blankzero = true
@sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
pbSetSystemFont(@sprites["overlay"].bitmap)
@@ -287,7 +287,7 @@ class PokemonSummary_Scene
if @pokemon.egg?
drawPageOneEgg; return
end
@sprites["itemicon"].item = @pokemon.item
@sprites["itemicon"].item = @pokemon.item_id
overlay = @sprites["overlay"].bitmap
overlay.clear
base = Color.new(248,248,248)
@@ -330,7 +330,7 @@ class PokemonSummary_Scene
]
# Write the held item's name
if @pokemon.hasItem?
textpos.push([PBItems.getName(@pokemon.item),16,352,0,Color.new(64,64,64),Color.new(176,176,176)])
textpos.push([@pokemon.item.name,16,352,0,Color.new(64,64,64),Color.new(176,176,176)])
else
textpos.push([_INTL("None"),16,352,0,Color.new(192,200,208),Color.new(208,216,224)])
end
@@ -454,7 +454,7 @@ class PokemonSummary_Scene
end
def drawPageOneEgg
@sprites["itemicon"].item = @pokemon.item
@sprites["itemicon"].item = @pokemon.item_id
overlay = @sprites["overlay"].bitmap
overlay.clear
base = Color.new(248,248,248)
@@ -475,7 +475,7 @@ class PokemonSummary_Scene
]
# Write the held item's name
if @pokemon.hasItem?
textpos.push([PBItems.getName(@pokemon.item),16,352,0,Color.new(64,64,64),Color.new(176,176,176)])
textpos.push([@pokemon.item.name,16,352,0,Color.new(64,64,64),Color.new(176,176,176)])
else
textpos.push([_INTL("None"),16,352,0,Color.new(192,200,208),Color.new(208,216,224)])
end
@@ -892,7 +892,7 @@ class PokemonSummary_Scene
def pbChangePokemon
@pokemon = @party[@partyindex]
@sprites["pokemon"].setPokemonBitmap(@pokemon)
@sprites["itemicon"].item = @pokemon.item
@sprites["itemicon"].item = @pokemon.item_id
pbSEStop
pbPlayCry(@pokemon)
end
@@ -1169,13 +1169,13 @@ class PokemonSummary_Scene
commands[commands.length] = _INTL("Cancel")
command = pbShowCommands(commands)
if cmdGiveItem>=0 && command==cmdGiveItem
item = 0
item = nil
pbFadeOutIn {
scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag)
item = screen.pbChooseItemScreen(Proc.new { |itm| pbCanHoldItem?(itm) })
item = screen.pbChooseItemScreen(Proc.new { |itm| GameData::Item.get(itm).can_hold? })
}
if item>0
if item
dorefresh = pbGiveItemToPokemon(item,@pokemon,self,@partyindex)
end
elsif cmdTakeItem>=0 && command==cmdTakeItem

View File

@@ -29,10 +29,10 @@ class Window_PokemonBag < Window_DrawableCommand
def page_item_max; return PokemonBag_Scene::ITEMSVISIBLE; end
def item
return 0 if @filterlist && !@filterlist[@pocket][self.index]
return nil if @filterlist && !@filterlist[@pocket][self.index]
thispocket = @bag.pockets[@pocket]
item = (@filterlist) ? thispocket[@filterlist[@pocket][self.index]] : thispocket[self.index]
return (item) ? item[0] : 0
return (item) ? item[0] : nil
end
def itemCount
@@ -76,13 +76,7 @@ class Window_PokemonBag < Window_DrawableCommand
textpos.push(
[@adapter.getDisplayName(item),rect.x,ypos,false,baseColor,shadowColor]
)
if !pbIsImportantItem?(item) # Not a Key item or HM (or infinite TM)
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
qtytext = _ISPRINTF("x{1: 3d}",qty)
xQty = rect.x+rect.width-self.contents.text_size(qtytext).width-16
textpos.push([qtytext,xQty,ypos,false,baseColor,shadowColor])
end
if pbIsImportantItem?(item)
if GameData::Item.get(item).is_important?
if @bag.pbIsRegistered?(item)
pbDrawImagePositions(self.contents,[
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,ypos+4,0,0,-1,24]
@@ -92,6 +86,11 @@ class Window_PokemonBag < Window_DrawableCommand
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,ypos+4,0,24,-1,24]
])
end
else
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
qtytext = _ISPRINTF("x{1: 3d}",qty)
xQty = rect.x+rect.width-self.contents.text_size(qtytext).width-16
textpos.push([qtytext,xQty,ypos,false,baseColor,shadowColor])
end
end
pbDrawTextPositions(self.contents,textpos)
@@ -195,7 +194,7 @@ class PokemonBag_Scene
@sprites["itemlist"].index = @bag.getChoice(lastpocket)
@sprites["itemlist"].baseColor = ITEMLISTBASECOLOR
@sprites["itemlist"].shadowColor = ITEMLISTSHADOWCOLOR
@sprites["itemicon"] = ItemIconSprite.new(48,Graphics.height-48,-1,@viewport)
@sprites["itemicon"] = ItemIconSprite.new(48,Graphics.height-48,nil,@viewport)
@sprites["itemtext"] = Window_UnformattedTextPokemon.new("")
@sprites["itemtext"].x = 72
@sprites["itemtext"].y = 270
@@ -318,8 +317,9 @@ class PokemonBag_Scene
# Set the selected item's icon
@sprites["itemicon"].item = itemlist.item
# Set the selected item's description
@sprites["itemtext"].text = (itemlist.item==0) ? _INTL("Close bag.") :
pbGetMessage(MessageTypes::ItemDescriptions,itemlist.item)
@sprites["itemtext"].text =
(itemlist.item) ? GameData::Item.get(itemlist.item).description : _INTL("Close bag.")
end
def pbRefreshFilter
@@ -379,8 +379,10 @@ class PokemonBag_Scene
loop do
newpocket = (newpocket==1) ? PokemonBag.numPockets : newpocket-1
break if !@choosing || newpocket==itemwindow.pocket
if @filterlist; break if @filterlist[newpocket].length>0
else; break if @bag.pockets[newpocket].length>0
if @filterlist
break if @filterlist[newpocket].length>0
else
break if @bag.pockets[newpocket].length>0
end
end
if itemwindow.pocket!=newpocket
@@ -395,8 +397,10 @@ class PokemonBag_Scene
loop do
newpocket = (newpocket==PokemonBag.numPockets) ? 1 : newpocket+1
break if !@choosing || newpocket==itemwindow.pocket
if @filterlist; break if @filterlist[newpocket].length>0
else; break if @bag.pockets[newpocket].length>0
if @filterlist
break if @filterlist[newpocket].length>0
else
break if @bag.pockets[newpocket].length>0
end
end
if itemwindow.pocket!=newpocket
@@ -428,9 +432,9 @@ class PokemonBag_Scene
end
elsif Input.trigger?(Input::B) # Cancel the item screen
pbPlayCloseMenuSE
return 0
return nil
elsif Input.trigger?(Input::C) # Choose selected item
(itemwindow.item==0) ? pbPlayCloseMenuSE : pbPlayDecisionSE
(itemwindow.item) ? pbPlayDecisionSE : pbPlayCloseMenuSE
return itemwindow.item
end
end
@@ -452,10 +456,11 @@ class PokemonBagScreen
def pbStartScreen
@scene.pbStartScene(@bag)
item = 0
item = nil
loop do
item = @scene.pbChooseItem
break if item==0
break if !item
itm = GameData::Item.get(item)
cmdRead = -1
cmdUse = -1
cmdRegister = -1
@@ -464,16 +469,16 @@ class PokemonBagScreen
cmdDebug = -1
commands = []
# Generate command list
commands[cmdRead = commands.length] = _INTL("Read") if pbIsMail?(item)
if ItemHandlers.hasOutHandler(item) || (pbIsMachine?(item) && $Trainer.party.length>0)
commands[cmdRead = commands.length] = _INTL("Read") if itm.is_mail?
if ItemHandlers.hasOutHandler(item) || (itm.is_machine? && $Trainer.party.length>0)
if ItemHandlers.hasUseText(item)
commands[cmdUse = commands.length] = ItemHandlers.getUseText(item)
else
commands[cmdUse = commands.length] = _INTL("Use")
end
end
commands[cmdGive = commands.length] = _INTL("Give") if $Trainer.pokemonParty.length>0 && pbCanHoldItem?(item)
commands[cmdToss = commands.length] = _INTL("Toss") if !pbIsImportantItem?(item) || $DEBUG
commands[cmdGive = commands.length] = _INTL("Give") if $Trainer.pokemonParty.length>0 && itm.can_hold?
commands[cmdToss = commands.length] = _INTL("Toss") if !itm.is_important? || $DEBUG
if @bag.pbIsRegistered?(item)
commands[cmdRegister = commands.length] = _INTL("Deselect")
elsif pbCanRegisterItem?(item)
@@ -482,7 +487,7 @@ class PokemonBagScreen
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
commands[commands.length] = _INTL("Cancel")
# Show commands generated above
itemname = PBItems.getName(item)
itemname = itm.name
command = @scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
if cmdRead>=0 && command==cmdRead # Read mail
pbFadeOutIn {
@@ -497,7 +502,7 @@ class PokemonBagScreen
elsif cmdGive>=0 && command==cmdGive # Give item to Pokémon
if $Trainer.pokemonCount==0
@scene.pbDisplay(_INTL("There is no Pokémon."))
elsif pbIsImportantItem?(item)
elsif itm.is_important?
@scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
else
pbFadeOutIn {
@@ -510,11 +515,11 @@ class PokemonBagScreen
elsif cmdToss>=0 && command==cmdToss # Toss item
qty = @bag.pbQuantity(item)
if qty>1
helptext = _INTL("Toss out how many {1}?",PBItems.getNamePlural(item))
helptext = _INTL("Toss out how many {1}?",itm.name_plural)
qty = @scene.pbChooseNumber(helptext,qty)
end
if qty>0
itemname = PBItems.getNamePlural(item) if qty>1
itemname = itm.name_plural if qty>1
if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname))
pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname))
qty.times { @bag.pbDeleteItem(item) }
@@ -543,7 +548,7 @@ class PokemonBagScreen
### Change quantity ###
when 0
qty = @bag.pbQuantity(item)
itemplural = PBItems.getNamePlural(item)
itemplural = itm.name_plural
params = ChooseNumberParams.new
params.setRange(0,BAG_MAX_PER_SLOT)
params.setDefaultValue(qty)
@@ -596,9 +601,10 @@ class PokemonBagScreen
@scene.pbStartScene(storage)
loop do
item = @scene.pbChooseItem
break if item==0
break if !item
itm = GameData::Item.get(item)
qty = storage.pbQuantity(item)
if qty>1 && !pbIsImportantItem?(item)
if qty>1 && !itm.is_important?
qty = @scene.pbChooseNumber(_INTL("How many do you want to withdraw?"),qty)
end
next if qty<=0
@@ -610,8 +616,8 @@ class PokemonBagScreen
raise "Can't withdraw items from storage"
end
@scene.pbRefresh
dispqty = (pbIsImportantItem?(item)) ? 1 : qty
itemname = (dispqty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
dispqty = (itm.is_important?) ? 1 : qty
itemname = (dispqty>1) ? itm.name_plural : itm.name
pbDisplay(_INTL("Withdrew {1} {2}.",dispqty,itemname))
else
pbDisplay(_INTL("There's no more room in the Bag."))
@@ -627,12 +633,12 @@ class PokemonBagScreen
$PokemonGlobal.pcItemStorage = PCItemStorage.new
end
storage = $PokemonGlobal.pcItemStorage
item = 0
loop do
item = @scene.pbChooseItem
break if item==0
break if !item
itm = GameData::Item.get(item)
qty = @bag.pbQuantity(item)
if qty>1 && !pbIsImportantItem?(item)
if qty>1 && !itm.is_important?
qty = @scene.pbChooseNumber(_INTL("How many do you want to deposit?"),qty)
end
if qty>0
@@ -646,8 +652,8 @@ class PokemonBagScreen
raise "Can't deposit items to storage"
end
@scene.pbRefresh
dispqty = (pbIsImportantItem?(item)) ? 1 : qty
itemname = (dispqty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
dispqty = (itm.is_important?) ? 1 : qty
itemname = (dispqty>1) ? itm.name_plural : itm.name
pbDisplay(_INTL("Deposited {1} {2}.",dispqty,itemname))
end
end
@@ -664,14 +670,15 @@ class PokemonBagScreen
@scene.pbStartScene(storage)
loop do
item = @scene.pbChooseItem
break if item==0
if pbIsImportantItem?(item)
break if !item
itm = GameData::Item.get(item)
if itm.is_important?
@scene.pbDisplay(_INTL("That's too important to toss out!"))
next
end
qty = storage.pbQuantity(item)
itemname = PBItems.getName(item)
itemnameplural = PBItems.getNamePlural(item)
itemname = itm.name
itemnameplural = itm.name_plural
if qty>1
qty=@scene.pbChooseNumber(_INTL("Toss out how many {1}?",itemnameplural),qty)
end

View File

@@ -268,7 +268,6 @@ class PokemonLoadScreen
$scene = nil
return
end
PokemonData::Ability.load
commands = []
cmdContinue = -1
cmdNewGame = -1

View File

@@ -66,12 +66,12 @@ class ReadyMenuButton < SpriteWrapper
self.bitmap.clear
rect = Rect.new(0,(sel) ? @button.height/2 : 0,@button.width,@button.height/2)
self.bitmap.blt(0,0,@button.bitmap,rect)
textx = (@command[2]) ? 164 : (pbIsImportantItem?(@command[0])) ? 146 : 124
textx = (@command[2]) ? 164 : (GameData::Item.get(@command[0]).is_important?) ? 146 : 124
textpos = [
[@command[1],textx,18,2,Color.new(248,248,248),Color.new(40,40,40),1],
]
if !@command[2]
if !pbIsImportantItem?(@command[0])
if !GameData::Item.get(@command[0]).is_important?
qty = $PokemonBag.pbQuantity(@command[0])
if qty>99
textpos.push([_INTL(">99"),230,18,1,
@@ -236,11 +236,11 @@ class PokemonReadyMenu
def pbStartReadyMenu(moves,items)
commands = [[],[]] # Moves, items
for i in moves
commands[0].push([i[0],PBMoves.getName(i[0]),true,i[1]])
commands[0].push([i[0], PBMoves.getName(i[0]), true, i[1]])
end
commands[0].sort! { |a,b| a[1]<=>b[1] }
for i in items
commands[1].push([i,PBItems.getName(i),false])
commands[1].push([i, GameData::Item.get(i).name, false])
end
commands[1].sort! { |a,b| a[1]<=>b[1] }
@scene.pbStartScene(commands)
@@ -296,9 +296,9 @@ end
# Using a registered item
#===============================================================================
def pbUseKeyItem
moves = [:CUT,:DEFOG,:DIG,:DIVE,:FLASH,:FLY,:HEADBUTT,:ROCKCLIMB,:ROCKSMASH,
:SECRETPOWER,:STRENGTH,:SURF,:SWEETSCENT,:TELEPORT,:WATERFALL,
:WHIRLPOOL]
moves = [:CUT, :DEFOG, :DIG, :DIVE, :FLASH, :FLY, :HEADBUTT, :ROCKCLIMB,
:ROCKSMASH, :SECRETPOWER, :STRENGTH, :SURF, :SWEETSCENT, :TELEPORT,
:WATERFALL, :WHIRLPOOL]
realmoves = []
for i in moves
move = getID(PBMoves,i)
@@ -312,7 +312,8 @@ def pbUseKeyItem
end
realitems = []
for i in $PokemonBag.registeredItems
realitems.push(i) if $PokemonBag.pbHasItem?(i)
itm = GameData::Item.get(i).id
realitems.push(itm) if $PokemonBag.pbHasItem?(itm)
end
if realitems.length==0 && realmoves.length==0
pbMessage(_INTL("An item in the Bag can be registered to this key for instant use."))

View File

@@ -1205,11 +1205,11 @@ class PokemonStorageScene
end
def pbChooseItem(bag)
ret = 0
ret = nil
pbFadeOutIn {
scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,bag)
ret = screen.pbChooseItemScreen(Proc.new { |item| pbCanHoldItem?(item) })
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? })
}
return ret
end
@@ -1415,14 +1415,13 @@ class PokemonStorageScene
end
imagepos.push(["Graphics/Pictures/Storage/overlay_lv",6,246])
textstrings.push([pokemon.level.to_s,28,234,false,base,shadow])
ability = pokemon.ability
if ability
textstrings.push([ability.name,86,306,2,base,shadow])
if pokemon.ability
textstrings.push([pokemon.ability.name,86,306,2,base,shadow])
else
textstrings.push([_INTL("No ability"),86,306,2,nonbase,nonshadow])
end
if pokemon.item>0
textstrings.push([PBItems.getName(pokemon.item),86,342,2,base,shadow])
if pokemon.item
textstrings.push([pokemon.item.name,86,342,2,base,shadow])
else
textstrings.push([_INTL("No item"),86,342,2,nonbase,nonshadow])
end
@@ -1869,21 +1868,21 @@ class PokemonStorageScreen
pbDisplay(_INTL("Please remove the mail."))
return
end
if pokemon.item>0
itemname = PBItems.getName(pokemon.item)
if pokemon.item
itemname = pokemon.item.name
if pbConfirm(_INTL("Take this {1}?",itemname))
if !$PokemonBag.pbStoreItem(pokemon.item)
pbDisplay(_INTL("Can't store the {1}.",itemname))
else
pbDisplay(_INTL("Took the {1}.",itemname))
pokemon.setItem(0)
pokemon.setItem(nil)
@scene.pbHardRefresh
end
end
else
item = scene.pbChooseItem($PokemonBag)
if item>0
itemname = PBItems.getName(item)
if item
itemname = GameData::Item.get(item).name
pokemon.setItem(item)
$PokemonBag.pbDeleteItem(item)
pbDisplay(_INTL("{1} is now being held.",itemname))

View File

@@ -18,7 +18,7 @@ class Window_PokemonItemStorage < Window_DrawableCommand
def item
item = @bag[self.index]
return item ? item[0] : 0
return item ? item[0] : nil
end
def itemCount
@@ -34,12 +34,12 @@ class Window_PokemonItemStorage < Window_DrawableCommand
else
item = @bag[index][0]
itemname = @adapter.getDisplayName(item)
qty = _ISPRINTF("x{1: 2d}",@bag[index][1])
sizeQty = self.contents.text_size(qty).width
xQty = rect.x+rect.width-sizeQty-2
baseColor = (index==@sortIndex) ? Color.new(248,24,24) : self.baseColor
textpos.push([itemname,rect.x,ypos,false,self.baseColor,self.shadowColor])
if !pbIsImportantItem?(item) # Not a Key item or HM (or infinite TM)
if !GameData::Item.get(item).is_important? # Not a Key item or HM (or infinite TM)
qty = _ISPRINTF("x{1: 2d}",@bag[index][1])
sizeQty = self.contents.text_size(qty).width
xQty = rect.x+rect.width-sizeQty-2
textpos.push([qty,xQty,ypos,false,baseColor,self.shadowColor])
end
end
@@ -73,7 +73,7 @@ class ItemStorage_Scene
@sprites = {}
@sprites["background"] = IconSprite.new(0,0,@viewport)
@sprites["background"].setBitmap("Graphics/Pictures/pcItembg")
@sprites["icon"] = ItemIconSprite.new(50,334,-1,@viewport)
@sprites["icon"] = ItemIconSprite.new(50,334,nil,@viewport)
# Item list
@sprites["itemwindow"] = Window_PokemonItemStorage.new(@bag,98,14,334,32+ITEMSVISIBLE*32)
@sprites["itemwindow"].viewport = @viewport
@@ -134,10 +134,10 @@ class ItemStorage_Scene
# Draw item icon
@sprites["icon"].item = itemwindow.item
# Get item description
if itemwindow.item==0
@sprites["itemtextwindow"].text = _INTL("Close storage.")
if itemwindow.item
@sprites["itemtextwindow"].text = GameData::Item.get(itemwindow.item).description
else
@sprites["itemtextwindow"].text = pbGetMessage(MessageTypes::ItemDescriptions,itemwindow.item)
@sprites["itemtextwindow"].text = _INTL("Close storage.")
end
itemwindow.refresh
end
@@ -155,13 +155,13 @@ class ItemStorage_Scene
self.update
pbRefresh if itemwindow.item!=olditem
if Input.trigger?(Input::B)
return 0
return nil
elsif Input.trigger?(Input::C)
if itemwindow.index<@bag.length
pbRefresh
return @bag[itemwindow.index][0]
else
return 0
return nil
end
end
end
@@ -258,10 +258,10 @@ module UIHelper
(block_given?) ? yield : dw.update
if !dw.busy? && dw.resume
if Input.trigger?(Input::B)
pbPlayCancelSE()
pbPlayCancelSE
break
elsif Input.trigger?(Input::C)
pbPlayDecisionSE()
pbPlayDecisionSE
ret = (cw.index==0)
break
end
@@ -294,32 +294,32 @@ module UIHelper
(block_given?) ? yield : helpwindow.update
if Input.trigger?(Input::B)
ret = 0
pbPlayCancelSE()
pbPlayCancelSE
break
elsif Input.trigger?(Input::C)
ret = curnumber
pbPlayDecisionSE()
pbPlayDecisionSE
break
elsif Input.repeat?(Input::UP)
curnumber += 1
curnumber = 1 if curnumber>maximum
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
pbPlayCursorSE()
pbPlayCursorSE
elsif Input.repeat?(Input::DOWN)
curnumber -= 1
curnumber = maximum if curnumber<1
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
pbPlayCursorSE()
pbPlayCursorSE
elsif Input.repeat?(Input::LEFT)
curnumber -= 10
curnumber = 1 if curnumber<1
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
pbPlayCursorSE()
pbPlayCursorSE
elsif Input.repeat?(Input::RIGHT)
curnumber += 10
curnumber = maximum if curnumber>maximum
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
pbPlayCursorSE()
pbPlayCursorSE
end
end
}
@@ -347,12 +347,12 @@ module UIHelper
cmdwindow.update
if Input.trigger?(Input::B)
ret = -1
pbPlayCancelSE()
pbPlayCancelSE
break
end
if Input.trigger?(Input::C)
ret = cmdwindow.index
pbPlayDecisionSE()
pbPlayDecisionSE
break
end
end

View File

@@ -614,7 +614,7 @@ class PokemonEvolutionScene
new_pkmn.name = PBSpecies.getName(new_species)
new_pkmn.markings = 0
new_pkmn.ballused = 0
new_pkmn.setItem(0)
new_pkmn.setItem(nil)
new_pkmn.clearAllRibbons
new_pkmn.calcStats
new_pkmn.heal

View File

@@ -18,21 +18,21 @@ class PokemonMartAdapter
return $PokemonBag
end
def getDisplayName(item)
itemname = PBItems.getName(item)
if pbIsMachine?(item)
machine = pbGetMachine(item)
itemname = _INTL("{1} {2}",itemname,PBMoves.getName(machine))
end
return itemname
def getName(item)
return GameData::Item.get(item).name
end
def getName(item)
return PBItems.getName(item)
def getDisplayName(item)
item_name = getName(item)
if GameData::Item.get(item).is_machine?
machine = GameData::Item.get(item).move
item_name = _INTL("{1} {2}", item_name, PBMoves.getName(machine))
end
return item_name
end
def getDescription(item)
return pbGetMessage(MessageTypes::ItemDescriptions,item)
return GameData::Item.get(item).description
end
def getItemIcon(item)
@@ -40,8 +40,9 @@ class PokemonMartAdapter
return pbItemIconFile(item)
end
# Unused
def getItemIconRect(_item)
return Rect.new(0,0,48,48)
return Rect.new(0, 0, 48, 48)
end
def getQuantity(item)
@@ -49,27 +50,27 @@ class PokemonMartAdapter
end
def showQuantity?(item)
return !pbIsImportantItem?(item)
return !GameData::Item.get(item).is_important?
end
def getPrice(item,selling=false)
def getPrice(item, selling = false)
if $game_temp.mart_prices && $game_temp.mart_prices[item]
if selling
return $game_temp.mart_prices[item][1] if $game_temp.mart_prices[item][1]>=0
return $game_temp.mart_prices[item][1] if $game_temp.mart_prices[item][1] >= 0
else
return $game_temp.mart_prices[item][0] if $game_temp.mart_prices[item][0]>0
return $game_temp.mart_prices[item][0] if $game_temp.mart_prices[item][0] > 0
end
end
return pbGetPrice(item)
return GameData::Item.get(item).price
end
def getDisplayPrice(item,selling=false)
price = getPrice(item,selling).to_s_formatted
return _INTL("$ {1}",price)
def getDisplayPrice(item, selling = false)
price = getPrice(item, selling).to_s_formatted
return _INTL("$ {1}", price)
end
def canSell?(item)
return (getPrice(item,true)>0 && !pbIsImportantItem?(item))
return getPrice(item, true) > 0 && !GameData::Item.get(item).is_important?
end
def addItem(item)
@@ -101,32 +102,31 @@ class RpgxpMartAdapter
$game_party.gain_gold(value)
end
def getPrice(item,_selling=false)
def getPrice(item, _selling = false)
return item.price
end
def getItemIcon(item)
return nil if !item
if item==0
if item == 0
return sprintf("Graphics/Icons/itemBack")
elsif item.respond_to?("icon_index")
return "Graphics/System/IconSet"
else
return sprintf("Graphics/Icons/%s",item.icon_name)
return sprintf("Graphics/Icons/%s", item.icon_name)
end
end
def getItemIconRect(item)
if item && item.respond_to?("icon_index")
ix=item.icon_index % 16 * 24
iy=item.icon_index / 16 * 24
return Rect.new(ix,iy,24,24)
else
return Rect.new(0,0,32,32)
ix = item.icon_index % 16 * 24
iy = item.icon_index / 16 * 24
return Rect.new(ix, iy, 24, 24)
end
return Rect.new(0, 0, 32, 32)
end
def getInventory()
def getInventory
data = []
for i in 1...$data_items.size
data.push($data_items[i]) if getQuantity($data_items[i]) > 0
@@ -141,7 +141,7 @@ class RpgxpMartAdapter
end
def canSell?(item)
return item ? item.price>0 : false
return item ? item.price > 0 : false
end
def getName(item)
@@ -152,17 +152,17 @@ class RpgxpMartAdapter
return item ? item.name : ""
end
def getDisplayPrice(item,_selling=false)
price=item.price
return price.to_s
end
def getDescription(item)
return item ? item.description : ""
end
def getDisplayPrice(item, _selling = false)
price = item.price
return price.to_s
end
def addItem(item)
ret=(getQuantity(item)<99)
ret = (getQuantity(item) < 99)
if $game_party.respond_to?("gain_weapon")
case item
when RPG::Item
@@ -173,21 +173,21 @@ class RpgxpMartAdapter
$game_party.gain_armor(item.id, 1) if ret
end
else
$game_party.gain_item(item,1) if ret
$game_party.gain_item(item, 1) if ret
end
return ret
end
def getQuantity(item)
ret=0
ret = 0
if $game_party.respond_to?("weapon_number")
case item
when RPG::Item
ret=$game_party.item_number(item.id)
ret = $game_party.item_number(item.id)
when RPG::Weapon
ret=($game_party.weapon_number(item.id))
ret = ($game_party.weapon_number(item.id))
when RPG::Armor
ret=($game_party.armor_number(item.id))
ret = ($game_party.armor_number(item.id))
end
else
return $game_party.item_number(item)
@@ -200,7 +200,7 @@ class RpgxpMartAdapter
end
def removeItem(item)
ret=(getQuantity(item)>0)
ret = (getQuantity(item) > 0)
if $game_party.respond_to?("lose_weapon")
case item
when RPG::Item
@@ -211,7 +211,7 @@ class RpgxpMartAdapter
$game_party.lose_armor(item.id, 1) if ret
end
else
$game_party.lose_item(item,1) if ret
$game_party.lose_item(item, 1) if ret
end
return ret
end
@@ -223,7 +223,7 @@ end
#===============================================================================
class BuyAdapter
def initialize(adapter)
@adapter=adapter
@adapter = adapter
end
def getDisplayName(item)
@@ -231,7 +231,7 @@ class BuyAdapter
end
def getDisplayPrice(item)
@adapter.getDisplayPrice(item,false)
@adapter.getDisplayPrice(item, false)
end
def isSelling?
@@ -243,7 +243,7 @@ end
class SellAdapter
def initialize(adapter)
@adapter=adapter
@adapter = adapter
end
def getDisplayName(item)
@@ -252,7 +252,7 @@ class SellAdapter
def getDisplayPrice(item)
if @adapter.showQuantity?(item)
return sprintf("x%d",@adapter.getQuantity(item))
return sprintf("x%d", @adapter.getQuantity(item))
else
return ""
end
@@ -269,41 +269,40 @@ end
# Pokémon Mart
#===============================================================================
class Window_PokemonMart < Window_DrawableCommand
def initialize(stock,adapter,x,y,width,height,viewport=nil)
@stock=stock
@adapter=adapter
super(x,y,width,height,viewport)
@selarrow=AnimatedBitmap.new("Graphics/Pictures/martSel")
@baseColor=Color.new(88,88,80)
@shadowColor=Color.new(168,184,184)
self.windowskin=nil
def initialize(stock, adapter, x, y, width, height, viewport = nil)
@stock = stock
@adapter = adapter
super(x, y, width, height, viewport)
@selarrow = AnimatedBitmap.new("Graphics/Pictures/martSel")
@baseColor = Color.new(88,88,80)
@shadowColor = Color.new(168,184,184)
self.windowskin = nil
end
def itemCount
return @stock.length+1
return @stock.length + 1
end
def item
return self.index>=@stock.length ? 0 : @stock[self.index]
return (self.index >= @stock.length) ? nil : @stock[self.index]
end
def drawItem(index,count,rect)
textpos=[]
rect=drawCursor(index,rect)
ypos=rect.y
if index==count-1
textpos.push([_INTL("CANCEL"),rect.x,ypos+2,false,
self.baseColor,self.shadowColor])
def drawItem(index, count, rect)
textpos = []
rect = drawCursor(index, rect)
ypos = rect.y
if index == count-1
textpos.push([_INTL("CANCEL"), rect.x, ypos + 2, false, self.baseColor, self.shadowColor])
else
item=@stock[index]
itemname=@adapter.getDisplayName(item)
qty=@adapter.getDisplayPrice(item)
sizeQty=self.contents.text_size(qty).width
xQty=rect.x+rect.width-sizeQty-2-16
textpos.push([itemname,rect.x,ypos+2,false,self.baseColor,self.shadowColor])
textpos.push([qty,xQty,ypos+2,false,self.baseColor,self.shadowColor])
item = @stock[index]
itemname = @adapter.getDisplayName(item)
qty = @adapter.getDisplayPrice(item)
sizeQty = self.contents.text_size(qty).width
xQty = rect.x + rect.width - sizeQty - 2 - 16
textpos.push([itemname, rect.x, ypos + 2, false, self.baseColor, self.shadowColor])
textpos.push([qty, xQty, ypos + 2, false, self.baseColor, self.shadowColor])
end
pbDrawTextPositions(self.contents,textpos)
pbDrawTextPositions(self.contents, textpos)
end
end
@@ -319,112 +318,112 @@ class PokemonMart_Scene
if @subscene
@subscene.pbRefresh
else
itemwindow=@sprites["itemwindow"]
@sprites["icon"].item=itemwindow.item
@sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") :
@adapter.getDescription(itemwindow.item)
itemwindow = @sprites["itemwindow"]
@sprites["icon"].item = itemwindow.item
@sprites["itemtextwindow"].text =
(itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.")
itemwindow.refresh
end
@sprites["moneywindow"].text=_INTL("Money:\r\n<r>{1}",@adapter.getMoneyString)
@sprites["moneywindow"].text = _INTL("Money:\r\n<r>{1}", @adapter.getMoneyString)
end
def pbStartBuyOrSellScene(buying,stock,adapter)
def pbStartBuyOrSellScene(buying, stock, adapter)
# Scroll right before showing screen
pbScrollMap(6,5,5)
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@stock=stock
@adapter=adapter
@sprites={}
@sprites["background"]=IconSprite.new(0,0,@viewport)
pbScrollMap(6, 5, 5)
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@stock = stock
@adapter = adapter
@sprites = {}
@sprites["background"] = IconSprite.new(0, 0, @viewport)
@sprites["background"].setBitmap("Graphics/Pictures/martScreen")
@sprites["icon"]=ItemIconSprite.new(36,Graphics.height-50,-1,@viewport)
winAdapter=buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter)
@sprites["itemwindow"]=Window_PokemonMart.new(stock,winAdapter,
Graphics.width-316-16,12,330+16,Graphics.height-126)
@sprites["itemwindow"].viewport=@viewport
@sprites["itemwindow"].index=0
@sprites["icon"] = ItemIconSprite.new(36, Graphics.height - 50, nil, @viewport)
winAdapter = buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter)
@sprites["itemwindow"] = Window_PokemonMart.new(stock, winAdapter,
Graphics.width - 316 - 16, 12, 330 + 16, Graphics.height - 126)
@sprites["itemwindow"].viewport = @viewport
@sprites["itemwindow"].index = 0
@sprites["itemwindow"].refresh
@sprites["itemtextwindow"]=Window_UnformattedTextPokemon.new("")
@sprites["itemtextwindow"] = Window_UnformattedTextPokemon.new("")
pbPrepareWindow(@sprites["itemtextwindow"])
@sprites["itemtextwindow"].x=64
@sprites["itemtextwindow"].y=Graphics.height-96-16
@sprites["itemtextwindow"].width=Graphics.width-64
@sprites["itemtextwindow"].height=128
@sprites["itemtextwindow"].baseColor=Color.new(248,248,248)
@sprites["itemtextwindow"].shadowColor=Color.new(0,0,0)
@sprites["itemtextwindow"].visible=true
@sprites["itemtextwindow"].viewport=@viewport
@sprites["itemtextwindow"].windowskin=nil
@sprites["helpwindow"]=Window_AdvancedTextPokemon.new("")
@sprites["itemtextwindow"].x = 64
@sprites["itemtextwindow"].y = Graphics.height - 96 - 16
@sprites["itemtextwindow"].width = Graphics.width - 64
@sprites["itemtextwindow"].height = 128
@sprites["itemtextwindow"].baseColor = Color.new(248, 248, 248)
@sprites["itemtextwindow"].shadowColor = Color.new(0, 0, 0)
@sprites["itemtextwindow"].visible = true
@sprites["itemtextwindow"].viewport = @viewport
@sprites["itemtextwindow"].windowskin = nil
@sprites["helpwindow"] = Window_AdvancedTextPokemon.new("")
pbPrepareWindow(@sprites["helpwindow"])
@sprites["helpwindow"].visible=false
@sprites["helpwindow"].viewport=@viewport
pbBottomLeftLines(@sprites["helpwindow"],1)
@sprites["moneywindow"]=Window_AdvancedTextPokemon.new("")
@sprites["helpwindow"].visible = false
@sprites["helpwindow"].viewport = @viewport
pbBottomLeftLines(@sprites["helpwindow"], 1)
@sprites["moneywindow"] = Window_AdvancedTextPokemon.new("")
pbPrepareWindow(@sprites["moneywindow"])
@sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin")
@sprites["moneywindow"].visible=true
@sprites["moneywindow"].viewport=@viewport
@sprites["moneywindow"].x=0
@sprites["moneywindow"].y=0
@sprites["moneywindow"].width=190
@sprites["moneywindow"].height=96
@sprites["moneywindow"].baseColor=Color.new(88,88,80)
@sprites["moneywindow"].shadowColor=Color.new(168,184,184)
@sprites["moneywindow"].visible = true
@sprites["moneywindow"].viewport = @viewport
@sprites["moneywindow"].x = 0
@sprites["moneywindow"].y = 0
@sprites["moneywindow"].width = 190
@sprites["moneywindow"].height = 96
@sprites["moneywindow"].baseColor = Color.new(88, 88, 80)
@sprites["moneywindow"].shadowColor = Color.new(168, 184, 184)
pbDeactivateWindows(@sprites)
@buying=buying
@buying = buying
pbRefresh
Graphics.frame_reset
end
def pbStartBuyScene(stock,adapter)
pbStartBuyOrSellScene(true,stock,adapter)
def pbStartBuyScene(stock, adapter)
pbStartBuyOrSellScene(true, stock, adapter)
end
def pbStartSellScene(bag,adapter)
def pbStartSellScene(bag, adapter)
if $PokemonBag
pbStartSellScene2(bag,adapter)
pbStartSellScene2(bag, adapter)
else
pbStartBuyOrSellScene(false,bag,adapter)
pbStartBuyOrSellScene(false, bag, adapter)
end
end
def pbStartSellScene2(bag,adapter)
@subscene=PokemonBag_Scene.new
@adapter=adapter
@viewport2=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport2.z=99999
numFrames = Graphics.frame_rate*4/10
alphaDiff = (255.0/numFrames).ceil
def pbStartSellScene2(bag, adapter)
@subscene = PokemonBag_Scene.new
@adapter = adapter
@viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport2.z = 99999
numFrames = Graphics.frame_rate * 4 / 10
alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames
col=Color.new(0,0,0,j*alphaDiff)
@viewport2.color=col
col = Color.new(0, 0, 0, j * alphaDiff)
@viewport2.color = col
Graphics.update
Input.update
end
@subscene.pbStartScene(bag)
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites={}
@sprites["helpwindow"]=Window_AdvancedTextPokemon.new("")
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
@sprites["helpwindow"] = Window_AdvancedTextPokemon.new("")
pbPrepareWindow(@sprites["helpwindow"])
@sprites["helpwindow"].visible=false
@sprites["helpwindow"].viewport=@viewport
pbBottomLeftLines(@sprites["helpwindow"],1)
@sprites["moneywindow"]=Window_AdvancedTextPokemon.new("")
@sprites["helpwindow"].visible = false
@sprites["helpwindow"].viewport = @viewport
pbBottomLeftLines(@sprites["helpwindow"], 1)
@sprites["moneywindow"] = Window_AdvancedTextPokemon.new("")
pbPrepareWindow(@sprites["moneywindow"])
@sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin")
@sprites["moneywindow"].visible=false
@sprites["moneywindow"].viewport=@viewport
@sprites["moneywindow"].x=0
@sprites["moneywindow"].y=0
@sprites["moneywindow"].width=186
@sprites["moneywindow"].height=96
@sprites["moneywindow"].baseColor=Color.new(88,88,80)
@sprites["moneywindow"].shadowColor=Color.new(168,184,184)
@sprites["moneywindow"].visible = false
@sprites["moneywindow"].viewport = @viewport
@sprites["moneywindow"].x = 0
@sprites["moneywindow"].y = 0
@sprites["moneywindow"].width = 186
@sprites["moneywindow"].height = 96
@sprites["moneywindow"].baseColor = Color.new(88, 88, 80)
@sprites["moneywindow"].shadowColor = Color.new(168, 184, 184)
pbDeactivateWindows(@sprites)
@buying=false
@buying = false
pbRefresh
end
@@ -432,82 +431,78 @@ class PokemonMart_Scene
pbDisposeSpriteHash(@sprites)
@viewport.dispose
# Scroll left after showing screen
pbScrollMap(4,5,5)
pbScrollMap(4, 5, 5)
end
def pbEndSellScene
if @subscene
@subscene.pbEndScene
end
@subscene.pbEndScene if @subscene
pbDisposeSpriteHash(@sprites)
if @viewport2
numFrames = Graphics.frame_rate*4/10
alphaDiff = (255.0/numFrames).ceil
numFrames = Graphics.frame_rate * 4 / 10
alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames
col=Color.new(0,0,0,(numFrames-j)*alphaDiff)
@viewport2.color=col
col = Color.new(0, 0, 0, (numFrames - j) * alphaDiff)
@viewport2.color = col
Graphics.update
Input.update
end
@viewport2.dispose
end
@viewport.dispose
if !@subscene
pbScrollMap(4,5,5)
end
pbScrollMap(4, 5, 5) if !@subscene
end
def pbPrepareWindow(window)
window.visible=true
window.letterbyletter=false
window.visible = true
window.letterbyletter = false
end
def pbShowMoney
pbRefresh
@sprites["moneywindow"].visible=true
@sprites["moneywindow"].visible = true
end
def pbHideMoney
pbRefresh
@sprites["moneywindow"].visible=false
@sprites["moneywindow"].visible = false
end
def pbDisplay(msg,brief=false)
cw=@sprites["helpwindow"]
cw.letterbyletter=true
cw.text=msg
pbBottomLeftLines(cw,2)
cw.visible=true
i=0
pbPlayDecisionSE()
def pbDisplay(msg, brief = false)
cw = @sprites["helpwindow"]
cw.letterbyletter = true
cw.text = msg
pbBottomLeftLines(cw, 2)
cw.visible = true
i = 0
pbPlayDecisionSE
loop do
Graphics.update
Input.update
self.update
if !cw.busy?
return if brief
pbRefresh if i==0
pbRefresh if i == 0
end
if Input.trigger?(Input::C) && cw.busy?
cw.resume
end
return if i>=Graphics.frame_rate*3/2
i+=1 if !cw.busy?
return if i >= Graphics.frame_rate * 3 / 2
i += 1 if !cw.busy?
end
end
def pbDisplayPaused(msg)
cw=@sprites["helpwindow"]
cw.letterbyletter=true
cw.text=msg
pbBottomLeftLines(cw,2)
cw.visible=true
cw = @sprites["helpwindow"]
cw.letterbyletter = true
cw.text = msg
pbBottomLeftLines(cw, 2)
cw.visible = true
yielded = false
pbPlayDecisionSE()
pbPlayDecisionSE
loop do
Graphics.update
Input.update
wasbusy=cw.busy?
wasbusy = cw.busy?
self.update
if !cw.busy? && !yielded
yield if block_given? # For playing SE as soon as the message is all shown
@@ -515,73 +510,73 @@ class PokemonMart_Scene
end
pbRefresh if !cw.busy? && wasbusy
if Input.trigger?(Input::C) && cw.resume && !cw.busy?
@sprites["helpwindow"].visible=false
@sprites["helpwindow"].visible = false
return
end
end
end
def pbConfirm(msg)
dw=@sprites["helpwindow"]
dw.letterbyletter=true
dw.text=msg
dw.visible=true
pbBottomLeftLines(dw,2)
commands=[_INTL("Yes"),_INTL("No")]
dw = @sprites["helpwindow"]
dw.letterbyletter = true
dw.text = msg
dw.visible = true
pbBottomLeftLines(dw, 2)
commands = [_INTL("Yes"), _INTL("No")]
cw = Window_CommandPokemon.new(commands)
cw.viewport=@viewport
cw.viewport = @viewport
pbBottomRight(cw)
cw.y-=dw.height
cw.index=0
pbPlayDecisionSE()
cw.y -= dw.height
cw.index = 0
pbPlayDecisionSE
loop do
cw.visible=!dw.busy?
cw.visible = !dw.busy?
Graphics.update
Input.update
cw.update
self.update
if Input.trigger?(Input::B) && dw.resume && !dw.busy?
cw.dispose
@sprites["helpwindow"].visible=false
@sprites["helpwindow"].visible = false
return false
end
if Input.trigger?(Input::C) && dw.resume && !dw.busy?
cw.dispose
@sprites["helpwindow"].visible=false
return (cw.index==0)?true:false
@sprites["helpwindow"].visible = false
return (cw.index == 0)
end
end
end
def pbChooseNumber(helptext,item,maximum)
curnumber=1
ret=0
helpwindow=@sprites["helpwindow"]
itemprice=@adapter.getPrice(item,!@buying)
itemprice/=2 if !@buying
pbDisplay(helptext,true)
using(numwindow=Window_AdvancedTextPokemon.new("")) { # Showing number of items
qty=@adapter.getQuantity(item)
using(inbagwindow=Window_AdvancedTextPokemon.new("")) { # Showing quantity in bag
curnumber = 1
ret = 0
helpwindow = @sprites["helpwindow"]
itemprice = @adapter.getPrice(item, !@buying)
itemprice /= 2 if !@buying
pbDisplay(helptext, true)
using (numwindow = Window_AdvancedTextPokemon.new("")) { # Showing number of items
qty = @adapter.getQuantity(item)
using (inbagwindow = Window_AdvancedTextPokemon.new("")) { # Showing quantity in bag
pbPrepareWindow(numwindow)
pbPrepareWindow(inbagwindow)
numwindow.viewport=@viewport
numwindow.width=224
numwindow.height=64
numwindow.baseColor=Color.new(88,88,80)
numwindow.shadowColor=Color.new(168,184,184)
inbagwindow.visible=@buying
inbagwindow.viewport=@viewport
inbagwindow.width=190
inbagwindow.height=64
inbagwindow.baseColor=Color.new(88,88,80)
inbagwindow.shadowColor=Color.new(168,184,184)
inbagwindow.text=_INTL("In Bag:<r>{1} ",qty)
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
numwindow.viewport = @viewport
numwindow.width = 224
numwindow.height = 64
numwindow.baseColor = Color.new(88, 88, 80)
numwindow.shadowColor = Color.new(168, 184, 184)
inbagwindow.visible = @buying
inbagwindow.viewport = @viewport
inbagwindow.width = 190
inbagwindow.height = 64
inbagwindow.baseColor = Color.new(88, 88, 80)
inbagwindow.shadowColor = Color.new(168, 184, 184)
inbagwindow.text = _INTL("In Bag:<r>{1} ", qty)
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
pbBottomRight(numwindow)
numwindow.y-=helpwindow.height
numwindow.y -= helpwindow.height
pbBottomLeft(inbagwindow)
inbagwindow.y-=helpwindow.height
inbagwindow.y -= helpwindow.height
loop do
Graphics.update
Input.update
@@ -589,65 +584,65 @@ class PokemonMart_Scene
inbagwindow.update
self.update
if Input.repeat?(Input::LEFT)
pbPlayCursorSE()
curnumber-=10
curnumber=1 if curnumber<1
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
pbPlayCursorSE
curnumber -= 10
curnumber = 1 if curnumber < 1
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
elsif Input.repeat?(Input::RIGHT)
pbPlayCursorSE()
curnumber+=10
curnumber=maximum if curnumber>maximum
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
pbPlayCursorSE
curnumber += 10
curnumber = maximum if curnumber > maximum
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
elsif Input.repeat?(Input::UP)
pbPlayCursorSE()
curnumber+=1
curnumber=1 if curnumber>maximum
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
pbPlayCursorSE
curnumber += 1
curnumber = 1 if curnumber > maximum
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
elsif Input.repeat?(Input::DOWN)
pbPlayCursorSE()
curnumber-=1
curnumber=maximum if curnumber<1
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
pbPlayCursorSE
curnumber -= 1
curnumber = maximum if curnumber < 1
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
elsif Input.trigger?(Input::C)
pbPlayDecisionSE()
ret=curnumber
pbPlayDecisionSE
ret = curnumber
break
elsif Input.trigger?(Input::B)
pbPlayCancelSE()
ret=0
pbPlayCancelSE
ret = 0
break
end
end
}
}
helpwindow.visible=false
helpwindow.visible = false
return ret
end
def pbChooseBuyItem
itemwindow=@sprites["itemwindow"]
@sprites["helpwindow"].visible=false
pbActivateWindow(@sprites,"itemwindow") {
itemwindow = @sprites["itemwindow"]
@sprites["helpwindow"].visible = false
pbActivateWindow(@sprites, "itemwindow") {
pbRefresh
loop do
Graphics.update
Input.update
olditem=itemwindow.item
olditem = itemwindow.item
self.update
if itemwindow.item!=olditem
@sprites["icon"].item=itemwindow.item
@sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") :
@adapter.getDescription(itemwindow.item)
if itemwindow.item != olditem
@sprites["icon"].item = itemwindow.item
@sprites["itemtextwindow"].text =
(itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.")
end
if Input.trigger?(Input::B)
pbPlayCloseMenuSE
return 0
return nil
elsif Input.trigger?(Input::C)
if itemwindow.index<@stock.length
if itemwindow.index < @stock.length
pbRefresh
return @stock[itemwindow.index]
else
return 0
return nil
end
end
end
@@ -688,18 +683,18 @@ class PokemonMartScreen
def pbBuyScreen
@scene.pbStartBuyScene(@stock,@adapter)
item=0
item=nil
loop do
item=@scene.pbChooseBuyItem
break if !item
quantity=0
break if item==0
itemname=@adapter.getDisplayName(item)
price=@adapter.getPrice(item)
if @adapter.getMoney<price
pbDisplayPaused(_INTL("You don't have enough money."))
next
end
if pbIsImportantItem?(item)
if GameData::Item.get(item).is_important?
if !pbConfirm(_INTL("Certainly. You want {1}. That will be ${2}. OK?",
itemname,price.to_s_formatted))
next
@@ -723,9 +718,7 @@ class PokemonMartScreen
end
added=0
quantity.times do
if !@adapter.addItem(item)
break
end
break if !@adapter.addItem(item)
added+=1
end
if added!=quantity
@@ -738,15 +731,15 @@ class PokemonMartScreen
else
@adapter.setMoney(@adapter.getMoney-price)
for i in 0...@stock.length
if pbIsImportantItem?(@stock[i]) && $PokemonBag.pbHasItem?(@stock[i])
if GameData::Item.get(@stock[i]).is_important? && $PokemonBag.pbHasItem?(@stock[i])
@stock[i]=nil
end
end
@stock.compact!
pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") }
if $PokemonBag
if quantity>=10 && pbIsPokeBall?(item) && hasConst?(PBItems,:PREMIERBALL)
if @adapter.addItem(getConst(PBItems,:PREMIERBALL))
if quantity>=10 && GameData::Item.get(item).is_poke_ball? && GameData::Item.exists?(:PREMIERBALL)
if @adapter.addItem(GameData::Item.get(:PREMIERBALL))
pbDisplayPaused(_INTL("I'll throw in a Premier Ball, too."))
end
end
@@ -760,7 +753,7 @@ class PokemonMartScreen
item=@scene.pbStartSellScene(@adapter.getInventory,@adapter)
loop do
item=@scene.pbChooseSellItem
break if item==0
break if !item
itemname=@adapter.getDisplayName(item)
price=@adapter.getPrice(item,true)
if !@adapter.canSell?(item)
@@ -798,11 +791,8 @@ end
def pbPokemonMart(stock,speech=nil,cantsell=false)
for i in 0...stock.length
stock[i] = getID(PBItems,stock[i])
if !stock[i] || stock[i]==0 ||
(pbIsImportantItem?(stock[i]) && $PokemonBag.pbHasItem?(stock[i]))
stock[i] = nil
end
stock[i] = GameData::Item.get(stock[i]).id
stock[i] = nil if GameData::Item.get(stock[i]).is_important? && $PokemonBag.pbHasItem?(stock[i])
end
stock.compact!
commands = []
@@ -880,7 +870,7 @@ class Interpreter
end
def setPrice(item,buyprice=-1,sellprice=-1)
item = getID(PBItems,item)
item = GameData::Item.get(item).id
$game_temp.mart_prices[item] = [-1,-1] if !$game_temp.mart_prices[item]
$game_temp.mart_prices[item][0] = buyprice if buyprice>0
if sellprice>=0 # 0=can't sell

View File

@@ -61,7 +61,8 @@ def pbEditMysteryGift(type,item,id=0,giftname="")
params.setDefaultValue(type)
params.setCancelValue(0)
loop do
newtype=pbMessageChooseNumber(_INTL("Choose a quantity."),params)
newtype=pbMessageChooseNumber(_INTL("Choose a quantity of {1}.",
GameData::Item.get(item).name),params)
if newtype==0
return nil if pbConfirmMessage(_INTL("Stop editing this gift?"))
else
@@ -230,17 +231,17 @@ def pbManageMysteryGifts
end
end
def pbRefreshMGCommands(master,online)
commands=[]
def pbRefreshMGCommands(master, online)
commands = []
for gift in master
itemname="BLANK"
if gift[1]==0
itemname=PBSpecies.getName(gift[2].species)
elsif gift[1]>0
itemname=PBItems.getName(gift[2])+sprintf(" x%d",gift[1])
itemname = "BLANK"
if gift[1] == 0
itemname = PBSpecies.getName(gift[2].species)
elsif gift[1] > 0
itemname = GameData::Item.get(gift[2]).name + sprintf(" x%d", gift[1])
end
ontext=["[ ]","[X]"][(online.include?(gift[0])) ? 1 : 0]
commands.push(_INTL("{1} {2}: {3} ({4})",ontext,gift[0],gift[3],itemname))
ontext = ["[ ]", "[X]"][(online.include?(gift[0])) ? 1 : 0]
commands.push(_INTL("{1} {2}: {3} ({4})", ontext, gift[0], gift[3], itemname))
end
commands.push(_INTL("Export selected to file"))
commands.push(_INTL("Cancel"))
@@ -378,7 +379,7 @@ def pbReceiveMysteryGift(id)
return false
end
gift=$Trainer.mysterygift[index]
if gift[1]==0
if gift[1]==0 # Pokémon
pID=rand(256)
pID|=rand(256)<<8
pID|=rand(256)<<16
@@ -401,15 +402,17 @@ def pbReceiveMysteryGift(id)
$Trainer.mysterygift[index]=[id]
return true
end
elsif gift[1]>0
if $PokemonBag.pbCanStore?(gift[2],gift[1])
$PokemonBag.pbStoreItem(gift[2],gift[1])
item=gift[2]; qty=gift[1]
itemname=(qty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
if isConst?(item,PBItems,:LEFTOVERS)
elsif gift[1]>0 # Item
item=gift[2]
qty=gift[1]
if $PokemonBag.pbCanStore?(item,qty)
$PokemonBag.pbStoreItem(item,qty)
itm = GameData::Item.get(item)
itemname=(qty>1) ? itm.name_plural : itm.name
if item == :LEFTOVERS
pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
elsif pbIsMachine?(item) # TM or HM
pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(pbGetMachine(item))))
elsif itm.is_machine? # TM or HM
pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(itm.move)))
elsif qty>1
pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]",qty,itemname))
elsif itemname.starts_with_vowel?