Skip to content

Spell slot loss on shifting

Wasn't there a scripting strategy for getting around this?

Or, has there been any indication that this might get addressed in EE?

Comments

  • TerrorbleTerrorble Member Posts: 169
    I think this is old news for most of you, but I'm sharing since I finally decided to work on it in my mod. (I know I read about this here a while back, I just didn't find the post)

    In short, if you Delay-Command the polymorph section of the code (for Polymorph Self, Shapechange, any druids or shifter shifts), you can add stuff to the player before the slots get lost and prevent them from getting cleared.

    Unfortunately, the player skin gets unequipped during the shift, so adding Bonus Spell Slots to it doesn't work.

    Fortunately, buffing the Casting Stat ahead of time does work. (Which is nice since it is probably the more common reason to have bonus spell slots in the first place)
    void DoPolymorph(object oPC);
    void main()
    {
        int nBuff, nClass = GetLastSpellCastClass();
    
        switch( nClass )
        {
            case    CLASS_TYPE_BARD:
                                        nClass = IP_CONST_CLASS_BARD;
                                        nBuff  = ABILITY_CHARISMA;
                                        break;
            case    CLASS_TYPE_CLERIC:
                                        nClass = IP_CONST_CLASS_CLERIC;
                                        nBuff  = ABILITY_WISDOM;
                                        break;
            case    CLASS_TYPE_DRUID:
                                        nClass = IP_CONST_CLASS_DRUID;
                                        nBuff  = ABILITY_WISDOM;
                                        break;
            case    CLASS_TYPE_PALADIN:
                                        nClass = IP_CONST_CLASS_PALADIN;
                                        nBuff  = ABILITY_WISDOM;
                                        break;
            case    CLASS_TYPE_RANGER:
                                        nClass = IP_CONST_CLASS_RANGER;
                                        nBuff  = ABILITY_WISDOM;
                                        break;
            case    CLASS_TYPE_SORCERER:
                                        nClass = IP_CONST_CLASS_SORCERER;
                                        nBuff  = ABILITY_CHARISMA;
                                        break;
            case    CLASS_TYPE_WIZARD:
                                        nClass = IP_CONST_CLASS_WIZARD;
                                        nBuff  = ABILITY_INTELLIGENCE;
                                        break;
            case    CLASS_TYPE_INVALID:
                                        SendMessageToPC(OBJECT_SELF,"Casting class not found, using Wizard by default.");
                                        break;
    
        default: nClass = IP_CONST_CLASS_WIZARD; ABILITY_INTELLIGENCE; break;
        }
    
        //This part (adding spell slots to the player skin) doesn't work :(
    
        itemproperty ip;
        object oSkin = SKIN_SupportGetSkin(OBJECT_SELF);
        int i, j, k;
    
        if( !GetIsObjectValid(oSkin) ) SendMessageToPC(OBJECT_SELF,"SKIN INVALID");
    
        if( nClass == CLASS_TYPE_PALADIN || nClass == CLASS_TYPE_RANGER ) j = 4;
        else if( nClass == CLASS_TYPE_BARD ) j = 6;
        else j = 9;
    
        //Add 5 spell slots
        for( i=1; i<=j; i++ )
        {
            for( k=0; k<5; k++ )
            {
                ip = ItemPropertyBonusLevelSpell(nClass,i);
                ip = TagItemProperty(ip,"BONUS_SLOT");
                IPSafeAddItemProperty(oSkin,ip,0.0f,X2_IP_ADDPROP_POLICY_IGNORE_EXISTING);
    
            }
        }
    
        //This part (adding the casting stat buff to the PC before the shift) does work!
    
        //I want to know how much of a buff they have to their spell casting ability.
        int nAbilityBuff = GetAbilityScore(OBJECT_SELF,nBuff,FALSE) - GetAbilityScore(OBJECT_SELF,nBuff,TRUE);
    
        if( nAbilityBuff > 1 )
        {
            effect eBonus = EffectAbilityIncrease(nBuff,nAbilityBuff);
            eBonus = TagEffect(eBonus,"BONUS_SLOT");
            ApplyEffectToObject(DURATION_TYPE_PERMANENT,eBonus,OBJECT_SELF);
        }
    
        SetLocalInt(OBJECT_SELF,"BONUS_SLOTS",1);
    
        DelayCommand(0.0,DoPolymorph(OBJECT_SELF));
    }
    

    I have the module heartbeat check for the BONUS_SLOTS Int on the player and remove the appropriately tagged effects if they aren't shifted any longer.
Sign In or Register to comment.