Author Topic: Help with a scripting issue...  (Read 369 times)

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Help with a scripting issue...
« on: March 16, 2015, 12:16:57 am »


               

So I decided to dust off an old mod of mine from back in 1.68 and update it for 1.69. Low and behold my spell scripts won't compile due to this error:


 


PM: Error. 'nw_s0_acidarrow' did not compile.

x3_inc_string.nss(75): ERROR: FUNCTION IMPLEMENTATION AND DEFINTITION DIFFER


 


looking at x3 I see the line 75 the error mentions:


 


string StringReplace(string sSource, string sFind, string sReplace);


 


I'm afraid I was never great at scripting even at the height of my nwn days and I'm even worse now that what little i did know is covered in cobwebs in my head '<img'>


 


here's a copy of the example spell script:



//::///////////////////////////////////////////////
//:: Melf's Acid Arrow
//:: MelfsAcidArrow.nss
//:: Copyright (c) 2000 Bioware Corp.
//:://////////////////////////////////////////////
/*
    An acidic arrow springs from the caster's hands
    and does 3d6 acid damage to the target.  For
    every 3 levels the caster has the target takes an
    additional 1d6 per round.
*/
/////////////////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Created By: Aidan Scanlan
//:: Created On: 01/09/01
//:://////////////////////////////////////////////
//:: Rewritten: Georg Zoeller, Oct 29, 2003
//:: Now uses VFX to track its own duration, cutting
//:: down the impact on the CPU to 1/6th
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Added: by psychospaz
//:: Now uses sneak attack system as well
//:://////////////////////////////////////////////

#include "X0_I0_SPELLS"
#include "x2_inc_spellhook"
#include "x2_i0_spells"
#include "spell_sneak_inc"

float ARROW_TIME_DELAY = 6.0f;

void RunImpact(object oTarget, object oCaster, int nMetaMagic, float nTimeLeft);
void main()
{
    object oTarget = GetSpellTargetObject();

    //--------------------------------------------------------------------------
    // 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())
    {
        return;
    }
    // End of Spell Cast Hook

    //--------------------------------------------------------------------------
    // This spell no longer stacks. If there is one of that type, thats ok
    //--------------------------------------------------------------------------
/*
    if (GetHasSpellEffect(GetSpellId(),oTarget))
    {
        FloatingTextStrRefOnCreature(100775,OBJECT_SELF,FALSE);
        return;
    }
*/
    //--------------------------------------------------------------------------
    // Calculate the duration
    //--------------------------------------------------------------------------
    int nMetaMagic = GetMetaMagicFeat();
    int nDuration = (GetCasterLevel(OBJECT_SELF)/3);

    if (nMetaMagic == METAMAGIC_EXTEND)
    {
       nDuration = nDuration * 2;
    }

    if (nDuration < 1)
    {
        nDuration = 1;
    }


    //--------------------------------------------------------------------------
    // Setup VFX
    //--------------------------------------------------------------------------
    effect eVis     = EffectVisualEffect(VFX_IMP_ACID_L);
    effect eDur     = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
    effect eArrow   = EffectVisualEffect(245);


    //--------------------------------------------------------------------------
    // Set the VFX to be non dispelable, because the acid is not magic
    //--------------------------------------------------------------------------
    eDur = ExtraordinaryEffect(eDur);
     // * Dec 2003- added the reaction check back i
    if (GetIsReactionTypeFriendly(oTarget) == FALSE)
    {
        int nSneakBonus = getSneakDamageRanged(OBJECT_SELF, oTarget);
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId()));

        float fDist = GetDistanceToObject(oTarget);
        float fDelay = (fDist/25.0);


        if(!MyResistSpell(OBJECT_SELF, oTarget))
        {
            //----------------------------------------------------------------------
            // Do the initial 3d6 points of damage
            //----------------------------------------------------------------------
            int nDamage = MaximizeOrEmpower(6,3,nMetaMagic);
            effect eDam = EffectDamage(nDamage+nSneakBonus, DAMAGE_TYPE_ACID);

            DelayCommand(fDelay,ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
            DelayCommand(fDelay,ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));

            float nSpellTime = RoundsToSeconds(nDuration);
            //----------------------------------------------------------------------
            // Apply the VFX that is used to track the spells duration
            //----------------------------------------------------------------------
            DelayCommand(fDelay,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eDur,oTarget, nSpellTime));
            object oSelf = OBJECT_SELF; // because OBJECT_SELF is a function

            //start recursive
            float nRandomDelay = IntToFloat(Random(9))*0.25;
            DelayCommand(ARROW_TIME_DELAY+fDelay+nRandomDelay,
                RunImpact(oTarget, oSelf,nMetaMagic, nSpellTime) );
        }
        else
        {
            //----------------------------------------------------------------------
            // Indicate Failure
            //----------------------------------------------------------------------
            effect eSmoke = EffectVisualEffect(VFX_IMP_REFLEX_SAVE_THROW_USE);
            DelayCommand(fDelay+0.1f,ApplyEffectToObject(DURATION_TYPE_INSTANT,eSmoke,oTarget));
        }
    }
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eArrow, oTarget);

}

void RunImpact(object oTarget, object oCaster, int nMetaMagic, float nTimeLeft)
{
    //Spell Expired
    if (!GetHasSpellEffect(SPELL_MELFS_ACID_ARROW, oTarget))
        return;

    //expired even if other arrows have hit
    if (nTimeLeft<=0.0)
        return;

    if (GetIsDead(oTarget) == FALSE)
    {
        //----------------------------------------------------------------------
        // Calculate Damage
        //----------------------------------------------------------------------
        int nDamage = MaximizeOrEmpower(6,1,nMetaMagic);
        effect eDam = EffectDamage(nDamage, DAMAGE_TYPE_ACID);
        effect eVis = EffectVisualEffect(VFX_IMP_ACID_S);
        eDam = EffectLinkEffects(eVis,eDam); // flare up
        ApplyEffectToObject (DURATION_TYPE_INSTANT,eDam,oTarget);
        DelayCommand(ARROW_TIME_DELAY ,RunImpact(oTarget,oCaster,nMetaMagic, nTimeLeft-ARROW_TIME_DELAY));
    }
}


 


 


I tried commenting out the includes one by one but that didn't help and I got the same error until I commented out the spellhook inc which gave a different error.


 


I know that more info is probably needed for anyone to give me input on how to go about tracking down the cause of the error but if anyone can give me any sort of insight as to where to look I'd be grateful. Thanks in advance!



               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Help with a scripting issue...
« Reply #1 on: March 16, 2015, 12:56:57 am »


               

Are you using a custom x3_inc_string script? The error message you posted means that the parameter list of the function prototype differs from the list of that same, defined function(usually lower in code). You'll quickly see if the signatures differ.


 


 


Kato 



               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Help with a scripting issue...
« Reply #2 on: March 16, 2015, 01:47:49 am »


               


Are you using a custom x3_inc_string script? The error message you posted means that the parameter list of the function prototype differs from the list of that same, defined function(usually lower in code). You'll quickly see if the signatures differ.


 


 


Kato 




 


No I haven't touched the x3_inc_string script. The original module hadn't been updated since patch 1.68 and x3 wasn't added till 1.69. At least... I don't think I've touched it... I'll double check to be sure though!


 


EDIT: Nope! No edits to it. The x3_inc_string is the default untouched script from 1.69


 


Here's the default script:



//::///////////////////////////////////////////////
//:: Functions useful for string manipulation
//:: x3_inc_string
//:: Copyright (c) 2008 Bioware Corp.
//:://////////////////////////////////////////////
/*
    This is a collection of string functions useful
    for coloring text, parsing text, etc.
    Very useful for the new OnPlayerChat event.
*/
//:://////////////////////////////////////////////
//:: Created By: Deva B. Winblood
//:: Created On: Feb 3rd, 2008
//:: Modified by: The Krit
//:: Modified on: Apr 15, 2008
//:://////////////////////////////////////////////


