Files
dsrc/sku.0/sys.server/compiled/game/script/library/grenade.scriptlib
T
2013-09-10 23:17:15 -07:00

298 lines
9.9 KiB
Plaintext

//------------------------------------------------
// grenade.scriptlib
// Brandon Reinhart
//------------------------------------------------
include library.combat;
include library.buff;
include library.dot;
include library.utils;
include library.vehicle;
const string_id SID_THROW_DELAY = new string_id( "grenade", "throw_delay" );
const string_id SID_THROW_CLASS_DELAY = new string_id( "grenade", "throw_class_delay" );
//------------------------------------------------
// canThrowGrenade
//
// Checks if the player has an outstanding reuse timer on the current grenade.
//------------------------------------------------
boolean canThrowGrenade( obj_id thrower, obj_id grenade, boolean verbose )
{
if(!combat.hasCertification(thrower, grenade, verbose))
{
sendSystemMessage(thrower, new string_id("spam", "no_cert_grenade"));
return false;
}
return true;
}
//------------------------------------------------
// hasThrownGrenade
//
// Records the reuse timers of the grenade on the thrower.
//------------------------------------------------
boolean hasThrownGrenade( obj_id thrower, obj_id grenade )
{
// Get the effect class.
string grenadeEffectClass = getStringObjVar( grenade, "effect_class" );
return true;
}
//------------------------------------------------
// applyGrenadeEffects
//
// Called from combat_base::runHitEngine
//
// Applies non-damage grenade effects to the defender.
// Called individually on each defender struck by the grenade.
//------------------------------------------------
effect_data applyGrenadeEffects( obj_id defender, obj_id grenade, float range )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "APPLYING GRENADE EFFECTS ON "+getName(defender)+"("+defender+")" + " WITH " + getName(grenade) + "("+grenade+")" );
// Prepare our effect_data.
effect_data resultData = new effect_data();
// By default we return the current posture of the defender.
int currentPosture = getPosture( defender );
resultData.posture = currentPosture;
// Get the effect class.
string grenadeEffectClass = getStringObjVar( grenade, "effect_class" );
// Apply these effects.
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Applying grenade effects of class ["+grenadeEffectClass+"] to " + defender );
if ( grenadeEffectClass.equals( "fragmentation" ) )
{ // Fragmentation
resultData = applyFragmentationEffects( defender, grenade, range, resultData );
}
else if ( grenadeEffectClass.equals( "cryoban" ) )
{ // Cryoban
resultData = applyCryobanEffects( defender, grenade, range, resultData );
}
else if ( grenadeEffectClass.equals( "glop" ) )
{ // Glop
resultData = applyGlopEffects( defender, grenade, range, resultData );
}
else if ( grenadeEffectClass.equals( "imperial_detonator" ) )
{ // Imperial Detonator
resultData = applyImperialDetonatorEffects( defender, grenade, range, resultData );
}
else if ( grenadeEffectClass.equals( "proton" ) )
{ // Proton
resultData = applyProtonEffects( defender, grenade, range, resultData );
}
else if ( grenadeEffectClass.equals( "thermal_detonator" ) )
{ // Thermal Detonator
resultData = applyThermalDetonatorEffects( defender, grenade, range, resultData );
}
else if ( grenadeEffectClass.equals( "bug" ) )
{ // Bug Bomb
resultData = applyBugBombEffects( defender, grenade, range, resultData );
}
else
{ // Unknown Grenade Type
}
// Return the new posture to the combat core.
if ( resultData.posture != currentPosture )
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Recommending a new posture of " + resultData.posture + " be set on " + defender );
return resultData;
}
//------------------------------------------------
// applyFragmentationEffects
//
// Special Effect: None
//------------------------------------------------
effect_data applyFragmentationEffects( obj_id defender, obj_id grenade, float range, effect_data resultData )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Applying fragmentation effects." );
return resultData;
}
//------------------------------------------------
// applyCryobanEffects
//
// Special Effect: 30m Radius 10% Snare for 3s
// 15m Radius 20% Slow for 10s
//------------------------------------------------
effect_data applyCryobanEffects( obj_id defender, obj_id grenade, float range, effect_data resultData )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Applying cryoban effects." );
// Is the target within range to be snared?
float maxRange = getMaxRange( grenade );
if ( range > maxRange )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Target is out of special effect range. (snare)" );
return resultData;
}
// Apply the snare.
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Target is snared." );
buff.applyBuff( defender, "cryobanSnare" );
// Is the target within range to be slowed?
float midRange = (getMaxRange( grenade ) - getMinRange( grenade))/2;
if ( range > midRange )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Target is out of special effect range. (slow)" );
return resultData;
}
// Apply the combat slow.
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Target is combat slowed." );
int slowDuration = getIntObjVar( grenade, "slowDuration" );
int slowIntensity = getIntObjVar( grenade, "slowIntensity" );
addSkillModModifier( defender, "cryobanSlow", "combat_slow", slowIntensity, slowDuration, false, true );
return resultData;
}
//------------------------------------------------
// applyGlopEffects
//
// Special Effect: 15m Radius Blind
//------------------------------------------------
effect_data applyGlopEffects( obj_id defender, obj_id grenade, float range, effect_data resultData )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Applying glop effects." );
// Is the target within range to be blinded?
float midRange = (getMaxRange( grenade ) - getMinRange( grenade))/2;
if ( range > midRange )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Target is out of special effect range." );
return resultData;
}
// Can we blind the target?
// Recommend that the target be blinded.
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Blinding the target: " + defender );
resultData.states = new int[1];
resultData.durations = new float[1];
resultData.states[0] = STATE_BLINDED;
resultData.durations[0] = getIntObjVar( grenade, "blindDuration" );
resultData.stateChance = getIntObjVar( grenade, "blindChance" );
return resultData;
}
//------------------------------------------------
// applyImperialDetonatorEffects
//
// Special Effect: 20m Radius Knockdown
//------------------------------------------------
effect_data applyImperialDetonatorEffects( obj_id defender, obj_id grenade, float range, effect_data resultData )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Applying imperial detonator effects." );
// Is the target within range to be knocked down?
if ( range > 20 )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Target is out of special effect range." );
return resultData;
}
// Can we knock the target down?
// Set the knock down posture (this will be skill tested later, in the main combat logic).
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Knocking down the target: " + defender );
resultData.posture = POSTURE_KNOCKED_DOWN;
return resultData;
}
//------------------------------------------------
// applyProtonEffects
//
// Special Effect: 30m Radius Chance of Disabling Vehicles for 30s
// 20m Radius Health DOT
//------------------------------------------------
effect_data applyProtonEffects( obj_id defender, obj_id grenade, float range, effect_data resultData )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Applying proton effects." );
// Is the target within range to be disabled?
if ( range > 30 )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Target is out of special effect range. (vehicle disable)" );
return resultData;
}
// Search the radius for vehicles to disable.
if(vehicle.isRidingVehicle(defender) && rand(1, 100) <= 50)
{
obj_id objVehicle = getMountId(defender);
vehicle.doTempMaxSpeedReduction(objVehicle, 0.1f, 30);
sendSystemMessage(defender, new string_id("cbt_spam", "vehicle_slow_lightning"));
}
// Is the target within range to be DOT'd?
if ( range > 20 )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Target is out of special effect range. (DOT)" );
return resultData;
}
// Apply a health DOT.
int burnIntensity = getIntObjVar( grenade, "burnIntensity" );
int burnDuration = getIntObjVar( grenade, "burnDuration" );
dot.applyBleedingEffect( defender, grenade, "protonBurn", HEALTH, burnIntensity, burnDuration );
return resultData;
}
//------------------------------------------------
// applyThermalDetonatorEffects
//
// Special Effect: 20m Radius Fire DOT
//------------------------------------------------
effect_data applyThermalDetonatorEffects( obj_id defender, obj_id grenade, float range, effect_data resultData )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Applying thermal detonator effects." );
// Is the target within range to be DOT'd?
if ( range > 20 )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Target is out of special effect range. (DOT)" );
return resultData;
}
// Apply a fire DOT.
int burnIntensity = getIntObjVar( grenade, "burnIntensity" );
int burnDuration = getIntObjVar( grenade, "burnDuration" );
dot.applyFireEffect( defender, grenade, "thermalBurn", burnIntensity, burnDuration );
return resultData;
}
//------------------------------------------------
// applyBugBombEffects
//
// Special Effect: None
//------------------------------------------------
effect_data applyBugBombEffects( obj_id defender, obj_id grenade, float range, effect_data resultData )
{
combat.combatLog( grenade, defender, "applyGrenadeEffects", "Applying bug bomb effects." );
return resultData;
}