basically the wanted lines are
local positio = self.position
local direction = self.rotation:apply(positio):normalize()
-- position = positio + direction * -300
-- this will make it 300 units front
as example the vfx is spawned every 5 seconds and the timer is stopped when the object becomes inactive. the script is on local NPC:
local core = require('openmw.core')
local self = require('openmw.self')
local util = require("openmw.util")
local types = require('openmw.types')
local time = require('openmw_aux.time')
local function onActive()
stop = time.runRepeatedly(function()
local positio = self.position
local direction = self.rotation:apply(positio):normalize()
local effect = core.magic.effects.records[core.magic.EFFECT_TYPE.Blind]
local model = types.Static.records[effect.castStatic].model
core.sendGlobalEvent('SpawnVfx', {model = model, position = positio + direction * -300})
end,5 * time.second)
end
local function onInactive()
stop()
print("stop")
end
return { engineHandlers = { onActive = onActive,
onInactive = onInactive }}