[Relz] NPC Friendly Fire

Post » Thu Mar 31, 2011 1:14 pm

(A mod based on http://www.gamesas.com/index.php?/topic/1121958-npcs-and-friendly-fire/)

http://www.tesnexus.com/downloads/file.php?id=35257

** NPC Friendly Fire v1.0 ** -by Skycaptain

[this mod requires Oblivion Script Extender!]


Overview
--------

This is a very simple one-script mod that helps to keep NPCs from killing each other without a reason.


Details
-------

The script checks if any fighting NPC in the loaded are is fighting. If the NPC is fighting another NPC from the same faction as the NPC himself, the fight is stopped.

To keep the fight from starting again, the script also increases the NPCs disposition against the other NPC to the same level as his agression (if lower than aggression).

Optionally, the mod can be configured to add EXTRA disposition, so that the resulting disposition is safely above the aggression value.



Configuration
-------------

This mod has two configurable values

-how often the script runs. default is every 1s, which should be fine but nevertheless can be changed.

-how much extra disposition is added. If the value is other than 0, the script makes sure that the fighting NPCs have disposition equal to their aggression level + extra value, towards each other, unless its already higher.


Notes:
-------

Many NPCs, even in towns, do not share any factions between each other.

If you want to verify that this mod works, open console, click a guard, memorize the id you see, click another guard, and type startcombat [the id of the other guard].

Similarly, you can verify if two NPCs do not share any faction relations. Just use a console command "samefaction" in a similar manner (1=yes, 0=no).



Install
--------

1. Make sure to install Oblivion Script Extender (http://obse.silverlock.org/)

Make sure you know how to run Oblivion with it - it has a readme.

2. Put the contents of this mod into your Oblivion\data folder.

3. Enable the mod, and hopefully your NPCs will fight (to death) less the they used to. ;)


Legal
--------

This mod can be edited and redistributed, if credit for the original work is given. :)



Credits
--------

-Obse crew, without them there would exist no mods made by me

-PetrusOctavianus, who′s request thread gave the idea for this mod

-Bethesda for the original game and CS


-------
-Sky

User avatar
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am

Post » Thu Mar 31, 2011 4:35 am

Right! In it goes...

:foodndrink:
User avatar
Jeff Tingler
 
Posts: 3609
Joined: Sat Oct 13, 2007 7:55 pm

Post » Thu Mar 31, 2011 6:44 am

So will this keep all my "Extended" xxxx city npcs from causing riots in taverns when someone steals something?

I went into the IC market tavern at night and this "Extended Imperial City" mod added like 10-15 npcs that were at dinner. The strange thing is it seems they only started fighting when I entered upon loading the scene twice. I had to resurrect 3 npcs from that fight.

You might want a download link somewhere up there.
User avatar
kasia
 
Posts: 3427
Joined: Sun Jun 18, 2006 10:46 pm

Post » Thu Mar 31, 2011 12:16 am

Ah good, no more watching as Imperial guards in the wilderness kill each other. Would you mind adding a link though?
User avatar
Ash
 
Posts: 3392
Joined: Tue Jun 13, 2006 8:59 am

Post » Thu Mar 31, 2011 7:43 am

Good show! :bowdown:
User avatar
GabiiE Liiziiouz
 
Posts: 3360
Joined: Mon Jan 22, 2007 3:20 am

Post » Thu Mar 31, 2011 9:47 am

Installed. Hopefully will work for the "Extended" mods.

Where should this go in the LO while we wait for BOSS to sort it?
User avatar
Kyra
 
Posts: 3365
Joined: Mon Jan 29, 2007 8:24 am

Post » Thu Mar 31, 2011 12:12 pm

So will this keep all my "Extended" xxxx city npcs from causing riots in taverns when someone steals something?

I went into the IC market tavern at night and this "Extended Imperial City" mod added like 10-15 npcs that were at dinner. The strange thing is it seems they only started fighting when I entered upon loading the scene twice. I had to resurrect 3 npcs from that fight.


