mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-13 22:01:04 -04:00
194 lines
4.9 KiB
Plaintext
194 lines
4.9 KiB
Plaintext
/**
|
|
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
|
|
* All Rights Reserved
|
|
*
|
|
* Title: terminal_food.script
|
|
* Description: BETA SCRIPT: food dispenser
|
|
* @author $Author:$
|
|
* @version $Revision:$
|
|
*/
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
|
|
include library.utils;
|
|
include library.sui;
|
|
include library.xp;
|
|
include library.prose;
|
|
include library.pclib;
|
|
|
|
/***** INHERITS ********************************************************/
|
|
|
|
inherits terminal.base.terminal_add_use;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const int XP_AMOUNT = 100000;
|
|
|
|
const string TBL = "datatables/skill/skills.iff";
|
|
|
|
const string VAR_XP_TYPES = "xp_types";
|
|
const string VAR_XP_TYPES_LIST = "xp_types.list";
|
|
const string VAR_XP_TYPES_NAMES = "xp_types.names";
|
|
|
|
const string HANDLER_XP_SELECT = "handleXpSelect";
|
|
const string HANDLER_XP_AMOUNT_SELECT = "handleXpAmountSelect";
|
|
|
|
const string_id PROSE_GRANT_XP = new string_id("base_player","prose_grant_xp");
|
|
|
|
const string VAR_DESIRED_XP_TYPE = "desired_xpType";
|
|
|
|
/***** TRIGGERS ********************************************************/
|
|
trigger OnAttach()
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
removeObjVar(self, VAR_XP_TYPES_LIST);
|
|
initializeXpTerminal(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
|
|
if (isGod(player) || hasObjVar(player, "beta.terminal_ok"))
|
|
{
|
|
|
|
if ( item == menu_info_types.ITEM_USE )
|
|
{
|
|
string[] xpTypes = utils.getStringBatchScriptVar(self, VAR_XP_TYPES_NAMES);
|
|
if ( (xpTypes != null) && (xpTypes.length > 0) )
|
|
{
|
|
string prompt = "Select the xp type you would like more xp in...";
|
|
string title = "Beta XP Dispenser";
|
|
sui.listbox(self, player, prompt, sui.OK_CANCEL, title, xpTypes, HANDLER_XP_SELECT);
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessageTestingOnly(player, "Only authorized users may access this terminal.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
/***** FUNCTIONS *******************************************************/
|
|
void initializeXpTerminal(obj_id self)
|
|
{
|
|
string[] xpTypes = xp.getXpTypes(self);
|
|
if ( (xpTypes != null) && (xpTypes.length > 0) )
|
|
{
|
|
setXpTypesScriptVar(self, xpTypes);
|
|
}
|
|
}
|
|
|
|
void setXpTypesScriptVar(obj_id self, string[] varData)
|
|
{
|
|
if ( (varData == null) || (varData.length == 0) )
|
|
{
|
|
debugSpeakMsg(self, "setXpTypesVar: passed bad string array!");
|
|
return;
|
|
}
|
|
|
|
utils.setBatchScriptVar(self, VAR_XP_TYPES_LIST, varData);
|
|
|
|
string[] xpNames = new string[varData.length];
|
|
for ( int i = 0; i < varData.length; i++ )
|
|
xpNames[i] = "@exp_n:" + varData[i];
|
|
|
|
utils.setBatchScriptVar(self, VAR_XP_TYPES_NAMES, xpNames);
|
|
}
|
|
|
|
/***** MESSAGEHANDLERS *************************************************/
|
|
messageHandler handleXpSelect()
|
|
{
|
|
obj_id player = sui.getPlayerId(params);
|
|
if ( !isIdValid(player) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int btn = sui.getIntButtonPressed(params);
|
|
if ( btn == sui.BP_CANCEL )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int idx = sui.getListboxSelectedRow(params);
|
|
if ( idx < 0 )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
string[] xpTypes = utils.getStringBatchScriptVar(self, VAR_XP_TYPES_LIST);
|
|
if ( xpTypes == null || xpTypes.length == 0 || idx >= xpTypes.length )
|
|
{
|
|
sendSystemMessageTestingOnly(player, "There has been an error in determining the xp type selected.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/*string[] typeSplit = split(xpTypes[idx], ':');
|
|
string xpType = typeSplit[1];*/
|
|
|
|
string xpType = xpTypes[idx];
|
|
|
|
int xp = getExperiencePoints(player, xpType);
|
|
|
|
setObjVar(player, VAR_DESIRED_XP_TYPE, xpType);
|
|
|
|
string prompt = "Select the amount of XP you desire in the right box";
|
|
string title = "Select your desired XP amount";
|
|
sui.transfer(self, player, prompt, title, "Available", XP_AMOUNT, "Amount", 0, HANDLER_XP_AMOUNT_SELECT);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleXpAmountSelect()
|
|
{
|
|
obj_id player = sui.getPlayerId(params);
|
|
int btn = sui.getIntButtonPressed(params);
|
|
int amt = sui.getTransferInputTo(params);
|
|
|
|
if ( btn == sui.BP_CANCEL )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string xpType = getStringObjVar(player, VAR_DESIRED_XP_TYPE);
|
|
if ( xpType.equals("") )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
removeObjVar(player, VAR_DESIRED_XP_TYPE);
|
|
|
|
/*
|
|
prose_package pp = prose.getPackage(PROSE_GRANT_XP, "@exp_n:" + xpType, amt);
|
|
sendSystemMessageProse(player, pp);
|
|
|
|
pclib.msgGrantXP(player, xpType, amt);
|
|
*/
|
|
|
|
xp.grant(player, xpType, amt);
|
|
|
|
dictionary d = new dictionary();
|
|
d.put("xpType", xpType);
|
|
d.put("playerId", player);
|
|
|
|
messageTo(self, "handleDisplayXp", d, 1, false);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleDisplayXp()
|
|
{
|
|
obj_id player = params.getObjId("playerId");
|
|
string xpType = params.getString("xpType");
|
|
|
|
string_id PROSE_HAVE_XP = new string_id("base_player", "prose_have_xp");
|
|
|
|
int xp = getExperiencePoints(player, xpType);
|
|
|
|
prose_package pp = prose.getPackage(PROSE_HAVE_XP, "@exp_n:" + xpType, xp);
|
|
sendSystemMessageProse(player, pp);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|