mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-02 02:15:48 -04:00
76 lines
1.5 KiB
Plaintext
76 lines
1.5 KiB
Plaintext
include library.utils;
|
|
include library.beast_lib;
|
|
include library.static_item;
|
|
|
|
/***** CONSTANTS ****************************************************/
|
|
|
|
const string_id SID_FEED_BEAST = new string_id("beast", "menu_feed");
|
|
|
|
/***** TRIGGERS *****************************************************/
|
|
|
|
trigger OnAttach()
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
if(!utils.isNestedWithin(self, player))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int management_root = mi.addRootMenu (menu_info_types.ITEM_USE, SID_FEED_BEAST);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
|
|
{
|
|
int idx = utils.getValidAttributeIndex(names);
|
|
if (idx == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int count = getCount(self);
|
|
|
|
if(count > 0)
|
|
{
|
|
names[idx] = "count";
|
|
attribs[idx] = "" + count;
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if(!utils.isNestedWithin(self, player))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
|
|
if(item == menu_info_types.ITEM_USE)
|
|
{
|
|
obj_id beast = beast_lib.getBeastOnPlayer(player);
|
|
|
|
if(!isIdValid(beast))
|
|
{
|
|
sendSystemMessage(player, beast_lib.SID_NO_BEAST);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(isDead(beast))
|
|
{
|
|
sendSystemMessage(player, new string_id("beast", "beast_cant_when_dead"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
beast_lib.applyFoodEffect(self, beast, player);
|
|
static_item.decrementStaticItem (self);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|