Well it stops them from fighting, if they are in the same faction. I doubt that′s the case there.

But sounds like your real problem is that the NPCs start fighting in the first place. Even if they are in different factions, they obviously should not start fighting without a reason (but I can′t tell from script the they shouldn′t fight, unless they are in the same faction). (Some) mod adding NPCs in that location has a fault, that should be fixed.



What this mod is for, is to stop NPCs from fighting, if they accidentally hit each other (too much) in combat (towards some enemy), and end up fighting even though they normally wouldn′t. A good example is guards fighting some bandits, shooting each other accidentally with arrows until one of the guards attacks another guard.



EDIT: Ah, thanks added the link. Load order doesn′t matter, it′s single pure script with no connection to anywhere. :)
User avatar
Nomee
 
Posts: 3382
Joined: Thu May 24, 2007 5:18 pm

Post » Thu Mar 31, 2011 12:22 pm

Ok. I figure it is because it is a confined space relative to the number of NPCs these mods add to the city. 10-15 NPCs inside the market tavern is crowded at the dinner hours.
Someone is bound to get hit.
User avatar
Marie
 
Posts: 3405
Joined: Thu Jun 29, 2006 12:05 am

Post » Wed Mar 30, 2011 11:23 pm

Wow thank you so much Skycaptain, this is one of those mods that I wish I'd been playing with years ago. I can't tell you how many times I've had to reload because the all the IC Guards or all the Blades started a huge war between themselves. Keep up the good work. :)
User avatar
ladyflames
 
Posts: 3355
Joined: Sat Nov 25, 2006 9:45 am

Post » Thu Mar 31, 2011 3:55 am

Heh, I must say I had half expected the mod to be called "Hey, I'm on your side!" in the same vein as one of your other mods called "Medic!". :P
User avatar
Stephy Beck
 
Posts: 3492
Joined: Mon Apr 16, 2007 12:33 pm

Post » Thu Mar 31, 2011 3:06 pm

Ok. I figure it is because it is a confined space relative to the number of NPCs these mods add to the city. 10-15 NPCs inside the market tavern is crowded at the dinner hours.
Someone is bound to get hit.


Heh. :P

But really, just incase you want to know, if an NPC attacks another NPC just like that, there is only one reason:

if ( callingActor.getAV aggression > 5 )  if ( callingActor.getDisposition target < callingActor.getAV aggression )    ; actor is hostile toward target  endifendif


The above means that if

1. NPC has Aggression > 5

and

2. his Disposition towards some other NPC is lower than his general Aggression

-->the result is he will attack.


So most likely some mod adds an NPC with a generally high agression, so that it he/she attacks NPCs from any other mod easily (because there′s no connection between the mods and the disposition defaults to low). Usually these situations are solved with patches that either reduce the agression of the NPC, or add him/her into some faction shared with the other NPCs in the area, which automatically sets the disposition very high, or something similar, you get the idea. :)
User avatar
Silvia Gil
 
Posts: 3433
Joined: Mon Nov 20, 2006 9:31 pm

Post » Thu Mar 31, 2011 1:37 pm

Heh, I must say I had half expected the mod to be called "Hey, I'm on your side!" in the same vein as one of your other mods called "Medic!". :P


Dammit!!! :facepalm:
User avatar
Tom Flanagan
 
Posts: 3522
Joined: Sat Jul 21, 2007 1:51 am

Post » Thu Mar 31, 2011 5:12 am

And sometimes it's an NPCs AI Package that sets it all off. Had to uninstall the Beggars from NPCs Alive since they were killed by the guards as soon as their AI Packages had them looking for food and the guards considered it stealing.
User avatar
LittleMiss
 
Posts: 3412
Joined: Wed Nov 29, 2006 6:22 am

Post » Thu Mar 31, 2011 3:56 am

And sometimes it's an NPCs AI Package that sets it all off. Had to uninstall the Beggars from NPCs Alive since they were killed by the guards as soon as their AI Packages had them looking for food and the guards considered it stealing.


