136 lines
4.1 KiB
Plaintext
Raw Permalink Normal View History

////////////////////////////////
//
// Troll (Acurate for 3E)
//
// By\ Invizible420
// Created\ 11.28.04
//
// ScriptName\ troll_on_dmg
//
// Location for script\
// To be placed in the
// OnDamaged event of the
// troll.
//
//
// Complete Code rewrite of
// original troll script/
//
//
// Freatures\
//
// Troll will take subdual
// damage untll it has
// recieved it's HP in
// subdual damage, it will
// then fall unconscious
// slowly regenerating 5
// pts. of subdual damage
// per turn until it is
// completely revived, and
// rises again to attack/
//
////////////////////////////////
void DoTrollBurn(object oTroll = OBJECT_SELF)
{
effect eVFX1 = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_ORANGE);
effect eVFX2 = EffectVisualEffect(VFX_IMP_FLAME_S);
object oFIRE = CreateObject(OBJECT_TYPE_PLACEABLE,"plc_flamemedium",GetLocation(oTroll),TRUE);
DestroyObject(oFIRE,1.5);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eVFX2,oTroll);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX1,oTroll,1.5);
int iTrollHP = GetCurrentHitPoints(oTroll);
effect eDmg = EffectDamage(iTrollHP,DAMAGE_TYPE_FIRE);
}
void main()
{
// DEFINE MAIN VARIABLES
object oSelf = OBJECT_SELF;
//int TORCHDMG = d4(1)+2; // This is the torch damage roll (MOVED TO script "troll_execute_pc"
object oPC = GetLastDamager();
object oRHand = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
object oLHand = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
// Counters
int iADmg = GetDamageDealtByType(DAMAGE_TYPE_ACID);
int iFDmg = GetDamageDealtByType(DAMAGE_TYPE_FIRE);
int iSubDmg = GetTotalDamageDealt() - iADmg - iFDmg;
int iDTotal = GetLocalInt(oSelf,"AMOUNT_SUBDMG");
if (iDTotal < 150) SetLocalInt(oSelf,"AMOUNT_SUBDMG",iDTotal+iSubDmg);
iDTotal = GetLocalInt(oSelf,"AMOUNT_SUBDMG");
// Track HP
int iHP = GetMaxHitPoints();
int iLastHP = GetLocalInt(oSelf,"HIT_POINTS");
// Effects
effect eSleepT = EffectSleep();
effect eImmob = EffectCutsceneImmobilize();
effect eSleep = EffectLinkEffects(eSleepT,eImmob); // Sleep effect (by sleep I mean unconscious)
effect eDeath = EffectDeath(FALSE,TRUE);
// Store this troll for use in the PC ExecuteScripts / also store Acid/Fire damage
SetLocalObject(oPC,"LAST_TROLL_ATTACKED",OBJECT_SELF);
SetLocalInt(OBJECT_SELF,"TROLL_LAST_ACID_DMG_AMT",iADmg);
SetLocalInt(OBJECT_SELF,"TROLL_LAST_FIRE_DMG_AMT",iFDmg);
// Start Checks
// Subdual damage knockout check
if (iDTotal >= iHP)
{
// make the troll sleep (slee means unconscious)
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eSleep,oSelf);
// This is the torch check after the troll is unconscious
// Currently torches aren't equippable in right hand but if this is ever
// changed... it will still work
if(GetTag(oRHand) == "NW_IT_TORCH001" || GetTag(oLHand) == "NW_IT_TORCH001"
&& GetLocalInt(OBJECT_SELF,"TROLL_WAS_TORCHED") != 1)
{
// Only way I found to make the PC do the fire damage and per NWN Lexicon
// and testing is to run an ExecuteScript call on the PC (if the PC
// doesnt do the damage then they will not get the XP either.
ExecuteScript("troll_exec_pc_01",oPC);
// Make the burning look good
DoTrollBurn();
}
}
// Check to insure no infinite loop
if (GetLocalInt(OBJECT_SELF,"TROLL_PC_NRML_DMG") <= 0 && GetLocalInt(OBJECT_SELF,"TROLL_WAS_TORCHED") != 1)
{
ExecuteScript("troll_exec_pc_02",oPC);
}
// If HP <= 0 kill the chump
if (iLastHP >= iHP)
{
// cleanup
DeleteLocalInt(oSelf,"AMOUNT_SUBDMG");
DeleteLocalInt(oSelf,"HIT_POINTS");
SetIsDestroyable(TRUE,FALSE,FALSE);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_COM_BLOOD_CRT_GREEN),oSelf,1.0);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eDeath,oSelf);
}
//Cleanup
DeleteLocalInt(OBJECT_SELF,"TROLL_WAS_TORCHED");
DeleteLocalObject(oPC,"LAST_TROLL_ATTACKED");
DeleteLocalInt(OBJECT_SELF,"TROLL_PC_NRML_DMG");
// Heal all damage (this gives the appearance of subduel damage
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(iSubDmg),oSelf,0.0);
}