Author Topic: How to set the reputation to a new faction?  (Read 332 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to set the reputation to a new faction?
« on: August 02, 2014, 06:02:27 am »


               

I created a faction called neutral that's neutral to all other factions and for the player. I would like to reset the reputation to neutral when the player dead, is possible to do like this?


 


    object oPlayer = GetLastPlayerDied();


 


    if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)

    {

        SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);

    }

    if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)

    {

        SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);

    }

    if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)

    {

        SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);

    }


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
How to set the reputation to a new faction?
« Reply #1 on: August 02, 2014, 07:26:51 am »


               Yes.

Since there is no way to refer to a custom faction directly, a common approach is to create a dummy reference creature in an inaccessible area that no PC can ever visit. In your case, the creature would be faction Neutral and have a unique tag, e.g. FactionNeutral. The plot flag should not be set. If you want to keep the reference creatures for several factions in the same area, remove the scripts and make them immobile so that they can't fight one another.

You can use GetReputation and AdjustReputation to reset the player's reputation with the entire faction to 50, passing the dummy reference creature as an argument.

For non-global factions, I also cycle through the faction members, using ClearPersonalReputation on each one. The Lexicon hints that GetFirst/NextFactionMember is inefficient, but I don't know whether that's true.
               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to set the reputation to a new faction?
« Reply #2 on: August 02, 2014, 11:23:42 am »


               


object oNPC = GetObjectByTag("NeutralFaction");

if(GetReputation(oNPC, oPC) <= 10) AdjustReputation(oPC, oNPC, 50);

Thank you proleric, works well.