Aller au contenu

Photo

Script for setting faction/faction relationship during game play??


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

#1
Groove Widdit

Groove Widdit
  • Members
  • 383 messages
Hello. Is there a way to set the relationship between diferent faction programmatically during game play? I know, obviously, how to do this in the toolset, but doing it with a script would fix a lot of issues for me. This topic may overlap with my other one, if the solution for the door-bludgeoning is to set the NPC's faction to hostile with the PC. I appreciate the help. Thanx!

#2
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
For standard factions: SetStandardFactionReputation()
For custom factions: AdjustFactionReputation()

More information: NWN Lexicon on Reputation and Faction Functions

#3
henesua

henesua
  • Members
  • 3 879 messages
The typical way to do this is to have a few creatures in an area that are out of play and to target these creatures with the faction adjustments.

The trick:
each creature has no AI scripts. Delete them all.
each creature has one of the custom factions.
each creature is tagged with the name of the custom faction they belong to
none of these creatures should be targeted with plot, and none of them should be able to see one another (although without any AI scripts this probably doesn't matter)

then when you want to adjust a faction's reputation relative to another or to the PC:
search by tag for the faction name
adjust reputation

#4
Groove Widdit

Groove Widdit
  • Members
  • 383 messages
Ah. Yes. This is perfect.

#5
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
There's a simple example of the faction focus concept that henesua talk about on the AdjustFactionReputation() page I linked. For a more robust implementation, though, you might consider using Personal Reputation and Reaction. It also has scripts that have guards protect doors and chests (much better than the simple one I posted on the other thread).

#6
Groove Widdit

Groove Widdit
  • Members
  • 383 messages
I can't get it to work. It's compiling okay, but the Dojo isn't going hostile when I attack the door. I know there's no PC faction. Here's what I'm trying to do:
#include "nw_i0_plot"
void main()
{
// Get the faction focus objects
object oPC = GetObjectByTag("Faction_Focus_PC");
object oDojo = GetObjectByTag("Faction_Focus_Dojo");

// Get how the PC and Dojo feel about each other now.
int nReputationWithPC = GetReputation(oDojo, oPC);
int nReputationWithDojo = GetReputation(oPC, oDojo);

// Get how the PC should feel about the Dojo and vice versa. This
// info is set by any script that persistently adjusts how the factions feel
// about each other.
int nStoredReputationWithPC = GetCampaignInt("MyCampaign", "Reputation_PC_Dojo");
int nStoredReputationWithDojo = GetCampaignInt("MyCampaign", "Reputation_Dojo_PC");

// Adjust the reputations to the desired values.
AdjustFactionReputation(oDojo, oPC, nStoredReputationWithPC - nReputationWithPC - 100);
AdjustFactionReputation(oPC, oDojo, nStoredReputationWithDojo - nReputationWithDojo - 100);
}

#7
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
What the example is doing is adjusting how those factions feel about each other based on a persistently stored value. It's the sort of thing that might run OnModuleLoad. For an OnPhysicalAttacked script, you'd wanna do the following:

void main()
{
    // Get the PC and Dojo faction focus object
    object oPC   = GetLastAttacker();
    object oDojo = GetObjectByTag("Faction_Focus_Dojo");

    // Adjust how the Dojo feels about the PC
    AdjustReputation(oPC, oDojo, -100);
}

Note that we don't get a faction focus for the PC. We just get him instead.

Modifié par Squatting Monk, 16 juin 2013 - 02:30 .


#8
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
EDIT: double post :blink:

Modifié par Squatting Monk, 16 juin 2013 - 02:26 .


#9
WhiZard

WhiZard
  • Members
  • 1 204 messages

henesua wrote...

The typical way to do this is to have a few creatures in an area that are out of play and to target these creatures with the faction adjustments.

The trick:
each creature has no AI scripts. Delete them all.
each creature has one of the custom factions.
each creature is tagged with the name of the custom faction they belong to
none of these creatures should be targeted with plot, and none of them should be able to see one another (although without any AI scripts this probably doesn't matter)

then when you want to adjust a faction's reputation relative to another or to the PC:
search by tag for the faction name
adjust reputation


Couldn't you also do this with placeables?

#10
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
No, unfortunately. AdjustReputation() does not work with placeables.

#11
Groove Widdit

Groove Widdit
  • Members
  • 383 messages
I still can't get it to work, Monk. Is there a header file?

#12
BelowTheBelt

BelowTheBelt
  • Members
  • 394 messages
Quick question... How does the plot setting on the NPC faction creatures affect the custom factions?

#13
Squatting Monk

Squatting Monk
  • Members
  • 446 messages

Groove Widdit wrote...

I still can't get it to work, Monk. Is there a header file?

No, you don't need to include anything. Here's a simple demo. Notice that when you attack the door, both the faction focus and the member of the faction go hostile. (Though neither of them will attack you, since they do not have scripts assigned making them do so).

BelowTheBelt wrote...

Quick question... How does the plot setting on the NPC faction creatures affect the custom factions?

IIRC, both the plot and immortal flags stop this from working. This is why it's important to keep your factions focuses isolated and unscripted. Don't want them killing each other.

#14
Groove Widdit

Groove Widdit
  • Members
  • 383 messages
Okay, I got it to work. Thanks guys. It took some experimentation to figure how to get an isolated custom creature set up right, but it does now work. This is crucial to my dungeon.

#15
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
 For another way of handling when your door is attacked, you may want to loot at the  Simply Stealing   thread. 

#16
Groove Widdit

Groove Widdit
  • Members
  • 383 messages
That's helpful. I can also use it for something else I'm working on.