Jump to content


Anybody want to take up this mechanic for Chain Lightning?

  • Please log in to reply
6 replies to this topic

#1 temnix

  • Member
  • 983 posts

Posted 17 March 2017 - 09:43 AM

As I work on illusions, other ideas come to my mind. This one is about Chain Lightning. I put together a test version, and it works, but anyone who wants to sit down and develop it is welcome. The Player's Handbook version of Chain Lightning does what we expect of that fantasy spell: it strikes a target of choice, then arcs to the nearest creature, even if it's the caster or one of his allies, at half strength, then jumps to the next target at one-quarter, and so on. The details from the description: 1) every creature can only be struck once; 2) the charge moves on even if it killed the current target (it doesn't say so explicitly in the description, but it's assumed); 3) if a struck creature is immune to the damage, it still passes on the bolt, 4) if the next available target is outside of the spell's range, the rest of the charge fizzles, 5) maximum damage is 12d6 at 12th level - just one level above the 11th when Chain Lightning becomes available. So implementation only needs to make versions for caster levels 11 and 12.


Details aside, this jumping mechanic is what Chain Lightning is all about. The version in the IE games simply does electrical damage to all enemies in an area. A sort of electrical Fireball, and selective, too.


I thought about how a creature struck by the spell can be forced to pass on the charge. I quickly realized there is no projectile or settings for that kind of effect, but creatures can be scripted to pass on the charge, if only it wouldn't ruin their AI.


So I turned to the trick I've written about before, AREA-tier scripts for creatures. Since creature AI has nothing in that slot - except something like two guards at the Copper Coronet, who have something there by accident - we can safely put any script we want there, still giving precedence to the OVERRIDE script, if any. Then we can put a blank script in that spot, either with a delayed application of opcode 82 or with a scripted AI change. The version I have uses the latter.


Here are the files. The spell only does 1d6 damage now, for testing. No scaling for levels, save for half etc. This is how it works:


CHLI11_# is the starting 6th level spell. It puts a spell state on the struck creature. Anything unlikely would do, in this case it's GASEOUS FORM. The spell also changes the AREA script of the creature to the following, CHLI1_#, and lastly it does electrical damage delayed by 1 second - so it's inflicted only after the creature has passed on the baton.


The script:


		ReallyForceSpellRES("CHLIX_#",LastSeenBy(Myself)) // No-level, no-name Chain Lightning version

The script would have to be changed, of course, so the spell to be passed on is a half-strength version of the one received, but it's just a matter of making more spells/scripts on this template, one inside the other. Like a Matryoshka.


CHLI0_# is an empty script.


In testing, the bolt isn't quite instantaneous in going around, but it is fast, and even Tutors with 1 hit point pass on the lightning before dying from it.


Anyone who wants to develop and publish this is welcome, just give me credit for the idea.


Attached File  Chain_Lightning_Prototype.rar   885bytes   25 downloads

#2 Galactygon


    Modding since 2002

  • Member
  • 937 posts

Posted 17 March 2017 - 12:53 PM

You should check out how IWDEE has implemented Chain Lightning. It works similar to the ADnD version. It involves setting a SPLSTATE.ids state CHAIN_LIGHTNING for each affected creature and then selectively target subsequent projectile "jumps"/"explosions" to target a single nearby creature who does not have the SPLSTATE state CHAIN_LIGHTNING set.


Projectile explosions can selectively target creatures (or even just one creature) who do not have a certain SPLSTATE set.

Edited by Galactygon, 17 March 2017 - 12:55 PM.

Posted Image

#3 temnix

  • Member
  • 983 posts

Posted 20 March 2017 - 12:57 PM

Well, it's good to hear there are implementations of it. And I didn't know that about projectile properties. I don't remember such a line there - "unless in a state". And how does the projectile behave with regard to damage? I mean, every jump has to be half strength of the previous one.

#4 Galactygon


    Modding since 2002

  • Member
  • 937 posts

Posted 20 March 2017 - 01:29 PM

The initial spell inflicts 12d6 damage and sets the "CHAIN_LIGHTNING" spellstate for 1 round. Then, another spell is cast onto the creature one level lower inflicting 11d6 points of damage (and sets the "CHAIN_LIGHTNING" state for 1 round). This spell is nameless (you do not see it in the combat log) and uses a projectile which hits one random creature who is not already under the "CHAIN_LIGHTNING" splstate. The nameless spell then keeps on recasting itself, each time one level lower until it reaches the end (1d6 points of damage) or until the projectile runs out of creatures to affect (everyone nearby has been hit and have "CHAIN_LIGHTNING" splstate set).
Posted Image

#5 temnix

  • Member
  • 983 posts

Posted 20 March 2017 - 04:59 PM

Yes, that's not by the book as far as the amount of damage is concerned. Less 1d6 with every jump. I was wrong thinking it ought to do half. Probably mixed it up with the version in Heroes of Might&Magic. But where is all that selective targeting business in the projectile mechanics? I know a random-target option there, but nothing about choosing spell states. Of course, if it's there and that's how they did it, then it's better than my version.


It's not opcode 232, is it? Cast spell on condition? That one can be used to cast one at someone who is in a particular state, but there is no option for NOT in a state. That's why I had to go through the AI.

Edited by temnix, 20 March 2017 - 05:01 PM.

#6 -kjeron-

  • Guest

Posted 20 March 2017 - 07:25 PM

In the Projectile File, only for Area Affect Projectiles:

Fields 0x3c/0x3e: Targeting 1.  Only used if non-zero.

Fields 0x40/0x42: Targeting 2.  Only used if non-zero.

Field 0x2c: Extended Flags, Bit 30: Use SPLPROT check.  Default is IDS check.

" " Bit 25: Exclude NOT Targets 1, Default is Exclude Targets 1.

" " Bit 26: Exclude NOT Targets 2, Default is Exclude Targets 2.

" " Bit 27: Targeting 1 AND 2.   Default is Targeting 1 OR 2.


Bit 25 = Target must match Targeting 1 or not match Targeting 2.

Bit 26 = Target must match Targeting 2 or not match Targeting 1.

Bit 27 = Exclude targets matching Targeting 1 and 2.

Bit 25&26 = Target must match Targeting 1 and/or 2.

Bit 25&27 = Target must match Targeting 1 but not 2.

Bit 26&27 = Target must match Targeting 2 but not 1.

Bit 25,26,&27 = Target must match Targeting 1 and 2.

#7 temnix

  • Member
  • 983 posts

Posted 21 March 2017 - 06:39 AM

So that's what "IWD check" stands for.