mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
169 lines
4.6 KiB
Plaintext
169 lines
4.6 KiB
Plaintext
include library.resource;
|
|
include library.sui;
|
|
include library.utils;
|
|
|
|
const string STF = "recycler_messages";
|
|
|
|
trigger OnAboutToReceiveItem(obj_id srcContainer, obj_id player, obj_id item)
|
|
{
|
|
if ( !utils.isNestedWithin(self, player) )
|
|
return SCRIPT_OVERRIDE;
|
|
|
|
if (isResourceContainer (item))
|
|
{
|
|
obj_id container = getResourceContainerResourceType(item);
|
|
obj_id recycle = getRecycledVersionOfResourceType(container);
|
|
|
|
if (recycle == container)
|
|
{
|
|
string_id alreadyRecycled = new string_id (STF, "already_recycled");
|
|
sendSystemMessage (player, alreadyRecycled);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
string name = getResourceClass (container);
|
|
string typeName = getResourceName(container);
|
|
|
|
string currentSet = getStringObjVar (self, "current_set");
|
|
|
|
if (currentSet == null || currentSet == "")
|
|
{
|
|
currentSet = "milk";
|
|
setObjVar (self, "current_set", currentSet);
|
|
}
|
|
|
|
if (isResourceClassDerivedFrom(name, currentSet))
|
|
{
|
|
// Special case for Fish and Meat because fish is technically a subset of meat
|
|
// but we want the two seperated out, so seafood won't work when the machine is
|
|
// set to do meats.
|
|
int stringCheck = name.indexOf("seafood");
|
|
if ((stringCheck > -1) && (currentSet == "meat"))
|
|
{
|
|
string_id hide = new string_id (STF, "only_" + currentSet);
|
|
sendSystemMessage(player, hide);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
obj_id type = getResourceTypeByName (typeName);
|
|
int amount = getResourceContainerQuantity(item);
|
|
obj_id inv = utils.getInventoryContainer (player);
|
|
obj_id generic = createResourceCrate(recycle, amount, inv);
|
|
|
|
if (generic == null)
|
|
{
|
|
int emptySpace = getVolumeFree(inv);
|
|
if (emptySpace < 1)
|
|
{
|
|
string_id noRoom = new string_id (STF, "no_room_in_inventory");
|
|
sendSystemMessage (player, noRoom);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
string_id noRecycleType = new string_id (STF, "no_type");
|
|
sendSystemMessage(player, noRecycleType);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
else
|
|
{
|
|
string_id success = new string_id (STF, "success");
|
|
sendSystemMessage(player, success);
|
|
|
|
dictionary webster = new dictionary();
|
|
webster.put ("item", item);
|
|
|
|
// I'm messaging the destroy because if it tries to do it in the same frame
|
|
// the container got it, it kicks out an error message, even though it actually
|
|
// destroys it.
|
|
messageTo (self, "destroyResource", webster, 1.0f, false);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
string_id hide = new string_id (STF, "only_" + currentSet);
|
|
sendSystemMessage(player, hide);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string_id noResource = new string_id (STF, "no_resource");
|
|
sendSystemMessage(player, noResource);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
string_id choose = new string_id (STF, "choose_type");
|
|
string_id bordens = new string_id (STF, "milk");
|
|
string_id steak = new string_id (STF, "meat");
|
|
string_id skull = new string_id (STF, "bone");
|
|
string_id trumpet = new string_id (STF, "bone_horn");
|
|
string_id skins = new string_id (STF, "hide");
|
|
string_id lobster = new string_id (STF, "seafood");
|
|
|
|
int mnuOptions = -1;
|
|
menu_info_data mid = mi.getMenuItemByType(menu_info_types.SERVER_MENU1);
|
|
if ( mid == null )
|
|
{
|
|
mnuOptions = mi.addRootMenu(menu_info_types.SERVER_MENU1, choose);
|
|
}
|
|
else
|
|
{
|
|
mnuOptions = mid.getId();
|
|
}
|
|
|
|
if ( mnuOptions > 0 )
|
|
{
|
|
int subClass = mi.addSubMenu(mnuOptions, menu_info_types.SERVER_MENU7, skins);
|
|
int subClass2 = mi.addSubMenu(mnuOptions, menu_info_types.SERVER_MENU2, steak);
|
|
int subClass3 = mi.addSubMenu(mnuOptions, menu_info_types.SERVER_MENU3, skull);
|
|
int subClass4 = mi.addSubMenu(mnuOptions, menu_info_types.SERVER_MENU4, trumpet);
|
|
int subClass5 = mi.addSubMenu(mnuOptions, menu_info_types.SERVER_MENU5, lobster);
|
|
int subClass6 = mi.addSubMenu(mnuOptions, menu_info_types.SERVER_MENU6, bordens);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if ( item == menu_info_types.SERVER_MENU7)
|
|
{
|
|
setObjVar (self, "current_set", "hide");
|
|
}
|
|
|
|
if ( item == menu_info_types.SERVER_MENU2)
|
|
{
|
|
setObjVar (self, "current_set", "meat");
|
|
}
|
|
|
|
if ( item == menu_info_types.SERVER_MENU3)
|
|
{
|
|
setObjVar (self, "current_set", "bone");
|
|
}
|
|
|
|
if ( item == menu_info_types.SERVER_MENU4)
|
|
{
|
|
setObjVar (self, "current_set", "bone_horn");
|
|
}
|
|
|
|
if ( item == menu_info_types.SERVER_MENU5)
|
|
{
|
|
setObjVar (self, "current_set", "seafood");
|
|
}
|
|
|
|
if ( item == menu_info_types.SERVER_MENU6)
|
|
{
|
|
setObjVar (self, "current_set", "milk");
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler destroyResource ()
|
|
{
|
|
obj_id item = params.getObjId ("item");
|
|
destroyObject (item);
|
|
return SCRIPT_CONTINUE;
|
|
} |