Aller au contenu

Photo

Anti-Magic zone


  • Veuillez vous connecter pour répondre
27 réponses à ce sujet

#1
Badwater

Badwater
  • Members
  • 113 messages
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 .


#2
Foregone_Conclusion

Foregone_Conclusion
  • Members
  • 85 messages
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.

#3
Badwater

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

#4
Shadooow

Shadooow
  • Members
  • 4 468 messages

#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 .


#5
Badwater

Badwater
  • Members
  • 113 messages

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 .


#6
WhiZard

WhiZard
  • Members
  • 1 204 messages

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.

#7
Badwater

Badwater
  • Members
  • 113 messages
*edit* Dang forums.

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


#8
Badwater

Badwater
  • Members
  • 113 messages
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.

#9
ShadowM

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

#10
Badwater

Badwater
  • Members
  • 113 messages
Thanks to everyone; I will put together a script tonight and test it out.

#11
Badwater

Badwater
  • Members
  • 113 messages
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.");
}
}

#12
ShadowM

ShadowM
  • Members
  • 768 messages
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());

#13
Knight_Shield

Knight_Shield
  • Members
  • 444 messages
http://nwvault.ign.c...l&id=1157#Files

#14
Badwater

Badwater
  • Members
  • 113 messages
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?

#15
ShadowM

ShadowM
  • Members
  • 768 messages

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 .


#16
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
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.

#17
ShadowM

ShadowM
  • Members
  • 768 messages
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.

#18
Badwater

Badwater
  • Members
  • 113 messages
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.

#19
Taino

Taino
  • Members
  • 139 messages
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..");
}

#20
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

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 .


#21
Pstemarie

Pstemarie
  • Members
  • 2 745 messages

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


#22
ShadowM

ShadowM
  • Members
  • 768 messages
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.

#23
ShadowM

ShadowM
  • Members
  • 768 messages
spell hooking link:
spell hooking

#24
Badwater

Badwater
  • Members
  • 113 messages
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!

#25
Badwater

Badwater
  • Members
  • 113 messages
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.