[SOLVED] Items are infinite ...

Started by TrueCynder, February 17, 2014, 05:25:19 pm

Previous topic - Next topic

TrueCynder

February 17, 2014, 05:25:19 pm Last Edit: February 18, 2014, 07:10:59 pm by TrueCynder
Hey everyone so i was testing some new healing items
and realized that they can be used infinitely
and that is the case with every healing item
i can just jam the enter button and use it and use it :/

Any idea why ?

Zexion

Make sure it is marked as a consumable. Otherwise it will not be deleted on use

TrueCynder

they all are conumable
and their numbers do decrease but once they hit zero they are still there (useable)

Zexion

Hmm if you use common events you should make sure and check if they have the item or check the quantity of the item before executing the event. If they don't or have 0 delete the item and do nothing

TrueCynder

I´m talking directly from the menu
When I´m in the target window i can just keep pressing it
It even says the item is :0 it´s grey´d out and everything
but i can keep using it

I even tried out to copy a default item and see if that is any different
but nope same happends to the default items

KK20

Modified Window_Item? Should probably post the scripts related to the item scene.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

TrueCynder

This is the Item window it´s the default one just with a new size so it fits the menu screen ...


#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
#  This window displays items in possession on the item and battle screens.
#==============================================================================

class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 50, 640, 338)
    @column_max = 2
    refresh
    self.index = 0
    # If in battle, move window to center of screen
    # and make it semi-transparent
    if $game_temp.in_battle
      self.y = 50
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Also add weapons and items if outside of battle
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
          @data.push($data_weapons[i])
        end
      end
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0
          @data.push($data_armors[i])
        end
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help2
    @help2_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

KK20

I'll need your Scripts.rxdata file then. Nothing is out of line there.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

TrueCynder

February 18, 2014, 12:10:58 pm #8 Last Edit: February 18, 2014, 12:20:30 pm by TrueCynder
Here you go : https://www.dropbox.com/s/x6ozoarp6nti96y/Scripts.rxdata

Also while you´re on it there are two other things that need fixing too
for one when you exit the equipment screen it returns to the wrong menu point
i allready tried to fix it myself but it won´t work

also wehna  party member is removed from the party it forget all of its learned skills :(

if you can - can you see if you can fix these too ?

KK20

February 18, 2014, 05:59:16 pm #9 Last Edit: February 18, 2014, 06:03:48 pm by KK20
Looking at modified Scene_Item. Look at comments on side for what to do:

   # If C button was pressed
   if Input.trigger?(Input::C)
     # If items are used up
     if $game_party.item_number(@item.id) == 2          #<===== wut, should be a zero
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     # If target is all
     if @target_window.index == -1
       # Apply item effects to entire party
       used = false
       for i in $game_party.actors
         used |= i.item_effect(@item)
       end
     end
     # If single target
     if @target_window.index >= 0
       # Apply item use effects to target actor
       target = $game_party.actors[@target_window.index]
       used = target.item_effect(@item)
     end
     # If an item was used
     if used
       # Play item use SE
       $game_system.se_play(@item.menu_se)
       # If consumable
       if @item.consumable
         # Decrease used items by 1
         $game_party.lose_item(@item.id, 2)          #<===== again, wut, should be a 1
         # Redraw item window item
         @item_window.draw_item(@item_window.index)
       end

As for the Scene_Equip not returning correctly, the update method was placed outside of the Scene_Equip class. Gotta move it inside.

And don't check the box for Initialize Actor when adding them back into the party.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

TrueCynder