View RSS Feed

Mike's Blog

Excellia - Item support

Rate this Entry

So today I've mostly been focusing on improving the item support system. I already had a basic system which dealt with the rough edges (equipping/un-equipping, depositing and withdrawing). Though that was just temporary, and totally not to my likings.

Now, I've written a neat system which allows me to fully manage any item-related activity on the server. Amongst those classes, there is an item container class which maintains basically all items on an interface. With dedicated container listeners that listen for any changes in the container and synchronise the client-sided interfaces of that container. Inventory, bank, equipment, trade offers and the bank deposit box, which brings me to the following.

I was working on the banking system, hence allowing the bank booths to open them (more on object options in another post), in the west bank of Varrock when I noticed the Bank Deposit Box standing in the corner. I figured "While I'm at it, why not add deposit boxes as well?". So I started working on it. It wasn't hard though, basically the same thing as normal banking, just with limited features and different interfaces.

So the result of today is that I've created an almost complete, perfect banking system that includes depositing boxes. All that's left is to complete one or two bug fixes, do some unit tests and I have yet to complete item switching in interfaces (i.e. swapping the slots of 2 items in your bank). But I have already completed the methods to deal with this, so I suspect it won't be much work to finish it all tomorrow.

I still have to decide what I'm going to do after this, either start working on friends, ignores and (cross-world) private messaging or proceed with the item support and begin working on a trading system. Either way, the next post I'll make shall probably be about the object management.

Thanks for reading!
Categories
Excellia

