iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

The 2nd Quarter Contest has arrived! Go check it out in the Community Announcements now!
 
Reply to this topicStart new topic
> Item Selection Number Fix, One item charge use per battler per combat round.
Rating 5 V
Mithran
post Jan 27 2009, 06:19 PM
Post #1


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




Item Selection Number Fix
by Mithran


Introduction
This script is desinged for the default battler only and will probably not work with other battle systems.

Okay, here is what the script really does. You know how when you have one potion left, and you have Ralph use one? Then you pull open the item window for Ulrika, and you still have one? Why? Shouldn't there be no potions left, since Ralph already selected to use one?

If you answered yes, then this script is for you. Of course, the item shouldnt actually be consumed until it is 'used', so I have accounted for this as well.

Features
- Only one actor can use any given single item (read: one item use) in any given combat round (this includes non-consumables)
- Items selected are NOT consumed until they are actually used. Actors will see a reduction in quantity as they select their items, but if anyone selecting to 'use' an item cancels out, the item will be available for use by someone else.
- completely plug and play

How to Use
Place it in the materials section above main and below scripts that alter item numbers.

Script
Spoiler:
CODE
# Item Selection Number Fix
# v 1.0b
# By Mithran
# Created January 27, 2009
# Only tested with default battler system.
# Subtracts 1 item for each member 'using' the item in the command selection.
# The items are NOT really 'gone', but will be unavailable for the next actors
# to select.
# In other words, if Ralph selects to 'use' the last potion, there wont be one
# Ulrika wont be able to select it.  If for some reason Ralph doesn't get to use
# the potion before the combat round or battle ends, it is still available for
# use the next round or after battle.  If Ralph cancels using the potion, Ulrika
# can then use it.
# Also dissalows multiple actors from selecting the same non-consumable item
# (there must be one for each actor selecting the item)


class Scene_Battle < Scene_Base
  alias start_actor_command_selection_item_number_fix start_actor_command_selection
  def start_actor_command_selection
    start_actor_command_selection_item_number_fix
    @active_battler.action.clear
  end
  alias process_action_item_number_fix process_action
  def process_action
    $game_temp.action_processing_item_number = true
    process_action_item_number_fix
    $game_temp.action_processing_item_number = false
  end
end

class Game_Temp
  attr_accessor :action_processing_item_number
end

class Game_Party < Game_Unit
  alias item_number_item_number_fix item_number
  def item_number(item)
    n = item_number_item_number_fix(item)
    return n unless $game_temp.in_battle
    return n if item.class != RPG::Item
    return n if $game_temp.action_processing_item_number
    for member in members
      n -= 1 if member.action.kind == 2 && member.action.item_id == item.id
    end
    return [n, 0].max
  end
end


FAQ
q. How about one for (insert custom battle system here)?
a. Shoot me a name and a link and I'll look into it. No promises, though.

Credit and Thanks
- Mithran

Author's Notes
This script is a purely optional addon. Feedback is welcome.


--------------------
Go to the top of the page
 
+Quote Post
   
aba3k
post Jun 26 2009, 01:29 AM
Post #2



Group Icon


Type: Undisclosed
Alignment: Chaotic Good




Using just Equipment Extension from Kgc + your fix:
Script 'Game Actor' line 142: SystemStack ErrorOcurred
stack level too deep


--------------------
Go for the eyes Boo, go for the eyes!
Go to the top of the page
 
+Quote Post
   
Mithran
post Jun 26 2009, 01:53 AM
Post #3


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




Changing equipment before the group members were fully set up was causing a recursion. Should be fixed now. Thanks for reporting.


--------------------
Go to the top of the page
 
+Quote Post
   
MASH_MX
post Jun 26 2009, 04:52 AM
Post #4


"Everyone Is Unique In There Own Defined Way."
Group Icon


Type: Writer
Alignment: Chaotic Good




Very nice job with this little script Mithran.
That is very useful for not having the annoying do nothing when you already used that potion.


--------------------
My Projects:

Other:

Who and what I Support:
Spoiler:


Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 18th April 2014 - 08:52 PM

RPGMakerVX.net is an Privacy Policy, Legal.