Another FACTION Question (STILL BROKEN!)

Just when I think I am resolved of all module issues, my wife finds another. This time a problem similar to something that happened before, but something I would like to understand better. Here is the issue …

  1. I have a monster which starts as “NEUTRAL” faction (my own named faction), which is set as 50 towards the PLAYER and 50 towards HOSTILES.

  2. This works fine to begin with, and allows the players to speak with the monster, while also not being attacked by the HOSTILE faction creatures.

  3. Next, HOSTILE faction monsters spawn nearby and the PCs attack these newly spawned hostile creatures.

  4. The first monster remains NEUTRAL but after a few rounds of the PCs attacking the nearby HOSTILES, this NEUTRAL monster has a sudden REPUTATION drop with the players and becomes hostile to them while remaining NEUTRAL faction. This sudden reputation change thereafter breaks further NEUTRAL reliant faction contacts.

OBSERVATIONS

  1. I don’t believe the attack has been triggered by anything I have scripted, but I am going to go through the code to double-check all potential “attack” issues just in case.

  2. It may also be something to do with proximity, as I have not always experienced the issue. It appears to occur if the players attack creatures near to this NEUTRAL creature. Does it witness the attacks and have a reputation change in favour of the hostiles?

  3. I have not yet been unable to change the reputation back using ClearPersonalReputation or even appear to adjust it back into favour using AdjustReputation. (I will keep investigating this, as I have managed to do something similar before.)

So, does anyone have a better understanding of what may be happening here?

1 Like

Could it be something related to the UsesPersonalReputations campaign parameter?

The comment (in French for me) states that creatures might be prone to local modifiers in front of specific creatures.

I always set it to False. Like you, I use a ‘NEUTRAL’ faction and never experienced this issue

If you need the parameter set to TRUE, maybe setting a NEUTRAL2 faction to 100 towards the player? Or using AdjustReputation every round would do?

2 Likes

@Claudius33

Thanks for answering … :slight_smile:

Yes, my campaign setting is set to FALSE too.

I never experienced it until recently.

This is what I am considering if I cannot find the direct cause.

This no longer appears to work for this situation. Really weird.

1 Like

Weird indeed. Something in your override that plays with factions?

1 Like

@Claudius33

No. My override is empty.

In debug feedback, (while combat with other creatures is taking place), the NEUTRAL creature suddenly switches from 100 reputation with PCs (friendly) to 0 (enemy).

The faction remains unchanged (as NEUTRAL), but now the entire NEUTRAL faction is “bugged” to enemy status with the PCs, meaning all future NEUTRAL encounters attack the PCs on sight. Not good at all. (I have pulled my module from download until I can sort it.)

1 Like

I’m afraid I’m running out of ideas. Does the neutral creature use standard script only?

@Claudius33,

No, I do have very heavily modified AI scripts for all creatures. And there is a lot of checks going on.

Yet, even when I comment much of these areas out, I am still having the same result.

I am considering setting up a default environment to see if it still happens. i.e. With default scripts and just this faction difference.

When fighting the hostile creatures, did you (or the companions) use some AoE spells? A fire ball exploding near a neutral creature (depending on the difficulty level though) will turn it into retaliation mode :wink:

@4760

I did consider this as a possibility myself. But then I had the monster turn “enemy” even from close to the start of the combat when I did not notice any AoE happening at that time.

Furthermore, I have a function CheckInitialAggro that determines the reaction of a creature taking any damage from anywhere. This creature is among those that should ClearAllActions. However, I am now considering that the personal reputation may still be affected and will look at addressing that here too.

I will try that and report back.

1 Like

PersonalReputation, for whatever hairbrained reason, can be “set” (scare quotes) in the Campaign properties, in the Module OnLoad (x2_inc_switches), and right on the faction table …

make sure they’re all off.

 
try removing all ai-scripts from the NEUTRAL’s scriptslots and see what happens. Then add your ai-scripts back one at a time until it goes aggro. Running a console script on each test could help

5 Likes

