Item Selection Number Fix

Hello, everybody!

Hope you're all doing just fine 🙂

I wanted to see if I could get some help with this scriptlet from Mithran that does the following:
Spoiler: What it does
When using an item in battle, the script subtracts 1 of that item immediately after each member selects the item during command selection. This way, the items will be unavailable for the next actors to select if you ran out of them along the way. For example: if Ralph selects to 'use' the last potion, there won't be one for Ulrika to select next. 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).
Spoiler: Scriptlet
Ruby:
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

This script was made for the default RPGMVX. Even though I use Tankentai SBS 3.4e, I have thoroughly tested and found that it works exactly the same in both battle systems.

The problem is very small and specific: If, say, you have 1 potion left, and you cancel the use of that potion while selecting the target --which brings you back to the item selection menu-- you won't be able to select the item again (buzzer sound) unless you fully cancel the current actor's action selection turn and go back to the previous actor's action selection turn. By doing this, the item previously selected gets restored correctly and you can try again, hopefully without second thoughts this time.​

Although this is a rather small bug, I believe it takes you out of the experience a bit, and I'd really like to be able to use this properly.

Thanks all for any attention thrown at this!
Or you could use my solution here.
(Wait till it gets approved by a moderator!)
Hey Kyonides!

Thanks for the reply 🙂
I was checking that script, and it seems to run into the same issue.

I uploaded a short demonstration here:
Spoiler: Error Demo


Right before the buzzer I just pressed "X" to go back to the item menu and maybe, say, choose another item with that same character, but the potion is no longer available unless I press "X" 2 times to redo the whole action selection.

Updated the showcase vid. This one's much better than the 1st, hehe 😅

I believe this issue could be solved if somehow the items could get deducted AFTER you select your target and not right after choosing it without having selected a target yet. This way, if you select an item, and --while selecting a target-- you cancel so you can choose a different item with that same character, the item selection window should still remain unchanged 🙂
I guess you didn't notice it as of yet, but I did update that script of mine a couple of days ago. Just letting you know about it.
Hey, Kyonides!

Thanks a lot for following up with this request! The script seems to be fixed for the most part, however, I did find a few instances where the same bug occurs, although much less frequently.

Spoiler: Error Demo 2
I tested the updated version on a clean Tankentai SBS 3.4e and also on a clean standard project (I do this just to make sure that SBS is not interfering, but I only care about how it works with SBS, as it's what I use):



The audio's a bit busted up. Sorry about that.

Finding the exact circumstances under which this happens is proving to be kinda tricky, however, it seems to be happening when 2 characters are commanded to use an item, and then the action of the 2nd character is cancelled by pressing "X", and the 1st character is commanded to use the same item he used at first.

All that said, I am currently happy with how the script works at this point, and I'd have no issue by just having this listed on my game's "known bugs", as it's very situational and wouldn't cause much trouble overall. Therefore, I'll leave the decision of whether or not to polish this script to perfection up to you 🙂

Thanks a lot for your support! ☺️
What do you mean by cancelled here?
Does the other character forget about using that item and goes back to the previous menu?
Or he or she gets frozen and cannot consume it?
What do you mean by cancelled here?
Does the other character forget about using that item and goes back to the previous menu?
Or he or she gets frozen and cannot consume it?
Ah, sorry about that. By "cancelled" I just mean pressing "X" to go back to the previous character's command selection. The item use process works exactly as it should 😀
So the impression I'm getting here from your edited posts is that once the player cancels the use of any item and it goes back to hero No. 1 or the previous hero, it only subtracts the value once and not twice, right?
UPDATE: After the script updates, we realized that the specific issue I described in this post (when it comes to Kyonides' method) is 100% caused by the battle system I'm using (Tankentai Sideview Battle System 3.4e). Kyonides' method works with no issues and fixes the problem that Mithran's script has for the default battle system, but sadly it's not compatible Tankentai SBS.

So, technically, the original issue has been solved. However, let's just put this topic on hold for now, just in case a compatibility fix is achieved later on, in which case we'll post it here 🙂

Thanks! ☺️

Spoiler: Tankentai SBS 3.4e Compatibility Issue
Ok, so I've been testing a bit more and realized that the 1st issue still persists. This time I made a lengthy FULL REPORT of my findings while testing, hehe 😀 The process goes as follows:

> Enter a fight!
1.- Two options: Fight or Escape > Select "Fight"!
2.- Go to "Item" in the Menu (with any character).
3.- Select an item.
4.- BEFORE SELECTING A TARGET, press "X" to go back to the Main Battle Menu, because you realized you didn't want to use an item after all!

Right after this point, the script will substract 1 of the selected item, whatever action you end up selecting in the end. Even if you ended up choosing to use a skill, you still have 1 less of the item you were about to use before. Naturally, if you had only 1 of that item and you try to use it again, the buzzer will sound, as you don't really have that item anymore.

ADDITIONAL INFO. on the error
  • If you have 5 potions, you can repeat the aforementioned process 5 times and the same will happen, you'll reach the buzzer. All the items lost through this process are returned to you after you either:
  1. Press "X" until you're back to the 1st step (when you have to select "Fight" or "Escape").
  2. Decide to do other things and wait for that round to play out. Next turn the items will be available.
  • If, during the same round, you try to use the same potion again with the same character that you went through the 4-step-process with, then the amount displayed when selecting the item will not be refreshed (it'll say you still have that one potion, but the buzzer will still play, as you don't really have the item, it was substracted before).
  • If you try to use the item with a different character on that same round (after a previous character went through the 4-step-process already), the amount displayed when selecting the item will actually be refreshed for them. Example: You have 2 potions, the 1st party member went through the 4-step-process (almost used a potion), but then decided to use a skill. The next character, when selecting to use another potion, the amount displayed will be 1, which is the correct amount, as another potion was substracted by the script before, even though it wasn't used in the end.

END OF REPORT!!!
Hope it amounts to something :rswt2:

Original thread: https://forums.rpgmakerweb.com/threads/item-selection-number-fix.162946/