Comments

  1. Deadproof's Avatar
    People usually ignore putting deposit boxes in the game, i like what your doing.
    When working with equipping, does your system already decide where the item should be in your equipment (via helm, shield, etc.)
    or do you have to input where what would go into? Is it seems easy to perform, just want to know if it is.

    Good work Mike
  2. Ripvayne's Avatar
    Great job Mike, glad I could help.
  3. Mike's Avatar
    Quote Originally Posted by Peace
    People usually ignore putting deposit boxes in the game, i like what your doing.
    When working with equipping, does your system already decide where the item should be in your equipment (via helm, shield, etc.)
    or do you have to input where what would go into? Is it seems easy to perform, just want to know if it is.

    Good work Mike
    Thank you. And the answer to your question is yes. In past server projects I've been searching for configurations such as those, and those are coming out very useful now. I have a utility class Equipment which contains several arrays with IDs of items that are classified as i.e. helms, shields, platebodies, etc. Upon the first access to this class (which is pretty much the moment the first player logs in as then the appearance update is flagged), the server iterates over all those arrays and places the item IDs within in HashMaps. This allows the equipment type of an item to be acquired rapidly without having any impact on performance.

    These arrays are also used upon the server startup, more specifically the initialisation of equipping event handlers. The handlers of skill requirements (especially Attack and Defense) store the IDs and their corresponding levels in a HashMap after configuring them. This allows very quick level requirement handling as opposed to a lot of servers out there, which configure item IDs over and over again during handling.
  4. Deadproof's Avatar
    Oo, Its tough to understand HashMaps. I like to think i understood but, not sure.
    Did you use level requirements based on the experience of the skill instead of level or both?
  5. Ripvayne's Avatar
    dopsfjgnvaodfvnasbufgvasdfou
    ASLBGVSUIOFBASDVKLFVNAODUFAS;V
    psidoasdfunvaldfuibna;dfbnasdf;lvnas;dfulnafginf;e uiovbhaysd'fbh;adefv ;ioahf[ovhfdp0haedj;dlmvo;adifhsg ;hax;vmfuihdeln;fvjhsph;sdffngp;suodfhv[nbf;usbnaslnvuiaf;ghdfgasrfngaiapvfruvnaurunvj d iaosab; a;jb v fafal;fahfjpasijfaisg'ga;lvn'ih'hn;ljntkmnounuhblj gklnarfgahviphdf;lgndffru
  6. Sean's Avatar
    Of course you probably wont do this but it would be awesome if you could do like mass banking and mass equipping such as lets say i go to the bank and I want to woodcut, i click a little icon of a tree and then bam, my inventory and worn items are deposited and suddenly my best equippable axe is equipped so then im ready to go chop some wood... now lets say i like to look fancy while chopping wood, i could press a cog gear on the bank and then click on the tree symbol, then it opens up a display of the equipment screen and the inventory with a search bar in the chat box, Hmmm i want to wear a robin hat, green d'hide, and ranger boots. so i just type each item in 1 at a time and then the client/server compares what you typed to what is in your bank and gives you a list of what is in your bank that contains those characters (basically like the GE) then you simply drag and drop from the list on to the equipment bar, also in the right hand corner three is a little trash can where you can drag items to take them out of the setup.

    also lets say im about to go to the barrows, have 3 custom buttons that players can fix up themselves with no presets, so i will click my custom button, and then once again my inventory and equipment are stored, and then the items I want are equipped and then the items i want in my inventory are taken. now I'm at barrows, so i go to verac's first, i switch to my attack style tab, now instead of just attack styles there are 4 buttons below all the attack styles similar to the ones in the bank, i click the first button which is a rune, i instantly switch to my magic equipment and prot from melee is on, and an autocast spell is already chosen. i kill verac's from far away with barrage. no damage, now i go to karil's, once again in magic gear and when i go down i start fighting, (this happens any time you get damaged) a screen replaces the inventory with a couple boxs one is those 4 little buttons in the attack style menu earlier, there is one that shows the symbol of food and another showing the sprites of a any potions in your inventory, so i quickly hit the magic potion button, and eat when needed and turn prayers on and off all in the same window.

    of course this can all be condensed into a simpler version but it was just a wild tangent of imagination. and i thought it would be insanely cool to add to a server. players would jack off to it... especially if it was in first person......
  7. Ripvayne's Avatar
    Quote Originally Posted by Sean
    Of course you probably wont do this but it would be awesome if you could do like mass banking and mass equipping such as lets say i go to the bank and I want to woodcut, i click a little icon of a tree and then bam, my inventory and worn items are deposited and suddenly my best equippable axe is equipped so then im ready to go chop some wood... now lets say i like to look fancy while chopping wood, i could press a cog gear on the bank and then click on the tree symbol, then it opens up a display of the equipment screen and the inventory with a search bar in the chat box, Hmmm i want to wear a robin hat, green d'hide, and ranger boots. so i just type each item in 1 at a time and then the client/server compares what you typed to what is in your bank and gives you a list of what is in your bank that contains those characters (basically like the GE) then you simply drag and drop from the list on to the equipment bar, also in the right hand corner three is a little trash can where you can drag items to take them out of the setup.

    also lets say im about to go to the barrows, have 3 custom buttons that players can fix up themselves with no presets, so i will click my custom button, and then once again my inventory and equipment are stored, and then the items I want are equipped and then the items i want in my inventory are taken. now I'm at barrows, so i go to verac's first, i switch to my attack style tab, now instead of just attack styles there are 4 buttons below all the attack styles similar to the ones in the bank, i click the first button which is a rune, i instantly switch to my magic equipment and prot from melee is on, and an autocast spell is already chosen. i kill verac's from far away with barrage. no damage, now i go to karil's, once again in magic gear and when i go down i start fighting, (this happens any time you get damaged) a screen replaces the inventory with a couple boxs one is those 4 little buttons in the attack style menu earlier, there is one that shows the symbol of food and another showing the sprites of a any potions in your inventory, so i quickly hit the magic potion button, and eat when needed and turn prayers on and off all in the same window.

    of course this can all be condensed into a simpler version but it was just a wild tangent of imagination. and i thought it would be insanely cool to add to a server. players would jack off to it... especially if it was in first person......
    You probably won't do this but if would be awesome if you would buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandosbuy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos.

    Also, let's say I'm about to go do barrows, but I don't have armor, it would be cool if you could buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos.

    of course this can all be condensed into a simpler version but it was just a wild tangent of imagination. and i thought it would be insanely cool to buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos buy me bandos. I would jack off to it. Especially if you buy me bandos.
  8. Sean's Avatar
    i died at bloodvelds with bandos on... the bot didnt eat for some reason... left it on over night... gf
  9. Mike's Avatar
    Quote Originally Posted by Peace
    Oo, Its tough to understand HashMaps. I like to think i understood but, not sure.
    Did you use level requirements based on the experience of the skill instead of level or both?
    HashMaps store key-value entries with the use of objects' hashcode() method. For an example, here is the StrengthRequirementHandler class: http://pastebin.com/6aiSbfzj

    As you can see, it's pretty basic and only covers a couple of items. It is highly expandable though, and makes the adding of new configurations a quick and easy job.

    You might notice the HashMap here though. When a player attempts to wield i.e. a Granite maul, the getRequirement(Item) method is called. That method checks if the maul's item ID is already configured in the HashMap, and if so it returns the corresponding value. If it is the first time any player tries to wield it since the server's start-up, it won't find any value yet, making it call the configureAndGet(Item) method. That method configures the required level for the Granite maul, puts it in the HashMap for later reference, and returns the value from the method. Any other time the Granite maul is attempted to be equipped, the handler can just get the required level from the HashMap without re-configuring it.

    In the case of the Strength skill, where not many items require a specific level for them to be wielded, its not such a difference. But i.e. the Attack and Defense skill it definitely is. The easiest way to configure those is by comparing item names (i.e. items that start with "Dragon" require level 60). But String comparison on such a scale can have quite an impact on performance. With the caching system, that's history. It gets configured once, after which it can rapidly be obtained from the caching HashMap.
  10. Unborn's Avatar
    http://pastebin.com/6aiSbfzj

    Non-hardcoded or gtfo. :assmike:
  11. Mike's Avatar
    Quote Originally Posted by Unborn
    http://pastebin.com/6aiSbfzj

    Non-hardcoded or gtfo. :assmike:

    If I wanted, I would've already done so. Wouldn't take longer than 10-15 minutes to dump all the configurations I have now but for as long as I'm unsure that all item IDs are covered, I'm not going to bother doing so.
  12. Deadproof's Avatar
    Yeah mike, it's a pretty basic function. Seeing it from that perspective, i guess i kind of knew.
  13. Unborn's Avatar
    I know you're open to criticism, so here we go. :jewzach:

    Hardcoding requirements is terrible. You might as well make an ItemAnimationHandler interface with subclasses such as ItemStabAttackAnimationHandler, ItemCrushAttackAnimationHandler, ItemBlockAnimationHandler, ItemWalkAnimationHandler, etc. and hardcode animations into those too while you're at it.

    "The easiest way to configure those is by comparing item names"
    Definitely not the most efficient. All this time you've been aiming to make it as efficient as possible, don't start taking the easy route now..
    Store requirements in database, preload at startup - or it's just going to have to load them later anyway.

    The per-skill approach is only needed if you plan on hardcoding.. so for the love of pizza get rid of the hardcoding and throw the requirements into your item data instead.
    No doubt the equipping methods will have to grab the item data anyway, just grab the requirements from that while you already have it.

    Also, there's almost 8000 items in a 377 cache. "as long as I'm unsure all of them are covered" is going to be forever.

    --

    On a different note, I'm interested in how you actually use your current "SkillRequirementHandler"s.
    How does it use them to check requirements?
    What happens when a user tries to equip an item, and they are lacking 2 or more requirements? Does it only output the first one it finds?
  14. Mike's Avatar
    I know hardcoding is terrible, and I'm not planning on keeping it this way forever. But as I said I won't dump the data until I've covered 99% of all item IDs. As for "is going to be forever"; The actual 317 cache I have has 6541 items, and I'm willing to share all equipment type data I have now: http://pastebin.com/RtWkdQGH

    Item names comparison is absolutely not the most efficient way, and I'm aware of that. That's why it actually is configured at startup (and I notice I haven't mentioned that clearly). With the use of the item IDs in the equipment arrays, I let the SkillRequirementHandlers configure everything while loading the event handlers. In the case of the StrengthRequirementHandler I didn't take the effort because there's actually just 6 items currently being processed within.

    As for the SkillRequirementHandlers;
    In an upper-class WieldSkillRequirementHandler, the constructor populates an array with all the SkillVerificationHandlers (construction of the class happens at startup).
    Whenever a player tries to equip an item, the actions depend on if the item has been tried to be equipped before (by any player);

    If the item has not been equipped before:
    The WieldSkillRequirementHandler loops through all SkillRequirementHandlers in the array mentioned earlier, calling their getRequirement(Item) method. If this method returns any value higher than 0, it's skill ID is placed in a HashSet (more on that in a sec). If a player lacks one of the requirements, it remembers that but it doesn't break the loop. Once it has looped through all SkillRequirementhandlers, it sends the 'failure message' of the remembered handler. The HashSet (which now has the skill numbers of all handlers that have a requirement for the item) is stored in a Map for later reference.

    If the item has been equipped before:
    The HashSet containing the corresponding skill number is retrieved from the Map mentioned above. It loops through the RequirementHandlers which are bound to that skill number, and breaks the loop upon the first lack of requirements (no need to look any further).