1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 03:21:41 +00:00

Activation handler for ESM4 Door

This commit is contained in:
Petr Mikheev 2023-04-17 19:52:24 +02:00
parent 2a6e301925
commit 480951207c

View File

@ -1,9 +1,27 @@
local async = require('openmw.async')
local types = require('openmw.types')
local world = require('openmw.world')
local EnableObject = async:registerTimerCallback('EnableObject', function(obj) obj.enabled = true end)
local function ESM4DoorActivation(door, actor)
-- TODO: Implement lockpicking minigame
-- TODO: Play door opening animation and sound
local Door4 = types.ESM4Door
if Door4.isTeleport(door) then
actor:teleport(Door4.destCell(door), Door4.destPosition(door), Door4.destRotation(door))
else
door.enabled = false
async:newSimulationTimer(5, EnableObject, door)
end
return false -- disable activation handling in C++ mwmechanics code
end
local handlersPerObject = {}
local handlersPerType = {}
handlersPerType[types.ESM4Door] = { ESM4DoorActivation }
local function onActivate(obj, actor)
local handlers = handlersPerObject[obj.id]
if handlers then