mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
111 lines
2.7 KiB
Plaintext
111 lines
2.7 KiB
Plaintext
/**
|
|
|
|
*
|
|
* Title: outdoorsman.script
|
|
* Description: scout command handlers
|
|
|
|
*/
|
|
|
|
//------------------------------------------------
|
|
// Includes
|
|
//------------------------------------------------
|
|
|
|
include library.permissions;
|
|
include library.corpse;
|
|
include library.prose;
|
|
|
|
//------------------------------------------------
|
|
// Constants
|
|
//------------------------------------------------
|
|
|
|
// Harvesting
|
|
const string_id PROSE_HARVEST_FAILED = new string_id("error_message","prose_harvest_corpse_failed");
|
|
const string_id SID_HARVEST_FAILED = new string_id("error_message","harvest_corpse_failed");
|
|
|
|
const string_id SID_NO_RESOURCE = new string_id("error_message","no_resource");
|
|
|
|
//------------------------------------------------
|
|
// Methods
|
|
//------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------
|
|
// CORPSE HARVESTING
|
|
//------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------
|
|
// cmdHarvestCorpse
|
|
//------------------------------------------------
|
|
|
|
commandHandler cmdHarvestCorpse()
|
|
{
|
|
if ( !isIdValid(target) || params == null )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
// Do we have permission to harvest?
|
|
boolean canOpen = corpse.hasLootPermissions(target, self);
|
|
|
|
if ( !canOpen )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
// Does the target have resources?
|
|
if ( !hasObjVar(target, corpse.VAR_HAS_RESOURCE) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
// Does the target have the resource we want?
|
|
boolean found = false;
|
|
int[] hasResource = getIntArrayObjVar( target, corpse.VAR_HAS_RESOURCE );
|
|
if ( params == "meat" )
|
|
{
|
|
if ( hasResource[corpse.CCR_MEAT] > 0 )
|
|
found = true;
|
|
}
|
|
else if ( params == "hide" )
|
|
{
|
|
if ( hasResource[corpse.CCR_HIDE] > 0 )
|
|
found = true;
|
|
}
|
|
else if ( params == "bone" )
|
|
{
|
|
if ( hasResource[corpse.CCR_BONE] > 0 )
|
|
found = true;
|
|
}
|
|
else if ( params == "" )
|
|
{
|
|
found = true;
|
|
}
|
|
|
|
if ( !found )
|
|
{
|
|
// Can't harvest.
|
|
sendSystemMessage( self, SID_NO_RESOURCE );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Send harvest message.
|
|
dictionary outparams = new dictionary();
|
|
outparams.put( "player", self );
|
|
outparams.put( "args", params );
|
|
messageTo( target, "harvestCorpse", outparams, 0.f, false );
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// cmdHarvestCorpseFail
|
|
//------------------------------------------------
|
|
|
|
commandHandler cmdHarvestCorpseFail()
|
|
{
|
|
if ( target == null )
|
|
{
|
|
sendSystemMessage(self, SID_HARVEST_FAILED);
|
|
}
|
|
else
|
|
{
|
|
prose_package pp = prose.getPackage( PROSE_HARVEST_FAILED, target );
|
|
sendSystemMessageProse( self, pp );
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|