Thread: Object-Orientated Items?

Page 1 of 7 123 ... LastLast
Results 1 to 10 of 64
  1. #1 Object-Orientated Items? 
    Banned
    Join Date
    Nov 2011
    Posts
    21
    Thanks given
    0
    Thanks received
    2
    Rep Power
    0
    Well, i'm writing a new base for myself at the moment, and it's in the stage where i'm about to start implementing interfaces and other stuff, but, i had an idea that popped up and im not sure if anyone thinks it'll be a good idea or not.

    I'm assuming it is related to how RS does theirs.

    Basically, what im thinking is having a class per item for example player items. This way, you can add states such as degraded state, different stats per different item etc etc.

    I believe this is how RuneScape must do it, because for some things such as barrows different pieces degrade at different speeds when you wear them, so, if you bought 2 dharok platebodies and switched before the first one degraded, you'd still have the whole time for the second one to degrade.

    My example would be like;

    Code:
    class Item {
    
    	int id;
    	int amount;
    	int state;
    	
    }
    Then, you'd have declared for players;

    Code:
    Item[] playerItems = new Item[28];
    It's an awkward idea, because you'd have to save the whole class instance and reload etc when the player logs in, but it's still feasable.

    Anyone agree this would be a good idea to implement?

    It'd also bring possible customisation to the game, such as being able to change stats based on item or something, like you could have an item where you can change the style that gives the most accuracy, such as switching stab with slash bonuses or something.

    Post your thoughts and opinions.
    Reply With Quote  
     

  2. #2  
    Programmer, Contributor, RM and Veteran




    Join Date
    Mar 2007
    Posts
    5,074
    Thanks given
    2,625
    Thanks received
    3,579
    Discord
    View profile
    Rep Power
    5000
    Servers like Hyperion already do this (the normal Hyperion doesn't store anything other than id/amount, but you could add additional attributes if required).
    .
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,747
    Thanks given
    354
    Thanks received
    1,368
    Rep Power
    3032
    [Only registered and activated users can see links. ]
    Quote Originally Posted by veer
    I think I know how to implement item tracking, and I think it's fairly easy.
    Most items in game can be treated as what in the domain-driven mindset call value objects. These objects have attributes but no conceptual individual identity... you can see an example of this in the fact most private servers merely keep an item ID or some other reference to a definition (ItemDef).
    It should be very clear items have been treated like this in private servers for some time now as it makes sense... an item ID or ItemDef reference are adequate because they are distinct from one another by their attributes, each item's definition.
    When people exchange dollar bills, they generally do not distinguish between each unique bill; they only are concerned about the face value of the dollar bill. In this context, dollar bills are value objects.
    The concept of value objects contrasts with that of entities, which are not defined merely by their attributes but yet by that very trait value objects lack, a sense of identity.
    However, the Federal Reserve may be concerned about each unique bill; in this context each bill would be an entity.
    What you can see here is that you are asking how to change items in game from value objects into entities... it is very much possible, but is it practical and worth it?
    It'd require quite a change in the codebase. A simple item ID would not be adequate here as instead we would now need to track the identity of each item, distinct from their attributes. Something perhaps like:
    Code:
    public class Item {
    
        private UUID id;
        private ItemDefinition definition;
        ....
    }
    Each individual item in the game could be tracked now by their unique ID distinct from others with the same attributes.
    Is it practical, though? Surprisingly so. Good luck.

    For more on this stuff, [Only registered and activated users can see links. ]

    As a side note, I'm a little surprised object didn't delve into this... I mean, he was the one who introduced me to DDD in the first place a couple odd years ago.
    Reply With Quote  
     

  5. #4  
    Banned
    Join Date
    Nov 2011
    Posts
    21
    Thanks given
    0
    Thanks received
    2
    Rep Power
    0
    Quote Originally Posted by Graham View Post
    Servers like Hyperion already do this (the normal Hyperion doesn't store anything other than id/amount, but you could add additional attributes if required).
    Quote Originally Posted by super_ View Post
    [Only registered and activated users can see links. ]
    Sweet, ill look into doing this then.
    Reply With Quote  
     

  6. #5  
    Registered Member
    Kamiel's Avatar
    Join Date
    Jul 2010
    Age
    25
    Posts
    1,272
    Thanks given
    66
    Thanks received
    166
    Rep Power
    295
    I'm using something similar to this for my source.
    Reply With Quote  
     

  7. #6  
    Registered Member
    Mister Maggot's Avatar
    Join Date
    Dec 2008
    Posts
    7,246
    Thanks given
    3,283
    Thanks received
    2,874
    Discord
    View profile
    Rep Power
    5000
    Are you planning to log all transactions/track items or something?
    Reply With Quote  
     

  8. #7  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,747
    Thanks given
    354
    Thanks received
    1,368
    Rep Power
    3032
    i think from his post he's merely interested in being able to retain state with instances of items (like the degradation of barrows items) versus the de facto canonical approach of treating items as value objects and merely keeping references to definitions e.g. using the item ID
    i don't actually know how useful it would be, however... don't different states of items have their own respective ID?
    Reply With Quote  
     

  9. Thankful user:


  10. #8  




    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    27
    Posts
    16,200
    Thanks given
    7,190
    Thanks received
    12,174
    Discord
    View profile
    Rep Power
    5000
    Oh by the way the barrows degrading thing is based on your account not the item. If someone uses a "dharoks axe" down to the point where it's 1 point from degrading, and they give you it, it wont degrade until you use up your 'points for it to degrade'. They get around this by not letting you trade them (but that's how it would work).

    You can try this by having multiple of the same barrows item at the same degradable state. Get one down to near degrading, put on the other one and it wll degrade instead.

    Also @super_ how are you going to keep track of individual items, in things such as stacks? What if I had a stack of 2147M dharok's platebodies. Is the server really supposed to track each one is at what index of the stack? (This is another reason why jagex go the easier way).

    [Only registered and activated users can see links. ]



    Reply With Quote  
     

  11. Thankful user:


  12. #9  
    Banned

    Join Date
    Dec 2008
    Posts
    2,098
    Thanks given
    1,419
    Thanks received
    732
    Rep Power
    0
    Quote Originally Posted by Scu11 View Post
    Oh by the way the barrows degrading thing is based on your account not the item. If someone uses a "dharoks axe" down to the point where it's 1 point from degrading, and they give you it, it wont degrade until you use up your 'points for it to degrade'. They get around this by not letting you trade them (but that's how it would work).

    You can try this by having multiple of the same barrows item at the same degradable state. Get one down to near degrading, put on the other one and it wll degrade instead.

    Also @super_ how are you going to keep track of individual items, in things such as stacks? What if I had a stack of 2147M dharok's platebodies. Is the server really supposed to track each one is at what index of the stack? (This is another reason why jagex go the easier way).
    So If I have two dharok axes and they're both at say the 75 mark I use one of the axes till it's one point from degrading to the 50 mark then I switch to the other axe and it will degrade as if it was the axe I used down to one point from being at the 50 mark?
    Reply With Quote  
     

  13. #10  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,747
    Thanks given
    354
    Thanks received
    1,368
    Rep Power
    3032
    you would have a reference to each individual item in the stack, of course...
    Reply With Quote  
     

Page 1 of 7 123 ... LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Object list(dungeoneering items)
    By cruel ko in forum Help
    Replies: 0
    Last Post: 06-22-2011, 04:52 AM
  2. Object Grabber? Wheres the Items?
    By Deviants in forum Models
    Replies: 1
    Last Post: 02-14-2009, 09:58 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •