[Ynamar Engine] #5 - Engine Update [Combat, Inventory]
Repository: https://github.com/Zotesso/YnamarEngine
After a few months without touching the project, last week I decided to return to it.
Server and Client - Progress
Npc/Player Combat
Started Updating the Models
Draw Player HP bar and npc health bar using spritebatch of monogame.
Set the key Z to be the attack command, and added the sprite animation for attacking.
Now the exciting part for me: when the player attacks, the packet is sent via UDP. That means it's not as reliable as other information transferred so far, but it is faster, it’s taking steps toward good real-time combat.
When the packet reaches the server, it checks if any Npc is in the exact position being attacked. If that is the case, it reduces the NPC's hp and sends that information back to the players in the Map (I’m not 100% sure this part is working for all players in the map—need to come back to it later).
Next step: Work on Npc chasing and attacking players if their behavior is set to be aggressive.
-(1).webp)
Items/Inventory
Started again by updating the models.
Character → Has One → Inventory
Inventory → Has Many → Inventory Slots
Inventory Slot → Has One (or none) → Item
Then again, using the library GUM: https://docs.flatredball.com/gum I Created the Inventory and InventorySlot components.
The InventorySlot can have a SpriteInstance, which can accept Texture2D as a sprite. That means we can combine the Monogame Content Manager with the Gum Interface.
So I added some test items in the database for my player's Inventory and developed the Interface logic.
Finally, I chose the key combination: Alt + E to open the inventory.

I know it looks really ugly by now, but I'm not focusing in the graphics. At this stage, I'm just locked into the code, trying to add the features I think an MMO RPG Engine should have.
Next Steps:
After Player-Npc combat, the Npc should drop items from its drop list(already modeled), I'm still deciding whether those items will appear directly in the player’s inventory or if the user will need to interact with them to pick them up. (Probably going with the autoloot option).
The next feature I plan to work on after that, is some kind of Map Editor. If I want this thing to be a real engine, the user needs a way to create their own maps with their own textures.
And that means it will probably take a long time until the next update.
Future Step:
I would really like the InventorySlot table in the database to, instead of pointing to an item’s ID, point to a unique PlayerItem. But that would cause the database to have potentially millions of records. Just imagine:
Actually, 1000 Players, each with 100 Itens, and those items being exactly the same, the Database Table Item would only have 100 records, but if each item is unique, then it will have 100,000 records.
So I'm planning to use a non relational database Table to handle this, and just point to its ID inside of the InventorySlot.
Thank you for reading again, I'll be even more thankful if you could give me some advice to accomplish that journey.
Thanks again,
Zotesso
Discussion