[General] Custom Chain Lightning

Status
Not open for further replies.
Level 1
Joined
Apr 15, 2022
Messages
1
Hi, is it possible to add additional functionality to the default chain lightning spell without making it entirely custom? I want the spell to be normal chain lightning but it deals aoe damage around any units it hits a few seconds after it hits. My thought was maybe if I add a buff and a duration it'll apply it to the units hit and then when I can check when the buff expires and deal aoe. That doesn't work (probably obvious to most reading this) but is there any other way to check if a unit is damaged by chain lightning, even if it isn't the primary target?

And if it does need to be entirely custom I definitely wouldn't mind a simple rundown or link to a guide for it :)
 
Level 41
Joined
Feb 27, 2007
Messages
5,234
Essentially, no. For most spells the effects are hardcoded and you can't just give it a buff and hope that does something. You have, as I see it, 3 options:
  1. Use one of these old resources, presuming they can be sufficiently modified to do the delayed damage part you need. They're quite old, though, so YMMV. There may be others, but this is what I was able to uncover using Chain as a search keyword in the resources section; code snippets or example maps may exist in the main help forums.

  2. Build your own chain spell from scratch. There may be tutorials or you could use a resource as a template for your own purposes.

  3. Implement a Damage Detection System (there are many you could use but the one I know to recommend is Damage Engine 5.9.0.0) so you can detect when a unit is damaged by the chain lightning spell. Knowing what specific thing (rather than just which unit) caused the detected damage is still usually a big problem, but you can get around that in a clever way:

    Turn your hero Chain Lightning spell into a dummy spell (base it on Channel, there should be a tutorial for how to configure Channel somewhere) that does nothing when cast. When this spell is cast, create an invisible dummy caster for the owner of the triggering unit, give it the actual chain lightning spell you want to cast, set its level appropriately, tell it to cast on the same target, and give it a short expiration timer. In another trigger that runs when the DDS detects damage, check the level of the actual chain lightning spell for the source of that damage; if it's > 0 then the damage dealt was done by the chain lightning cast.

    From here you now just need to do the echoed damage on any units that get this far in the DDS trigger. You could code this in with some timers (please don't think to use Waits, it won't work the way you want it to) and global arrays to keep track of the targets... but that might be a little complex to make it work properly for multiple units simultaneously and not break. Also my good friend @Kyrbi0 would be disappointed if I didn't suggest that there might be an Object Editor solution:

    I looked through the World Editor and wasn't able to identify any default spells that deal AoE damage after a duration, but there might be one that I didn't see or think about. The closest is Acid Bomb and it almost can do that by setting the damage tick interval and duration properly... but it will always deal a tick of the DoT immediately when the ability lands (and every damage interval thereafter) so it can't really be used for delayed damage. You could simulated delayed damage by giving the custom Acid Bomb ability a 5s cast time, max range, and max projectile speed but this would still fail if the target unit is no longer visible when the cast goes off or dies while the cast is in progress. To resolve those issues you'd need to constantly move the dummy unit to the position of the target unit without interrupting the cast order (something you can do with JASS but not GUI) and at that point you are back to needing timers and arrays to keep track of it all.

    Another possible solution still using Acid Bomb and a DDS would be to prevent the damage dealt by the Chain Lightning spell (something you can do with the appropriate steps in pretty much any DDS), so that you are effectively only using Chain Lightning for its target selection, art, and slightly delayed jumps. Then you again give a dummy unit an Acid Bomb spell (with no cast time) and dynamically adjust the damage dealt by that spell (triggers can arbitrarily set ability fields on the fly now, which is cool) based on how many times the CL has jumped (if you want jumps to do reduced damage). This Acid Bomb's damage interval should be the duration until the AoE aftershock. Because Acid Bomb has primary and secondary damage you could make the AoE deal more/less damage than the jump damage was, but the main target of the AB will always take the same damage as the jump dealt.

    I think Frost Nova has the same issues with visibility/line-of-sight that Acid Bomb has, though it has no projectile travel time which is a plus. It would briefly change the color of affected units when it goes off, though. The various mine/explosion abilities could be cast by a dummy on the location of the target or be automatically cast when the dummy unit dies... but you still have to make sure they're constantly moving to the position of the affected unit which requires the same sort of trigger we're trying to avoid (giving them max speed and telling them to follow the targeted unit isn't a good solution, but if you don't care if it's sloppy this could work for you).
Other questions to consider that will affect the solution: If an affected unit dies between being hit and when the AoE goes off, should the AoE still happen on its corpse or should it fizzle? Should units take damage from multiple AoEs if they overlap?

There should also be a resource/tutorial/thread somewhere around here that explains how to make an invisible dummy unit that can cast instantly. Normally there is a small delay between order and cast because the unit tries to turn to face its target, and in such cases you can't use a single dummy unit to cast on, for example, an entire group of units at once with a trigger.
 
Last edited:
Status
Not open for further replies.
Top