mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-13 22:01:04 -04:00
99 lines
2.6 KiB
Plaintext
99 lines
2.6 KiB
Plaintext
// ALL SERVING DROID SCRIPTS
|
|
// structure/serving_droid_control.script
|
|
// creature/serving_droid.script
|
|
// item/droid/serving_droid_terminal.script
|
|
|
|
include library.player_structure;
|
|
include library.utils;
|
|
//variable constants
|
|
const string DROID_ID = "serving_droid.droid";
|
|
|
|
|
|
trigger OnAttach()
|
|
{
|
|
messageTo(self, "checkdroidId", null, 3, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnReceivedItem(obj_id srcContainer, obj_id transferer, obj_id item)
|
|
{
|
|
if(isPlayer(item))
|
|
messageTo(self, "handleReceived", null, 6, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnLostItem(obj_id srcContainer, obj_id transferer, obj_id item)
|
|
{
|
|
if(isPlayer(item))
|
|
messageTo(self, "handleLost", null, 6, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//This is called on init to get the terminal user's OID
|
|
messageHandler checkDroidId()
|
|
{
|
|
//remove the script if no droid exists
|
|
//IFhASoBJVAR here
|
|
//if !exists if (incubator.isStatEnzyme(self) && exists(self))
|
|
|
|
if(!isValidId(getObjIdObjVar(self, DROID_ID)))
|
|
detachScript(self, "structure.serving_droid_control");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleReceived()
|
|
{
|
|
//remove the script if no droid exists
|
|
if(!isValidId(self) && !exists(self))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if(!hasObjVar(self, DROID_ID) && !exists(self))
|
|
detachScript(self, "structure.serving_droid_control");
|
|
|
|
obj_id droid = getObjIdObjVar(self, DROID_ID);
|
|
if(!isValidId(droid) && !exists(self))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//the droid is moving already or the owner is setting patrols
|
|
if(utils.hasScriptVar(droid, "droid.moving") || utils.hasScriptVar(droid, "droid.settingPatrol"))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id[] players = player_structure.getPlayersInBuilding(self);
|
|
|
|
if(players == null || players.length == 0)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//players already here
|
|
if(players.length > 1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//Reactivate the sleeping droid
|
|
broadcastMessage("handleActivateDroid", new dictionary());
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleLost()
|
|
{
|
|
//remove the script if no droid exists
|
|
if(!isValidId(self) && !exists(self))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if(!hasObjVar(self, DROID_ID) && !exists(self))
|
|
detachScript(self, "structure.serving_droid_control");
|
|
|
|
obj_id droid = getObjIdObjVar(self, DROID_ID);
|
|
if(!isValidId(droid) && !exists(self))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if(utils.hasScriptVar(droid, "droid.settingPatrol"))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id[] players = player_structure.getPlayersInBuilding(self);
|
|
if(players == null || players.length == 0)
|
|
{
|
|
broadcastMessage("handleDeactivateDroid", new dictionary());
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
} |