Creating a new type of item

Status
Not open for further replies.

vociferocity

Veteran
Veteran
Joined
Mar 29, 2012
Messages
180
Reaction score
18
First Language
English
Primarily Uses
N/A
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 :(
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

vociferocity

Veteran
Veteran
Joined
Mar 29, 2012
Messages
180
Reaction score
18
First Language
English
Primarily Uses
N/A
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 :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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 :)
 

vociferocity

Veteran
Veteran
Joined
Mar 29, 2012
Messages
180
Reaction score
18
First Language
English
Primarily Uses
N/A
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
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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
 

vociferocity

Veteran
Veteran
Joined
Mar 29, 2012
Messages
180
Reaction score
18
First Language
English
Primarily Uses
N/A
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?
 

Lord Valdyr

Team BlackHawk Dev
Veteran
Joined
Mar 13, 2012
Messages
159
Reaction score
18
First Language
English
Primarily Uses
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.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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.

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
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Should there be something in there to exclude loot items from the :item category? (And maybe the key_item category?)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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!)
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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.
 
Last edited by a moderator:

vociferocity

Veteran
Veteran
Joined
Mar 29, 2012
Messages
180
Reaction score
18
First Language
English
Primarily Uses
N/A
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
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
The help document describes all of the RPG classes. You will probably need to reference that often.
 

Celianna

Tileset artist
Veteran
Joined
Mar 1, 2012
Messages
10,557
Reaction score
5,592
First Language
Dutch
Primarily Uses
RMMV
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.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,845
Messages
1,016,961
Members
137,561
Latest member
JaCrispy85
Top