And another dev. log entry is here! Its a wonder i managed to mark at least one thing from "to do" list i posted last week as workdays were quite bussy, but at least i had time to think about the project during my everyday 4km long hike to work in the morning and did some "theoretical" preparation for implementing the most feared item from to do list.
Loot & inventory system
Thanks to time i had to think whole thing through in advance it was not that complicated(yeah, i know im still noob when it comes to game maker). The whole process from item drop, to equiping and applying item atributes to character goes like this:
Item drop chance:
Each time an enemy is created it perfoms "loot roll" when it randomly picks random number between 1 - 100 to be used upon enemy death. When enemy dies, right before self destructing it self and spawning corpse it compares "loot roll" with assigned loot table. If enemy object finds match it creates corpse, assigned item, tells its spawner its dying to trigger cooldown for spawning his replacement and then it self destructs to save your cpu bit of computing time.
All right, the item has been created, its rarity and type (head/chest/trinket) has been allready decided by its spawner. What happens next? The item checks "item_level" variable, whitch is different for each level. Then the item chose its appereance, rolls its atributes using item_level var. as a guide, tells the light controler to create coloured glow around themselves based on item rarity and periodicaly checks how far away the player is from the item. If player is near enought the item displays its name in desired color(white/green/blue/purple) below the item and above are displayed the atributes.As game is fast and hectic, the decision to pick, or not to pick the item have to be made fast. The item helps player by displaying its attributes in three different colors. In green if the atribute is higher than same atribute in occupied slot. White if they are same, and red it attribute is lower. If this is still not enought player can perform quick check by holding ctrl key and atributes of equiped items ll appear above the item bar in lower right corner of screen.
If player is near enought item ll start flashing "E" icon indicating that player ll pick it if he/she ll press E key. What happens next? Lets say we are picking the helmet, all attributes assigned to the helmet slot are ereased and new values are assigned based on item we just picked up. When values are assigned, item is destroyed.
Note i decided not to spawn item we had equiped before we picked up the new one. This is becouse game is about fast action, not about careful theorycrafting and loot and items are in game as a little enrichment and gameplay is not centered about item drops. However this might change in the future after first wave of public testing if players ll feel it should be that way.
Easy right? And i was so worried about it. Still, i learned another lesson that sometimes its better to think things through in advance instead of hammering code without plan in mind.