Aller au contenu

Photo

faction attack! ( nonPC fights )


  • Veuillez vous connecter pour répondre
1 réponse à ce sujet

#1
kevL

kevL
  • Members
  • 4 070 messages
So, I've been putting a fair bit of time into identifying and altering NPC reputations logically. noticed that several of the internal faction functions are, not broken but borky. i suggest that if you're inclined to alter reputations, give yourself some debug to see if what you thought happened, really happened. This isn't about changing factions per se, but altering reputations from Friendly to Hostile & vice versa.

Due to quirks, it isn't so important when addressing an NPC's rep vis-a-vis the PC, because the return value of a PC vs. NPC is the same as NPC vs. PC .... Similarly, if you're just doing a good ol' -100/+100 shift things tend to work out.

So ... to the bite. I scratched the top layer of soil off the Companion&Monster AI and drilled out a few core samples. Got the scripts organized in Override. Found the hook points I want in the event scripts. Altered code, wherever needed, to be consistent with what myDebug tells me is actually happening. hey, works great!

here's the settings:
Campaign Editor UsePersonalReputation, FALSE
module Load script: UsePersonalRep, FALSE
faction table customs: Global, TRUE ( edit: FALSE )

so no personal reputation. I can live with that .... here's the situation:
PC attacks commoner, commoner turns red and runs away, defender turns red and jumps in against the PC. Four minutes later a DelayedFunction fires and hostilities cease. ( will put in conditions on that later, right now just using an advance time convo-item ) Now, I've got two different test areas.

The first uses Standard_Factions Commoner & Defender. The second uses Custom factions set the same (or very nearly so) as Commoner and Defender. ( standard commoner has 60 vs PC, custom commoner has 70 vs PC, defenders are at 80 to PC and 100 to both Commoners ). hey, works great ...?

The standard factions do in all my variations. But if I zone out of the area that has custom factions to hit my time advance, my custom factionPigs suddenly regard the PC as a merchant!! well, not a merchant but with the exact same values that they have toward merchants. If, however, the PC remains in the area where the fight is and dodges around long enough to start the advance time dialog, the reputations for custom Commoner and custom Defender vs PC pop up the correct values. Note, if I change my custom factions to standard factions and redo the test it all works hunky dory again!!!

I really don't think it's my scripts because they're designed to not rely on Standard_Factions at all, but to be inclusive of all factions. I'm willing to share my scripts if anyone else is interested in looking at this ...


impromtu update: confirmed it's *not* reading the Merchant rep; adjusted those values in the faction table and custom defenders **still** regard PC as 100 ( should be 0 ), while commoners **still** regard PC as 50 ( should be 0 )

- am looking into Faction.Fac file : It seems odd that nwscript.nss defines standard_factions as 0 to 3 while faction.fac lists the same factions as 1 to 4 ......

- changed custom Globals to FALSE, to be consistent with what I'm seeing in faction.Fac for standard factions; no change.

- Found IT, geez you guys are wonderful :)
'twas my onExit script, doh

#2
kevL

kevL
  • Members
  • 4 070 messages
here's the header, prototypes, & first function of #include file

//------------------
/* kL, reputation quirks ( global, personal not checked )

// how Source feels about Target
GETREPUTATION (oTarget, oSource)

// how Source feels about Target
GETISFRIEND (oSource, oTarget)
GETISNEUTRAL (oSource, oTarget)
GETISENEMY (oSource, oTarget)

// sets how Source feels about Target
// does not work without UsePersonalReputation set TRUE
SETISTEMPORARYFRIEND (oTarget, oSource)
SETISTEMPORARYNEUTRAL (oTarget, oSource)
SETISTEMPORARYENEMY (oTarget, oSource)

NB: GetIsTemporaryF/N/E ...
+ others

// gets how Target feels about Source, adds iAdjustment to it, and assigns the
// new value to Source.
// use kL_AdjustReputation()
ADJUSTREPUTATION (oTarget, oSource, iAdjustment)

*/
//------------------


//___________________
//-------------------
// *** Prototypes ***
//___________________
//-------------------

// this function corrects the fault in AdjustReputation()
void kL_AdjustReputation(object oTarget, object oSource, int iAdjustment);

// determines if oCreature is a member of a PC faction
int kL_GetIsPCFaction(object oCreature = OBJECT_SELF);

// returns the truePC object of faction oCreature
//object kL_GetPC(object oCreature); // not used.

// checks if FactionPig is destroyed ( for testing/debug only ) This is
// only a wrapper for GetIsObjectValid() called in kL_RemoveEnemy()
void kL_PigReport(object oPig);

// reverts reputation to what it was previously. And destroys FactionPig!
//
// Consider doing a test for bSeen = enemy, then don't remove it yet ...
// or is in combat with enemy, and renew the enmity. This should be called
// from only 'kL_MakeEnemy' unless you really know what you're doing:
void kL_RemoveEnemy(object oPig_def = OBJECT_INVALID,
  object oPig_att = OBJECT_INVALID, int iRep_def = -1, int iRep_att = -1);

// turns Neutrals/Friendlies to EnemyReputation ( hostile ), and creates
// a FactionPig to help track the original reputation; note, you need a
// FactionPig blueprint ready, ResRef 'kl_c_faction_pig' -- although the
// default Pig could probably be used as-is.
//
// ( 'gb_assoc_attack' 'nw_c2_default5' 'gb_assoc_spell' 'nw_c2_defaultb' ).
// ( those are onPhysAttacked & onSpellCastAt scripts ) + via 'nw_c2_default4'
// the monster respond to shout section, v. HenchMonRespondToShout()
void kL_MakeEnemy(object oAttacker, object oDefender = OBJECT_SELF);


//__________________
//------------------
// *** Functions ***
//__________________
//------------------

// this function corrects the fault in AdjustReputation()
void kL_AdjustReputation(object oTarget, object oSource, int iAdjustment)
{
  int iRep_source = GetReputation(oTarget, oSource);
  int iRep_target = GetReputation(oSource, oTarget);

  int iDiff = iRep_source - iRep_target;
  iDiff = iDiff + iAdjustment;

  AdjustReputation(oTarget, oSource, iDiff);
}


/ gone fision