//////////////////////////////////////////////////////////////////////////////// // underwater_h - This header supplies scripts to support underwater areas // By Deva Bryson Winblood. 03/31/2005 //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////// // PROTOTYPES //////////////////////////////////////// // FILE: underwater_h FUNCTION: EnterUnderwaterArea() // This function will check the creature for bCanSwimUnderwater flag // it will appropriately handle slowing down creatures without this flag // it will also check for water breathing. If water breathing does not exist // for the creature then it will have 30 + CON seconds before drowning. // Any creatures that can swim underwater should have bCanSwimUnderwater int set // to 1 on their creature blueprint. Any creatures that can always breathe // underwater should have bWaterBreathing set to 1 on the blueprint as well. // This function sets the bIsUnderWater int on the oCreature to TRUE when // the creature enters. You can set additional variables on creature blueprints // for additional effects. // nWaterDamage = how much damage creature should take every 5 seconds underwater // nWaterHealing = how much damage creature should heal every 5 seconds underwater void EnterUnderwaterArea(object oCreature); // FILE: underwater_h FUNCTION: ExitUnderwaterArea() // This function will remove the bIsUnderwater flag. void ExitUnderwaterArea(object oCreature); /////////////////////////////////////// // FUNCTIONS /////////////////////////////////////// void fnDrown(object oCreature) { // PURPOSE: The creature has drowned effect eDeath=EffectDeath(); effect eImb=EffectCutsceneImmobilize(); ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eImb,oCreature,6.0); if (GetIsPC(oCreature)) SendMessageToPC(oCreature,"You have drowned!!!"); AssignCommand(oCreature,ClearAllActions(TRUE)); AssignCommand(oCreature,ActionPlayAnimation(ANIMATION_LOOPING_SPASM,1.0,3.0)); AssignCommand(oCreature,ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_INSTANT,eDeath,oCreature,1.0))); } // fnDrown() void fnUnderwaterHandler(object oCreature) { // PURPOSE: Underwater handler effect eE; int bUnderwater=GetLocalInt(oCreature,"bIsUnderwater"); int bWaterBreathing=GetLocalInt(oCreature,"bWaterBreathing"); int bSwim=GetLocalInt(oCreature,"bCanSwimUnderwater"); int nTime=GetLocalInt(oCreature,"nTimeDrowning"); int nDur=30+GetAbilityScore(oCreature,ABILITY_CONSTITUTION); int nDmg=GetLocalInt(oCreature,"nWaterDamage"); int nHeal=GetLocalInt(oCreature,"nWaterHealing"); int nTR; if (bUnderwater) { // still underwater if (nDmg>0) { // underwater damage eE=EffectDamage(nDmg); ApplyEffectToObject(DURATION_TYPE_INSTANT,eE,oCreature); } // underwater damage if (nHeal>0) { // underwater regeneration eE=EffectHeal(nHeal); ApplyEffectToObject(DURATION_TYPE_INSTANT,eE,oCreature); } // underwater regeneration if (!bSwim) { // movement speed decrease eE=EffectMovementSpeedDecrease(50); ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eE,oCreature,5.1); } // movement speed decrease if (!bWaterBreathing) { // drowning nTR=nDur-nTime; if (GetIsPC(oCreature)) SendMessageToPC(oCreature,"You have approximately "+IntToString(nTR)+" seconds before you drown."); nTime=nTime+5; SetLocalInt(oCreature,"nTimeDrowning",nTime); if (nTR<1) fnDrown(oCreature); } // drowning else { // not drowning DeleteLocalInt(oCreature,"nTimeDrowning"); } // not drowning DelayCommand(5.0,fnUnderwaterHandler(oCreature)); } // still underwater } // fnUnderwaterHandler() void EnterUnderwaterArea(object oCreature) { // PURPOSE: Enter an underwater area and deal with it appropriately int bUnderwater=GetLocalInt(oCreature,"bIsUnderwater"); if (!bUnderwater) { // activate underwater handler DelayCommand(6.0,SetLocalInt(oCreature,"bIsUnderwater",TRUE)); if (GetIsPC(oCreature)) SendMessageToPC(oCreature,"You have entered an underwater area!!"); DelayCommand(6.1,AssignCommand(oCreature,fnUnderwaterHandler(oCreature))); } // activate underwater handler } // EnterUnderwaterArea() void ExitUnderwaterArea(object oCreature) { // PURPOSE: Mark the creature as no longer underwater DeleteLocalInt(oCreature,"bIsUnderwater"); DeleteLocalInt(oCreature,"nTimeDrowning"); } // ExitUnderwaterArea() //void main(){}