Aller au contenu

Photo

Can't get Tag-Based Scripting to work


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

#1
millenx

millenx
  • Members
  • 13 messages
I have been trying to make an item cast a particular custom spell but haven't been able to get it to work.

What I want is to make a particular wand have a unique power that has a kind of "Ray of Frost" spell-like ability. I wrote the script for the spell and it works fine as a spell, but when I try to use the item nothing happens, and I come here for some help because I checked everything and have yet to make it work.

If I am correct, this is what I need to get tag-based scripting to work:

1) Create the item, give it the "Activate" or "Unique Power" ability (not sure about which one, but neither has worked)

2) Write the corresponding script using the template given by the toolset, and using function GetItemActivator() to    get   PC, GetItemActivated() to get the item being used, and GetItemActivatedTarget() to get the target of the spell.

3) Compile script, name it with the prefix "i_" and the postfix "_ac" ( i_"item_tag"_ac ) and export both the item's blueprint and its respective script into the override folder.

Bear in mind that I am trying to make this work in any module (including OC), and that's why I am just putting both files into the override folder by themselves.

Regardless of what I do, I can't get it to work. I am sure the script works, but I can't still get the item to trigger it, am I missing something? Any help would be greatly appreciated.

#2
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
You compiled the script and copied the NCS version to the override, right? The NSS version isn't executable.

If that isn't it then I suggest you download something that works and compare. I have several tag based items on the vault. I suggest looking at my Teleportation Items.

Regards

#3
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
sounds like a issue with the item not the script, if you never get the menu item to activate item, it's not going to matter about the NCS

Someone more toolset savvy than i can help, but i'd compare your items blueprint to an item which has this setup, or the teleportation item. Then drop this item in override, and use debug commands to give yourself this item. ( it won't update an item if you change it after you get it, what you got is the old items )

#4
millenx

millenx
  • Members
  • 13 messages
The item I used to compare and check what I did wrong was Staff of the Magi, which has a bunch of spells it can cast and also has the nifty ability of expending all charges left into a single "ultimate" ability, being destroyed in the process; still I could not find out why my isn't working.

"If that isn't it then I suggest you download something that works and compare. I have several tag based items on the vault. I suggest looking at my Teleportation Items."

Thanks! I'll take a look and see where I went wrong. I always make sure to put both .NSS and .NCS since I did commit the mistake of not putting the compiled file once before hehe.

#5
millenx

millenx
  • Members
  • 13 messages

Kaldor Silverwand wrote...

You compiled the script and copied the NCS version to the override, right? The NSS version isn't executable.

If that isn't it then I suggest you download something that works and compare. I have several tag based items on the vault. I suggest looking at my Teleportation Items.

Regards


I am still checking your stuff out to figure out what the problem is but just wanted to say KUDOS on the teleportation effect, very impressive :happy:.

#6
millenx

millenx
  • Members
  • 13 messages
ok I am really frustrated; I just can't get it to work. I am now sure it has to do with the script, because I tested the item using other more simple "OnActivate" scripts and it worked, so I am posting the code to see if someone else can point me in the right direction.

-
void main()
{
object oPC = GetItemActivator();
object oItem = GetItemActivated();
object oTarget = GetItemActivatedTarget();
location lTarget = GetItemActivatedTargetLocation();

int nDmgType = DAMAGE_TYPE_NEGATIVE;
int nTouch = TouchAttackRanged(oTarget);

if (GetIsReactionTypeHostile(oTarget, oPC) || GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD)
{

SignalEvent(oTarget, EventSpellCastAt(oPC, SPELL_RAY_OF_ENFEEBLEMENT));

if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD)
{
int nHeal = d4(6);

effect eHeal = EffectHeal(nHeal);
effect eVis = EffectVisualEffect(VFX_HIT_SPELL_NECROMANCY);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
}

if (GetIsReactionTypeHostile(oTarget, oPC) && nTouch != TOUCH_ATTACK_RESULT_MISS)
{ //Make SR Check
if(!MyResistSpell(oPC, oTarget))
{
int nDam = d4(3);

effect eDam = EffectDamage(nDam, nDmgType, DAMAGE_POWER_NORMAL);
effect eVis = EffectVisualEffect(VFX_HIT_SPELL_NECROMANCY);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
}
}

effect eRay = EffectBeam(VFX_BEAM_ELDRITCH, OBJECT_SELF, BODY_NODE_HAND);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eRay, oTarget, 2.0);

}
}
-

This basically shoots a ray that either deals negative damage or heals an undead target. Whenever I activate the rod nothing really happens, and I am using Activate (Long Range) option.

Any help would be greatly appreciated.

#7
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
I'm not familiar with the touch functions you are using. A couple of things that seem incorrect in the script are that you are using two if's rather than an if-else. So this means that a hostile undead will be both damaged and healed. Since undead are healed by negative energy (aren't they? I think so) I think all you need to do is cause negative energy damage.

I'm not sure if you should be using Signal Event. You aren't really casting ray of enfeeblement, so to signal it doesn't seem correct.

Hope this helps.

Regards

#8
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
you need to signal it so if you are invisible it undoes your invisibility, or to trigger on spell cast at AI and module events. You can however used the spell id for activate item or the like instead instead of ray of enfeeblement. Removing it would be a bad idea.

I would add some
SendMessageToPC( GetFirstPC(), "Message about where in teh script it is")
to send you messages showing where it is in the logic, if it's running, and once you do that you should be able to get a better understanding of what its actually doing. Hard to know which portion is the issue as errors can be almost impossible to spot. Might not even be running if you did not name the script file right.

You probably need to redo that logic too on the touch attack, if it's undead or hostile is already known, which means the second get is hostile is not needed, just do an else. Also you can then do the touch attack inside the hostile block instead of doing it prior to even knowing if they are your own undead.