placing something on ground where playere si loking needs 2 scripts
namely in local to get the spot in question, on terrain this case
local core = require('openmw.core')
local self = require('openmw.self')
local types = require('openmw.types')
local nearby = require('openmw.nearby')
local camera = require('openmw.camera')
local util = require('openmw.util')
local count = 0
local function onUpdate(dt)
if types.Actor.getStance(self) == types.Actor.STANCE.Spell then
count = count + dt
if count > 0.5 then
local pos = camera.getPosition()
local direction = camera.viewportToWorldVector(util.vector2(0.5,0.5)):normalize()
local hit = nearby.castRay( pos, pos + direction * 1500, {
ignore = self,
collisionType = nearby.COLLISION_TYPE.HeightMap })
if hit and hit.hitPos then
core.sendGlobalEvent("sjek_place_fire", { hitpos = hit.hitPos, hitdir = hit.hitNormal } )
end
count = 0
end
end
end
return { engineHandlers = { onUpdate = onUpdate } }
and then using global to summon the effect
local world = require('openmw.world')
local core = require('openmw.core')
local types = require('openmw.types')
local function place_fire(func)
local effe = core.magic.effects.records[core.magic.EFFECT_TYPE.AlmsiviIntervention].castStatic
local model = types.Static.record(effe).model
world.vfx.spawn( model , func.hitpos )
--world.vfx.spawn( model , func.hitpos + func.hitdir * 100 )
end
return {
eventHandlers = { sjek_place_fire = place_fire }
}