• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

CLAW MACHINE [MINIGAME]

Code:
#===============================================================================
# * Claw Machine MiniGame - Bhagya Jyoti (Credits will be apreciated)
# * Graphics by - D-weeb
#===============================================================================
# This script is for Pokémon Essentials v18. The player controls a simple
# claw machine to get particular items.
#===============================================================================
# Paste this script above `Main` and required graphics in `Graphics/Pictures/
#	Claw Machine/` . To call this script, use the script command 'pbClawGame(X)' 
# where X is the number of chances that we can use the Claw Machine.
#===============================================================================
# Add the items that you want in the particular arrays in order, BASICITEMS are 
# common items while LEGENDARYITEMS are the most uncommon items.
#===============================================================================
# It was originally made for my fangame Pokemon BHARAT where I used to catch pokepuffs.
# Do edit the `glassfg.png` with your look to suite your game.
#===============================================================================
# Plugin Mangar support for v18.
PluginManager.register({
  :name    => "Claw Machine Minigame",
  :version => "1.0",
  :link    => "https://www.pokecommunity.com/showthread.php?t=439877",
  :credits => ["Bhagya Jyoti"]
})
#===============================================================================

BASICITEMS = [
  :BASICBROWNPUFF,
  :BASICDARKBROWNPUFF,
  :BASICORANGEPUFF,
  :BASICYELLOWPUFF,
  :BASICPINKPUFF
  ]
EPICITEMS = [
  :FANCYBROWNPUFF,
  :FANCYDARKBROWNPUFF,
  :FANCYORANGEPUFF,
  :FANCYYELLOWPUFF,
  :FANCYPINKPUFF
  ]
RAREITEMS = [
  :FROSTEDBROWNPUFF,
  :FROSTEDDARKBROWNPUFF,
  :FROSTEDORANGEPUFF,
  :FROSTEDYELLOWPUFF,
  :FROSTEDPINKPUFF
  ]
MYTHICALITEMS = [
  :DELUXEBROWNPUFF,
  :DELUXEDARKBROWNPUFF,
  :DELUXEORANGEPUFF,
  :DELUXEYELLOWPUFF,
  :DELUXEPINKPUFF
  ]
LEGENDARYITEMS = [
  :SUPREMEBROWNPUFF,
  :SUPREMEDARKBROWNPUFF,
  :SUPREMEORANGEPUFF,
  :SUPREMEYELLOWPUFF,
  :SUPREMEPINKPUFF1,
  :SUPREMEPINKPUFF2
  ]

