Blood Link - revisited
#1
Posté 12 avril 2012 - 03:35
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
Posté 12 avril 2012 - 05:11
- compare the sytax of these two lines:
if (GetIsDead(oTarget) == FALSE) // if (nRun = 4)
head <-> keyboard (?)
#3
Posté 12 avril 2012 - 07:47
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
Posté 12 avril 2012 - 10:54
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
Posté 12 avril 2012 - 12:49
if (nRun == 4)
- think "is equivalent to"
#6
Posté 12 avril 2012 - 12:58
If (variable==x)
{// do stuff}
#7
Posté 12 avril 2012 - 02:40
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 (
ps. my head is very familiar w/ keyboard too
#8
Posté 12 avril 2012 - 05:07
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
Posté 12 avril 2012 - 07:14
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
Posté 12 avril 2012 - 09:28
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
Posté 12 avril 2012 - 09:42
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
Posté 13 avril 2012 - 12:37
heads up, last time i tried to get OBJECT_SELF on a tag-based script it returned nada - no name, no tag ...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.
thisIf 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.
ack ! ( Pain's posts on bitwise are like translations from the original GreekPain 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.
Modifié par kevL, 13 avril 2012 - 12:46 .





Retour en haut






