So here is the scenario:
I have six wandering neutral creatures. The player and cohorts have to sneak through the area without being seen or an event will happen.
I am trying to figure out the best way or most effecient way to put this script together. I have looked at several ways, but haven't been overly thrilled with them. I haven't started any scripting yet, trying to find the best format then I will write the script.
Here are some ideas I've kicked around:
-Have each creature have a unique heart beat that will check near objects (PC and party) and run checks.
-Have a master script on an ipoint that uses a loop to find each party member then check is they are close to a creature and run the checks.
-Or have the master script find the creatures then check for the party members. Or is there even a better way.
With these method I will need to account for a character being near multiple creatures and doing a check with each one, or a creature being near multiple characters and doing a check for each one.
Each of the 6 creatures has a unique tag so they can have individual walkpaths. That way the player can time their advance.
Advice on a Hiding Script
Débuté par
Shaughn78
, mars 12 2011 11:25
#1
Posté 12 mars 2011 - 11:25
#2
Posté 12 mars 2011 - 11:30
OnPerception
#3
Posté 12 mars 2011 - 11:36
The issue I have with on preception is that it will fire only once per party member, but if the character succeeds that check and they hang around within range of the creature it won't continue to fire and they could just shadow the creature.
#4
Posté 12 mars 2011 - 11:47
kamalpoe's right, the on-percep script is the way to go. You can either modify the default or make up your own, depending on how much of the normal AI you want to use.
The game isn't terribly nuanced when it comes to sneaking around though, basically it just does a listen and spot check for every creature within the perception radius every turn. I use triggers to give the PC a hide bonus depending on terrain, but you might try something a bit more complicated, like an area of effect that gives a hide or move silently penalty to creatures near your sentries.
Another trick is to use SetActionMode to turn off stealth mode once the PC has been spotted.
The game isn't terribly nuanced when it comes to sneaking around though, basically it just does a listen and spot check for every creature within the perception radius every turn. I use triggers to give the PC a hide bonus depending on terrain, but you might try something a bit more complicated, like an area of effect that gives a hide or move silently penalty to creatures near your sentries.
Another trick is to use SetActionMode to turn off stealth mode once the PC has been spotted.
#5
Posté 13 mars 2011 - 12:31
Lagaid, I ran a test and the preception will only work when the character runs into the range. I need something to keep firing, that is why I am looking at heartbeats. I plan on throwing out the AI on these creatures as it is part of a non-combat area i am working on. So i will be creating my own checks for spot, listen, invisibilty and stealth and all that other junk.
With my test I was able to shadow the creature for several minutes with no preception firing.
With my test I was able to shadow the creature for several minutes with no preception firing.
#6
Posté 13 mars 2011 - 12:51
I guess I am basically looking for performance advice.
-Is it more efficient to run the 6 creature HB and use a loop to find the party members and run checks if they are within X distance.
-Run a loop to id party members then loop through the 6 creatures to see if they are within the distance and run hide checks. Or run the opposite. ID creatures first then run through party members.
Is it bad to have a loop within a loop?
-Is it more efficient to run the 6 creature HB and use a loop to find the party members and run checks if they are within X distance.
-Run a loop to id party members then loop through the 6 creatures to see if they are within the distance and run hide checks. Or run the opposite. ID creatures first then run through party members.
Is it bad to have a loop within a loop?
#7
Posté 13 mars 2011 - 06:30
I think your numbers are small enough that a loop within a loop won't create any lag. Essentially, you're just doing a set of checks, 6 NPCs vs 5 or so PCs, or just 30 checks. Percep checks only induce lag when everyone is perceiving everyone else (i.e. 11x10, or 110 checks in this setup).
6 seconds is a bit long to wait, though, so you might want to set up a pseudo heartbeat to run the check every 1 or 2 seconds.
You could also use triggers to limit when and how the checks are made. A simple way would be to have a big trigger that covers the whole sneaking area, and which toggles a variable when the party enters and exits. As long as the party is in the area, the heartbeat runs the checks. That way, you don't have to constantly recalculate distance.
A more intricate approach would be to litter the area with triggers, each of which does a check on-enter, between the entrant and a particular creature, no heartbeats required.
6 seconds is a bit long to wait, though, so you might want to set up a pseudo heartbeat to run the check every 1 or 2 seconds.
You could also use triggers to limit when and how the checks are made. A simple way would be to have a big trigger that covers the whole sneaking area, and which toggles a variable when the party enters and exits. As long as the party is in the area, the heartbeat runs the checks. That way, you don't have to constantly recalculate distance.
A more intricate approach would be to litter the area with triggers, each of which does a check on-enter, between the entrant and a particular creature, no heartbeats required.
#8
Posté 14 mars 2011 - 02:35
I'd go with HB. On perception works great for a one time type thing when a player comes into the perception range of the creature/npc but that's about it.
If you need a function to see if the npc is facing something in particular you could use something like this in it's HB:
int GetIsFacingTarget(object oSelf, object oTarget, int nViewArc);
int GetIsFacingTarget(object oSelf, object oTarget, int nViewArc)
{
location lSelf = GetLocation(oSelf);
location lTarget = GetLocation(oTarget);
float AngleOffset = VectorToAngle(GetPosition(oTarget) - GetPosition(oSelf)) - GetFacing(oSelf) ;
return (abs(FloatToInt(AngleOffset)) < nViewArc/2);
}
Good luck.
If you need a function to see if the npc is facing something in particular you could use something like this in it's HB:
int GetIsFacingTarget(object oSelf, object oTarget, int nViewArc);
int GetIsFacingTarget(object oSelf, object oTarget, int nViewArc)
{
location lSelf = GetLocation(oSelf);
location lTarget = GetLocation(oTarget);
float AngleOffset = VectorToAngle(GetPosition(oTarget) - GetPosition(oSelf)) - GetFacing(oSelf) ;
return (abs(FloatToInt(AngleOffset)) < nViewArc/2);
}
Good luck.
#9
Posté 16 mars 2011 - 02:58
PERCEPTION DOES NOT FIRE ONLY ONCE. IT fires a lot of times over and over.
#10
Posté 16 mars 2011 - 04:54
I went with the individual creature heartbeats and it is working fine.
The issue with preception is that I am trying to create the conditions of when an character is preceived and I am ignoring the normal game mechanics that would cause the precieved script to fire.
The issue with preception is that I am trying to create the conditions of when an character is preceived and I am ignoring the normal game mechanics that would cause the precieved script to fire.
#11
Posté 16 mars 2011 - 05:19
dethia wrote...
PERCEPTION DOES NOT FIRE ONLY ONCE. IT fires a lot of times over and over.
Unless this is a change from NWN1, and to my knowledge it hasn't, what we're saying is that it only fires ONCE while entering the perception range of the creature/npc. The player would have to leave the perception range(no longer be seen or heard by said npc/creature) then reenter the perception range again. It does not repeatedly fire like an HB would. In some cases this is fine. However in many cases this does not work well for what a person needs to happen.
Modifié par GhostOfGod, 16 mars 2011 - 05:25 .
#12
Posté 16 mars 2011 - 09:45
um, yer both kinda right
I'm using a custom onPerception script that gives a SendMessageToPC() whenever it fires. It usually fires two or three times on entering LoS (line-of-sight), and again once or twice on leaving. But while remaining distinctly inside (or outside) LoS it won't fire off.
I'm using a custom onPerception script that gives a SendMessageToPC() whenever it fires. It usually fires two or three times on entering LoS (line-of-sight), and again once or twice on leaving. But while remaining distinctly inside (or outside) LoS it won't fire off.
#13
Posté 16 mars 2011 - 10:04
Hmm...most likely reason it fires 3 times would be to do all perception checks? Seen, Heard and Vanished? My best guess anyway.
#14
Posté 16 mars 2011 - 10:36
most likely. i mean, it's odd
usually it fires twice in instant succession (Seen, Heard perhaps), then as PC approaches closer it cliks over yet again, and again. (But sometimes not) It's odd ..
I'm using it to increase TumbleDC - rather, to decrease Tumble Skill. This thread has been giving me ideas on how to make it less kludgy.
usually it fires twice in instant succession (Seen, Heard perhaps), then as PC approaches closer it cliks over yet again, and again. (But sometimes not) It's odd ..
I'm using it to increase TumbleDC - rather, to decrease Tumble Skill. This thread has been giving me ideas on how to make it less kludgy.
#15
Posté 17 mars 2011 - 03:26
I've had a bit of success in forcing a re-perception by making creatures temporarily blind and deaf in their heartbeat script. I have some fish, eels and sharks in an upcoming module that are usually of neutral alignment, but only become hostile when the player enters the water. I initially had trouble getting them to attack from their custom OnPerceived script (which checks the perceived creature's Z height relative to their local 'water level' variable), since often the PC would be within perception range at the edge of the water. They weren't being re-perceived when they entered the water, so there was no hostility.
Making the fishies blind and deaf for one second in their heartbeat script seems to make them re-perceive anything in range when they recover - at least most of the time. I still get the occasional shark that lets you approach it. Putting the creature to sleep for a second works a lot better (they re-perceive every time), but has the downside of causing the sharks to roll onto their backs in a death posture every round.
Making the fishies blind and deaf for one second in their heartbeat script seems to make them re-perceive anything in range when they recover - at least most of the time. I still get the occasional shark that lets you approach it. Putting the creature to sleep for a second works a lot better (they re-perceive every time), but has the downside of causing the sharks to roll onto their backs in a death posture every round.
#16
Posté 17 mars 2011 - 10:35
You could have the perception script fire off a simple recursive call that checks if that party member is still in range. If true, make another perception check (with a penalty?), then call itself six seconds later on a failure. Otherwise, exit the call.
Possibly this may need to run on the area or an invisible object, rather than the creature, to avoid the action being cleared(?). You might also use local object variables to make the party member lookup efficient. Just thinking out loud here...
Possibly this may need to run on the area or an invisible object, rather than the creature, to avoid the action being cleared(?). You might also use local object variables to make the party member lookup efficient. Just thinking out loud here...
Modifié par rjshae, 17 mars 2011 - 10:38 .





Retour en haut