class ClawMachine
  def pbStartScene(chance)
    @chances = chance
    @chance = 0
    @dir=0
    @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
    @claw = {}
    
    @claw["bgmain"] = Sprite.new(@viewport)
    @claw["bgmain"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/background")
    @claw["bgmain"].z = 99995
    
    @claw["glassbg"] = Sprite.new(@viewport)
    @claw["glassbg"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/glassbg")
    @claw["glassbg"].x = 56
    @claw["glassbg"].y = 184
    @claw["glassbg"].z = 99996
    
    @claw["glassfg"] = Sprite.new(@viewport)
    @claw["glassfg"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/glassfg")
    @claw["glassfg"].x = 56
    @claw["glassfg"].y = 184
    @claw["glassfg"].z = 99999
    
    @claw["bar"] = Sprite.new(@viewport)
    @claw["bar"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/bar")
    @claw["bar"].z = 99996
    
    @claw["clawbase"] = Sprite.new(@viewport)
    @claw["clawbase"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/clawbase")
    @claw["clawbase"].x = 201
    @claw["clawbase"].y = 42
    @claw["clawbase"].z = 99997
    
    @claw["clawrod"] = Sprite.new(@viewport)
    @claw["clawrod"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/clawrod")
    @claw["clawrod"].x = 201
    @claw["clawrod"].y = 80
    @claw["clawrod"].z = 99996
    
    @claw["clawhand"] = Sprite.new(@viewport)
    @claw["clawhand"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/clawhand")
    @claw["clawhand"].x = 201
    @claw["clawhand"].y = 42
    @claw["clawhand"].z = 99996
    
    @claw["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
    @claw["overlay"].z = 99999
    pbSetSystemFont(@claw["overlay"].bitmap)
    pbDrawText
  end
  
  def pbDrawText
    overlay=@claw["overlay"].bitmap
    overlay.clear
    chance=_INTL("Chance: {1}/{2}",@chance,@chances)
    baseColor=Color.new(256,256,256)
    shadowColor=Color.new(160,160,160)
    textPositions=[[chance,196,4,false,baseColor,shadowColor],]
    pbDrawTextPositions(overlay,textPositions)
  end
  
  def pbMain
    loop do
      Graphics.update
      Input.update
      
      if @chance==@chances || Input.trigger?(Input::B)
        pbMessage("Thanks for playing!")
        break
        pbEndScene
      end
      
      if @dir==0 && @claw["clawhand"].x!=66
        @claw["clawbase"].x-=5
        @claw["clawrod"].x-=5
        @claw["clawhand"].x-=5
        Graphics.update
        @dir=1 if @claw["clawhand"].x==66
      end
      if @dir==1 && @claw["clawhand"].x!=336
        @claw["clawbase"].x+=5
        @claw["clawrod"].x+=5
        @claw["clawhand"].x+=5
        Graphics.update
        @dir=0 if @claw["clawhand"].x==336
      end
      
      if Input.trigger?(Input::C)
        @chance+=1
        pbDrawText
        @claw["clawhand"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/clawlaunch")
        while @claw["clawhand"].y!=222
          @claw["clawrod"].zoom_y+=0.2
          @claw["clawhand"].y+=10
          Graphics.update
        end
        pbWait(5)
        if rand(100)<25
          @item = nil
        elsif rand(100)<50
          @item = getID(PBItems,(BASICITEMS[rand(BASICITEMS.length)]))
        elsif rand(100)<60
          @item = getID(PBItems,(EPICITEMS[rand(EPICITEMS.length)]))
        elsif rand(100)<70
          @item = getID(PBItems,(RAREITEMS[rand(RAREITEMS.length)]))
        elsif rand(100)<80
          @item = getID(PBItems,(MYTHICALITEMS[rand(MYTHICALITEMS.length)]))
        elsif rand(100)<90
          @item = getID(PBItems,(LEGENDARYITEMS[rand(LEGENDARYITEMS.length)]))
        end
        if @item!=nil
          @claw["puff"] = Sprite.new(@viewport)
          @claw["puff"].bitmap = Bitmap.new("Graphics/Icons/item"[email protected]_s)
          @claw["puff"].x = @claw["clawhand"].x+28
          @claw["puff"].y = @claw["clawhand"].y+100
          @claw["puff"].z = 99997
          @claw["clawhand"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/clawpick")
        end        
        while @claw["clawhand"].y!=42
            @claw["clawrod"].zoom_y-=0.2
            @claw["clawhand"].y-=10
            @claw["puff"].y-=10 if @item!=nil
          Graphics.update
        end
        pbReceiveItem(@item) if @item!=nil
        @claw["clawhand"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/clawlaunch")
        if @item!=nil
          while @claw["puff"].opacity!=0
            @claw["puff"].opacity-=16
            Graphics.update
          end
          @claw["puff"].dispose
        else
          pbMessage("Claw Machine missed the aim.")
        end
        @claw["clawhand"].bitmap = Bitmap.new("Graphics/Pictures/Claw Machine/clawhand")
      end
    end
  end
  
  def pbEndScene
    $game_map.autoplay
    pbDisposeSpriteHash(@claw)
    @viewport.dispose
  end
end

class ClawMachineStart
  def initialize(scene)
    @scene=scene
  end
  def pbStartScreen(chance)
    @scene.pbStartScene(chance)
    [email protected]
    @scene.pbEndScene
    return ret
  end
end

def pbClawMachine(chance=10)
  scene=ClawMachine.new
  screen=ClawMachineStart.new(scene)
  return screen.pbStartScreen(chance)
end
OVERLOOK:-
 

Attachments

  • Claw Machine.zip
    38.4 KB · Views: 87
Last edited:
465
Posts
7
Years
    • Seen May 9, 2024
    very interesting script! would been nice for some additional text about it here but the actual script gives it some background.
    guessing the pokepuffs are not included minus as examples for the items(?) and the icons in the thing are the item icons or?


    While its made for v18, any idea if it works ported backwards? (e.g. to 17 or 16)
    very interested,
     
    very interesting script! would been nice for some additional text about it here but the actual script gives it some background.
    guessing the pokepuffs are not included minus as examples for the items(?) and the icons in the thing are the item icons or?,
    Can you please elaborate with easy english. Sorry, I don't understand such complex phrases.
    While its made for v18, any idea if it works ported backwards? (e.g. to 17 or 16)
    very interested,
    Yes, I have v17, and I am making it compatible with it. v16 is just way too old...
     
    21
    Posts
    11
    Years
    • Seen today
    Really cool script, but since i dont have the puffs in my game, i could just rename them as normal items.
     
    220
    Posts
    9
    Years
  • Thanks everyone, if you all had any suggestion of any minigame, feel free to share it here.

    Can you make a script for Berry Pots for PE v18? No one seems to madded it and its pretty usefull. Note: I can provide the graphics for it from the HG SS games.

    CLAW MACHINE [MINIGAME]



    EDIT: Here is the graphics for that in case you want to make the script: https://mega.nz/file/BIVQhQhJ#m2Sp2AK1QMF2P8vcULYCBac41egb2AcqiFnIha2Ytsw
     
    Last edited:
    150
    Posts
    8
    Years
    • Seen Jul 13, 2023
    Heh, nice. I actually made a claw machine tile a long time ago, and this is perfect opportunity to use it.

    CLAW MACHINE [MINIGAME]

    If anyone wants to use the tiles with this, I've included them here.
     

    Attachments

    • CLAW MACHINE [MINIGAME]
      ClawMachine_AnimationFrames-01.png
      1.9 KB · Views: 30
    150
    Posts
    8
    Years
    • Seen Jul 13, 2023
    So nice of you Ulithium Dragon to post these here. These will form a perfect combination.

    No problem!

    I actually made a custom glass background for my own uses, but if anyone else wants to use it or even if you wanted to include it with the main download please feel free to do so!

    CLAW MACHINE [MINIGAME]

    I intend to use the claw machine for Secret Base dolls for my game, which is why I made this graphic.
     
    6
    Posts
    5
    Years
    • Seen Nov 17, 2023
    Hi, nice script.
    It did not work for me on V.17, so I made it work.
    I also change the Hit chances a little.

    Thanks!

    Spoiler:
     
    Hi, nice script.
    It did not work for me on V.17, so I made it work.
    I also change the Hit chances a little.

    Thanks!

    Spoiler:

    Oh, nice!
     
    Back
    Top