Thread: [Essentials script] Apricorn System for Essentials
View Single Post
  #1    
Old August 17th, 2012, 12:48 PM
zingzags's Avatar
zingzags
Creator or Pokemon Serenity
 
Join Date: Jan 2009
Location: Boston
Age: 20
Nature: Adamant
Here is another nice add-on brought to you by yours truly.
Code:
# Apricorn system by zingzags
# credits will be nice!

class Apricorn

  def pbStartScene
    @sprites={}
    @posx={}
    @posy={}
    @choose=1
    @text_update=nil
    @exit=nil
    @leave=nil
    @posx[1],@posy[1]=30,0
    @posx[2],@posy[2]=120,30
    @posx[3],@posy[3]=30,65
    @posx[4],@posy[4]=120,90
    @posx[5],@posy[5]=30,130
    @posx[6],@posy[6]=120,155
    @posx[7],@posy[7]=30,190
    @posx[8],@posy[8]=Graphics.width-100,Graphics.height-150
    
    @viewport=Viewport.new(0,0,Graphics.width, Graphics.height)
    @viewport.z=99999
    
    @sprites["bg"]=IconSprite.new(0,0,@viewport)
    @sprites["bg"].setBitmap("Graphics/Pictures/Apricorn/Apricorn")
    @sprites["bg"].z=1
    
    @sprites["up"]=AnimatedSprite.create("Graphics/Pictures/Apricorn/uparrow1",10,3,@viewport)
    @sprites["up"].x=30
    @sprites["up"].y=0
    @sprites["up"].z=3
    @sprites["up"].play
    
    @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
    @sprites["overlay"].z=2
    overlay=@sprites["overlay"].bitmap
    overlay.clear
    base=Color.new(12*8,12*8,12*8)
    base1=Color.new(255,255,240)
    base2=Color.new(128,128,128)
    pbSetSystemFont(overlay)
  textpos=[
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::REDAPRICORN)),107,97,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::YLWAPRICORN)),203,130,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::BLUAPRICORN)),107,160,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::GRNAPRICORN)),203,193,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::PNKAPRICORN)),108,223,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::WHTAPRICORN)),203,256,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::BLKAPRICORN)),108,288,1,base,base2],
  [_ISPRINTF("Apricorn Box"),180,335,1,base1,base2],
  ]
 pbDrawTextPositions(overlay,textpos)
   
  if $PokemonBag.pbQuantity(PBItems::REDAPRICORN)!=0
    @sprites["REDAPRICORN"]=IconSprite.new(30,74,@viewport)
    @sprites["REDAPRICORN"].setBitmap("Graphics/Pictures/REDAPRICORN")
    @sprites["REDAPRICORN"].z=2
  end  
  if $PokemonBag.pbQuantity(PBItems::YLWAPRICORN)!=0
    @sprites["YLWAPRICORN"]=IconSprite.new(125,106,@viewport)
    @sprites["YLWAPRICORN"].setBitmap("Graphics/Pictures/YLWAPRICORN")
    @sprites["YLWAPRICORN"].z=2  
  end 
  if $PokemonBag.pbQuantity(PBItems::BLUAPRICORN)!=0
    @sprites["BLUAPRICORN"]=IconSprite.new(30,138,@viewport)
    @sprites["BLUAPRICORN"].setBitmap("Graphics/Pictures/BLUAPRICORN")
    @sprites["BLUAPRICORN"].z=2  
  end 
  if $PokemonBag.pbQuantity(PBItems::GRNAPRICORN)!=0
    @sprites["GRNAPRICORN"]=IconSprite.new(125,170,@viewport)
    @sprites["GRNAPRICORN"].setBitmap("Graphics/Pictures/GRNAPRICORN")
    @sprites["GRNAPRICORN"].z=2  
  end
  if $PokemonBag.pbQuantity(PBItems::PNKAPRICORN)!=0
    @sprites["PNKAPRICORN"]=IconSprite.new(30,202,@viewport)
    @sprites["PNKAPRICORN"].setBitmap("Graphics/Pictures/PNKAPRICORN")
    @sprites["PNKAPRICORN"].z=2  
  end
  if $PokemonBag.pbQuantity(PBItems::WHTAPRICORN)!=0
    @sprites["WHTAPRICORN"]=IconSprite.new(125,234,@viewport)
    @sprites["WHTAPRICORN"].setBitmap("Graphics/Pictures/WHTAPRICORN")
    @sprites["WHTAPRICORN"].z=2  
  end  
  if $PokemonBag.pbQuantity(PBItems::BLKAPRICORN)!=0
    @sprites["BLKAPRICORN"]=IconSprite.new(30,266,@viewport)
    @sprites["BLKAPRICORN"].setBitmap("Graphics/Pictures/BLKAPRICORN")
    @sprites["BLKAPRICORN"].z=2  
  end  

 end 
 
 
 def pbUpdate
  if @text_update==true  
   @sprites["overlay"].bitmap.clear
   pbSetSystemFont(@sprites["overlay"].bitmap)
   
   
    base=Color.new(12*8,12*8,12*8)
    base1=Color.new(255,255,240)
    base2=Color.new(128,128,128)
  textpos=[
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::REDAPRICORN)),107,97,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::YLWAPRICORN)),203,130,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::BLUAPRICORN)),107,160,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::GRNAPRICORN)),203,193,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::PNKAPRICORN)),108,223,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::WHTAPRICORN)),203,256,1,base,base2],
  [_ISPRINTF("{1:3d}",$PokemonBag.pbQuantity(PBItems::BLKAPRICORN)),108,288,1,base,base2],
  [_ISPRINTF("Apricorn Box"),180,335,1,base1,base2],
  ]
   pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
   @text_update=false
   @leave=true if @exit==true
   else
   end
   pbUpdateSpriteHash(@sprites)
  end
 
  def pbEndScene
   pbDisposeSpriteHash(@sprites)
   @viewport.dispose
  end
 
 
 
 
  def pbScene
  loop do
    Graphics.update
    Input.update
    pbUpdate
    
    if @leave==true
      @exit=false
      pbWait(20)
      break @leave=false
    end  
    if Input.trigger?(Input::LEFT)
        @choose-=1
        @choose=8 if @choose<=0
        @sprites["up"].x=@posx[@choose]
        @sprites["up"].y=@posy[@choose]
    elsif Input.trigger?(Input::RIGHT)
        @choose+=1
        @choose=1 if @choose>=9
        @sprites["up"].x=@posx[@choose]
        @sprites["up"].y=@posy[@choose]
    elsif Input.trigger?(Input::DOWN)
        @choose+=2
        @choose=1 if @choose>=9
        @sprites["up"].x=@posx[@choose]
        @sprites["up"].y=@posy[@choose]      
    elsif Input.trigger?(Input::UP)
        @choose-=2
        @choose=8 if @choose<=0
        @sprites["up"].x=@posx[@choose]
        @sprites["up"].y=@posy[@choose]
    elsif @sprites["up"].x==@posx[8] && @sprites["up"].y==@posy[8] && Input.trigger?(Input::C) || Input.trigger?(Input::B)
      break
    end
    
  interp=pbMapInterpreter
  thisEvent=interp.get_character(0)  
    
 if thisEvent.name=="Kurt"

      if @sprites["up"].x==@posx[1] && @sprites["up"].y==@posy[1] && $PokemonBag.pbQuantity(PBItems::REDAPRICORN)>=1 && Input.trigger?(Input::C)
       if Kernel.pbConfirmMessage(_INTL("Are you sure you want me to use a Red Apricorn?"))
     itemqty=$PokemonBag.pbQuantity(PBItems::REDAPRICORN)
      params=ChooseNumberParams.new
      params.setRange(1,itemqty)
      params.setInitialValue(itemqty)
      params.setCancelValue(0)
      qty=Kernel.pbMessageChooseNumber(
         _INTL("How much do you want to give?"),params
      )
        $PokemonBag.pbDeleteItem(PBItems::REDAPRICORN,qty)
        $game_variables[ApricornColorNumber]=1
        $game_variables[Apricornqty]=qty
        @sprites["REDAPRICORN"].dispose if $PokemonBag.pbQuantity(PBItems::REDAPRICORN)==0
        #pbMapInterpreter.pbSetSelfSwitch(thisEvent.id,"A",true)
        @text_update=true
        @exit=true
     else
         Kernel.pbMessage(_INTL("Please choose an Apricorn."))
       end
      end
    
       if @sprites["up"].x==@posx[2] && @sprites["up"].y==@posy[2] && $PokemonBag.pbQuantity(PBItems::YLWAPRICORN)>=1 && Input.trigger?(Input::C)
       if Kernel.pbConfirmMessage(_INTL("Are you sure you want me to use a Ylw Apricorn?"))
     itemqty=$PokemonBag.pbQuantity(PBItems::YLWAPRICORN)
      params=ChooseNumberParams.new
      params.setRange(1,itemqty)
      params.setInitialValue(itemqty)
      params.setCancelValue(0)
      qty=Kernel.pbMessageChooseNumber(
         _INTL("How much do you want to give?"),params
      )
        $PokemonBag.pbDeleteItem(PBItems::YLWAPRICORN,qty)
        $game_variables[ApricornColorNumber]=2
        $game_variables[Apricornqty]=qty
        @sprites["YLWAPRICORN"].dispose if $PokemonBag.pbQuantity(PBItems::YLWAPRICORN)==0
        #pbMapInterpreter.pbSetSelfSwitch(thisEvent.id,"A",true)
        @text_update=true
        @exit=true
        break
      else
         Kernel.pbMessage(_INTL("Please choose an Apricorn."))
      end
    end
    
       if @sprites["up"].x==@posx[3] && @sprites["up"].y==@posy[3] && $PokemonBag.pbQuantity(PBItems::BLUAPRICORN)>=1 && Input.trigger?(Input::C)
       if Kernel.pbConfirmMessage(_INTL("Are you sure you want me to use a Blu Apricorn?"))
     itemqty=$PokemonBag.pbQuantity(PBItems::BLUAPRICORN)
      params=ChooseNumberParams.new
      params.setRange(1,itemqty)
      params.setInitialValue(itemqty)
      params.setCancelValue(0)
      qty=Kernel.pbMessageChooseNumber(
         _INTL("How much do you want to give?"),params
      )
        $PokemonBag.pbDeleteItem(PBItems::BLUAPRICORN,qty)
        $game_variables[ApricornColorNumber]=3
        $game_variables[Apricornqty]=qty
        @sprites["BLUAPRICORN"].dispose if $PokemonBag.pbQuantity(PBItems::BLUAPRICORN)==0
        #pbMapInterpreter.pbSetSelfSwitch(thisEvent.id,"A",true)
        @text_update=true
        @exit=true
        break
      else
         Kernel.pbMessage(_INTL("Please choose an Apricorn."))
      end
    end
    
       if @sprites["up"].x==@posx[4] && @sprites["up"].y==@posy[4] && $PokemonBag.pbQuantity(PBItems::GRNAPRICORN)>=1 && Input.trigger?(Input::C)
       if Kernel.pbConfirmMessage(_INTL("Are you sure you want me to use a Grn Apricorn?"))
     itemqty=$PokemonBag.pbQuantity(PBItems::GRNAPRICORN)
      params=ChooseNumberParams.new
      params.setRange(1,itemqty)
      params.setInitialValue(itemqty)
      params.setCancelValue(0)
      qty=Kernel.pbMessageChooseNumber(
         _INTL("How much do you want to give?"),params
      )
        $PokemonBag.pbDeleteItem(PBItems::GRNAPRICORN,qty)
        $game_variables[ApricornColorNumber]=4
        $game_variables[Apricornqty]=qty
        @sprites["GRNAPRICORN"].dispose if $PokemonBag.pbQuantity(PBItems::GRNAPRICORN)==0
        #pbMapInterpreter.pbSetSelfSwitch(thisEvent.id,"A",true)
        @text_update=true
        @exit=true
        break
      else
         Kernel.pbMessage(_INTL("Please choose an Apricorn."))
      end
    end    
    
       if @sprites["up"].x==@posx[5] && @sprites["up"].y==@posy[5] && $PokemonBag.pbQuantity(PBItems::PNKAPRICORN)>=1 && Input.trigger?(Input::C)
       if Kernel.pbConfirmMessage(_INTL("Are you sure you want me to use a Pnk Apricorn?"))
     itemqty=$PokemonBag.pbQuantity(PBItems::PNKAPRICORN)
      params=ChooseNumberParams.new
      params.setRange(1,itemqty)
      params.setInitialValue(itemqty)
      params.setCancelValue(0)
      qty=Kernel.pbMessageChooseNumber(
         _INTL("How much do you want to give?"),params
      )
        $PokemonBag.pbDeleteItem(PBItems::PNKAPRICORN,qty)
        $game_variables[ApricornColorNumber]=5
        $game_variables[Apricornqty]=qty
        @sprites["PNKAPRICORN"].dispose if $PokemonBag.pbQuantity(PBItems::PNKAPRICORN)==0
        #pbMapInterpreter.pbSetSelfSwitch(thisEvent.id,"A",true)
        @text_update=true
        @exit=true
        break
      else
         Kernel.pbMessage(_INTL("Please choose an Apricorn."))
      end
    end    
    
       if @sprites["up"].x==@posx[6] && @sprites["up"].y==@posy[6] && $PokemonBag.pbQuantity(PBItems::WHTAPRICORN)>=1 && Input.trigger?(Input::C)
       if Kernel.pbConfirmMessage(_INTL("Are you sure you want me to use a Wht Apricorn?"))
     itemqty=$PokemonBag.pbQuantity(PBItems::WHTAPRICORN)
      params=ChooseNumberParams.new
      params.setRange(1,itemqty)
      params.setInitialValue(itemqty)
      params.setCancelValue(0)
      qty=Kernel.pbMessageChooseNumber(
         _INTL("How much do you want to give?"),params
      )
        $PokemonBag.pbDeleteItem(PBItems::WHTAPRICORN,qty)
        $game_variables[ApricornColorNumber]=6
        $game_variables[Apricornqty]=qty
        @sprites["WHTAPRICORN"].dispose if $PokemonBag.pbQuantity(PBItems::WHTAPRICORN)==0
        #pbMapInterpreter.pbSetSelfSwitch(thisEvent.id,"A",true)
        @text_update=true
        @exit=true
        break
      else
         Kernel.pbMessage(_INTL("Please choose an Apricorn."))
      end
    end   
    
       if @sprites["up"].x==@posx[7] && @sprites["up"].y==@posy[7] && $PokemonBag.pbQuantity(PBItems::WHTAPRICORN)>=1 && Input.trigger?(Input::C)
       if Kernel.pbConfirmMessage(_INTL("Are you sure you want me to use a Blk Apricorn?"))
     itemqty=$PokemonBag.pbQuantity(PBItems::BLKAPRICORN)
      params=ChooseNumberParams.new
      params.setRange(1,itemqty)
      params.setInitialValue(itemqty)
      params.setCancelValue(0)
      qty=Kernel.pbMessageChooseNumber(
         _INTL("How much do you want to give?"),params
      )
        $PokemonBag.pbDeleteItem(PBItems::BLKAPRICORN,qty)
        $game_variables[ApricornColorNumber]=7
        $game_variables[Apricornqty]=qty
        @sprites["BLKAPRICORN"].dispose if $PokemonBag.pbQuantity(PBItems::BLKAPRICORN)==0
        #pbMapInterpreter.pbSetSelfSwitch(thisEvent.id,"A",true)
        @text_update=true
        @exit=true
        break
      else
         Kernel.pbMessage(_INTL("Please choose an Apricorn."))
      end
    end  
    
    
    
    
    
    
    
    end
 

    
    
    
    end    
  end
