Hi,
Yes, as KevL said, I did manage to implement this idea into my module. You have to be very careful when implementing this, as it can be tricky to ensure the player does not make enemies in the wrong way.
I will try to dig out the thread.
Sadly, my web info does not go back far enough to cover this thread and I cannot recall it's topic title to search for it. Instead, I have included some extracts of my code, which you can pick through if you like. One of the key factors is creating an ANTIPARTY faction, which is only hostile to PCs.
(When my mod is released, you can check out how I implemented it in full.)
Hope that gives some helpful pointers ... Bear in mind that the code below covers *many* other aspects of my own module that you can probably ignore.
Regards,
Lance.
EDIT:
XML EXTRACT:
<!-- Make HOSTILE & Close Button -->
<UIButton name="HostileCloseButton" x=349 y=8 width=25 height=25
OnLeftClick0=UIButton_Input_ScreenClose() OnLeftClick1=UIObject_Misc_ExecuteServerScript("gui_examine","HostileToggle")
OnToolTip='UIObject_Tooltip_DisplayTooltipString("Toggle target HOSTILE/NEUTRAL setting to allow spell targeting","OBJECT_X","OBJECT_Y","SCREEN_TOOLTIP_2")'>
<UIFrame state=up fill="ife_attack.tga" />
<UIFrame state=down fill="ife_attack.tga" />
<UIFrame state=focused fill="ife_attack.tga" />
<UIFrame state=hilited fill="ife_attack.tga" />
<UIFrame state=hifocus fill="ife_attack.tga" />
<UIFrame state=disabled fill="ife_attack.tga" />
</UIButton>
SCRIPT EXTRACT:
/////////////////////////////////////////////////////////////////////////////////////////
// EXAMINE GUI (HOSTILE BUTTON) - TOGGLE TARGET HOSTILITY BUTTON (ALLOWS SPELL TARGETING)
/////////////////////////////////////////////////////////////////////////////////////////
if(sOption == "HostileToggle")
{
// PROTECT PLOT CREATURES
SetLocalObject(oMainPC, "NPCTarget", oTarget);
if(GetGlobalInt("TESTMODE") > 0){SendMessageToAllPCs("TARGET TAG: " + sTag);}
// SEND AN INT TO ENSURE NO NEGATIVE REACTION FROM GENERIC TARGET (BUT FIRES QH INFO STILL IF AVAILABLE i.e. IF RETURNS 1)
int IGNORE = 0; if(NPCStateCheck(oMainPC, sTag, 1) == 1){IGNORE = 1;}
if(GetGlobalInt("TESTMODE") > 0){SendMessageToAllPCs("IGNORE VAL: " + IntToString(IGNORE));}
if(IGNORE == 0)
{
string sReport = CRED + "Target made: HOSTILE (Party AI Disabled)";
if(GetLocalInt(oTarget, "CoolDown") != -1)
{
SetLocalInt(oTarget, "CoolDown", -1);
// TURN ANTI-PARTY BY DEFAULT
object oAnti = GetObjectByTag("SETFACTION_ANTIPARTY");
// UNLESS KNOWN FOR EVIL, IN WHICH CASE TURN HOSTILE (TO PREVENT ALLIES COMING TO AID)
// NB: THIS DOES NOT CHANGE THE DEFAULT FACTION YET - SO PC CAN "UNHOSTILE" THE NPC IF NOT ATTACKED
//if(GetAlignmentGoodEvil(oTarget) == ALIGNMENT_EVIL){oAnti = GetObjectByTag("SETFACTION_HOSTILE");}
// NB: COULD NOT DO ABOVE LINE, AS IT WOULD MAKE THE CREATURE ATTACK OTHERS NEARBY
// CHANGE TO HOSTILE IN THE ACTUAL ATTACK USING CHECKAGGRO FUNCTION !!!!!!!!!!!!!!
ChangeFaction(oTarget, oAnti);
// DISABLE PARTY AI REGARDLESS TO PREVENT AUTO ATTACK (TURN ALL PCS PUPPET MODE)
object oFM = GetFirstFactionMember(oPC, FALSE);
while(oFM != OBJECT_INVALID)
{
int BYPASS = 0;
// NOT FOR HENCHMEN, SUMMONED OR FAMILIARS
if(GetAssociateType(oFM) == ASSOCIATE_TYPE_HENCHMAN
|| GetAssociateType(oFM) == ASSOCIATE_TYPE_ANIMALCOMPANION
|| GetAssociateType(oFM) == ASSOCIATE_TYPE_FAMILIAR
|| GetAssociateType(oFM) == ASSOCIATE_TYPE_SUMMONED){BYPASS = 1;}
if(BYPASS == 0){AssignCommand(oFM,SetAssociateState(NW_ASC_MODE_PUPPET,TRUE));} // PLAYER MUST ORDER
oFM = GetNextFactionMember(oPC, FALSE);
}
}
// ONLY ALLOW TOGGLE OF PREVIOUSLY TOGGLED (i.e. Not a substitute for "Sorry")
else if(GetLocalInt(oTarget, "CoolDown") == -1)
{
AssignCommand(oTarget, ClearAllActions(TRUE));
AssignCommand(OBJECT_SELF, ClearAllActions(TRUE));
DeleteLocalInt(oTarget, "CoolDown");
ChangeFaction(oTarget, DEFAULTFACTION);
sReport = CGREEN + "Target made: NON HOSTILE";
// REQUIRES RESTART WHEN GOING BACK TO NON HOSTILE
DeleteLocalInt(oTarget, "WP_SETUP");
}
// INFORM PLAYER
SetNoticeText(oPC, sReport);
// KEEP WALKERS WALKING
//DeleteLocalInt(oTarget, "WP_SETUP");
SetLocalInt(oTarget, "STOPANIMS", 1);
SetLocalInt(oTarget, "FORCEWALK", 1);
} // END IGNORE
} // END HOSTILE TOGGLE