//Script Name: speedcast ////////////////////////////////////////// //Created By: Genisys (Guile) //Created On: 9/4/08 ///////////////////////////////////////// /* This script gives casters the option to speed buff, which is a great option and edition to any module! Updated 9/9/08 Added more buffs.. */ //////////////////////////////////////// //PROTOTYPE DECLARED int GetHasBetter(object oTarget, int nInt); //////////////////////////////////////////// void main() { object oPC; int nSpellId; int nSpell; int i; int nGs; oPC = GetPCSpeaker(); //Disable use in combat if(GetIsInCombat(oPC)) { FloatingTextStringOnCreature("You cannot use this while in combat!", oPC, FALSE); return; } //They must be a caster to use the item! if ((GetLevelByClass(CLASS_TYPE_BARD, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_CLERIC, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_DRUID, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_PALADIN, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_RANGER, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_SORCERER, oPC)>0)|| (GetLevelByClass(CLASS_TYPE_WIZARD, oPC)>0)) { for(i = 0; i<85; i++) { //This tells us which spell we are looking at.. //We look at each one in turn, and IF the caster can cast it //then we assign them a command to cast it at thier level.. switch (i) { case 1: { nSpell = SPELL_AMPLIFY; break; } case 2: { nSpell = SPELL_AURA_OF_VITALITY; break; } case 3: { nSpell = SPELL_AURAOFGLORY; break; } case 4: { nSpell = SPELL_BARKSKIN; break; } case 5: { nSpell = SPELL_BATTLETIDE; break; } case 6: { nSpell = SPELL_BLESS; break; } case 7: { nSpell = SPELL_BLESS_WEAPON; break; } //Redundant spells, we will check for better versions first! case 8: { nSpell = SPELL_CAMOFLAGE; break; } case 9: { nSpell = SPELL_CATS_GRACE; break; } case 10: { nSpell = SPELL_CLAIRAUDIENCE_AND_CLAIRVOYANCE; break; } case 11: { nSpell = SPELL_CLARITY; break; } case 12: { nSpell = SPELL_DARKFIRE; break; } case 13: { nSpell = SPELL_DEATH_ARMOR; break; } case 14: { nSpell = SPELL_DEATH_WARD; break; } case 15: { nSpell = SPELL_DISPLACEMENT; break; } case 16: { nSpell = SPELL_DIVINE_FAVOR; break; } case 17: { nSpell = SPELL_DIVINE_POWER; break; } case 18: { nSpell = SPELL_DOOM; break; } case 19: { nSpell = SPELL_ELEMENTAL_SHIELD; break; } case 20: { nSpell = SPELL_ENDURANCE; break; } //Redundant spells, we will check for better versions first! case 21: { nSpell = SPELL_ENDURE_ELEMENTS; break; } case 22: { nSpell = SPELL_RESIST_ELEMENTS; break; } case 23: { nSpell = SPELL_PROTECTION_FROM_ELEMENTS; break; } case 24: { nSpell = SPELL_ENERGY_BUFFER; break; } case 25: { nSpell = SPELL_BULLS_STRENGTH; break; } case 26: { nSpell = SPELL_EAGLE_SPLEDOR; break; } case 27: { nSpell = SPELL_ENTROPIC_SHIELD; break; } case 28: { nSpell = SPELL_ETHEREAL_VISAGE; break; } //Redundant spell, we will check for better versions first! case 29: { nSpell = SPELL_EXPEDITIOUS_RETREAT; break; } case 30: { nSpell = SPELL_FLAME_WEAPON; break; } case 31: { nSpell = SPELL_FOXS_CUNNING; break; } case 32: { nSpell = SPELL_FREEDOM_OF_MOVEMENT; break; } case 33: { nSpell = SPELL_GHOSTLY_VISAGE; break; } case 34: { nSpell = SPELL_GREATER_BULLS_STRENGTH; break; } case 35: { nSpell = SPELL_GREATER_CATS_GRACE; break; } case 36: { nSpell = SPELL_GREATER_EAGLE_SPLENDOR; break; } case 37: { nSpell = SPELL_GREATER_ENDURANCE; break; } case 38: { nSpell = SPELL_GREATER_FOXS_CUNNING; break; } //Redundant spells, we will check for better versions first! case 39: { nSpell = SPELL_MAGIC_WEAPON; break; } case 40: { nSpell = SPELL_GREATER_MAGIC_WEAPON; break; } case 41: { nSpell = SPELL_STONESKIN; break; } case 42: { nSpell = SPELL_GREATER_STONESKIN; break; } case 43: { nSpell = SPELL_PREMONITION; break; } case 44: { nSpell = SPELL_GREATER_OWLS_WISDOM; break; } case 45: { nSpell = SPELL_HASTE; break; } case 46: { nSpell = SPELL_HOLY_AURA; break; } case 47: { nSpell = SPELL_HOLY_SWORD; break; } //Redundant spells, we will check for better versions first! case 48: { nSpell = SPELL_INVISIBILITY; break; } case 49: { nSpell = SPELL_INVISIBILITY_SPHERE; break; } case 50: { nSpell = SPELL_IMPROVED_INVISIBILITY; break; } case 51: { nSpell = SPELL_KEEN_EDGE; break; } case 52: { nSpell = SPELL_LIGHT; break; } case 53: { nSpell = SPELL_LESSER_MIND_BLANK; break; } //Redundant spells, we will check for better versions first! case 54: { nSpell = SPELL_LESSER_SPELL_MANTLE; break; } case 55: { nSpell = SPELL_SPELL_MANTLE; break; } case 56: { nSpell = SPELL_GREATER_SPELL_MANTLE; break; } //Redundant spells, we will check for better versions first! case 57: { nSpell = SPELL_MINOR_GLOBE_OF_INVULNERABILITY; break; } case 58: { nSpell = SPELL_GLOBE_OF_INVULNERABILITY; break; } case 59: { nSpell = SPELL_MAGIC_CIRCLE_AGAINST_CHAOS; break; } case 60: { nSpell = SPELL_MAGIC_CIRCLE_AGAINST_EVIL; break; } case 61: { nSpell = SPELL_MAGIC_VESTMENT; break; } case 62: { nSpell = SPELL_MASS_CAMOFLAGE; break; } case 63: { nSpell = SPELL_MASS_HASTE; break; } case 64: { nSpell = SPELL_MESTILS_ACID_SHEATH; break; } case 65: { nSpell = SPELL_MIND_BLANK; break; } case 66: { nSpell = SPELL_MONSTROUS_REGENERATION; break; } case 67: { nSpell = SPELL_NEGATIVE_ENERGY_PROTECTION; break; } case 68: { nSpell = SPELL_ONE_WITH_THE_LAND; break; } case 69: { nSpell = SPELL_OWLS_INSIGHT; break; } case 70: { nSpell = SPELL_OWLS_WISDOM; break; } case 71: { nSpell = SPELL_PRAYER; break; } case 72: { nSpell = SPELL_PROTECTION_FROM_SPELLS; break; } case 73: { nSpell = SPELL_PROTECTION_FROM_EVIL; break; } case 74: { nSpell = SPELL_REGENERATE; break; } case 75: { nSpell = SPELL_RESISTANCE; break; } case 76: { nSpell = SPELL_SPELL_RESISTANCE; break; } //Redundant spells, we will check for better versions first! case 77: { nSpell = SPELL_SEE_INVISIBILITY; break; } case 78: { nSpell = SPELL_SHADOW_SHIELD; break; } case 79: { nSpell = SPELL_SHIELD; break; } case 80: { nSpell = SPELL_TRUE_SEEING; break; } case 81: { nSpell = SPELL_UNHOLY_AURA; break; } case 82: { nSpell = SPELL_VINE_MINE_CAMOUFLAGE; break; } case 83: { nSpell = SPELL_WOUNDING_WHISPERS; break; } case 84: { nSpell = SPELL_VIRTUE; break; } //Most casters will have this one, just in case an error occurs. default: {nSpell = SPELL_LIGHT; break; } } //If they have the spell memorized make them cast quickly! if(GetHasSpell(nSpell, oPC)>0) { nGs = GetHasBetter(oPC, i); //If the user doesn't have a better spell memorized... if(nGs==2) { AssignCommand(oPC, ActionCastSpellAtObject (nSpell, oPC , METAMAGIC_ANY , FALSE , 0 , PROJECTILE_PATH_TYPE_DEFAULT , TRUE)); } } } } //Otherwise Tell the PC why they can't use the item.. else { FloatingTextStringOnCreature("You must be a Spell Caster to use this item!", oPC, FALSE); } //Main Script End } ///////////////////////////////////////////////////////////////////////// //PROTOTYPE DEFINED int GetHasBetter(object oTarget, int nInt) { int b = 0; //If the current spell (which might be cast) is the lesser, //then lets see if they have a great version! if(nInt == 15) //Displacement { //Improved Invisibility has 50% concealment! if(GetHasSpell(SPELL_IMPROVED_INVISIBILITY, oTarget)) b = 1; } else if(nInt ==19)//SPELL_ELEMENTAL_SHIELD { //Energy Buffer is better! if(GetHasSpell(SPELL_ENERGY_BUFFER, oTarget)) b = 1; } else if(nInt ==21)//SPELL_ENDURE_ELEMENTS { if(GetHasSpell(SPELL_ELEMENTAL_SHIELD, oTarget) || GetHasSpell(SPELL_RESIST_ELEMENTS, oTarget) || GetHasSpell(SPELL_PROTECTION_FROM_ELEMENTS, oTarget) || GetHasSpell(SPELL_ENERGY_BUFFER, oTarget)) b = 1; } else if(nInt ==22)//SPELL_RESIST_ELEMENTS { if(GetHasSpell(SPELL_RESIST_ELEMENTS, oTarget) || GetHasSpell(SPELL_PROTECTION_FROM_ELEMENTS, oTarget) || GetHasSpell(SPELL_ENERGY_BUFFER, oTarget)) b = 1; } else if(nInt ==23)//SPELL_PROTECTION_FROM_ELEMENTS { if(GetHasSpell(SPELL_ENERGY_BUFFER, oTarget)) b = 1; } else if(nInt ==29) //SPELL_EXPEDITIOUS_RETREAT { if(GetHasSpell(SPELL_HASTE, oTarget)) b = 1; } else if(nInt ==39)//SPELL_MAGIC_WEAPON { if(GetHasSpell(SPELL_GREATER_MAGIC_WEAPON, oTarget)) b = 1; } else if(nInt ==41)//SPELL_STONESKIN { if(GetHasSpell(SPELL_GREATER_STONESKIN, oTarget) || GetHasSpell(SPELL_PREMONITION, oTarget)) b = 1; } else if(nInt ==42)//SPELL_GREATER_STONESKIN { if(GetHasSpell(SPELL_PREMONITION, oTarget)) b = 1; } else if(nInt ==48)//SPELL_INVISIBILITY { if(GetHasSpell(SPELL_IMPROVED_INVISIBILITY, oTarget) || GetHasSpell(SPELL_INVISIBILITY_SPHERE, oTarget)) b = 1; } else if(nInt ==49)//SPELL_INVISIBILITY_SPHERE { if(GetHasSpell(SPELL_IMPROVED_INVISIBILITY, oTarget)) b = 1; } else if(nInt ==53)//SPELL_LESSER_MIND_BLANK { if(GetHasSpell(SPELL_MIND_BLANK, oTarget)) b = 1; } else if(nInt ==54)//SPELL_LESSER_SPELL_MANTLE { if(GetHasSpell(SPELL_SPELL_MANTLE, oTarget) || GetHasSpell(SPELL_GREATER_SPELL_MANTLE, oTarget)) b = 1; } else if(nInt ==55)//SPELL_SPELL_MANTLE { if(GetHasSpell(SPELL_GREATER_SPELL_MANTLE, oTarget)) b = 1; } else if(nInt ==57)//SPELL_MINOR_GLOBE_OF_INVULNERABILITY { if(GetHasSpell(SPELL_GLOBE_OF_INVULNERABILITY, oTarget)) b = 1; } else if(nInt ==77)//SPELL_SEE_INVISIBILITY { if(GetHasSpell(SPELL_TRUE_SEEING, oTarget)) b = 1; } //Otherwise, if it's not a spell in one of these categories //Tell the script to have the player cast the spell... else { b = 2; } //If they have a better spell don't allow them to cast this spell if(b==1) { return 1;} //Otherwise allow them to cast the spell.. else { return 2;} //PROTOTYPE END } /////////////THE END, WOOHOO!!!///////////