end

    class ApricornScreen
         def initialize(scene)
                @scene = scene
         end
              
         def pbStartScreen
                @scene.pbStartScene
                @scene.pbScene
                @scene.pbEndScene
         end
    end

def pbPokeballTime
  if(1<=$game_variables[ApricornColorNumber] && $game_variables[ApricornColorNumber]<=7)
    apricornBall=[PBItems::LEVELBALL,PBItems::MOONBALL,PBItems::LUREBALL,PBItems::FRIENDBALL,
    PBItems::LOVEBALL,PBItems::FASTBALL,PBItems::HEAVYBALL][$game_variables[ApricornColorNumber]-1]
    Kernel.pbReceiveItem(apricornBall,$game_variables[Apricornqty])
    $game_variables[Apricornqty]=0
  end
end

    def pbApricorn
          scene=Apricorn.new
          screen=ApricornScreen.new(scene)
          pbFadeOutIn(99999) { 
          screen.pbStartScreen
          }
    end
And this goes into your settings page
Code:
#===============================================================================
# * These are custom settings for the Apricorn Box.
# * "ApricornColorNumber" defines which Apricorn color represents which number
#      set it to what ever variable you want.
# * "Apricornqty" defines the quantity of the Apricorn which you want to make
#      again set it to what ever variable you want.
# * The "Choose" switch is to define if the player can only view what is inside
#      the Apricorn box, or choose an item inside. 
#===============================================================================
ApricornColorNumber=50
Apricornqty=51
Mini tut
Code:
Okay, so here is how you use it.
pbPokeballTime
 must be used with a time sensitive event, because it is not like he can craft a pokeball in a blink of an eye like magic.

To call upon the screen you must use
pbApricorn
To make the Apricorn box into an item:
Code:
ItemHandlers::UseFromBag.add(:APRICORNBOX,proc{|item|
   pbApricorn
   next 1 # Continue
})
^ put that in PokemonItemEffects
under
Code:
ItemHandlers::UseFromBag.add(:TOWNMAP,proc{|item|
   pbShowMap
   next 1 # Continue
})
Also put this:
Code:
ItemHandlers::UseInField.add(:APRICORNBOX,proc{|item|
   pbApricorn
})
under:
Code:
ItemHandlers::UseInField.add(:OLDROD,proc{|item|
   terrain=Kernel.pbFacingTerrainTag
   if !pbIsWaterTag?(terrain)
     Kernel.pbMessage(_INTL("Can't use that here."))
     next
   end
   encounter=$PokemonEncounters.hasEncounter?(4)
   if pbFishing(encounter)
     pbEncounter(4)
   end
})
Put the attachment inside your Pictures folder(so it will be Pictures/Apricorn).
Attached Files
File Type: rar Apricorn.rar‎ (47.5 KB, 69 views) (Save to Dropbox)
__________________
Pokemon Serenity is my fangame name.
name decided 12/15/09
Currently helping:
Pokemon ebony
and
Xenotime:

Last edited by zingzags; August 22nd, 2012 at 01:59 PM. Reason: Forgot to add mini-tut
Reply With Quote