Jump to content


Photo

Seeing things last


  • Please log in to reply
3 replies to this topic

#1 temnix

temnix
  • Member
  • 983 posts

Posted 18 October 2016 - 05:04 PM

A question to those who have experimented with creature scripts. I have this code:

 

IF

 

Global("C&CWHITE","GLOBAL",0)

See([ANYONE])
CheckSpellState(LastSeenBy(Myself),C&CWHITE)

 

THEN
    

RESPONSE #100
        Attack(LastSeenBy(Myself))

 

END

 

As you can see, this is a vision check in two parts. One is asking whether the creature sees anyone at all. Maybe it looks at them one by one, or perhaps sees them all together. The second part is asking whether, among those it sees, the last one is in that spell state (so I suppose its "gaze" goes from one to the next, after all). Then the command is for it to attack the last creature seen - it says nothing about the spell state here. By this point - by the time we get to commands - we are just using the "anchor" hooked on to the creature from the trigger. The premise is that LastSeenByMyself() in the triggers and in the actions is the same creature. Is that actually so? It should be so, but does the checking in triggers stop after the right creature is found, or does it go on?

 

Example: let's say the scripted creature is surrounded by three hobgoblins, and Hobgoblin 2 is the one in the spell state. If the creature looks no further at finding him and digs into the actions sections for orders, then all is well. But if it keeps looking - because See([ANYONE]) forces it go through ALL those in sight - then it's going to see Hobgoblin 3, and he will be the one signed in the book as LastSeen, so the action, triggered by the spell state of one creature, will actually target another. No? Yes?

 

This is a practical question. I have this script for a creature who I want to attack Kagain in this spell state. So it does. However, when I remove the spell state from him and put it on Edwin (and apply a Feeblemind to make the creature run its scripts anew), it goes back to hacking at the dwarf. Edwin is in sight too, with his brand-new spell state. Might it not be that the creature thinks it's enough that someone nearby is in the spell state and then hits whoever happens to be LastSeen for it? And once it has fixed it sights on this target, it's going to pursue it around the area - there is no reason for it to re-run the script with an infinite Attack(). (Or am I wrong about this?)

 

My first thought when I saw this stubborn behavior was that Kagain's state was never really removed. So I applied another effect that set the Global to 1, a Feeblemind, and the creature obediently calmed down. When I next set the Global to 0 again and again put Edwin in the spell state, the creature did indeed switch to him. This means Kagain's state goes away as intended. But then the above is the only explanation I have.

 

I wanted to use a simple See([ANYONE]) to avoid going through Nearest, SecondNearest and so forth.


Edited by temnix, 18 October 2016 - 05:57 PM.


#2 Fiann of the Silver Hand

Fiann of the Silver Hand
  • Member
  • 286 posts

Posted 18 October 2016 - 06:28 PM

See[Anyone] will always return true if the CRE running the script qualifies (not hidden/invisible).  I don't know what priority that would take over another CRE being seen.



#3 Creepin

Creepin
  • Administrator
  • 1676 posts

Posted 19 October 2016 - 06:07 AM

Have you tried using AttackReevaluate instead of Attack? Or even more clear way to check if your "last seen" is stored correctly - ActionOverride(LastSeenBy(Myself), DisplayStringHead(Myself,xxxxx)).

Edited by Creepin, 19 October 2016 - 06:10 AM.

The Old Gold - v0.2 WIP (mod for BGT/BWP/BWS)


#4 temnix

temnix
  • Member
  • 983 posts

Posted 19 October 2016 - 11:07 AM

That second suggestion is something to try, Creepin. And AttackReevaluate() - yes, I tried it, and I might yet go back to it. The problem, even if I sort out this issue with LastSeen, is that creatures normally have a fairly short visual range. About 20 feet or so. The natural interval for Reevaluate is 90 ticks (6 seconds, every round), which is rather often, and it is easy for creatures to get confused if the target takes a few steps away or the creature itself moves off just a little, which happens all the time during fighting. A straight Attack() fixes its sight solidly on the target. I might include a sight boost in the effects. Token objects might help, except they are a great mystery. If I keep Attack(), I need to come up with some way to make the creature stop running the script without having to hit it with a Feeblemind separately just for that purpose.

 

Hmm, perhaps I should just include Feeblemind in the spell that initiates the attack script to begin with. That way every check for targets will begin with a mind wipe.

 

Fiann, if the creature always sees itself, when it's not invisible (mine isn't), doesn't that mean I can drop See([ANYONE]) altogether? If so, that just leaves CheckSpellState(LastSeenBy(Myself),C&CWHITE), and the look around is just assumed to happen. I suppose, if the creature does go from one neighbor to the next and there is someone in that spell state, it's going to see that one eventually. But the question remains whether the creature is satisfied or keeps looking. If it keeps looking, then the spell state only works as a go-ahead signal to start the actions, not as an identifier.