mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
129 lines
3.3 KiB
Plaintext
129 lines
3.3 KiB
Plaintext
//------------------------------------------------
|
|
// Include
|
|
//------------------------------------------------
|
|
|
|
include library.player_stomach;
|
|
include library.utils;
|
|
|
|
//------------------------------------------------
|
|
// Constants
|
|
//------------------------------------------------
|
|
|
|
const string_id SID_DEAD_EYE_ACTIVE = new string_id( "combat_effects", "dead_eye_active" );
|
|
const string_id SID_DEAD_EYE_ALREADY = new string_id( "combat_effects", "dead_eye_already" );
|
|
const string_id SID_DEAD_EYE_WAIT = new string_id( "combat_effects", "dead_eye_wait" );
|
|
|
|
//------------------------------------------------
|
|
// OnInitialize
|
|
//------------------------------------------------
|
|
/*
|
|
trigger OnInitialize()
|
|
{
|
|
// Test stuff.
|
|
setCount( self, 2 );
|
|
setObjVar( self, "deadeye_eff", 40 );
|
|
setObjVar( self, "deadeye_dur", 1200.f );
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
*/
|
|
//------------------------------------------------
|
|
// OnObjectMenuRequest
|
|
//------------------------------------------------
|
|
|
|
trigger OnObjectMenuRequest( obj_id player, menu_info mi )
|
|
{
|
|
menu_info_data mid = mi.getMenuItemByType( menu_info_types.ITEM_USE );
|
|
if ( mid != null )
|
|
{
|
|
mid.setServerNotify( true );
|
|
}
|
|
|
|
mid = mi.getMenuItemByType( menu_info_types.EXAMINE );
|
|
if ( mid != null )
|
|
{
|
|
mid.setServerNotify( true );
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// OnObjectMenuSelect
|
|
//------------------------------------------------
|
|
|
|
trigger OnObjectMenuSelect( obj_id player, int item )
|
|
{
|
|
if ( item == menu_info_types.ITEM_USE )
|
|
{
|
|
applyDeadEye( self, player );
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//------------------------------------------------
|
|
// applyDeadEye
|
|
//------------------------------------------------
|
|
|
|
void applyDeadEye( obj_id self, obj_id player )
|
|
{
|
|
// Check and see if we are already affected by Dead Eye.
|
|
if ( utils.hasScriptVar( player, "dead_eye.active" ) )
|
|
{
|
|
int dea = utils.getIntScriptVar( player, "dead_eye.active" );
|
|
float dur = utils.getFloatScriptVar( player, "dead_eye.dur" );
|
|
if ( getGameTime() - dea < dur )
|
|
{
|
|
sendSystemMessage( player, SID_DEAD_EYE_ALREADY );
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Decrement count.
|
|
int count = getCount( self );
|
|
count--;
|
|
setCount( self, count );
|
|
|
|
// Do a bit of stomach filling.
|
|
int[] vol = { 20, 0 };
|
|
boolean wasConsumed = player_stomach.addToStomach( player, player, vol );
|
|
|
|
// Store activation time / flag.
|
|
utils.setScriptVar( player, "dead_eye.active", getGameTime() );
|
|
utils.setScriptVar( player, "dead_eye.eff", getIntObjVar( self, "deadeye_eff" ) );
|
|
utils.setScriptVar( player, "dead_eye.dur", getFloatObjVar(self, "deadeye_dur"));
|
|
|
|
sendSystemMessage( player, SID_DEAD_EYE_ACTIVE );
|
|
|
|
// Destroy if count is zero.
|
|
if ( count <= 0 )
|
|
destroyObject( self );
|
|
}
|
|
|
|
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
|
|
{
|
|
int idx = utils.getValidAttributeIndex(names);
|
|
if (idx == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (hasObjVar(self, "deadeye_eff"))
|
|
{
|
|
names[idx] = "examine_dot_apply_power";
|
|
attribs[idx] = ""+getIntObjVar(self, "deadeye_eff")+"%";
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (hasObjVar(self, "deadeye_dur"))
|
|
{
|
|
names[idx] = "duration";
|
|
attribs[idx] = utils.formatTime((int)getFloatObjVar(self, "deadeye_dur"));
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|