Aller au contenu

Photo

Kill all in a faction function help


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

#1
prokat

prokat
  • Members
  • 2 messages
Hi all-
I'm trying to write a function that will kill all of an object's faction.  Here's what I have:

void KillTheFaction(object oMember)
{
    object oTarget = GetFactionLeastDamagedMember(oMember, FALSE);
    while(GetIsObjectValid(oTarget))
    {
          ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(GetCurrentHitPoints(oTarget)), oTarget);
         oTarget = GetFactionLeastDamagedMember(oMember, FALSE);
    }
}

It receives oMember who belongs to a faction.  Then cycles through all members of that faction and kills them by reducing the HP to zero until it runs out of objects that belong to that faction.

It either doesn't totally work, does work (rarely), or crashes nwn.  I'm not sure what's wrong but hopefully you can help.  If there's an easier way to do this, please suggest it.  Thank you!

Modifié par prokat, 31 août 2010 - 05:44 .


#2
Genisys

Genisys
  • Members
  • 525 messages
void KillTheFaction(object oMember) //
{
 object oTarget;
 effect eDeath = EffectDeath();  //This Simply Works (Apply Damage can crash the game)
 
oTarget = GetFirstFactionMember(oMember, TRUE);
 while(GetIsObjectValid(oTarget))
 {
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oTarget); 
   oTarget = GetNextFactionMember(oMember, TRUE);
 }

}

Modifié par Genisys, 31 août 2010 - 07:46 .


#3
prokat

prokat
  • Members
  • 2 messages
Thank you! Bashing my head against the wall on that one. GetFirstFactionMember() and EffectDeath() are great! The TRUE flag on the faction function made me think it wasn't working (as I am killing NPCs) but I never defined what I was killing.



Thanks again Genisys. You cleared my coding block!