Galv’s New Item Indication V.1.5

Demo – Version 1.4 > (Demo uses old version)

#------------------------------------------------------------------------------#
#  Galv's New Item Indication
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.5
#------------------------------------------------------------------------------#
#  2014-01-05 - Version 1.5 - compatibility fix
#  2013-07-16 - Version 1.4 - made key items work
#  2013-03-05 - Version 1.3 - fixed bug when all items are new when battle exit
#  2013-03-03 - Version 1.2 - added script call to manually remove 'new' images
#                           - fixed unequipping item creating 'new' images
#  2013-03-03 - Version 1.1 - fixed method 2 new not appearing for drops
#  2013-03-03 - Version 1.0 - release
#------------------------------------------------------------------------------#
#  Adds a 'new' image on items in the inventory that the player has recently
#  acquired. There are 2 methods for you to chose from as to when this image
#  appears and when it is removed and no longer counted as new.
#------------------------------------------------------------------------------#
#  SCRIPT CALL
#------------------------------------------------------------------------------#
#
#  clear_new(type)      # Manually removes 'new' images from selected type
#                       # type can be one of the following
#                       # :all    :item     :weapon    :armor
#------------------------------------------------------------------------------#
#  EXAMPLE:
#  clear_new(:item)     # all 'new' image on items will be cleared
#  clear_new(:all)      # all 'new' images on everything will be cleared
#------------------------------------------------------------------------------#
  
($imported ||= {})["Galv_New_Item_Indicator"] = true
module Galv_Nitem
    
#------------------------------------------------------------------------------# 
#  SETUP OPTIONS
#------------------------------------------------------------------------------#
  
  IMAGE = "new_indicator"    # Image located in /Graphics/System/
    
  METHOD = 2     # METHOD option can be 1 or 2 (see below)
  
#------------------------------------------------------------------------------# 
#
#   1: The 'new' image appears on items that the player hasn't seen before and
#      is only removed when the player moves the cursor over them (from any
#      scene)
#
#   2: The new image appears for items that are picked up and are removed
#      when the player leaves the item scene OR cursors over the item.
#      Any items picked up again will re-add the 'new' image for the player to
#      see what items they picked up recently. (So if you already had 4 potions
#      and pick up another, potions would have 'new' image again).
#
#------------------------------------------------------------------------------# 
#  END SETUP OPTIONS
#------------------------------------------------------------------------------#
  
end
  
class Game_Interpreter
  def clear_new(type)
    if type == :all
      $game_party.nitems[:weapon] = []
      $game_party.nitems[:armor] = []
      $game_party.nitems[:item] = []
    else
      $game_party.nitems[type] = []
    end
  end
end # Game_Interpreter
  
  
module Galv_GetCat
  def get_category(item)
    if item.is_a?(RPG::Item)
      return :item
    elsif item.is_a?(RPG::Weapon)
      return :weapon
    elsif item.is_a?(RPG::Armor)
      return :armor
    else
      return :none
    end
  end
end # Galv_GetCat
  
  
class Window_Help < Window_Base
  include Galv_GetCat
    
  alias galv_nitem_wh_set_item set_item
  def set_item(item)
    galv_nitem_wh_set_item(item)
    add_to_known_items(item)
  end
    
  def add_to_known_items(item)
    category = get_category(item)
    return if category == :none
    if !$game_party.nitems[category][item.id] && Galv_Nitem::METHOD == 1
      $game_party.nitems[category][item.id] = true
    elsif $game_party.nitems[category][item.id] && Galv_Nitem::METHOD == 2
      $game_party.nitems[category][item.id] = false
    end
    SceneManager.scene.refresh_new
  end
