this makes the player invisible when under knockout animation
- local script
- thas the limitation that removal happens always outside knockout
- does loop over equipment splots to find the gear
local core = require('openmw.core')
local self = require('openmw.self')
local anim = require('openmw.animation')
local I = require('openmw.interfaces')
local types = require('openmw.types')
I.AnimationController.addTextKeyHandler('', function(groupname, key)
local spell = "Invisibility"
-- "chameleon" -- "fifth barrier"
local gear = "common_amulet_05"
-- might need equipment splot check sometimes for use case
local equips = types.Actor.getEquipment(self)
for c, _ in pairs(equips) do
if equips[c].recordId == gear and groupname == "knockout" then
-- this can be changed easily to other group
types.Actor.activeSpells(self):add({ id = spell, effects = {0}})
end
if anim.isPlaying(self,"knockout") == false then
-- under any other group
local effects = core.magic.spells.records[spell].effects
for i=1, #effects do
types.Actor.activeEffects(self):remove(effects[i].id)
--CAUTION: removes all the spell effects, also from other spells
end
end
end
end)
for checking what spells / effects actor has
- you need to fetch the list item in pairs ie.
local spells = types.Actor.activeSpells(self)
--local spells = types.Actor.activeEffects(self)
for _, b in pairs(spells) do
print(b.id)
end
- tho for removal you still need calls to remove spell without temporary flag.
otherwise this could be used under
if anim.isPlaying(self,"knockout") == false then
local spells = types.Actor.activeSpells(self)
for a, b in pairs(spells) do
if b.id == spell then
print(b.id)
types.Actor.activeSpells(self):remove(b.id)
end
end