Aller au contenu

Photo

Custom Faction - Faction doesn't attack when attacked?


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

#1
OrdinaryMan21

OrdinaryMan21
  • Members
  • 48 messages
Something I've noticed changed from NWN1 to NWN2: Factions don't change to hostile when attacked by a PC.

I have a custom faction set initially to 50. When testing the PC can attack and kill this faction and it won't fight back and its friends won't help either.

Have the campaign setting to attack neutral factions set to TRUE and all factions are Global. Am I doing something wrong?

#2
MasterChanger

MasterChanger
  • Members
  • 686 messages
I had this problem myself when creating a custom faction system. I believe that it may have something to do with the OnPhysicallyAttacked script attached to the NPC, but I'm not positive. I'd say that's a place to start, at least.

#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Like MC said, you could probably just as a few conditionals to make sure you want the NPC to turn hostile when attacked and then use SetStandardFaction() to turn them hostile to the PC.

#4
MasterChanger

MasterChanger
  • Members
  • 686 messages

M. Rieder wrote...

Like MC said, you could probably just as a few conditionals to make sure you want the NPC to turn hostile when attacked and then use SetStandardFaction() to turn them hostile to the PC.


Except you might want to adjust the faction's reputation with respect to the PC rather than changing the faction of the NPC to the Hostile faction.

If you change the faction of the NPC, you risk changing its relationship with respect to other NPCs. Of course, you should construct your faction table so that it doesn't suddenly get jumped by its buddies, but better safe than sorry.

#5
Dann-J

Dann-J
  • Members
  • 3 161 messages
The test module in my Lions, Tigers & Bears submission to the vault has some neutral animals that turn hostile when attacked. There is a standard 'go hostile' script already in the game that works either as an OnDamaged or an OnAttacked script.

I used a similar approach in Isle of Shrines for neutral NPCs, although that was a bit more complex as the script I wrote also turned their nearby allies hostile at the same time.

#6
OrdinaryMan21

OrdinaryMan21
  • Members
  • 48 messages
Just seems kind of strange this isn't standard behaviour.

I see an option in DMFI to turn an entire area hostile or to the commoner faction. Also see the option to make a selected NPC hostile. But it runs into the same issue that MC pointed out, he'd get jumped by his buddies in some situations.

Perhaps there's a part of DMFI I'm missing? Seems like a DM would like to give his players the freedom of choosing who to consider a friend and who an enemy by having an adjust reputation command in the DMFI toolset without the need to prescript it in a conversation? Mmm...

Modifié par OrdinaryMan21, 30 janvier 2012 - 04:09 .


#7
OrdinaryMan21

OrdinaryMan21
  • Members
  • 48 messages
Welp. decided to go with the following script added to a book through a conversation. It'll list all the factions and I simply choose *Make PC friends with X", Make PC enemies with X". All converation options. Ill need to create a limbo type area to store an NPC that belongs to each faction and reference it with the following script:

void main(object oPlaceholder,int oModified)
{

AdjustReputationWithFaction(GetFirstPC(1),oPlaceholder,oModified);

}

Basically in each conversation node I load the script as an action and place values for oPlaceholders and oModified which is the NPC with the faction I want to modify and the oModified being -100 or 100.

Problem is the script compiles but when I load it to my conversation and put it in an action node it crashes the client. Any ideas? Or more elegant solutions?

#8
MasterChanger

MasterChanger
  • Members
  • 686 messages
The general solution is to use faction pigs -- that is, to create blueprints for NPCs of the factions in question that are script-hidden. For some reason, it's traditional to use pigs. Just because it's funny, I guess. :)

Regarding your particular script, I have not found a function called AdjustReputationWithFaction, just AdjustReputation (takes the same parameters you specify).

#9
OrdinaryMan21

OrdinaryMan21
  • Members
  • 48 messages
http://www.nwnlexico...ithfaction.html

Difference between this one and AdjustReputation is the first is party-wide, and the latter is one PC-specific. It appears for me in the toolset when I attach the include script, and unless its deprecated or non-functioning appears to have a full description and entry.

My problem is not compiling, but instead attaching to a conversation node (in a DM-only book) as it crashes the toolset.http://social.bioware.com/forum/1/topic/172/new_post/9107436 as soon as I hit "refresh" to add the variables being passed onto the script.

#10
MasterChanger

MasterChanger
  • Members
  • 686 messages
Ah, the function you are using is in the include file X0_I0_PARTYWIDE. That's fine.

If you wrote your script to fire from a conversation node, I have an idea about what might be causing your problem.

void main(object oPlaceholder,int oModified)

I'm not much of a conversation-node scripter. That being said, I'm not sure how you would pass an object from a convo node. A tag (as a string) would be fine, or you could identify the placeholder through script and save it as a local variable on some object you can retrieve.

When I wanted to give DMs faction-adjusting power, I created a wand (not too different from a book) that they would point at a target creature. Then I scripted a GUI (which is more advanced than a convo, to be sure) that would give them the options they wanted. In theory, you could just have a target designated when your DM pointed the widget, and then give them the faction options in text. For example:

"You have selected player <playername>. With which faction would you like to adjust <his/her> reputation?"
--DM choose faction--
"By how much?"
--DM chooses +/- amount--
"Done!" --fires adjustment script--

#11
OrdinaryMan21

OrdinaryMan21
  • Members
  • 48 messages
Thanks for the helpful reply. I guess the problem here is I should be doing:

void main(string sPlaceholder,int oModified)
{
AdjustReputationWithFaction(GetFirstPC(1),GetObjectByTag(sPlaceholder),oModified);
}

Ideally, as you say, identifying the PC with a Wand might be better in case for whatever reason there are multiple groups around and GetFirstPC tags the wrong group. Im going to see if I can fiddle with this when I get back home :)

#12
OrdinaryMan21

OrdinaryMan21
  • Members
  • 48 messages
Having a bit of trouble with the script. Set up the faction pigs as suggestion, a Wand that starts a conversation that passes the Pig's Tag as well as either 100 or -100 integer.

Here's the script:

#include "X0_I0_PARTYWIDE"

void main(string sPlaceholder, int iValue)
{
object oTarget = GetItemActivatedTarget();
object oFactionPig = GetObjectByTag(sPlaceholder);

if (GetIsObjectValid(oTarget) == TRUE) {
AdjustReputationWithFaction(oTarget,oFactionPig,iValue);}
}

The campaign setting USEPERSONALREPUTATION is set to TRUE. All set. Yet the Wand does nothing when used.

I cry.

Modifié par OrdinaryMan21, 06 février 2012 - 03:13 .


#13
MasterChanger

MasterChanger
  • Members
  • 686 messages
To debug, start by verifying that all your variables are known within the script. Have it send you a message telling you what it thinks the values of sPlaceholder and iValue are.

Then double-check that it finds oFactionPig successfully.

I can't see anything obvious mis-coded in your script, but there's a chance it's receiving bad info from elsewhere (like maybe the string passed by the convo doesn't exactly match the pig's tag).

#14
OrdinaryMan21

OrdinaryMan21
  • Members
  • 48 messages
Thanks for the tips MasterChanger, did just as you recommended. The problem was actually that the FactionPigs were PLOT.

All future Pig users. Repeat after me: FACTION PIGS CANNOT BE PLOT.

Now on to my Baaz death script.. mmm...

#15
The Fred

The Fred
  • Members
  • 2 516 messages
Weird. I don't know why that should happen.

#16
kevL

kevL
  • Members
  • 4 070 messages

OrdinaryMan21 wrote...

Something I've noticed changed from NWN1 to NWN2: Factions don't change to hostile when attacked by a PC.

i noticed that too, so did a lot of others on the old Bioware board



I have a custom faction set initially to 50. When testing the PC can attack and kill this faction and it won't fight back and its friends won't help either.

I've determined that this is a result of UsePersonalReputation=FALSE under Campaign Editor settings (regardless of the seemingly redundant setting CAMPAIGN_SWITCH_USE_PERSONAL_REPUTATION in the moduleLoad script, or whether the attacked faction is custom or standard)



Have the campaign setting to attack neutral factions set to TRUE and all factions are Global.

same.



Am I doing something wrong?

imo, they made it so we can't do it right. While setting the campaign switch in the editor to TRUE will set neutral & friendly factions aggro, when attacked ( and, btw, enable Defenders to come to their aid! ), this setting also causes players to necessitate a manual attack sequence on creatures that are already Faction_Hostile -- companions eg won't auto-attack in AI-On mode, and Hostiles will appear blue instead of red on mouseovers in both AI & Puppet modes.

Functions from NwN that use personal reputation don't seem to work when PRep is set FALSE in NwN2. Like, SetIsTemporaryEnemy( ), so i just finished restructuring the primary OnPhysAttacked and OnSpellCastAt scripts to mimic that for GlobalRep. It seemed easier than trying to tell companions et al, 'yeah, that Ogre really is hostile bud' ... but i still haven't decided what to do such that Defenders will jump into the fray when their wards get attacked

EDIT, gonna try using "shouts" ....


MasterChanger wrote...

I had this problem myself when creating a custom faction system. I believe that it may have something to do with the OnPhysicallyAttacked script attached to the NPC, but I'm not positive. I'd say that's a place to start, at least.

MC, i Believe it's not so much the onAttacked scripts as it deals with personal reputation settings. If you remember my findings from this thread, re. Factions & Custom Factions -- the main result I was getting seems to have been caused by GetReputation parameters reversed (in the nwscript description), but what actually fixed that issue was that when changing the module into a campaign I set UsePersonalReputation=TRUE

but i no longer want to do that since it means giving manual orders to attack against every goblin group ya meet ....


ps. My changes to the onAttacked scripts do a check for IsEnemy before adjusting reputation: my debug tells me that the engine itself is turning neutrals/friendlies aggro *before* getting to that check (when campaignPRep is true, when campaignPRep is false they would just stand there getting pounded on, aarg)

Modifié par kevL, 23 mai 2012 - 07:18 .