Advertisement
TechSkylander1518

Rare Candy Anticheating (v18)

Jul 9th, 2021 (edited)
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.91 KB | None | 0 0
  1. RARE_CANDY_VARIABLE = 100
  2. CHEAT_MESSAGE = "Hey! I don't think you're supposed to have this!"
  3.  
  4.  
  5. #===============================================================================
  6. # Picking up an item found on the ground
  7. #===============================================================================
  8. def pbItemBall(item,quantity=1)
  9.   if item == :RARECANDY
  10.     $game_variables[RARE_CANDY_VARIABLE] += 1
  11.   end
  12.   item = getID(PBItems,item)
  13.   return false if !item || item<=0 || quantity<1
  14.   itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
  15.   pocket = pbGetPocket(item)
  16.   if $PokemonBag.pbStoreItem(item,quantity)   # If item can be picked up
  17.     meName = (pbIsKeyItem?(item)) ? "Key item get" : "Item get"
  18.     if isConst?(item,PBItems,:LEFTOVERS)
  19.       pbMessage(_INTL("\\me[{1}]You found some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
  20.     elsif pbIsMachine?(item)   # TM or HM
  21.       pbMessage(_INTL("\\me[{1}]You found \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(pbGetMachine(item))))
  22.     elsif quantity>1
  23.       pbMessage(_INTL("\\me[{1}]You found {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
  24.     elsif itemname.starts_with_vowel?
  25.       pbMessage(_INTL("\\me[{1}]You found an \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
  26.     else
  27.       pbMessage(_INTL("\\me[{1}]You found a \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
  28.     end
  29.     pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
  30.        itemname,pocket,PokemonBag.pocketNames()[pocket]))
  31.     return true
  32.   end
  33.   # Can't add the item
  34.   if isConst?(item,PBItems,:LEFTOVERS)
  35.     pbMessage(_INTL("You found some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
  36.   elsif pbIsMachine?(item)   # TM or HM
  37.     pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(pbGetMachine(item))))
  38.   elsif quantity>1
  39.     pbMessage(_INTL("You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]",quantity,itemname))
  40.   elsif itemname.starts_with_vowel?
  41.     pbMessage(_INTL("You found an \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
  42.   else
  43.     pbMessage(_INTL("You found a \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
  44.   end
  45.   pbMessage(_INTL("But your Bag is full..."))
  46.   return false
  47. end
  48.  
  49.  
  50.  
  51. #===============================================================================
  52. # Being given an item
  53. #===============================================================================
  54. def pbReceiveItem(item,quantity=1)
  55.   if item == :RARECANDY
  56.     $game_variables[RARE_CANDY_VARIABLE] += 1
  57.   end
  58.   item = getID(PBItems,item)
  59.   return false if !item || item<=0 || quantity<1
  60.   itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
  61.   pocket = pbGetPocket(item)
  62.   meName = (pbIsKeyItem?(item)) ? "Key item get" : "Item get"
  63.   if isConst?(item,PBItems,:LEFTOVERS)
  64.     pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
  65.   elsif pbIsMachine?(item)   # TM or HM
  66.     pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(pbGetMachine(item))))
  67.   elsif quantity>1
  68.     pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
  69.   elsif itemname.starts_with_vowel?
  70.     pbMessage(_INTL("\\me[{1}]You obtained an \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
  71.   else
  72.     pbMessage(_INTL("\\me[{1}]You obtained a \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
  73.   end
  74.   if $PokemonBag.pbStoreItem(item,quantity)   # If item can be added
  75.     pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
  76.        itemname,pocket,PokemonBag.pocketNames()[pocket]))
  77.     return true
  78.   end
  79.   return false   # Can't add the item
  80. end
  81.  
  82.  
  83. ItemHandlers::UseOnPokemon.add(:RARECANDY,proc { |item,pkmn,scene|
  84.   if pkmn.level>=PBExperience.maxLevel || pkmn.shadowPokemon?
  85.     scene.pbDisplay(_INTL("It won't have any effect."))
  86.     next false
  87.   end
  88.   if $game_variables[RARE_CANDY_VARIABLE] == 0
  89.     scene.pbDisplay(_INTL("#{CHEAT_MESSAGE}"))
  90.     quantity = $PokemonBag.pbQuantity(:RARECANDY)
  91.     $PokemonBag.pbDeleteItem(:RARECANDY,quantity)
  92.     next true
  93.   end
  94.   pbChangeLevel(pkmn,pkmn.level+1,scene)
  95.   $game_variables[RARE_CANDY_VARIABLE] -= 1
  96.   scene.pbHardRefresh
  97.   next true
  98. })
  99.  
  100.  
  101.  
  102.  
  103. class PokemonBag
  104.   def pbStoreItem(item,qty=1)
  105.     item = getID(PBItems,item)
  106.     if !item || item<1
  107.       raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
  108.     end
  109.     if item == getID(PBItems,:RARECANDY)
  110.       $game_variables[RARE_CANDY_VARIABLE] += qty
  111.     end
  112.     pocket = pbGetPocket(item)
  113.     maxsize = maxPocketSize(pocket)
  114.     maxsize = @pockets[pocket].length+1 if maxsize<0
  115.     return ItemStorageHelper.pbStoreItem(@pockets[pocket],maxsize,
  116.                                          BAG_MAX_PER_SLOT,item,qty,true)
  117.   end
  118. end
  119.  
  120.  
  121. def pbRareCandy
  122.   $game_variables[RARE_CANDY_VARIABLE] = $PokemonBag.pbQuantity(:RARECANDY)
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement