Devlog Update 2.8: Magic System 2, Electric Boogaloo


 Hey All!

It's ya boi, Bad-Code 101 here, back at it again with another calamity of code -- or at least, a patch to unbreak some janky stuff from last time.

As I'm sure you remember, I finished my last blog post with a picture of a "Switch On Enum" blueprint -- which I was thoroughly roasted for by my lead programmer.


Actually, after he read the blog post and proofread the blueprint, he roasted my code and told me to do better.  Humiliated and sad, I crawled back into the shoebox under my desk and cried for a few days started formulating a better structure. 

Introducing the Modular Magic Masterwork, or "MMM" for short.  The core concept driving MMM is external variable control through a Data Table holding all information linked to each spell. This includes, but isn't limited to the UI display texture displayed in the skill tree & hot bar, the actor class spawned in when the spell is cast, the cost of casting, and the type of spell the player cast (Circle, Projectile, or Barrier).

Attached below are images of the structure used in the table, and the table itself.

The table below uses this structure for each row. This structure holds all the information relevant to each spell in Sigil

This image shows the table of all magic spells currently in the game -- notice the Disp_Name and Disp_Desc, responsible for holding the text shown to the user in the skill tree.

Storing the data in a magic bucket is one thing, but how do we get it back out?

Why we read from it like a normal table of course.


This code-node pulls all information for each spell out of the table so we can make use of it.Once we've pulled the information we need from the table, we can go about casting or spawning the spell properly. Note how some variables aren't used in the above picture? They're not important for casting the magic to the world, but for displaying the spell's information in the skill tree.

The casting process is fairly similar to my previous version:

  1. Check if we have mana
    1. If not, cancel spell casting right here -- no freebies in this game.
  2. Determine the spell Type; wall, circle, or projectile, and then set the transform relative to the player based on this information.
  3. Once we know the transform,  spawn in the actor and cast it to the base spell class so we can pass its Damage to it
  4. Tell the player controller the spell's cast was successful so we can start the visual cooldown effect on the UI

The base spell class holds very little information, but means adding spells is as easy as creating a child blueprint, updating the particle effects, and overwriting the UseMagic function, which is responsible for the spell's interactions with the world.

This modular system means that adding a new spell class requires minimal work, and creating sub-classes of the spell (or 'specializations' as Sigil calls them) requires even less; inherit from the spell class and change the graphics.

Overall, the MMM is a smoother, more modular system that stops people from crying when they're told to add a new spell to the game.

Hope you enjoyed the update, 

Lots of DevLove,

T0RCH

Get Sigil

Leave a comment

Log in with itch.io to leave a comment.