mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
102 lines
2.7 KiB
Plaintext
102 lines
2.7 KiB
Plaintext
/**
|
|
* Title: lifeday gift xmas tree
|
|
* Description: Grants holiday items to the player
|
|
*/
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
include library.utils;
|
|
include library.static_item;
|
|
include library.badge;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const string_id TREE_USE = new string_id("spam", "tree_use");
|
|
const string_id NOT_OLD_ENOUGH = new string_id("spam", "not_old_enough");
|
|
const string_id GIFT_GRANTED = new string_id("spam", "gift_granted");
|
|
|
|
//update these every year
|
|
const string GIFT_SELF = "item_lifeday_gift_self_01_04";
|
|
const string GIFT_OTHER = "item_lifeday_gift_other_01_04";
|
|
|
|
//Lifeday badge
|
|
const string LIFEDAY_BADGE = "lifeday_badge_09";
|
|
const string_id TREE_BADGE = new string_id("spam", "tree_badge");
|
|
|
|
|
|
|
|
string currentYearObjVar()
|
|
{
|
|
//manually update this const value every year
|
|
return utils.XMAS_RECEIVED_IX_01;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
string config = getConfigSetting("GameServer", "grantGift");
|
|
if (config != null)
|
|
{
|
|
if (config.equals("false"))
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(!hasObjVar(player, currentYearObjVar()))
|
|
mi.addRootMenu(menu_info_types.ITEM_USE, TREE_USE);
|
|
//checking if player has received life day badge.
|
|
if (!hasCompletedCollectionSlot(player, LIFEDAY_BADGE))
|
|
mi.addRootMenu(menu_info_types.SERVER_MENU2, TREE_BADGE);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
//congrats! You clicked on the USE option, lets see if you pass all the checks
|
|
if( item == menu_info_types.ITEM_USE)
|
|
{
|
|
//check character age if they are less than 10 days no joy
|
|
if(!isGod(player))
|
|
{
|
|
if( (getCurrentBirthDate() - getPlayerBirthDate(player)) < 10 )
|
|
{
|
|
sendSystemMessage(player, NOT_OLD_ENOUGH);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
if(!hasObjVar(player, currentYearObjVar()))
|
|
grantGift(player);
|
|
}
|
|
//Granting life day badge.
|
|
if( item == menu_info_types.SERVER_MENU2)
|
|
badge.grantBadge(player, LIFEDAY_BADGE);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
|
|
boolean grantGift(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
return false;
|
|
|
|
obj_id inv = utils.getInventoryContainer(player);
|
|
|
|
obj_id giftSelf = static_item.createNewItemFunction(GIFT_SELF, inv);
|
|
|
|
obj_id giftOther = static_item.createNewItemFunction(GIFT_OTHER, inv);
|
|
setObjVar(giftOther, utils.LIFEDAY_OWNER, player);
|
|
|
|
// Mark the player has having gotten the item and send email
|
|
utils.sendMail(utils.GIFT_GRANTED_SUB, utils.GIFT_GRANTED, player, "System");
|
|
setObjVar(player, currentYearObjVar(), 1);
|
|
sendSystemMessage(player, GIFT_GRANTED);
|
|
CustomerServiceLog("grantGift", getFirstName(player) + "(" + player + ") has received his Christmas '09 gift.");
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|