How do I make an NPC flee on sight?

Post » Mon Jun 18, 2012 6:40 pm

In the mod I'm working on, I wanted to have some cultists and these cultists, upon seeing the player or after the player gets within a certain distance of them, would flee and run away. I don't know much about scripting or anything of the sort so I'm looking for some help on getting this to work. Thanks!
User avatar
Jhenna lee Lizama
 
Posts: 3344
Joined: Wed Jun 06, 2007 5:39 am

Post » Mon Jun 18, 2012 5:52 am

Maybe slapping a fear effect on them would work? Put invisible fear traps everywhere but where their "last stand" would be, and have the PC turn them on by opening the door to the room where they are (hang some of those bone "noise traps" next to the door to explain to the player later why opening the door alerted them regardless of high sneak or something)
User avatar
louise fortin
 
Posts: 3327
Joined: Wed Apr 04, 2007 4:51 am

Post » Mon Jun 18, 2012 3:47 pm

I know animals flee on sight like deer and stuff. One idea I had was giving them the same AI as those animals but I have no idea if that would work. The fear effect is an interesting idea but the area I have them in is an exterior cell. I could probably give them a constant fear effect but that would have them running to the hills regardless of the player's proximity, right?
User avatar
Jonny
 
Posts: 3508
Joined: Wed Jul 18, 2007 9:04 am

Post » Mon Jun 18, 2012 4:58 pm

In the mod I'm working on, I wanted to have some cultists and these cultists, upon seeing the player or after the player gets within a certain distance of them, would flee and run away. I don't know much about scripting or anything of the sort so I'm looking for some help on getting this to work. Thanks!
does stg like getLOS still exist in papyrus? if yes: this and then add a flee-package
User avatar
Michael Russ
 
Posts: 3380
Joined: Thu Jul 05, 2007 3:33 am

Post » Mon Jun 18, 2012 11:47 am

Also, you could create a new actor type for each of your Cowardly Cultists

(For example, copy "EncBandit01MagicBretonM" and call it "CowardlyCultistMagicBretonM")

double click on the new actor type, and turn off "USE AI Data" under templates...this will allow you to edit the AI data manually (It doesn't turn AI data OFF, it just keeps it from using the default data) - Change his AI Data tab information as follows:

Set Aggression to "Unaggressive", set "Confidence" to "Cowardly", and turn "Mood" to "Fear"

Do this for whatever actor types you want your cultists to be. I made a cowardly bandit race, but you'll probably want them in robes or something.
User avatar
Megan Stabler
 
Posts: 3420
Joined: Mon Sep 18, 2006 2:03 pm

Post » Mon Jun 18, 2012 3:21 am

Ok, try this: Create a new magic effect (I copied one), call it "Cowardice", open the editor and set the following:

Name: Run Away
Effect Archetype: Demoralize
Casting Type: Constant Effect
Delivery: Self
Magic Skill: NONE

And add the script 'ActivateSelfOnCombatBegin' to the Papyrus Scripts list, just to be sure.

Now create a new spell called "Chicken" or "Run Away" or something, add the Cowardice effect to it, and put it in the cultist's spell lists.

And see if that works.
User avatar
lauren cleaves
 
Posts: 3307
Joined: Tue Aug 15, 2006 8:35 am

Post » Mon Jun 18, 2012 11:43 am

There's also that Dark Elf in Bleak Falls Barrow who's caught in the spider web. I'd have a look at how his AI works, to see what you can do.
User avatar
MR.BIGG
 
Posts: 3373
Joined: Sat Sep 08, 2007 7:51 am

Post » Mon Jun 18, 2012 1:53 pm

Also, you could create a new actor type for each of your Cowardly Cultists (For example, copy "EncBandit01MagicBretonM" and call it "CowardlyCultistMagicBretonM") double click on the new actor type, and turn off "USE AI Data" under templates...this will allow you to edit the AI data manually (It doesn't turn AI data OFF, it just keeps it from using the default data) - Change his AI Data tab information as follows: Set Aggression to "Unaggressive", set "Confidence" to "Cowardly", and turn "Mood" to "Fear" Do this for whatever actor types you want your cultists to be. I made a cowardly bandit race, but you'll probably want them in robes or something.
Ok, try this: Create a new magic effect (I copied one), call it "Cowardice", open the editor and set the following: Name: Run Away Effect Archetype: Demoralize Casting Type: Constant Effect Delivery: Self Magic Skill: NONE And add the script 'ActivateSelfOnCombatBegin' to the Papyrus Scripts list, just to be sure. Now create a new spell called "Chicken" or "Run Away" or something, add the Cowardice effect to it, and put it in the cultist's spell lists. And see if that works.
I tried both but neither worked. I can get them to run away once I engage them in combat, no problem. I just want them to run away as soon as the player shows up.
User avatar
Kayleigh Williams
 
Posts: 3397
Joined: Wed Aug 23, 2006 10:41 am

Post » Mon Jun 18, 2012 3:01 pm

You could create a new cloak spell that causes fear within a certain range of the player. Set the magnitude to 99 and remove any shaders or impact data, and go ahead and use HealFakeProjectile on it. Attach it to a perk as an ability, then add it to the player. Stick a conditional on it to check for a unique keyword you assign to the chosen NPCs so it only affects them. I've played with cloak spells a lot for True Yield and Specialized Followers. I know that they can awkwardly affect AI under some circumstances, so you should probably only temporarily have the cloak on the player, then remove it later on.
User avatar
Charles Mckinna
 
Posts: 3511
Joined: Mon Nov 12, 2007 6:51 am

Post » Mon Jun 18, 2012 10:50 am

I tried both but neither worked. I can get them to run away once I engage them in combat, no problem. I just want them to run away as soon as the player shows up.
Are you sure your factions are set up right? You want THEM to engage into combat in order for them to flee.
User avatar
Melanie Steinberg
 
Posts: 3365
Joined: Fri Apr 20, 2007 11:25 pm

Post » Mon Jun 18, 2012 7:05 pm

Thanks for everyone's help but I think I figured it out. I scanned all of the "cowardly" animals (foxes, deer, goats) and I noticed they all have aggro radii in addition to being set as Cowardly. I think the aggro radius is what I need to play with. I'm setting all of the cultists to the exact same AI data as a deer so let's hope this works.
User avatar
Chris Ellis
 
Posts: 3447
Joined: Thu Jul 26, 2007 10:00 am

Post » Mon Jun 18, 2012 11:59 am

I would think that the aggro radii would help. When an actor is fleeing, they are actually in a combat state. In FO3, the enclave scientists would always flee the player - their confidence was set to cowardly and aggression set to 'Very aggressive'. A very aggressive actor is more likely to enter combat and remain there - in this case fleeing since they are cowardly.
User avatar
renee Duhamel
 
Posts: 3371
Joined: Thu Dec 14, 2006 9:12 am

Post » Mon Jun 18, 2012 7:47 am

The aggro radius was what I needed! I set it first to 1500 which is what deer have but that made them way too easily spooked so I put it to 500. As soon as the player approaches one, they bolt! Awesome.
User avatar
flora
 
Posts: 3479
Joined: Fri Jun 23, 2006 1:48 am

Post » Mon Jun 18, 2012 3:10 am

Adolon your avatar is the win :D
User avatar
Jade Barnes-Mackey
 
Posts: 3418
Joined: Thu Jul 13, 2006 7:29 am


Return to V - Skyrim