Holy Vision Spell script question (RESOLVED)

Hi everyone,

I am going through some spells in my module I could never get to work. I have this one spell called: “Holy Vision”…see below.

It is suppose to primarily show the entire map area when cast along with some other features (i.e. grants ultravision and truesight to caster, removes blindness in addition).

Here is the original spell as I have it:

//::///////////////////////////////////////////////
//:: Holy Vision
//:: kl_sp_holyvision.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Reveals the entire area to the Caster and
    all Players in the party.
*/
//:://////////////////////////////////////////////
//:: Created By: junhunglau
//:: Created On: Mar 07, 2007
//:://////////////////////////////////////////////
// Modified by junhunglau Apr 10, 2007 - Now briefly grants ultravision and truesight to caster, removes blindness
#include "kl_inc_spells"

void HolyVision(object oCaster);
void HolyVision(object oCaster)
{
    object oPC = GetFirstFactionMember(oCaster, TRUE);
    effect eVis2 = EffectVisualEffect(VFX_DUR_MAGICAL_SIGHT);

    while (GetIsObjectValid(oPC))
        {
        if(oPC != oCaster)
            {
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis2, oPC, 5.0);
            FloatingTextStringOnCreature("*Holy Vision*", oPC, TRUE);
            ExploreAreaForPlayer(GetArea(oCaster), oPC, TRUE);
            }
        oPC = GetNextFactionMember(oCaster, TRUE);
        }

    object oMapPin = GetFirstObjectInArea();
    while (GetIsObjectValid(oMapPin))
        {
        if(GetObjectType(oMapPin) == OBJECT_TYPE_WAYPOINT)
            {
            SetMapPinEnabled(oMapPin, TRUE);
            }
        oMapPin = GetNextObjectInArea();
        }
}
void main()
{

/*
  Spellcast Hook Code
  Added 2003-06-20 by Georg
  If you want to make changes to all spells,
  check x2_inc_spellhook.nss to find out more

*/

    if (!X2PreSpellCastCode())
    {
    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

// End of Spell Cast Hook

    object oCaster = OBJECT_SELF;

    effect eVis1 = EffectVisualEffect(VFX_FNF_LOS_HOLY_30);
    effect eVis2 = EffectVisualEffect(VFX_DUR_MAGICAL_SIGHT);
    effect eUltra = EffectUltravision();
    effect eTrue = EffectTrueSeeing();
    effect eLink = EffectLinkEffects(eUltra, eTrue);
           eLink = EffectLinkEffects(eLink, eVis2);
           eLink = SupernaturalEffect(eLink);

    SignalEvent(oCaster, EventSpellCastAt(oCaster, GetSpellId(), FALSE));
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis1, oCaster);

    if(GetHasEffect(EFFECT_TYPE_BLINDNESS, oCaster))
        {
        RemoveSpecificEffect(EFFECT_TYPE_BLINDNESS, oCaster);
        }
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oCaster, 6.0);
    HolyVision(oCaster);
}

But I took out the include: #include “kl_inc_spells”

And right away it did not compile. I tried fixing all the errors going down after that which I did (i.e. remove right brackets, put in brackets, etc as prompted)…then got to the point below (see screen shot of last error I can’t fix). I tried doing what it said and it still did not compile. I almost made it to the end,…lol

Why did I take out the include? I figured it depended on that and figured since many spells that depend on that include do not work…maybe the spell could be adjusted to work without it…my logic…it looks like it should as a stand alone.

Here is the error:

The spell version below is where I get the above error that I have adjusted. Any feedback would be appreciated.

//::///////////////////////////////////////////////
//:: Holy Vision
//:: kl_sp_holyvision.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Reveals the entire area to the Caster and
    all Players in the party.
*/
//:://////////////////////////////////////////////
//:: Created By: junhunglau
//:: Created On: Mar 07, 2007
//:://////////////////////////////////////////////
// Modified by junhunglau Apr 10, 2007 - Now briefly grants ultravision and truesight to caster, removes blindness


void HolyVision(object oCaster);
void HolyVision(object oCaster)
{
    object oPC = GetFirstFactionMember(oCaster, TRUE);
    effect eVis2 = EffectVisualEffect(VFX_DUR_MAGICAL_SIGHT);

    while (GetIsObjectValid(oPC))
        {
        if(oPC != oCaster)
            {
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis2, oPC, 5.0);
            FloatingTextStringOnCreature("*Holy Vision*", oPC, TRUE);
            ExploreAreaForPlayer(GetArea(oCaster), oPC, TRUE);
            }
        oPC = GetNextFactionMember(oCaster, TRUE);
        }

    object oMapPin = GetFirstObjectInArea();
    while (GetIsObjectValid(oMapPin))
        {
        if(GetObjectType(oMapPin) == OBJECT_TYPE_WAYPOINT)
            {
            SetMapPinEnabled(oMapPin, TRUE);
            }
        oMapPin = GetNextObjectInArea();
        }
}
void main()
{

/*
  Spellcast Hook Code
  Added 2003-06-20 by Georg
  If you want to make changes to all spells,
  check x2_inc_spellhook.nss to find out more

*/

    if (!X2PreSpellCastCode)
    {
    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

// End of Spell Cast Hook

    object oCaster = OBJECT_SELF;

    effect eVis1 = EffectVisualEffect(VFX_FNF_LOS_HOLY_30);
    effect eVis2 = EffectVisualEffect(VFX_DUR_MAGICAL_SIGHT);
    effect eUltra = EffectUltravision();
    effect eTrue = EffectTrueSeeing();
    effect eLink = EffectLinkEffects(eUltra, eTrue);
           eLink = EffectLinkEffects(eLink, eVis2);
           eLink = SupernaturalEffect(eLink);

    SignalEvent(oCaster, EventSpellCastAt(oCaster, GetSpellId(), FALSE));
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis1, oCaster);

    if (GetHasEffect(EFFECT_TYPE_BLINDNESS, oCaster))
        {
        RemoveSpecificEffect(EFFECT_TYPE_BLINDNESS, oCaster);
        }
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oCaster, 6.0);
    HolyVision(oCaster);
}

That include probably has functions that this script needs to compile (that you use in this script). Other than that I can’t see anything wrong at first glance.

It probably has the GetHasEffect(). That’s why you get the ‘NO RIGHT BRACKET ON EXPRESSION’ error. The compiler expects a right bracket after GetHasEffect because he does know it and expects it to be a variable (and not a function).

To fix your script you either have to search that include file for the GetHasEffect() implementation and copy it into your script or write your own GetHasEffect() function.

Same for RemoveSpecificEffect().

That if (GetHasEffect(...)) is not really needed (and actually a waste).

Replace

    if (GetHasEffect(EFFECT_TYPE_BLINDNESS, oCaster))
        {
        RemoveSpecificEffect(EFFECT_TYPE_BLINDNESS, oCaster);
        }

with

        RemoveSpecificEffect(EFFECT_TYPE_BLINDNESS, oCaster);

and use the following implementation

int RemoveSpecificEffect(int nEffect, object oTarget)
{
   int nResult = FALSE;
   effect eff = GetFirstEffect(oTarget);
   while (GetIsEffectValid(eff))
   {
      if (GetEffectType(eff) == nEffect)
      {
          RemoveEffect(oTarget, eff);
          nResult = TRUE;
          break;
      }
      eff = GetNextEffect(oTarget);  
   }
   return nResult;
}

Not tested in the toolset.

GetHasEffect is found in “x0_i0_match” and RemoveSpecificEffect is found in “nw_i0_spells”.

At the top of your script, before the void main(), add these two lines:

#include "x0_i0_spells"
#include "x2_inc_spellhook"

I say use x0_i0_spells because it is the main XP1 spell include and includes both nw_i0_spells and x0_i0_match. You also need the spellhook include because you have the spellhook check.

Any spellscript you make needs to include at least x2_inc_spellhook and at least one of the main spell includes - typically x0_i0_spells. Depending upon what your spell is doing, you may need to use x2_i0_spells instead of x0_i0_spells OR you may be able to just use nw_i0_spells instead of x0_i0_spells.

I tend to use x0_i0_spells as it includes a lot of helper functions commonly used in spells and greatly reduces the need to add new functions.

Any time you compile a script and it errors out on a function, look up the function on the Lexicon site by googling “nwn Lexicon” and the name of the function. The lexicon’s description of the function will tell you how to use it and what include file it is found in. If no include file listed, then the function is built into the game code (i.e. hardcoded). If the Lexicon doesn’t include the function, then its a good bet that its a custom function.

Hi andgalf,

I took out the include because I have other spells too made by the same author in my module that depend on that include which (for some reason) ALL those spells do not work. So if these scripts are already written out…I figured that maybe I can adjust them without that include.

Hi Kamiryn,

I will try what you suggested above. Are the changes to be done on the original one above or on my current one I have experimented on?

Hi Pstemarie,

I will try what you suggest too. Thanks for your input bud. :slight_smile:

Ok, I started simple first.

I took the ORIGINAL script of the authour then I took out his “include” and added in the two “includes” Pstemarie suggested. And BAM!..it compiled…just like that. Wow…maybe now I can get a ton of spells this authour made to work with that simple fix. :slight_smile:

I will test it and get back to you all :slight_smile:

Thanks again guys for all your help :slight_smile:

Ok tested it.

