//::///////////////////////////////////////////////
//:: Dragon Breath Negative Energy
//:: NW_S1_DragNeg
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Calculates the proper damage and DC Save for the
    breath weapon based on the HD of the dragon.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: May 9, 2001
//:://////////////////////////////////////////////

const string DRAGBREATHLOCK = "DragonBreathLock";


//modified to use the breath include - Fox
#include "prc_inc_spells"
#include "prc_inc_breath"

void main()
{
    // Check the dragon breath delay lock
    if(GetLocalInt(OBJECT_SELF, DRAGBREATHLOCK))
    {
        SendMessageToPC(OBJECT_SELF, "You cannot use your breath weapon again so soon");
        return;
    }
	
    //Declare major variables
    int nAge = GetHitDice(OBJECT_SELF);
    int nDCBoost = nAge / 2;
    int nDamageDice;
    int nLevelDrain; //drain was commented out, kept just in case
    struct breath NegBreath;
    
    //Determine save DC and ability damage
    if (nAge <= 6) //Wyrmling
    {
    	nLevelDrain = 1;
        nDamageDice = 2;
    }
    else if (nAge >= 7 && nAge <= 9) //Very Young
    {
    	nLevelDrain = 1;
        nDamageDice = 4;
    }
    else if (nAge >= 10 && nAge <= 12) //Young
    {
    	nLevelDrain = 1;
        nDamageDice = 6;
    }
    else if (nAge >= 13 && nAge <= 15) //Juvenile
    {
    	nLevelDrain = 2;
        nDamageDice = 8;
    }
    else if (nAge >= 16 && nAge <= 18) //Young Adult
    {
    	nLevelDrain = 2;
        nDamageDice = 10;
    }
    else if (nAge >= 19 && nAge <= 21) //Adult
    {
    	nLevelDrain = 3;
        nDamageDice = 12;
    }
    else if (nAge >= 22 && nAge <= 24) //Mature Adult
    {
    	nLevelDrain = 4;
        nDamageDice = 14;
    }
    else if (nAge >= 25 && nAge <= 27) //Old
    {
    	nLevelDrain = 5;
        nDamageDice = 16;
    }
    else if (nAge >= 28 && nAge <= 30) //Very Old
    {
    	nLevelDrain = 5;
        nDamageDice = 18;
    }
    else if (nAge >= 31 && nAge <= 33) //Ancient
    {
    	nLevelDrain = 6;
        nDamageDice = 20;
    }
    else if (nAge >= 34 && nAge <= 37) //Wyrm
    {
    	nLevelDrain = 7;
        nDamageDice = 22;
    }
else if (nAge >= 38 && nAge <= 41) //Great Wyrm
    {
        nDamageDice = 24;
		nLevelDrain = 8;
    }
	    else if (nAge >= 42 && nAge <= 45) //Great Wyrm
    {
        nDamageDice = 26;
		nLevelDrain = 9;
    }
	    else if (nAge >= 46 && nAge <= 49) //Great Wyrm
    {
        nDamageDice = 28;
		nLevelDrain = 10;
    }
	
	    else if (nAge >= 50 && nAge <= 53) //Great Wyrm
    {
        nDamageDice = 30;
		nLevelDrain = 11;
    }
	    else if (nAge >= 54 && nAge <= 57) //Great Wyrm
    {
        nDamageDice = 32;
		nLevelDrain = 12;
    }
	    else if (nAge >= 58 && nAge <= 61) //Great Wyrm
    {
        nDamageDice = 34;
		nLevelDrain = 13;
    }
	    else if (nAge >= 62 && nAge <= 65) //Great Wyrm
    {
        nDamageDice = 36;
		nLevelDrain = 14;
    }
	    else if (nAge >= 66 && nAge <= 69) //Great Wyrm
    {
        nDamageDice = 38;
		nLevelDrain = 15;
    }
	    else if (nAge >= 70 && nAge <= 73) //Great Wyrm
    {
        nDamageDice = 40;
		nLevelDrain = 16;
    }
	    else if (nAge >= 74 && nAge <= 77) //Great Wyrm
    {
        nDamageDice = 42;
		nLevelDrain = 17;
    }
	    else if (nAge >= 78 && nAge <= 81) //Great Wyrm
    {
        nDamageDice = 44;
		nLevelDrain = 18;
    }
	    else if (nAge >= 82 && nAge <= 85) //Great Wyrm
    {
        nDamageDice = 46;
		nLevelDrain = 19;
    }
	
		else if (nAge >= 86 && nAge <= 89) //Great Wyrm
    {
        nDamageDice = 48;
		nLevelDrain = 20;
    }

	    else if (nAge >= 90 && nAge <= 93) //Great Wyrm
    {
        nDamageDice = 50;
		nLevelDrain = 21;
    }

	    else if (nAge >= 94 && nAge <= 97) //Great Wyrm
    {
        nDamageDice = 52;
		nLevelDrain = 22;
    } 

	    else if (nAge >= 98 && nAge <= 101) //Great Wyrm
    {
        nDamageDice = 54;
		nLevelDrain = 23;
    } 
	    else if (nAge >= 102 && nAge <= 105) //Great Wyrm
    {
        nDamageDice = 56;
		nLevelDrain = 24;
    } 
	    else if (nAge >= 106 && nAge <= 109) //Great Wyrm
    {
        nDamageDice = 58;
		nLevelDrain = 25;
    } 
	    else if (nAge >= 110 && nAge <= 113) //Great Wyrm
    {
        nDamageDice = 60;
		nLevelDrain = 26;
    } 
	    else if (nAge >= 114 && nAge <= 117) //Great Wyrm
    {
        nDamageDice = 62;
		nLevelDrain = 27;
    } 
	    else if (nAge >= 118 && nAge <= 121) //Great Wyrm
    {
        nDamageDice = 64;
		nLevelDrain = 28;
    } 
	    else if (nAge >= 122 && nAge <= 125) //Great Wyrm
    {
        nDamageDice = 66;
		nLevelDrain = 29;
    } 
	    else if (nAge >= 126 && nAge <= 129) //Great Wyrm
    {
        nDamageDice = 68;
		nLevelDrain = 30;
    } 
	    else if (nAge >= 130 && nAge <= 133) //Great Wyrm
    {
        nDamageDice = 70;
		nLevelDrain = 31;
    } 
	    else if (nAge >= 134 && nAge <= 137) //Great Wyrm
    {
        nDamageDice = 72;
		nLevelDrain = 32;
    } 
        else if (nAge >= 138 && nAge <= 141) //Great Wyrm
    {
        nDamageDice = 74;
		nLevelDrain = 33;
    } 
	    else if (nAge >= 142 && nAge <= 145) //Great Wyrm
    {
        nDamageDice = 76;
		nLevelDrain = 34;
    } 	
	    else if (nAge >= 146 && nAge <= 149) //Great Wyrm
    {
        nDamageDice = 78;
		nLevelDrain = 35;
    } 	
	    else if (nAge >= 150 && nAge <= 153) //Great Wyrm
    {
        nDamageDice = 80;
		nLevelDrain = 36;
    } 	
	    else if (nAge >= 154 && nAge <= 157) //Great Wyrm
    {
        nDamageDice = 82;
		nLevelDrain = 37;
    }

	    else if (nAge >= 158 && nAge <= 161) //Great Wyrm
    {
        nDamageDice = 84;
		nLevelDrain = 38;
    } 
	    else if (nAge >= 162 && nAge <= 165) //Great Wyrm
    {
        nDamageDice = 86;
		nLevelDrain = 39;
    } 
	    else if (nAge >= 166 && nAge <= 169) //Great Wyrm
    {
        nDamageDice = 88;
		nLevelDrain = 40;
    } 

	    else if (nAge >= 170 && nAge <= 173) //Great Wyrm
    {
        nDamageDice = 90;
		nLevelDrain = 41;
    } 
	    else if (nAge >= 174 && nAge <= 177) //Great Wyrm
    {
        nDamageDice = 92;
		nLevelDrain = 42;
    }  	
	    else if (nAge > 178 ) //Great Wyrm
    {
        nDamageDice = 94;
		nLevelDrain = 43;
    } 	
    
    //create the breath - 40' ~ 14m? - should set it based on size later
    NegBreath = CreateBreath(OBJECT_SELF, FALSE, 40.0, DAMAGE_TYPE_NEGATIVE, 8, nDamageDice, ABILITY_CONSTITUTION, nDCBoost);
    
    //Apply the breath - note: Level drain was included but commented out in the original, thus not currently implemented in the include.
    //Information on the level drain amount is kept just in case.
    PRCPlayDragonBattleCry();
    ApplyBreath(NegBreath, PRCGetSpellTargetLocation());
    
    //Apply the recharge lock
    SetLocalInt(OBJECT_SELF, DRAGBREATHLOCK, TRUE);

    // Schedule opening the delay lock
    float fDelay = RoundsToSeconds(NegBreath.nRoundsUntilRecharge);
    SendMessageToPC(OBJECT_SELF, "Your breath weapon will be ready again in " + IntToString(NegBreath.nRoundsUntilRecharge) + " rounds.");

    DelayCommand(fDelay, DeleteLocalInt(OBJECT_SELF, DRAGBREATHLOCK));
    DelayCommand(fDelay, SendMessageToPC(OBJECT_SELF, "Your breath weapon is ready now"));
}