//////////////////////////////////////
// CONSTANTS
//////////////////////////////////////

const string STRING_COLOR_BLACK = "000";
const string STRING_COLOR_BLUE  = "007";
const string STRING_COLOR_GREEN = "070";
const string STRING_COLOR_PINK  = "755";
const string STRING_COLOR_RED   = "700";
const string STRING_COLOR_ROSE  = "744";
const string STRING_COLOR_WHITE = "777";

//////////////////////////////////////
// PROTOTYPES
//////////////////////////////////////


// FILE: x3_inc_string      FUNCTION: StringToRGBString()
//
// This function will make sString be the specified color
// as specified in sRGB.  RGB is the Red, Green, and Blue
// components of the color.  Each color can have a value from
// 0 to 7.
// Ex: red   == "700"
//     green == "070"
//     blue  == "007"
//     white == "777"
//     black == "000"
// The STRING_COLOR_* constants may be used for sRGB.
string StringToRGBString(string sString, string sRGB);


// FILE: x3_inc_string       FUNCTION: StringParse()
//
// This function will parse sSource from left to right until it encounters
// sDelimiter and will return all the characters it encountered before
// the delimiter occurred.
// If bRightToLeft is set to TRUE then it will parse from right to left instead.
string StringParse(string sSource, string sDelimiter = " ", int bRightToLeft = FALSE);


// FILE: x3_inc_string        FUNCTION: StringRemoveParsed()
//
// This function will take sParsed and remove it from the left side of sSource.
// It will also remove any excess sDelimiter occurrences after sParsed.
// If bRightToLeft is set to TRUE then it will perform this from the right side
// rather than the left.
//
// No check is made that sParsed actually matches sSource; all that matters
// about sParsed is its length.
string StringRemoveParsed(string sSource, string sParsed, string sDelimiter = " ", int bRightToLeft = FALSE);


// FILE: x3_inc_string         FUNCTION: StringReplace()
//
// This function will replace any occurrence of sFind in sSource with sReplace.
string StringReplace(string sSource, string sFind, string sReplace);


///////////////////////////////////////
// FUNCTIONS
///////////////////////////////////////


//------------------------------------------------------------------------------
// This function will make sString be the specified color
// as specified in sRGB.  RGB is the Red, Green, and Blue
// components of the color.  Each color can have a value from
// 0 to 7.
//
string StringToRGBString(string sString, string sRGB)
{
    // The magic characters (padded -- the last three characters are the same).
    string sColorCodes = " fw®°Ìþþþ";
    // For the older version going 0 to 6, use:
    //string sColorCodes = " fw®°Ìþþþþ";

    return "<c" +   // Begin the color token.
            GetSubString(sColorCodes, StringToInt(GetSubString(sRGB, 0, 1)), 1) + // red
            GetSubString(sColorCodes, StringToInt(GetSubString(sRGB, 1, 1)), 1) + // green
            GetSubString(sColorCodes, StringToInt(GetSubString(sRGB, 2, 1)), 1) + // blue
            ">" +   // End the color token
            sString + "</c>";
}//StringToRGBString()


//------------------------------------------------------------------------------
// This function will parse sSource from left to right until it encounters
// sDelimiter and will return all the characters it encountered before
// the delimiter occurred.
// If bRightToLeft is set to TRUE then it will parse from right to left instead.
//
string StringParse(string sSource, string sDelimiter = " ", int bRightToLeft = FALSE)
{
    // Find the first delimiter.
    int nDelimIndex = FindSubString(sSource, sDelimiter);
    if ( nDelimIndex < 0 )
        // Delimiter not found; return the whole source string.
        return sSource;

    // For left-to-right, we're basically done.
    if ( !bRightToLeft )
        return GetStringLeft(sSource, nDelimIndex);

    // For right-to-left, we need to find the last delimiter.
    int nLastDelim = 0;
    while ( nDelimIndex >= 0 )
    {
        nLastDelim = nDelimIndex;
        nDelimIndex = FindSubString(sSource, sDelimiter, nLastDelim+1);
    }
    // Return everything after the last delimiter.
    int nRetLength = GetStringLength(sSource) - nLastDelim - GetStringLength(sDelimiter);
    return GetStringRight(sSource, nRetLength);
}//StringParse()


