mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
258 lines
6.3 KiB
Plaintext
258 lines
6.3 KiB
Plaintext
/**
|
|
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
|
|
* All Rights Reserved
|
|
*
|
|
* Title: insurance.script
|
|
* Description: script for insurance menu options; to be attached to insurance terminals
|
|
* @author $Author:$
|
|
* @version $Revision:$
|
|
*/
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
|
|
include library.utils;
|
|
include library.sui;
|
|
include library.pclib;
|
|
include library.money;
|
|
|
|
/***** INHERITS ********************************************************/
|
|
|
|
inherits terminal.base.base_terminal;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const string SCRIPTVAR_CONFIRM_ALL = "confirmInsureAll";
|
|
|
|
const string_id SID_MNU_INSURE = new string_id("sui", "mnu_insure");
|
|
const string_id SID_MNU_INSURE_ALL = new string_id("sui", "mnu_insure_all"); //menu1
|
|
|
|
const string_id SID_OBJECT_NOT_ACTIVE = new string_id("error_message", "object_not_active");
|
|
|
|
const string_id SID_UNABLE_TO_INSURE = new string_id("error_message","unable_to_insure");
|
|
|
|
const string STF = "terminal_ui";
|
|
|
|
/***** TRIGGERS ********************************************************/
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
destroyObject(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// INSURANCE IS NO MORE, THIS SCRIPT SHOULD NO LONGER BE USED
|
|
/*
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
if (isMob(self))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
menu_info_data mid = mi.getMenuItemByType(menu_info_types.ITEM_USE);
|
|
if ( mid == null )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int mnu = mid.getId();
|
|
int sub_insure_all = mi.addSubMenu(mnu, menu_info_types.SERVER_MENU1, SID_MNU_INSURE_ALL);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if ( item == menu_info_types.ITEM_USE)
|
|
{
|
|
queueCommand(player, ##"insure", self, "", COMMAND_PRIORITY_DEFAULT);
|
|
}
|
|
else if ( item == menu_info_types.SERVER_MENU1)
|
|
{
|
|
confirmInsureAll(player);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
*/
|
|
|
|
/***** FUNCTIONS *******************************************************/
|
|
/*
|
|
messageHandler handleConfirmInsureAll()
|
|
{
|
|
obj_id player = params.getObjId("player");
|
|
confirmInsureAll(player);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
void confirmInsureAll(obj_id player)
|
|
{
|
|
obj_id self = getSelf();
|
|
|
|
string scriptvar = SCRIPTVAR_CONFIRM_ALL + "." + player;
|
|
if ( utils.hasScriptVar(self, scriptvar) )
|
|
{
|
|
int oldpid = utils.getIntScriptVar(self, scriptvar);
|
|
sui.closeSUI(player, oldpid);
|
|
|
|
utils.removeScriptVar(self, scriptvar);
|
|
}
|
|
|
|
int total = 0;
|
|
obj_id[] tmp = pclib.getValidUninsuredItems(player);
|
|
resizeable obj_id[] items = utils.concatArrays(null, tmp);
|
|
if ( items != null && items.length > 0 )
|
|
{
|
|
for ( int i = 0; i < items.length; i++ )
|
|
{
|
|
if ( isIdValid(items[i]) )
|
|
{
|
|
int cost = pclib.getInsureCost( items[i], player );
|
|
if ( cost > 0 )
|
|
total += cost;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(player, new string_id(STF, "no_insurable_items")); // You do not have any items that can be insured.
|
|
return;
|
|
}
|
|
|
|
string prompt = getString(new string_id(STF, "insure_all_d_prefix")) + total + getString(new string_id(STF, "insure_all_d_suffix")) + "\n\n" + getString(new string_id(STF, "insure_all_confirm"));
|
|
|
|
int pid = sui.msgbox(self, player, prompt, sui.YES_NO, getString(new string_id(STF, "insure_all_t")), "handleConfirmSui");
|
|
if ( pid > -1 )
|
|
utils.setScriptVar(self, scriptvar, pid);
|
|
}
|
|
*/
|
|
|
|
/***** MESSAGEHANDLERS *************************************************/
|
|
/*
|
|
messageHandler handleConfirmSui()
|
|
{
|
|
obj_id player = sui.getPlayerId(params);
|
|
if ( !isIdValid(player) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//cleanup confirm pid scriptvar
|
|
utils.removeScriptVar(self, SCRIPTVAR_CONFIRM_ALL + "." + player);
|
|
|
|
int bp = sui.getIntButtonPressed(params);
|
|
if ( bp == sui.BP_OK )
|
|
queueCommand(player, ##"insure", self, "all", COMMAND_PRIORITY_DEFAULT);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//FROM INSURANCE LIST MENU
|
|
messageHandler handleInsureRequest()
|
|
{
|
|
obj_id player = sui.getPlayerId(params);
|
|
if ( (player == null) || (player == obj_id.NULL_ID) )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
utils.removeScriptVar(player, "sui.insurance");
|
|
|
|
if ( sui.getListboxOtherButtonPressed(params) )
|
|
{
|
|
queueCommand(player, ##"insure", self, "all", COMMAND_PRIORITY_DEFAULT);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int btnPressed = sui.getIntButtonPressed(params);
|
|
//debugSpeakMsg(player, "I selected button #" + btnPressed);
|
|
switch(btnPressed)
|
|
{
|
|
case sui.BP_CANCEL:
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( utils.hasScriptVar(player, pclib.VAR_INSURE_UI_OPTIONS) )
|
|
{
|
|
obj_id[] options = utils.getObjIdBatchScriptVar(player, pclib.VAR_INSURE_UI_OPTIONS);
|
|
utils.removeBatchScriptVar(player, pclib.VAR_INSURE_UI_OPTIONS);
|
|
if ( (options == null) || (options.length == 0) )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
if ( params == null )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int idx = sui.getListboxSelectedRow(params);
|
|
if ( idx < 0 )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if ( idx >= options.length )
|
|
{
|
|
sendSystemMessage(player, SID_UNABLE_TO_INSURE);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
queueCommand(player, ##"insure", self, options[idx].toString(), COMMAND_PRIORITY_DEFAULT);
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//
|
|
messageHandler handleRequestedInsurance()
|
|
{
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int retVal = money.getReturnCode(params);
|
|
|
|
obj_id player = params.getObjId(money.DICT_PLAYER_ID);
|
|
if ( (player == null) || (player == obj_id.NULL_ID) )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int total = params.getInt(money.DICT_TOTAL);
|
|
|
|
if ( retVal == money.RET_SUCCESS )
|
|
{
|
|
money.bankTo(self, money.ACCT_INSURANCE, total);
|
|
}
|
|
|
|
messageTo(player, "handleFinalizeBatchInsure", params, 0, true);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleNewbieInsureConfirm()
|
|
{
|
|
obj_id player = sui.getPlayerId(params);
|
|
if ( !isIdValid(player) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
utils.removeScriptVar(player, "sui.newbieInsureConfirm");
|
|
|
|
string scriptvarPath = "newbieConfirm." + player;
|
|
int bp = sui.getIntButtonPressed(params);
|
|
if ( bp == sui.BP_OK )
|
|
{
|
|
setObjVar(player, pclib.VAR_NEWBIE_CONFIRM_INSURE, getGameTime());
|
|
|
|
string passParams = utils.getStringScriptVar(self, scriptvarPath);
|
|
if ( passParams == null )
|
|
passParams = "";
|
|
|
|
queueCommand(player, ##"insure", self, passParams, COMMAND_PRIORITY_DEFAULT);
|
|
}
|
|
|
|
utils.removeScriptVar(self, scriptvarPath);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
*/
|