I'm writing a creature script along the usual lines of MAGE.BCS etc., with spells that are to be cast. The difference is that my script responds to Heard([ANYONE],10) - 10 is a Global Shout. This is passed to LastHeardBy(Myself) as the target for the spells on the list. Now, targeting by sound rather than sight works and relieves me of looking for Nearest, SecondNearest and so on in a crowd. However, Heard only applies during the current script run (round). The next time the script is run the creature needs to hear the shout again to cast more spells. I, however, want it to continue hurling magic at the same target, even though there is no more shouting (only screaming, I suppose). So how do I fix the creature's sights for the following script rounds?
I had an idea: go with LastHeardBy for the first time, and in later script rounds with LastTargetedBy(Myself). But the latter either only works in the same script round as well or it's the Horror spell cast first that trips me up here, because Horror doesn't target anybody, it's an area effect. So if the creature is freshly summoned - no previous targets - and Horror is the first spell due for casting, no object goes inside LastTargetedBy(Myself) for later spells to hang off. The only way to get something as an object here appears to be to place a Living actor-targeted spell first on the list, like Magic Missile, Chromatic Orb or something of that sort. Yet I can't assume that the creature is going to have those spells memorized - it's a generic control script. Besides, casting area effects like Horror or Confusion first should work better, they are superior battle-winning tactics than anything cast at one creature.
Any ideas about how to stick a target inside here, if areas go first? Cast the spells at the location of the Heard object instead? Can somebody give me a code example?
This mod should really be a departure from everything else done for the games so far. I have a way to control any creature without ruining its AI. But I need actual smart scripts, and I have next to no experience with the AI part of modding... It's your chance to get your name in the credits.