@kevL_s.

Yes, all off, even in FACTION tables. :slight_smile:

I am working along these lines at the moment. I “think” it may be related to a companion perception script. I am double checking that now, by commenting various sections. Somewhere here, I think I am turning the creature hostile, which in turn may be affecting the entire faction. It’s almost as bad as tracing that bitwise stuff. :wink:

EDIT: And the answer to my “thought” is … nope! :woozy_face:

2 Likes

Hi All,

@Claudius33
@4760
@kevL_s

This looks helpful (maybe for NWN2 too):

And it does refer to “witnesses”, which makes me think the faction reputation is changing due to witnessing combat/kills of creatures with which they are neutral as well.

Quote: “So you disable the Global checkbox but this isn’t necessarily going to fix everything because of how witnesses affect their personal reputation. You can still get a large amount of attention. The AI comes and responds to friends asking for help and will rapidly become personally hostile themselves.”

And a comment from here:

That says, “Feeling friendliness to a creature will cause an immediate drop in personal reputation towards anyone who is seen attacking that creature, resulting in hostility towards the attacker.”

So, maybe there is a little of this going on? i.e. The creature is equally as friendly to the “hostiles” as it is towards the PCs. Therefore, eventually (it does appear random), there is the possibility that the creature eventually acts as though the PCs are the aggressors and turns hostile towards them, bringing the whole faction along with it.

quick note before i doze off …

Did you try removing the NEUTRAL’s OnDialog script? it might be responding to a (silent) SHOUT_ATTACK_MY_TARGET or similiar …

@kevL_s,

Yes, I did a campaign script check search for that and I do have it a creature’s OnSpawn script as a switch.

I also looked for NW_ATTACK_MY_TARGET, which (apparently) can also adjust reputations. I only have this on a creature’s OnDeath script - so I may look into this a bit more.

At the moment, I am looking at trying to adjust the NEUTRAL reputation with the player at every turn possible, but it may not be enough if a sudden -100 bombs my creature and the whole thing starts attacking before I can adjust it back.

I may have to completely rewrite this area of code. Although, I am a little nervous because it says in that link that a plot creature does not have any changes, but my NEUTRAL faction pig, which is plot, does still change! :astonished:

This looks considerably more difficult (serious) than I first anticipated. :woozy_face:

@Claudius33
@4760
@kevL_s

EDIT: OK, I have made a breakthrough updating my own function that checks the attacks on a creature with the following code, which appears to help towards the issue:-

// KEEP NEUTRALS NEUTRAL
		
		object oNEUTRAL = GetObjectByTag("SETFACTION_NEUTRAL");
		object oPlayer = GetAPlayer();
		AdjustReputation(oPlayer, oNEUTRAL, 50);	
		
		if(GetFactionEqual(oNEUTRAL, oNPC))
		{			 
			ClearPersonalReputation(oPlayer, oNPC); 
			AdjustReputation(oPlayer, oNPC, 50);
		}	

This resets the reputation with the faction pig and the current creature who forced the faction change, due to “witnessing” nasty combat nearby with whom the creature had as much “allegiance” to (50/50) as the PCs.

This is quite a nasty “bug” in my opinion, as it means the OC AI appears to be adjusting the reputation of a whole faction at the witness of one creature! And that is with all “globals” set to FALSE.

I may even tempted to alter the repadjust.2da, which appears to dictate the amount by which the reputations are adjusted according to an attack, kill or theft. However, I will play test with the scripted readjustments for now and see how that pans out.

Bottom line: Factions do appear to alter even beyond the normal expectations due to some “witnessing”. At least, that is how it appears to me, unless I do find some rogue piece of code somewhere. I will let you know. Also, if anyone can also confirm this “auto adjustment” when witnessing a combat, do let me know. As a heads up, the change may not happen immediately, and may take some rounds to “trip” the change. The point is, the longer the combat within the vicinity of the NEUTRAL, the more likely its witnessing of combat, the more likely it will change. At least, in my testing.

