Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wallet and Item Capacity Levels
#1
Wallet and Item Capacity Levels
Ragnarok Rob
Aug 11 2006

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.


Just like i said in the title, this script gives "levels" to the amounts of items and gold you can carry. The only thing similar i can compare this to is in Ocarina of Time when you can upgrade your wallet to carry more rupees...well its exactly like that. It also does this for items...for example, on item lvl 1, you can carry 20 of each item. Lvl 2? 40. Its a really simple script. All instructions you need to know are in the first block 'o comments! I made a demo, though it doesn't really need one...

Code:
#======================================================================
====
# ** Rag's Wallet and Item Bag Upgrades
#--------------------------------------------------------------------------
# Author: Ragnarok Rob
# Date: 8/10/06
# Version: 1.1
#--------------------------------------------------------------------------
# ~What it does
# -Creates different levels of wallets and items bags,
# so they can upgrade & carry more junk
#
# ~How it works
# -Changes Game_Party to change the parameters, then
# tweaks Window_Gold and Scene_Item to display which
# level's they're at
#
# Everything needed in terms of script are written there
# for you already. But here's how to make it work in a game:
#
# 1. Make two new items on position 33 and 34. Call 33
# "Peasant's Wallet" and 34 "Beggar's Bag". Make sure
# each can NEVER be used and are NOT consumable!!!
#
# 2. There are five levels of wallets and items bags. The
# default wallet and items bag is 0. To change wallet
# level in game, set variable 0001 to any number 0 to
# 4. To change items bag, set variable 0002 to any number
# 0 to 4.
#==========================================================================

#==========================================================================
# ** Game_Party
#--------------------------------------------------------------------------
# Used to change wallet size and item amounts
#==========================================================================

class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :wallet_name #Shortened name of wallet for Window_Gold
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Create actor array
@wallet_name = "Psnt:"
@actors = []
# Initialize amount of gold and steps
@gold = 0
@steps = 0
# Create amount in possession hash for items, weapons, and armor
@items = {}
@weapons = {}
@armors = {}
end
#--------------------------------------------------------------------------
# * Gain Gold
# n : amount of gold
# wallet_name : abbreviated name of wallet type
#--------------------------------------------------------------------------
def gain_gold(n)
wallet_name = @wallet_name
case $game_variables[1]
when 0 #First wallet
@gold = [[@gold + n, 0].max, 5000].min
when 1 #Second wallet
@gold = [[@gold + n, 0].max, 10000].min
@wallet_name = "Trvl:"
$data_items[33].name = "Traveler's Wallet"
$data_items[33].description = "A wallet that holds 10000 gold."
when 2 #Third wallet
@gold = [[@gold + n, 0].max, 25000].min
@wallet_name = "Mrch:"
$data_items[33].name = "Merchant's Wallet"
$data_items[33].description = "A wallet that holds 25000 gold."
when 3 #Fourth wallet
@gold = [[@gold + n, 0].max, 50000].min
@wallet_name = "King:"
$data_items[33].name = "King's Wallet"
$data_items[33].description = "A wallet that holds 50000 gold."
when 4 #Fifth wallet
@gold = [[@gold + n, 0].max, 1000000].min
@wallet_name = "Gnt:"
$data_items[33].name = "Giant's Wallet"
$data_items[33].description = "A wallet that holds 100000 gold!"
end
end
#--------------------------------------------------------------------------
# * Gain Items (or lose)
# item_id : item ID
# n : quantity
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# Update quantity data in the hash.
if item_id > 0
case $game_variables[2]
when 0 #First item bag
@items[item_id] = [[item_number(item_id) + n, 0].max, 20].min
when 1 #Second item bag
@items[item_id] = [[item_number(item_id) + n, 0].max, 40].min
$data_items[34].name = "Goblin's Bag"
$data_items[34].description = "An item bag that holds 40 of each item."
when 2 #Third item bag
@items[item_id] = [[item_number(item_id) + n, 0].max, 60].min
$data_items[34].name = "Thief's Bag"
$data_items[34].description = "An item bag that holds 60 of each items."
when 3 #Fourth item bag
@items[item_id] = [[item_number(item_id) + n, 0].max, 80].min
$data_items[34].name = "Banker's Bag"
$data_items[34].description = "An item bag that holds 80 of each items."
when 4 #Fifth item bag
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
$data_items[34].name = "Ogre's Bag"
$data_items[34].description = "An item bag that holds 99 of each items!"
end
end
end
end

#============================================================================
# ** Window_Gold
#----------------------------------------------------------------------------
# Used to redefine refresh to inculde shortened wallet name
#============================================================================

class Window_Gold
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
wx = contents.text_size($game_party.wallet_name).width
self.contents.font.color = system_color
self.contents.draw_text(0, 0, wx, 32, $game_party.wallet_name, 0)
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end

#============================================================================
# ** Scene_Item
#----------------------------------------------------------------------------
# Used to display item bag name when an item isn't selected
#============================================================================

class Scene_Item
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make help window, item window
@help_window = Window_Help.new
@item_window = Window_Item.new
@help_window.set_text("#{$data_items[34].name}")
# Associate help window
@item_window.help_window = @help_window
# Make target window (set to invisible / inactive)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
end

I'll get screenies later!!! Enjoy my first script!!!
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Fix for Item Detail Vieuw Derk-Jan 0 1,879 12-26-2005, 01:00 PM
Last Post: Derk-Jan
  Item Inventory SephirothSpawn 0 2,189 12-02-2005, 01:00 PM
Last Post: SephirothSpawn
  Cool, sortable item menu Jimmie 0 2,000 12-01-2005, 01:00 PM
Last Post: Jimmie
  Item Encyclopedia GoldenShadow 0 2,220 08-14-2005, 01:00 PM
Last Post: GoldenShadow
  Enemy drop more than one item dragonslayer 0 2,018 06-04-2005, 01:00 PM
Last Post: dragonslayer
  New Item Icon Menu Chrono Cry 0 2,008 04-21-2005, 01:00 PM
Last Post: Chrono Cry



Users browsing this thread: