HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Item Class Hierarchy Question  (Read 2663 times)

nocake

  • General Accounts
  • *
  • Posts: 404
    • View Profile
    • BlightMMO
[Resolved] Item Class Hierarchy Question
« on: Jan 18, 12, 04:49:34 PM »

http://wiki.heroengine.com/wiki/Inventory_Tutorial#Class_hierarchy_representation_for_items

more specifically http://wiki.heroengine.com/wiki/File:ItemsRepresentedAsClassHierarchy.jpg

Why do i need the last classes in that hierarchy? Could i just include an Armor Type field in armorItem? What is the reason you would have separate classes for each item. Thanks.

I will be writing a small tutorial on creating inventory on the server side only for now. Maybe later continue on to client side visualization and interaction.
« Last Edit: Nov 02, 12, 08:43:07 PM by HE-Cooper »
Logged

JoshHalls

  • Founding Professional
  • *****
  • Posts: 335
    • View Profile
    • The Repopulation
Re: Item Class Hierarchy Question
« Reply #1 on: Jan 18, 12, 05:28:14 PM »

You could just include every field you would ever use on the base spec and run it all that way, but the big point really is to break down the spec into pieces and only use the pieces that you need (or in some cases to override certain functionality).  It reduces down the number of fields to the most applicable fields for that item and adds quite a bit of expandability.  There really is no need to have armor data on a weapon unless you can wear it also or have any kind of stack data if you cannot stack it.

So the end result is you look at the base spec as what every spec instance is going to need or need 90% of the time and the rest you add in additional classes and GLOM the data through the spec oracle interface and now you have armor, weapons, grenades, scrolls, potions, etc.
Logged
Co-Owner/Programmer - The Repopulation

nocake

  • General Accounts
  • *
  • Posts: 404
    • View Profile
    • BlightMMO
Re: Item Class Hierarchy Question
« Reply #2 on: Jan 18, 12, 05:44:28 PM »

Right i understand all that. I am just wondering why you would need separate classes for handArmor, chestArmor, legArmor. I know in my case i wont need it but i figured i should shed light on why they decided to break down each armor Type.

Quote
It reduces down the number of fields to the most applicable fields for that item and adds quite a bit of expandability.

What expand-ability would be possible in having each armor type be broken down? and what MMO's might use a system like this?

My MMO will have base stats for armor piece and there will be no difference in capability between the head/arm/hand/chest/leg/boots.  
« Last Edit: Jan 18, 12, 05:49:16 PM by nocake »
Logged

JoshHalls

  • Founding Professional
  • *****
  • Posts: 335
    • View Profile
    • The Repopulation
Re: Item Class Hierarchy Question
« Reply #3 on: Jan 18, 12, 05:52:04 PM »

Not entirely sure what would be added exactly by breaking down those types unless they had unique values and attributes that were not in the other type, but in general you can probably group your armor types together (picture was probably just there as an example).
Logged
Co-Owner/Programmer - The Repopulation

nocake

  • General Accounts
  • *
  • Posts: 404
    • View Profile
    • BlightMMO
Re: Item Class Hierarchy Question
« Reply #4 on: Jan 18, 12, 05:56:29 PM »

Not entirely sure what would be added exactly by breaking down those types unless they had unique values and attributes that were not in the other type, but in general you can probably group your armor types together (picture was probably just there as an example).

Thank you.

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Item Class Hierarchy Question
« Reply #5 on: Jan 18, 12, 08:01:59 PM »

Besides being able to provide different fields, another use for glomming classes onto a node is to mark that node in a way that can be queried for by testing if it is kindof or exactly that type, then branching code based on that.  That is something done by some of the built-in Clean Engine code, as well as HJ Ref.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Item Class Hierarchy Question
« Reply #6 on: Jan 18, 12, 08:10:11 PM »

Quote
What expand-ability would be possible in having each armor type be broken down?

By having code depend on glommed classes, such as calling a method which gets defined in such a decorator class, then that behavior can be modified at run-time on a node-by-node basis by snapping on/off these interchangable parts.  The expandability comes in that you can define classes later in the future not yet even dreamed of yet that can add brand new functionality. This is similar to using virtual functions in inheritance, but with inheritance the classes are locked at creation but glommed classes can come and go as things change live, such as acquiring/losing a specific piece of armor.

I hope that makes sense; its all based on the decorator design pattern.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.