Jump to content

[Magic Script] Failing to make a NPC invisible


Recommended Posts

I have invisible NPC. While drinking a potion the NPC gets visible and once the effect wears of the NPC should become invisible again.

 

The NPC is at first invisible and the spell to remove the invisibility works too (I am using an ability with the DogmeatInvisibility Effect). But the NPC won't get invisible again.

 

The magic script is like this:

Scriptname FHM2DetectLifePlayerPerkMagEffScr extends activemagiceffect

Perk Property FHM2PlayerDetectLifePerk Auto
EffectShader Property VisibleShader Auto
EffectShader Property StealthBoyInvisibilityEffect Auto
Actor Property FHM2ElizaRef Auto
Spell Property FHM2Invisibility Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
Game.Getplayer().AddPerk (FHM2PlayerDetectLifePerk)
    VisibleShader.Play(FHM2ElizaRef )
FHM2ElizaRef.RemoveSpell (FHM2Invisibility)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
Game.Getplayer().RemovePerk (FHM2PlayerDetectLifePerk)
    VisibleShader.Stop(FHM2ElizaRef )
FHM2ElizaRef.AddSpell (FHM2Invisibility)
EndEvent

 Any Ideas?

 

Link to comment
Share on other sites

I gotta stop checking forums before bed 🙂 . Is the invisibility applied through magic effect? If so, you can add the condition check:

Subject.HasMagicEffectKeyword(DisableInvisibilityKeyord)=0

Then for the magic effect of the potion you add this same keyword. For the duration of the potion effect, this keyword will be added to the character, the condition for the invisibility effect will trigger and the effect will be interrupted. I don't know what should be the Archetype of the magic effect for the potion though, since you only need to apply the keyword, not damage/recover anything.

Link to comment
Share on other sites

That's the odd thing.

I had two magic effects on the character: Invisibility and another shader.

Both were applied through an ability with a constant effect.

 

I used the condition Player.HasPerk (FHM02DetectLifePerk) == 0 on the invisibility an Player.HasPerk (FHM02DetectLifePerk) == 1 on the shader magic effect.

The ghost became visible but never got invisible again, after the FHM02DetectLifePerk got removed.

Link to comment
Share on other sites

At first glance it seems to me the ActiveMagicEffect that applies the invisibility remains on the effect target actor and when you try to remove the effect source the ActiveMagicEffect enters into a "dormant" or "inactive" state but doesn't get properly removed.

If you have Better Console, you can quickly see the list of all "Active Effects" applied to the actor. Check that actor's pre-OnEffectStart, post-OnEffectFinished, etc. state.

As for using HasPerk, well, generally speaking the perk can easily get "untied" from the active effect, condition functions like HasMagicEffect, HasMagicEffectKeyword, EP(...) like EPAlchemyEffectHasKeyword are more appropriate to be used in Magic Effect >> Target Conditions.

Edited by LarannKiar
Link to comment
Share on other sites

  • Recently Browsing   0 members

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