#include "x2_inc_switches" //#include "prc_inc_spells" const int nMaxSpells = 20; void FireSpells(); int AddSpell(object oSpellGem); string GetMetaMagicString(int iMetaMagic); void main() { int nEvent =GetUserDefinedItemEventNumber(); object oPC; object oItem; if (nEvent == X2_ITEM_EVENT_SPELLCAST_AT) { oItem = GetSpellTargetObject(); if (GetIsObjectValid(oItem) && GetObjectType(oItem) == OBJECT_TYPE_ITEM && GetTag(oItem) == "MC_IT_QUICKSLOT") { AddSpell(oItem); SetModuleOverrideSpellScriptFinished(); } } // * This code runs when the Unique Power property of the item is used // * Note that this event fires PCs only else if (nEvent == X2_ITEM_EVENT_ACTIVATE) { // else if (nEvent == MOD_ONACTIVATE) { FireSpells(); } // unacquiring clears the stored spells else if (nEvent == X2_ITEM_EVENT_UNACQUIRE) { // else if (nEvent == PWS_ONUNACQUIRE) { oItem = GetModuleItemLost(); int i; for (i = 1; i<= nMaxSpells; i++) { DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER" + IntToString(i)); DeleteLocalInt(oItem, "X2_L_METAMAGIC" + IntToString(i)); DeleteLocalInt(oItem, "X2_L_NUMTRIGGERS"); } SetName(oItem, ""); } } void FireSpells() { object oItem = GetItemActivated(); object oPC = GetItemActivator(); int i = 0; int nSpellId = -1; int nMode = GetSpellId(); int iMax = GetLocalInt(oItem, "X2_L_NUMTRIGGERS"); int iMetaMagic; if (iMax < 1) { FloatingTextStrRefOnCreature(83886, oPC); // no spells stored return; } int bSuccess = FALSE; AssignCommand(oPC, ClearAllActions(TRUE)); for (i = 1; i <= iMax; i++) { nSpellId = GetLocalInt(oItem, "X2_L_SPELLTRIGGER" + IntToString(i)); if (nSpellId > 0) { bSuccess = TRUE; iMetaMagic = GetLocalInt(oItem, "X2_L_METAMAGIC" + IntToString(i)); nSpellId --; // I added +1 to the spellID when the sequencer was created, so I have to remove it here DelayCommand(IntToFloat(i), AssignCommand(oPC, ActionCastSpellAtObject(nSpellId, oPC, iMetaMagic, FALSE, 0, PROJECTILE_PATH_TYPE_DEFAULT, FALSE))); } } } int AddSpell(object oSpellGem) { object oPC = GetLastSpellCaster(); // Does the Gem already have the maximum amount of spells stored int nNumSpells = GetLocalInt(oSpellGem, "X2_L_NUMTRIGGERS"); if (nNumSpells >= nMaxSpells) { FloatingTextStringOnCreature("This spell gem is full, no more spells may be added to it.", oPC); return FALSE; } else { // spell cannot be cast from an item if (GetIsObjectValid(GetSpellCastItem())) { FloatingTextStringOnCreature("Cannot use one object to enchant another.", oPC); return FALSE; } // Check if the spell is marked as hostile in spells.2da int nHostile = StringToInt(Get2DAString("spells","HostileSetting",GetSpellId())); if (nHostile == 1) { FloatingTextStringOnCreature("Cannot store offensive spells!", oPC); return FALSE; // no hostile spells on sequencers, sorry ya munchkins :) } // success visual and store spell-id on item. effect eVisual = EffectVisualEffect(VFX_IMP_BREACH); nNumSpells++; //NOTE: I add +1 to the SpellId to spell 0 can be used to trap failure int nSID = GetSpellId()+1; int iMetaMagic = GetMetaMagicFeat(); SetLocalInt(oSpellGem, "X2_L_SPELLTRIGGER" + IntToString(nNumSpells), nSID); SetLocalInt(oSpellGem, "X2_L_METAMAGIC" + IntToString(nNumSpells), iMetaMagic); SetLocalInt(oSpellGem, "X2_L_NUMTRIGGERS", nNumSpells); ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPC); FloatingTextStringOnCreature("Spell Stored", oPC); if (nNumSpells == 1) { SetName(oSpellGem, GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSID-1))) + GetMetaMagicString(iMetaMagic) + "\n"); } else { SetName(oSpellGem, GetName(oSpellGem) + GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSID-1))) + GetMetaMagicString(iMetaMagic) + "\n"); } } return TRUE; } string GetMetaMagicString(int iMetaMagic) { switch (iMetaMagic) { case METAMAGIC_NONE : return ""; break; case METAMAGIC_EMPOWER : return " (Empowered) "; break; case METAMAGIC_EXTEND : return " (Extended) "; break; case METAMAGIC_MAXIMIZE : return " (Maximized) "; break; case METAMAGIC_QUICKEN : return " (Quickened) "; break; case METAMAGIC_SILENT : return " (Silenced) "; break; case METAMAGIC_STILL : return " (Stilled) "; break; } return ""; }