Author Topic: HELP -- Need to Know If I Read This Function Right  (Read 324 times)

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
HELP -- Need to Know If I Read This Function Right
« on: August 21, 2012, 09:42:41 pm »


               I need to know if I'm reading this function right - its commented out in nw-o0_death, but I think its perfect for what I need with resetting custom factions to base reputation...


void ClearAllFactionMembers(object oMember, object oPlayer)
{   
    AdjustReputation(oPlayer, oMember, 100);
   
    object oClear = GetFirstFactionMember(oMember, FALSE);   
    while (GetIsObjectValid(oClear) == TRUE)
    {       
         ClearPersonalReputation(oPlayer, oClear);
         oClear = GetNextFactionMember(oMember, FALSE);
    }
}


If I read this correctly, it basically makes oMember "friendly" (100) to oPlayer then loops through oMember's factions and resets the faction's personal reputation in regards to oPlayer back to its baseline value.

For example, oMember's faction is "neutral"  (50) towards oPlayer. oPlayer accidently hits oMember with a fireball, making oMember's faction hostile towards oPlayer. However, this function is called from oMember's OnSpellCastAt Event - setting the personal reputation of oMember to 100 regarding oPlayer. Then it loops through oMember's faction, restoring oMember and all other faction members back to the original reputaion of 50 regarding oPlayer. So everything is all peaceful again???

               
               

               


                     Modifié par Pstemarie, 21 août 2012 - 08:43 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
HELP -- Need to Know If I Read This Function Right
« Reply #1 on: August 21, 2012, 10:23:34 pm »


               That function is explained about half way down in the Factions, Shouts and Attacking My Enemy tutorial.
               
               

               


                     Modifié par Lightfoot8, 21 août 2012 - 09:25 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
HELP -- Need to Know If I Read This Function Right
« Reply #2 on: August 21, 2012, 10:46:48 pm »


               Thanks Lightfoot, that answered it - this function is exactly what I was looking for to reset my custom factions when needed.

My module has a variety of glowing orbs (modified will-o-wisps) that flit around for atmosphere. I've given them a custom faction that is "neutral" to all the other factions, but they sometimes get caught up in AOE spells and go hostile. I just needed a function for their event scripts that would reset the faction back to neutral.