Aller au contenu

Photo

request: make npc search for pc for three rounds


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

#1
kamal_

kamal_
  • Members
  • 5 258 messages
I'd like to make a npc (not hostile to the player) search for the pc for three rounds. If they find the pc, start a conversation. Otherwise, continue what they are doing.

I've got all my conditionals to trigger the behavior working properly, just can't seem to get the searching to work.

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
You mean like use action mode search to find a stealth-hidden PC? Or just wander around an area until they get within so many meters of the PC?

#3
kamal_

kamal_
  • Members
  • 5 258 messages
Yes, action mode searching looking for a potentially stealthed pc. Preferably wandering some around an already defined object.

If a patrolling guard finds a door open that shouldn't be (shop doors after hours), he searches for the culprint (eg the pc) and starts a conversation if he does, and if he doesn't find the culprit, he will close the door and continue his patrol. I'm using a trigger system like I did for guards and torches the pc has turned off. The triggering itself works fine. The PRR system allows a guard to own a door, but it seems to assume that the guard is nearby when the door is opened, which generally isn't going to be the case here, the trigger allows the guard to actually "discover" the open door.

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
You could put three waypoints around the object and each round or so make the guard move to one of the waypoint and then run a script that checks for all objects within a certain radius, then do a check on the guards spot vs PC hide/stealth, then if the guard wins the check, start convo, if not, move to next waypoint and try again. If pc is outside of search radius, return and go to next waypoint. If failing to detect PC on all three waypoints, return to patrol.

#5
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
I would give the guard a custom perception script, so that when they perceive the PC, and some flag is set, they start the conversation. Then, you have a trigger around your door, with an on-enter script. When the guard enter the trigger, it sets the flag, puts the guard into search mode (SetActionMode, or better yet, just give him keen senses), and does a check for unhiding PCs (and starts the convo if they find them). Then you can have something on the heartbeat that moves the guard along a search pattern, and turns off the flag after enough time has passed.

Some of my gendarmes in Last of the Danaan start conversations when they spot hiding PCs, so you can look at their perception scripts to see how I kludged it together.

#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Oh yeah. That's a better way.

#7
kamal_

kamal_
  • Members
  • 5 258 messages
How I'm doing it now is when the guard enters the trigger, it checks the open/closed hours of the store (stored on the door), as well as the variable that tells the guard to pay attention to the door (variables on the door and guard). I'm clearing the guards actions if those conditions are met, so I know the conditional stuff to tell the guard "that door shouldn't be open and it is" is working correctly. That the conditional stuff is working is no surprise as I'm doing a very similar thing for my guards with torches.

I am using SetActionMode to put the guard in to search. He just doesn't seem to do it. Currently I have him cycle through creatures in a sphere with a while statement and have him run a perception, but the debug code I've put in to keep track never fires.

#8
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Sounds like a syntax issue in that last script, care to post it?

#9
Shaughn78

Shaughn78
  • Members
  • 637 messages
I have found with the SetActionMode doesn't always apply the animation. I had an area and would set the player and companions to stealth mode. Only the controlled character looked like they were in stealth mode, when switching between the companions they were in stealth mode and would play the animation once controlled.

#10
kamal_

kamal_
  • Members
  • 5 258 messages
The SendMessageToPC commands in the while loop never fire. the SendMessageToPC(oPC, "focus check"); command near the beginning does.


