PoA_PRC8/_module/nss/buffme.nss
Jaysyn904 8d97886c3f Changed folder name.
Changed folder name.
2022-10-07 21:08:37 -04:00

333 lines
10 KiB
Plaintext

//Script Name: buffme
//////////////////////////////////////////
// Created By: Genisys (Guile)
// Created On: 8/13/08
// Updated On: 4/01/09
/////////////////////////////////////////
/*
This script must be executed from another
script, utilizing the ExecuteScript("buffme", oPC);
function, basically this script will,
if PC is a spell caster, they
will cast all of their buffs instantly, if
they have the spells to cast.
*/
////////////////////////////////////////
#include "x2_inc_switches"
////////////////////////////////////////
//PROTOTYPE(S) DECLARED
int GetHasBetter(object oTarget, int nInt);
void Buff ();
////////////////////////////////////////////
//Main Script
void main()
{
//Make the caster use all buff spells instantly!
Buff();
//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 == 17) //Displacement
{
//Improved Invisibility has 50% concealment!
if(GetHasSpell(SPELL_IMPROVED_INVISIBILITY, oTarget))
b = 1;
}
else if(nInt ==27) //SPELL_EXPEDITIOUS_RETREAT
{
if(GetHasSpell(SPELL_HASTE, oTarget))
b = 1;
}
else if(nInt ==44)//SPELL_MAGIC_WEAPON
{
if(GetHasSpell(SPELL_GREATER_MAGIC_WEAPON, oTarget))
b = 1;
}
else if(nInt ==46)//SPELL_STONESKIN
{
if(GetHasSpell(SPELL_GREATER_STONESKIN, oTarget) ||
GetHasSpell(SPELL_PREMONITION, oTarget))
b = 1;
}
else if(nInt ==47)//SPELL_GREATER_STONESKIN
{
if(GetHasSpell(SPELL_PREMONITION, oTarget))
b = 1;
}
else if(nInt ==52)//SPELL_INVISIBILITY
{
if(GetHasSpell(SPELL_IMPROVED_INVISIBILITY, oTarget) ||
GetHasSpell(SPELL_INVISIBILITY_SPHERE, oTarget))
b = 1;
}
else if(nInt ==53)//SPELL_INVISIBILITY_SPHERE
{
if(GetHasSpell(SPELL_IMPROVED_INVISIBILITY, oTarget))
b = 1;
}
else if(nInt ==57)//SPELL_LESSER_MIND_BLANK
{
if(GetHasSpell(SPELL_MIND_BLANK, oTarget))
b = 1;
}
else if(nInt ==58)//SPELL_LESSER_SPELL_MANTLE
{
if(GetHasSpell(SPELL_SPELL_MANTLE, oTarget) ||
GetHasSpell(SPELL_GREATER_SPELL_MANTLE, oTarget))
b = 1;
}
else if(nInt ==59)//SPELL_SPELL_MANTLE
{
if(GetHasSpell(SPELL_GREATER_SPELL_MANTLE, oTarget))
b = 1;
}
else if(nInt ==61)//SPELL_MINOR_GLOBE_OF_INVULNERABILITY
{
if(GetHasSpell(SPELL_GLOBE_OF_INVULNERABILITY, oTarget))
b = 1;
}
else if(nInt ==81)//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;
}
return b;
/*
//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
}
//////////////////////////////////////////////////////////////////////////////
//PROTOTYPE DEFINED
void Buff()
{
object oPC;
int nSpellId;
int nSpell;
int i;
int nGs;
oPC = OBJECT_SELF;
//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<87; 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_AID; break; }
case 2: { nSpell = SPELL_AMPLIFY; break; }
case 3: { nSpell = SPELL_AURA_OF_VITALITY; break; }
case 4: { nSpell = SPELL_AURAOFGLORY; break; }
case 5: { nSpell = SPELL_BARKSKIN; break; }
case 6: { nSpell = SPELL_BATTLETIDE; break; }
case 7: { nSpell = SPELL_BLACKSTAFF; break; }
case 8: { nSpell = SPELL_BLESS; break; }
case 9: { nSpell = SPELL_BLESS_WEAPON; break; }
case 10: { nSpell = SPELL_BLOOD_FRENZY; break; }
//Redundant spells, we will check for better versions first!
case 11: { nSpell = SPELL_CAMOFLAGE; break; }
case 12: { nSpell = SPELL_CLAIRAUDIENCE_AND_CLAIRVOYANCE; break; }
case 13: { nSpell = SPELL_CLARITY; break; }
case 14: { nSpell = SPELL_DARKFIRE; break; }
case 15: { nSpell = SPELL_DEATH_ARMOR; break; }
case 16: { nSpell = SPELL_DEATH_WARD; break; }
case 17: { nSpell = SPELL_DISPLACEMENT; break; }
case 18: { nSpell = SPELL_DIVINE_FAVOR; break; }
case 19: { nSpell = SPELL_DIVINE_POWER; break; }
case 20: { nSpell = SPELL_ELEMENTAL_SHIELD; 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_ENTROPIC_SHIELD; break; }
case 26: { nSpell = SPELL_ETHEREAL_VISAGE; break; }
case 27: { nSpell = SPELL_EXPEDITIOUS_RETREAT; break; }
case 28: { nSpell = SPELL_FLAME_WEAPON; break; }
case 29: { nSpell = SPELL_FREEDOM_OF_MOVEMENT; break; }
case 30: { nSpell = SPELL_GHOSTLY_VISAGE; break; }
case 31: { nSpell = SPELL_MAGE_ARMOR; break; }
//Redundant Spells we will check for better first!
case 32: { nSpell = SPELL_BULLS_STRENGTH; break; }
case 33: { nSpell = SPELL_CATS_GRACE; break; }
case 34: { nSpell = SPELL_EAGLE_SPLEDOR; break; }
case 35: { nSpell = SPELL_ENDURANCE; break; }
case 36: { nSpell = SPELL_FOXS_CUNNING; break; }
case 37: { nSpell = SPELL_OWLS_WISDOM; break; }
case 38: { nSpell = SPELL_GREATER_BULLS_STRENGTH; break; }
case 39: { nSpell = SPELL_GREATER_CATS_GRACE; break; }
case 40: { nSpell = SPELL_GREATER_EAGLE_SPLENDOR; break; }
case 41: { nSpell = SPELL_GREATER_ENDURANCE; break; }
case 42: { nSpell = SPELL_GREATER_FOXS_CUNNING; break; }
case 43: { nSpell = SPELL_GREATER_OWLS_WISDOM; break; }
//Redundant spells, we will check for better versions first!
case 44: { nSpell = SPELL_MAGIC_WEAPON; break; }
case 45: { nSpell = SPELL_GREATER_MAGIC_WEAPON; break; }
//Redundant spells, we will check for better versions first!
case 46: { nSpell = SPELL_STONESKIN; break; }
case 47: { nSpell = SPELL_GREATER_STONESKIN; break; }
case 48: { nSpell = SPELL_PREMONITION; break; }
case 49: { nSpell = SPELL_HASTE; break; }
case 50: { nSpell = SPELL_HOLY_AURA; break; }
case 51: { nSpell = SPELL_HOLY_SWORD; break; }
//Redundant spells, we will check for better versions first!
case 52: { nSpell = SPELL_INVISIBILITY; break; }
case 53: { nSpell = SPELL_INVISIBILITY_SPHERE; break; }
case 54: { nSpell = SPELL_IMPROVED_INVISIBILITY; break; }
case 55: { nSpell = SPELL_KEEN_EDGE; break; }
case 56: { nSpell = SPELL_LIGHT; break; }
//Redundant spells, we will check for better versions first!
case 57: { nSpell = SPELL_LESSER_MIND_BLANK; break; }
//Redundant spells, we will check for better versions first!
case 58: { nSpell = SPELL_LESSER_SPELL_MANTLE; break; }
case 59: { nSpell = SPELL_SPELL_MANTLE; break; }
case 60: { nSpell = SPELL_GREATER_SPELL_MANTLE; break; }
//Redundant spells, we will check for better versions first!
case 61: { nSpell = SPELL_MINOR_GLOBE_OF_INVULNERABILITY; break; }
case 62: { nSpell = SPELL_GLOBE_OF_INVULNERABILITY; break; }
case 63: { nSpell = SPELL_MAGE_ARMOR; break; }
case 64: { nSpell = SPELL_MAGIC_CIRCLE_AGAINST_CHAOS; break; }
case 65: { nSpell = SPELL_MAGIC_CIRCLE_AGAINST_EVIL; break; }
case 66: { nSpell = SPELL_MAGIC_VESTMENT; break; }
case 67: { nSpell = SPELL_MASS_CAMOFLAGE; break; }
case 68: { nSpell = SPELL_MASS_HASTE; break; }
case 69: { nSpell = SPELL_MESTILS_ACID_SHEATH; break; }
case 70: { nSpell = SPELL_MIND_BLANK; break; }
case 71: { nSpell = SPELL_MONSTROUS_REGENERATION; break; }
case 72: { nSpell = SPELL_NEGATIVE_ENERGY_PROTECTION; break; }
case 73: { nSpell = SPELL_ONE_WITH_THE_LAND; break; }
case 74: { nSpell = SPELL_OWLS_INSIGHT; break; }
case 75: { nSpell = SPELL_PRAYER; break; }
case 76: { nSpell = SPELL_PROTECTION_FROM_SPELLS; break; }
case 77: { nSpell = SPELL_PROTECTION_FROM_EVIL; break; }
case 78: { nSpell = SPELL_REGENERATE; break; }
case 79: { nSpell = SPELL_RESISTANCE; break; }
case 80: { nSpell = SPELL_SPELL_RESISTANCE; break; }
//Redundant spells, we will check for better versions first!
case 81: { nSpell = SPELL_SEE_INVISIBILITY; break; }
case 82: { nSpell = SPELL_SHADOW_SHIELD; break; }
case 83: { nSpell = SPELL_SHIELD; break; }
case 84: { nSpell = SPELL_TRUE_SEEING; break; }
case 85: { nSpell = SPELL_UNHOLY_AURA; break; }
case 86: { nSpell = SPELL_VINE_MINE_CAMOUFLAGE; break; }
case 87: { nSpell = SPELL_WOUNDING_WHISPERS; break; }
case 88: { nSpell = SPELL_VIRTUE; 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);
}
//PROTOTYPE END
}
/////////////THE END, WOOHOO!!!///////////