Files
dsrc/sku.0/sys.server/compiled/game/script/terminal/terminal_pob_ship.script
T
2013-09-10 23:17:15 -07:00

256 lines
8.5 KiB
Plaintext

// ======================================================================
//
// terminal.terminal_pob_ship
//
// Copyright 2004 Sony Online Entertainment
//
// ======================================================================
include library.player_structure;
include library.prose;
include library.space_transition;
include library.sui;
include library.utils;
// ======================================================================
const string_id SID_TERMINAL_PERMISSIONS = new string_id("player_structure", "permissions");
const string_id SID_MOVE_FIRST_ITEM = new string_id("player_structure", "move_first_item");
const string_id SID_MOVED_FIRST_ITEM = new string_id("player_structure", "moved_first_item_pob");
const string_id SID_DELETE_ALL_ITEMS = new string_id("player_structure", "delete_all_items");
const string_id SID_ITEMS_DELETED = new string_id("player_structure", "items_deleted_pob_ship");
const string_id SID_ROOT_ITEM_MENU = new string_id( "player_structure", "find_items_root_menu" );
const string_id SID_FIND_ALL_HOUSE_ITEMS = new string_id( "player_structure", "find_items_find_all_house_items" );
const string_id SID_SEARCH_FOR_HOUSE_ITEMS = new string_id( "player_structure", "find_items_search_for_house_items" );
const string_id SID_TERMINAL_REDEED_STORAGE = new string_id("player_structure", "redeed_storage");
const string_id SID_STORAGE_INCREASE_REDEED_TITLE = new string_id("player_structure", "sui_storage_redeed_title");
const string_id SID_STORAGE_INCREASE_REDEED_PROMPT = new string_id("player_structure", "sui_storage_redeed_prompt");
// ======================================================================
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
obj_id ship = space_transition.getContainingShip(self);
if(isIdValid(ship) && getOwner(ship) == player)
{
int rootItemMenu = mi.addRootMenu(menu_info_types.SERVER_MENU10, SID_ROOT_ITEM_MENU);
mi.addSubMenu(rootItemMenu, menu_info_types.SERVER_MENU11, SID_FIND_ALL_HOUSE_ITEMS);
mi.addSubMenu(rootItemMenu, menu_info_types.SERVER_MENU12, SID_SEARCH_FOR_HOUSE_ITEMS);
mi.addSubMenu(rootItemMenu, menu_info_types.SERVER_MENU2, SID_MOVE_FIRST_ITEM);
mi.addSubMenu(rootItemMenu, menu_info_types.SERVER_MENU3, SID_DELETE_ALL_ITEMS);
if(hasObjVar(ship, player_structure.OBJVAR_STRUCTURE_STORAGE_INCREASE))
{
mi.addRootMenu(menu_info_types.DICE_ROLL, SID_TERMINAL_REDEED_STORAGE);
}
mi.addRootMenu(menu_info_types.SERVER_MENU1, SID_TERMINAL_PERMISSIONS);
}
return SCRIPT_CONTINUE;
}
// ----------------------------------------------------------------------
trigger OnObjectMenuSelect(obj_id player, int item)
{
obj_id ship = space_transition.getContainingShip(self);
if(isIdValid(ship) && getOwner(ship) == player)
{
if (item == menu_info_types.SERVER_MENU1)
{
queueCommand(player, ##"setpermission", self, "admin", COMMAND_PRIORITY_DEFAULT);
}
else if (item == menu_info_types.SERVER_MENU2)
{
sui.msgbox(self, player, "@player_structure:move_first_item_d", sui.OK_CANCEL, "@player_structure:move_first_item", sui.MSG_QUESTION, "handleMoveFirstItem");
}
else if (item == menu_info_types.SERVER_MENU3)
{
sui.msgbox(self, player, "@player_structure:delete_all_items_d", sui.OK_CANCEL, "@player_structure:delete_all_items", sui.MSG_QUESTION, "handleDeleteSecondConfirm");
}
else if(item == menu_info_types.DICE_ROLL)
{
if(!hasObjVar(ship, player_structure.OBJVAR_STRUCTURE_STORAGE_INCREASE))
return SCRIPT_CONTINUE;
// Should be safe here to redeed the storage - handler = handleStorageRedeedChoice
player_structure.displayAvailableNonGenericStorageTypes(player, self, ship);
}
else if ( item == menu_info_types.SERVER_MENU11 )
{
int lockoutEnds = -1;
if ( hasObjVar(self, "findItems.lockout") )
{
lockoutEnds = getIntObjVar(self, "findItems.lockout");
}
int currentTime = getGameTime();
if ( currentTime > lockoutEnds || isGod(player) )
{
player_structure.initializeFindAllItemsInHouse(self, player);
setObjVar(self, "findItems.lockout", currentTime + player_structure.HOUSE_ITEMS_SEARCH_LOCKOUT);
}
else
{
string_id message = new string_id ("player_structure", "find_items_locked_out");
prose_package pp = prose.getPackage(message, player, player);
prose.setTO(pp, utils.formatTimeVerbose(lockoutEnds - currentTime));
sendSystemMessageProse(player, pp);
}
}
else if ( item == menu_info_types.SERVER_MENU12 )
{
int lockoutEnds = -1;
if ( hasObjVar(self, "findItems.lockout") )
{
lockoutEnds = getIntObjVar(self, "findItems.lockout");
}
int currentTime = getGameTime();
if ( currentTime > lockoutEnds || isGod(player) )
{
player_structure.initializeItemSearchInHouse(self, player);
setObjVar(self, "findItems.lockout", currentTime + player_structure.HOUSE_ITEMS_SEARCH_LOCKOUT);
}
else
{
string_id message = new string_id ("player_structure", "find_items_locked_out");
prose_package pp = prose.getPackage(message, player, player);
prose.setTO(pp, utils.formatTimeVerbose(lockoutEnds - currentTime));
sendSystemMessageProse(player, pp);
}
}
}
return SCRIPT_CONTINUE;
}
messageHandler handleStorageRedeedChoice()
{
obj_id player = sui.getPlayerId(params);
string accessFee = sui.getInputBoxText(params);
int btn = sui.getIntButtonPressed(params);
if(btn == sui.BP_CANCEL)
return SCRIPT_CONTINUE;
obj_id objShip = space_transition.getContainingShip(self);
if(!isIdValid(objShip) || getOwner(objShip) != player)
{
return SCRIPT_CONTINUE;
}
if(hasObjVar(objShip, player_structure.OBJVAR_STRUCTURE_STORAGE_INCREASE))
{
int storageRedeedSelected = 0;
if ( params.containsKey(sui.LISTBOX_LIST + "." + sui.PROP_SELECTEDROW) )
{
storageRedeedSelected = sui.getListboxSelectedRow(params);
if ( storageRedeedSelected < 0)
{
return SCRIPT_CONTINUE;
}
}
if(player_structure.decrementStorageAmount(player, objShip, self, storageRedeedSelected))
{
sendSystemMessage(player, new string_id("player_structure", "storage_increase_redeeded"));
}
}
return SCRIPT_CONTINUE;
}
// ======================================================================
messageHandler handleMoveFirstItem()
{
obj_id player = sui.getPlayerId(params);
if(sui.getIntButtonPressed(params) != sui.BP_CANCEL)
{
// The player wants to move the first object in his ship to his location.
// This is used to find objects that might have been pushed into walls.
obj_id ship = space_transition.getContainingShip(self);
if(isIdValid(ship) && getOwner(ship) == player)
{
moveHouseItemToPlayer(ship, player, 0);
sendSystemMessage(player, SID_MOVED_FIRST_ITEM);
}
}
return SCRIPT_CONTINUE;
}
// ----------------------------------------------------------------------
messageHandler handleDeleteSecondConfirm()
{
obj_id player = sui.getPlayerId(params);
if(sui.getIntButtonPressed(params) != sui.BP_CANCEL)
{
sui.msgbox(self, player, "@player_structure:delete_all_items_second_d_pob_ship", sui.OK_CANCEL, "@player_structure:delete_all_items", sui.MSG_QUESTION, "handleDeleteItems");
}
return SCRIPT_CONTINUE;
}
// ----------------------------------------------------------------------
messageHandler handleDeleteItems()
{
obj_id player = sui.getPlayerId(params);
if(sui.getIntButtonPressed(params) != sui.BP_CANCEL)
{
// The player wants to delete everything.
obj_id ship = space_transition.getContainingShip(self);
if(isIdValid(ship) && getOwner(ship) == player)
{
deleteAllHouseItems(ship, player);
fixHouseItemLimit(ship);
sendSystemMessage(player, SID_ITEMS_DELETED);
CustomerServiceLog("playerStructure", "deleteAllItems (Deleting all objects in ship by player's request.) Player: " + player + " (" + getName(player) + ") Ship: " + ship);
}
}
return SCRIPT_CONTINUE;
}
// ======================================================================
/***** ITEM SEARCH HANDLERS ********************************************/
messageHandler handlePlayerStructureFindItemsListResponse()
{
player_structure.handleFindItemsListResponse(self, params);
return SCRIPT_CONTINUE;
}
messageHandler handlePlayerStructureFindItemsPageResponse()
{
player_structure.handleFindItemsChangePageResponse(self, params);
return SCRIPT_CONTINUE;
}
messageHandler handlePlayerStructureSearchItemsGetKeyword()
{
player_structure.handleSearchItemsGetKeyword(self, params);
return SCRIPT_CONTINUE;
}
messageHandler handlePlayerStructureSearchItemsSelectedResponse()
{
player_structure.handleSearchItemsSelectedResponse(self, params);
return SCRIPT_CONTINUE;
}
/***********************************************************************/