EDIT: This small additional adjustment spread throughout various places (inc heartbeats) managed to keep the factions in check, even if there was the very occasional threatening posture that drew the attention of the PCs on the odd occasion. It worked well for my needs. Importantly, the NEUTRAL faction integrity was maintained within a heartbeat (if compromised), meaning all later faction checks were fine. (You never actually see the creature turn hostile - red.)

3 Likes

Thanks for your insight!

1 Like

Hi All

So I just stumbled on this in nw_i0_generic while looking for something to solve my cross area walkway points issue. The function RespondToShout under case 5 “Attack My Target” causes a -100 reputation shift. I didn’t dig in too closely to see under what specific circumstances this fires, or what other scripts call this function, but since nw_i0_generic is the main include for combat and is included in lots of other stuff ( I wish it were easier to find every script that includes a specific include), seems like it might be where Lance’s issue is coming from. Also, nw_i0_generic does not include the exact text “NW_ATTACK_MY_TARGET” which would explain why his global script search did not lead him here.

Hope this helps.

1 Like

Hi All,

@kevL_s
@ChuckerIINO

OK, this is becoming a very difficult issue to fix.

The problem I have is that I cannot seem to be able to “maintain” factions or “reset” them after two other factions witness events of the players. When I fix one set of factions, it appears to break another set.

i.e. I managed to ensure “NEUTRAL” stayed neutral to the PCs even if neutrals witnessed PC attacking HOSTILES. However, to do this, it seems that another faction breaks that is friendly to NEUTRALS & HOSTILES, in that by forcing neutrals to remain friendly, a faction that should remain enemies to the PCs ends up turning friendly to the PCs too!

This is a seriously difficult problem. Even trying to clear reputations and adjusting does not appear to work here now.

I believe I may have to look at rearranging factions even more than I currently have them, but it is a real headache trying to work out. Any advise welcome!

@Lance_Botelle Could you post a screenshot of your factiontable?

@kevL_s

Sure …

The problem …

PCs attack creature (HOSTILE FACTION) and a witnessing NEUTRAL faction eventually switches to hostile to PCs, turning whole NEUTRAL faction “hostile” to PCs. So, I added the “neutral fix”, but found the ANTIPARTY faction now also turns “friendly” to the PCs.

Even with adjustments in place, I get this … Set ANTIPARTY to xPC should be 0 (zero).

I have tried adding this to a monster heartbeat to bring it back to “hostile” to PC:-

//////////////////////////////////////////////////////////////////////////////////////////////
	// KEEP NEUTRALS NEUTRAL (NEUTRAL FACTION FIX 08/04/21)
	//////////////////////////////////////////////////////////////////////////////////////////////
	
	object oANTIPARTY = GetObjectByTag("SETFACTION_ANTIPARTY");
	object oNEUTRAL = GetObjectByTag("SETFACTION_NEUTRAL");
	
	// DO NOT RESET CONTRUCTS NEUTRALITY
	if(GetFactionEqual(oANTIPARTY, OBJECT_SELF))
	{			 
		ClearPersonalReputation(oPlayer, OBJECT_SELF); 
		AdjustReputation(oPlayer, OBJECT_SELF, -100);
		
		ClearPersonalReputation(oNEUTRAL, OBJECT_SELF); 		
		AdjustReputation(oPlayer, oNEUTRAL, 50);	
	}	

why does Defender feel only 50 to Commoner (neutral, won’t assist), while Commoner feels 100 to Defender (allied, will assist)

wouldn’t you want those reversed?

we both know that’s not a solution …

weird …

Personally im convinced there’s some truly borked stuff going on between nonPC factions in nwn2. But it should only happen between nonPC factions … that is, PC vs NPC reputations aren’t affected

I still think you should remove all ai-scripts from one of the ‘offenders’ so he doesn’t do anything … and run debug scripts from the console to check all factions … did i give you that script yet?

 
i believe atm that the only way that reputation can change is by scripting … i don’t think that the engine (hardcode) changes reputations … (?)