The visual effects effects worked, but the words did not float above the head as it was suppose to. AND…it did not do the main thing I wanted it to do and that is show the map of the entire area. :frowning:

Here is the script that compiles.

//::///////////////////////////////////////////////
//:: Holy Vision
//:: kl_sp_holyvision.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Reveals the entire area to the Caster and
    all Players in the party.
*/
//:://////////////////////////////////////////////
//:: Created By: junhunglau
//:: Created On: Mar 07, 2007
//:://////////////////////////////////////////////
// Modified by junhunglau Apr 10, 2007 - Now briefly grants ultravision and truesight to caster, removes blindness
#include "x0_i0_spells"
#include "x2_inc_spellhook"

void HolyVision(object oCaster);
void HolyVision(object oCaster)
{
    object oPC = GetFirstFactionMember(oCaster, TRUE);
    effect eVis2 = EffectVisualEffect(VFX_DUR_MAGICAL_SIGHT);

    while (GetIsObjectValid(oPC))
        {
        if(oPC != oCaster)
            {
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis2, oPC, 5.0);
            FloatingTextStringOnCreature("*Holy Vision*", oPC, TRUE);
            ExploreAreaForPlayer(GetArea(oCaster), oPC, TRUE);
            }
        oPC = GetNextFactionMember(oCaster, TRUE);
        }

    object oMapPin = GetFirstObjectInArea();
    while (GetIsObjectValid(oMapPin))
        {
        if(GetObjectType(oMapPin) == OBJECT_TYPE_WAYPOINT)
            {
            SetMapPinEnabled(oMapPin, TRUE);
            }
        oMapPin = GetNextObjectInArea();
        }
}
void main()
{

/*
  Spellcast Hook Code
  Added 2003-06-20 by Georg
  If you want to make changes to all spells,
  check x2_inc_spellhook.nss to find out more

*/

    if (!X2PreSpellCastCode())
    {
    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

// End of Spell Cast Hook

    object oCaster = OBJECT_SELF;

    effect eVis1 = EffectVisualEffect(VFX_FNF_LOS_HOLY_30);
    effect eVis2 = EffectVisualEffect(VFX_DUR_MAGICAL_SIGHT);
    effect eUltra = EffectUltravision();
    effect eTrue = EffectTrueSeeing();
    effect eLink = EffectLinkEffects(eUltra, eTrue);
           eLink = EffectLinkEffects(eLink, eVis2);
           eLink = SupernaturalEffect(eLink);

    SignalEvent(oCaster, EventSpellCastAt(oCaster, GetSpellId(), FALSE));
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis1, oCaster);

    if(GetHasEffect(EFFECT_TYPE_BLINDNESS, oCaster))
        {
        RemoveSpecificEffect(EFFECT_TYPE_BLINDNESS, oCaster);
        }
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oCaster, 6.0);
    HolyVision(oCaster);
}

Looking at the script…

Do you have several waypoints in the area? 'Cause if you do, it seems that the script takes the first waypoint object it can find and sets the map pin to enabled. But maybe that’s what you want…
Also, by trying to make sense of the script…It seems like the script will only show the area for the player if he/she is not the oCaster. Maybe I’m thinking backwards here but…shouldn’t it be that it shows the area if the player is the caster? Like this:

if(oPC == oCaster)

instead of

if(oPC != oCaster)

@Pstemarie and @Kamiryn will have to correct me on this if I’m wrong here.

I will try that one change you suggest. I’m not sure why this script makes reference to “waypoints”…I wonder if there is an easier way to just script this to show the entire map. Not sure how to do that.

Hmmm, ok, oCaster is set to OBJECT_SELF I see now. Who is OBJECT_SELF here? What I mean by that is: Where is this script called? Is it on a trigger, on a placeable or on a person?

I do not know. Why can’t there just be a simple constant that says: “show area map” to caster and party…lol

You must know this. Where have you put the script inside the game?

Hey andgalf,

Your small change made it work!! Thanks man.

And thanks also to Pstemarie and Kamiryn. You guys are very helpful too. :slight_smile:

I’d still like to know where the script is put to understand the situation better.

EDIT: If I had to guess the owner of the script is the player? He/she casts this spell?

I don’t understand your question as to where it is put?

It is a spell I have in the game. To cast it so it does what it does (reveal the area). It is one of the many spells I have in the game.

Ok, so this is not a spell that’s on an object or a character or a placeable. It’s just a spell that you cast? In that case it makes sense that my change worked for you.

EDIT: You know, sometimes you have scripts on the OnHeartbeat of a character for example, or a spell that’s put on a trigger and that runs from that trigger when you enter the trigger for example.

1 Like

Yup…now I understand your question. Yes it is a spell a PC would cast :slight_smile: