Author Topic: [XP] Party Item Limit  (Read 9806 times)

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
[XP] Party Item Limit
« on: July 06, 2009, 07:44:02 PM »
Party Item Limit
Authors: game_guy
Version: 1.2
Type: Item Carry Limit
Key Term: Player / Party / Troop Add-on

Introduction

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 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
  • Limit is changable throughout the game

Screenshots

N/A

Demo

Demo is 1.1
Demo

Script

(click to show/hide)

Here's a different version that allows you to set the maximum of items, armors, and weapons instead of all of them together
(click to show/hide)

Instructions

Instructions
Go down to the BEGIN CONFIG and you'll see this line
@max_items = 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
x = number

Compatibility

Not tested with SDK. Should be compatible with pretty much anything.

Credits and Thanks

  • game_guy ~ for making it
  • Xuroth ~ inspiring me with the idea of a post
I was just thinking that the 99 of any item would seem kinda ridiculus.  Arshes: I can carry 99 of any item, but not 100, yet i can carry 99 of another item at the same time!
Hilda: I can carry 250 pounds of items
you already have an awesome feature, but I think you could do even better. of course if you dont like the idea, thats fine. I know how it would work, and how to assign (through many ways ) weight to items using multiplexed dummy elements or by using a comment in the items description (simpler) any way thanks for the awesome script


Author's Notes

N/A
« Last Edit: July 15, 2009, 07:32:45 AM by game_guy »

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: [XP] Party Item Limit
« Reply #1 on: July 06, 2009, 07:56:31 PM »
this system is flawed it only checks to see if you have the max items already if you have one less than the max then gain 100 items all at the same time then you will still gain the 100 items. same if you have 0 and gain more than the max all at the same time, also you only give them one potion in the demo not 20

use an n.times loop and increase the number of items they have by 1 each loop unless they have the max items. like so
Code: [Select]
def gain_item(item_id, n)
    if item_id > 0
      itemamount = get_item_total
      n.times {|i|
        unless itemamount == $game_system.max_items
          @items[item_id] = [[item_number(item_id) 1 n, 0].max, 99].min
        end
      }
    end
  end

« Last Edit: July 06, 2009, 08:04:49 PM by Ryexander »
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Aqua

  • Lexima Warrior
  • *******
  • Posts: 2554
  • LV: 118
  • Gender: Female
  • Quack!
    • View Profile
Re: [XP] Party Item Limit
« Reply #2 on: July 06, 2009, 07:57:50 PM »
Just to be nitpicky...

Quote
You can only hold 10 different items/weapons/armors.
For example you have 6 potions and 4 high potions.
In this example, that'd only be 2 different items, so you'd be able to carry 8 more different items.

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Party Item Limit
« Reply #3 on: July 06, 2009, 08:01:22 PM »
@ryex I do need to fix that.
@aqua no you couldnt have 8 more. I meant 10 items total its hard for me to explain. Pretty much you can only hold a total of 10 items at a time

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: [XP] Party Item Limit
« Reply #4 on: July 06, 2009, 08:03:14 PM »
i edited my post with a easy way to fix that problem g_g
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Party Item Limit
« Reply #5 on: July 06, 2009, 08:04:10 PM »
I had already fixed it :P XD

Anyways updated.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5135
  • LV: 198
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: [XP] Party Item Limit
« Reply #6 on: July 06, 2009, 08:06:23 PM »
my method is faster and uses less code

YOU FAIL G_G... :V:
« Last Edit: July 06, 2009, 08:21:43 PM by Ryexander »
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Party Item Limit
« Reply #7 on: July 06, 2009, 08:07:47 PM »
well I updated it before you edited post and oh well if I fail. I fail at a lot of things xD

Anyways any thoughts on teh script itself?

Offline Aqua

  • Lexima Warrior
  • *******
  • Posts: 2554
  • LV: 118
  • Gender: Female
  • Quack!
    • View Profile
Re: [XP] Party Item Limit
« Reply #8 on: July 06, 2009, 08:09:24 PM »
I editted your introduction to fix some minor stuff.

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Party Item Limit
« Reply #9 on: July 15, 2009, 07:33:24 AM »
Added a different version that allows you to setup the max items, weapons, and armors

Offline Launian

  • Trained Member
  • *
  • Posts: 23
  • LV: 1
  • Gender: Male
  • Tsuki no Kenshi
    • View Profile
Re: [XP] Party Item Limit
« Reply #10 on: June 26, 2010, 03:18:37 AM »
Well, here are some lines of code that some people might find usefull (to be used with the first version):

To print the current number of items and the max number of items on a window (maybe replacing the steps/playtime window on the menu) :
Code: [Select]
self.contents.draw_text(4, 20, 120, 32, $game_party.get_item_total.to_s + "/" + $game_system.max_items.to_s)
If you decide to upgrade the "bag" on a constant basis (20 items each time, for example), you can use this to show the next size of your bag:

Code: [Select]
self.contents.draw_text(4, 60, 120, 32, ($game_system.max_items + 20).to_s)
You can replace the 20 for any other number, so if you have a item cap of 20, it'll show 40.

Also, I guess people know this alredy, but you can use this to sum certain number of items instead of giving a real number (usefull if you want to make some kind of upgrade bag shop, I guess) :

Code: [Select]
$game_system.max_items =
$game_system.max_items + n

Where n is the number of allowed items you want to give to the player.

I know it's very basic stuff, but I wanted to thanks for the script, so I thought I'd might as well share the little stuff I found out, in case another noob like me comes and wants to do any of that. So... thanks for the script  :^_^':

If I were to leave tonight, would your hand try to reach me?

Offline nathmatt

  • Chaos User
  • ******
  • Posts: 1289
  • LV: 114
  • Gender: Male
  • The Add_on King
    • View Profile
    • Nathmatt Productions
Re: [XP] Party Item Limit
« Reply #11 on: June 26, 2010, 03:33:03 AM »
wouldn't you just do this

Code: [Select]
#===============================================================================
# Game_System
#-------------------------------------------------------------------------------
# *Changed one method
#===============================================================================
class Game_System
  attr_accessor :max_items
  alias add_max_items initialize
  def initialize
    #===========================================================================
    # BEGIN CONFIG
    @max_items = 20 # Change this to the max items you want the party to carry
    # END CONFIG
    #===========================================================================
    add_max_items
  end
end
#===============================================================================
# Game_Party
#-------------------------------------------------------------------------------
# *Added one method
# *changed three methods
#===============================================================================
class Game_Party
  #--------------------------------------------------------------------------
  # * 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
      @items[item_id] = [[item_number(item_id) + n, 0].max, $game_systems.max_items].min
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Weapons (or lose)
  #     weapon_id : weapon ID
  #     n         : quantity
  #--------------------------------------------------------------------------
  def gain_weapon(weapon_id, n)
    # Update quantity data in the hash.
    if weapon_id > 0
      @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, $game_systems.max_items].min
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Armor (or lose)
  #     armor_id : armor ID
  #     n        : quantity
  #--------------------------------------------------------------------------
  def gain_armor(armor_id, n)
    # Update quantity data in the hash.
    if armor_id > 0
      @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, $game_systems.max_items].min
    end
  end

end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script
(click to show/hide)

Offline Sacred Nym

  • Awakened Visionist
  • **
  • Posts: 70
  • LV: 0
  • Gender: Male
    • View Profile
Re: [XP] Party Item Limit
« Reply #12 on: June 26, 2010, 10:23:55 PM »
I noticed a flaw in this script where it won't check if you can carry your entire purchase when at a shop. If you can't it just gives you what you can carry but you still pay for everything else.
Quote
昨日の自分に「さようなら」
Say "Goodbye" to who you were yesterday.

Offline Launian

  • Trained Member
  • *
  • Posts: 23
  • LV: 1
  • Gender: Male
  • Tsuki no Kenshi
    • View Profile
Re: [XP] Party Item Limit
« Reply #13 on: June 26, 2010, 11:29:47 PM »
I noticed a flaw in this script where it won't check if you can carry your entire purchase when at a shop. If you can't it just gives you what you can carry but you still pay for everything else.

True. Here's a little edit in order to avoid that:

Edited: The last fix had a bug where you couldn't sell items if you had more the max number of items. Anyways, here's another fix, hopefully this one will have no bugs:

(click to show/hide)

Hopefully that will solve it for good. If you find any bugs... well, I guess I'll try to fix them lol. Or if you can fix them, that's fine with me  :^_^':
« Last Edit: June 26, 2010, 11:45:49 PM by Launian »

If I were to leave tonight, would your hand try to reach me?