Jump to content

[LE] Papyrus Script to add Keyword


Recommended Posts

I was looking for a way to add the ImmuneParalysis keyword to the player when a certain spell is used.


Not very experienced with Papyrus scripting. I was going to add the script to the magic effect that the spell would use.


Any guidance anyone can give me regarding this will be very helpful. Thank you.



I'v


Link to comment
Share on other sites

I think you have 2 options.

1. Papyrus Extender has 'AddKeywordToRef' and 'RemoveKeywordFromRef' functions.

2. Or use a quest alias. For this method, set up a quest with a reference alias for the player, but leave it empty.

Make sure to check the 'optional' flag and add the keyword to the alias.

Then use following script on the magic effect, fill the properties.

Scriptname SomeScriptName extends ActiveMagicEffect

Actor Property PlayerRef auto
ReferenceAlias Property PlayerAlias auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
	if (akTarget == PlayerRef)
		PlayerAlias.ForceRefTo(PlayerRef)
	endif
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	if (PlayerAlias.GetActorReference())
		PlayerAlias.Clear()
	endif
EndEvent

 

Link to comment
Share on other sites

I just realized that the RemoveKeywordFromRef function is exclusive to the SSE version of Papyrus Extender.

The LE version has a ReplaceKeywordOnRef function, which in theory could work too, but sadly it only lasts for the current game session. :confused:

 

Sorry about the confusion. Unfortunately I can't think of a practicable way to add and remove keywords for random NPCs, at least for Skyrim LE.

Link to comment
Share on other sites

I think your best bet, at least without using skse, would be to do what Ghaunadaur suggested and use reference alias's. You can make maybe 30 or something. Once you make one you can duplicate them so it's not hard, and put them in an area for the spell to use. Make sure they have the Optional box checked. Example script:

 

ReferenceAlias[] Property AliasList Auto
ReferenceAlias Property UsedAlias Auto Hidden

Event OnEffectStart(Actor akTarget, Actor akCaster)
    UsedAlias = FindUnusedalias()
    
    If UsedAlias
        UsedAlias.ForceRefTo(akTarget)
    Endif
EndEvent 

Event OnEffectFinish(Actor akTarget, Actor akCaster) 
    If UsedAlias 
        UsedAlias.Clear()
    Endif 
EndEvent

ReferenceAlias Function FindUnusedalias() 
    Int i = AliasList.Length 
    While i > 0 
        i -= 1 
        If AliasList[i].GetActorRef() == None 
            return AliasList[i]
        Endif 
    EndWhile
    
    return None
EndFunction 
Link to comment
Share on other sites

  • Recently Browsing   0 members

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