Aller au contenu

Photo

Force a creature to re-perceive a target?


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

#1
Dann-J

Dann-J
  • Members
  • 3 161 messages
Is it possible to clear a creature's perception list to force it to re-perceive a target that has already been perceived but not moved out of range? Or can I force it to consider something already perceived as if it has vanished and reappeared?

I need this to polish my AI scripts of aquatic-only creatures. Their OnPerceived script ignores any perceived target above their set water level, but I want them to re-perceive a player if they step into the water.

#2
Boozehound Blue

Boozehound Blue
  • Members
  • 64 messages
Can a trigger in the water fire a user defined event on the creature? And/or spawn a guppy or such in front of the creature at some point to clear the way to 're-perceive'? Or have a fishy silently shout, "He's gone!" or "Oh Noes! He's back!"?

#3
Shallina

Shallina
  • Members
  • 1 011 messages
Use the on heart bat event and check the distance between the 2 objects you want to check as percieved.



If the distance is short enought, lauch the regular action wich is most of the time a script.

#4
Olblach

Olblach
  • Members
  • 175 messages
I'm using a perception script for guards and it works over time

It starts like this:

void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF); 
    if (GetIsObjectValid(oPC) && GetObjectSeen(oPC)) { 
...
 

Not sure about water level though.

Modifié par Olblach, 15 octobre 2010 - 08:36 .


#5
Morbane

Morbane
  • Members
  • 1 883 messages
Are the underwater creatures ignoring players that enter the water to start with?
I would think the default perception scripts would fire when the player entered the creatures domain / area...

I dont think there is any way to perceive only the player's feet for example - they need to be all the way in the area to be perceived afaik.

Modifié par Morbane, 15 octobre 2010 - 12:41 .


#6
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
As Boozehound Blue suggested a trigger might be the way to go and bypass the need for a perception check all together. Have the trigger surround the "be hostile zone." OnEnter of the trigger - change factions of fish to hostile vs. PC and begin combat. OnExit - Clear All (Combat) Actions and change fish faction to Neutral vs. PC.



Seems the simplest solution to me...

#7
Dann-J

Dann-J
  • Members
  • 3 161 messages
All good suggestions, but not quite what I had in mind.



My aquatic creatures (lets call them 'sharks') have a neutral faction most of the time (so NPCs don't rush into the water to attack them, or shoot at them) and only become hostile if:



- The perceived creature is seen.

- The perceived creature is not 'Neutral' or 'Hostile' (so they attack party members, commoners, merchants, but never each other). The gods bless those faction pigs... :)

- The perceived creature is lower than the 'WaterLevel' variable they each have, which is the paint height of the water in that given area.



It seems that each creature maintains a list of perception targets that enter their range, so the OnPerceived script doesn't fire again unless those creatures leave their perception range and come back (or duck behind architecture). This means that if a 'shark' is close to the edge of the water, it can perceive a creature and initially ignore it (it's above water level), but if that creature enters the water and becomes a valid target, the OnPerceived script won't refire, so they continue to remain neutral (unless you damage them).



I'm trying to avoid having to use too many triggers. I've already got 'HighAndDry' triggers around the waters edge, which turns the fish around (with a splash effect) to prevent it from leaving the water, with a fallback routine in their heartbeat script that checks their height relative to their WaterLevel variable. It seems that sometimes triggers fail, and creatures that should have legitimately fired off the script manage to avoid it. Before I put the fall-back routine in their heartbeat, they sometimes managed to swim up ramps and float in the air. I'm loath to trust OnEnter or OnExit.



I've been mining the default scripts in the game, and have found that many of the perception/target-related scripts seem to set local objects on creatures, and then delete them on occasions. For instance, the hench_io_generic defines sHenchLastTarget and sHenchLastTargetLocation, which the default OnPerceived script sets/deletes as a local object on creatures. I've found other scripts that also set or delete local objects, but so far clearing them in the heartbeat script has had no effect.



I was hoping someone knew how the game clears a perception target when they disappear, and therefore how to force the fish to re-perceive everything by clearing their list of perceived creatures in their heartbeat script. If you could change a creature's viewing angle so it couldn't perceive anything above it, that would work too.

#8
Dann-J

Dann-J
  • Members
  • 3 161 messages
...and I've just had a thought. I wonder if making the fish temporarily blind for less than a second in their hearbeat script would force them to re-perceive things when their sight is restored? Or do blindness effects only impact combat situations where one creature is alread hostile?



I'll also see if there's a way to reset their perception range temporarily (from a normal distance to close, or to none at all).



I've got some experimenting to do...

#9
Olblach

Olblach
  • Members
  • 175 messages
As a quick fix you could make an invisible creature that moves from one waypoint to another. Players wouldn't see it but it would be enough to make tbe perception script fire again. Or just make the shark move.

It's good you posted this, you made me discover that my guard script doesn't fire again when the player stands still :P

So I'm on the boat with you now... I'm going to look into some AI scripts to see if I can find inspiration..probably a heartbeat/DelayCommand like suggested would do.

Ok..this is from a NWN1 script (Jasperre AI) but I think it's still valid for NWN2

   It fires:

    - When a creature enters it perception range (Set in creature properties) and
      is seen or heard.
    - When a creature uses invisiblity/leaves the area in the creatures perception
      range
    - When a creature appears suddenly, already in the perception range (not
      the other way round, normally)
    - When a creature moves out of the creatures perception range, and therefore
      becomes unseen.

So the perception fires when the PC appears and disappears then it needs to fire a DelayCommand(ed) script that would do the checks when the PC appears and stop it when the PC disappears.
Or set a flag on the PC "SEEN_BY_SHARK" and have the heartbeat of the area do the appropriate checks when the flag is set.

Since the check routine can perform GetObjectSeen() it can stop by itself too.

Modifié par Olblach, 16 octobre 2010 - 06:53 .


#10
Guest_ElfinMad_*

Guest_ElfinMad_*
  • Guests
I think a lot of the perception stuff, ie whether a creature is actually seen or heard, and the firing of the event, is hardcoded.

One option is to have a user defined event script that catches the perceived, heartbeat, damaged and any other event where you want the fish to possibly go hostile and attack. Put the checks in place to determine the PC position and the fish's response in this script. This is the simplest approach I can think of as it would require a single script to be written.

Messing around with effects to accomplish this sounds too complex an messy IMO.

#11
Dann-J

Dann-J
  • Members
  • 3 161 messages
It turns out that one of my own suggestions actually works (I'm as shocked as anyone).



Making the fish temporarily blind for an instant in the hearbeat script causes it to re-perceive anything in range. It turns out that all I had to do was make a creature with no eyelids blink. :)



Now my ravenous hoards of the deep attack within six seconds or less of you entering their watery domain.