Aller au contenu

Photo

Blood Link - revisited


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

#1
Retpircs Wols

Retpircs Wols
  • Members
  • 18 messages
Greetings,

I have dusted off an old spell from a NWN (the original) mod that I made called Blood Link, which creates an effect between the caster and target until one or the other dies (damages the target and heals the caster).  I wanted to sexy it up a little, so I tried to throw in an effect based on how many cycles the spell has run.  It does not work (neither does the VFX - it is still the NWN code - am taking suggestions on a NWN 2 one).

The script has to replace any normal spell (I replaced the Warlock's Eldritch Blast) so that the caster is ObjectSelf and not ItemActivator (I think)

The effects are just temporary, chosen for obviousness when they
go into effect.  The point is to get it to run something different the
4th or 8th time the spell fires (will probably be a temp CON bonus or something else that lines up with the Blood Link concept.

Could anyone tell me why the if at line 62 and 74 is not working properly?  Much apreciated!


//Bloodlink (LV 1) created by Retpircs Wols
//form and function borrowed from NWN Acid Arrow script.
#include "NW_I0_SPELLS"
#include "x2_inc_spellhook"


//declare variables
object oTarget = GetSpellTargetObject();
effect eEffect;
object oCaster = OBJECT_SELF;
int nRun = 1;


void RunLink(object oTarget, object oCaster);
//main spell body


void main()
{
//define variables
// do once without delay
eEffect = EffectDamage(2, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_ENERGY);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget);
eEffect = EffectHeal(2);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oCaster, 1.0f);

//visual effect of evilness
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_DEMON_HAND), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_DEMON_HAND), GetLocation(oTarget));

//call recurring link
DelayCommand(3.0f,RunLink(oTarget, oCaster));
}

//do until enmy is dead, with 5 second delay
void RunLink(object oTarget, object oCaster)
{
//variables

effect eEffect;
int nChar = GetAbilityModifier(ABILITY_CHARISMA, oCaster);  //get char modifier
int nLevel = (GetCasterLevel(oCaster)/2);                        //get caster level
int nDC = nLevel + nChar + 8;                                        //Baddie has to overcome lvl/2 + char mod
int Save = WillSave(oTarget, nDC, SAVING_THROW_TYPE_MIND_SPELLS, oCaster);       
       

if (GetIsDead(oTarget) == FALSE) //ends loop if target is dead
    {
        if (GetIsDead(oCaster) == FALSE) //ends loop if Caster is dead
           {
            if (WillSave(oTarget, nDC, SAVING_THROW_TYPE_NONE) == 0)
            {
                   //hurt enemy
                   eEffect = EffectDamage(2, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_ENERGY);
                   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget);
                   //heal PC
                   eEffect = EffectHeal(2);
                   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oCaster, 1.0f);

                   if (nRun = 4)
                   {
                 
                 //increase attack
eEffect = EffectAttackIncrease(nChar);

eEffect = ExtraordinaryEffect(eEffect);

ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect,  oCaster);

                   }//end run 4
                  
                    if (nRun = 8)
                   {
                 
//imune to knockdown
eEffect = EffectImmunity(IMMUNITY_TYPE_KNOCKDOWN);

eEffect = ExtraordinaryEffect(eEffect);

ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oCaster);

                   }//end run 8
                  
            }// end willsave if     
           } //end of PC dead if
    } //end of target dead if

   
nRun = nRun + 1;
//play it again, Sam
DelayCommand(3.0f,RunLink(oTarget, oCaster));
//end of script
}

#2
kevL

kevL
  • Members
  • 4 074 messages
Retp Retp Retp .....

- compare the sytax of these two lines:

if (GetIsDead(oTarget) == FALSE)
//
if (nRun = 4)


head <-> keyboard (?)

#3
Morbane

Morbane
  • Members
  • 1 883 messages
Slow Scripter<>Retpircs Wols

You are going all over the place - try getting one thing at a time working - then build on it

Start simple; maybe get the vfx working at the right times - then the spell effects - or viceversa

#4
Retpircs Wols

Retpircs Wols
  • Members
  • 18 messages
Morbane,

You are right. Watching me work is painful. The VFX are just eye candy, though...

KevL

Not sure why I did not think of that... I am a little slow (as Morbane pointed out). So, maybe something more along the lines of

if ((nRun = 4) == FALSE)

I also tried

if ((nRun = 8) == TRUE)

because I think TRUE should be right, but it does not work either way. STILL not sure what I am doing (maybe it is because I hit the keyboard too hard with my head).

Modifié par Retpircs Wols, 12 avril 2012 - 11:33 .


#5
kevL

kevL
  • Members
  • 4 074 messages
if (nRun == 4)


- think "is equivalent to" ( not "set to" )

#6
kamal_

