mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
244 lines
5.8 KiB
Plaintext
244 lines
5.8 KiB
Plaintext
include library.utils;
|
|
include library.consumable;
|
|
include library.player_stomach;
|
|
include library.healing;
|
|
|
|
inherits item.comestible.comestible;
|
|
|
|
trigger OnGetAttributes( obj_id player, string[] names, string[] attribs )
|
|
{
|
|
string food_type = getStringObjVar( self, "food_type" );
|
|
|
|
// Quantity.
|
|
int count = getCount( self );
|
|
if ( count > 0 )
|
|
{
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if ( n == -1 )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
names[n] = "quantity";
|
|
attribs[n] = Integer.toString( count );
|
|
}
|
|
|
|
// Stomach filling.
|
|
if ( hasObjVar( self, consumable.VAR_CONSUMABLE_STOMACH_VALUES ) )
|
|
{
|
|
int[] stomach = getIntArrayObjVar( self, consumable.VAR_CONSUMABLE_STOMACH_VALUES );
|
|
if ( stomach[0] > 0 )
|
|
{
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if ( n == -1 )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
names[n] = "stomach_food";
|
|
attribs[n] = Integer.toString( stomach[0] );
|
|
}
|
|
else if ( stomach[1] > 0 )
|
|
{
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if ( n == -1 )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
names[n] = "stomach_drink";
|
|
attribs[n] = Integer.toString( stomach[1] );
|
|
}
|
|
}
|
|
|
|
// Stat mod food.
|
|
if ( hasObjVar( self, consumable.VAR_CONSUMABLE_MODS ) )
|
|
{
|
|
attrib_mod[] am = getAttribModArrayObjVar(self, consumable.VAR_CONSUMABLE_MODS);
|
|
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if (n == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
|
|
names[n] = EXAM_ATTRIB_MOD;
|
|
|
|
if ( (am == null) || (am.length == 0) )
|
|
{
|
|
attribs[n] = EXAM_NONE;
|
|
n++;
|
|
if (n > names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
int numMods = am.length;
|
|
|
|
attribs[n] = "" + numMods;
|
|
n++;
|
|
if (n > names.length)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
for ( int i = 0; i < numMods; i++ )
|
|
{
|
|
int attrib = am[i].getAttribute();
|
|
// int val = healing.getBuffPercentage(am[i].getValue());
|
|
int val = Integer.MIN_VALUE;
|
|
int duration = (int)(am[i].getDuration());
|
|
|
|
string sVal = "";
|
|
|
|
if ( val > 0 )
|
|
sVal = "+" + val;
|
|
else if ( val < 0 )
|
|
sVal = "" + val;
|
|
|
|
int minutes = duration / 60;
|
|
int seconds = duration - (minutes*60);
|
|
|
|
names[n] = toLower(consumable.STAT_NAME[attrib]);
|
|
attribs[n] = sVal + "% for " + minutes + "m " + seconds + "s";
|
|
LOG("examine", n + ": " + names[n] + " -> " + attribs[n]);
|
|
|
|
n++;
|
|
if ( n > names.length )
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Skill mod food.
|
|
if ( hasObjVar( self, "skill_mod" ) )
|
|
{
|
|
string mod = getStringObjVar( self, "skill_mod.name" );
|
|
float amount = getFloatObjVar( self, "skill_mod.amount" );
|
|
float dur = getFloatObjVar( self, "skill_mod.dur" );
|
|
int duration = (int) dur;
|
|
|
|
int minutes = duration / 60;
|
|
int seconds = duration - (minutes*60);
|
|
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if (n == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
string lmod = localize( new string_id( "stat_n", mod ) );
|
|
names[n] = "skill";
|
|
attribs[n] = lmod;
|
|
n++;
|
|
names[n] = "modifier";
|
|
attribs[n] = "+" + amount;
|
|
n++;
|
|
names[n] = "duration";
|
|
attribs[n] = minutes + "m " + seconds + "s";
|
|
}
|
|
|
|
// Mind healing food.
|
|
if ( hasObjVar( self, "mind_heal" ) )
|
|
{
|
|
int amount = getIntObjVar( self, "mind_heal" );
|
|
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if (n == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
names[n] = "mind_heal";
|
|
attribs[n] = Integer.toString( amount );
|
|
}
|
|
|
|
// Delayed special effect food.
|
|
if ( hasObjVar( self, "delayed.type" ) )
|
|
{
|
|
string delay_type = getStringObjVar( self, "delayed.type" );
|
|
int delay_eff = getIntObjVar( self, "delayed.eff" );
|
|
int duration = getIntObjVar( self, "delayed.dur" );
|
|
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if (n == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
names[n] = "delay_effect";
|
|
attribs[n] = localize( new string_id( "obj_attr_n", delay_type+"_d" ) );
|
|
if ( delay_eff > 0 )
|
|
{
|
|
n++;
|
|
names[n] = delay_type+"_eff";
|
|
attribs[n] = Integer.toString( delay_eff );
|
|
}
|
|
if ( duration > 0 )
|
|
{
|
|
n++;
|
|
names[n] = delay_type+"_dur";
|
|
attribs[n] = Integer.toString( duration );
|
|
}
|
|
}
|
|
|
|
// Duration special effect food.
|
|
if ( hasObjVar( self, "duration.type" ) )
|
|
{
|
|
string duration_type = getStringObjVar( self, "duration.type" );
|
|
int duration_eff = getIntObjVar( self, "duration.eff" );
|
|
int duration = getIntObjVar( self, "duration.dur" );
|
|
|
|
int minutes = duration / 60;
|
|
int seconds = duration - (minutes*60);
|
|
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if (n == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
names[n] = "duration_effect";
|
|
attribs[n] = localize( new string_id( "obj_attr_n", duration_type+"_d" ) );
|
|
if ( duration_eff > 0 )
|
|
{
|
|
n++;
|
|
names[n] = duration_type+"_eff";
|
|
attribs[n] = Integer.toString( duration_eff );
|
|
}
|
|
if ( duration > 0 )
|
|
{
|
|
n++;
|
|
names[n] = "duration";
|
|
attribs[n] = minutes + "m " + seconds + "s";
|
|
}
|
|
}
|
|
|
|
// Instant special effect food.
|
|
if ( hasObjVar( self, "instant.type" ) )
|
|
{
|
|
string instant_type = getStringObjVar( self, "instant.type" );
|
|
int instant_v1 = getIntObjVar( self, "instant.v1" );
|
|
int instant_v2 = getIntObjVar( self, "instant.v2" );
|
|
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if (n == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
names[n] = "instant_effect";
|
|
attribs[n] = localize( new string_id( "obj_attr_n", instant_type+"_d" ) );
|
|
if ( instant_v1 > 0 )
|
|
{
|
|
n++;
|
|
names[n] = instant_type+"_v1";
|
|
attribs[n] = Integer.toString( instant_v1 );
|
|
}
|
|
if ( instant_v2 > 0 )
|
|
{
|
|
n++;
|
|
names[n] = instant_type+"_v2";
|
|
attribs[n] = Integer.toString( instant_v2 );
|
|
}
|
|
}
|
|
|
|
// Race restriction?
|
|
if ( hasObjVar( self, "race_restriction" ) )
|
|
{
|
|
int n = utils.getValidAttributeIndex( names );
|
|
if (n == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int race = getIntObjVar( self, "race_restriction" );
|
|
names[n] = "race_restriction";
|
|
if ( race == -2 )
|
|
attribs[n] = localize( new string_id( "obj_attr_n", "speciespet" ) );
|
|
else
|
|
attribs[n] = localize( new string_id( "obj_attr_n", "species"+race ) );
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|