Aller au contenu

Photo

re. Factions & Custom Factions


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

#1
kevL

kevL
  • Members
  • 4 074 messages
This should get a chuckle somewhere out there ..

Imagine you're trying to get Defenders to protect the Commoners and no matter how hard you script-fu, it just aint happening. Then say you're working in single module mode (not Campaign) and the debug code ends up double the size of real code. Just before you do the keyboardface-thing, aha! you notice a pattern

i can say for certain that - when in single module mode with any custom factions marked global only - the faction table reads backwards. Solution: just don't do it. This seems yet another reason to work in Campaign mode only. (Preferably with UsePersonalReputation flagged TRUE)

Really, I didn't check the global and UPR flags, but did check the single vs. Campaign modes, the former exhaustively. Campaigns read the Faction table fine (left column is how NPC feels about top row), while single module mode reads the faction table as how top row feels about left column (excluding Player column exclusively)


* This may have repercussions for people building in single mod mode, for later integration into a Campaign (hint hint) *


ps. this may be ' just me ' but after setting up a faction table with unique values in each entry and doing extensive ( how xNPC feels about yNPC ) etc.

#2
MasterChanger

MasterChanger
  • Members
  • 686 messages

kevL wrote...

i can say for certain that - when in single module mode with any custom factions marked global only - the faction table reads backwards. Solution: just don't do it. This seems yet another reason to work in Campaign mode only. (Preferably with UsePersonalReputation flagged TRUE)

Really, I didn't check the global and UPR flags, but did check the single vs. Campaign modes, the former exhaustively. Campaigns read the Faction table fine (left column is how NPC feels about top row), while single module mode reads the faction table as how top row feels about left column (excluding Player column exclusively)


The table reads backwards in what way? How X feels about Y is really how Y feels about X? Global reputations aren't? Custom factions were an issue of concern for me in the past so I want to make sure I understand what you're saying.

#3
kevL

kevL
  • Members
  • 4 074 messages
hi MC,
I'm not sure about Global reputations & Personal reps and how these affect things. I mention them simply to say they could be involved.

What I did, and remember this is a single module (not a Campaign setup, which wasn't tested more than a couple of entries) was place code such as the following in various NPCs' OnPhysicallyAttacked events:


object oPC = GetLastHostileActor();

object oDefendPig = GetObjectByTag("kl_defender_pig");
object oCommonPig = GetObjectByTag("kl_commoner_pig");

int iTestRep = GetReputation(oDefendPig, oPC);
SendMessageToPC(oPC, "Defender vs PC = " + IntToString(iTestRep));
iTestRep = GetReputation(oCommonPig, oPC);
SendMessageToPC(oPC, "Commoner vs PC = " + IntToString(iTestRep));

iTestRep = GetReputation(oDefendPig, OBJECT_SELF);
SendMessageToPC(oPC, "Defender vs Self = " + IntToString(iTestRep));
iTestRep = GetReputation(OBJECT_SELF, oDefendPig);
SendMessageToPC(oPC, "Self vs Defender = " + IntToString(iTestRep));
iTestRep = GetReputation(oCommonPig, OBJECT_SELF);
SendMessageToPC(oPC, "Commoner vs Self = " + IntToString(iTestRep));
iTestRep = GetReputation(OBJECT_SELF, oCommonPig);
SendMessageToPC(oPC, "Self vs Commoner = " + IntToString(iTestRep));


Along with that - and much more of the like (in fact it cycled through every creature in the room spitting out Reps) - I changed every entry in the Faction table to unique integers from 11 to 20 for the Hostile row and column, and around 76 to 100 for the other Standard Factions as well as two custom factions that I'd added previously. I left the custom factions marked as Global (and later noticed there is a switch at the end of x2_mod_def_load as follows:

// A flag that reflects the engine setting for whether or not we use personal reputation; this is a consideration in spell targeting
// BMA-OEI 11/14/2006: Defaulted TRUE to enable spell targetting neutral PC associates (nw_i0_spells)
SetGlobalInt( CAMPAIGN_SWITCH_USE_PERSONAL_REPUTATION, TRUE );

but I did not test that and it might well be obsolete. Does it work for single module, does it work for Campaign setups, hmm idk) But I really did walk around among a room full of Defenders, Commoners, Merchants, a Hostile (set not to attack, as noted), as well as my two custom factions, kL_Defender & kL_Commoner. Then I took a swing at each one. The onPhysAttacked script fired and spat out numbers, that I referenced against the Faction table. And every entry was entirely consistent with

How X feels about Y is really how Y feels about X?

yes. Only the Player column remained as expected ..


am i crazy? i sure felt crazy

#4
kevL

kevL
  • Members
  • 4 074 messages
here's the code that was doing the actual work, along with extensive debugs, again in the onPhysAttacked script:

object oNPC = GetFirstObjectInArea();
while (GetIsObjectValid(oNPC))
{
  //debug
  SendMessageToPC(oPC, "................ in Valid(oNPC) loop : ( " + GetTag(oNPC) + " )");
  if (GetObjectType(oNPC) == OBJECT_TYPE_CREATURE && !GetIsPC(oNPC)
    && !GetFactionEqual(oNPC, oPC) && !GetIsOwnedByPlayer(oNPC) && !GetIsRosterMember(oNPC))
  {
    int iReputation_self = GetReputation(oNPC, OBJECT_SELF);
    //debug
    SendMessageToPC(oPC, "> in OBJECT_TYPE_CREATURE");
    SendMessageToPC(oPC, "> iReputation vs oSelf = " + IntToString(iReputation_self));
    int iReputation_Pc = GetReputation(oNPC, oPC);
    //debug
    SendMessageToPC(oPC, "> iReputation vs oPC = " + IntToString(iReputation_Pc));
    if (iReputation_self > 89 && iReputation_Pc > 10)
    {
      //debug
      SendMessageToPC(oPC, ">> in iReputation");
      AdjustReputationWithFaction(oPC, oNPC, -iReputation_Pc);
      DelayCommand(300.0f, AdjustReputationWithFaction(oPC, oNPC, iReputation_Pc));
      //debug
      iReputation_Pc = GetReputation(oNPC, oPC);
      SendMessageToPC(oPC, ">> iReputation vs oPC = " + IntToString(iReputation_Pc));
    }
  }
  oNPC = GetNextObjectInArea();
}

As you can see this quickly gives the exact entry of how every faction feels about every other faction in the room, simply by walking around and taking a swing at them. If someone wants to take the code and repeat the process, hey feel free - but i'm never working in single mod mode again

EDIT, on a happy note, once I switched the module to Campaign .. i just got rid of all this extravagance since everything jimmed itself right into place as I'd wanted in the first place

Image IPB

Modifié par kevL, 25 mars 2011 - 04:40 .