mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-10-21 12:03:08 -04:00
63 lines
1.8 KiB
Plaintext
63 lines
1.8 KiB
Plaintext
/**
|
|
* Title: main chocolate fountain
|
|
* Description: Turn Berries into Choc Berries
|
|
*/
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
include library.utils;
|
|
include library.static_item;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const string_id FOUNTAIN_USE = new string_id("spam", "fountain_use");
|
|
const string_id ALREADY_HAVE = new string_id("spam", "already_have");
|
|
const string_id BERRY_GRANTED = new string_id("spam", "berry_granted");
|
|
|
|
//update these every year
|
|
const string OBJ_BERRY_ONE = "item_event_ewok_berry_01_01";
|
|
const string OBJ_BERRY_TWO = "item_event_ewok_berry_01_02";
|
|
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
if(utils.playerHasStaticItemInBankOrInventory(player, OBJ_BERRY_ONE))
|
|
mi.addRootMenu(menu_info_types.ITEM_USE, FOUNTAIN_USE);
|
|
|
|
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 && utils.playerHasStaticItemInBankOrInventory(player, OBJ_BERRY_ONE))
|
|
{
|
|
if(!utils.playerHasStaticItemInBankOrInventory(player, OBJ_BERRY_TWO))
|
|
convertBerry(player);
|
|
else
|
|
sendSystemMessage(player, ALREADY_HAVE);
|
|
|
|
sendDirtyObjectMenuNotification(self);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
boolean convertBerry(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
return false;
|
|
|
|
obj_id inv = utils.getInventoryContainer(player);
|
|
|
|
obj_id berryOne = utils.getStaticItemInInventory(player, OBJ_BERRY_ONE);
|
|
|
|
if(isIdValid(berryOne))
|
|
{
|
|
obj_id berryTwo = static_item.createNewItemFunction(OBJ_BERRY_TWO, inv);
|
|
doAnimationAction(player, "manipulate_medium");
|
|
sendSystemMessage(player, BERRY_GRANTED);
|
|
destroyObject(berryOne);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|