I have a love triangle of creatures. One is a party member with a special ability to command an NPC. Another is a blue-circle NPC. The third creature is an enemy attacking the party member. The problem: what command should the party member cry to the NPC so that the NPC distracts the enemy and leads it away from the party member?
Let's first look at this last bit, how the NPC can get the enemy to stop its current attack and focus on itself instead. The NPC can issue an ActionOverride to LastAttackerOf(the party member) to Attack a new target. This command will have approximately this form in the script of the NPC:
ActionOverride(LastAtttackerOf(the party member),Attack(the NPC))
There are two non-obvious objects here. One question is how to get the party member inside the first pair of parentheses, i.e. how to select the LastAttackerOf who to manipulate? I can tell you the answer to that one: I use shouts, global shouts actually, and the party member issues the original command by shouting a number, let's say 15. There is a further mechanism for getting the party member to shout, but never mind that, let's say we got him to shout 15. Then the code for the NPC will be
IF
Heard([ANYONE],15)
THEN
RESPONSE #100
ActionOverride(LastAttackerOf(LastHeardBy(),Attack(the NPC))
I'm reasonably certain that this will work - it is only a slightly more complicated form of the communication system I use already. We have found the enemy. But we have yet to find a way to tell the enemy who to attack. And this is what I need help with from script-savvy people. You see, at this point the action of the script, having passed through a couple of places, returns to the author of the ActionOverride. But its identity is by now effaced: we can't use Myself, because inside an ActionOverride Myself refers to the controlled creature. So how do we make the NPC known to the enemy?
I have an idea to make the NPC shout another number and then go with
ActionOverride(LastAttackerOf(LastHeardBy(),Attack(LastHeardBy()))
But I would have to differentiate the two shouts somehow, and I can't do it in the middle of the action. Perhaps I can use GiveOrder or Trigger instead? But I'm not familiar with those.
Edited by temnix, 18 November 2016 - 04:15 PM.