Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RARE_CANDY_VARIABLE = 100
- CHEAT_MESSAGE = "Hey! I don't think you're supposed to have this!"
- #===============================================================================
- # Picking up an item found on the ground
- #===============================================================================
- def pbItemBall(item,quantity=1)
- if item == :RARECANDY
- $game_variables[RARE_CANDY_VARIABLE] += 1
- end
- item = getID(PBItems,item)
- return false if !item || item<=0 || quantity<1
- itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
- pocket = pbGetPocket(item)
- if $PokemonBag.pbStoreItem(item,quantity) # If item can be picked up
- 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 itemname.starts_with_vowel?
- 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
- pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
- itemname,pocket,PokemonBag.pocketNames()[pocket]))
- return true
- end
- # Can't add the item
- if isConst?(item,PBItems,:LEFTOVERS)
- pbMessage(_INTL("You found some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
- elsif pbIsMachine?(item) # TM or HM
- pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(pbGetMachine(item))))
- elsif quantity>1
- pbMessage(_INTL("You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]",quantity,itemname))
- elsif itemname.starts_with_vowel?
- pbMessage(_INTL("You found an \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
- else
- pbMessage(_INTL("You found a \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
- end
- pbMessage(_INTL("But your Bag is full..."))
- return false
- end
- #===============================================================================
- # Being given an item
- #===============================================================================
- def pbReceiveItem(item,quantity=1)
- if item == :RARECANDY
- $game_variables[RARE_CANDY_VARIABLE] += 1
- end
- 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 itemname.starts_with_vowel?
- 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]))
- return true
- end
- return false # Can't add the item
- end
- ItemHandlers::UseOnPokemon.add(:RARECANDY,proc { |item,pkmn,scene|
- if pkmn.level>=PBExperience.maxLevel || pkmn.shadowPokemon?
- scene.pbDisplay(_INTL("It won't have any effect."))
- next false
- end
- if $game_variables[RARE_CANDY_VARIABLE] == 0
- scene.pbDisplay(_INTL("#{CHEAT_MESSAGE}"))
- quantity = $PokemonBag.pbQuantity(:RARECANDY)
- $PokemonBag.pbDeleteItem(:RARECANDY,quantity)
- next true
- end
- pbChangeLevel(pkmn,pkmn.level+1,scene)
- $game_variables[RARE_CANDY_VARIABLE] -= 1
- scene.pbHardRefresh
- next true
- })
- class PokemonBag
- def pbStoreItem(item,qty=1)
- item = getID(PBItems,item)
- if !item || item<1
- raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
- end
- if item == getID(PBItems,:RARECANDY)
- $game_variables[RARE_CANDY_VARIABLE] += qty
- end
- pocket = pbGetPocket(item)
- maxsize = maxPocketSize(pocket)
- maxsize = @pockets[pocket].length+1 if maxsize<0
- return ItemStorageHelper.pbStoreItem(@pockets[pocket],maxsize,
- BAG_MAX_PER_SLOT,item,qty,true)
- end
- end
- def pbRareCandy
- $game_variables[RARE_CANDY_VARIABLE] = $PokemonBag.pbQuantity(:RARECANDY)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement