Author Topic: Anti-Magic zone  (Read 871 times)

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Anti-Magic zone
« Reply #15 on: January 22, 2012, 06:44:18 am »


               Not sure if this is your problem either, but just changing the spellhook will only affect spells that are built again afterwords.  Meaning, only spells you've customized already will be affected.  Vanilla ones will still be castable in that area no matter how well the spellhook change is made.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Anti-Magic zone
« Reply #16 on: January 22, 2012, 07:30:01 am »


               Nope, that one of the reasons they put in spell hooking. All vanilla spell check for spell hooks. Just tested the script in a new test module and work perfectly.
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #17 on: January 22, 2012, 01:16:04 pm »


               I understand what you're saying here, and I made the changes - but to no effect. My caster is still popping off any spell he likes.

I work nights so I'm going to get some sleep and tackle this again when I get up. I appreciate the patience of all those who have been trying to help.
               
               

               
            

Legacy_Taino

  • Sr. Member
  • ****
  • Posts: 268
  • Karma: +0/-0
Anti-Magic zone
« Reply #18 on: January 22, 2012, 01:30:01 pm »


               This is a simple one and used by a trigger.

//OnEnter:
void main()
{
   object oPC = GetEnteringObject();
   effect eFail = SupernaturalEffect(EffectSpellFailure());
   ApplyEffectToObject(DURATION_TYPE_PERMANENT,eFail, oPC);
   SendMessageToPC(oPC, "You Feel a tingling sensation..");
}


//OnExit:
#include "nw_i0_spells"

void main()
{
   object oPC = GetExitingObject();
   RemoveSpecificEffect(EFFECT_TYPE_SPELL_FAILURE, oPC);
   SendMessageToPC(oPC, "The tingling sensation goes away..");
}
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Anti-Magic zone
« Reply #19 on: January 22, 2012, 03:05:40 pm »


               

Badwater wrote...

I understand what you're saying here, and I made the changes - but to no effect. My caster is still popping off any spell he likes.

I work nights so I'm going to get some sleep and tackle this again when I get up. I appreciate the patience of all those who have been trying to help.



Did you set the spellhook script to the one you are using?

//------------------------------------------------------------------------------
// Allows the module creator to specify a script that will be run before any spellscript is run
// You can call SetModuleOverrideSpellScriptFinished(); at the end of the script specified by
// sScriptName. If you call this function this will prevent the original spellscript
// (and all craft item code) from being executed.
// If you do not add this line, the original spellscript and/or crafting code will
// run in addition to your script
//------------------------------------------------------------------------------
void SetModuleOverrideSpellscript(string sScriptName) 


               
               

               


                     Modifié par Lightfoot8, 22 janvier 2012 - 03:07 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Anti-Magic zone
« Reply #20 on: January 22, 2012, 03:30:37 pm »


               

Badwater wrote...

I got a reply that offered the following script:

#include "x2_inc_switches"
#include "nw_i0_plot"

void main()
{
    if (GetLocalInt(GetArea(oCaster), "NULL_MAGIC_ZONE") == 1) //Magic Nullification Area
    {
        SetModuleOverrideSpellScriptFinished();
        SendMessageToPC(oCaster, "Your spell disipates before the magical energies conjured forth can manifest any effect.");
    }
}


But on the if stamement line I get an ERROR: VARIABLE DEFINED WITHOUT TYPE


My bad - I forgot to define the variable (what's above is a very small snippet from a spellhook script). Should have looked like this:


#include "x2_inc_switches"
#include "nw_i0_plot"

void main()
{
    object oCaster = OBJECT_SELF;

    if (GetLocalInt(GetArea(oCaster), "NULL_MAGIC_ZONE") == 1) //Magic Nullification Area
    {
        SetModuleOverrideSpellScriptFinished();
        SendMessageToPC(oCaster, "Your spell disipates before the magical energies conjured forth can manifest any effect.");
    }
}

               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Anti-Magic zone
« Reply #21 on: January 22, 2012, 04:27:17 pm »


               Like Lightfoot8 said you probably set up you spell hooking wrong. It ok I got tired of this and uploaded a simple prefab spell hooking module to the vault. When It up I link and you can look it over. There probably already one there.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Anti-Magic zone
« Reply #22 on: January 23, 2012, 03:35:37 am »


               spell hooking link:
spell hooking
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #23 on: February 01, 2012, 08:38:48 am »


               ShadowM, thanks for that link. I've had some RL things going on and I'm picking this up again and working with your download. I'll figure out where my setup went wrong and then implement this.

Thanks again to all that helped!
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #24 on: February 01, 2012, 10:12:48 am »


               Ok, the spellhooking works and I have an OnEnter script that eliminates temporary effects from weapons whether they are equipped or not.

My next question: How can I remove buffs? If my character buffs up then the buffs remain.

Everything else seems solid so far.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Anti-Magic zone
« Reply #25 on: February 01, 2012, 10:19:47 am »


               try this in area OnEnter:

void removeAllTempEffect(object oItem) {
    itemproperty vlastnost;
    if (GetIsObjectValid(oItem)) {
          vlastnost = GetFirstItemProperty(oItem);
          while (GetIsItemPropertyValid(vlastnost))
          {
            if (GetItemPropertyDurationType(vlastnost)==DURATION_TYPE_TEMPORARY) RemoveItemProperty(oItem, vlastnost);
            vlastnost = GetNextItemProperty(oItem);
          }
    }
}

void main()
{
object oPC = GetEnteringObject();
 if(GetIsPC(oPC) && !GetIsDM(oPC) && !GetIsDMPossessed(oPC))
 {
 int nSlot;
 object o,uvnitr;
  for(;nSlot < NUM_INVENTORY_SLOTS;nSlot++)
  {
  o = GetItemInSlot(nSlot,oPC);
   if(o != OBJECT_INVALID)
   {
   removeAllTempEffect(o);
   }
  }
 o = GetFirstItemInInventory(oPC);
  while(o != OBJECT_INVALID)
  {
   if(GetHasInventory(o))
   {
   uvnitr = GetFirstItemInInventory(o);
    while(uvnitr != OBJECT_INVALID)
    {
    removeAllTempEffect(uvnitr);
    uvnitr = GetNextItemInInventory(o);
    }
   }
   else
   {
   removeAllTempEffect(o);
   }
  o = GetNextItemInInventory(oPC);
  }
 effect ef=GetFirstEffect(oPC);
  while(GetIsEffectValid(ef))
  {
  RemoveEffect(oPC,ef);
  ef=GetNextEffect(oPC);
  }
 ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectSpellResistanceDecrease(1),oPC,10.0);
 }
}


               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #26 on: February 01, 2012, 11:44:48 am »


               Sweet. Thanks so much!
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #27 on: February 05, 2012, 09:32:10 pm »


               *Update* I know what happened....never mind
               
               

               


                     Modifié par Badwater, 05 février 2012 - 09:40 .