Now just so you know there is no actual reputation functions or actual faction functions that can be used with players. These only work for NPCs. You need to make everything up with variables. So as far as players being hostile to eachother you can only use the "SetPCLike" or SetPCDislike" functions. This is the same thing that happens when a player manually gos into the player list and sets the Like/Dislike for other players. That being said, you can script this in an area's OnEnter event BUT the player can then just go into the list and manually set it back. They can do this at any time which is why I suggested an AOE. Even in an AOE the player can manually set the like/dislike back but if the AOE is also using a heartbeat script to keep checking then at least it will keep changing the like/dislike to the appropriate setting every 6 seconds. It's by no means a fool proof way for people to keep hostile to appropriate factions but at least it is a deterent and a means.
But anyway this is what an area's OnEnter script might look like for something like this (and this script uses a database item as example for persistence) and this is ONLY for players not NPCs:
void main()
{
object oPC = GetEnteringObject();
object oMyArea = OBJECT_SELF;
object oMyDBItem = GetItemPossessedBy(oPC, "Tag Of DB Item");
int iMyFaction = GetLocalInt(oMyDBItem, "MY_FACTION");
object oOther = GetFirstPC();
object oOtherArea;
object oOtherDBItem;
int iOtherFaction;
while (GetIsObjectValid(oOther))
{
oOtherArea = GetArea(oOther);
if (oMyArea == oOtherArea)
{
oOtherDBItem = GetItemPossessedBy(oOther, "Tag Of DB Item");
iOtherFaction = GetLocalInt(oOtherDBItem, "MY_FACTION");
if (iMyFaction != iOtherFaction)
{
SetPCDislike(oPC, oOther);
}
else
{
SetPCLike(oPC, oOther);
}
}
oOther = GetNextPC();
}
}
As for NPCs there are some things to take into consideration. Like if the NPCs in the area will even exist when a player first enters. And then do you really want to loop through all the objects in the area to get each NPC and then set is friend enemy etc.
Instead you might want to give NPCs a custom perception script or alter the default one (which would probably be easier).
Something like this might work for a custom OnPerception script which would then also run the default one:
void main()
{
object oPercep = GetLastPerceived();
int iMyFaction = GetLocalInt(OBJECT_SELF, "MY_FACTION");
object oPercepDBItem = GetItemPossessedBy(oPercep, "Tag of DB item");
int iOtherFaction = GetLocalInt(oPercepDBItem, "MY_FACTION");
if (iMyFaction != iOtherFaction)
{
SetIsTemporaryEnemy(oPercep, OBJECT_SELF);
}
ExecuteScript("nw_c2_default2", OBJECT_SELF);
}
Again this is not in practice just thoughts but I still hope it helps ya. Good luck.
Modifié par GhostOfGod, 16 mai 2012 - 02:49 .