mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
58 lines
986 B
Plaintext
58 lines
986 B
Plaintext
include library.ai_lib;
|
|
include library.stealth;
|
|
include library.utils;
|
|
|
|
void addHateToTarget(obj_id self)
|
|
{
|
|
if(ai_lib.isDead(self))
|
|
{
|
|
return;
|
|
}
|
|
|
|
obj_id target = null;
|
|
|
|
// debugSpeakMsg(self, "Acquiring target...");
|
|
|
|
// Get a new target
|
|
obj_id[] targets = getPlayerCreaturesInRange(getLocation(self), 64f);
|
|
|
|
if(targets == null || targets.length <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
target = targets[rand(0, targets.length - 1)];
|
|
|
|
if(!isIdValid(target) || isIncapacitated(target) || isDead(target) || stealth.hasInvisibleBuff(target))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(!canSee(self, target))
|
|
{
|
|
stopCombat(self);
|
|
}
|
|
|
|
utils.setScriptVar(self, "lastTargetSwitchTime", getGameTime());
|
|
|
|
// Add more hate to a random target
|
|
addHate(self, target, 5000);
|
|
}
|
|
|
|
trigger OnAiCombatFrame()
|
|
{
|
|
if(!isIdValid(self))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int lastTime = utils.getIntScriptVar(self, "lastTargetSwitchTime");
|
|
|
|
if(getGameTime() - lastTime > 10)
|
|
{
|
|
addHateToTarget(self);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|