Creating a new type of item

● ARCHIVED · READ-ONLY
Started by vociferocity 16 posts View original ↗
  1. So I've decided to forego the whole "monsters drop gold" route, and instead go for "monsters drop useless themed items that you sell for gold" (broken fangs, pelts, etc). but I don't want the loot items to clog up the regular item page, or the key item page, so I'd like to create a new type of item (ie "loot") that I can designate items as, and have a new section in the item menu for them.

    I had a look in the scripts, and I thought I'd done the right stuff (added a line in the vocab page, added a new window page (basically just C/Ped the key item page), and added a "if the item is Item type and is not key_item and is loot_item, then it's a loot item" line in one of the item pages), but I obviously missed something, since it's not showing up in the database as either a type I can designate items as, or a term I can specify a name for, or anything. Am I totally barking up the wrong tree? I really though it'd be quite simple :(
  2. Scripts do not allow you to change what you can see or do in the editor. You will have to define them as regular items, and then have something in the script to determine whether to show it on the "regular" or "loot" list. Notes would be the ideal way to go.
  3. ughhhhhhh how troublesome

    but ok, thanks! I don't think I've really ever used the note system before, I'll have to check it out :)
  4. You don't HAVE to go that way. You could just allocate the first 100 items to "regular" stuff and from 101-150 to loot, then make your script allocate based on item number.

    I just suggested notes because it's a VERY popular way to add extra information to the database. There are a LOT of scripts for Ace that take advantage of the note boxes. Check some of the more simple ones out, or look for some tutorials. It's not too complicated. Or if you're fine with scripting, just go to the help file and look at the layout of the database, which should clue you in on how to access them :)
  5. I might as well work out notetags, from the tutorials I've seen they don't look that complicated. plus, they seem like they'd be v handy for lots of things
  6. I'd prefer to define an array of ID's in the script related to your custom item type.



    Code:
    loot_items = [2, 3, 4, 10, 11, 15, 17, ... ]
    Pros

    -manage all custom loot items from one location

    -less typing for the user

    Cons

    -if you delete an item, you better remember to update the array

    -users have to cross-reference to determine whether an item is a loot item or not
  7. ok honestly I had a go with the notetags, and clearly I understand a lot less of the rpg maker scripting language than I thought I did, because I have pretty much no idea what to do with either a function that returns if the specific notetag is there, or with an array of items, and also the code I already had is broken haha. sorry to be so fail at this, but could you guys maybe give me a bit of a step by step walkthrough through this whole thing?
  8. You COULD if you dont want to use the key items page. just set the vocab for that to be loot right in the database and then just set all the loot items to be key items. simple solution if you decide not to have a key items page.
  9. vociferocity said:
    ok honestly I had a go with the notetags, and clearly I understand a lot less of the rpg maker scripting language than I thought I did, because I have pretty much no idea what to do with either a function that returns if the specific notetag is there, or with an array of items, and also the code I already had is broken haha. sorry to be so fail at this, but could you guys maybe give me a bit of a step by step walkthrough through this whole thing?
    I'm not really sure what you want to do either.

    If I were to implement a custom item type it would just be for filtering purposes.

    Spoiler
    Code:
    # define a loot type
    module RPG
      class Item
        def load_notetags
          # search for the specific string using regex
          res = self.note.match(/<loot_type>/)
    
          # just make it 2
          if res 
            @itype_id = 2 
          end
    
          # don't check anymore in the future
          @loot_checked = true
        end
    
        # is this a loot item?
        def loot_item?
          # since RPG objects are not initialized we need to explicitly check it
          load_notetags unless @loot_checked
          @itype_id == 2
        end
      end
    end
    
    # add new category
    class Window_ItemCategory
    
      def col_max
        return 5
      end
    
      def make_command_list
        add_command(Vocab::item,     :item)
        add_command(Vocab::weapon,   :weapon)
        add_command(Vocab::armor,    :armor)
        add_command(Vocab::key_item, :key_item)
        add_command("Loots", :loot)
      end
    end
    
    # add new case for your category
    class Window_ItemList < Window_Selectable
      def include?(item)
        case @category
        when :item
          item.is_a?(RPG::Item) && !item.key_item?
        when :weapon
          item.is_a?(RPG::Weapon)
        when :armor
          item.is_a?(RPG::Armor)
        when :key_item
          item.is_a?(RPG::Item) && item.key_item?
        when :loot
          item.is_a?(RPG::Item) && item.loot_item?
        else
          false
        end
      end
    end
    This example allows you to tag your items with <loot_item>, and then in-game you will have
  10. Should there be something in there to exclude loot items from the :item category? (And maybe the key_item category?)
  11. There should be.
  12. I mean this:



    Code:
    # add new case for your category
    class Window_ItemList < Window_Selectable
      def include?(item)
            case @category
            when :item
              item.is_a?(RPG::Item) && !item.key_item? && !item.loot_item?
            when :weapon
              item.is_a?(RPG::Weapon)
            when :armor
              item.is_a?(RPG::Armor)
            when :key_item
              item.is_a?(RPG::Item) && item.key_item? && !item.loot_item?
            when :loot
              item.is_a?(RPG::Item) && item.loot_item? && !item.key_item?
            else
              false
            end
      end
    end
    I'm not familiar enough with the way item/key_item/loot_item are differentiated. If you don't add the extra checks at the end of those lines, could you end up with loot or key items in each other's lists, or loot items in the regular items list?

    (Ugh! Darn IPB code formatting!)
  13. Yes if it's not filtered properly you'll get extra stuff in your lists that you don't want.

    It's the `itype_id` attribute.

    0 is a common item, 1 is key item, and 2 is the custom loot item.

    I think the default item check is just bad. It basically assumes an item is either a key item or it's not. Which was probably the dev's intent, but even this would've been nicer...



    Code:
    when :item
      item.is_a?(RPG::Item) && item.itype_id == 0
    when :key_item
      item.is_a?(RPG::Item) && item.itype_id == 1
    when :loot_item
      item.is_a?(RPG::Item) && item.itype_id == 2
    ...
    It's like, why not just check whether you're a common item if you're in the common item category? They wrote it in such a roundabout way.
  14. awesome, it works perfectly! thanks so much for your help, guys :) checking out the code you wrote has given me a few "aha!" moments about rpgmaker scripting, I should really look into it a bit more. /wanders off to find a tutorial
  15. The help document describes all of the RPG classes. You will probably need to reference that often.
  16. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.