- 2,170
- Posts
- 5
- Years
- बिहार, भारत। Bihar, India.
- Seen Aug 25, 2024
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
Spoiler:
Attachments
Last edited: