Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Demonfires pokemon kit, custimizing the bag script and need help...

Hello everyone, I was a long time user of the original RPG makers and have decided to make a pokemon game using the "new" RMXP. I downloaded the (true pokemon starter kit), the one made by Demon Fire. Its a great kit and all but I am upgrading all the menus and some other ingame things to more recent versions of the pokemon games.

I havent used RMXP before and this scripting this is somewhat new to me, I have experience in C++, HTML, PHP, those kind of languages but nothing like this before.

What I am trying to do is edit the menu screen so that when you scroll between the different pockets in your bag it will display an image in the upper left showing what bag your in. There are only 5 bag pockets and 2 images for each pocket. (Items, Key Items, TMs/Hms, Berries, and Pokeballs). If someone could help me that would be great, I will post the PokemonBag script now to see if you can help.

I think it has something to do with the lines around 490-500 where it labels the bag pockets. It labels them with text and I merely want them labeled with 2 pictures instead. Thanks in advance.

Code:
ITEMID=0
ITEMNAME=1
ITEMPOCKET=2
ITEMPRICE=3
ITEMDESC=4
ITEMUSE=5
ITEMBATTLEUSE=6
ITEMTYPE=7
ITEMMACHINE=8

def pbResizeWindow(window,x,y,width,height,viewport=nil)
 window.x=x
 window.y=y
 window.width=width
 window.height=height
 if viewport && window.is_a?(SpriteWindow)
  window.viewport=viewport
 end
end

class Window_PokemonBag < SpriteWindow_Selectable
 attr_reader :bag
 attr_reader :pocket
 attr_reader :baseColor
 attr_reader :shadowColor
 def initialize(bag,pocket,x,y,width,height)
  super(x,y,width,height)
  @bag=bag
  @pocket=pocket
  self.windowskin=nil
  @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png")
  @uparrow=AnimatedSprite.new("Graphics/Pictures/uparrow.png",8,28,40,2,@viewport)
  @downarrow=AnimatedSprite.new("Graphics/Pictures/downarrow.png",8,28,40,2,@viewport)
  @uparrow.play
  @downarrow.play
  @sortIndex=-1
  @index=0
  @baseColor=Color.new(72,72,72)
  @shadowColor=Color.new(208,208,208)
  refresh
 end
 def pocket=(value)
  @pocket=value
  thispocket=@bag.pockets[@pocket]
  @item_max=thispocket.length+1
  self.index=@bag.getChoice(@pocket)
  self.update_cursor_rect
  refresh
 end
 def dispose
  @selarrow.dispose
  @uparrow.dispose
  @downarrow.dispose
  super
 end
 def sortIndex
  return @sortIndex
 end
 def sortIndex=(value)
  @sortIndex=value
  refresh
 end
 def color=(value)
  super
  @uparrow.color=self.color
  @downarrow.color=self.color
 end
 def baseColor=(value)
  @baseColor=value
  refresh
 end
 def shadowColor=(value)
  @shadowColor=value
  refresh
 end
 def item
  thispocket=@bag.pockets[self.pocket]
  item=thispocket[self.index]
  return item ? item[0] : 0
 end
 def refresh
  thispocket=@bag.pockets[self.pocket]
  @bag.setChoice(self.pocket,self.index)
  @bag.lastpocket=self.pocket
  @item_max=thispocket.length+1
  dwidth=self.width-32
  dheight=self.height-32
  if !self.contents || self.contents.height<dheight || self.contents.width<dwidth
   self.contents.dispose if self.contents
   self.contents=Bitmap.new([1,dwidth].max,[1,dheight].max)
   pbSetSystemFont(self.contents)
  end
  @uparrow.x=self.x+(self.width/2)-(@uparrow.framewidth/2)
  @downarrow.x=self.x+(self.width/2)-(@downarrow.framewidth/2)
  @uparrow.y=self.y
  @downarrow.y=self.y+self.height-@downarrow.frameheight
  @uparrow.visible=(self.top_row!=0 && @item_max > self.page_item_max)
  @downarrow.visible=(self.top_row+self.page_item_max<@item_max && @item_max > self.page_item_max)
  @uparrow.viewport=self.viewport
  @downarrow.viewport=self.viewport
  contentsWidth=self.contents.width
  ypos=0
  trans=Color.new(0,0,0,0)
  self.contents.clear
  for i in 0..thispocket.length
   if i<self.top_row || i>self.top_row+self.page_row_max
    next
   end
   textpos=[]
   if i==thispocket.length
    pbCopyBitmap(self.contents,@selarrow,0,ypos) if self.index==i
    textpos.push([_INTL("CLOSE BAG"),16,ypos,false,self.baseColor,self.shadowColor])
   else
    item=thispocket[i][0]
    itemname=PBItems.getName(item)
    if $ItemData[item][ITEMPOCKET]==3
     machine=$ItemData[item][ITEMMACHINE]
     itemname=_INTL("{1} {2}",itemname,PBMoves.getName(machine))
    end
    qty=_ISPRINTF("x{1: 2d}",thispocket[i][1])
    sizeQty=self.contents.text_size(qty).width
    xQty=contentsWidth-sizeQty-2
    pbCopyBitmap(self.contents,@selarrow,0,ypos) if self.index==i
    baseColor=(i==@sortIndex) ? Color.new(248,24,24) : self.baseColor
    textpos.push([itemname,16,ypos,false,baseColor,self.shadowColor])
    textpos.push([qty,xQty,ypos,false,baseColor,self.shadowColor]) if self.pocket!=5
   end
   pbDrawTextPositions(self.contents,textpos)
   if i!=thispocket.length
    if self.pocket==5 && @bag.registeredItem==thispocket[i][0]
     pbDrawImagePositions(self.contents,[
      ["Graphics/Pictures/regitem.png",224,ypos+8,0,0,-1,-1]
     ])
    end
   end
   ypos+=32
  end
 end
 def update
  oldindex=self.index
  super
  @uparrow.update
  @downarrow.update
  refresh if self.index!=oldindex
 end
end

class Window_PokemonItemStorage < SpriteWindow_Selectable
 attr_reader :bag
 attr_reader :pocket
 attr_reader :baseColor
 attr_reader :shadowColor
 def initialize(bag,x,y,width,height)
  super(x,y,width,height)
  @bag=bag
  self.windowskin=nil
  @selarrow=BitmapCache.load_bitmap("Graphics/Pictures/selarrow.png")
  @uparrow=AnimatedSprite.new("Graphics/Pictures/uparrow.png",8,28,40,2,@viewport)
  @downarrow=AnimatedSprite.new("Graphics/Pictures/downarrow.png",8,28,40,2,@viewport)
  @uparrow.play
  @downarrow.play
  @index=0
  @sortIndex=-1
  @baseColor=Color.new(72,72,72)
  @shadowColor=Color.new(208,208,208)
  refresh
 end
 def dispose
  @selarrow.dispose
  @uparrow.dispose
  @downarrow.dispose
  super
 end
 def color=(value)
  super
  @uparrow.color=self.color
  @downarrow.color=self.color
 end
 def baseColor=(value)
  @baseColor=value
  refresh
 end
 def shadowColor=(value)
  @shadowColor=value
  refresh
 end
 def item
  item=@bag[self.index]
  return item ? item[0] : 0
 end
 def refresh
  @item_max=@bag.length+1
  dwidth=self.width-32
  dheight=self.height-32
  if !self.contents || self.contents.height<dheight || self.contents.width<dwidth
   self.contents.dispose if self.contents
   self.contents=Bitmap.new([1,dwidth].max,[1,dheight].max)
   pbSetSystemFont(self.contents)
  end
  @uparrow.x=self.x+(self.width/2)-(@uparrow.framewidth/2)
  @downarrow.x=self.x+(self.width/2)-(@downarrow.framewidth/2)
  @uparrow.y=self.y
  @downarrow.y=self.y+self.height-@downarrow.frameheight
  @uparrow.visible=(self.top_row!=0 && @item_max > self.page_item_max)
  @downarrow.visible=(self.top_row+self.page_item_max<@item_max && @item_max > self.page_item_max)
  @uparrow.viewport=self.viewport
  @downarrow.viewport=self.viewport
  contentsWidth=self.contents.width
  ypos=0
  trans=Color.new(0,0,0,0)
  self.contents.clear
  for i in 0..@bag.length
   if i<self.top_row || i>self.top_row+self.page_row_max
    next
   end
   textpos=[]
   if i==@bag.length
    pbCopyBitmap(self.contents,@selarrow,0,ypos) if self.index==i
    textpos.push([_INTL("CANCEL"),16,ypos,false,self.baseColor,self.shadowColor])
   else
    item=@bag[i][0]
    itemname=PBItems.getName(item)
    if $ItemData[item][ITEMPOCKET]==3
     machine=$ItemData[item][ITEMMACHINE]
     itemname=_INTL("{1} {2}",itemname,PBMoves.getName(machine))
    end
    qty=_ISPRINTF("x{1: 2d}",@bag[i][1])
    sizeQty=self.contents.text_size(qty).width
    xQty=contentsWidth-sizeQty-2
    pbCopyBitmap(self.contents,@selarrow,0,ypos) if self.index==i
    baseColor=(i==@sortIndex) ? Color.new(248,24,24) : self.baseColor
    textpos.push([itemname,16,ypos,false,baseColor,self.shadowColor])
    if $ItemData[item][ITEMPOCKET]!=5
     textpos.push([qty,xQty,ypos,false,baseColor,self.shadowColor])
    end
   end
   pbDrawTextPositions(self.contents,textpos)
   ypos+=32
  end
 end
 def update
  oldindex=self.index
  super
  @uparrow.update
  @downarrow.update
  refresh if self.index!=oldindex
 end
end



######################################################

module ItemStorageUIHelper

def self.pbChooseNumber(helpwindow,helptext,maximum)
 helpwindow.visible=true
 helpwindow.text=helptext
 helpwindow.letterbyletter=false
 curnumber=1
 ret=0
 using(numwindow=Window_SimpleTextPokemon.new(_INTL("x000"))){
   numwindow.viewport=helpwindow.viewport
   numwindow.letterbyletter=false
   numwindow.baseColor=Color.new(72,72,72)
   numwindow.shadowColor=Color.new(208,208,208)
   numwindow.text=_ISPRINTF("x{1:03d}",curnumber)
   numwindow.resizeToFit(numwindow.text,480)
   pbBottomRight(numwindow)
   helpwindow.resizeHeightToFit(helpwindow.text,480-numwindow.width)
   pbBottomLeft(helpwindow)
   loop do
     Graphics.update
     Input.update
     numwindow.update
     helpwindow.update
     if Input.repeat?(Input::LEFT)
      curnumber-=10
      curnumber=1 if curnumber<1
      numwindow.text=_ISPRINTF("x{1:03d}",curnumber)
     elsif Input.repeat?(Input::RIGHT)
      curnumber+=10
      curnumber=maximum if curnumber>maximum
      numwindow.text=_ISPRINTF("x{1:03d}",curnumber)
     elsif Input.repeat?(Input::UP)
      curnumber+=1
      curnumber=1 if curnumber>maximum
      numwindow.text=_ISPRINTF("x{1:03d}",curnumber)
     elsif Input.repeat?(Input::DOWN)
      curnumber-=1
      curnumber=maximum if curnumber<1
      numwindow.text=_ISPRINTF("x{1:03d}",curnumber)
     elsif Input.trigger?(Input::C)
      ret=curnumber
      break
     elsif Input.trigger?(Input::B)
      ret=0
      break
     end
  end
 }
 helpwindow.visible=false
 return ret
end

def self.pbDisplay(helpwindow,msg,brief)
 cw=helpwindow
 cw.letterbyletter=true
 cw.text=msg
 pbBottomLeftLines(cw,2)
 cw.visible=true
 i=0
 loop do
  Graphics.update
  Input.update
  cw.update
  if brief && !cw.busy?
   return
  end
  if i==60
   return
  end
  i+=1 if !cw.busy?
 end
end

def self.pbDisplayPaused(helpwindow,msg)
 cw=helpwindow
 cw.letterbyletter=true
 cw.text=msg
 pbBottomLeftLines(cw,2)
 cw.visible=true
 i=0
 loop do
  Graphics.update
  Input.update
  cw.update
  if Input.trigger?(Input::C) && cw.resume && !cw.busy?
   return
  end
 end
end


def self.pbConfirm(helpwindow,msg)
 dw=helpwindow
 dw.letterbyletter=true
 dw.text=msg
 dw.visible=true
 pbBottomLeftLines(dw,2)
 commands=[_INTL("YES"),_INTL("NO")]
 cw = Window_CommandPokemon.new(commands)
 cw.viewport=helpwindow.viewport
 pbBottomRight(cw)
 cw.y-=dw.height
 cw.index=0
 loop do
  cw.visible=!dw.busy?
  Graphics.update
  Input.update
  cw.update
  dw.update
  if Input.trigger?(Input::B) && dw.resume && !dw.busy?
   cw.dispose
   return false
  end
  if Input.trigger?(Input::C) && dw.resume && !dw.busy?
   cw.dispose
   return (cw.index==0)?true:false
  end
 end
end


def self.pbShowCommands(helpwindow,helptext,commands)
 ret=-1
 helpwindow.visible=true
 helpwindow.letterbyletter=false
 helpwindow.text=helptext
 using(cmdwindow=Window_CommandPokemon.new(commands)) {
   cmdwindow.viewport=helpwindow.viewport
   pbBottomRight(cmdwindow)
   helpwindow.resizeHeightToFit(helpwindow.text,480-cmdwindow.width)
   pbBottomLeft(helpwindow)
   loop do
    Graphics.update
    Input.update
    cmdwindow.update
    if Input.trigger?(Input::B)
     ret=-1
     break
    end
    if Input.trigger?(Input::C)
     ret=cmdwindow.index
     break
    end
   end
 }
 helpwindow.visible=false
 return ret
end

end


class PokemonBag_Scene

def update
 pbUpdateSpriteHash(@sprites)
end

def pbStartScene(bag)
  @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  @viewport.z=99999
  @bag=bag
  @sprites={}
  lastpocket=@bag.lastpocket
  lastitem=@bag.getChoice(lastpocket)
  @sprites["background"]=SpriteWrapper.new(@viewport)
  @sprites["background"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/bagscreen2.png")
  @sprites["leftarrow"]=AnimatedSprite.new("Graphics/Pictures/leftarrow.png",8,40,28,2,@viewport)
  @sprites["rightarrow"]=AnimatedSprite.new("Graphics/Pictures/rightarrow.png",8,40,28,2,@viewport)
  @sprites["leftarrow"].play
  @sprites["rightarrow"].play
  @sprites["bag"]=IconSprite.new(16,72,@viewport)
  @sprites["icon"]=IconSprite.new(16,248,@viewport)
  @sprites["itemwindow"]=Window_PokemonBag.new(@bag,lastpocket,160,0,304,224)
  @sprites["itemwindow"].viewport=@viewport
  @sprites["itemwindow"].pocket=lastpocket
  @sprites["itemwindow"].index=lastitem
  @sprites["itemwindow"].refresh
  @sprites["pocketwindow"]=SpriteWrapper.new(@viewport)
  @sprites["pocketwindow"].x=0
  @sprites["pocketwindow"].y=0
  @sprites["pocketwindow"].bitmap=Bitmap.new(176,64)
  pbSetSystemFont(@sprites["pocketwindow"].bitmap)
  @sprites["itemtextwindow"]=Window_SimpleTextPokemon.new("")
  @sprites["itemtextwindow"].x=64
  @sprites["itemtextwindow"].y=208
  @sprites["itemtextwindow"].width=480-64
  @sprites["itemtextwindow"].height=128
  @sprites["itemtextwindow"].baseColor=Color.new(31*8,31*8,31*8)
  @sprites["itemtextwindow"].shadowColor=Color.new(12*8,12*8,12*8)
  @sprites["itemtextwindow"].visible=true
  @sprites["itemtextwindow"].viewport=@viewport
  @sprites["itemtextwindow"].windowskin=nil
  @sprites["helpwindow"]=Window_SimpleTextPokemon.new("")
  @sprites["helpwindow"].visible=false
  @sprites["helpwindow"].viewport=@viewport
  @sprites["helpwindow"].baseColor=Color.new(72,72,72)
  @sprites["helpwindow"].shadowColor=Color.new(208,208,208)
  pbBottomLeftLines(@sprites["helpwindow"],1)
  pbRefresh
  pbFadeInAndShow(@sprites)
end

def pbEndScene
  pbFadeOutAndHide(@sprites)
  pbDisposeSpriteHash(@sprites)
  @viewport.dispose
end

def pbChooseNumber(helptext,maximum)
 return ItemStorageUIHelper.pbChooseNumber(
  @sprites["helpwindow"],helptext,maximum)
end

def pbDisplay(msg,brief=false)
 ItemStorageUIHelper.pbDisplay(
  @sprites["helpwindow"],msg,brief)
end

def pbDisplayPaused(msg)
 ItemStorageUIHelper.pbDisplayPaused(
  @sprites["helpwindow"],msg)
end

def pbConfirm(msg)
 ItemStorageUIHelper.pbConfirm(
  @sprites["helpwindow"],msg)
end

def pbShowCommands(helptext,commands)
 return ItemStorageUIHelper.pbShowCommands(
   @sprites["helpwindow"],helptext,commands)
end


def pbRefresh
 bm=@sprites["pocketwindow"].bitmap
 bm.clear
 pocketNames=["",
   _INTL("Items"),_INTL("Pokeballs"),
   _INTL("TM"),_INTL("Berries"),
   _INTL("Key Items")
 ]
 name=pocketNames[@bag.lastpocket]
 @sprites["bag"].setBitmap("Graphics/Pictures/Bag#{@bag.lastpocket}.png")
 base=Color.new(31*8,31*8,31*8)
 shadow=Color.new(12*8,12*8,12*8)
 pbDrawTextPositions(bm,[
   [name,bm.width/2,16,2,base,shadow]
 ])
 @sprites["leftarrow"].x=-4
 @sprites["leftarrow"].y=128
 @sprites["rightarrow"].x=124
 @sprites["rightarrow"].y=128
 itemwindow=@sprites["itemwindow"]
 filename=sprintf("Graphics/Icons/item%03d.png",itemwindow.item)
 @sprites["icon"].setBitmap(filename)
 @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Close bag.") : 
      pbGetMessage(MessageTypes::ItemDescriptions,itemwindow.item)
 itemwindow.refresh
end



def pbChooseItem
 @sprites["helpwindow"].visible=false
 itemwindow=@sprites["itemwindow"]
 itemwindow.refresh
 sorting=false
 sortindex=-1
 loop do
  Graphics.update
  Input.update
  olditem=itemwindow.item
  self.update
  if itemwindow.item!=olditem
   filename=sprintf("Graphics/Icons/item%03d.png",itemwindow.item)
   @sprites["icon"].setBitmap(filename)
   @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Close bag.") :
      pbGetMessage(MessageTypes::ItemDescriptions,itemwindow.item)
  end
  if Input.trigger?(Input::LEFT)
   itemwindow.pocket=(itemwindow.pocket==1) ? 5 : itemwindow.pocket-1
   pbRefresh
  elsif Input.trigger?(Input::RIGHT)
   itemwindow.pocket=(itemwindow.pocket==5) ? 1 : itemwindow.pocket+1
   pbRefresh
  end
  if Input.trigger?(Input::A)
   thispocket=@bag.pockets[itemwindow.pocket]
   if itemwindow.index<thispocket.length
    sortindex=itemwindow.index
    sorting=true
    @sprites["itemwindow"].sortIndex=sortindex
   else
    next
   end
  end
  if Input.trigger?(Input::B)
   if sorting
    sorting=false
    @sprites["itemwindow"].sortIndex=-1
   else
    return 0
   end
  end
  if Input.trigger?(Input::C)
   thispocket=@bag.pockets[itemwindow.pocket]
   if itemwindow.index<thispocket.length
    if sorting
     sorting=false
     tmp=thispocket[itemwindow.index]
     thispocket[itemwindow.index]=thispocket[sortindex]
     thispocket[sortindex]=tmp
     @sprites["itemwindow"].sortIndex=-1
     next
    else
     pbRefresh
     return thispocket[itemwindow.index][0]
    end
   else
    return 0
   end
  end
 end
end


end


class ItemStorageScene

def initialize(title)
 @title=title
end

def update
 pbUpdateSpriteHash(@sprites)
end

def pbStartScene(bag)
  @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  @viewport.z=99999
  @bag=bag
  @sprites={}
  @sprites["background"]=SpriteWrapper.new(@viewport)
  @sprites["background"].bitmap=BitmapCache.load_bitmap("Graphics/Pictures/pcitembg.png")
  @sprites["icon"]=IconSprite.new(16,248,@viewport)
  @sprites["itemwindow"]=Window_PokemonItemStorage.new(@bag,96,0,304,224)
  @sprites["itemwindow"].viewport=@viewport
  @sprites["itemwindow"].index=0
  @sprites["itemwindow"].refresh
  @sprites["pocketwindow"]=SpriteWrapper.new(@viewport)
  @sprites["pocketwindow"].x=16
  @sprites["pocketwindow"].y=16
  @sprites["pocketwindow"].bitmap=Bitmap.new(88,64)
  pbSetNarrowFont(@sprites["pocketwindow"].bitmap)
  @sprites["itemtextwindow"]=Window_SimpleTextPokemon.newWithSize("",64,208,480-64,128,@viewport)
  @sprites["itemtextwindow"].baseColor=Color.new(31*8,31*8,31*8)
  @sprites["itemtextwindow"].shadowColor=Color.new(12*8,12*8,12*8)
  @sprites["itemtextwindow"].windowskin=nil
  @sprites["helpwindow"]=Window_SimpleTextPokemon.new("")
  @sprites["helpwindow"].visible=false
  @sprites["helpwindow"].viewport=@viewport
  @sprites["helpwindow"].baseColor=Color.new(72,72,72)
  @sprites["helpwindow"].shadowColor=Color.new(208,208,208)
  pbBottomLeftLines(@sprites["helpwindow"],1)
  pbRefresh
  pbFadeInAndShow(@sprites)
end

def pbEndScene
  pbFadeOutAndHide(@sprites)
  pbDisposeSpriteHash(@sprites)
  @viewport.dispose
end

def pbRefresh
 bm=@sprites["pocketwindow"].bitmap
 drawTextEx(bm,0,0,bm.width,2,@title,
    Color.new(31*8,31*8,31*8),
    Color.new(12*8,12*8,12*8)
 )
 itemwindow=@sprites["itemwindow"]
 filename=sprintf("Graphics/Icons/item%03d.png",itemwindow.item)
 @sprites["icon"].setBitmap(filename)
 @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Close storage.") : 
      pbGetMessage(MessageTypes::ItemDescriptions,itemwindow.item)
 itemwindow.refresh
end

def pbChooseItem
 @sprites["helpwindow"].visible=false
 itemwindow=@sprites["itemwindow"]
 itemwindow.refresh
 loop do
  Graphics.update
  Input.update
  olditem=itemwindow.item
  self.update
  if itemwindow.item!=olditem
   self.pbRefresh
  end
  if Input.trigger?(Input::B)
   return 0
  end
  if Input.trigger?(Input::C)
   if itemwindow.index<@bag.length
    pbRefresh
    return @bag[itemwindow.index][0]
   else
    return 0
   end
  end
 end
end

def pbChooseNumber(helptext,maximum)
 return ItemStorageUIHelper.pbChooseNumber(
  @sprites["helpwindow"],helptext,maximum)
end

def pbDisplay(msg,brief=false)
 ItemStorageUIHelper.pbDisplay(
  @sprites["helpwindow"],msg,brief)
end

def pbDisplayPaused(msg)
 ItemStorageUIHelper.pbDisplayPaused(
  @sprites["helpwindow"],msg)
end

def pbConfirm(msg)
 ItemStorageUIHelper.pbConfirm(
  @sprites["helpwindow"],msg)
end

def pbShowCommands(helptext,commands)
 return ItemStorageUIHelper.pbShowCommands(
   @sprites["helpwindow"],helptext,commands)
end


end


class WithdrawItemScene < ItemStorageScene
 def initialize
  super(_INTL("WITHDRAW\nITEM"))
 end
end

class TossItemScene < ItemStorageScene
 def initialize
  super(_INTL("TOSS\nITEM"))
 end
end



module ItemStorageHelper
 def self.pbQuantity(items,maxsize,item)
  ret=0
  for i in 0...maxsize
   itemslot=items[i]
   if itemslot && itemslot[0]==item
    ret+=itemslot[1]
   end
  end
  return ret
 end
 def self.pbDeleteItem(items,maxsize,item,qty)
  raise "Invalid value for qty: #{qty}" if qty<0
  return true if qty==0
  ret=false
  for i in 0...maxsize
   itemslot=items[i]
   if itemslot && itemslot[0]==item
    amount=[qty,itemslot[1]].min
    itemslot[1]-=amount
    qty-=amount
    items[i]=nil if itemslot[1]==0
    if qty==0
     ret=true
     break
    end
   end
  end
  items.compact!
  return ret
 end
 def self.pbCanStore?(items,maxsize,maxPerSlot,item,qty)
  raise "Invalid value for qty: #{qty}" if qty<0
  return true if qty==0
  for i in 0...maxsize
   itemslot=items[i]
   if !itemslot
    qty-=[qty,maxPerSlot].min
    return true if qty==0
   elsif itemslot[0]==item && itemslot[1]<maxPerSlot
    newamt=itemslot[1]
    newamt=[newamt+qty,maxPerSlot].min
    qty-=(newamt-itemslot[1])
    return true if qty==0
   end
  end
  return false
 end
 def self.pbStoreItem(items,maxsize,maxPerSlot,item,qty)
  raise "Invalid value for qty: #{qty}" if qty<0
  return true if qty==0
  for i in 0...maxsize
   itemslot=items[i]
   if !itemslot
    items[i]=[item,[qty,maxPerSlot].min]
    qty-=items[i][1]
    return true if qty==0
   elsif itemslot[0]==item && itemslot[1]<maxPerSlot
    newamt=itemslot[1]
    newamt=[newamt+qty,maxPerSlot].min
    qty-=(newamt-itemslot[1])
    itemslot[1]=newamt
    return true if qty==0
   end
  end
  return false
 end
end

class PokemonBag
 attr_reader :registeredItem
 attr_accessor :lastpocket
 attr_reader :pockets
 MAXPERSLOT=99
 MAXPOCKETSIZE=[0,256,-1,-1,-1,-1]
 def initialize
  @lastpocket=1
  @pockets=[]
  @pockets[0]=[]
  @pockets[1]=[]
  @pockets[2]=[]
  @pockets[3]=[]
  @pockets[4]=[]
  @pockets[5]=[]
  @choices=[0,0,0,0,0,0]
  @registeredItem=0
 end
 def getChoice(pocket)
  raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect)) if pocket<=0 || pocket>5
  return @choices[pocket]
 end
 def clear
  for pocket in @pockets
   pocket.clear
  end
 end
 def setChoice(pocket,value)
  raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect)) if pocket<=0 || pocket>5
  @choices[pocket]=value if value<@pockets[pocket].length
 end
 def pbRegisterKeyItem(item)
  if item!=@registeredItem
   @registeredItem=item
  else
   @registeredItem=0
  end
 end
 def pbQuantity(item)
  pocket=$ItemData[item][ITEMPOCKET]
  maxsize=MAXPOCKETSIZE[pocket]
  maxsize=@pockets[pocket].length if maxsize<0
  return ItemStorageHelper.pbQuantity(
    @pockets[pocket],maxsize,item)
 end
 def pbDeleteItem(item,qty=1)
  pocket=$ItemData[item][ITEMPOCKET]
  maxsize=MAXPOCKETSIZE[pocket]
  maxsize=@pockets[pocket].length if maxsize<0
  ret=ItemStorageHelper.pbDeleteItem(
    @pockets[pocket],maxsize,item,qty)
  if ret
   @registeredItem=0 if @registeredItem==item
  end
  return ret
 end
 def pbCanStore?(item,qty=1)
  pocket=$ItemData[item][ITEMPOCKET]
  maxsize=MAXPOCKETSIZE[pocket]
  maxsize=@pockets[pocket].length+1 if maxsize<0
  return ItemStorageHelper.pbCanStore?(
    @pockets[pocket],maxsize,MAXPERSLOT,item,qty)
 end
 def pbStoreItem(item,qty=1)
  pocket=$ItemData[item][ITEMPOCKET]
  maxsize=MAXPOCKETSIZE[pocket]
  maxsize=@pockets[pocket].length+1 if maxsize<0
  return ItemStorageHelper.pbStoreItem(
    @pockets[pocket],maxsize,MAXPERSLOT,item,qty)
 end
end


class PCItemStorage
 MAXSIZE=50
 MAXPERSLOT=999
 def initialize
  @items=[]
  ItemStorageHelper.pbStoreItem(
    @items,MAXSIZE,MAXPERSLOT,PBItems::POTION,1)
 end
 def empty?
  return @items.length==0
 end
 def length
  @items.length
 end
 def [](i)
  @items[i]
 end
 def getItem(index)
  if index<0 || index>=@items.length
   return 0
  else
   return @items[index][0]
  end
 end
 def getCount(index)
  if index<0 || index>=@items.length
   return 0
  else
   return @items[index][1]
  end
 end
 def pbQuantity(item)
  return ItemStorageHelper.pbQuantity(
    @items,MAXSIZE,item)
 end
 def pbDeleteItem(item,qty=1)
  return ItemStorageHelper.pbDeleteItem(
    @items,MAXSIZE,item,qty)
 end
 def pbCanStore?(item,qty=1)
  return ItemStorageHelper.pbCanStore?(
    @items,MAXSIZE,MAXPERSLOT,item,qty)
 end
 def pbStoreItem(item,qty=1)
  return ItemStorageHelper.pbStoreItem(
    @items,MAXSIZE,MAXPERSLOT,item,qty)
 end
end

class PokemonBagScreen
 def initialize(scene,bag)
  @bag=bag
  @scene=scene
 end
 def pbDisplay(text)
  @scene.pbDisplay(text)
 end
 def pbDisplayPaused(text)
  @scene.pbDisplayPaused(text)
 end
 def pbConfirm(text)
  return @scene.pbConfirm(text)
 end
 def pbGiveItemScreen
  @scene.pbStartScene(@bag)
  item=0
  loop do
   item=@scene.pbChooseItem
   break if item==0
   itemname=PBItems.getName(item)
   if $ItemData[item][ITEMPOCKET]==5 || pbIsHiddenMachine?(item)
    @scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
    next
   else
    break
   end
  end
  @scene.pbEndScene
  return item
 end
 def pbChooseBerryScreen
  oldlastpocket=@bag.lastpocket
  @bag.lastpocket=4
  @scene.pbStartScene(@bag)
  item=0
  loop do
   item=@scene.pbChooseItem
   break if item==0
   itemname=PBItems.getName(item)
   if $ItemData[item][ITEMPOCKET]!=4
    @scene.pbDisplay(_INTL("That's not a Berry.",itemname))
    next
   else
    break
   end
  end
  @scene.pbEndScene
  @bag.lastpocket=oldlastpocket
  return item
 end
 def pbTossItemScreen
  if !$PokemonGlobal.pcItemStorage
   $PokemonGlobal.pcItemStorage=PCItemStorage.new
  end
  storage=$PokemonGlobal.pcItemStorage
  @scene.pbStartScene(storage)
  loop do
   item=@scene.pbChooseItem
   break if item==0
   if $ItemData[item][ITEMPOCKET]==5 || pbIsHiddenMachine?(item)
    @scene.pbDisplay(_INTL("That's too important to toss out!"))
    next
   end
   qty=storage.pbQuantity(item)
   itemname=PBItems.getName(item)
   if qty>1
     qty=@scene.pbChooseNumber(_INTL("Toss out how many {1}(s)?",itemname),qty)
   end
   if qty>0
     if pbConfirm(_INTL("Is it OK to throw away {1} {2}(s)?",qty,itemname))
       if !storage.pbDeleteItem(item,qty)
         raise "Can't delete items from storage"
       end
       pbDisplayPaused(_INTL("Threw away {1} {2}(s).",qty,itemname))
     end
   end
  end
  @scene.pbEndScene
 end
 def pbWithdrawItemScreen
  if !$PokemonGlobal.pcItemStorage
   $PokemonGlobal.pcItemStorage=PCItemStorage.new
  end
  storage=$PokemonGlobal.pcItemStorage
  @scene.pbStartScene(storage)
  loop do
   item=@scene.pbChooseItem
   break if item==0
   commands=[_INTL("WITHDRAW"),_INTL("GIVE"),_INTL("CANCEL")]
   itemname=PBItems.getName(item)
   command=@scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
   if command==0
    qty=storage.pbQuantity(item)
    if qty>1
     qty=@scene.pbChooseNumber(_INTL("How many do you want to withdraw?"),qty)
    end
    if qty>0
     if !@bag.pbCanStore?(item,qty)
      pbDisplayPaused(_INTL("There's no more room in the Bag."))
     else
      pbDisplayPaused(_INTL("Withdrew {1} {2}(s).",qty,itemname))
      if !storage.pbDeleteItem(item,qty)
       raise "Can't delete items from storage"
      end
      if !@bag.pbStoreItem(item,qty)
       raise "Can't withdraw items from storage"
      end
     end
    end
   elsif command==1 # Give
    if $Trainer.pokemonCount==0
     @scene.pbDisplay(_INTL("There is no Pokemon."))
     return 0
    elsif $ItemData[item][ITEMPOCKET]==5 || pbIsHiddenMachine?(item)
     @scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
    else
     pbFadeOutIn(99999){
      sscene=PokemonScreen_Scene.new
      sscreen=PokemonScreen.new(sscene,$Trainer.party)
      if sscreen.pbPokemonGiveScreen(item)
       if !storage.pbDeleteItem(item,1)
        raise "Can't delete item from storage"
       end
      end
      @scene.pbRefresh
     }
    end
   end
  end
  @scene.pbEndScene
 end
 def pbDepositItemScreen
  @scene.pbStartScene(@bag)
  if !$PokemonGlobal.pcItemStorage
   $PokemonGlobal.pcItemStorage=PCItemStorage.new
  end
  storage=$PokemonGlobal.pcItemStorage
  item=0
  loop do
   item=@scene.pbChooseItem
   break if item==0
   qty=@bag.pbQuantity(item)
   if qty>1
    qty=@scene.pbChooseNumber(_INTL("How many do you want to deposit?"),qty)
   end
   if qty>0
     itemname=PBItems.getName(item)
     if !storage.pbCanStore?(item,qty)
      pbDisplayPaused(_INTL("There's no room to store items."))
     else
      pbDisplayPaused(_INTL("Deposited {1} {2}(s).",qty,itemname))
      if !@bag.pbDeleteItem(item,qty)
       raise "Can't delete items from bag"
      end
      if !storage.pbStoreItem(item,qty)
       raise "Can't deposit items to storage"
      end
     end
   end
  end
  @scene.pbEndScene
 end
 def pbStartScreen
  @scene.pbStartScene(@bag)
  item=0
  loop do
   item=@scene.pbChooseItem
   break if item==0
   pocket=$ItemData[item][ITEMPOCKET]
   cmdUse=-1
   cmdTag=-1
   cmdRegister=-1
   cmdGive=-1
   cmdToss=-1
   cmdCheck=-1
   commands=[]
   case pocket
    when 1 # Items
     if pbIsMail?(item)
      commands[cmdCheck=commands.length]=_INTL("CHECK")
      commands[cmdGive=commands.length]=_INTL("GIVE") if $Trainer.party.length>0
      commands[cmdToss=commands.length]=_INTL("TOSS")
      commands[commands.length]=_INTL("CANCEL")
     else
      commands[cmdUse=commands.length]=_INTL("USE")
      commands[cmdGive=commands.length]=_INTL("GIVE") if $Trainer.party.length>0
      commands[cmdToss=commands.length]=_INTL("TOSS")
      commands[commands.length]=_INTL("CANCEL")
     end
    when 2 # Balls
     commands[cmdGive=commands.length]=_INTL("GIVE") if $Trainer.party.length>0
     commands[cmdToss=commands.length]=_INTL("TOSS")
     commands[commands.length]=_INTL("CANCEL")
    when 3 # Machines
     commands[cmdUse=commands.length]=_INTL("USE")
     commands[cmdGive=commands.length]=_INTL("GIVE") if $Trainer.party.length>0
     commands[commands.length]=_INTL("CANCEL")
    when 4 # Berries
     commands[cmdTag=commands.length]=_INTL("CHECK TAG")
     commands[cmdUse=commands.length]=_INTL("USE")
     commands[cmdGive=commands.length]=_INTL("GIVE") if $Trainer.party.length>0
     commands[cmdToss=commands.length]=_INTL("TOSS")
     commands[commands.length]=_INTL("CANCEL")
    when 5 # Key Items
     commands[cmdUse=commands.length]=_INTL("USE")
     commands[cmdRegister=commands.length]=_INTL("REGISTER")
     commands[commands.length]=_INTL("CANCEL")
   end
   itemname=PBItems.getName(item)
   command=@scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
   if cmdUse>=0 && command==cmdUse
    if pocket==3
     ret=pbUseMachine(@bag,item) ? 1 : 0
    else
     ret=pbUseItem(@bag,item)
    end
    # ret==0: Item wasn't used; ret==1: Item was used
    if ret==2 # End screen
     break
    end
    @scene.pbRefresh
    next
   elsif cmdCheck>=0 && command==cmdCheck
    pbFadeOutIn(99999){
     pbDisplayMail(PokemonMail.new(item,"",""))
    }
   elsif cmdTag>=0 && command==cmdTag
   elsif cmdRegister>=0 && command==cmdRegister
    @bag.pbRegisterKeyItem(item)
    @scene.pbRefresh
   elsif cmdGive>=0 && command==cmdGive
    if $Trainer.pokemonCount==0
     @scene.pbDisplay(_INTL("There is no Pokemon."))
    elsif $ItemData[item][ITEMPOCKET]==5 || pbIsHiddenMachine?(item)
     @scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
    else
     pbFadeOutIn(99999){
      sscene=PokemonScreen_Scene.new
      sscreen=PokemonScreen.new(sscene,$Trainer.party)
      sscreen.pbPokemonGiveScreen(item)
      @scene.pbRefresh
     }
    end
   elsif cmdToss>=0 && command==cmdToss
    qty=@bag.pbQuantity(item)
    helptext=_INTL("Toss out how many {1}(s)?",itemname)
    qty=@scene.pbChooseNumber(helptext,qty)
    if qty>0
     if pbConfirm(_INTL("Is it OK to throw away {1} {2}(s)?",qty,itemname))
      pbDisplayPaused(_INTL("Threw away {1} {2}(s).",qty,itemname))
      qty.times { @bag.pbDeleteItem(item) }      
     end
    end   
   end
  end
  @scene.pbEndScene
  return item
 end
end
 

poccil

Sponsor

The Pokemon kit was made by me, not "Demon Fire".

To answer your response, you can replace this statement:
Code:
 pbDrawTextPositions(bm,[
   [name,bm.width/2,16,2,base,shadow]
 ])

with this:
Code:
 pbDrawImagePositions(bm,[
   ["Graphics/Pictures/pocket#{@bag.lastpocket}.png",0,0,0,0,-1,-1]
 ])

That code draws an image representing the current pocket, located in Graphics/Pictures/ and having the name pocketX.png, where X is 0 for Items, 1 for Pokeballs, 2 for TMs/HMs, 3 for berries, and 4 for key items.
 
poccil":21s8nmwk said:
The Pokemon kit was made by me, not "Demon Fire".

To answer your response, you can replace this statement:
Code:
 pbDrawTextPositions(bm,[
   [name,bm.width/2,16,2,base,shadow]
 ])

with this:
Code:
 pbDrawImagePositions(bm,[
   ["Graphics/Pictures/pocket#{@bag.lastpocket}.png",0,0,0,0,-1,-1]
 ])

That code draws an image representing the current pocket, located in Graphics/Pictures/ and having the name pocketX.png, where X is 0 for Items, 1 for Pokeballs, 2 for TMs/HMs, 3 for berries, and 4 for key items.

Actually, his mistake derives from the fact that DeMoNfIrE, a member both here and at Pokecommunity, started a kit similar to yours only a couple of months before you. (It was based on previous kits available at Pokecommunity) Also, you might avoid a lot of posts like this if you'd comment your scripts in a way that enables people to actually figure out what is going on without being an advanced scripter and without needing to take a couple of hours to unravel the tangle of scripts in your kit.
 
poccil":r58ax07f said:
The Pokemon kit was made by me, not "Demon Fire".

To answer your response, you can replace this statement:
Code:
 pbDrawTextPositions(bm,[
   [name,bm.width/2,16,2,base,shadow]
 ])

with this:
Code:
 pbDrawImagePositions(bm,[
   ["Graphics/Pictures/pocket#{@bag.lastpocket}.png",0,0,0,0,-1,-1]
 ])

That code draws an image representing the current pocket, located in Graphics/Pictures/ and having the name pocketX.png, where X is 0 for Items, 1 for Pokeballs, 2 for TMs/HMs, 3 for berries, and 4 for key items.


This didnt work, well it somewhat worked but also didnt. First let me say, thanks for the reply and the help I really do appreciate it. But I have a problem now. When I first open my bad it shows the first photo for the first bag slot but then when I try to switch bag pockets it glitches. When I say glitches I mean, it shows my backback switch pockets but then the left and right arrows for switching pockets moves to the upper left part of the screen, then the bag doesnt work at all and the pictures stay on the screen but I can hear my character walking and bumping into things and I can reopen my menu, reopen my bad and nothing happens if I do that. It goes away if I restart the game obviously. Please Help.

