Skip to content

Hopelessly Stuck

I'm sure I'm in the ballpark on this one, but am having a time of it.
I'm just trying to have the PC cast color spray on a loom placeable and an effect will occur, otherwise you'll get some floaty text...
object oObject;
void main()
{
   int nSpell = GetLastSpell();
   object oPC = GetLastSpellCaster();

   if (GetIsPC(oPC) && (nSpell == SPELL_COLOR_SPRAY))
   {
     oObject = GetObjectByTag("LOOM_FX");
     effect eFX = EffectVisualEffect(VFX_IMP_GLOBE_USE);
     DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eFX, oObject));
   }
   else
   {
   FloatingTextStringOnCreature("Inadequate Incantation!", oPC);
   }
}

Thing is, it has to be color spray for the effect to work. As is this script wont fire. But (say I replace color spray with dispel magic) it works just fine.???
A nudge in the right direction would be very helpful. As is, I'm pulling my hair out! :)

Comments

  • ReachPWReachPW Member Posts: 27
    edited January 2022
    Do you get "Inadequate Incantation" when you use color spray? Just a thought, but maybe it has something to do with being an AOE spell and not a targeted spell?

    Another option would be to try to modify the color spray nss file. (NW_S0_ColSpray.nss)

    Looking though the code it only really triggers if object is hostile:
        while (GetIsObjectValid(oTarget))
        {
            if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
            {
    // spell stuff
    	 }
            //Get next target in spell area
            oTarget = GetNextObjectInShape(SHAPE_SPELLCONE, 10.0, GetSpellTargetLocation(), TRUE);
    


    Try setting the placeable to 'hostile' and see if that helps. If not, maybe a hack like this would work:

    if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF) || GetTag(oTarget) == "MY_LOOM_TAG")

  • TerrorbleTerrorble Member Posts: 169
    I think what ReachPW said: put the code inside nw_s0_colspray. I didn't test, but this probably works.
        while (GetIsObjectValid(oTarget))
        {
    	   if ( GetTag(oTarget) == "LOOM_FX" && GetIsPC(OBJECT_SELF) )
    	   {
    	     effect eFX = EffectVisualEffect(VFX_IMP_GLOBE_USE);
    	     DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eFX, oObject));
    	   }
    	   else
    	   {
    	   FloatingTextStringOnCreature("Inadequate Incantation!", oPC);
    	   }        
    
    	if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
            {
                //Fire cast spell at event for the specified target
                SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_COLOR_SPRAY));
                fDelay = GetDistanceBetween(OBJECT_SELF, oTarget)/30;
                if(!MyResistSpell(OBJECT_SELF, oTarget, fDelay) && oTarget != OBJECT_SELF)
                {
                    if(!MySavingThrow(SAVING_THROW_WILL, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_MIND_SPELLS, OBJECT_SELF, fDelay))
                    {
                          nDuration = 3 + d4();
                          //Enter Metamagic conditions
                          if (nMetaMagic == METAMAGIC_MAXIMIZE)
                          {
                             nDuration = 7;//Damage is at max
                          }
                          else if (nMetaMagic == METAMAGIC_EMPOWER)
                          {
                             nDuration = nDuration + (nDuration/2); //Damage/Healing is +50%
                          }
                          else if (nMetaMagic == METAMAGIC_EXTEND)
                          {
                             nDuration = nDuration *2;  //Duration is +100%
                          }
    
                        nHD = GetHitDice(oTarget);
                        if(nHD <= 2)
                        {
                             //Apply the VFX impact and effects
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis1, oTarget));
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink1, oTarget, RoundsToSeconds(nDuration)));
                        }
                        else if(nHD > 2 && nHD < 5)
                        {
                             nDuration = nDuration - 1;
                             //Apply the VFX impact and effects
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis3, oTarget));
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink3, oTarget, RoundsToSeconds(nDuration)));                }
                        else
                        {
                             nDuration = nDuration - 2;
                             //Apply the VFX impact and effects
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget));
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink2, oTarget, RoundsToSeconds(nDuration)));
                        }
                    }
                }
            }
            //Get next target in spell area
            oTarget = GetNextObjectInShape(SHAPE_SPELLCONE, 10.0, GetSpellTargetLocation(), TRUE);
    
  • TerrorbleTerrorble Member Posts: 169
    I see now that there are a couple problems. If you cast any other spell you don't get the "Inadequate Incantation" message. Also, if you use this in the color spray script it'll give you this message for every target that isn't LOOM_FX.

    {
    FloatingTextStringOnCreature("Inadequate Incantation!", oPC);
    }
  • NeverwinterWightsNeverwinterWights Member Posts: 339
    edited January 2022
    The Color Spray spell only targets creatures as is, so you will have to alter the spell to also include placeable objects.

    If you just want to alter the spell and include the Loom information in it then you could do something like the following. It is the original script with the changes to "GetFirstObjectInShape" and "GetNextObjectInShape" to include placeables as well as a few lines to only effect a placeable with the tag "LOOM", but you can change that to whatever tag you are using:
    #include "X0_I0_SPELLS"
    #include "x2_inc_spellhook"
    
    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
        int nMetaMagic = GetMetaMagicFeat();
        int nHD;
        int nDuration;
        float fDelay;
        object oTarget;
        effect eSleep = EffectSleep();
        effect eStun = EffectStunned();
        effect eBlind = EffectBlindness();
        effect eMind = EffectVisualEffect(VFX_DUR_MIND_AFFECTING_NEGATIVE);
        effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
    
        effect eLink1 = EffectLinkEffects(eSleep, eMind);
    
        effect eLink2 = EffectLinkEffects(eStun, eMind);
        eLink2 = EffectLinkEffects(eLink2, eDur);
    
        effect eLink3 = EffectLinkEffects(eBlind, eMind);
    
        effect eVis1 = EffectVisualEffect(VFX_IMP_SLEEP);
        effect eVis2 = EffectVisualEffect(VFX_IMP_STUN);
        effect eVis3 = EffectVisualEffect(VFX_IMP_BLIND_DEAF_M);
    
    
        //Get first object in the spell cone
        oTarget = GetFirstObjectInShape(SHAPE_SPELLCONE, 10.0, GetSpellTargetLocation(), TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE);
        //Cycle through the target until the current object is invalid
        while (GetIsObjectValid(oTarget))
        {
            SendMessageToPC(GetFirstPC(), "Object Found In Spray Cone!");//test line
            if (GetObjectType(oTarget) == OBJECT_TYPE_PLACEABLE)
            {
                if (GetTag(oTarget) == "LOOM")
                {
                    effect eFX = EffectVisualEffect(VFX_IMP_GLOBE_USE);
                    DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eFX, oTarget));
                    SendMessageToPC(GetFirstPC(), "Effect should be applied to the loom!");//test line
                }
            }
            else if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
            {
                //Fire cast spell at event for the specified target
                SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_COLOR_SPRAY));
                fDelay = GetDistanceBetween(OBJECT_SELF, oTarget)/30;
                if(!MyResistSpell(OBJECT_SELF, oTarget, fDelay) && oTarget != OBJECT_SELF)
                {
                    if(!MySavingThrow(SAVING_THROW_WILL, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_MIND_SPELLS, OBJECT_SELF, fDelay))
                    {
                          nDuration = 3 + d4();
                          //Enter Metamagic conditions
                          if (nMetaMagic == METAMAGIC_MAXIMIZE)
                          {
                             nDuration = 7;//Damage is at max
                          }
                          else if (nMetaMagic == METAMAGIC_EMPOWER)
                          {
                             nDuration = nDuration + (nDuration/2); //Damage/Healing is +50%
                          }
                          else if (nMetaMagic == METAMAGIC_EXTEND)
                          {
                             nDuration = nDuration *2;  //Duration is +100%
                          }
    
                        nHD = GetHitDice(oTarget);
                        if(nHD <= 2)
                        {
                             //Apply the VFX impact and effects
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis1, oTarget));
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink1, oTarget, RoundsToSeconds(nDuration)));
                        }
                        else if(nHD > 2 && nHD < 5)
                        {
                             nDuration = nDuration - 1;
                             //Apply the VFX impact and effects
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis3, oTarget));
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink3, oTarget, RoundsToSeconds(nDuration)));                }
                        else
                        {
                             nDuration = nDuration - 2;
                             //Apply the VFX impact and effects
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget));
                             DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink2, oTarget, RoundsToSeconds(nDuration)));
                        }
                    }
                }
            }
            //Get next target in spell area
            oTarget = GetNextObjectInShape(SHAPE_SPELLCONE, 10.0, GetSpellTargetLocation(), TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE);
        }
    }
    
Sign In or Register to comment.