Alright, So normally I wouldn't make a topic for something as mundane as a spell, But I think this one is unique to anything anyone else has done with scripts so far.
Anyway. I have created a witch spell known as "Domino" which is totally original and definitely not in any way stolen from Dishonored 2.
To work the spell, You must select it and cast it towards multiple targets. Once you do, Their health bars will become linked. This means that any damage done to one enemy will be translated to all other enemies linked to them.
This is proportionate to the HP of each mob. So dealing 1 damage to a mob with 10 max HP will deal 10 damage to a mob with 100 HP that is linked to it.
It also should
be multiplayer compatible in theory. But scripts that should work fine for multiplayer in theory don't always do so well in practice.
Anyways, On to the script.
Ignore the Essencia, Karma, And Cooldown stuff. That's just specific to how I do my spells. Really, The only parts relevant to the script are the var line and script line.
This is the meat of the script, The loop.
This runs on all targeted entities until they die.
The first section of the script queries whether or not the entity running the script is dead. If so, It changes the global HP history value to 0 (Necessary because if I did not do this, A mob dying would not kill the other mobs.) Then it exits the script instance.
The next line changes the var for the percentage of max HP from the last iteration of the loop to the old percentage of max HP. After that it calculates the current percentage of max HP then removes anything after the decimal to make it a whole number.
I am not entirely sure if this last step is necessary, But it is possible to have a non whole percentage and that would probably mess with the next part.
The last portion of the script is what puts it all together.
First it checks to see if there has been any change in HP since the last iteration of the loop. If there has, It will set the global caster history to the caster ID determined in the previous script. Then it will set the global HP history to the HP percentage value.
If there has been no change in HP then it checks if the HP percentage matches the HP history, And if the caster ID of this instance of the script is the same as the caster history.
If so then it does some fancy math talk that just means "Set my HP to Domino\HP%"
Then it loops.
There are still some problems I need to fix. One being that this does not handle regenerating entities well. I need to find a way around that. Currently what happens is that the nonregenerative entity basically becomes immortal because the regenerating entity's HP is dominant due to it updating faster.
I am not sure what would happen if you linked two regenerating players together, But I suspect they may become gods.
It would only be possible to kill them if you attacked them both at the same time.
Another slight issue is that despawning does not register to the script as having 0% HP. But I think IsMobCount is an easy fix for that.
I hope that after seeing this, Craig may add some official networking commands and conditionals to PC. The TM script engine is not meant for this. I had to do kind of a hacky solution to make this work to any extent.
It is fantastic though IMO. Killing 20 goblins in one sword swing is sooooo satisfying.