mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-02 02:15:48 -04:00
83 lines
1.9 KiB
Plaintext
83 lines
1.9 KiB
Plaintext
//------------------------------------------------
|
|
// Includes
|
|
//------------------------------------------------
|
|
|
|
include library.utils;
|
|
include library.scout;
|
|
|
|
//------------------------------------------------
|
|
// Constants
|
|
//------------------------------------------------
|
|
|
|
const string_id SID_APPLY_CAMO = new string_id( "skl_use", "skl_apply_camo" );
|
|
|
|
//------------------------------------------------
|
|
// OnObjectMenuRequest
|
|
//------------------------------------------------
|
|
|
|
trigger OnObjectMenuRequest( obj_id player, menu_info mi )
|
|
{
|
|
int count = getCount( self );
|
|
if ( count < 0 )
|
|
{
|
|
destroyObject( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Only needs to be gated on the client.
|
|
obj_id pInv = utils.getInventoryContainer( player );
|
|
obj_id[] contents = utils.getContents( pInv, true );
|
|
int found = 0;
|
|
for ( int i=0; i<contents.length; i++ )
|
|
{
|
|
if ( contents[i] == self )
|
|
{
|
|
found = 1;
|
|
break;
|
|
}
|
|
}
|
|
if ( found == 0 )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
mi.addRootMenu( menu_info_types.ITEM_USE, SID_APPLY_CAMO );
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// OnObjectMenuSelect
|
|
//------------------------------------------------
|
|
|
|
trigger OnObjectMenuSelect( obj_id player, int item )
|
|
{
|
|
// Item was used.
|
|
if ( item == menu_info_types.ITEM_USE )
|
|
{
|
|
// Apply the camo to ourselves.
|
|
scout.conceal( player, null );
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// OnGetAttributes
|
|
//------------------------------------------------
|
|
|
|
trigger OnGetAttributes( obj_id player, string[] names, string[] attribs )
|
|
{
|
|
int idx = utils.getValidAttributeIndex( names );
|
|
if ( idx == -1 )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int count = getCount( self );
|
|
names[idx] = "quantity";
|
|
attribs[idx] = Integer.toString( count );
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
return SCRIPT_CONTINUE;
|
|
} |