Jump to content

(Scripted) Targeted Spell [Effect] Casting


Elemakil

Recommended Posts

Hiya!

 

is there a way to define a spell such that the underlying fire-and-forget magic effect is casted in a certain direction [Relative to the current player char orientation of course]?

 

Let me give you a short use case: I'm using a mod that makes dungeons _really_ dark. Thus whenever I have cleaned a room and want to use magic for creating the lights required for checking whether there is something to loot I have basically two choices: a) Have Candlelight active, which looks kinda strange (especially in snowy dungeons/caves) or b) cast a magelight upwards such that it floats just below the ceiling.

 

The use case for scripted, targeted spell casting would be a spell that fires the magic effect of Magelight in the positive Z-direction of the player char reference frame. Of course, one might tinker a little further and add a spell that cast not one but multiple magelights such that they form a "circle of lightballs" just below the ceiling.

 

Alright, back to my question: Is it possible (how?) to specify the target direction of a fire and forget magic effect?

Edited by Elemakil
Link to comment
Share on other sites

a hack would be to spawn a target very high up above each world.

then shoot a magelight at that.

Based on this idea I tried to create a script that spawns two objects (activators) at pre-defineable locations and casts a spell originating from one object and targeted to the other. This is the script:

Scriptname ele_TargetedCast extends ActiveMagicEffect

import Utility
import Debug
import Math

; Relative Positioning is relative to player Reference Frame
Float Property xCaster Auto ; Relative X Position of origin of spell
Float Property yCaster Auto ; Relative Y Position of origin of spell
Float Property zCaster Auto ; Relative Z Position of origin of spell

Float Property xTarget Auto ; Relative X Position of target of spell
Float Property yTarget Auto ; Relative Y Position of target of spell
Float Property zTarget Auto ; Relative Z Position of target of spell

Spell Property SpellToCast Auto ; The spell to be cast

Activator Property TargetType Auto ; The object type to be spawned for making a caster/target

Event OnEffectStart(Actor akTarget, Actor akCaster)
	; Create caster and target objects
	ObjectReference thisCaster = akCaster.PlaceAtMe(TargetType)
	thisCaster.MoveTo(akCaster, xCaster, yCaster, zCaster)
	ObjectReference thisTarget = akCaster.PlaceAtMe(TargetType)
	thisTarget.MoveTo(akCaster, xTarget, yTarget, zTarget)
	
	; thisCaster shall cast the spell and target thisTarget (dummy comment I guess)
    SpellToCast.Cast(thisCaster,thisTarget)
	
	; Delete the objects
	; thisCaster.DisableNoWait()
	; thisCaster.Delete()
	; thisTarget.DisableNoWait()
	; thisTarget.Delete()
EndEvent

 

For debugging purposes I have disabled the deletion of the spawned objects.

 

Afterwards I created a magic effect (fire and forget + self) to which I attached that script and a spell which uses that magic effect. The script variables have been set such that there's some space between caster and target; I chose and arbitrary activator (without script or anything) and set the spell to be cast from one object to the other to the (vanilla) Magelight spell.

 

When casting my spell the two objects are created properly. However when there's something inbetween the two objects (e.g. the player because the caster object was placed at 0,0,0 i.e. its feet) the hit animation/effect of Magelight is player. For the player (and any NPC I guess) it looks like he/she has cast Candlelight. My conclusion is that I require a version of the Magelight spell that does not hit the player and NPCs (it passes through them). Can anyone give me a hint how to do this?

 

EDIT: Also, when I use the above script and the projectile hits something I get a CTD. When I manually cast the spell that is cast by the script aswell I don't get a CTD...

Edited by Elemakil
Link to comment
Share on other sites

  • Recently Browsing   0 members

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