You are here

Permancy on self

2 posts / 0 new
Last post
Arianna0
Permancy on self

So I have a player who is now high enough level to cast permancy at 14th caster level.  He has cast  See invisibilty on himself.

 

Trying to figure out how to institute some gadget they can just activate every time they log in that will grant them the  See invisibility for the duration  BUT  also  check to see if it gets dispelled  when caught in a  Dispel magic from a higher level caster  removes the see invisibilty and to delete the item if gets dispelled.  The item must also only be usable on the PC  and not any one else.  

script name is   i_009_perm_seeinvis_ac                       item name is 009_perm_seeinvis

 

so far I have this for the script but do not know how to put in the  check for the if dispelled part

 

 

#include "acr_spells_i"


void OnActivate(object oEventItem, object oActTarget, location lActTarget, object oActivator)
{
    effect eEffect;
    object oPC = oActivator;

    // This item must target a PC.
    if ( !GetIsPC(OBJECT_SELF )
    {
        SendMessageToPC(oActivator, "Improper use of this item!");
        return;
    }

    // Apply an effect.
    eEffect = EffectSeeInvisible();
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oActivator);

 

 



    // Remove all effects of a specified type.
    RemoveSpecificEffect(EFFECT_TYPE_SEEINVISIBLE, oActTarget);

    // Destroy objects (not fully effective until this script ends).
    DestroyObject(oEventItem);
    DestroyObject(GetObjectByTag("009_perm_seeinvis"));
}

  • up
    50%
  • down
    50%
kevL's

apparently a callback can be linked as an effect to another effect.


The callback (a function) gets called if the effect is dispelled.

// Brock H. - OEI 12/06/05
// If this is linked to another spell effect, and that spell
// gets removed from an EffectDispelMagic effect, then
// the aOnDispelEffect script will be called.
effect EffectOnDispel( float fDelay, action aOnDispelEffect );



This is untested but it's worth a try:



// 'i_009_perm_seeinvis_ac'

//#include "acr_spells_i"
#include "nw_i0_spells"


//
void OnDispelCallback(object oActivator)
{
    object oActivated = GetItemPossessedBy(oActivator, "009_perm_seeinvis");
    if (GetIsObjectValid(oActivated))
        DestroyObject(oActivated);
}


//
void OnActivate(object oEventItem, object oActTarget, location lActTarget, object oActivator)
{
    // note: the OnItemActivated event can be fired only by a controlled PC
    // so this should never happen, i think:
    if (!GetIsPC(OBJECT_SELF))
    {
        SendMessageToPC(oActivator, "Improper use of this item!");
        return;
    }

    // note: clear the effect *before* re-applying it:
    RemoveSpecificEffect(EFFECT_TYPE_SEEINVISIBLE, oActTarget);
    // note2: that could have unexpected results; if 'oActTarget' has
    // another effect-construction that contains a SeeInvis effect, that
    // entire effect-construction will get removed as well as the
    // permanent SeeInvis ...


    effect eDispel = EffectOnDispel(0.f, OnDispelCallback(oActivator));
    effect eEffect = EffectSeeInvisible();
    eEffect = EffectLinkEffects(eEffect, eDispel);

    // note: not removed by resting:
    eEffect = ExtraordinaryEffect(eEffect);

    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oActivator);


//    DestroyObject(oEventItem);
//    DestroyObject(GetObjectByTag("009_perm_seeinvis"));
}

void main() // for test compiling only.
{}




personally i'd look into
- using a custom SpellId
- doing away with the item, and storing vars on the pc-object, and automagically re-applying/refreshing the permanent SeeInvis in various OnEnter scripts or whenever/wherever it could possibly be cleared, due to other circumstances (dependent on the overall design of the module...). ie, Make it as seamless as possible

ps. Flag the item as both cursed and plot.

  • up
    50%
  • down
    50%