I want monsters to attack the creature that cast a particular spell I'm making on them. I'm doing it through temporary AI swapping, from effects, and the BCS I choose the monsters to have is super-short: figure out who cast the spell on them, then Attack(). The first part is giving me trouble. There is a SpellCastOnMe trick I could use, but I can't put the spell's name into that one as a string, only its designation from SPELL.IDS. I don't know how to work with SPELL.IDS yet and I would rather avoid it as much as I can, for compatibility and to keep the mod light on its feet. So, is there another trigger that could direct the creature to attack the character who cast that spell on it? Or maybe just the last spell cast on it, because it's going to be the same thing.

How to have a SpellCastOnMe-type trigger?
#1
Posted 23 July 2016 - 01:08 AM
#2
Posted 23 July 2016 - 01:06 PM
I want monsters to attack the creature that cast a particular spell I'm making on them. I'm doing it through temporary AI swapping, from effects, and the BCS I choose the monsters to have is super-short: figure out who cast the spell on them, then Attack(). The first part is giving me trouble. There is a SpellCastOnMe trick I could use, but I can't put the spell's name into that one as a string, only its designation from SPELL.IDS. I don't know how to work with SPELL.IDS yet and I would rather avoid it as much as I can, for compatibility and to keep the mod light on its feet. So, is there another trigger that could direct the creature to attack the character who cast that spell on it? Or maybe just the last spell cast on it, because it's going to be the same thing.
SpellCastOnMeRES("filename",Caster) where you put the spl filename in the quotes and use whatever identification you want for your purpose from object.ids to specify the caster.
#3
Posted 23 July 2016 - 06:02 PM
Yes, but how do I identify the caster? That's the question. It's good that I don't have to use SPELL.IDS this way, thank you, but... Wait. I see. There is no general way to do this, but I can go through the whole party, Player1 through Player 6. Nice!
#4
Posted 24 July 2016 - 03:39 AM
Actual stuff: Almateria's Restoration Project | Icewind Dale 2 Fixpack + Restorations
Skips: Hell Recollection | Fake Import Mod
Assorted tweaks from when I was 14: Alma Tweaks (macOS)
#5
Posted 24 July 2016 - 04:09 AM
"Caster" can be any supported object specifier. Use [ANYONE] if the caster can be any creature. Use [PC] if you want to restrict it to party members only. Use [GOODCUTOFF] if you want to restrict it to party members and their allies (which includes familiars and controlled creatures).
Imagination is more important than knowledge. Knowledge is limited; imagination encircles the world. - Albert Einstein
My contributions:
#6
Posted 24 July 2016 - 04:26 AM
IF SpellCastOnMeRES("MYSPELL",Nearest) THEN RESPONSE #100 AttackOneRound(Nearest) END IF SpellCastOnMeRES("MYSPELL",SecondNearest) THEN RESPONSE #100 AttackOneRound(SecondNearest) END // and so on ... IF SpellCastOnMeRES("MYSPELL",TenthNearest) THEN RESPONSE #100 AttackOneRound(TenthNearest) END
I would also include Player1-Player6 in the list for good measure.
Note that if you change the script of a creature via opcode 82 then the script does not change back automatically. There are some workarounds for that:
(1) Patch most AI scripts such as WTASIGHT in the game with the aforementioned script blocks which can be invasive when mods such as SCS are concerned.
(2) Have both the caster and the target summon an invisible/invulnerable .cre with custom GENERAL/RACE/CLASS/GENDER/SPECIFIC IDS values with a new IDS name such as TAUNT. You could then run the following script for the target's summoned .cre:
IF True() THEN RESPONSE #100 ActionOverride(LastSummonerOf(Myself),AttackOneRound(LastSummonerOf([0.0.TAUNT]))) ActionOverride([0.0.TAUNT],DestroySelf()) DestroySelf() ENDThe above script block is experimental you have to try and see if it works ingame. But it is a noninvasive method that does not touch existing scripts or require extensive patching apart from making sure that your new IDS values are not used by any other creature.
Edited by Galactygon, 24 July 2016 - 04:28 AM.
#7
Posted 24 July 2016 - 11:34 AM
Hmm, this is getting complicated. I'm only learning the tools. I think your first script, Galactygon, is what I need. That way I can make the Taunt spell useful to monsters as well - unlike if I just restrict it to Player1-Player6. But for Argent77's suggestion - can I really use Anyone? It's a bit emarassing to ask, but is there a list of all the different objects I can put in somewhere? I haven't found on in Gibberlings 3's guide...
If Anyone works, that would just be perfect. About the script not switching the AI back. You mean, it doesn't return the creature to its usual script - not even if I make Taunt a limited duration spell? Well, how about doing it through the Taunt script itself? I can put a Wait(x) in the end and then just put ChangeAIScript(Myself,DEFAULT)? Which, being the last action, should end this script, and after that the creature would have its default script back. Would that work? Or I could include a delayed spell effect that sets the creature script to default. So basically one AI changer at the start and another to end.
I'll test these things tomorrow...
By the way, is Attack() going to make the creature pursue and ignore distractions, if that's all there is in the script? Single-minded is how I want them to be.
#8
Posted 24 July 2016 - 01:21 PM
Well, I got Bentley Mirrorshade to chase Edwin around the Friendly Arm Inn's hall with a knife, but he won't relent after the first 10 seconds... I've got to find a way to set the script back, or use something like Galactygon's complicated suggestion.
How about this: the taunt does 0 points of some kind of damage to the target, save negates. (If it's impossible to do 0 damage, I'll have it do 1 damage with a save and then heal 1 damage, no save). The save will actually work as the save vs. taunt, because if the target resists the damage, nothing happens. At the same time I will summon an invisible creature and make it do
ActionOverride(HitBy(LastSummonerOf(Myself)),STUNNING),Attack(LastSummonerOf(Myself)))
The parentheses probably aren't right, and I really need the list of valid objects...
Also I need to make the target attack the caster for a set length of time. One round isn't enough, just Attack() is permanent. Maybe have the creature spur the target to action every few seconds? That would be AttackOneRound repeated, wouldn't it.
Maybe this - Nearest etc. check for SpellCastOnMe, then ActionOverride to LastSummonerOfMyself?
Edited by temnix, 24 July 2016 - 02:17 PM.
#9
Posted 25 July 2016 - 05:57 PM
Okay, about variables... I'm getting confused here. What the Planescape version of Taunt, Litany of Curses, does is set a local variable on the taunted creature. I don't know what for, because the main action is through a basic AI change, like I planned to do in the beginning. In that game creatures don't have complex fighting behaviors and only Morte can cast Litany of Curses anyway, so they didn't need to bother with restoring the target's AI. But I do. I have Galactygon's idea with two creatures to check out if nothing else works, but that's a last resort (and a little lonely).
So my plan for now is this. The spell that the wizard is going to cast will be just a marker spell - it will fire off a little FX on the target, indicating an attempt at taunting, more importantly the actual save vs. spells will be against an EFF that sets a local variable on the creature if it fails. And maybe I'm not doing this right, but what I need is to tell the game: this particular creature failed the save, so now mark it and make it stand out.
At the same time as the marker spell goes off I'm going to summon an invisible creature and make it check Nearest, SecondNearest and so on for the creature with that variable. When it finds it, I'll tell it to ActionOverride that creature, now identified as taunted, and make it attack LastSummonerOf(Myself) for 18 seconds, which is what I expect the spell's duration to be. The invisible creature will also apply pulsing, an increased movement rate and so on. Or I could do it through the marker spell, I suppose. The important thing is to hang some kind of marker on the target, if it fails the save, so that the creature knows who to control with its ActionOverride.
Any ideas?
Well, the second invisible creature might be the marker...
Edited by temnix, 25 July 2016 - 06:01 PM.