Aller au contenu

Photo

Editing Scripts


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

#1
Kesaru

Kesaru
  • Members
  • 130 messages
This is a weird question, but somehow I cannot find the information anywhere.
How do I open the script editor for this game? I have absolutely no idea where it is, and not a single tutorial I've found actually says where it is. I can't find it in the toolset, and I can't find it as a standalone program.

Also, does anyone know how to find the name of a script attached to a certain spell? It doesn't seem to be listed under spells.2da.

Modifié par Kesaru, 09 juin 2011 - 05:50 .


#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
From the file menu, click 'open conversation/script'. The spell scripts are usually prefixed with an s.

#3
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Also, if you go to File -> New -> Script, it will open the script editor with a blank page ready for your custom code to be written.

#4
MasterChanger

MasterChanger
  • Members
  • 686 messages

Kesaru wrote...
Also, does anyone know how to find the name of a script attached to a certain spell? It doesn't seem to be listed under spells.2da.


Yup, it is in spells.2da. Look for a column called ImpactScript.

#5
Kesaru

Kesaru
  • Members
  • 130 messages
Ah, thank you. That was everything I needed to know.

#6
Kesaru

Kesaru
  • Members
  • 130 messages
I have one more question now. I altered the Telthor Companion given by Kaedrin's PrC Pack to be Fey type rather than Monstrous, and I'm now attempting to alter the Nature's Avatar spell to affect Fey as well as animals, but it doesn't seem to be working. Here's the script I'm altering, nw_s0_natavatar.nss:
//::///////////////////////////////////////////////
//:: Nature's Avatar
//:: nw_s0_natavatar.nss
//:: Copyright © 2006 Obsidian Entertainment
//:://////////////////////////////////////////////
/*
    With a touch, you gift your animal ally with nature's strength, resilience
    and speed. 
   
    The affected animal gains a +10 bonus on attack and damage rolls, and 1d8
    temporary hit points per caster level, plus the effect of the haste spell.
*/
//:://////////////////////////////////////////////
//:: Created By: Patrick Mills
//:: Created On: Oct 17, 2006
//:://////////////////////////////////////////////


#include "nw_i0_spells"
#include "x2_inc_spellhook"
#include "nwn2_inc_metmag"


void main()
{
    /*
      Spellcast Hook Code
      Added 2003-07-07 by Georg Zoeller
      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

//Major variables
    object     oTarget     =     GetSpellTargetObject();
    object     oCaster     =     OBJECT_SELF;
    effect     eHaste         =     EffectHaste();
    effect     eVis         =     EffectVisualEffect(VFX_SPELL_DUR_NATURE_AVATAR);
    effect     eAttack     =    EffectAttackIncrease(10);
    effect    eDamage        =    EffectDamageIncrease(DAMAGE_BONUS_10, DAMAGE_TYPE_SLASHING);
    effect    eBonusHP;
    effect     eLink;
    int        nHP            =    d8() * GetCasterLevel(oCaster);
    float    fDuration    =    RoundsToSeconds(GetCasterLevel(oCaster));

//None of the following meta-magic behaviors can be used in base NWN2, the checks only exist to support epic levels
//should they be added later.
//Determine duration
    ApplyMetamagicDurationMods(fDuration);
   

//Determine HP Bonus
            nHP            =    ApplyMetamagicVariableMods(nHP, 160);
            eBonusHP    =    EffectTemporaryHitpoints(nHP);
   
//Link up effects
            eLink    =    EffectLinkEffects(eHaste,eAttack);
            eLink    =    EffectLinkEffects(eLink,eVis);
            eLink    =    EffectLinkEffects(eLink,eDamage);
            //eLink    =    EffectLinkEffects(eLink,eBonusHP);

            effect eOnDispell = EffectOnDispel(0.0f, RemoveEffectsFromSpell(oTarget, SPELL_NATURE_AVATAR));
            eLink = EffectLinkEffects(eLink, eOnDispell);
            eBonusHP = EffectLinkEffects(eBonusHP, eOnDispell);

//Validate target and apply effects
    if (GetIsObjectValid(oTarget))
    {
        if (spellsIsTarget(oTarget, SPELL_TARGET_ALLALLIES, oCaster))
        {
            if ((GetRacialType(oTarget) == RACIAL_TYPE_ANIMAL
                || GetRacialType(oTarget) == RACIAL_TYPE_BEAST
                || GetRacialType(oTarget) == RACIAL_TYPE_VERMIN
                || GetRacialType(oTarget) == RACIAL_TYPE_FEY)
                //&& !GetHasEffect(EFFECT_TYPE_WILDSHAPE, oTarget))
                && !GetHasEffect(EFFECT_TYPE_POLYMORPH, oTarget))
            {
                RemoveEffectsFromSpell(oTarget, GetSpellId());
                ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBonusHP, oTarget, fDuration);
                ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, fDuration);
            }
            else
            {
                FloatingTextStrRefOnCreature(184683, oCaster, FALSE);
                return;
            }
        }
    }
}

Now all I've done is add in the line || GetRacialType(oTarget) == RACIAL_TYPE_FEY). The Telthor companion does indeed have both the race and class of Fey when I examine it in-game, but I still get the "Target is immune to this effect" message when I try casting Nature's Avatar on it.
If it matters, I am also getting the strange compile result message "ginc_crafting.nss: ERROR: DUPLICATE FUNCTION IMPLEMENTATION Search2DA", even though it saves properly.
Also, I've placed the script in with the rest of the scripts for Kaedrin's PrC Pack in my Override folder.

Modifié par Kesaru, 09 juin 2011 - 07:53 .


#7
MasterChanger

MasterChanger
  • Members
  • 686 messages
I'm not at my toolset right now, so I'll offer you my first thought: it's possible that RACIAL_TYPE_FEY and the race of the companion in game don't technically match up. Here's how to check:

Open up a script and look at your Script Assist (the helpful searchable directory on the right of your script window). Click over to the "constants" tab and search for RACIAL_TYPE_FEY. When you click on that, the definition should pop up on the bottom of your screen, something like
const int RACIAL_TYPE_FEY = <some positive integer>
. Now open up racialtypes.2da and check the line with the same number as the definition of RACIAL_TYPE_FEY. What does that line in the 2da say? If it is indeed Fey, this isn't your problem.

Even if this doesn't help resolve your problem, it can be helpful to see the magic behind the curtain of how those constants are defined and what their implication is. The constants are just stand-ins for numerical values; they are defined in nwscript.nss the same way you could define a constant or function in any include file. (For more about #includes, read _Knightmare_'s wonderful scripting tutorial linked up-thread).

#8
Kesaru

Kesaru
  • Members
  • 130 messages
I did what you said, and the Constant column for it does indeed say RACIAL_TYPE_FEY. I'll see if the issue may be with the companion rather than the script by casting it on Okku.
-Edit- Just checked. It doesn't work on Okku either.

Modifié par Kesaru, 09 juin 2011 - 08:35 .


#9
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I suspect you are not compiling the script since it would throw an error with the extra ) on the line you added. Remove the ) from your line and save and compile your script.

Regards

#10
Kesaru

Kesaru
  • Members
  • 130 messages
The original script had that bracket over the VERMIN line just before it. I tested what you said though, and it still doesn't work on Fey. It does work on normal animals though in each case.

I think I've realized what's wrong now, though. When I compiled the script I got only a single .NSS file, no .NCS. My changes aren't even getting applied in-game because of that.

-Edit- I installed the Advanced Script Compiler Plugin, and I now get this, more detailed error message when I compile:
Error: ginc_crafting.nss(594): Error: Function "Search2DA" already has a body defined
Error: Compilation aborted with errors.


But I have absolutely no idea what it's referring to.

Modifié par Kesaru, 09 juin 2011 - 09:46 .


#11
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
The error means that the Search2DA function is defined twice in the script. Once in ginc_crafting and also somewhere else. The include files in the script must be including other files. If you have files in the override folder than you are using any include files in there as well. There is an incompatibility somewhere.

Regards

#12
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I was mistaken about the ). Sorry about that. Your edit didn't show that it had been on the prior line and I miscounted.

If you first empty your override folder and then modify the script in a new module it should compile cleanly. Something in your override or your campaign folder or your module is interfering. I was able to compile it with an empty override and with Kaedrin's 141.1 content installed with no error.

#13
Kesaru

Kesaru
  • Members
  • 130 messages
Awesome, that fixed it. Thanks.

#14
Kesaru

Kesaru
  • Members
  • 130 messages
I'm working on a new script now to try adding a new feat to Spirit Shamans which lets you use a charge of Chastise Spirits to try striking a single undead or spirit target dead instantly, and I'm having issues with it. I'm getting a very specific error message, but when I look at what it refers to I see absolutely nothing wrong.
Here's the message:
Error: script1.nss(57): Error: Syntax error at "{"

And here's the script, I'll mark line 57 in red:

//::///////////////////////////////////////////////
//:: Exorcism
//:: nx_S2_SHExorcism
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
// You can expnd a daily use of Chastise Spirits
// to banish a single spirit or force the spirit
// from a target hostile undead, destroying them
// instantly unless they pass a will save.
// A successful save will still deal full
// Chastise Spirits damage to the target.
*/
//:://////////////////////////////////////////////
//:: Created By: Noel Borstad
//:: Created On: Oct 17, 2000
//:://////////////////////////////////////////////
//:: Updated By: Georg Z, On: Aug 21, 2003 - no longer affects placeables
// BMA-OEI 11/9/06: Allow casting on neutral creatures

#include "nwn2_inc_spells"   
#include "x0_I0_SPELLS"
#include "x2_inc_spellhook"

void main()
{

/*
  Spellcast Hook Code
  Added 2003-06-23 by GeorgZ
  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


    //Declare major variables
    object oTarget = GetSpellTargetObject();
    int nShamanLvl = GetLevelByclass(class_TYPE_SPIRIT_SHAMAN, OBJECT_SELF);
    int nDamage;
    effect eDam;
    effect eVis = EffectVisualEffect(VFX_HIT_CHASTISE_SPIRITS);

    // BMA-OEI 11/9/06: Allow casting on neutral creatures
    //if(spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE,OBJECT_SELF))
    if(spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE,OBJECT_SELF) &&
           (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD
        ||GetIsSpirit(oTarget))
    {
        //GZ: I still signal this event for scripting purposes, even if a placeable
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId));
        if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
        {

            //Make Will save
            if (!MySavingThrow(SAVING_THROW_WILL, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_DIVINE))
            {
                //Apply the death effect and VFX impact
                ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oTarget);
                //ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
            }
            else
            {
                //Roll damage
                nDamage = d6(nShamanLvl);
                //Set damage effect
                eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
                //Apply damage effect and VFX impact
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
                //ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
            }
           
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);        // play the impact effect regardless of save
        }
    }
   
    DecrementRemainingFeatUses(OBJECT_SELF, FEAT_CHASTISE_SPIRITS);
}

Anyone know what's going wrong?

#15
The Fred

The Fred
  • Members
  • 2 516 messages
Looks like you're missing a close bracket, ).

#16
The Fred

The Fred
  • Members
  • 2 516 messages
It helps (to see what's going on) if you write it this way:
if(spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE,OBJECT_SELF) &&
    ( GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD || GetIsSpirit(oTarget) [b])[/b]
  )
EDIT: Tried to put colours on it, but it took them off again.

Modifié par The Fred, 10 juin 2011 - 07:12 .


#17
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I couldn't get the script to compile either. What custom content do you have installed in your module, campaign, or override?

#18
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
What the Fred said.:)

if(spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE,OBJECT_SELF) &&
           (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD
        ||GetIsSpirit(oTarget)))

#19
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
try this

( lot of typos, and getspellid had no parenthesis, copy paste from the script assist the functions and constants to make things work )

//::///////////////////////////////////////////////
//:: Exorcism
//:: nx_S2_SHExorcism
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
// You can expnd a daily use of Chastise Spirits
// to banish a single spirit or force the spirit
// from a target hostile undead, destroying them
// instantly unless they pass a will save.
// A successful save will still deal full
// Chastise Spirits damage to the target.
*/
//:://////////////////////////////////////////////
//:: Created By: Noel Borstad
//:: Created On: Oct 17, 2000
//:://////////////////////////////////////////////
//:: Updated By: Georg Z, On: Aug 21, 2003 - no longer affects placeables
// BMA-OEI 11/9/06: Allow casting on neutral creatures

#include "nwn2_inc_spells"    
#include "x0_I0_SPELLS"
#include "x2_inc_spellhook"

void main()
{

/*
  Spellcast Hook Code
  Added 2003-06-23 by GeorgZ
  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


    //Declare major variables
    object oTarget = GetSpellTargetObject();
    int nShamanLvl = GetLevelByclass(class_TYPE_SPIRIT_SHAMAN, OBJECT_SELF);
    int nDamage;
    effect eDam;
    effect eVis = EffectVisualEffect(VFX_HIT_CHASTISE_SPIRITS);

    // BMA-OEI 11/9/06: Allow casting on neutral creatures
    //if(spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE,OBJECT_SELF))
    if(spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE,OBJECT_SELF) &&
           (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD
        ||GetIsSpirit(oTarget)) )
    {
        //GZ: I still signal this event for scripting purposes, even if a placeable
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId() ));
        if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
        {

            //Make Will save
            if (!MySavingThrow(SAVING_THROW_WILL, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_DIVINE))
            {
                //Apply the death effect and VFX impact
                ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oTarget);
                //ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
            }
            else
            {
                //Roll damage
                nDamage = d6(nShamanLvl);
                //Set damage effect
                eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
                //Apply damage effect and VFX impact
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
                //ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
            }
            
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);        // play the impact effect regardless of save
        }
    }
    
    DecrementRemainingFeatUses(OBJECT_SELF, FEAT_CHASTISE_SPIRITS);
}



#20
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
The forum will change any instances of capitalized class to lower case. C is case sensitive, so you will need to change them back.

Regards

#21
Kesaru

Kesaru
  • Members
  • 130 messages
Awesome, thanks everyone. I  used the script painofdungeoneternal posted and it seems to work perfectly, except for one thing. I was hoping the save DC would use Spirit Shaman level and Charisma modifier, but it doesn't seem to be, and when looking at the Chastise Spirits script I can't make out what is being done differently. Neither seem to actually define anything specific in that area.
When I try just copying that line over from the Chastise Spirits script I get an error on pretty much every section:
            if (!MySavingThrow(WillSave(oTarget, nSaveDC)))

Error: script1.nss(64): Error: Undeclared identifier "nSaveDC"
Error: script1.nss(64): Error: Required argument missing in call to "WillSave"
Error: script1.nss(64): Error: Required argument missing in call to "MySavingThrow"

I also tried:
            nSaveResult = WillSave(oTarget, nSaveDC);
            if (nSaveResult == SAVING_THROW_CHECK_FAILED

And got:
Error: script1.nss(64): Error: Undeclared identifier "nSaveResult"
Error: script1.nss(64): Error: Undeclared identifier "nSaveDC"
Error: script1.nss(64): Error: Required argument missing in call to "WillSave"
Error: script1.nss(65): Error: Undeclared identifier "nSaveResult"

Modifié par Kesaru, 11 juin 2011 - 05:54 .


#22
MasterChanger

MasterChanger
  • Members
  • 686 messages

Kesaru wrote...

Awesome, thanks everyone. I  used the script painofdungeoneternal posted and it seems to work perfectly, except for one thing. I was hoping the save DC would use Spirit Shaman level and Charisma modifier, but it doesn't seem to be, and when looking at the Chastise Spirits script I can't make out what is being done differently. Neither seem to actually define anything specific in that area.
When I try just copying that line over from the Chastise Spirits script I get an error on pretty much every section:
            if (!MySavingThrow(WillSave(oTarget, nSaveDC)))

Error: script1.nss(64): Error: Undeclared identifier "nSaveDC"
Error: script1.nss(64): Error: Required argument missing in call to "WillSave"
Error: script1.nss(64): Error: Required argument missing in call to "MySavingThrow"

I also tried:
            nSaveResult = WillSave(oTarget, nSaveDC);
            if (nSaveResult == SAVING_THROW_CHECK_FAILED

And got:
Error: script1.nss(64): Error: Undeclared identifier "nSaveResult"
Error: script1.nss(64): Error: Undeclared identifier "nSaveDC"
Error: script1.nss(64): Error: Required argument missing in call to "WillSave"
Error: script1.nss(65): Error: Undeclared identifier "nSaveResult"


Seems like you didn't bring over the lines that defined nSaveDC and didn't define it yourself. If you like you can define the DC by hand (retrieve the charisma modifier, etc.) or use the handy HkGetSpellSaveDC function from the CSL.

#23
Kesaru

Kesaru
  • Members
  • 130 messages
That worked as well, thanks.