mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-10-18 09:02:56 -04:00
140 lines
3.4 KiB
Plaintext
140 lines
3.4 KiB
Plaintext
include library.utils;
|
|
include library.sui;
|
|
|
|
const string CONVO = "city/bestine/terminal_items";
|
|
const string DATATABLE_NAME = "datatables/city/bestine/terminal_items.iff";
|
|
|
|
const string GET_QUEST_ITEM_VOLUME_NAME = "getQuestItemTriggerVolume";
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
createTriggerVolume( GET_QUEST_ITEM_VOLUME_NAME, 2.0f, true );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnTriggerVolumeEntered( string volumeName, obj_id breacher )
|
|
{
|
|
if ( volumeName == GET_QUEST_ITEM_VOLUME_NAME )
|
|
{
|
|
string template = getStringObjVar(self, "disk");
|
|
if ( (template != null) && (!template.equals("")) )
|
|
{
|
|
int stringCheck = template.indexOf("history");
|
|
if ( stringCheck > -1 )
|
|
{
|
|
if ( isPlayer( breacher ) )
|
|
{
|
|
if ( canSearch(self, breacher) )
|
|
{
|
|
// already gotten this disk
|
|
if ( hasObjVar(breacher, "bestine.searched") )
|
|
{
|
|
sendSystemMessage(breacher, new string_id(CONVO,"history_disk_found_already"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
// give em the disk
|
|
obj_id playerInv = utils.getInventoryContainer(breacher);
|
|
if ( isIdValid(playerInv) )
|
|
{
|
|
int free_space = getVolumeFree(playerInv);
|
|
if (free_space > 0)
|
|
{
|
|
obj_id objectReceived = createObject(template, playerInv, "");
|
|
if ( isIdValid(objectReceived) )
|
|
{
|
|
sendSystemMessage(breacher, new string_id(CONVO,"history_disk_found"));
|
|
setObjVar(breacher, "bestine.searched", 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(breacher, new string_id(CONVO,"inv_full"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
string template = getStringObjVar(self, "disk");
|
|
int stringCheck = template.indexOf("history");
|
|
if ( stringCheck < 0 )
|
|
{
|
|
if ( canSearch(self, player) )
|
|
{
|
|
int menuOption = mi.addRootMenu ( menu_info_types.ITEM_USE, new string_id(CONVO,"download"));
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if ( item == menu_info_types.ITEM_USE )
|
|
{
|
|
if ( canSearch(self, player) )
|
|
{
|
|
if ( hasObjVar(player, "bestine.searched") )
|
|
{
|
|
sendSystemMessage(player, new string_id(CONVO,"searched"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
string template = getStringObjVar(self, "disk");
|
|
if ( (template != null) && (!template.equals("")) )
|
|
{
|
|
obj_id playerInv = utils.getInventoryContainer(player);
|
|
if ( isIdValid(playerInv) )
|
|
{
|
|
int free_space = getVolumeFree(playerInv);
|
|
if (free_space > 0)
|
|
{
|
|
obj_id objectReceived = createObject(template, playerInv, "");
|
|
if ( isIdValid(objectReceived) )
|
|
{
|
|
sendSystemMessage(player, new string_id(CONVO,"download_complete"));
|
|
setObjVar(player, "bestine.searched", 1);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(player, new string_id(CONVO,"inv_full"));
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
/***** FUNCTIONS *******************************************************/
|
|
|
|
|
|
boolean canSearch(obj_id self, obj_id player)
|
|
{
|
|
|
|
boolean result = false;
|
|
if ( hasObjVar(self, "disk") )
|
|
{
|
|
|
|
string objectTemplate = getStringObjVar(self, "disk");
|
|
dictionary row = dataTableGetRow(DATATABLE_NAME, objectTemplate);
|
|
string gatingObjVar = row.getString("gatingObjVar");
|
|
if ( hasObjVar(player, gatingObjVar) )
|
|
{
|
|
result = true;
|
|
}
|
|
}
|
|
return result;
|
|
}
|