This is what I came up with. Tested and seems to be working fine. There might be a better way to do it though. Hopefully it can help you.
void StopFactionCombat(object oPC, object oEnemy)
{
int iNth = 1;
object oCombatant = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oPC, iNth);
object oMember;
while (GetIsObjectValid(oCombatant))
{
if (GetFactionEqual(oEnemy, oCombatant))
{
oMember = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oMember))
{
if (GetCurrentAction(oMember) == ACTION_ATTACKOBJECT)
AssignCommand(oMember, ClearAllActions(TRUE));
if (GetCurrentAction(oCombatant) == ACTION_ATTACKOBJECT)
AssignCommand(oCombatant, ClearAllActions(TRUE));
SetIsTemporaryFriend(oMember, oCombatant, FALSE);
oMember = GetNextFactionMember(oPC, FALSE);
}
}
iNth++;
oCombatant = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oPC, iNth);
}
}
void main()
{
object oPC = GetLastDamager(OBJECT_SELF);
object oEnemy = OBJECT_SELF;
if (GetCurrentHitPoints(OBJECT_SELF) < 4)
StopFactionCombat(oPC, oEnemy);
}
P.S. Using the GetFirst/NextFactionMember functions works fine for single player as well since associates are considered faction members.
Modifié par GhostOfGod, 27 juillet 2011 - 10:09 .