kamal_
  • Members
  • 5 259 messages
What kevL says is correct, using the single = you will be setting the variable to that number (4 or 8). The correct way to do it is what kevL just posted:
If (variable==x)
{// do stuff}

#7
kevL

kevL
  • Members
  • 4 074 messages
btw Retp,

what you think about / == TRUE / is correct. In fact it's so true that / == TRUE / doesn't even have to be included in the parentheses. it's a given-for-granted:

if (TRUE)
{
// this will always run
}
// but ..
if (FALSE)
{
// this will never run
}

The condition inside the parentheses must evaluate to TRUE for the 'scope' to run. Another way to look at this :

if (TRUE == TRUE)
{
// this will always run
}
// but ..
if (FALSE == TRUE)
{
// this will never run
}





bonus pts. Let's change up the line

if (GetIsDead(oTarget) == FALSE)

for the fun of it. What follows should all be valid TRUE conditions :

if (GetIsDead(oTarget) != TRUE) { // if alive, will run }

if (!GetIsDead(oTarget)) { // if alive, will run }

Because they all test against TRUE ( even though it's a !FALSE statement )


ps. my head is very familiar w/ keyboard too

#8
MasterChanger

MasterChanger
  • Members
  • 686 messages
I'm going to pick out a different line (that isn't even in the code at all) to question your assumptions on:

Retpircs Wols wrote...
The script has to replace any normal spell (I replaced the Warlock's Eldritch Blast) so that the caster is ObjectSelf and not ItemActivator (I think)


Why does it have to replace a spell? The only reason would seem to be that you want to be able to override a script without overriding spells.2da, maybe to ensure better compatibility with other custom content. You're really going to find yourself limited in what you can do, though, if you're not overriding any 2da's.

You really can just make it a new spell (new line in spells.2da). That kind of thing is done all the time by scripters.

#9
Retpircs Wols

Retpircs Wols
  • Members
  • 18 messages
Gents,

I greatly apreciate your help. I will be back at my own computer fairly soon to try it out. I have been doing this for years and never really understanding what I was typing (though I pulled up some of my other scripts and saw that I was not even emulating past successes here). The compiler in my head says that that should work.

MasterChanger - when I really thought about it, ObjectSelf would work with an unique item too... though one step up, creating your own spell via the 2das is something I have not played with yet. As you say, it is the correct way to do it. Perhaps something I will look into next.

#10
MasterChanger

MasterChanger
  • Members
  • 686 messages

Retpircs Wols wrote...

Gents,

I greatly apreciate your help. I will be back at my own computer fairly soon to try it out. I have been doing this for years and never really understanding what I was typing (though I pulled up some of my other scripts and saw that I was not even emulating past successes here). The compiler in my head says that that should work.

MasterChanger - when I really thought about it, ObjectSelf would work with an unique item too... though one step up, creating your own spell via the 2das is something I have not played with yet. As you say, it is the correct way to do it. Perhaps something I will look into next.


In the case of a unique item script (a tag-based script) OBJECT_SELF probably would be the item itself rather than the PC. That's all right because you do not need access to OBJECT_SELF to get the player-character.

If a PC activates an item, then in that item's OnActivate script you can retrieve the PC using GetItemActivator(). There's a similar function to retrieve the item itself.

Pain used to have a list of a bunch of event scripts and how you would retrieve the PC within those scripts. The list was on the Citadel, which is currently out of commission. Maybe he can repost the list somewhere.

#11
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Actually was asking DNO for access to that data, got a few topics like that, the NWNx configuration ones and bitwise math which unless i get ahold of them, they are not going to be recreated - just too much work involved. If i can get the data my aim is to put it into the csl reference ( and that is something that can be put into a CHM reference or the like )

If i could get ahold of it in it's entirely, i could probably create a compilation organized by topic, something i wanted to do with the citadel itself as that was always an issue of finding stuff. Far too much valuable info there which is no longer available, major loss for the community equal to the loss of the bioware forums.

#12
kevL

kevL
  • Members
  • 4 074 messages

MasterChanger wrote...

In the case of a unique item script (a tag-based script) OBJECT_SELF probably would be the item itself rather than the PC. That's all right because you do not need access to OBJECT_SELF to get the player-character.

heads up, last time i tried to get OBJECT_SELF on a tag-based script it returned nada - no name, no tag ...



If a PC activates an item, then in that item's OnActivate script you can retrieve the PC using GetItemActivator(). There's a similar function to retrieve the item itself.

this



Pain used to have a list of a bunch of event scripts and how you would retrieve the PC within those scripts. The list was on the Citadel, which is currently out of commission. Maybe he can repost the list somewhere.

ack ! ( Pain's posts on bitwise are like translations from the original Greek ;)

Modifié par kevL, 13 avril 2012 - 12:46 .