#include "prc_inc_spells"

void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

StopFade(oPC);

int nDmg;
int nDam1 = d6();
int nDam2 = d6();
int nDam = (nDam1 + nDam2);
int nAdj =  (nDam/2);
int nSave = ReflexSave(oPC, 16, SAVING_THROW_TYPE_SPELL, GetAreaOfEffectCreator());
if (nSave >= 1) nDmg = nAdj;
else nDmg = nDam;

if (GetLevelByClass(CLASS_TYPE_MONK, oPC) >= 4) nDmg = 0;
if (GetLevelByClass(CLASS_TYPE_NINJA, oPC) >= 4) nDmg = 0;
if (GetLevelByClass(CLASS_TYPE_SWIFT_WING, oPC) >= 5) nDmg = 0;
if (GetLevelByClass(CLASS_TYPE_DRAGON_DISCIPLE, oPC) >= 9) nDmg = 0;
if (GetLevelByClass(CLASS_TYPE_DRAGON_SHAMAN, oPC) >= 19) nDmg = 0;
if (GetLevelByClass(CLASS_TYPE_FAVOURED_SOUL, oPC) >= 17) nDmg = 0;

if (MyPRCGetRacialType(oPC) == RACIAL_TYPE_SPIRETOPDRAGON) nDmg = 0;
if (MyPRCGetRacialType(oPC) == RACIAL_TYPE_GLOURA) nDmg = 0;

effect eDamage = EffectDamage(nDmg, DAMAGE_TYPE_BLUDGEONING, DAMAGE_POWER_NORMAL);
effect eShake = EffectVisualEffect(VFX_FNF_SCREEN_SHAKE);
effect eKnockdown = EffectKnockdown();

DelayCommand(1.0, PlaySound("as_na_rockfallg1"));
DelayCommand(1.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eShake, GetLocation(oPC)));
DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC));
DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_CHUNK_STONE_MEDIUM), oPC));
DelayCommand(1.25, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eKnockdown, oPC, 5.0f));

object oVoice = GetNearestObjectByTag("VoiceFromAbove");
int nHelp = GetLocalInt(oPC, "HenchRope");
if (nHelp == 1) DelayCommand(10.0, AssignCommand(oVoice, ActionStartConversation(oPC, "")));

if ((!(nHelp == 1))&&(!(GetItemPossessedBy(oPC, "CoilRope") == OBJECT_INVALID))) DelayCommand(15.0, FloatingTextStringOnCreature("Perhaps you should've tied off your rope BEFORE you fell...", oPC));
if ((!(nHelp == 1))&&(!(GetItemPossessedBy(oPC, "RopeClimbing") == OBJECT_INVALID))) DelayCommand(15.5, FloatingTextStringOnCreature("Thank goodness for your Rope of Climbing!", oPC));
if ((!(nHelp == 1))&&(GetItemPossessedBy(oPC, "RopeClimbing") == OBJECT_INVALID)) DelayCommand(30.0, FloatingTextStringOnCreature("It is hopeless.  You will never escape this pit...", oPC));

}

