[RESOLVED]Weapon/armor/item limits

Started by godsrighthand, July 12, 2009, 01:34:09 pm

Previous topic - Next topic

godsrighthand

July 12, 2009, 01:34:09 pm Last Edit: July 14, 2009, 11:31:02 pm by godsrighthand
Required features:
1) Limits for the number of items, weapons and armors in inventory EACH SEPARATELY. ie i can configure it like this..... 5 items, 10 weapons, 20 armors etc
2) The configuration needs to be done using a call script command so that it can be changed any time

Consider game_guy's party item limit script but instead of a universal limit for items/weapons/armor there can be a separate limit for each one
http://forum.chaos-project.com/index.php?topic=4066.0
My fav sayings
---My god carries a hammer. Your god died nailed to a tree. Any questions?
---When I die, I want to go peacefully like my Grandfather did, in his sleep -- not screaming, like the passengers in his car.
---War doesn't determine who's right. War determines who's left.
---I don't suffer from insanity. I enjoy every minute of it.
---I intend to live forever, or die trying.

godsrighthand

My fav sayings
---My god carries a hammer. Your god died nailed to a tree. Any questions?
---When I die, I want to go peacefully like my Grandfather did, in his sleep -- not screaming, like the passengers in his car.
---War doesn't determine who's right. War determines who's left.
---I don't suffer from insanity. I enjoy every minute of it.
---I intend to live forever, or die trying.

fugibo

July 14, 2009, 11:46:59 am #2 Last Edit: July 14, 2009, 11:51:49 am by Longfellow
Post up the Game_Party script from the editor (or just upload the Scripts.rxdata from the RTP) and I can try it for you. Seems rather simple, just alias and rewrite a couple methods. 0_o

EDIT:

Nevermind, I just remembered I had a copy of the default on-disk. 'Sall good, I'll work on it now :P

G_G

Too late WcW here you go grh oh and you can use this in your commercial game too ^_^

#===============================================================================
# Party Item Limit
# Author: game_guy
# Date: June 6th, 2009
#-------------------------------------------------------------------------------
# Intro
# What this script does is set the party's item limit. For instance say the
# party item limit is 10. You can only hold 10 different items/weapons/armors.
# For example you have 6 potions and 4 high potions. You won't be able to
# Carry anything else.
#
# Features
# * Limits how many items the party can carry
#
# Instructions
# Go down to the BEGIN CONFIG and you'll see this line
# @max_items = 20
# @max_weapons = 20
# @max_armors = 20
# Change that 20 to whatever you like.
# You can also change that number in game using this in a script call
# $game_system.max_items = x
# $game_system.max_weapons = x
# $game_system.max_armor = x
# x = number
#
# Credits
# game_guy ~ for making it
# Xuroth ~ inspiring me with the idea of a post
# link to post
# http://forum.chaos-project.com/index.php?topic=3444.msg74388#msg74388
#===============================================================================

#===============================================================================
# Game_System
#-------------------------------------------------------------------------------
# *Changed one method
#===============================================================================
class Game_System
 attr_accessor :max_items
 attr_accessor :max_weapons
 attr_accessor :max_armor
 alias add_max_items initialize
 def initialize
   #===========================================================================
   # BEGIN CONFIG
   @max_items   = 20 # Change this to the max items you want the party to carry
   @max_weapons = 20 # Change this to the max weapons you want the party to carry
   @max_armor   = 20 # Change this to the max armor you want the party to carry
   # END CONFIG
   #===========================================================================
   add_max_items
 end
end
#===============================================================================
# Game_Party
#-------------------------------------------------------------------------------
# *Added one method
# *changed three methods
#===============================================================================
class Game_Party
 #=============================================================================
 # Get Item Total
 #=============================================================================
 def get_item_total
   amount = 0
   for i in 1...$data_items.size
     if item_number(i) > 0
       amount += item_number(i)
     end
   end
   return amount
 end
 #=============================================================================
 # Get Armor Total
 #=============================================================================
 def get_armor_total
   amount = 0
   for i in 1...$data_armors.size
     if armor_number(i) > 0
       amount += armor_number(i)
     end
   end
   return amount
 end
 #=============================================================================
 # Get Weapon Total
 #=============================================================================
 def get_weapon_total
   amount = 0
   for i in 1...$data_weapons.size
     if weapon_number(i) > 0
       amount += weapon_number(i)
     end
   end
   return amount
 end
 #=============================================================================
 # Gain Item
 #=============================================================================
 def gain_item(item_id, n)
   if item_id > 0
     itemamount = get_item_total
     unless itemamount >= $game_system.max_items
       number = $game_system.max_items - itemamount
       if n > number
         n = number
       end
       @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
     end
   end
 end
 #=============================================================================
 # Gain Weapon
 #=============================================================================
 def gain_weapon(weapon_id, n)
   if weapon_id > 0
     itemamount = get_weapon_total
     unless itemamount >= $game_system.max_weapons
       number = $game_system.max_weapons - itemamount
       if n > number
         n = number
       end
       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
     end
   end
 end
 #=============================================================================
 # Gain Armor
 #=============================================================================
 def gain_armor(armor_id, n)
   if armor_id > 0
     itemamount = get_armor_total
     unless itemamount >= $game_system.max_armor
       number = $game_system.max_armor - itemamount
       if n > number
         n = number
       end
       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
     end
   end
 end
end

fugibo

Quote from: game_guy on July 14, 2009, 12:14:58 pm
Too late WcW here you go grh oh and you can use this in your commercial game too ^_^

#===============================================================================
# Party Item Limit
# Author: game_guy
# Date: June 6th, 2009
#-------------------------------------------------------------------------------
# Intro
# What this script does is set the party's item limit. For instance say the
# party item limit is 10. You can only hold 10 different items/weapons/armors.
# For example you have 6 potions and 4 high potions. You won't be able to
# Carry anything else.
#
# Features
# * Limits how many items the party can carry
#
# Instructions
# Go down to the BEGIN CONFIG and you'll see this line
# @max_items = 20
# @max_weapons = 20
# @max_armors = 20
# Change that 20 to whatever you like.
# You can also change that number in game using this in a script call
# $game_system.max_items = x
# $game_system.max_weapons = x
# $game_system.max_armor = x
# x = number
#
# Credits
# game_guy ~ for making it
# Xuroth ~ inspiring me with the idea of a post
# link to post
# http://forum.chaos-project.com/index.php?topic=3444.msg74388#msg74388
#===============================================================================

#===============================================================================
# Game_System
#-------------------------------------------------------------------------------
# *Changed one method
#===============================================================================
class Game_System
 attr_accessor :max_items
 attr_accessor :max_weapons
 attr_accessor :max_armor
 alias add_max_items initialize
 def initialize
   #===========================================================================
   # BEGIN CONFIG
   @max_items   = 20 # Change this to the max items you want the party to carry
   @max_weapons = 20 # Change this to the max weapons you want the party to carry
   @max_armor   = 20 # Change this to the max armor you want the party to carry
   # END CONFIG
   #===========================================================================
   add_max_items
 end
end
#===============================================================================
# Game_Party
#-------------------------------------------------------------------------------
# *Added one method
# *changed three methods
#===============================================================================
class Game_Party
 #=============================================================================
 # Get Item Total
 #=============================================================================
 def get_item_total
   amount = 0
   for i in 1...$data_items.size
     if item_number(i) > 0
       amount += item_number(i)
     end
   end
   return amount
 end
 #=============================================================================
 # Get Armor Total
 #=============================================================================
 def get_armor_total
   amount = 0
   for i in 1...$data_armors.size
     if armor_number(i) > 0
       amount += armor_number(i)
     end
   end
   return amount
 end
 #=============================================================================
 # Get Weapon Total
 #=============================================================================
 def get_weapon_total
   amount = 0
   for i in 1...$data_weapons.size
     if weapon_number(i) > 0
       amount += weapon_number(i)
     end
   end
   return amount
 end
 #=============================================================================
 # Gain Item
 #=============================================================================
 def gain_item(item_id, n)
   if item_id > 0
     itemamount = get_item_total
     unless itemamount >= $game_system.max_items
       number = $game_system.max_items - itemamount
       if n > number
         n = number
       end
       @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
     end
   end
 end
 #=============================================================================
 # Gain Weapon
 #=============================================================================
 def gain_weapon(weapon_id, n)
   if weapon_id > 0
     itemamount = get_weapon_total
     unless itemamount >= $game_system.max_weapons
       number = $game_system.max_weapons - itemamount
       if n > number
         n = number
       end
       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
     end
   end
 end
 #=============================================================================
 # Gain Armor
 #=============================================================================
 def gain_armor(armor_id, n)
   if armor_id > 0
     itemamount = get_armor_total
     unless itemamount >= $game_system.max_armor
       number = $game_system.max_armor - itemamount
       if n > number
         n = number
       end
       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
     end
   end
 end