//------------------------------------------------------------------------------
// This function will take sParsed and remove it from the left side of sSource.
// It will also remove any excess sDelimiter occurrences after sParsed.
// If bRightToLeft is set to TRUE then it will perform this from the right side
// rather than the left.
//
// No check is made that sParsed actually matches sSource; all that matters
// about sParsed is its length.
//
string StringRemoveParsed(string sSource, string sParsed, string sDelimiter = " ", int bRightToLeft = FALSE)
{
    int nDelimLength = GetStringLength(sDelimiter);

    if ( !bRightToLeft )
    {
        // Start after a string the length of sParsed.
        int nStart = GetStringLength(sParsed);
        if ( nDelimLength > 0 )
            // Locate excess delimiters.
            while ( GetSubString(sSource, nStart, nDelimLength) == sDelimiter )
                nStart += nDelimLength;
        // Remove the delimiters and the string the length of sParsed.
        return GetStringRight(sSource, GetStringLength(sSource) - nStart);
    }
    else
    {
        // Stop before a string the length of sParsed.
        int nEnd = GetStringLength(sSource) - GetStringLength(sParsed);
        if ( nDelimLength > 0 )
            // Locate excess delimiters.
            while ( GetSubString(sSource, nEnd - nDelimLength, nDelimLength) == sDelimiter )
                nEnd -= nDelimLength;
        // Remove the delimiters and the string the length of sParsed.
        return GetStringLeft(sSource, nEnd);
    }
}//StringRemoveParsed()


//------------------------------------------------------------------------------
// This function will replace any occurrence of sFind in sSource with sReplace.
//
string StringReplace(string sSource, string sFind, string sReplace)
{
    int nFindLength = GetStringLength(sFind);
    int nPosition = 0;
    string sRetVal = "";

    // Locate all occurences of sFind.
    int nFound = FindSubString(sSource, sFind);
    while ( nFound >= 0 )
    {
        // Build the return string, replacing this occurence of sFind with sReplace.
        sRetVal += GetSubString(sSource, nPosition, nFound - nPosition) + sReplace;
        nPosition = nFound + nFindLength;
        nFound = FindSubString(sSource, sFind, nPosition);
    }
    // Tack on the end of sSource and return.
    return sRetVal + GetStringRight(sSource, GetStringLength(sSource) - nPosition);
}//StringReplace()

I think the issue may have something to do with either (or both) of two other systems I am using. The Genji color system seems like a likely culprit since it does things with colored text like the x3 does. Shayan's Subrace Engine also seems to have some interactivity as well. I am wondering if there's some conflict between the two since 1.69



               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Help with a scripting issue...
« Reply #3 on: March 16, 2015, 02:15:49 am »


               

I just tested your spell script, compiles fine, after commenting-out the few lines using the sneak system(and the include itself since I don't have it). Unfortunately I have not used 1.69 for quite some time, sorry that I can't help...


 


 


Kato


               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Help with a scripting issue...
« Reply #4 on: March 16, 2015, 02:21:14 am »


               


I just tested your spell script, compiles fine, after commenting-out the few lines using the sneak system(and the include itself since I don't have it). Unfortunately I have not used 1.69 for quite some time, sorry that I can't help...


 


 


Kato




 


I think I may have found the issue... My version of Shayan's subrace engie is from 1.68 and there's a newer one for 1.69 if I can integrate the updated version it may address my issue! But ty for the input, it helped me think outside the box a bit!