Yes, you can certainly loop through the pc's faction and boot them from the heartbeat - that's not going to create much overhead at all. The only issue is deciding whether to boot the good or the evil ones. You could choose to keep whichever the first pc scanned happens to be, which would be simplest, or you could instead opt to tally up good and evil counts and boot the minority. Then, the only trick is making sure you don't check a pc more than once as you loop through them all. Here's the simplest example I could whip up. It won't do exactly what you want in all cases, but it's pretty streamlined. I did the boots in a separate loop so it wouldn't affect faction averages:
void main() {
object oMember, oPC = GetFirstPC();
int nFactionAlign;
while (GetIsObjectValid(oPC)) {
nFactionAlign = GetFactionAverageGoodEvilAlignment(oPC);
if ((nFactionAlign < 50 && GetAlignmentGoodEvil(oPC) == ALIGNMENT_GOOD) ||
(nFactionAlign >= 50 && GetAlignmentGoodEvil(oPC) == ALIGNMENT_EVIL))
SetLocalInt(oPC, "AlignmentBoot", 1);
oPC = GetNextPC();
}
oPC = GetFirstPC();
while (GetIsObjectValid(oPC)) {
if (GetLocalInt(oPC, "AlignmentBoot")) {
DeleteLocalInt(oPC, "AlignmentBoot");
RemoveFromParty(oPC);
}
oPC = GetNextPC();
}
}
That's not compiled, but it should work. A more precise method would involve looping each pc's factionmembers with GetFirstFactionMember and checking for GetAlignmentGoodEvil mismatches, but then you'd need a second variable so you didn't recheck pcs as you continued through the primary loop. Again, I don't think lag would be an issue, I just don't feel like coding up another highly redundant example. LMK if you want the other.
Funky
Modifié par FunkySwerve, 20 octobre 2010 - 09:34 .