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

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« on: January 20, 2012, 10:10:53 am »


               I had originally posted this in another forum:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I wanted something along the line of this download: http://nwvault.ign.c...s.Detail&id=282

but it appears that this is a module only for NWN2. I'm assuming so because I cannot open it.

Is there anything out there for NWN1 that will do this; establish a no magic area by way of the area's OnEnter script?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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

So I have two questions: 1) How to properly define the variable, and 2) One of the things that attracted me to the download was not only rendering spells ineffective but also making temporary item attributes not work (Darkfire, etc. etc.). Is this script enough to achieve that (and my hunch is no.....)?

Thanks in advance for your input. I'm a builder, not a scripter Jim! ':?'
               
               

               


                     Modifié par Badwater, 20 janvier 2012 - 10:12 .
                     
                  


            

Legacy_Foregone_Conclusion

  • Newbie
  • *
  • Posts: 40
  • Karma: +0/-0
Anti-Magic zone
« Reply #1 on: January 20, 2012, 12:15:40 pm »


               Something like this would have to be on a heartbeat I think. Maybe via remove effect(s) string. Have the script constantly check for active magic effects and the using an IF or If else, to purge active effects.
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #2 on: January 20, 2012, 12:58:12 pm »


               I hate anything dealing with heatbeats (unless there is NO alternative), because it incurs lag in a PW.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Anti-Magic zone
« Reply #3 on: January 20, 2012, 01:11:53 pm »


               

#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.");
    }
}


to your question, darkfire/flameweapon and any magic cast pre-entering this area will continue to work normally

also this script disables any potion/wands which might not be appropriate for you idea - if you want to exclude them use this:

#include "x2_inc_switches"
#include "nw_i0_plot"

void main()
{
object oCaster = OBJECT_SELF;
    if (GetSpellCastItem() == OBJECT_INVALID && 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.");
    }
}


if you want to disable flame weapon/darkdire onhit property you have at least two possibilities:
1) remove all effects or only fire weapon effect from entering object in area OnEnter
2) modify flame weapon/darkfire onhit script to check NULL_MAGIC_ZONE variable
               
               

               


                     Modifié par ShaDoOoW, 20 janvier 2012 - 01:13 .
                     
                  


            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #4 on: January 20, 2012, 01:37:38 pm »


               

ShaDoOoW wrote...
If you want to disable flame weapon/darkdire onhit property you have at least two possibilities:
1) remove all effects or only fire weapon effect from entering object in area OnEnter
2) modify flame weapon/darkfire onhit script to check NULL_MAGIC_ZONE variable


My impression is that option #1 is what I'm after. Is that also the easier option to script?

And....I do want to disable potions and wands, but thanks for the alternative. I want a stringent, non-magic area.
               
               

               


                     Modifié par Badwater, 20 janvier 2012 - 01:39 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Anti-Magic zone
« Reply #5 on: January 20, 2012, 10:26:32 pm »


               

Badwater wrote...

ShaDoOoW wrote...
If you want to disable flame weapon/darkdire onhit property you have at least two possibilities:
1) remove all effects or only fire weapon effect from entering object in area OnEnter
2) modify flame weapon/darkfire onhit script to check NULL_MAGIC_ZONE variable


My impression is that option #1 is what I'm after. Is that also the easier option to script?

And....I do want to disable potions and wands, but thanks for the alternative. I want a stringent, non-magic area.


If you want to remove darkfire you cannot simply remove effects from the player (as the weapon will still have the item property).  You can loop through the item props of the left and right hand slot (also armor if you want to remove magic vestment)  and remove all item properties with a temporary duration.
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #6 on: January 20, 2012, 11:10:25 pm »


               *edit* Dang forums.
               
               

               


                     Modifié par Badwater, 20 janvier 2012 - 11:12 .
                     
                  


            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #7 on: January 20, 2012, 11:12:22 pm »


               Yes, I would like to be removing all item properties of temporary duration...that was one of the attractions of the download for me. It doesn't make sense to me to have an anti-magic area where you can pre-buff to your heart's content.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Anti-Magic zone
