mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
166 lines
5.0 KiB
Plaintext
166 lines
5.0 KiB
Plaintext
/*
|
|
systems.collections.collection_gcw.script
|
|
Player uses the item this script is attached to consume the item and grant GCW points.
|
|
The item this script is attached to is a reward from the collection system.
|
|
Authors: Jesse Benjamin, James Michener, and Jeff Haskell
|
|
*/
|
|
|
|
//libraries
|
|
include library.collection;
|
|
include library.factions;
|
|
include library.gcw;
|
|
include library.sui;
|
|
include library.utils;
|
|
|
|
//constants
|
|
|
|
const string PID_NAME = "gcw_consume";
|
|
|
|
const string_id SID_GCW_CONSUME_PROMPT = new string_id("collection", "consume_gcw_prompt");
|
|
const string_id SID_GCW_CONSUME_TITLE = new string_id("collection", "consume_gcw_title");
|
|
const string_id SID_GCW_CONSUME_ITEM = new string_id("collection", "consume_gcw_item");
|
|
const string_id WRONG_FACTION = new string_id("collection", "wrong_faction");
|
|
const string_id USED_ITEM = new string_id("collection", "gcw_point_item_used");
|
|
|
|
//triggers
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
//set gcw_item to self
|
|
obj_id gcw_item = self;
|
|
|
|
string faction = factions.getFaction(player);
|
|
if(faction == null || faction.equals(""))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//can only consume if you have it picked up
|
|
if(utils.isNestedWithinAPlayer(gcw_item))
|
|
{
|
|
mi.addRootMenu (menu_info_types.SERVER_MENU10, SID_GCW_CONSUME_ITEM);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if(!isIdValid(player))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
sendDirtyObjectMenuNotification(self);
|
|
//set gcw_item to self
|
|
obj_id gcw_item = self;
|
|
|
|
if (item == menu_info_types.SERVER_MENU10 && utils.isNestedWithinAPlayer(gcw_item))
|
|
{
|
|
if(sui.hasPid(player, PID_NAME))
|
|
{
|
|
int pid = sui.getPid(player, PID_NAME);
|
|
forceCloseSUIPage(pid);
|
|
}
|
|
//get the player's faction
|
|
string faction = factions.getFaction(player);
|
|
if(faction == null || faction.equals(""))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//make sure the item has the correct objvar
|
|
string itemFaction = "";
|
|
if(hasObjVar(gcw_item, "faction"))
|
|
{
|
|
itemFaction = getStringObjVar(gcw_item, "faction");
|
|
}
|
|
//make sure their faction matches with the item.
|
|
if(toLower(faction).equals("rebel") && itemFaction.equals(toLower(faction)))
|
|
{
|
|
int pid = sui.msgbox(self, player, "@" + SID_GCW_CONSUME_PROMPT, sui.YES_NO, "@" + SID_GCW_CONSUME_TITLE, "handlerSuiGrantGcwPoints");
|
|
sui.setPid(player, pid, PID_NAME);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if(toLower(faction).equals("imperial") && itemFaction.equals(toLower(faction)))
|
|
{
|
|
int pid = sui.msgbox(self, player, "@" + SID_GCW_CONSUME_PROMPT, sui.YES_NO, "@" + SID_GCW_CONSUME_TITLE, "handlerSuiGrantGcwPoints");
|
|
sui.setPid(player, pid, PID_NAME);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
//You are not of the appropriate faction - you can not use this item.
|
|
sendSystemMessage(player, WRONG_FACTION);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//messageHandlers
|
|
|
|
messageHandler handlerSuiGrantGcwPoints ()
|
|
{
|
|
//set gcw_item to self
|
|
obj_id gcw_item = self;
|
|
|
|
//check params
|
|
if(params == null || params.isEmpty())
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//get players id
|
|
obj_id player = sui.getPlayerId(params);
|
|
|
|
if(!isIdValid(player))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//get button pressed
|
|
int bp = sui.getIntButtonPressed(params);
|
|
|
|
//if they pressed cancel then we bail out and do nothing
|
|
if ( bp == sui.BP_CANCEL )
|
|
{
|
|
sui.removePid(player, PID_NAME);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(!sui.hasPid(player, PID_NAME))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//Lets validate again to ensure the player is of the correct faction
|
|
|
|
if(hasObjVar(gcw_item, "collection.gcw_point_value"))
|
|
{
|
|
//Get modify amount from the item.
|
|
int gcw_amount = getIntObjVar(gcw_item, "collection.gcw_point_value");
|
|
//Modify the player's GCW points
|
|
pvpModifyCurrentGcwPoints(player, gcw_amount);
|
|
sendSystemMessage(player, USED_ITEM);
|
|
|
|
//Decrement so we can allow stacking
|
|
decrementCount(gcw_item);
|
|
|
|
//Get player name for the CS Log
|
|
string playerName = getPlayerName(player);
|
|
//Destroy the object now -
|
|
if(!exists(gcw_item))
|
|
{
|
|
CustomerServiceLog("CollectionLootChannel", playerName + "(" + player + ") has acquired " + gcw_amount + " GCW points by consuming a GCW Collection Reward (" + gcw_item + ") was deleted(consumed) *by design*.");
|
|
}
|
|
else
|
|
{
|
|
//The item was not deleted for some reason - remove the point value
|
|
//so they can not use it again - Generate CS Logs.
|
|
//removeObjVar(gcw_item, "collection.gcw_point_value");
|
|
CustomerServiceLog("CollectionLootChannel", playerName + "(" + player + ") has acquired " + gcw_amount + " GCW points by consuming a GCW Collection Reward (" + gcw_item + ") was NOT DELETED!!! CONTACT SWG DESIGN([email protected])");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Get player name for the CS Log
|
|
string playerName = getPlayerName(player);
|
|
//Customer Service Log Here - this item is broken.
|
|
CustomerServiceLog("CollectionLootChannel: ", "BrokenLoot: " + gcw_item + " did not give " + playerName + "(" + player + ") GCW Points due to a bad objvar");
|
|
}
|
|
sui.removePid(player, PID_NAME);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|