So, we just finished the last sprint which was the Player UI. Now we’ve got all of the UI stuff out of the way. Mostly importantly (in regards to this sprint), we have an equipment window which has slots for items. In this scope of work document, we’ll discuss what needs to be done, and how it needs to be done, and possibly the order in which it needs to get done. Lets get started.

Equipping Items

In the original Tibia, the way that picking up items was fairly simple. Since everything was tile-based, you would click on a tile, and click and drag the items into your inventory. If there were other items under your item, you would only receive the top item. Very simple. From a design perspective, it was even beautifully simple.

For us though, this isn’t going to work since we don’t have tiles. This raises some questions as to how we want to be able to pick up items. The downside to the way that tibia did things was that if someone else was faster on the ‘drag’ of the ‘click and drag’, then they would get the item first. Dragging items to the inventory was always laborious and took a lot of work. If you missed the UI by a bit, then the event cancelled and you had to start over. Click, drag, click, drag, endlessly.

So, it would stand to reason that there should be a better way to pick up items. I’ve already got an idea, lets talk about it and see if it works.

How about, when you right click on an area of the map, it will give you options (icons, organized in a circle) around where you clicked. These options vary depending on what one could do there. For example, if there are items to pick up, then that option exists. If there is an herb to harvest, then there’s that too. If there’s a lever to push, then there’s that, etc etc.

This would mean that if you wanted to pick up an item you would have to right click, and then select the pick up icon. We could also offer a way to do this via keybind, so if you wanted to pick up items faster, it could be press E on keyboard, then right click on designated spot. Well that’s pretty decent, but what about picking up single vs multiple items. What if I want to pick up 5 items at once? What if I want to pick up just 1 of the 5?

My immediate thought is that we could offer some kind of modifier. Like, hold alt and click on the icon to pick up all of the items. Or maybe, we don’t remove the icon until the player clicks somewhere that is not a valid icon spot. So for example, you see 5 items. You right click. Icons come up. You click on the pick up icon. It grabs the first item. You click it 4 more times, and each of the items enters your inventory. Then the icons disappear because there are no items left to pick up.

This of course still leaves us unable to pick up a specific item of the five that are lying on the ground, but I’m not sure thats such a big issue. In addition, players could have a pick up radius that is relative to their players position, as well as relative to the position they clicked at, so a smart player could position themselves, and their click such that they only pick up the designated item. In addition, the system will try to pick up the item that is being shown ‘on top’ as best it can.

Well, what about throwing items? In tibia, loot-bagging was a very interesting and famous game mechanic. I think our system could accommodate that as well. Instead of a ‘pick up’ icon, we have a ‘throw items’ icon. It would work the same way, such that the more you click it, the more items are thrown.

Further Considerations

So, when thinking about these new ideas, there are some obvious considerations. We need to consider for example, that not only picking up items, but also throwing items will involve raycasting against hard surfaces to make sure we can’t pick up items behind walls for example. This would also mean that if we’re throwing items that if we throw an item against a wall, the final destination point of the item will be at the collision point of the wall. Interesting.

Now what about equipping items? If we wanted to equip a helmet that is on the floor, how would we go about doing that? Well, we could put another icon that says ‘equip’. However, when it comes to items that don’t have a single slot (like hands or rings (each has 2 possible slots)), this breaks down. So, we could just disallow equipping from the floor.

That would mean that in order to equip something, you’d need to add it to your inventory first, and then equip it. But wait, what if I don’t have a bag? Well, in that case the item would be auto-equipped if you had an empty slot. However, if you have no empty slots, and no bag, then you should receive an error message stating that you can not pick something up. I think that works fairly well.

Un-equipping or moving items from the inventory to the ground should be pretty simple. Just click and drag and the system will throw that item as far as it can.

Moving items within the inventory should work the same as it does in Tibia, or most MMORPGs. Equipping and un-equipping should work the same way as well; just click and drag.


Okay, so lets talk about what needs to be done. This for sure is going to be a big sprint. Lets start listing thins out and see if some structure emerges.

  • Items
    • Item prefabs
    • Item properties / stats
  • Player equipment script
  • Generic right-click functionality
    • Item pickup
    • Item move
  • Backpack window
  • Item click and drag functionality
  • Saving items to database and recreating upon login
  • Currency

Immediately there are some things that need further discussion. Lets cover those things next.

Limited Scope

So, there are some things that should be left out of this scope. Its already big enough, and these things don’t need to get made right now, so I’ll just leave them out for now. Those two things are item stats, and currency.

Currency is getting left out because theres nothing we can do with it right now, and it will probably be handled differently than regular items.

Item stats are going to be quite complicated and will modify the player’s stats when they are equipped, so again, to limit the scope, we’re not going to expand on item stats here. The only properties the items will have for now is a name, a type, and an image (and internally an id).

It would obviously be nice for a player to be able to right click on an item and view the item, so that they could see its name and stats, but again, lets push that off for now.


I have to say, I’m really glad I took the time to write up this document. It turned out to be a big one. It helped me to answer some of the questions I had. Now I can go work on the sprint document, and get started working on code and prefabs later today.

Further Analysis

I’m currently stuck trying to figure out how to do something. So, I’m going to attempt to analyze the problem here, in hopes that I can figure out the right way to solve this problem.


So far, I’ve gotten all of the database related stuff done.  I’m at the point where the player logs in, and we need to initialize the items for that player, on the server side. That part isn’t the tricky part. The way I’ll have items work is that the items (represented as game objects) will actually exist on the player object, as a child object. They will move around and follow the player. They don’t have colliders, and their sprites are turned off while in this mode.

Then, say for example a player were to unequip an item. We’d take that item from the player, and move it to the desired location. Then we simply turn the sprite renderer on, and enable it to be picked up. Thats not the tricky part.

The problem that I have is how to tie all of this into the event manager I’m building. I have these events:

  • OnCreateAddItem
  • OnCreatureRemoveItem
  • OnCreatureEquipItem
  • OnCreatureUnequipItem

And I have these scripts:

  • Equipment – this is the script that exists on the player
  • Item System – this is the thing we talk to to get items
  • Prefab Manager – this is the thing we talk to to get prefabs
  • Event Manager – this is the thing that broadcasts out the above events

So I think I already see my problem. The item system and prefab manager are doing about the same thing. Lets say I just get rid of the item system, and just use the prefab system to grab prefabs. We could build the GetItem() function that was in the item system into the prefab manager.

Well okay, but who is going to raise the above events? I suppose it would have to be the Equipment script. I guess thats fine since the equipment script knows whether or not an add item will cascade into an equip item, or into drop item, etc. Actually let me try to graph that up.

creature_items_graphOkay, so I got a little carried away with the graph. Let me try to elaborate on it a bit. Items are added to the creature via several ways. A player could craft something, and the crafting system simply “adds” the item. The player or monster could pick up an item off the ground, and it gets added that way, or in our case, we’re logging in and need to instantiate the player’s equipment. All of these things will trigger a CreatureAddItem event first.

If the creature doesn’t have anything in their equipment slot for that item, then the item will go there. If the slot is taken, it will try to put it in the creatures inventory. If the inventory is full, it will drop the item. All of this logic lines up nicely with our events. If an item is dropped, it will then cascade into a creature remove item event. There are also other ways to trigger a creature remove item event. A creature might throw an item, or a creature might consume an item. And, now that I’m thinking about it, a creature might die and drop some items that way.

Okay, this is starting to make sense a bit more. So, what happens at each stage of the process. Lets discuss that next:

  • Creature Add Item – we instantiate the prefab, hide the sprite, and set it as the child of the creature.
  • Creature Add Inventory Item – we simply add it to the list of items that are in our inventory. Visually its already disabled, so thats done.
  • Creature Equip Item – we simply assign the item to the correct slot in the equipment script. Done.
  • Creature Drop Item – we simply un-parent the item from the player, remove it from inventory or equipment if it existed there, and enable the sprite. Now its on the ground under the player. Done.
  • Creature Throw Item – we remove the item from equipment or inventory, un-parent it, enable the sprite, and then do all of the logic involved with throwing something. If it hits a wall, we place it there, if not, it ends up at its final destination.
  • Creature Consume Item – we would remove the item from equipment or inventory, then we’d destroy the item. Done.
  • Creature Remove Item – I think this will be a purely decorative event to notify when any of the removal events have occurred.

I think all of this makes a good deal of sense. I’m going to see how well it applies to the code now.