if (iFocused <= FOCUSED_STANDARD)
{
SendMessageToPC(oPC, "focus check"); //testing. works to this point.
//if we see the pc, start conversation to confront
// if(GetIsPC(oLastPerceived) && bSeen)

SendMessageToPC(oPC, "looking for pc");
//equip weapon, spend 15 seconds searching for pc. confront if detected.
AssignCommand(oEnterer, ActionEquipMostDamagingMelee());
SetActionMode(oEnterer,ACTION_MODE_DETECT,TRUE);

while (GetIsObjectValid(oLastPerceived))
{
if(GetIsPC(oLastPerceived) && bSeen)
{
SendMessageToPC(oPC, "search found pc");
ActionStartConversation(oLastPerceived, "sh_crimmor_guard_confront", FALSE, FALSE, FALSE, FALSE);
}
else
{
SendMessageToPC(oPC, "while looping");
oLastPerceived = GetNextObjectInShape(SHAPE_SPHERE, 12.5, GetLocation(oEnterer), TRUE, OBJECT_TYPE_CREATURE );
int bSeen = GetLastPerceptionSeen();
}

//we're stacking the sanity check on the door and the check to make sure the guard hasn't found and started the confrontation conversation with the pc.
while (GetIsObjectValid(oDoor) && (!IsInConversation(oEnterer)))
{
//the guardable and usable door will be the only object with this variable, it is always 1, all guard monitored doors must have this local variable
if (GetLocalInt(oDoor, "guard_monitored ")==1)
{

//after searching for 15 seconds, move to door and close
DelayCommand(15.0, AssignCommand(oEnterer, ActionMoveToObject(oDoor,0,1.0f)));
ActionCloseDoor(oDoor);
break;

}
else //not door in question, continue cycling looking for source.
{
oDoor = GetNextInPersistentObject(OBJECT_SELF, OBJECT_TYPE_DOOR);
}
}//ends while loop
}

Modifié par kamal_, 11 novembre 2011 - 11:36 .


#11
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Is this in the perception script? How is oLastPerceived first getting defined? Is bSeen also defined somewhere?

I haven't used the shapes, so I don't know if you're looping through the objects there properly (shouldn't you have a get-first-object-in-shape?).

If you do use the perception script, make sure to do something when the PC is heard, but not seen. Maybe the guard runs towards the PC, or starts a slightly different conversation.

#12
kamal_

kamal_
  • Members
  • 5 258 messages
hmmm, good point, I assumed I was sending commands to oEnterer (eg the guard). No, this script is in the onEnter trigger around the door.

#13
Shaughn78

Shaughn78
  • Members
  • 637 messages
I recently did a search script. Instead of using the perception script I did an alternative, like you. Instead of a trigger I used he heartbeat, but same idea. However, I did the roll for the seen and heard checks in the script and did not use LastPerceived. If the the check failed then I had the script fire off the second half, in your case that would be the conversation. I think I ran into some issues going through invisibility and similar buffs that would give bonuses to hidden PC, off hand I can't remember how I did it. If you want more info let me know and I can post the script I used.

#14
kamal_

kamal_
  • Members
  • 5 258 messages
using Lugaid's suggestion of changing the perception script for the guard I came up with this
pastebin.myrror.net/3030

The  SendMessageToPC(oPC, "perception running");  line runs, but the 
SendMessageToPC(oPC, "PC perceived by guard");  line never runs even standing right in front of the guard.

The following lines don't seem to play out ingame either.
SetActionMode(OBJECT_SELF, ACTION_MODE_DETECT, TRUE);

AssignCommand(OBJECT_SELF, ActionPlayAnimation(ANIMATION_FIREFORGET_SEARCH, 0.5));


Though I am sure action mode is being set, as I've used debug messages to check. One thing I noticed is the setactionmode (and presumably the assigncommand) fire 6-8 times in a row.

#15
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
The perception script only runs when an object is first perceived by the caller, so it's possible that your guard saw the PC before the door was opened, and so didn't run the script a second time. (You are sure that the guard can in fact detect the PC standing in front of them, right? d20's can make even an inept rogue invisible to a guard for several rounds--give the guard 20+ skill ranks in spot to make sure, or just leave stealth mode).

Will this work with your area setup? I mean, if he PC is going to running through the area without attracting any suspicion before hand, then the perception script won't get run a second time. You might either have to script your spot checks manually, or spawn-in a fresh guard or something.