Skip to content

Targeting

chimericchimeric Member Posts: 1,163
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.

Comments

  • ArdanisArdanis Member Posts: 1,736
    While Heard() indeed only checks once, LastHeardBy() stays indefinitely. So you can have something like
    IF
      Heard([ANYONE],10)
    THEN
      RESPONSE #100
        SetGlobal("i_heard_someone","locals",1)
    END
    
    IF
      Global("i_heard_someone","locals",1)
    THEN
      RESPONSE #100
        Spell(LastHeardBy(),WIZARD_CONFUSION)
    END
    
    IF
      Global("i_heard_someone","locals",1)
    THEN
      RESPONSE #100
        Spell(LastHeardBy(),WIZARD_MAGIC_MISSILE)
    END
  • chimericchimeric Member Posts: 1,163
    Well, I'm going to try this. I think I had something similar and it didn't work, but there might have been differences.
  • chimericchimeric Member Posts: 1,163
    edited October 2016
    Yes! It works! Thank you, Ardanis. This is the test script I wrote for Tarnesh, who's volunteered to assist me.

    IF Global("C&CWHITE","GLOBAL",1) // The general Global switch, disable elsewhere to stop the behavior Heard([ANYONE],10) THEN RESPONSE #100 SetGlobal("BLAST_TARGET","LOCALS",1) Spell(LastHeardBy(Myself),WIZARD_HORROR) END IF Global("C&CWHITE","GLOBAL",1) CheckSpellState(LastHeardBy(Myself),C&C_WHITE_MARK) // A proviso for multiple shout IDs !StateCheck(LastHeardBy(Myself),STATE_INVISIBLE) // Playing by the ear, but this solves the invisibility problem Global("BLAST_TARGET","LOCALS",1) THEN RESPONSE #100 Spell(LastHeardBy(Myself),WIZARD_MAGIC_MISSILE) END

    Ta-da!
Sign In or Register to comment.