Aller au contenu

Photo

Spell (Potion)


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

#1
mornnova

mornnova
  • Members
  • 16 messages

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));

}



#2
KMdS!

KMdS!
  • Members
  • 189 messages

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.



#3
mornnova

mornnova
  • Members
  • 16 messages

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?



#4
KMdS!

KMdS!
  • Members
  • 189 messages

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);
}


#5
Terrorble

Terrorble
  • Members
  • 194 messages

    //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%
    }


#6
meaglyn

meaglyn
  • Members
  • 807 messages

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


  • Terrorble aime ceci

#7
mornnova

mornnova
  • Members
  • 16 messages

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.



#8
KMdS!

KMdS!
  • Members
  • 189 messages

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.



#9
mornnova

mornnova
  • Members
  • 16 messages

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?



#10
KMdS!

KMdS!
  • Members
  • 189 messages

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.


#11
mornnova

mornnova
  • Members
  • 16 messages

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.



#12
KMdS!

KMdS!
  • Members
  • 189 messages

That's good news.

 

When your ready, post and you can see how to "hook' your spell scripts..... ;)


  • mornnova aime ceci

#13
Shadooow

Shadooow
  • Members
  • 4 468 messages

solution using Community Patch 1.71:

 

add variable on potion ITEM_METAMAGIC_OVERRIDE int 2

 

and thats it


  • Terrorble aime ceci

#14
mornnova

mornnova
  • Members
  • 16 messages

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.