Aller au contenu

Photo

Getting Enemy to Investigate


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
rjshae

rjshae
  • Members
  • 4 485 messages

I have an encounter where the spawn points are out of the line of sight of the player, and I then want the spawned creatures to move toward the party. A relatively simple way to do this is to take advantage of the "LastSeenOrHeard" object variable. I set the following script as the spawned creature's "SpawnScript" variable and add a local string variable on the creatures called "investigate" that contains a tag. (For example, a WayPoint tag.) The script looks for the nearest instance of that tag and sets the spawned creatures in motion toward that position.

/*
    Obtain a tag variable from the subject called "investigate" and use
    it to set the "LastSeenOrHeard" object. This should cause the subject
    to move to investigate the location of the nearest object with that
    tag.
*/

#include "hench_i0_ai"

void main()
{
  object oPC = GetFirstPC();
  string sInv = GetLocalString( OBJECT_SELF, "investigate" );
  if ( GetStringLength( sInv ) ) {
    object oInv = GetNearestObjectByTag( sInv );
    if ( GetIsObjectValid( oInv ) ) {
      SetEnemyLocation( oInv );
    }
  }
}

Anyway, it's a simple trick that seems to work. Once the spawned creatures begin combat the action is cleared.


  • andysks aime ceci

#2
PJ156

PJ156
  • Members
  • 2 982 messages

That's useful and deceptively simple,

 

Thanks for sharing it.

 

PJ



#3
andysks

andysks
  • Members
  • 1 645 messages

With some tweaking it could also be used in combat to call reinforcements, or maybe spawn monsters nearby which will hear the battle and move to investigate/aid? I find many uses :).