void main()
{
object oPC = GetFirstPC();

//int nHour = GetTimeHour();
//int nMinute = GetTimeMinute();
//int nSecond = GetTimeSecond();
//SetTime(nHour,nMinute,nSecond+3,0);

effect eDeath = EffectDeath();
int nUA = GetLocalInt(oPC, "UnderwaterArea");
int nDT = GetLocalInt(oPC, "RoundsBeforeDrowning");
int nSW = GetLocalInt(oPC, "SwallowedWhole");
int nFL = GetLocalInt(oPC, "EnteredFireLevel");
int nND = GetLocalInt(oPC, "NoDrown");

if (nFL == 1)
 {
 // Define who else is susceptible to lava
 object oHench1 = GetHenchman(oPC, 1);
 object oHench2 = GetHenchman(oPC, 2);
 object oFamiliar = GetAssociate(ASSOCIATE_TYPE_FAMILIAR, oPC);
 object oSummoned = GetAssociate(ASSOCIATE_TYPE_SUMMONED, oPC);
 object oDominated = GetAssociate(ASSOCIATE_TYPE_DOMINATED, oPC);
 object oAnimal = GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION, oPC);
 // Access local variables
 int nInLavaPC = GetLocalInt(oPC, "InLavaPC");
 int nInLavaHench1 = GetLocalInt(oPC, "InLavaHench1");
 int nInLavaHench2 = GetLocalInt(oPC, "InLavaHench2");
 int nInLavaFamiliar = GetLocalInt(oPC, "InLavaFamiliar");
 int nInLavaSummoned = GetLocalInt(oPC, "InLavaSummoned");
 int nInLavaDominated = GetLocalInt(oPC, "InLavaDominated");
 int nInLavaAnimal = GetLocalInt(oPC, "InLavaAnimal");
 // Check who's valid & who's still in the lava & apply damage
 if ((GetIsObjectValid(oPC))&&(nInLavaPC == 1))
  {
  int nDam1 = d6();
  int nDam2 = d6();
  int nDam = (nDam1 + nDam2);
  effect eEffect = EffectDamage(nDam, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oPC);
  }
 if ((GetIsObjectValid(oHench1))&&(nInLavaHench1 == 1))
  {
  int nDam1 = d6();
  int nDam2 = d6();
  int nDam = (nDam1 + nDam2);
  effect eEffect = EffectDamage(nDam, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oHench1);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oHench1);
  }
 if ((GetIsObjectValid(oHench2))&&(nInLavaHench2 == 1))
  {
  int nDam1 = d6();
  int nDam2 = d6();
  int nDam = (nDam1 + nDam2);
  effect eEffect = EffectDamage(nDam, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oHench2);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oHench2);
  }
 if ((GetIsObjectValid(oFamiliar))&&(nInLavaFamiliar == 1))
  {
  int nDam1 = d6();
  int nDam2 = d6();
  int nDam = (nDam1 + nDam2);
  effect eEffect = EffectDamage(nDam, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oFamiliar);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oFamiliar);
  }
 if ((GetIsObjectValid(oSummoned))&&(nInLavaSummoned == 1))
  {
  int nDam1 = d6();
  int nDam2 = d6();
  int nDam = (nDam1 + nDam2);
  effect eEffect = EffectDamage(nDam, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oSummoned);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oSummoned);
  }
 if ((GetIsObjectValid(oDominated))&&(nInLavaDominated == 1))
  {
  int nDam1 = d6();
  int nDam2 = d6();
  int nDam = (nDam1 + nDam2);
  effect eEffect = EffectDamage(nDam, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oDominated);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oDominated);
  }
 if ((GetIsObjectValid(oAnimal))&&(nInLavaAnimal == 1))
  {
  int nDam1 = d6();
  int nDam2 = d6();
  int nDam = (nDam1 + nDam2);
  effect eEffect = EffectDamage(nDam, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oAnimal);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oAnimal);
  }
 // End Fire Level script
 }

if (nSW == 1)
 {
 int nDMG = d6();
 effect eEffect = EffectDamage(nDMG, DAMAGE_TYPE_ACID, DAMAGE_POWER_NORMAL);
 ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
 ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_GAS_EXPLOSION_NATURE),oPC);
 }

if ((nUA == 1)&&(nDT < 1)&&(nND < 1))
 {
 SetLocalInt(oPC, "UnderwaterArea", 0);
 DelayCommand(1.5, FloatingTextStringOnCreature("Your lungs fill with water as you slip from consciousness...", oPC));
 DelayCommand(4.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DEATH), oPC));
 DelayCommand(6.0, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDeath, oPC));
 }

if ((nUA == 1)&&(nDT >= 1)&&(nND < 1))
 {
 int nInt = (nDT - 1);
 FloatingTextStringOnCreature("If you cannot breathe, you will surely drown...", oPC);
 SetLocalInt(oPC, "RoundsBeforeDrowning", nInt);
 }

return;
}
