mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-29 23:15:55 -04:00
162 lines
3.9 KiB
Plaintext
162 lines
3.9 KiB
Plaintext
|
|
//------------------------------------------------
|
|
// Includes
|
|
//------------------------------------------------
|
|
|
|
include library.chat;
|
|
include library.create;
|
|
include library.groundquests;
|
|
include library.prose;
|
|
include ai.ai_combat;
|
|
|
|
//------------------------------------------------
|
|
// CONSTANTS
|
|
//------------------------------------------------
|
|
|
|
|
|
//------------------------------------------------
|
|
// TRIGGERS
|
|
//------------------------------------------------
|
|
trigger OnAttach()
|
|
{
|
|
// Set a destroy callback to 1000 seconds.
|
|
messageTo(self, "clientEffect", null, 400, true);
|
|
|
|
// Attack!
|
|
messageTo(self, "attackPlayer", null, 1, false);
|
|
messageTo(self, "barkAttack", null, 1, false);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//if the player I am attacking is incapped
|
|
trigger OnIncapacitateTarget(obj_id victim)
|
|
{
|
|
obj_id player = getObjIdObjVar(self, "player");
|
|
if(!isValidId(player) || !exists(player))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//we avoid other players getting slot stolen
|
|
if(player != victim)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//say something
|
|
messageTo(self, "expression", null, 3, true);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnLoiterMoving()
|
|
{
|
|
messageTo(self, "clientEffect", null, 3, true);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// MESSAGE HANDLERS
|
|
//------------------------------------------------
|
|
messageHandler clientEffect()
|
|
{
|
|
if(!hasObjVar(self, "clientEffect"))
|
|
messageTo(self, "cleanUp", null, 0, true);
|
|
else
|
|
{
|
|
playClientEffectObj(self, getStringObjVar(self, "clientEffect"), self, "");
|
|
// Clean us up.
|
|
messageTo(self, "cleanUp", null, 1, true);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler cleanUp()
|
|
{
|
|
// Clean us up.
|
|
destroyObject(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler expression()
|
|
{
|
|
obj_id player = getObjIdObjVar(self, "player");
|
|
if(!isValidId(player) || !exists(player))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
faceTo(self, player);
|
|
messageTo(self, "barkDefeat", null, 1, false);
|
|
|
|
location body = getLocation(player);
|
|
pathTo(self, body);
|
|
//Walk in a direction and destroy self
|
|
messageTo(self, "runAwayThenCleanUp", null, 4, false);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler runAwayThenCleanUp()
|
|
{
|
|
//get random loc, walk there and then eventually destroy myself.
|
|
location l = groundquests.getRandom2DLocationAroundPlayer(self, 20, 50);
|
|
pathTo(self, l);
|
|
messageTo( self, "clientEffect", null, 6, true );
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler attackPlayer()
|
|
{
|
|
// Get player ref.
|
|
obj_id player = getObjIdObjVar(self, "player");
|
|
if(!isValidId(player) || !exists(player))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//attack the player
|
|
startCombat(self, player);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// barkAttack
|
|
//------------------------------------------------
|
|
|
|
//say something before attack...or nothing if var not there
|
|
messageHandler barkAttack()
|
|
{
|
|
obj_id mob = self;
|
|
if (params == null)
|
|
return SCRIPT_CONTINUE;
|
|
else if(!hasObjVar(mob, "phrase_string_file"))
|
|
return SCRIPT_OVERRIDE;
|
|
|
|
string stringFile = getStringObjVar(mob, "phrase_string_file");
|
|
|
|
string attackString = getStringObjVar(mob, "attack_phrase");
|
|
if ((attackString == null) || (attackString.equals("")))
|
|
return SCRIPT_OVERRIDE;
|
|
|
|
string_id attack_phrase = new string_id(stringFile, attackString);
|
|
chat.chat(mob, chat.CHAT_SHOUT, chat.MOOD_ANGRY, attack_phrase);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//say something once player defeated...or nothing if var not there
|
|
messageHandler barkDefeat()
|
|
{
|
|
obj_id mob = self;
|
|
if (params == null)
|
|
return SCRIPT_CONTINUE;
|
|
else if(!hasObjVar(mob, "phrase_string_file"))
|
|
return SCRIPT_OVERRIDE;
|
|
|
|
string stringFile = getStringObjVar(mob, "phrase_string_file");
|
|
|
|
string defeatString = getStringObjVar(mob, "defeat_phrase");
|
|
if ((defeatString == null) || (defeatString.equals("")))
|
|
return SCRIPT_OVERRIDE;
|
|
|
|
string_id defeat_phrase = new string_id(stringFile, defeatString);
|
|
chat.chat(mob, chat.CHAT_SHOUT, chat.MOOD_ANGRY, defeat_phrase);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
} |