Ah, yes that′s true. It′s a shame the faction check is pretty much the only way to tell 100% sure the fight is uncalled for.
User avatar
Lyndsey Bird
 
Posts: 3539
Joined: Sun Oct 22, 2006 2:57 am

Post » Thu Mar 31, 2011 3:31 pm

It wasn't so bad that the "Extended" NPCs would die but the councilors from TEC got caught in it and I have no idea just how important they are since I haven't started it yet.
Good thing for resurrect.
User avatar
Nichola Haynes
 
Posts: 3457
Joined: Tue Aug 01, 2006 4:54 pm

Post » Thu Mar 31, 2011 4:00 am

So will rage and frenzy spells cause no effect now on creatures/NPCs? I've never been able to cause a riot with my current FCOM game, but IIRC, I can frenzy NPCs into fighting amongst each other. I guess this overrides that behavior, correct?
User avatar
Ownie Zuliana
 
Posts: 3375
Joined: Thu Jun 15, 2006 4:31 am

Post » Thu Mar 31, 2011 8:29 am

So will rage and frenzy spells cause no effect now on creatures/NPCs? I've never been able to cause a riot with my current FCOM game, but IIRC, I can frenzy NPCs into fighting amongst each other. I guess this overrides that behavior, correct?


Hmm, I guess it does! I didn′t even remember that spell type, never got it to do anything.


Reading about it, it seems it simply increases the target′s aggression. Because accidental massacres are mostly caused by too low disposition or because the attack happened in the first place, I′m thinking it could be safely assumed that if an NPC has aggression > base aggression he is under frenzy, and should not be stopped from fighting.

But the silly thing that happens then is that the script will stop he′s fellows from fighting HIM, while he′ll keep on beating THEM up. Don′t know if there′s a solution...
User avatar
Kyra
 
Posts: 3365
Joined: Mon Jan 29, 2007 8:24 am

Post » Thu Mar 31, 2011 9:41 am

Frenzy definitely raises the target's aggression, but if their disposition is high enough towards the player, they won't attack the player. I used it in testing the UOPS changes. I wanted Cingor to attack me (we were both in the FG, so his disposition towards "me" was 100). I successfully cast frenzy, but all I got was him to attack everyone in sight, except "me".

To confirm your conclusions on the scan area, yes it's the square. I recently reduced Oblivion XP's scan area when doing getFirstRef (changed to getFirstRef 69 1 from getFirstRef 69 2) to improve performance. So far I haven't had any issues with the NPC (or creature actually) from being detected. I even cast a targetted fire spell from across a valley and the kill was registered with no issues (the reason Oblivion XP is building an array of NPC's and creatures in the first place).
User avatar
Chris Jones
 
Posts: 3435
Joined: Wed May 09, 2007 3:11 am

Post » Thu Mar 31, 2011 1:19 pm

Frenzy definitely raises the target's aggression, but if their disposition is high enough towards the player, they won't attack the player. I used it in testing the UOPS changes. I wanted Cingor to attack me (we were both in the FG, so his disposition towards "me" was 100). I successfully cast frenzy, but all I got was him to attack everyone in sight, except "me".

To confirm your conclusions on the scan area, yes it's the square. I recently reduced Oblivion XP's scan area when doing getFirstRef (changed to getFirstRef 69 1 from getFirstRef 69 2) to improve performance. So far I haven't had any issues with the NPC (or creature actually) from being detected. I even cast a targetted fire spell from across a valley and the kill was registered with no issues (the reason Oblivion XP is building an array of NPC's and creatures in the first place).


Ok, well I guess with such simple mod like this people will have choose between frenzy and this mod - if a complex system were to be built around just managing this borderline issue, then it maybe could be taken out of the equation with faction/disposition/combattarget crosschecks and effect monitoring, but for me the work is done here. :)

I don′t build arrays either, again felt like an overkill, after all it′s rare that the AI actually even does anything like fighting each other when the area is not loaded (so I′m just looping the loaded area, there′s no performance questions either since the amount of code is so really really few lines, and only once a second).
User avatar
Stacy Hope
 
