Files
dsrc/sku.0/sys.server/compiled/game/script/library/food.scriptlib
T

169 lines
4.5 KiB
Plaintext

include library.utils;
include library.dot;
include library.player_stomach;
// Apply an instant food effect to the player.
void applyInstantEffect( obj_id target, obj_id item )
{
if ( !hasObjVar( item, "instant" ) )
return;
string type = getStringObjVar( item, "instant.type" );
if ( type == null )
return;
int v1 = getIntObjVar( item, "instant.v1" );
int v2 = getIntObjVar( item, "instant.v2" );
// Big switch for all the different special instant effects.
if ( type.equals( "burst_run" ) )
{
instantBurstRun( target, item, v1, v2 );
}
else if ( type.equals( "wookiee_roar" ) )
{
instantWookieeRoar( target, item, v1, v2 );
}
else if ( type.equals( "slow_dot" ) )
{
instantSlowDot( target, item, v1, v2 );
}
else if ( type.equals( "cure_fire" ) )
{
instantCureFire( target, item, v1, v2 );
}
else if ( type.equals( "enhanced_regen" ) )
{
instantEnhancedRegen( target, item, v1, v2 );
}
else if ( type.equals( "food_reduce" ) )
{
instantFoodReduce( target, item, v1, v2 );
}
}
void petEatFood( obj_id self, obj_id master, obj_id item, obj_id player )
{
if ( utils.hasScriptVar( self, "pet_food" ) )
{
int lastEatTime = utils.getIntScriptVar( self, "pet_food" );
if ( getGameTime() - lastEatTime < 3600 )
{
sendSystemMessage( master, new string_id( "error_message", "no_pet_feed" ) );
return;
}
}
// Apply the mod.
attrib_mod[] am = getAttribModArrayObjVar( item, consumable.VAR_CONSUMABLE_MODS );
if ( am != null )
utils.addAttribMod( self, am );
// Show our appreciation.
color textColor = colors.YELLOW;
chat.thinkTo( self, master, "Yummy!" );
doAnimationAction( self, "eat" );
utils.setScriptVar( self, "pet_food", getGameTime() );
// Eat the pet food.
consumable.decrementCharges( item, self );
}
void instantBurstRun( obj_id target, obj_id item, int v1, int v2 )
{
// Store burst run modifiers.
utils.setScriptVar( target, "food.burst_run.v1", v1 );
utils.setScriptVar( target, "food.burst_run.v2", v2 );
// Queue the normal burst run command.
queueCommand( target, ##"burstRun", null, "", COMMAND_PRIORITY_FRONT );
// Message the player.
sendSystemMessage( target, new string_id( "combat_effects", "instant_burst_run" ) );
}
void instantWookieeRoar( obj_id target, obj_id item, int v1, int v2 )
{
// Store roar modifiers.
utils.setScriptVar( target, "food.wookiee_roar.v1", v1 );
// Queue the roar.
queueCommand( target, ##"wookieeRoar", null, "", COMMAND_PRIORITY_IMMEDIATE );
// Message the player.
// sendSystemMessage( target, new string_id( "combat_effects", "instant_wookiee_roar" ) );
}
void instantSlowDot( obj_id target, obj_id item, int v1, int v2 )
{
// Get a list of dots on the player.
if ( !utils.hasScriptVarTree( target, dot.VAR_DOT ) )
return;
if ( utils.hasScriptVar( target, "slowDotTime" ) )
{
int time = utils.getIntScriptVar( target, "slowDotTime" );
if ( getGameTime() - time < 900 )
{
sendSystemMessage( target, new string_id( "combat_effects", "slow_dot_wait" ) );
return;
}
}
float mod = 1f - (v1/100f);
string[] dots = dot.getAllDots(target);
if (dots != null)
{
for ( int i=0; i<dots.length; i++ )
{
String varName = dot.VAR_DOT_ROOT + dots[i] + dot.VAR_DURATION;
int duration = utils.getIntScriptVar( target, varName );
duration *= mod;
utils.setScriptVar( target, varName, duration );
}
}
utils.setScriptVar( target, "slowDotTime", getGameTime() );
prose_package pp = prose.getPackage( new string_id( "combat_effects", "slow_dot_done" ), v1 );
sendSystemMessageProse( target, pp );
}
void instantCureFire( obj_id target, obj_id item, int v1, int v2 )
{
// Get a list of dots on the player.
if ( !dot.isOnFire(target) )
return;
if ( rand(1, 100) > v1 )
{
// Has no effect.
sendSystemMessage( target, new string_id( "combat_effects", "fire_cure_no_effect" ) );
return;
}
dot.reduceDotTypeStrength( target, dot.DOT_FIRE, 10000 );
sendSystemMessage( target, new string_id( "combat_effects", "fire_cured" ) );
}
void instantEnhancedRegen( obj_id target, obj_id item, int v1, int v2 )
{
// Store regen modifiers.
utils.setScriptVar( target, "food.enhanced_regen.v1", v1 );
// Queue the roar.
queueCommand( target, ##"regeneration", null, "", COMMAND_PRIORITY_IMMEDIATE );
// Message the player.
// sendSystemMessage( target, new string_id( "combat_effects", "instant_wookiee_roar" ) );
}
void instantFoodReduce( obj_id target, obj_id item, int v1, int v2 )
{
// Lower our stomach a bit.
player_stomach.addToStomach( target, 0, -1*v1 );
// Message the player.
sendSystemMessage( target, new string_id( "combat_effects", "feel_hungry" ) );
}