Aller au contenu

Photo

Perception and Chasing


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

#1
andysks

andysks
  • Members
  • 1 651 messages
Hi all, I was thinking if this is possible to make, coudn't find a good tittle though.
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
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
I wouldn't change the factions, not unless your willing to have some NPCs get killled in the process. I'd use the heartbeat script on the NPC to order the NPC to chase the PC and force the PC into a conversation if within 10m or so.

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
andysks

andysks
  • Members
  • 1 651 messages
The heartbeat will call for what? A local int which got set the moment the PC entered a given trigger, and if it's 1 let's say, he starts chasing?

#4
Tchos

Tchos
  • Members
  • 5 063 messages
Yes, that's how I'd do it (the heartbeat checks a local int). However, I'd probably use the perception event to start the chase rather than a trigger, so that the guard would not chase the PC if the PC successfully snuck past.

Modifié par Tchos, 10 octobre 2013 - 03:09 .


#5
andysks

andysks
  • Members
  • 1 651 messages
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.

#6
Guest_Iveforgotmypassword_*

Guest_Iveforgotmypassword_*
  • Guests
This sounds really complicated as I'd imagine getting a player to do something is very hard unless you just take over and cutscene or force the whole lot. What if the player just stands there and fights ?

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
kamal_

kamal_
  • Members
  • 5 254 messages
I believe you are looking for something like what's demonstrated in this video. www.youtube.com/watch

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
kamal_

kamal_
  • Members
  • 5 254 messages

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.

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).

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
andysks

andysks
  • Members
  • 1 651 messages
Password: it kinda happens after a cutscene, where an NPC informs you of stuff and you don't have much choice but run. If you choose to fight, you'll probably die, not because of immortal NPC but because you just can't fight him at the moment. You have no items and blah blah. Don't wanna spoil it :D.

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_*

Guest_Iveforgotmypassword_*
  • Guests
Stick this on your npc's on perception bit in the properties and you have a disguise that if worn will make the hostile npc behave.

#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
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
One way to force the chase is to fire a cutscene convo when the PC enters the first trigger, explain the situation in the convo, and give the player the choice of surrendering or running. If they choose run, end the cutscene and assign the PC a command to run to a waypoint near your refuge trigger.

#12
kamal_

kamal_
  • Members
  • 5 254 messages

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?

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.

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
andysks

andysks
  • Members
  • 1 651 messages
It is something like that. I will try to explain without saying too much. You need to escape from somewhere, and you got no items. So after you escape, they notice it(still in cutscene mode all this), and they start chasing you. Cutscene ended. There are spots on the map where you can hide behind boxes and what not, with a trigger that changes the chaser back to friendly and fires the small scene with him passing by. When you leave the safe spot, it all gets activated again. Only problem is, that the faction change script that exist in the toolset allows only the standard factions to be changed. Therefore if I make the chasing group hostile, they will most probably attack every commoner available before chasing the PC.

#14
kamal_

kamal_
  • Members
  • 5 254 messages
You can set to custom factions. If you noticed in my youtube demo for the open door, the guard is "hostile" and red, but ignores the commoners standing around. Or just make your commoners a neutral to all faction.

#15
Tchos

Tchos
  • Members
  • 5 063 messages

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.

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.

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
Dann-J

Dann-J
  • Members
  • 3 161 messages
Indeed - once you leave a creature's perception range, or become invisible to them (invisibilty, hide in plain sight, etc), you get deleted from that creature's current perception list. The next time you meet, their OnPerceived event will fire again (if they see/hear you).