Aller au contenu

Photo

On percieved scripts


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

#1
PJ156

PJ156
  • Members
  • 2 988 messages
I have written an on percieved script for an npc guard.

He is guarding a corridor, if he sees you he sends you back  If he does not see you nothing happens so you may sneak past him.

Functionaly, if he sees you, you are transported to a waypoint and a bark string appears over the guard with some warning message.

You may use sneak or invisibility to pass the guard

All of this works except it is not perfect, nor near perfect in fact.

The perception check seems to be on the heatbeat so once you are rebuked you then have an ample 6 seconds to walk past the guard and he does nothing. Also if he sees you coming back in the other direction I want his reaction to be more violent as you should not be behind him.

I can see this working better with two triggers. One before and one after the guard but I cannot see how to make a test on these triggers which tests if the guard can see you or not.

Would I be better to simply test to see if the character is in shadows or invisible and let them pass if they are? If so how do I test those scenarios?

You thoughts and help would be welcome.

PJ

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
I like to throw the PC into a cutscene-convo, so they can't do anything. Another option is to have the guard run to the PC, and start the conversation when close.

#3
Dann-J

Dann-J
  • Members
  • 3 161 messages
I've experimented with OnPerceived scripts, and found they are best avoided. A heartbeat script using a Get*ObjectInShape function loop is preferable.

If it were me, I'd create a custom Area of Effect (ie. an 'aura') and apply it to the guard, so that it fires custom OnEnter, Heartbeat and OnExit scripts. That way he will react when you first approach him and enter his aura (via the OnEnter script), he'll keep checking every six seconds (using a GetFirstObjectInShape/GetNextObjectIn Shape loop with the line-of-sight option as TRUE), and you can also script something to happen when you leave his custom 'aura' if you wanted.

The advantage of the custom AOE is that you can apply it to a wandering guard, and it's like they carry a mobile trigger around with them. Plus they run a second HB script.

I recently scripted a custom aura for a type of undead called a Quell, which has the power of intercession (it can block divine spells). Both the OnEnter and HB scripts for it check for divine spell casting classes and apply spell failure accordingly. I've found the custom AOE option to be an extremely powerful scripting tool.

Modifié par DannJ, 11 décembre 2011 - 10:42 .


#4
Shaughn78

Shaughn78
  • Members
  • 637 messages
To test for stealth it is just quick check: GetActionMode
For invisibility it gets a bit trickier: You have sanctuary, invisibility, improved invisibility, ethereal Jaunt, Walk Unseen, Retributive Invisibility, + others. It maybe a matter of picking a common effect that all these apply or checking GetEffectSpellId (which is much more in depth).

Once you determine if they are hidden you can do a PC vs Guard hide/spot or move silent/listen.

If the PC fails these checks or has no hidden status (sneaking, spell effect) then the guard does their thing. With the triggers you can fire the script and have an entering area and leaving area (sneaking back out) script or the triggers could just set the variables and the script can be fires some other way.

I would also suggest getting in touch with Kamal. I am sure he has situations like this in his thief campaign.

Modifié par Shaughn78, 11 décembre 2011 - 10:51 .


#5
Dann-J

Dann-J
  • Members
  • 3 161 messages
I've found that setting the LineOfSight option in the Get*ObjectInShape functions to TRUE also stops the player being noticed if they are invisible or successfully hiding. I assume that if the player is hiding and is heard, then they become 'visible' to the creature again (and start to satisfy the line-of-sight check in the function). The aquatic creatures in Isle of Shrines all use a HB script with this check, allowing you to sneak past them.

I don't know whether Sanctuary affects the function though. It might require a separate check.

Modifié par DannJ, 11 décembre 2011 - 11:03 .


#6
kamal_

kamal_
  • Members
  • 5 260 messages

Shaughn78 wrote...

To test for stealth it is just quick check: GetActionMode
For invisibility it gets a bit trickier: You have sanctuary, invisibility, improved invisibility, ethereal Jaunt, Walk Unseen, Retributive Invisibility, + others. It maybe a matter of picking a common effect that all these apply or checking GetEffectSpellId (which is much more in depth).

Once you determine if they are hidden you can do a PC vs Guard hide/spot or move silent/listen.

If the PC fails these checks or has no hidden status (sneaking, spell effect) then the guard does their thing. With the triggers you can fire the script and have an entering area and leaving area (sneaking back out) script or the triggers could just set the variables and the script can be fires some other way.

I would also suggest getting in touch with Kamal. I am sure he has situations like this in his thief campaign.

I'm using onPerceived for disguise. Some npc's are hostile by default, but will turn neutral if the player is properly disguised. For instance, castle guards will be hostile to a player not wearing a guard outfit, but turn neutral if the player is. One problem is it's possible to a hostile npc to attack before onPerception turns them neutral. Not a big deal for melee creatures (they start to approach then go neutral right away), but ranged creatures can make a single attack (guards who should get multiple attacks a round based on their bab will fire a single arrow) before turning neutral.