end # Window_Help < Window_Base
  
  
class Game_Party < Game_Unit
  attr_accessor :nitems
  include Galv_GetCat
    
  alias galv_nitem_gp_initialize initialize
  def initialize
    @nitems = {:item=>[],:weapon=>[],:armor=>[]}
    galv_nitem_gp_initialize
  end
    
  alias galv_nitem_gp_gain_item gain_item
  def gain_item(item, amount, include_equip = false)
    galv_nitem_gp_gain_item(item, amount, include_equip)
    if Galv_Nitem::METHOD == 2 && item
      last_number = item_number(item)
      new_number = last_number + amount
      
      if [[new_number, 0].max, max_item_number(item)].min > last_number
        cat = get_category(item)
        return if cat == :none
        $game_party.nitems[cat][item.id] = true
      end
    end
  end
end # Game_Party < Game_Unit
  
  
class Window_ItemList < Window_Selectable
  include Galv_GetCat
    
  alias galv_nitem_wi_draw_item draw_item
  def draw_item(index)
    galv_nitem_wi_draw_item(index)
    item = @data[index]
    return if item.nil?
      
    cat = get_category(item)
    return if cat == :none
    rect = item_rect(index)
    if Galv_Nitem::METHOD == 1 && !$game_party.nitems[cat][item.id] ||
        Galv_Nitem::METHOD == 2 && $game_party.nitems[cat][item.id]
      draw_item_new(item, rect.x, rect.y)
    end
  end
    
  def draw_item_new(item, x, y)
    bitmap = Cache.system(Galv_Nitem::IMAGE)
    rect = Rect.new(0, 0, 24, 24)
    contents.blt(x, y, bitmap, rect, 255)
  end
end # Window_ItemList < Window_Selectable
  
  
class Window_EquipItem
  # If Yanfly's Equip Engine:
  if $imported["YEA-AceEquipEngine"]
    def draw_item(index)
      item = @data[index]
      rect = item_rect(index)
      rect.width -= 4
      if item.nil?
        draw_remove_equip(rect)
        return
      end
      dw = contents.width - rect.x - 24
      draw_item_name(item, rect.x, rect.y, enable?(item), dw)
      draw_item_number(rect, item)
      cat = get_category(item)
      return if cat == :none
      if !$game_party.nitems[cat][item.id] && Galv_Nitem::METHOD == 1 ||
          $game_party.nitems[cat][item.id] && Galv_Nitem::METHOD == 2
        rect = item_rect(index)
        draw_item_new(item, rect.x, rect.y)
      end
    end
  end
end # Window_EquipItem (For Yanfly's Equip Script)
  
  
class Scene_Base
  def refresh_new
    @item_window.refresh if @item_window
  end
    
  alias galv_nitem_sb_return_scene return_scene
  def return_scene
    clear_new if Galv_Nitem::METHOD == 2
    galv_nitem_sb_return_scene
  end
    
  def clear_new
    if SceneManager.scene_is?(Scene_Item)
      $game_party.nitems[:weapon] = []
      $game_party.nitems[:armor] = []
      $game_party.nitems[:item] = []
    end
  end
end # Scene_Base
  
  
class Game_Actor < Game_Battler
  include Galv_GetCat
    
  # OVERWRITE
  def trade_item_with_party(new_item, old_item)
    return false if new_item && !$game_party.has_item?(new_item)
    $game_party.gain_item(old_item, 1)
    $game_party.lose_item(new_item, 1)
    unequipped_not_new(old_item)
    return true
  end
    
  def unequipped_not_new(item)
    cat = get_category(item)
    return if cat == :none || Galv_Nitem::METHOD == 1
    $game_party.nitems[cat][item.id] = false
  end
end # Game_Actor < Game_Battler
Advertisements

