Aller au contenu

Photo

feat dependant spell


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

#1
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

I am writing a spell that normally only harms undead but if the character has a feat it can harm elemetals as well.  I can get the script to compile but not work properly in the game. Can someone take a look at it to see why it is not haming either creature?

 

#include "nwn2_inc_spells"
 
 
#include "X0_I0_SPELLS"
#include "x2_inc_spellhook" 
const int SPELL_SPIRIT_LASH = 1647;
 
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
 
 
    //Declare major variables
    object oCaster = OBJECT_SELF;
    int nCasterLvl = GetCasterLevel(oCaster);
    int nDamage;
    float fDelay;
  
    //Get the spell target location as opposed to the spell target.
    location lTarget = GetSpellTargetLocation();
    //Apply the ice storm VFX at the location captured above.
    //Declare the spell shape, size and the location.  Capture the first target object in the shape.
    object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_VAST, lTarget, TRUE, OBJECT_TYPE_CREATURE);
effect eEffect;
    eEffect = EffectKnockdown();
    eEffect = SupernaturalEffect(eEffect);
    effect eDam;
    effect eVis = EffectVisualEffect(VFX_HIT_WEAKEN_SPIRITS);
effect eEff = EffectLinkEffects(eVis, eEffect);
effect eLink;
 
    
while(GetIsObjectValid(oTarget))
{
if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, oCaster))
{
 SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, 1647));
     if ((GetRacialType(oTarget) == RACIAL_TYPE_ELEMENTAL) && (GetHasFeat(2825, oCaster)))
     {
     nDamage = (d4(4)+(2*nCasterLvl));
 ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEff, oTarget, 6.0f);
 eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
 ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis,oCaster);
          DelayCommand(0.01, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEff, oTarget));
     }
 if ((GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD))
     {
     nDamage = (d4(4)+(2*nCasterLvl));
 ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEff, oTarget, 6.0f);
 eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
 ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis,oCaster);
          DelayCommand(0.01, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEff, oTarget));
     }
 else
 {
     nDamage = 1;
 ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEff, oTarget, 6.0f);
 eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
 ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis,oCaster);
          DelayCommand(0.01, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEff, oTarget));
 }
        }
 
     }
       oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_VAST, lTarget, TRUE, OBJECT_TYPE_CREATURE);
    }     


#2
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages
Code typo, you're not applying eDam but you're applying eEff twice. Also you're applying hit visuals to the caster.

#3
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

Code typo, you're not applying eDam but you're applying eEff twice. Also you're applying hit visuals to the caster.

thanks

#4
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

It is still not damaging any opponents, if someone could have another look?

 

#include "nwn2_inc_spells"
 
#include "X0_I0_SPELLS"
#include "x2_inc_spellhook" 
const int SPELL_SPIRIT_LASH = 1647;
 
void main()
{
 
 
    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 oCaster = OBJECT_SELF;
    int nCasterLvl = GetCasterLevel(oCaster);
    int nDamage;
    float fDelay;
  
    //Get the spell target location as opposed to the spell target.
    location lTarget = GetSpellTargetLocation();
    //Apply the ice storm VFX at the location captured above.
    //Declare the spell shape, size and the location.  Capture the first target object in the shape.
    object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_VAST, lTarget, TRUE, OBJECT_TYPE_CREATURE);
effect eEffect;
    eEffect = EffectKnockdown();
    eEffect = SupernaturalEffect(eEffect);
    effect eDam;
    effect eVis = EffectVisualEffect(VFX_HIT_WEAKEN_SPIRITS);
effect eEff = EffectLinkEffects(eVis, eEffect);
effect eLink;
 
    
while(GetIsObjectValid(oTarget))
{
if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, oCaster))
{
 SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, 1647));
     if ((GetRacialType(oTarget) == RACIAL_TYPE_ELEMENTAL) && (GetHasFeat(2825, oCaster)))
     {
     nDamage = (d4(4)+(2*nCasterLvl));
 ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEff, oTarget, 6.0f);
 eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
 ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
     }
 if ((GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD))
     {
     nDamage = (d4(4)+(2*nCasterLvl));
 ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEff, oTarget, 6.0f);
 eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
 ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
     }
 else
 {
     nDamage = 1;
 ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEff, oTarget, 6.0f);
 eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE, FALSE);
 ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
 }
        }
 
     }
       oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_VAST, lTarget, TRUE, OBJECT_TYPE_CREATURE);
    }


#5
Dann-J

Dann-J
  • Members
  • 3 161 messages

It looks like GetNextObjectInShape is outside of the 'while' loop. Try removing the } from above that line and placing it below instead.

 

I like to increase the indent at each bracket level, and annotate the major } characters, to keep track of them in my scripts:

 

while (xxxx)

   {

   if (xxxx)

        {

         Do something

        }

   }// end while



#6
kevL

kevL
  • Members
  • 4 061 messages
clean up. w/ Dj's fix
 
#include "nwn2_inc_spells"
#include "x2_inc_spellhook"


const int SPELL_SPIRIT_LASH = 1647;

void main()
{
    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;
    int nCasterLvl = GetCasterLevel(oCaster);

    effect eVis = EffectVisualEffect(VFX_HIT_WEAKEN_SPIRITS);
    effect eEffect = SupernaturalEffect(EffectKnockdown());
    eEffect = EffectLinkEffects(eVis, eEffect);

    int nDamage;
    effect eDam;

    location lTarget = GetSpellTargetLocation();

    object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_VAST, lTarget, TRUE);
    while (GetIsObjectValid(oTarget))
    {
        if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, oCaster))
        {
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_SPIRIT_LASH));

            if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD
                || (GetRacialType(oTarget) == RACIAL_TYPE_ELEMENTAL && GetHasFeat(2825, oCaster))) // custom Feat, might want nIgnoreUses=TRUE here.
            {
                nDamage = (d4(4) + (2 * nCasterLvl));
            }
            else
            {
                nDamage = 1;
            }

            eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 6.f);
        }

        oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_VAST, lTarget, TRUE);
    }
}

  • Laugh out loud et Psionic-Entity aiment ceci

#7
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

The feat 2825 allows the class to use their spirit lash in order to harm elementals in addition to just undead.  How would I add a line of code to allow another feat to that would allow the spirit lash to harm a different racial group? That is one of the benefits of this new class I am working on.  So far when I am working with the above code to appropriately modify it, it is still only harming just undead and elementals.  Strange thing is it is harming elementals even if the character does not have the 2825 feat.

 

For example the basic feat is spirit lash and it harms undead.  However if the character also has the nature-spirit affinity feat (feat 2825) this will allow their spirit lash to harm elementals and plants with their spirit lash ability as well.  Ancestral-spirit affinity (feat 2827) is yet anther feat available that will allow the characters spirit lash to harm humans and demi-humans.  Lastly the character can also attain animal-spirit affinity (feat 2826) which will allow their spirit lash to harm animals, beasts, magical beasts and vermin.  The character can choose to either attain or not attain any of these other feats but I am still having trouble modifying the script to recognize the correct targets with the correct options.

 

Thank you in advance.



#8
kevL

kevL
  • Members
  • 4 061 messages
sounds like this chunk here needs refining
 
          if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD
                || (GetRacialType(oTarget) == RACIAL_TYPE_ELEMENTAL && GetHasFeat(2825, oCaster))) // custom Feat, might want nIgnoreUses=TRUE here.
            {
                nDamage = (d4(4) + (2 * nCasterLvl));
            }
            else
            {
                nDamage = 1;
            }

          if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD
                || (GetHasFeat(2825, oCaster, TRUE)
                    && (GetRacialType(oTarget) == RACIAL_TYPE_ELEMENTAL
                        || GetSubRace(oTarget) == RACIAL_SUBTYPE_PLANT))
                || (GetHasFeat(2826, oCaster, TRUE)
                    && (GetRacialType(oTarget) == RACIAL_TYPE_ANIMAL
                        || GetRacialType(oTarget) == RACIAL_TYPE_BEAST
                        || GetRacialType(oTarget) == RACIAL_TYPE_MAGICAL_BEAST
                        || GetRacialType(oTarget) == RACIAL_TYPE_VERMIN))
                || (GetHasFeat(2827, oCaster, TRUE)
                    && (GetRacialType(oTarget) == RACIAL_TYPE_HUMAN
                        || GetRacialType(oTarget) == RACIAL_TYPE_DWARF
                        || GetRacialType(oTarget) == RACIAL_TYPE_ELF
                        || GetRacialType(oTarget) == RACIAL_TYPE_GNOME
                        || GetRacialType(oTarget) == RACIAL_TYPE_HALFLING
                        || GetRacialType(oTarget) == RACIAL_TYPE_HALFELF
                        || GetRacialType(oTarget) == RACIAL_TYPE_HALFORC)))
            {
                nDamage = (d4(4) + (2 * nCasterLvl));
            }
            else
                continue;
get the idea? notice i slipped in a GetSubRace() for type_Plant, sometimes it's better to just go with subraces but that'd require testing etc. The demi-humans can ofc be expanded, perhaps with a simple GetIsPlayableRacialType() ... (or perhaps not).

continue; should bypass any others from all effects. Or you could just move application of effects into scope w/ nDamage and remove else{} entirely.

#9
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

Thanks.  I hope this works.