mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
154 lines
2.9 KiB
Plaintext
154 lines
2.9 KiB
Plaintext
include library.ai_lib;
|
|
include library.chat;
|
|
include library.prose;
|
|
include library.utils;
|
|
include library.xp;
|
|
|
|
// This is the length of time that the buddy stays around before running away.
|
|
const float BUDDY_DURATION = 62.0f;
|
|
|
|
trigger OnAttach()
|
|
{
|
|
messageTo(self, "handleGreeting", null, 2.0f, false);
|
|
messageTo(self, "handleRunAway", null, BUDDY_DURATION, false);
|
|
|
|
setObjVar( self, "ai.pet", true );
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnExitedCombat()
|
|
{
|
|
if(utils.hasScriptVar(self, "runningaway"))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
messageTo(self, "handleNewTarget", null, 2.0f, false);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleGreeting()
|
|
{
|
|
obj_id master = getMaster(self);
|
|
|
|
if(isIdValid(master))
|
|
{
|
|
string name = getFirstName(master);
|
|
|
|
prose_package pp = new prose_package();
|
|
pp = prose.setStringId(pp, new string_id("combat_effects", "smuggler_buddy_greeting"));
|
|
pp = prose.setTU(pp, name);
|
|
|
|
chat.chat(self, master, chat.CHAT_SAY, null, chat.ChatFlag_targetGroupOnly, pp);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleNewTarget()
|
|
{
|
|
obj_id master = getMaster(self);
|
|
|
|
if(isIdValid(master))
|
|
{
|
|
obj_id newTarget = getHateTarget(master);
|
|
|
|
if(isIdValid(newTarget))
|
|
startCombat(self, newTarget);
|
|
else
|
|
messageTo(self, "handleRunAway", null, 2.0f, false);
|
|
}
|
|
else
|
|
{
|
|
messageTo(self, "handleRunAway", null, 2.0f, false);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleRunAway()
|
|
{
|
|
if(isDead(self))
|
|
{
|
|
messageTo(self, "handleCleanUp", null, 15.0f, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(utils.hasScriptVar(self, "runningaway"))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id master = getMaster(self);
|
|
|
|
if(isIdValid(master))
|
|
{
|
|
string name = getFirstName(master);
|
|
|
|
prose_package pp = new prose_package();
|
|
pp = prose.setStringId(pp, new string_id("combat_effects", "smuggler_buddy_goodbye"));
|
|
pp = prose.setTU(pp, name);
|
|
|
|
chat.chat(self, master, chat.CHAT_SAY, null, chat.ChatFlag_targetGroupOnly, pp);
|
|
}
|
|
|
|
stopCombat(self);
|
|
setMaster(self, null);
|
|
setInvulnerable(self, true);
|
|
|
|
if(isIdValid(master))
|
|
ai_lib.pathAwayFrom(self, master);
|
|
|
|
utils.setScriptVar(self, "runningaway", 1);
|
|
|
|
messageTo(self, "handleCleanUp", null, 15.0f, false);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleCleanUp()
|
|
{
|
|
destroyObject(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnIncapacitated(obj_id attacker)
|
|
{
|
|
obj_id weapon = getCurrentWeapon(self);
|
|
|
|
if( isIdValid(weapon) && !isDefaultWeapon(weapon) )
|
|
{
|
|
destroyObject(weapon);
|
|
}
|
|
|
|
//clear corpse inventory
|
|
|
|
obj_id cInv = utils.getInventoryContainer(self);
|
|
|
|
if(isIdValid(cInv))
|
|
{
|
|
utils.emptyContainerExceptStorytellerLoot(cInv);
|
|
}
|
|
|
|
ai_lib.clearCombatData();
|
|
|
|
setObjVar(self, xp.VAR_LANDED_DEATHBLOW, attacker);
|
|
|
|
if(!kill(self))
|
|
{
|
|
obj_id[] haters = getHateList(self);
|
|
|
|
if (haters != null || haters.length > 0)
|
|
{
|
|
for(int i=0;i<haters.length;i++)
|
|
{
|
|
removeHateTarget(haters[i], self);
|
|
}
|
|
}
|
|
|
|
destroyObject(self);
|
|
}
|
|
|
|
clearCondition(self, CONDITION_INTERESTING);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
} |