Files
dsrc/sku.0/sys.server/compiled/game/script/harvesting/shellfish_harvesting.script
T
2013-09-10 23:17:15 -07:00

170 lines
4.5 KiB
Plaintext

/**
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
* All Rights Reserved
*
* Title: shellfish harvesting
* DesCRiption: device used to gather mollusks and shellfish
* @author $AutHor: Eli Holding$
* @version $Revision:$
*/
/***** INCLUDES ********************************************************/
include library.sui;
include library.utils;
include library.resource;
include library.prose;
include library.colors;
include library.minigame;
/***** INCLUDES ********************************************************/
/***** CONSTANTS *******************************************************/
const string_id SID_USE = new string_id("sui", "use");
const string_id SID_FOUND_NOTHING = new string_id("harvesting", "found_nothing");
const string_id SID_FOUND_MOLLUSKS = new string_id("harvesting", "found_mollusks");
const string_id SID_FOUND_CRUSTACEANS = new string_id("harvesting", "found_crustaceans");
const string_id SID_SWIMMING = new string_id("harvesting", "swimming");
const string_id SID_INSIDE = new string_id("harvesting", "inside");
const string_id SID_IN_WATER = new string_id("harvesting", "in_water");
const string_id SID_SAMPLE_MIND = new string_id("error_message","sample_mind");
const string_id SID_SURVEY_ON_MOUNT = new string_id("error_message","survey_on_mount");
const string_id SID_BUSY = new string_id("harvesting", "busy");
const string_id SID_INV_FULL = new string_id("harvesting", "inv_full");
const int SAMPLE_ACTION_COST = 50;
/***** TRIGGERS ********************************************************/
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
if ( !utils.isNestedWithin(self, player) )
return SCRIPT_CONTINUE;
//mi.addRootMenu (menu_info_types.ITEM_USE, SID_USE);
menu_info_data mid = mi.getMenuItemByType (menu_info_types.ITEM_USE);
if (mid != null)
{
mid.setServerNotify (true);
}
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
if(item == menu_info_types.ITEM_USE)
{
use( self, player );
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
void use( obj_id self, obj_id player )
{
//make sure we have enough space in our inventory
obj_id inventory = utils.getInventoryContainer(player);
if(getVolumeFree(inventory) <= 0)
{
// system message: no room in inventory
sendSystemMessage(player, SID_INV_FULL);
return;
}
//make sure we are in players inventory
obj_id pInv = utils.getInventoryContainer( player );
if ( !isIdValid( pInv ) )
return;
//make sure we are not swimming
if ( getState(player, STATE_SWIMMING) != 0 )
{
sendSystemMessage( player, SID_SWIMMING );
return;
}
//make sure we are not mounted
obj_id playerCurrentMount = getMountId (player);
if ( isIdValid( playerCurrentMount ) )
{
sendSystemMessage(player, SID_SURVEY_ON_MOUNT);
return;
}
//make sure we are not inside
location here = getLocation(player);
if ( here == null )
return;
if ( isIdValid(here.cell) )
{
sendSystemMessage( player, SID_INSIDE );
return;
}
//make sure we are standing in water
if ( !minigame.isLocationFishable ( here ) )
{
sendSystemMessage( player, SID_IN_WATER );
return;
}
//make sure we are not already harvesting
boolean harvesting = utils.hasScriptVar( player, "shellfish_harvesting" );
if ( harvesting )
{
// We are harvesting.
sendSystemMessage( player, SID_BUSY );
return;
}
int action = getAttrib( player, ACTION );
int actioncost = SAMPLE_ACTION_COST;
if ( !drainAttributes( player, actioncost, 0 ) )
{
// We don't have the pool to do this.
sendSystemMessage( player, SID_SAMPLE_MIND );
return;
}
utils.setScriptVar (player, "shellfish_harvesting", 1);
dictionary harvester = new dictionary();
harvester.put("player", player);
messageTo(self, "harvest", harvester, 5f, false);
}
messageHandler harvest()
{
obj_id player = params.getObjId("player");
obj_id pInv = utils.getInventoryContainer( player );
if ( !isIdValid( pInv ) )
return SCRIPT_CONTINUE;
int searchRoll = rand( 1, 100 );
if ( searchRoll < 25 )
{
sendSystemMessage( player, SID_FOUND_NOTHING );
}
else if ( searchRoll < 70 )
{
sendSystemMessage( player, SID_FOUND_MOLLUSKS );
int amt = rand( 8, 14 );
resource.createRandom( "seafood_mollusk", amt, getLocation(self), pInv, player, 2 );
}
else
{
sendSystemMessage( player, SID_FOUND_CRUSTACEANS );
int amt = rand( 8, 14 );
resource.createRandom( "seafood_crustacean", amt, getLocation(self), pInv, player, 2 );
}
utils.removeScriptVar (player, "shellfish_harvesting");
return SCRIPT_CONTINUE;
}