I added a lightning spell so now you have a full(-ish) roster of spells to cast.
I know, I know! It's a terrible pun title and you heard it coming a mile away. I couldn't resist.
Electric Charge
In the real world, electrical current is *checks school notes*
excess electrons moving from their negatively charged source atoms to other positively charged atoms via conducting materials whose atomic structures allow free electron movement.
And if that conducting material happens to be part of you, then your meat-flesh will resist some of the current and heat up, causing Owies. 1
But in my game world, modeling electron flow is total overkill,2 so I went with a much simpler model:
- Conducting atoms have a charge.
- Charge reduces over time.
- If you touch a charged atom then you get Owies.
But how does a charged atom transfer charge to atoms around it?
Warning: Video below has a large bright flashing white light.
If that is okay by you, click on the video to start it playing.
Spreading charge between atoms is easy... but potentially seizure-inducing.
Electric Arcs
So I went with a different approach: atoms are charged by manually created electric arcs:
It's totally unrealistic! The arcs even "bounce" off grounded terrain, rather than dissipating!
But, it looks a lot more like the popular conception of how electricity moves, and so it's a win. 3
Naturally, you can get hit by (atoms charged by) an electric arc:
Flashing the character black with white bones when they get zapped would be cool, but I ran out of time for that.
Lightning
There was still no way to actually create electricity outside of the level editor, so it was time to add the lightning spell.
The way I wanted Lightning to work was as a reliable area-damage effect: find all the characters in range, and then lightning should chain (jump) between the characters:
My plan was to then divide the connecting lines between characters into segments and distort them in some jagged way to give an impression of lightning...
But! I realized those distorted lines could end up traveling through terrain4 and look bad.
So now the lightning works more like the Electric Arcs above:
Under the covers, a lightning bolt is made every so often by building up straight line segments with a slightly random angle and some chance to fork into a new bolt.
Each segment of the lightning bolt will also try to jump to nearby enemies to more reliably deal damage, but only the last segment "homes in" on enemies so it still needs a little work. 5
And of course, the lightning spell can create an electric arc when it hits a conducting atom:
Playable web build
Your homework for the week: try playing with Fire + Lightning, Acid (Water + Arcane) + Lightning, etc (press 2 to summon lightning, then left click to cast).
Do the extra elements do what you expect? Does the lightning spell look decent enough? Are the arcs still too seisure inducing? Let me know!
Just remember, keep your conversation.. positive! (I know, I should be grounded for that one.)
Oh also, if you want to play around more, you can manually create electric arcs with the zap tool in the level editor (press F4 then choose the zap tool from the left sidebar).
And, yeah, I know that Shield + Lightning and Shield + Arcane/Life + Lightning aren't doing anything lightning-y yet. You can blame a string of daycare-induced sickness for that.
Also because the current stimulates your nerves to directly make you feel pain, and because your cells get tiny holes in them which leak out the good bits so they die, and apparently also because electrical currents can make you flex your muscles so intensely that you damage your own body?
You learn something new every day.
That is, computationally expensive with little to no gameplay upside.
Plus, all the floating terrain wouldn't be grounded, so I think you wouldn't get hurt by electricity there then?
At least, that's my takeaway from this ridiculously cool video involving high voltage powerlines and a helicopter.
Though I think the arcs are a little too "curvey" still?
There's probably some clever way to calculate how much each segment lightning is allowed to be displaced based on the surrounding terrain (something something raymarching?), but it seemed like a hairy problem to solve so I didn't try that route.
If you have clever thoughts to solve that hairy problem, share them!
Ideally the lightning spell should probably detect enemies that are within a certain distance, and "redirect" the next N segments towards those enemies (rather than only checking if any given segment is close to an enemy).