void main()
{
    object oCaster = GetLastSpellCaster();
    object oTarget = OBJECT_SELF;
    int nInt = GetLocalInt(oCaster, "CurtainKnocks");
    nInt += 1;

    if(GetLastSpell() == SPELL_KNOCK)
     {
     SetLocalInt(oCaster, "CurtainKnocks", nInt);
     nInt = GetLocalInt(oCaster, "CurtainKnocks");
     if (nInt == 2)
      {
      SetPlotFlag(OBJECT_SELF, FALSE);
      DestroyObject(OBJECT_SELF, 0.0);
      DestroyObject(GetObjectByTag("TriggerCurtain1"), 0.0);
      DestroyObject(GetObjectByTag("TriggerCurtain2"), 0.0);
      GiveXPToCreature(oCaster, 50);
      ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_BREACH), GetLocation(OBJECT_SELF));
      FloatingTextStringOnCreature("It worked! The netting was destroyed!", oCaster);
      }
     else if (nInt == 1)
      {
      ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_KNOCK), GetLocation(OBJECT_SELF));
      DelayCommand(1.5, FloatingTextStringOnCreature("Your 'Knock' spell almost worked...", oCaster));
      }
     }

    if ((GetLastSpell() == SPELL_DISPEL_MAGIC)|(GetLastSpell() == SPELL_GREATER_DISPELLING)|(GetLastSpell() == SPELL_LESSER_DISPEL))
     {
     SetPlotFlag(OBJECT_SELF, FALSE);
     DestroyObject(OBJECT_SELF, 0.0);
     DestroyObject(GetObjectByTag("TriggerCurtain1"), 0.0);
     DestroyObject(GetObjectByTag("TriggerCurtain2"), 0.0);
     GiveXPToCreature(oCaster, 50);
     ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_BREACH), GetLocation(OBJECT_SELF));
     FloatingTextStringOnCreature("It worked! The netting was destroyed!", oCaster);
     }

}
