Jump to content

[LE] Continuous spell casting via papyrus


Jollypolly

Recommended Posts

Hey Jolly,

 

I mentioned that you may need to create a special ward spell to get his to work with your item.

 

This involves creating a new magic effect. Not modifying the Nif.

 

You will also need to dispel it when the item is unequipped.

 

 

I think something you might look at here is trying to turn the ward spell into an ability.

 

Then add the ability to the NPC when the item is equipped and remove it when it is unequipped.

Edited by SurfsideNaturals
Link to comment
Share on other sites

I'm late to the party... (i've been too busy), but as SurfsideNaturals mentioned above.

From "concentrate" to "fire and forget".


" You will also need to dispel it when the item is unequipped."

Don't forget this otherwise it will remain permanent.

Link to comment
Share on other sites

Thanks for the help guys, really appreciate it.

 

So it works perfectly with the casting type set to "Constant Effect".

You can also set a custom duration in the "Effect Item" window of the spell so no need to dispel it.

 

However this doesn't work for targetted spells like flames.

 

Example script :

 

Scriptname TQspell extends ObjectReference

SPELL Property FlamesSpell Auto
Actor Property PlayerRef Auto

Actor Property Npc Auto ;note : target npc is in player close radius.

 

Event OnEquipped(Actor akActor)
if akActor == PlayerRef
FlamesSpell.cast(PlayerRef, Npc)
EndIf
EndEvent

 

Any idea why it doesn't work for targetted spells?

Link to comment
Share on other sites

First of all a little piece of advice.
- Not everything is so simple as it looks, just because you put a duration in the Effect it doesn't mean that you don't need to "Stop/Remove" the spell.
Example:
(i have encountered this in so many mods)
You can add an "EffectShader" to the Player that has a small duration (it plays for x sec, like 3) and keep adding "EffectShaders", the same or different without Stopping/Removing each Effectshader before applying the next.
Everytime you apply an EffectShader and don't stop/remove it, no matter if the FX plays for just 3 sec, the internal "FX Player" used will stay "ON/Active", so everytime you add an FX you are using one more "FX Player" for that FX, and those keep accumulating in the background and depending on your PC's power, they will cause a random CTD, this is unavoidable !.
The same principle applies here.
- "Flames" is a concentration spell.
- The function "cast" is used mainly on objects, this function cannot track the npc's position, it will obtain the npc's position on first execution of the fanction and from that point and on it will keep that direction & angle.
In order to do what you are trying to do you need to follow a different direction.
* One simple solution to this is to put the "cast" on a "while" loop, so in every loop it will re obtain the target's position, but this has the disadvantage of causing issues if you try to unequip the item while the script is on the "while" loop.

 

Edit: Typos...

Edited by maxarturo
Link to comment
Share on other sites

- When the "cast" is used on an object it will cast the spell from the object's XYZ center axe, sometimes you can not see the spell because the XYZ center axe is exactly in the middle of the object's geometry and its collision forbids the spell to exit the object's geometry.

When "cast" is used on objects (and only on objects), it can obtain the targets position, direction and angle.


- In the case that "cast" is used on an "Actor" it will use the "Node" that its skeleton is responsible / handling the cast of "Spells", and it will always cast the spell in the predefined by the npc's skeletons Node casting direction.

All npcs cast in a straight path line and in front of them, there is no enemy tracking (by the spell casting), the tracking of the enemy is handle by the npc's AI and it will always face the actor he is supposed to attack.



I hope that this is clear enough, i have a terrible headache and i can't think straight, so sorry in advance if forgot or missed something...


Have a happy modding !.

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...