#include "nw_i0_plot"
#include "nw_i0_2q4luskan"
string sDeny;
/*   Script generated by
Lilac Soul's NWN Script Generator, v. 1.6

For download info, please visit:
http://www.lilacsoul.revility.com    */

//Put this OnEnter
void main()
//void sandboxtrap()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

int nInt;


nInt=GetPLocalInt(oPC, "intSandBoxCantKill");

if (nInt == 1)
   return;


nInt=GetPLocalInt(oPC, "intStartTrap");

if ((nInt == 2))
   {



    object oTarget;
    object oSpawn;
    location lTarget;
    effect eEffect;
    //Pre-First Round Actions
    nInt=GetPLocalInt(oPC, "intSandBoxRound");
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    //if ((nInt == 0))
    //    {
    //    //CREATE NORTH DOOR
    //    oTarget = GetWaypointByTag("LOC_c23DoorNorth");
    //    lTarget = GetLocation(oTarget);
    //    oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "zep_doors012", lTarget);
    //
    //    //CREATE SOUTH DOOR
    //    oTarget = GetWaypointByTag("LOC_c23South");
    //    lTarget = GetLocation(oTarget);
    //    oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "zep_doors012", lTarget);
    //
    //    //Display door text.
    //    FloatingTextStringOnCreature("You hear a click as copperbound doors come roaring down in front of you and behind you.", oPC);
    //
    //    //Display open trap slots text.
    //    DelayCommand(3.0, FloatingTextStringOnCreature("After a moment of silence there is the sound of stone slowly grating on stone.  Rows of 8 slots open near the ceiling in both walls.  Some dust trickles in from each.", oPC));
    //
    //    //Start Sandbox trap.
    //    DelayCommand(6.0, FloatingTextStringOnCreature("There is a crackling and rushing sound as golden sand starts to pour rapidly through the holes.  ", oPC));
    //
    //    //Create Will-o-the-wisp
    //    oTarget = GetWaypointByTag("c24Willow");
    //    lTarget = GetLocation(oTarget);
    //    DelayCommand(6.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "willowisp003", lTarget));
    //
    //    //Create Dirt 1
    //    oTarget = GetWaypointByTag("c24SmDirt1");
    //    lTarget = GetLocation(oTarget);
    //    DelayCommand(6.0, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt02", lTarget));
    //
    //    //Create Dirt 2
    //    oTarget = GetWaypointByTag("c24SmDirt2");
    //    lTarget = GetLocation(oTarget);
    //    DelayCommand(6.0, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt02", lTarget));
    //
    //    //Create Dirt 3
    //    oTarget = GetWaypointByTag("c24SmDirt3");
    //    lTarget = GetLocation(oTarget);
    //    DelayCommand(6.0, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt02", lTarget));
    //
    //    //Create Dirt 4
    //    oTarget = GetWaypointByTag("c24SmDirt4");
    //    lTarget = GetLocation(oTarget);
    //    DelayCommand(6.0, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt02", lTarget));
    //
    //    }

    //Round 1 check for fall

    //DebugSpeak ("intSandBoxRound retrieved will exectute if statement next  ");
    if (nInt == 1)
        {
        if (!ReflexSave(oPC, 12))
           {
           //sDeny="The sand on the floor causes you to loose your balance and fall.";

           //SendMessageToPC(oPC, sDeny);
           FloatingTextStringOnCreature("The sand on the floor causes you to loose your balance and fall.", oPC);


            object oTarget;
            oTarget = oPC;

             eEffect = EffectKnockdown();

            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 3.0f);

           //return;
           }
        }

    //Round 2 check for fall Add sand
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    if (nInt == 2)
        {
        if (!ReflexSave(oPC, 12))
           {
           //sDeny="The sand on the floor causes you to loose your balance and fall.";

           //SendMessageToPC(oPC, sDeny);
           FloatingTextStringOnCreature("The sand on the floor causes you to loose your balance and fall.", oPC);

            object oTarget;
            oTarget = oPC;


            eEffect = EffectKnockdown();

            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 3.0f);

           //return;
           }
        //Round 2 Create Dirt 1
        oTarget = GetWaypointByTag("c24Dirt1");
        lTarget = GetLocation(oTarget);
        CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt02", lTarget);

        //Round 2 Create Dirt 2
        oTarget = GetWaypointByTag("c24Dirt2");
        lTarget = GetLocation(oTarget);
        CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt02", lTarget);

        //Round 2 Create Dirt 3
        oTarget = GetWaypointByTag("c24Dirt3");
        lTarget = GetLocation(oTarget);
        CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt02", lTarget);
      }

    //Round 3 check for fall
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    if (nInt == 3)
        {
        if (!ReflexSave(oPC, 12))
           {
           //sDeny="The sand on the floor causes you to loose your balance and fall.";

           //SendMessageToPC(oPC, sDeny);
           FloatingTextStringOnCreature("The sand on the floor causes you to loose your balance and fall.", oPC);

            object oTarget;
            oTarget = oPC;


            eEffect = EffectKnockdown();

            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 3.0f);

           return;
           }
        }

    //Round 4 reduce attack and movement
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    if (nInt == 4)
        {
        oTarget = oPC;

        eEffect = EffectMovementSpeedDecrease(20);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 120.0f);
        eEffect = EffectAttackDecrease(1);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 120.0f);

        //Round 4 check for fall
        if (!ReflexSave(oPC, 12))
           {
           //sDeny="The sand on the floor causes you to loose your balance and fall.";

           //SendMessageToPC(oPC, sDeny);
           FloatingTextStringOnCreature("The sand on the floor causes you to loose your balance and fall.", oPC);

           object oTarget;
           oTarget = oPC;

           eEffect = EffectKnockdown();
           ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 3.0f);
           }

        //Round 4 More dirt
        //Create Dirt 1
        oTarget = GetWaypointByTag("c24SmDirt1");
        lTarget = GetLocation(oTarget);
        CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt01", lTarget);

        //Create Dirt 2
        oTarget = GetWaypointByTag("c24SmDirt2");
        lTarget = GetLocation(oTarget);
        CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt01", lTarget);

        //Create Dirt 3
        oTarget = GetWaypointByTag("c24SmDirt3");
        lTarget = GetLocation(oTarget);
        CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt01", lTarget);

        //Create Dirt 4
        oTarget = GetWaypointByTag("c24SmDirt4");
        lTarget = GetLocation(oTarget);
        CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_dirt01", lTarget);
        }

    //Round 5 check for fall
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    if (nInt == 5)
        {
        if (!ReflexSave(oPC, 12))
           {
           sDeny="The sand on the floor causes you to loose your balance and fall.";
           SendMessageToPC(oPC, sDeny);
           object oTarget;
           oTarget = oPC;

           eEffect = EffectKnockdown();
           ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 3.0f);
           }
       }



    //Round 6 check for fall and 1 round trap/paralyize
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    if (nInt == 6)
        {

        if (!ReflexSave(oPC, 12))
           {
           //sDeny="The sand on the floor causes you to loose your balance and fall.";

           //SendMessageToPC(oPC, sDeny);
           FloatingTextStringOnCreature("The sand on the floor causes you to loose your balance and fall.", oPC);

            object oTarget;
            oTarget = oPC;


            eEffect = EffectKnockdown();

            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 3.0f);
            oTarget = oPC;
            eEffect = EffectParalyze();
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 6.0f);


           }
        //More penalties
        eEffect = EffectAttackDecrease(1);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 60.0f);
        }


    //Round 7 check for fall and 1 round trap/paralyize
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    if (nInt == 7)
        {
        if (!ReflexSave(oPC, 12))
           {
           //sDeny="The sand on the floor causes you to loose your balance and fall.";

           //SendMessageToPC(oPC, sDeny);
           FloatingTextStringOnCreature("The sand on the floor causes you to loose your balance and fall.", oPC);


            object oTarget;
            oTarget = oPC;


            eEffect = EffectKnockdown();

            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 3.0f);
            oTarget = oPC;
            eEffect = EffectParalyze();
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 6.0f);

           }
        }


    //Round 8 check for fall and 1 round trap/paralyize take suffocation damage
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    if (nInt == 8)
        {


        if (!ReflexSave(oPC, 12))
           {
           //sDeny="The sand on the floor causes you to loose your balance and fall.";

           //SendMessageToPC(oPC, sDeny);
           FloatingTextStringOnCreature("The sand on the floor causes you to loose your balance and fall.", oPC);

            object oTarget;
            oTarget = oPC;

             eEffect = EffectKnockdown();

            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 3.0f);
            oTarget = oPC;
            eEffect = EffectParalyze();
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 6.0f);
            eEffect = EffectDamage(4, DAMAGE_TYPE_BLUDGEONING, DAMAGE_POWER_NORMAL);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
            FloatingTextStringOnCreature("You are suffocating in the sand.", oPC);
            }
            //More penalties
            eEffect = EffectAttackDecrease(1);
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 60.0f);
         }

    //Round 9 check for fall and 1 round trap/paralyize take suffocation damage
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    if (nInt == 9)
        {
        if (!ReflexSave(oPC, 12))
           {
           //sDeny="The sand on the floor causes you to loose your balance and fall.";

           //SendMessageToPC(oPC, sDeny);
           FloatingTextStringOnCreature("The sand on the floor causes you to loose your balance and fall.", oPC);

            object oTarget;
            oTarget = oPC;


            eEffect = EffectKnockdown();

            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 3.0f);
            oTarget = oPC;
            eEffect = EffectParalyze();
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 6.0f);
            eEffect = EffectDamage(4, DAMAGE_TYPE_BLUDGEONING, DAMAGE_POWER_NORMAL);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
            FloatingTextStringOnCreature("You are suffocating in the sand.", oPC);
           }
         }

    //Round 10 check for fall and 1 round trap/paralyize take suffocation damage
    //nInt=GetPLocalInt(oPC, "intSandBoxRound");
    if (nInt > 9)
        {

        FloatingTextStringOnCreature("You suffocate to death in the sand.", oPC);

        oTarget = oPC;

        eEffect = EffectDeath();

        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
        }



    SetPLocalInt(oPC, "intSandBoxRound", (++nInt)) ;
    FloatingTextStringOnCreature("The sand continues to pour in.", oPC);
    FloatingTextStringOnCreature(IntToString(nInt), oPC);
    }

}

