mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
148 lines
3.9 KiB
Plaintext
148 lines
3.9 KiB
Plaintext
|
|
include library.sui;
|
|
include library.utils;
|
|
include library.prose;
|
|
include library.minigame;
|
|
|
|
const string STF = "som/som_item";
|
|
|
|
const string_id MNU_TACKLE = new string_id(minigame.STF_FISH, "mnu_open_tackle");
|
|
const string_id MNU_BAIT = new string_id(minigame.STF_FISH, "mnu_set_bait");
|
|
const string_id MNU_CLEAR_BAIT = new string_id(minigame.STF_FISH, "mnu_clear_bait");
|
|
const string_id MNU_START_FISHING = new string_id(minigame.STF_FISH, "mnu_start_fishing");
|
|
const string_id MNU_STOP_FISHING = new string_id(minigame.STF_FISH, "mnu_stop_fishing");
|
|
const string_id SID_NO_FISH_IN_SPACE = new string_id("space/space_interaction", "no_fish_in_space");
|
|
|
|
const string STF_FISH = "fishing";
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
string planetName = getCurrentSceneName();
|
|
|
|
if (planetName.startsWith("mustafar"))
|
|
{
|
|
sendSystemMessage(self, new string_id(STF, "cannot_fish"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id inv = utils.getInventoryContainer(player);
|
|
if ( !isIdValid(inv) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id held = getObjectInSlot(player, "hold_r");
|
|
if ( utils.isNestedWithin(self, inv) || (self == held) )
|
|
{
|
|
boolean isPoleInUse = minigame.isPoleInUse(self);
|
|
|
|
//int mnuTackle = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_TACKLE);
|
|
|
|
/*if ( held != self )
|
|
{
|
|
int mnuEquip = mi.addRootMenu(menu_info_types.ITEM_EQUIP, new string_id("",""));
|
|
}
|
|
else
|
|
{
|
|
int mnuUnequip = mi.addRootMenu(menu_info_types.ITEM_UNEQUIP, new string_id("",""));
|
|
}*/
|
|
|
|
if ( !isPoleInUse )
|
|
{
|
|
if ( held == self )
|
|
{
|
|
int mnuCast = mi.addRootMenu(menu_info_types.SERVER_MENU2, MNU_START_FISHING);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
int mnuStopFishing = mi.addRootMenu(menu_info_types.SERVER_MENU3, MNU_STOP_FISHING);
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
sendDirtyObjectMenuNotification(self);
|
|
// Make sure we aren't in space.
|
|
if (isSpaceScene())
|
|
{
|
|
sendSystemMessage(player, SID_NO_FISH_IN_SPACE);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id inv = utils.getInventoryContainer(player);
|
|
if ( !isIdValid(inv) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id held = getObjectInSlot(player, "hold_r");
|
|
if ( utils.isNestedWithin(self, inv) || (self == held) )
|
|
{
|
|
/*if ( item == menu_info_types.SERVER_MENU1 ) //OPEN TACKLE
|
|
{
|
|
utils.requestContainerOpen(player, self);
|
|
}
|
|
else*/ if ( item == menu_info_types.SERVER_MENU2 ) //START FISHING
|
|
{
|
|
//minigame.startFishing(player);
|
|
queueCommand(player, ##"fish", null, "", COMMAND_PRIORITY_DEFAULT);
|
|
}
|
|
else if ( item == menu_info_types.SERVER_MENU3 ) //STOP FISHING
|
|
{
|
|
minigame.stopFishing(player);
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAboutToReceiveItem(obj_id srcContainer, obj_id transferer, obj_id item)
|
|
{
|
|
int got = getGameObjectType(item);
|
|
if ( isPlayer(transferer) && got != GOT_misc_fishing_bait )
|
|
{
|
|
sendSystemMessage(self, new string_id(STF_FISH, "bait_only")); // A fishing tackle can only accept bait-type items.
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAboutToLoseItem(obj_id destContainer, obj_id transferer, obj_id item)
|
|
{
|
|
if ( utils.hasScriptVar(self, minigame.SCRIPTVAR_IN_USE) )
|
|
{
|
|
obj_id user = utils.getObjIdScriptVar(self, minigame.SCRIPTVAR_IN_USE);
|
|
if ( !isIdValid(user) )
|
|
{
|
|
utils.removeScriptVar(self, minigame.SCRIPTVAR_IN_USE);
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(self, new string_id(STF_FISH, "cannot_remove_bait")); // You cannot remove bait that is currently in use...
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
|
|
{
|
|
int idx = utils.getValidAttributeIndex(names);
|
|
if (idx == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (hasObjVar(self, "useModifier"))
|
|
{
|
|
names[idx] = "useModifier";
|
|
float attrib = getIntObjVar(self, "useModifier");
|
|
attribs[idx] = "" + attrib;
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|