32 thoughts on “Galv’s New Item Indication V.1.5

  1. Marcos Luna says:

    Great script Galv,thanks you very much!
    Just a little question,is normal that all objects have the “new” indicator again after a battle, even after seeing them in the menu before?

    • Galv says:

      Haha, indeed it is not normal. That was code I accidentally left there from previous version – grab the script from this page again (mouse over the script code and icons appear in top right to copy to clipboard). Thanks for letting me know

  2. There is a way to get the “new” indicator also for weapon and armor?

  3. nice script galv! just a thing, do you think it is possible for it to be compatible with Modern Algebra Item Menu?
    http://rmrk.net/index.php?topic=46516.0

    The method 2 of your script works, the “new” indicator disappears after leaving the menu. However the method 1 dont’t work. Even when you pass the cursor over the items, the indicator doesnt’ disappear. Can you take a look at it? :D

  4. Johnny says:

    Love the script!
    but when i’m selecting the bait of the fishing mini game you made (which is another great one!)
    the “new” sign stays there and it looks really awkward…
    is there anyway to prevent that?

    • Galv says:

      Oh hmm, might have to add a patch that fixes it (unfortunately don’t have time at the moment). You could use the script call to clear new indicator on items but that would clear them all.

  5. Ellen says:

    It doesn’t work for me :( says there’s a syntax error that occurred in Line 37 “expecting line end” or something like that. :\

  6. Ellen says:

    I tried it again, but it still didn’t work. I have a few other scripts that I’m using, but none of them have anything to do with system graphics.

  7. Ellen says:

    I’m using Google Chrome. :\

    • Galv says:

      Very odd, I can copy/paste the code fine in chrome. Next thing to try I have just uploaded a demo with the latest version – try copying it from there :)

  8. Ellen says:

    Ah~! It works now! :D Thanks for doing so much to help me with this weird problem ^^

  9. Rob says:

    Newbie question here, but how do i find an image to place in as the new_indicator image?
    What size should it be etc? The images I have imported thus far seem to be either too big or just
    don’t display at all.

    • Galv says:

      There’s a link to the demo at the top of the page that has the image I made, but 24 x 24 (icon size) image will work

      • Rob says:

        Thanks Galv! I’ll give that a try. What are you working on at the moment?
        Are you creating RPG ACE VX games?

      • Rob says:

        yup that works, thanks mate, great script!
        Would love to network with more of the RPG VX ACE community, be interested to hear what people are working on, at the moment I am around 1 hour in to creation of my first game, at around 20 hours of development time. It’s taking a while and bug testing is eating up alot of time as is the learning curve, but i feel im getting the hang of the basics now.

      • Galv says:

        Keep at it, it does get easier the more and more you learn. You’ll go through a stage where you will feel you want to re-do your game because you’ve learned much better ways to do stuff :P

        I’m working on a commercial game currently with a Kickstarter planned for 1st of March.

        More info can be found here if interested:
        http://www.rpgmakervxace.net/topic/21233-tobys-island/

      • Rob says:

        Thanks mate, I’ll check that out. If you need any help with anything, my background is in QA, I worked on the Star Wars lego saga, working regression, bug testing on 306,ps3,psp,3ds, so I know how to work my way around a bug tracker and prioritize as such. If you need anything like that, hit me up. Apart from that, thanks for this awesome script and for helping me with the final hurdle here ;) cheers pal

  10. Waldo says:

    Hey just wanted to leave a thanks! great script mate!

  11. Tedrabear says:

    Hey dude, great script! When I try to download the ‘1.4’ link for the ‘New’ icon Chrome tells me that it’s a virus, when I use Firefox it downloads but as a .exe application? What is the application? Is there somewhere else to get ‘that’ icon? (others just don’t have the same magic)

    Thanks.

    • Galv says:

      It’s not a virus, the exe is the compressed project (that rpgmaker creates when you compress your game files). I haven’t put it anywhere else, no – but it’s a 24 x 24 pixel image if you want to make your own.

  12. feanor says:

    Thanks Galv!

  13. Júnior says:

    Erro, Line 130.
    $game_party.nitems[cat][item.id] = true

    Descrition.
    Script ‘Galv’s – New Item Indication’ line 130: NoMethodError ocurred. undefined method ‘[]’ for nil:NilClass

  14. lykos says:

    hello, i have a problem with the script and i hope you could help me. when i write the (:all) in the script and run the game, it shows me: unexpected tSYMBEG, expecting ´)´ def clear_new(:all). please help! (sorry if there´s bad english, im chilean)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s