Author Topic: Spell (Potion)  (Read 632 times)

Legacy_mornnova

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Spell (Potion)
« on: March 27, 2016, 04:18:31 pm »


               

hello


 


i can't figure out how to get the potion to give the effects of the spell instantly without the player casting.


 


Anyone able to help?


 


void PotionofClarityExtended()

{

object oPC;


if (!GetIsPC(GetItemActivatedTarget())

){


return;}


oPC = GetItemActivator();


object oCaster;

oCaster = oPC;


object oTarget;

oTarget = oPC;


AssignCommand(oCaster, ActionCastSpellAtObject(SPELL_CLARITY, oTarget, METAMAGIC_EXTEND, TRUE, 9, PROJECTILE_PATH_TYPE_DEFAULT, FALSE));


}



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Spell (Potion)
« Reply #1 on: March 27, 2016, 07:27:14 pm »


               

I you look at the actual script called when the spell is cast, you will see how to implement what you want. The impact script is "NW_S0_Clarity.nss" If you look through it the script applies effects with specific duration. Never calling "ActionCastSpellAtObject". The reason you get the spellcasting visuals is because when you use the "ActionCastSpellAtObject", the game defaults to the defined spellcasting algorithm using the spell.2da defined  properties. You only want to implement the impact script.



               
               

               
            

Legacy_mornnova

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Spell (Potion)
« Reply #2 on: March 27, 2016, 08:12:39 pm »


               

thanks!


 


i just added


 


DelayCommand(1.0, ExecuteScript("nw_s0_clarity", oPC));


 


and the potion works now.


 


but how should i edit NW_S0_Clarity so the spell from the potion is extended but otherwise not?



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Spell (Potion)
« Reply #3 on: March 28, 2016, 01:02:19 am »


               

Here is the code for a script to implement the extended clarity. Connect via #include and call the ExtendedClarify(object oPC, int bExtend) function directly. Set bExtend = TRUE if you want the spell extended. look in the code to define the method of defining duration you desire


void ExtendedClarify(object oPC, int bExtend)
{
    object oTarget = oPC;
 
    //Declare major variables
    effect eImm1 = EffectImmunity(IMMUNITY_TYPE_MIND_SPELLS);
    effect eDam = EffectDamage(1, DAMAGE_TYPE_NEGATIVE);
    effect eVis = EffectVisualEffect(VFX_DUR_MIND_AFFECTING_POSITIVE);
    effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
 
    effect eLink = EffectLinkEffects(eImm1, eVis);
    eLink = EffectLinkEffects(eLink, eDur);
 
    effect eSearch = GetFirstEffect(oTarget);
 
 
    /*////////////////////////////////////////
    Begin Define duration here
    Uncomment whichever method you choose.
    Use GetCasterLevel to maintain potion
    casting level
    ////////////////////////////////////////*/
 
    //int nDuration = GetLevelByClass(CLASS_TYPE_WIZARD, oPC);
    int nDuration = GetHitDice(oPC);
    //int nDuration = GetCasterLevel(oPC);
 
    // End Define duration here
 
    //if bExtend == TRUE, extend the duration
    if (bExtend)
    {
        nDuration = nDuration *2; //Duration is +100%
    }
    int bValid;
    int bVisual;
    //Fire cast spell at event for the specified target
    SignalEvent(oTarget, EventSpellCastAt(oPC, SPELL_CLARITY, FALSE));
    //Search through effects
    while(GetIsEffectValid(eSearch))
    {
        bValid = FALSE;
        //Check to see if the effect matches a particular type defined below
        if (GetEffectType(eSearch) == EFFECT_TYPE_DAZED)
        {
            bValid = TRUE;
        }
        else if(GetEffectType(eSearch) == EFFECT_TYPE_CHARMED)
        {
            bValid = TRUE;
        }
        else if(GetEffectType(eSearch) == EFFECT_TYPE_SLEEP)
        {
            bValid = TRUE;
        }
        else if(GetEffectType(eSearch) == EFFECT_TYPE_CONFUSED)
        {
            bValid = TRUE;
        }
        else if(GetEffectType(eSearch) == EFFECT_TYPE_STUNNED)
        {
            bValid = TRUE;
        }
        //Apply damage and remove effect if the effect is a match
        if (bValid == TRUE)
        {
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
            RemoveEffect(oTarget, eSearch);
            bVisual = TRUE;
        }
        eSearch = GetNextEffect(oTarget);
    }
    float fTime = 30.0  + RoundsToSeconds(nDuration);
    //After effects are removed we apply the immunity to mind spells to the target
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, fTime);
}

               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Spell (Potion)
« Reply #4 on: March 28, 2016, 01:03:01 am »


               

    //add a check to see if it was cast from a potion, if so, double its duration
    if (nMetaMagic == METAMAGIC_EXTEND || GetSpellCastItem() == BASE_ITEM_POTIONS )
    {
        nDuration = nDuration *2; //Duration is +100%
    }

               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Spell (Potion)
« Reply #5 on: March 28, 2016, 01:42:40 am »


               

@Terrorble: You'll want GetBaseItemType(GetSpellCastItem()) probably.



               
               

               
            

Legacy_mornnova

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Spell (Potion)
« Reply #6 on: March 28, 2016, 03:26:43 am »


               

thanks everyone.


 


i tested both a regular clarity potion and the extended potion using a lvl 10 paladin (not sure if the class/lvl makes a difference) the non extended clarity effect lasted 48 seconds, the extended pot had a duration of 30 seconds...


 


here are the two scripts


 


#include "pw_mod_inc"


void main()

{

   ExtendedClarity();

}


 


 


 


void ExtendedClarity()