Posts: 3391
Joined: Thu Jun 22, 2006 6:23 am

Post » Thu Mar 31, 2011 4:46 pm

I have only used a frenzy spell once so far vs pirate ghosts, but they couldn't kill each other due to them wielding normal weapons I presume.
User avatar
Trent Theriot
 
Posts: 3395
Joined: Sat Oct 13, 2007 3:37 am

Post » Thu Mar 31, 2011 9:09 am

I have only used a frenzy spell once so far vs pirate ghosts, but they couldn't kill each other due to them wielding normal weapons I presume.


Hehe, that must been hilarious...well at least those guys have something to do for the rest of the eternity. :P
User avatar
Adam Porter
 
Posts: 3532
Joined: Sat Jun 02, 2007 10:47 am

Post » Thu Mar 31, 2011 4:32 am

Ok, well I guess with such simple mod like this people will have choose between frenzy and this mod - if a complex system were to be built around just managing this borderline issue, then it maybe could be taken out of the equation with faction/disposition/combattarget crosschecks and effect monitoring, but for me the work is done here. :)

I don′t build arrays either, again felt like an overkill, after all it′s rare that the AI actually even does anything like fighting each other when the area is not loaded (so I′m just looping the loaded area, there′s no performance questions either since the amount of code is so really really few lines, and only once a second).


Yeah, your purpose here is a little different than what Ob XP needs to do! I was just wondering if there was an easy way to test for this. I know you can test for an active effect on a character - maybe that would do it. Just test if frenzy is in effect on the npc and return - don't worry about bumping up their disposition. Just a suggestion. This would require OBSE.

I had some issues with NPC battles in my current game, but it was due to Ulrim's Horses! Turns out Ulrim's adds meat to a horse's inventory so you can loot ingredients if you kill them. This seemed to make NPC's attack them and mayhem broke out. Once I realized what was going on, I removed the meat from the inventory of horses - problem solved.
User avatar
Eliza Potter
 
Posts: 3481
Joined: Mon Mar 05, 2007 3:20 am

Post » Thu Mar 31, 2011 8:37 am

Yeah, your purpose here is a little different than what Ob XP needs to do! I was just wondering if there was an easy way to test for this. I know you can test for an active effect on a character - maybe that would do it. Just test if frenzy is in effect on the npc and return - don't worry about bumping up their disposition. Just a suggestion. This would require OBSE.

I had some issues with NPC battles in my current game, but it was due to Ulrim's Horses! Turns out Ulrim's adds meat to a horse's inventory so you can loot ingredients if you kill them. This seemed to make NPC's attack them and mayhem broke out. Once I realized what was going on, I removed the meat from the inventory of horses - problem solved.


This would be possible, but as said then the script would still stop the other NPCs - defending themselves against the raging one - from trying to defend themselves.

Hmm, but yeah I could check if their combat target is in frenzy...hmm...I think I′ll look into this.
User avatar
Rozlyn Robinson
 
Posts: 3528
Joined: Wed Jun 21, 2006 1:25 am

Post » Thu Mar 31, 2011 2:04 am

"All right, a hokerr is on the loose - run!" --> the new AI package to add to the other NPC's :)
User avatar
Hayley Bristow
 
Posts: 3467
Joined: Tue Oct 31, 2006 12:24 am

Post » Thu Mar 31, 2011 7:27 am

It would be more realistic if there was an exception for frenzied npcs so people will fight back against the psycho running about. Though ... hmm, maybe you could have any frenzied npc's victims (from the same faction) make an intelligence or illusion skill check, and if they succeed instead of defending themselves they'll realize their friend is under the influence of a mind-controlling spell. Then they'll either try to run away until it wears off, or cast dispel or calm spells on him if they have any. A high responsibility npc or guard might try to block all his attacks until it wears off to keep him from hurting any innocents.

That's probably way too complicated to implement though.
User avatar
Matthew Warren
 
Posts: 3463
Joined: Fri Oct 19, 2007 11:37 pm

Next

Return to IV - Oblivion