Perception and Chasing
#1
Posté 10 octobre 2013 - 10:53
I wanted to know if it is even possible to make the PC chased by an NPC. I was thinking, the moment the PC enters a trigger the NPC faction changes. There is of course a safe spot with a nother trigger to change it back because the PC hid there.
Is that possible to make? On the second trigger mentioned, it could be also an onexit to change the faction back. I guess all this is quite possible, but I would also like more... don't we always? When the PC enters the safe trigger, and is hidden, how do you make the NPC pass by and speak something like "Where the hell did he go?"
Also, during the chase, I was thinking something like the Elder Scrolls guard system. That they are hostile, but when they reach you they talk to you about fines and prison. I think I can manage the easy part with the faction, but the last two are pretty much untouchable by me. Thanks.
#2
Posté 10 octobre 2013 - 12:16
You can script the NPC to walk by the hidden PC and shout out a barkstring, but you could also just use a conversation-style cutscene to play out the dialogue (just so it's clear to the player what happened).
#3
Posté 10 octobre 2013 - 12:25
#4
Posté 10 octobre 2013 - 03:08
Modifié par Tchos, 10 octobre 2013 - 03:09 .
#5
Posté 10 octobre 2013 - 03:39
#6
Guest_Iveforgotmypassword_*
Posté 10 octobre 2013 - 04:14
Guest_Iveforgotmypassword_*
Making the NPC immortal would be really annoying too as would you want to be playing a game where you felt completely forced into doing as your told or fighting for hours.
Bear in mind that people will all do different things when playing a game and even if you had every villager saying you better run away from x and x saying I'll give you a head start some still wont do it. So making it optional with more xp for hiding than killing might be one way of rewarding the well behaved.
#7
Posté 10 octobre 2013 - 04:27
How that works is that there is a trigger for the npc instead of the usual player activated trigger. When the npc enters the trigger, the OnEnter script of the trigger looks for whatever you want the npc to "notice", In this video what is happening is that the door is open when it is supposed to be closed. Since the door is open, that commands the npc to walk to the door and close it, and turn to a custom hostile only to pc faction. The npc's heartbeat script will set the npc to pursue the player until they can no longer perceive the player.
Basic following the player is done in Uncle FB's scripts.
You can make npc's do all sorts of things with OnEnter scripts triggered by them, in this video the guard notices the torch is out, and goes and lights it up before continuing on his patrol. www.youtube.com/watch
Modifié par kamal_, 10 octobre 2013 - 04:29 .
#8
Posté 10 octobre 2013 - 04:36
Disguise as used in Crimmor isn't any kind of skill check, it's a matter of being having the appropriate clothes equipped (as you are not disguising yourself as specific people, just members of large groups). The npc heartbeat runs a perception event to check check the players equipped items for the disguise. If the player is perceived, then it checks for the disguise. If the player is not perceived, or is perceived but disguised, the npc carries on as normal. Otherwise the npc does whatever you want the npc to do towards a non-disguised, perceived player (generally, attack the intruder).andysks wrote...
The first chase needs to happen so it has to be a trigger. After this, I guess it can continue as a perception. I was also thinking to include a disguise... I believe kamal did it in Crimmor. But I think this is a bit too much to achieve.
The reason I have the heartbeat run a perception check is the OnPerception script only fires when the player enters the perception area, so it doesn't work well because a player could wear the disguise into view, and then just remove it and carry on as normal. Running via heartbeat forces the player to remain disguised.
#9
Posté 10 octobre 2013 - 05:39
kamal: So the trigger has just simple scripts onenter and onexit with if statements? if the door is open, close it and attack. if the torch is unlit... and so on. Are there your own scripts or did you use the PRR 3, or something similar?
#10
Guest_Iveforgotmypassword_*
Posté 10 octobre 2013 - 07:22
Guest_Iveforgotmypassword_*
#include "ginc_actions"
void main()
{
object oPC=GetLastPerceived();
object oArmour=GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
string sTag=GetTag(oArmour);
if(!GetIsPC(oPC))return;
if(sTag!="disguise")
{
ChangeToStandardFaction(oNPC,STANDARD_FACTION_COMMONER);
}
}
Modifié par Iveforgotmypassword, 10 octobre 2013 - 07:23 .
#11
Posté 10 octobre 2013 - 09:20
#12
Posté 11 octobre 2013 - 12:07
I looked for my testing module that was for testing that specific behavior, but I deleted it. But to answer your question yes, the triggers have local variables that are set when the player uses the behavior triggering object. When the npc enters the trigger, if the variable is set to true, then the OnEnter script directs the npc to carry out a behavior, and the triggering object to also carry out a behavior (closing the door, turning the torch on), timed to look like the npc is doing it (the npc is not actually using the object). Tchos set up a system where the npc will actually use the object directly.andysks wrote...
kamal: So the trigger has just simple scripts onenter and onexit with if statements? if the door is open, close it and attack. if the torch is unlit... and so on. Are there your own scripts or did you use the PRR 3, or something similar?
Also, OnPerception is not a good function if you want an npc to chase down a pc and stop if they can't find the pc any more, since it only ever fires once per pc. You can take what you want happening in an OnPerception script make it a function in the heartbeat script directly, or an include. Then you can set the heartbeat to call the perception script on heartbeat (In Crimmor, many creatures also check if the player is inside a trigger before running that perception bit, to improve performance)
I used PRR 3 as a base, but changed a number of things to better fit what I wanted to do with it. If you look in the scripts in Crimmor, you will see the PRR scripts, and then duplicate versions with the _kam postfix.
#13
Posté 11 octobre 2013 - 12:08
#14
Posté 11 octobre 2013 - 12:52
#15
Posté 11 octobre 2013 - 01:03
I'm not sure if you're really saying what it sounds like you're saying here, but On Perception fires an unlimited number of times for a single PC. It just won't fire a second time until the PC has left the NPC's perception range, which resets it. I have many instances where I use the On Perception event to fire a script (such as my friendly NPCs who call things out when the PC walks by), and it fires every time you pass by them.kamal_ wrote...
Also, OnPerception is not a good function if you want an npc to chase down a pc and stop if they can't find the pc any more, since it only ever fires once per pc.
What I would do here, is use the perception event to set a local int on the NPC, and that NPC's heartbeat would act based on the value of that local int.
Modifié par Tchos, 11 octobre 2013 - 01:51 .
#16
Posté 11 octobre 2013 - 03:28





Retour en haut