{

    object oPC;


    if (!GetIsPC(GetItemActivatedTarget()))

    {


    return;

    }


    oPC = GetItemActivator();


    object oCaster;

    oCaster = oPC;


    object oTarget;

    oTarget = oPC;



    //Declare major variables

    effect eImm1 = EffectImmunity(IMMUNITY_TYPE_MIND_SPELLS);

    effect eDam = EffectDamage(1, DAMAGE_TYPE_NEGATIVE);

    effect eVis = EffectVisualEffect(VFX_DUR_MIND_AFFECTING_POSITIVE);

    effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);


    effect eLink = EffectLinkEffects(eImm1, eVis);

    eLink = EffectLinkEffects(eLink, eDur);


    effect eSearch = GetFirstEffect(oTarget);



    /*////////////////////////////////////////

    Begin Define duration here

    Uncomment whichever method you choose.

    Use GetCasterLevel to maintain potion

    casting level

    ////////////////////////////////////////*/


    //int nDuration = GetLevelByClass(CLASS_TYPE_WIZARD, oPC);

    //int nDuration = GetHitDice(oPC);

    int nDuration = GetCasterLevel(OBJECT_SELF);


    // End Define duration here


    int nMetaMagic = GetMetaMagicFeat();

    //Enter Metamagic conditions

    if (nMetaMagic == METAMAGIC_EXTEND || GetBaseItemType(GetSpellCastItem()) == BASE_ITEM_POTIONS)

    {

        nDuration = nDuration *2; //Duration is +100%

    }


    /*if (nMetaMagic == METAMAGIC_EXTEND)

    {

        nDuration = nDuration *2; //Duration is +100%

    }*/

    int bValid;

    int bVisual;

    //Fire cast spell at event for the specified target

    SignalEvent(oTarget, EventSpellCastAt(oPC, SPELL_CLARITY, FALSE));

    //Search through effects

    while(GetIsEffectValid(eSearch))

    {

        bValid = FALSE;

        //Check to see if the effect matches a particular type defined below

        if (GetEffectType(eSearch) == EFFECT_TYPE_DAZED)

        {

            bValid = TRUE;

        }

        else if(GetEffectType(eSearch) == EFFECT_TYPE_CHARMED)

        {

            bValid = TRUE;

        }

        else if(GetEffectType(eSearch) == EFFECT_TYPE_SLEEP)

        {

            bValid = TRUE;

        }

        else if(GetEffectType(eSearch) == EFFECT_TYPE_CONFUSED)

        {

            bValid = TRUE;

        }

        else if(GetEffectType(eSearch) == EFFECT_TYPE_STUNNED)

        {

            bValid = TRUE;

        }

        //Apply damage and remove effect if the effect is a match

        if (bValid == TRUE)

        {

            ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);

            RemoveEffect(oTarget, eSearch);

            bVisual = TRUE;

        }

        eSearch = GetNextEffect(oTarget);

    }

    float fTime = 30.0  + RoundsToSeconds(nDuration);

    //After effects are removed we apply the immunity to mind spells to the target

    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, fTime);

}


 


i am missing bExtend = TRUE. i didn't understand that part, sorry.



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Spell (Potion)
« Reply #7 on: March 28, 2016, 03:56:07 am »


               

Sorry bout that but I set the get caster level to OBJECT_SELF.... fixed it by edit in the post above. Try copy past again.


 


Question:  Do you want the duration set to the level of the user or the potion? If the potion, leave as fixed above. If the level of the user, uncomment 


 


int nDuration = GetHitDice(oPC);


 


and comment out


 


int nDuration = GetCasterLevel(oPC)


 


To get an extended effect call the function in this manner


 


ExtendedClarify(oPC, TRUE);.


 


Be sure to define oPC.



               
               

               
            

Legacy_mornnova

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Spell (Potion)
« Reply #8 on: March 28, 2016, 04:31:30 am »


               

ok, switched duration from potion to user.


 


but now when i try to compile this...


 


#include "pw_mod_inc"


void main()

{


   ExtendedClarity(oPC, TRUE);

}


 


it doesn't compile and says "variable defined without type"


 


so bExtend = TRUE isn't working, right?


               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Spell (Potion)
« Reply #9 on: March 28, 2016, 04:51:59 am »


               

Ok, I re-edited my post above to set to User for you.


Compiles.


 


Now place an include in whatever script you use to call the function.



#include"The name you gave the script above"

Then place the following code in the script



    object oPC = GetItemActivator();
    ExtendedClarify(oPC, TRUE);

 

This assumes you are using an on activate event script or tag based script.


               
               

               
            

Legacy_mornnova

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Spell (Potion)
« Reply #10 on: March 28, 2016, 05:42:23 am »


               

yup, i am using tag based.


 


2 min 30 seconds with the extended pot, at caster lvl 10. its working!


 


i get the feeling you made errors intentionally, so i could try to puzzle it out. now i just might be able to figure out how to make extended aid/bless potions on my own. ty


 


have a good one.



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Spell (Potion)
« Reply #11 on: March 28, 2016, 05:51:56 am »


               

That's good news.


 


When your ready, post and you can see how to "hook' your spell scripts..... '<img'>



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Spell (Potion)
« Reply #12 on: March 28, 2016, 11:06:04 am »


               

solution using Community Patch 1.71:


 


add variable on potion ITEM_METAMAGIC_OVERRIDE int 2


 


and thats it



               
               

               
            

Legacy_mornnova

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Spell (Potion)
« Reply #13 on: March 28, 2016, 02:07:34 pm »


               

ah ok, thanks. i have 1.71 installed, guess i should have read the documentation more closely. i learned a bit from this thread though and decided to keep the script tied to this potion so this wasn't all for nothing. making what i need next will be a lot easier now though.