NPC's 'Backing each other up' in fights

Post » Sun Aug 09, 2009 1:55 am

Hi.

Iv a whole bunch of NPC's who wander around town doing their thing. I also have a bunch of NPC's, in their own class, who are the local militia (NOT guards!)

Right now these militia have their confidence set at 100, and their responsibility set to 10 (so that they don't try to arrest the player if there is a bounty on him), but if I attack one of them, while he will attack back without hesitation, the other militia will run away from the conflict rather than try to help their colleague.

Is there a way to get these militia to back each other up in the same way as guards would back each other up? I don't want to use the guard class because I don't want them to try and arrest the player if there is a bounty on him, hence the low responsibility.

cheers

MVK
User avatar
Richard Dixon
 
Posts: 3461
Joined: Thu Jun 07, 2007 1:29 pm

Post » Sun Aug 09, 2009 5:04 am

Did you give them a faction that makes them allies (100 disposition towards the faction).
User avatar
Crystal Clarke
 
Posts: 3410
Joined: Mon Dec 11, 2006 5:55 am

Post » Sun Aug 09, 2009 12:54 am

The easy way would be to just use the getcombattarget and StartCombat commands


Hi.

Iv a whole bunch of NPC's who wander around town doing their thing. I also have a bunch of NPC's, in their own class, who are the local militia (NOT guards!)

Right now these militia have their confidence set at 100, and their responsibility set to 10 (so that they don't try to arrest the player if there is a bounty on him), but if I attack one of them, while he will attack back without hesitation, the other militia will run away from the conflict rather than try to help their colleague.

Is there a way to get these militia to back each other up in the same way as guards would back each other up? I don't want to use the guard class because I don't want them to try and arrest the player if there is a bounty on him, hence the low responsibility.

cheers

MVK

User avatar
Jah Allen
 
Posts: 3444
Joined: Wed Jan 24, 2007 2:09 am

Post » Sat Aug 08, 2009 9:13 pm

Did you give them a faction that makes them allies (100 disposition towards the faction).


Yes. They are 100 in favor of each other (Is 100 the highest or can it go further?)

The easy way would be to just use the getcombattarget and StartCombat commands


Okay. But how would I use these commands? Where would I use them?

cheers

MVK
User avatar
candice keenan
 
Posts: 3510
Joined: Tue Dec 05, 2006 10:43 pm

Post » Sun Aug 09, 2009 10:10 am

Might want to read through this
http://cs.elderscrolls.com/constwiki/index.php/Actors_Who_Assist
User avatar
Charlotte X
 
Posts: 3318
Joined: Thu Dec 07, 2006 2:53 am

Post » Sat Aug 08, 2009 9:34 pm

I don't know if using StartCombat would be the easiest way, but you could put it on all of the militia.

Begin OnHit	StartCombat Player; Makes this NPC attack player   ; Need something else to make the rest of the NPCs help.End


OBSE has a get http://cs.elderscrolls.com/constwiki/index.php/GetFirstReffunction which can be used to get actor references.

GetFirstRef 35 1

This scans the NPCs in the player's current cell and the surrounding 8 cells.

Then you can use http://cs.elderscrolls.com/constwiki/index.php/GetNextRefto get the next actor's reference.


http://www.gamesas.com/bgsforums/index.php?showtopic=1035652&hl= may be somewhat relavent.


As you can see I'm clearly not much help but I try...
User avatar
Ells
 
Posts: 3430
Joined: Thu Aug 10, 2006 9:03 pm

Post » Sun Aug 09, 2009 8:54 am

Might want to read through this
http://cs.elderscrolls.com/constwiki/index.php/Actors_Who_Assist


Yup, read it. That's why the militia has 100 confidence and 10 responsibility, but they still run away if they see a fight!

The only thing that Iv not played with is the Disposition, but I don't know how to get that to work on an NPC who observes a fight involving someone who is supposed to be his mate.

Thanks TRN - that last link doesnt (as far as I can see) help me much in this case, but it begins to answer another question entirely!

cheers all

MVK
User avatar
Darlene Delk
 
Posts: 3413
Joined: Mon Aug 27, 2007 3:48 am

Post » Sun Aug 09, 2009 1:58 am

I've never tried this with NPC's but if you want to make sure a companion creature fights anyone who attacks the player you set it to be owned by Player Faction.
I'm not even entirely sure why this works, but it does.

Try setting the guard refs to be 'owned' by the militia faction. If it works it's probably the simplest solution, and I can't think of a drawback off the top of my head.

[edit] OOps...you can't set that in the CS for NPCs. I wonder if it would work from a script though...


Also I'm not sure I understand why you need them to have low responsibility. I think only classes with the Guard checkbox set will attempt to arrest, regardless of responsibility.

Try just setting their responsibility to something moderate and see what happens.

The problem with really low responsibility is it makes NPC's not care about crimes they witness.
User avatar
Emmie Cate
 
Posts: 3372
Joined: Sun Mar 11, 2007 12:01 am

Post » Sun Aug 09, 2009 9:34 am

Also I'm not sure I understand why you need them to have low responsibility. I think only classes with the Guard checkbox set will attempt to arrest, regardless of responsibility.

Try just setting their responsibility to something moderate and see what happens.

The problem with really low responsibility is it makes NPC's not care about crimes they witness.


Hmm, perhaps I got things mixed up - I thought that a low responsibility was needed so that traders would buy stolen goods and so that other NPC's wouldn't immediately give the player a bad disposition because he may have been a little light fingered. Ill certainly try setting their responsibility up to see what happens.

[EDIT]
Okay, I tried with the militia having their responsibility turned up to 90, and you are right, they don't try to attack me etc if Iv committed a crime, which is right, but they still wont back each other up either, in fact they are outright cowards if they see any kind of altercation, and will run away unless they are directly attacked themselves.

I'm really puzzled over this now.

Any more ideas anyone?


Cheers

MVK
User avatar
Agnieszka Bak
 
Posts: 3540
Joined: Fri Jun 16, 2006 4:15 pm

Post » Sun Aug 09, 2009 6:13 am

Also I'm not sure I understand why you need them to have low responsibility. I think only classes with the Guard checkbox set will attempt to arrest, regardless of responsibility.

They need low responsibility so that they don't pay attention to the lawful status of targets when picking who to fight. Using a low responsibility, rather than just flagging one of their factions as evil, will still make it a crime if they are attacked while still allowing them to help out another friendly NPC even when doing so would make them a criminal.



Just to make a quick list;
All the militia are part of their own unique faction who has a higher than 50-100 disposition towards itself and probably something like 30 toward townspeople faction?
All militia are setup with 10 aggression, 100 confidence, 60 energy, 20 responsibility?
All of the townspeople are part of their own unique faction, have no disposition boost toward themselves and a -10 disposition toward militia?
All townspeople are setup with 5 aggression, 40 confidence, 40 energy, 20 responsibility?
Neither the townspeople nor the militia factions are setup as evil?

In this setup, if the player attacks a militia member, all of the militia should attack the player and all the townspeople should run for cover.If the player attacks a townsperson, the one being attacked should either fight back or try to run away with none of the other townspeople helping, but if someone in the militia sees this, they will start attacking the player. If the militia attacks a townsperson, all the townspeople will run in terror, and other militia will join in. All the while, no bounty or crime gold will be given to the player or any NPCs, but it would still count as assault and/or murder.
User avatar
Tammie Flint
 
Posts: 3336
Joined: Mon Aug 14, 2006 12:12 am

Post » Sun Aug 09, 2009 8:02 am

Thanks Vagrant0 - I'm off to check all these. I'm pretty sure this is the way things are, although maybe not those exact numbers

[EDIT]
Well. Everything is set exactly as you suggested and still the militia will leg it if they see a fight between the player and another of the militia!

I'm not sure what to do next. There's no really big deal about this, since the militia are actually on the same side as the player, but you know how things get, late at night and with a sword in your hand. Id just like the reactions to follow the storyline sort of thing - The militia are a team and should back each other up, but I'm stumped with this now.

Is there anything else I can look at?

cheers

MVK
User avatar
Lucy
 
Posts: 3362
Joined: Sun Sep 10, 2006 4:55 am

Post » Sun Aug 09, 2009 6:11 am

lol AI can be a HUGE pain can't it?

What combat style are the militia using?

I really have absolutely no idea why, there are no settings in a combat style that seem related, but that can make a difference in whether or not an actor will fight or run.

e.g. I made a flock of chickens for my house and wanted them to run from enemies. So i set them to Confidence 0 and left them on Default combat style.
They didn't run, they would even fight me if i punched them! I switched the style to Default Deer, and they started running from every fight.

Now I'll lay odds your Militia are just on Default too....but still...whatever it is, try changing it. The results are not always predictable.
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Sun Aug 09, 2009 12:08 am

Is there anything else I can look at?

You've been using a clean save (made before the mod was ever enabled) when testing right? If not, some of the behavior might be because the NPCs are using older settings which were present at the time of that save.

The only thing I can think of is that there is some other mod involved which is having an impact on combat AI. If you have a chance, when one is fleeing, open console, pick the NPC, and check the results of the following functions

GetCombatTarget
GetCurrentAIProcedure
GetDisposition Player
GetAV aggression
GetAV confidence

Hopefully one of the values returned by those will provide a hint.
User avatar
candice keenan
 
Posts: 3510
Joined: Tue Dec 05, 2006 10:43 pm

Post » Sat Aug 08, 2009 9:41 pm

oh wow yes!

My money is on old data in the save. Do a cleansave for sure.

If not, again i agree with Vagrant.
User avatar
Amanda Leis
 
Posts: 3518
Joined: Sun Dec 24, 2006 1:57 am

Post » Sat Aug 08, 2009 10:20 pm

Sorry guys, but I position my start location for testing and I start a new game when Iv changed anything more than positioning a rock! (Something that I did in fact learn from reading the posts here!)

Mind you, I will check the combat style - Iv not actually touched it, so perhaps something would change with it - right now its a bit odd - If an Imperial strays into range the Militia are a bunch of lunatics, sprinting to attack the poor sap, but if I slap one of them the others run away as if a giant mutant spider just crawled out of the woodwork!

Cheers anyway, Iv another idea to play around with.

MVK
User avatar
Lou
 
Posts: 3518
Joined: Wed Aug 23, 2006 6:56 pm

Post » Sun Aug 09, 2009 9:53 am

Well, all I can say for this case is; Good luck!
User avatar
megan gleeson
 
Posts: 3493
Joined: Wed Feb 07, 2007 2:01 pm

Post » Sat Aug 08, 2009 10:29 pm

I don't see why StartCombat Player wouldn't work.

You could set up a script that runs OnHit.

I personally use a StartCombat Player script to cause nearby bandits to come to the aid of bandits within a radius.

I use a GetRandomPercent value and when it is the right value I use CastSpell Player and the bandit casts a spell that uses the script for StartCombat Player.

Begin GameMode	 set GRP to GetRandomPercent	 if IsInCombat Player	 if DoOnce == 0 	 if GRP <= 49  		  		  Cast AlertOthersSpell Player;(The spell used would have a script for StartCombat Player and a radius of say 1 cell and would use  IF GetInFaction Bandit to make sure only Bandits respond to the command.)		  set DoOnce to 1	 endifend


Only issue with above code is that the enemy then goes through the spell casting animation which isn't that great.

Other idea is to use a quest script that starts OnHit or something. A disabled NPC ref could be placed at the Militia's location and then have the disabled NPC cast the spell instead so you don't see it happen.

This would cause all Militia NPC's in the current cell to go straight for the player.
User avatar
Mandy Muir
 
Posts: 3307
Joined: Wed Jan 24, 2007 4:38 pm

Post » Sun Aug 09, 2009 5:18 am

I don't see why StartCombat Player wouldn't work.


Calling startcombat player is never a good thing unless you have something that calls stopcombat player if the distance is beyond a certain point. Say the player is on a horse running by some bandits, and they are forced to start combat with the player. If the player doesn't stop for them and kill them he will be in combat indefinitely, making waiting, sleeping, and fast travel impossible. Even if the player decides to flee without killing an actor that has been forced into combat you get the same problem.
User avatar
u gone see
 
Posts: 3388
Joined: Tue Oct 02, 2007 2:53 pm


Return to IV - Oblivion