SetIsTemporaryEnemy(object, object, int, float)
Causes an creature to consider another creature an enemy indefintely or for a fixed time.
object oSource = OBJECT_SELF,
int bDecays = FALSE,
float fDurationInSeconds = 180.0f
The object whose reputation will be altered.
The creature whose opinion will change (Default: OBJECT_SELF)
If this is TRUE, the enmity decays over fDurationInSeconds; otherwise it is indefinite. (Default: FALSE)
This is only used if bDecays is TRUE, it is how long the enmity lasts. (Default: 180.0f)
Make oSource into a temporary enemy of oTarget using personal reputation. This will fail if oTarget and oSource are in the same faction or party (Check with GetFactionEqual()) as they can never be considered tempoarily anything but what the faction in general tells them to think.
Note: If bDecays is TRUE, the personal reputation amount decreases in size over fDurationInSeconds. Enmity will only be in effect as long as (faction reputation + total personal reputation) <= REPUTATION_TYPE_ENEMY.
To make a faction consider a creature an enemy you should use AdjustReputation instead of this function.
From David Gaider's (Bioware) Scripting FAQ:
COMMON PROBLEMS: Make sure that a creature you want to go into combat does not have levels in Commoner. Commoners are set up by the generic AI to run away from hostiles and only form into a mob when there is both a level 10+ Commoner nearby.
Also make sure that if you are using the 'Special Behaviors' in the OnSpawn script (one of the special behavior command lines is uncommented) that you are not using the 'Herbivore' behavior. Herbivores also never engage in combat and will always run away.
From a different David Gaider (Bioware) post:
Creatures who have their plot flag on will not turn hostile, period. That's part of the plot flag's design... to prevent indestructible NPC's from accidentally being set off by something and coming after the PC.
If you want to make an indestructible NPC that attacks the PC's, you must specifically remove the plot flag before turning it hostile and then re-set it.
//:: Attack on End of Conversation
//:: Copyright (c) 2001 Bioware Corp.
This script makes an NPC attack the person
they are currently talking with. This will
only make the single character hostile not
their entire faction.
//:: Created By: Preston Watamaniuk
//:: Created On: Nov 7, 2001
AdjustReputation | SetIsTemporaryNeutral | SetIsTemporaryFriend
author: Tom Cassiotis, editor: Jasperre, additional contributor(s): Jasperre, chrono