P.S. I will be at work all tomorrow so I wont be able to play test any suggestions until 1:30PM est. time. (Work from 5:30AM-1:30PM) Thanks in advance again, also I have 2 pictures per pocket slot if you can incorporate that, if you cant It is more then possible for me to make it 1 picture per pocket just will take some fidgeting. Thanks again everyone who helps.

EDIT:

Sorry for the mistake in credit of the kit. It is a great kit and I am really enjoying it! I have made some other modifications to it already but its a GREAT kit. Im trying to modernize it a little by updating all the graphics to D/P graphics. Only problems Im having is with this and the sprites. For some reason the sprites are fighting me lol. The D/P sprites are significantly smaller then the sprites you used so I have to try to either get new Tilesets, make my own tilesets, or hope that noone questions the small people in my game lol.

One more question, since you are the creator you could probably answer this. Why did you limit the screen size to so small, I mean I understand that the pokemon games are small but I would have liked it if the resolution could be turned up a little more. I see in the options there is an option for it but all it does is add a nifty background, one other question can I edit that nifty background? I couldn't find a picture for it. If I could edit that background that would be perfect!! I could make it a nice logo and some pokemon pictures there and it would look really nice. If I can do that, please tell me lol also can I change the default resolution or not? BTW you are getting full credit for the kit in the game dont worry about that.

Thanks for everything in advance.
 
Glitchfinder":23g3pftd said:
poccil":23g3pftd said:
The Pokemon kit was made by me, not "Demon Fire".

To answer your response, you can replace this statement:
Code:
 pbDrawTextPositions(bm,[
   [name,bm.width/2,16,2,base,shadow]
 ])

with this:
Code:
 pbDrawImagePositions(bm,[
   ["Graphics/Pictures/pocket#{@bag.lastpocket}.png",0,0,0,0,-1,-1]
 ])

That code draws an image representing the current pocket, located in Graphics/Pictures/ and having the name pocketX.png, where X is 0 for Items, 1 for Pokeballs, 2 for TMs/HMs, 3 for berries, and 4 for key items.

Actually, his mistake derives from the fact that DeMoNfIrE, a member both here and at Pokecommunity, started a kit similar to yours only a couple of months before you. (It was based on previous kits available at Pokecommunity) Also, you might avoid a lot of posts like this if you'd comment your scripts in a way that enables people to actually figure out what is going on without being an advanced scripter and without needing to take a couple of hours to unravel the tangle of scripts in your kit.

Im not making a kit Im using one and trying to edit it to better fit my needs. I mentioned that in my post, its not my script, thats why its not commented. I could probably figure it out myself if the person I got this from commented. Its the "True Pokemon Starting Kit" aka "Pokemon Essentials" Thats the kit I'm using. If you know of a better one that is commented better I would also greatly appreciate that.
 
First off, please avoid double posts. Second, I was saying that you were mistaking DeMoNfIrE's failed kit for Poccil's. (and mentioning the timing). As I was also telling Poccil, he really needs to work on commenting. It may be great to be a brilliant scripter, but he's at least got to clean it up so that others can see what he did. Unfortunately, he's got the best kit out there at the moment. (I've been contemplating taking his kit and commenting and untangling the scripts for a while, but he'd have released several new versions by the time I'm finished)
 

poccil

Sponsor

Nested quotes are not pretty to look at.  They should really change the quote system to one where there's just a link to a post number that a post refers to, as in some Japanese-style bulletin boards.

talimore:

To answer your new question, the background used in 640x480 mode is located at Graphics/Pictures/border.png .

The glitch resulted essentially because the game couldn't find the pictures it had to load, in this case:

Graphics/Pictures/pocket5.png
Graphics/Pictures/pocket1.png
Graphics/Pictures/pocket2.png
Graphics/Pictures/pocket3.png
Graphics/Pictures/pocket4.png
 
poccil":329bhrgq said:
Nested quotes are not pretty to look at.  They should really change the quote system to one where there's just a link to a post number that a post refers to, as in some Japanese-style bulletin boards.

talimore:

To answer your new question, the background used in 640x480 mode is located at Graphics/Pictures/border.png .

Thank you for the quick reply and I will edit the border tomorrow, any idea on how to fix my other problem? And also, how do I default the screen to 640x480?

UPDATE:

They all work except for Items "pocket0" thats the one that breaks it. Don't know why but that breaks it. Its in the pictures folder and named right... hmm...
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top