« Reply #8 on: January 21, 2012, 01:42:34 am »


               Here a differant discussion but it provide a custom function to remove temporary effects.
social.bioware.com/forum/1/topic/192/index/8847256
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #9 on: January 21, 2012, 02:33:08 am »


               Thanks to everyone; I will put together a script tonight and test it out.
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #10 on: January 21, 2012, 03:00:56 am »


               I've added this script to area OnEnter and heartbeat and have given a NULL_MAGIC_ZONE variable of 1. Nothing is happening, so what is wrong with my script?:

#include "x2_inc_switches"
#include "nw_i0_plot"

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

void removeEffectFromWeapons(object oPC) {
   removeAllTempEffect(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC));
   removeAllTempEffect(GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC));
   removeAllTempEffect(GetItemInSlot(INVENTORY_SLOT_CHEST,oPC));
   removeAllTempEffect(GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC));

   // remove effect also from all item in invertory
   object oItem = GetFirstItemInInventory(oPC);
   while (oItem != OBJECT_INVALID) {
       removeAllTempEffect(oItem);
       oItem = GetNextItemInInventory(oPC);

   }
}


void main()
{
object oCaster = OBJECT_SELF;
   // remove effects from weapons
   removeEffectFromWeapons(GetEnteringObject());

   if (GetSpellCastItem() == OBJECT_INVALID && 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 #11 on: January 21, 2012, 03:50:16 am »


               Well the part about
if (GetSpellCastItem() == OBJECT_INVALID && 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.");
}
}

should go into your spell hooking script.
Get the lexicon and go to Lyceum / Advanced Scripting / Lilac Soul - Spell-Hooking
To see how to set one up.

The other part will go in Onenter of the area, might add a check there also if a null zone, so non null zones do not remove the properties. The pc will also will just buff their weapons and unequip them then put them back on in the zone. Could do the inventory check or do a on equip check.

object oCaster = OBJECT_SELF;
// remove effects from weapons
removeEffectFromWeapons(GetEnteringObject());
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Anti-Magic zone
« Reply #12 on: January 21, 2012, 04:12:41 pm »


               http://nwvault.ign.c...l&id=1157#Files
               
               

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Anti-Magic zone
« Reply #13 on: January 22, 2012, 12:09:55 am »


               Ok, so my spellhook script is now defined as a script in the module variables, and is:

#include "x2_inc_switches"
#include "nw_i0_plot"


void main()
{
object oCaster = OBJECT_SELF;

   if (GetSpellCastItem() == OBJECT_INVALID && 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.");
   }
}

and nothing happens. The area has NULL_MAGIC_ZONE int 1 and my caster can cast spells in the area. What am I not picking up on?
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Anti-Magic zone
« Reply #14 on: January 22, 2012, 05:48:49 am »


               

Badwater wrote...

Ok, so my spellhook script is now defined as a script in the module variables, and is:

#include "x2_inc_switches"
#include "nw_i0_plot"


void main()
{
object oCaster = OBJECT_SELF;

   if (GetSpellCastItem() == OBJECT_INVALID && 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.");
   }
}

and nothing happens. The area has NULL_MAGIC_ZONE int 1 and my caster can cast spells in the area. What am I not picking up on?


You saying that it will block the magic item if it not a valid item.
You not checking the spell, I add a check to see if it a spell and not a feat too, from my system.

#include "x2_inc_switches"

int nSpell=GetSpellId();
object oCaster = OBJECT_SELF;
void main()
{

string sSpellCheck =Get2DAString("spells","UserType",nSpell);
if(GetLocalInt(GetArea(oCaster), "NULL_MAGIC_ZONE") == 1 && sSpellCheck=="1")
{
SendMessageToPC(oCaster, "Your spell disipates before the magical energies conjured forth can manifest any effect.");
SetModuleOverrideSpellScriptFinished();
return;
}
}

Try that and define you stuff before the void main when using spell hooks it saves on headaches as you will see later, if you want to look at my system look hr_base in script "hr_spells_router"  updated did not need the item check.
               
               

               


                     Modifié par ShadowM, 22 janvier 2012 - 04:24 .