Joshua Haberzettl Devlog #5 - Effect Items
Effect Items
For this week I implemented the framework for effect items, as well as two working effect items. We already had simple items that would affect the player's stats in various ways, but the next kind of item we wanted to add was something more substantial -- items that would grant the player some new ability that basically functions as it's own mechanic. After lots and lots of planning, I implemented and got the framework working in a way that should allow effect items to be added relatively simply while keeping interaction with the code of other unrelated sscripts to a minimum.
Effect Items are set up to work through events that are called at various points during gameplay. When such an event would need to be raised (for example upon the death of an enemy), in the script where this would happen, it creates a new ItemVars object. The ItemVars class has all of the variables that an effect item could potentially need in it. In the script when it is created, the relevant variables are assigned, and then an event is raised while passing this ItemVars object through the parameter. From there, there is an Item Manager in the scene itself that receives this event, checks to see what event has transpired (i.e. enemy death, or player dash), and goes through the player's inventory, finding any items that have an effect that triggers upon that event and procing the effect.
Effect Items themselves are a subclass of item that can still change stats, but also have an Effect and Action field. The Action field determines on what event the item's effect would be proc'd, and the effect is a custom script that has the code for the actual effect to happen. Effect Items are stored separately to basic items in the player's inventory so that we only have to iterate through the list of possibly applicable items when an event is raised.
For this initial implementation, I created two working effect items: Corpse Frag, and Fan the Hammer.
Corpse Frag
Corpse frag is an effect item that triggers upon enemy death. When the player kills an enemy, it spawns a ring of bullets (8 total: 4 in the cardinals and 4 in the diagonals) from that enemy's position.
Fan the Hammer
Fan the Hammer triggers its effect when the player finishes a dash. It empties the remainder of the player's bullets in their magazine in a random spread in the direction that they dashed, causing them to reload.
Get Whispering Abyss (2022)
Whispering Abyss (2022)
Top-down Lovecraftian Horror With a Profuseness of Items
More posts
- Matt McL - Dev Log #8 - 6/03/2022Jun 04, 2022
- Paul Harden DevLog #9 - 4/26/22May 19, 2022
- CarlIsaac Nicolas - Devlog #9May 16, 2022
- CarlIsaac Nicolas - Devlog #8May 16, 2022
- CarlIsaac Nicolas - Devlog #7May 16, 2022
- CarlIsaac Nicolas - Devlog #6May 16, 2022
- CarlIsaac Nicolas - Devlog #5May 16, 2022
- CarlIsaac Nicolas - Devlog #4 - 3/8/2022May 16, 2022
Leave a comment
Log in with itch.io to leave a comment.