Aller au contenu

Photo

Problems with SetIsTemporaryEnemy


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

#1
diophant

diophant
  • Members
  • 116 messages
When betatesting my mod, I realized that making NPCs hostile by script doesn't work any more. Basically, I'm using: SetIsTemporaryEnemy(oPc);
SetIsTemporaryEnemy(OBJECT_SELF, oPc);
DetermineCombatRound(oPc);
The NPC attacks, but the standard action on him remains "Talk". If I run away, he stops attacking after one (or two?) combat rounds.
I'm sure it used to work (maybe with an earlier patch), and I triple-checked that personal reputations are enabled in the campaign settings.
Is SetIsTemporaryEnemy broken, and what are the best workarounds? If possible, I do not want to change the NPCs faction to hostile, because then his friends will help me and not him. Furthermore, I want to avoid to create new factions, because I already have too much factions.

#2
kevL

kevL
  • Members
  • 4 078 messages
unfortunately, doing anything more than simple things with factions in NwN2 is thoroughly borked.

When you set the Campaign flag (campaign options or module load script) to use PersonalReputation you'll probably find that companions no longer attack hostiles without being given a manual command to do so. But then when you turn off PersonalRep, once-handy functions like SetIsTemporary* no longer work.

I spent a significant amount of time trying to work through the problems and ended up customizing a half dozen coreAI scripts (which i won't distribute because they haven't been well tested and could conceivably make things worse). Basically they involve using GlobalReputation and the AdjustReputation function to alter how factions feel about other factions. But i also found that the parameters of several reputation functions are reversed, when used to adjust how nonPC factions feel about other nonPC factions. Fortunately they seem to work okay when dealing with the PC faction due to further quirks of the engine.

i think most NwN2 designers go with setting FACTION_HOSTILE, or use AdjustReputation and cross their fingers


ps. there's a better function that supercedes DetermineCombatRound()
-> HenchDetermineCombatRound()


To the point: i know what you're talking about NPCs that just stand there getting wailed on; I forget exactly what causes that, but iirc setting reputations to global (everywhere, the faction table, the module load script, the campaign settings) sets things to rights again -- except there's no more personal reps .......

/something like that

#3
diophant

diophant
  • Members
  • 116 messages
Thanks for the reply. I'll do some experiments tomorrow, just to see what's the best I get out of this mess.

#4
diophant

diophant
  • Members
  • 116 messages
I finally found the time to implement a workaround that is sufficient for me.
I store the current faction reputation on the faction leader, make the whole faction hostile, and reset the faction reputation to the stored value in the onExit script of the area.

The effect of the workaround is convenient. The NPC and all his friends get hostile, but if I leave the area, his faction is neutral (or whatever it was) again. Of course, if I return, the NPC has forgotten his anger.

Btw., Set/GetFactionLeader seems to be broken, too. Thus, the faction leaders are fixed in my mod (hanging around in an unaccessable control area), and I wrote my own GetFactionLeader function.