Gained item/gold window.
#1
Gained item/gold window
by Jimmie
Aug 28 2005

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


Introduction
This makes a window pop up telling the player that he has gained gold/items and it stays up till "C" is pressed. Have fun.


Screenshots
[Image: getwindow.gif]


Installation
Copy the script below into a new slot above main. But really, get updated versions from here instead.
Code:
#==============================================================================
# ** Item and Gold gained Window
# ---- Edited by Nitt for "D&D Currencies"
# ---- Fixed by Nitt to allow easier calling and weather effects
# ---- Easier calling. Removed "D&D Currencies" support and dependancy.
# Version 2.3b
#==============================================================================
  #--------------------------------------------------------------------------
  # This window can be displayed whenever the player gains items or gold.
  # It will automatically add the items and gold as well, effectively
  # replacing the event commands themselves.
  #--------------------------------------------------------------------------

class Scene_Map
  def item_gain(*args)
    if args.last.is_a?(Integer)
      gold = args.pop
    else
      @gold = 0
    end
    
    Audio.me_stop
    Audio.me_play("Audio/ME/011-Item02", 100, 100)
  
    window=Window_ItemGain.new(args, gold)
    window.opacity = 175
    escape = false
    until escape == true
      if Input.trigger?(Input::C)
        if window.wait <= 0
          $game_system.se_play($data_system.decision_se)
          window.dispose
          escape = true
        end
      end
      $game_map.update
      $game_system.update
      $game_screen.update
      @spriteset.update
      Input.update
      Graphics.update
      window.wait
      if $scene != self
        break
      end
    end
    return
  end
end


class Window_ItemGain < Window_Selectable
  def initialize(items,gold)
    height = items.size*32
    height += gold != 0 ? 96 : 64
    @wait = [height / 4, 32].min
    @width = 0
    
    @type = []
    @id = []
    @numb = []
    
    items.each do |item|
      @type.push(item[0])
      @id.push(item[1])
      @numb.push(item[2])
    end
    
    test = Bitmap.new(1,1)
    for i in 0...@type.size
      case @type[i]
      when 0
        @w = test.text_size($data_items[@id[i]].name).width
        @width = @w if @w > @width
      when 1
        @w = test.text_size($data_weapons[@id[i]].name).width
        @width = @w if @w > @width
      when 2
        @w = test.text_size($data_armors[@id[i]].name).width
        @width = @w if @w > @width
      end
    end      
    @width += test.text_size('X').width
    @width += 96
    test.dispose
    super(320-@width/2,240-@type.size*16-48,@width,height)
    self.contents=Bitmap.new(@width-32,height-32)
    @item_max = @type.size
    @index=-1
    @gold=gold
    refresh
  end
  #--------------------------------------------------------------------------
  def refresh
    if @item_max != 0
      self.contents.draw_text(0,0,@width - 32,32,"Gained Items:",1)
      self.contents.fill_rect(0,32,@width-32,1,Color.new(255,255,255,255))
      self.contents.draw_text(-4, @type.size*32+32, @width - 32, 32, @gold.to_s, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(4, @type.size*32+32, @width - 32, 32, $data_system.words.gold  + ":")
      self.contents.fill_rect(0,@type.size*32+32,@width - 32,1,Color.new(255,255,255,255)) if @gold != 0
    elsif @gold != 0
      self.contents.fill_rect(0,32,@width - 32,1,Color.new(255,255,255,255))
      self.contents.draw_text(0, 32, @width - 32, 32, @gold.to_s, 1)
      self.contents.font.color = system_color
      self.contents.draw_text(0, 0, @width - 32, 32, $data_system.words.gold,1)
    end
    $game_party.gain_gold(@gold)
    for i in 0...@item_max
      case @type[i]
      when 0
        item=$data_items[@id[i]]
        $game_party.gain_item(@id[i],@numb[i])
      when 1
        item=$data_weapons[@id[i]]
        $game_party.gain_weapon(@id[i],@numb[i])
      when 2
        item=$data_armors[@id[i]]
        $game_party.gain_armor(@id[i],@numb[i])
      end
      draw_item_name(item, 4, i*32+32, @width - 96)
      self.contents.draw_text(-24,i*32+32,width-self.contents.text_size('X '+@numb[i].to_s).width,32,'X',2)
      self.contents.draw_text(-4,i*32+32,@width-32,32,@numb[i].to_s,2)
    end
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    self.cursor_rect.empty
  end
  #--------------------------------------------------------------------------
  def wait
    @wait-=1
    return @wait
  end
end


Instructions
Use the call script function: $scene.item_gain.new([t1, i1, a1], [t2, i2, a2], [etc],gold)
where:
tx = The type of item number X: 0 for item, 1 for weapon, 2 for armor.
ix = The database id for item X: 1 for potion/bronze sword/bronze shield. etc.
ax = The amount to gain of item X.
gold=the gold gained, if no gold is gained, it's not needed.

You don't need to put any empty arrays in case you're not adding items or stuff - just enter the gold alone ^^
so to gain 1 potion which has item type 0 and no gold
Code:
$scene.item_gain.new([0, 1, 1])


One high-potion and a perfume (both type 0) and 10 gold
Code:
$scene.item_gain.new([0,2, 1],[0,4, 1],10)

To gain no items and 50 gold
Code:
$scene.item_gain.new(50)


It automatically adds the items and gold.

EDIT: New and updated, it now changes the y position and height depending on the number of items. Don't add more than twelve different items at once, it'll go off the screen.

EDIT again: It now looks better when you get only gold.

3DIT: Calling is easier, screen effects are updated while the window is up.

EDIT 4:: Script will now be maintained in this topic. Not having several different versions to upkeep make support and maintenance much easier for me. Old script will stay here for reference.


//Jimmie
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compact Status Window Cockroach 0 3,342 01-24-2013, 01:00 PM
Last Post: Cockroach
  Gold Display Add-Ons Mister C Major 0 2,382 04-30-2007, 01:00 PM
Last Post: Mister C Major
  Monster drop more than one item. Hima 0 2,549 04-25-2007, 01:00 PM
Last Post: Hima
  TDS status window Sephirothtds 0 2,293 03-05-2007, 01:00 PM
Last Post: Sephirothtds
  Gold converted to decimals Jadant 0 2,561 11-18-2006, 01:00 PM
Last Post: Jadant
  Bag item menu rune76 0 2,230 08-12-2005, 01:00 PM
Last Post: rune76
  Item Detail Script jackatrades 0 2,645 05-19-2005, 01:00 PM
Last Post: jackatrades



Users browsing this thread: 1 Guest(s)