end



Dear god, that's waaaaay too long...


=begin
Item/Armor/Weapon Limits, v 1.00
by Collin Wright, aka WcW, aka WcWofEleven, aka Longfellow

Introduction:
This script allows for you to set a limit on the number of items, armors, or
weapons the player may have in his/her inventory at any given moment.

Instructions:
To set the initial values:
- Hit Ctrl+F, and type "INV_LIMIT CONFIG"
- Change the values within the section; they're fairly self-explanatory (-1 disables the limit for that type of item)
To change in game:
- Add a "Call Script" command to your event
- Use this code for items:
$game_system.wcw_max_items = <x>
And replace <x> with the desired limit
- To change the same for weapons and armor, replace "items" with "weapons" and "armor", respectively

Notes:
To all you scripters who look over this and say, "ZOMG! HE USED [a, b].min! THAT'S SO
SLOW!", note that the methods I used this in are used so rarely that the loss will
be negligible, and is worth it for the increase in readibility and brevity.
=end

#============================================================================================
# * Game_System
# Modified to allow savable configuration
#============================================================================================
class Game_System
attr_accessor :wcw_max_items, :wcw_max_armor, :wcw_max_weapons
#-----------------------------------------------------------------------------------------
# initialize
#-----------------------------------------------------------------------------------------
alias initialize_inventory_limit_wcw_later initialize
def initialize
#//////////////////////////////////////////////////////////////////////////////////////
#INV_LIMIT CONFIG
@wcw_max_items = -1
@wcw_max_weapons = -1
@wcw_max_armor = -1
#//////////////////////////////////////////////////////////////////////////////////////
initialize_inventory_limit_wcw_later
end
end

#============================================================================================
# * Game_Party
# gain_item, gain_weapon, and gain_armor all modified to ensure that items are limited
# properly
#============================================================================================
class Game_Party
#-----------------------------------------------------------------------------------------
# gain_item(item_id, n)
#-----------------------------------------------------------------------------------------
alias gain_item_inventory_limit_wcw_later gain_item
def gain_item(item_id, n)
return gain_item_inventory_limit_wcw_later(item_id, ($game_system.wcw_max_items == -1) ? n : [$game_system.wcw_max_items, item_number(item_id) + n].min)
end

#-----------------------------------------------------------------------------------------
# gain_weapon(weapon_id, n)
#-----------------------------------------------------------------------------------------
alias gain_weapon_inventory_limit_wcw_later gain_weapon
def gain_weapon(weapon_id, n)
return gain_weapon_inventory_limit_wcw_later(weapon_id, ($game_system.wcw_max_weapons == -1) ? n : [$game_system.wcw_max_weapons, weapon_number(weapon_id) + n].min)
end

#-----------------------------------------------------------------------------------------
# gain_armor(armor_id, n)
#-----------------------------------------------------------------------------------------
alias gain_armor_inventory_limit_wcw_later gain_armor
def gain_armor(armor_id, n)
return gain_armor_inventory_limit_wcw_later(armor_id, ($game_system.wcw_max_armor == -1) ? n : [$game_system.wcw_max_armor, armor_number(armor_id) + n].min)
end
end


My version. Public domain, have fun. However, I'm unable to test it since I don't have RMXP anymore >_<

G_G

eh so what if yours is longer or not I think I already know you're a better scripter than me I still filled the request before you even if the script is longer

fugibo

Quote from: game_guy on July 14, 2009, 03:06:25 pm
eh so what if yours is longer or not I think I already know you're a better scripter than me I still filled the request before you even if the script is longer


Three things:
1) I had to manually extract Game_Party from the Scripts.rxdata, which took me a while (I forgot to un-Zlib it the first time and had to start over, doing it manually from irb). We took about the same time =(

2) Yours is rather incompatible; anything else that mods gain_item/etc will conflict with it

3) Mine doesn't fill the request, actually -- I misunderstood it. Mine change the maximum allowed of each per item-- which happens to be almost useless.

godsrighthand

Thnx to both of you
I think you should put it up in the database
My fav sayings
---My god carries a hammer. Your god died nailed to a tree. Any questions?
---When I die, I want to go peacefully like my Grandfather did, in his sleep -- not screaming, like the passengers in his car.
---War doesn't determine who's right. War determines who's left.
---I don't suffer from insanity. I enjoy every minute of it.
---I intend to live forever, or die trying.