Jump to content

[LE] Cannot Remove a Vanilla Perk from a Mod


Recommended Posts

Briefly, I have a mod that added the Persuasion perk, I now want to remove it. I'll add conditions, et. al later. Right now, I'm just trying to get the perk to remove.

 

So I added a quest to the mod to remove the perk by adding a script to a reference alias for the player:

ScriptName _sp0ArtAllRemovePerk Extends ReferenceAlias

Perk Property Persuasion Auto
Spell Property NordAbPersuasion_sp0 Auto

function OnLoad()
	self.registerForUpdate(5.0)
endFunction

function OnInit()
	self.registerForUpdate(5.0)
endFunction

function OnUpdate()
		debug.Notification("Checking for perk...")
	If (Game.GetPlayer().HasPerk(Persuasion))
		Game.GetPlayer().RemovePerk(Persuasion)
		utility.Wait(0.1)
		(Game.GetPlayer().EvaluatePackage())
		utility.Wait(0.1)
		If (Game.GetPlayer().HasPerk(Persuasion) == False)
			debug.Notification("Perk removed!")
		Else
			debug.Notification("Failed to remove perk.")
		EndIf
	Else
		debug.Notification("Perk not found.")
	EndIf
	(Game.GetPlayer().unregisterForUpdate())
	debug.Notification("Perk maintenance completed.")
endFunction


These messages show:

 

Checking for perk...

Perk removed!

 

But when I view the Speech perk tree, the Persuasion perk is still present. Anyone have an idea what I'm doing wrong?

 

(BTW, not sure if this will help, but the Persuasion perk sets stage 60 of the PerksQuest, which sets the global values for the speech checks.)

Edited by sp0ckrates
Link to comment
Share on other sites

At a rough guess: You cannot really remove a vanilla perk by script, which are set on game start!

 

Furthermore your script is very strange. You are using "function" instead of "event" and next won't work on player alias script, it is working on a player actor script only.

Game.GetPlayer().unregisterForUpdate()

_sp0ArtPerkPlayerAliasScript

 

Scriptname _sp0ArtPerkPlayerAliasScript extends ReferenceAlias
; https://forums.nexusmods.com/index.php?/topic/5516512-cannot-remove-a-vanilla-perk-from-a-mod/

; "added a quest to the mod to remove the perk by adding a script to a reference alias for the player"

  Perk  PROPERTY myPerk  auto    ; Persuasion
  Spell PROPERTY mySpell auto    ; NordAbPersuasion_sp0 ???

  Int iUpdate

;  ******************************************************************
; *** Note: Do NEVER use RegisterForUpdate() in Skyrim scripts !!! *** (ReDragon)
;  ******************************************************************

; -- EVENTs -- 3

EVENT OnInit()  ; called once on a new game or existing savegame
    iUpdate = -1
    RegisterForSingleUpdate(5.0)
    Debug.Trace("OnInit() - has been reached..  " +self)    ; info only
ENDEVENT

EVENT OnPlayerLoadGame()   ; called every time a savegame has been loaded
IF (iUpdate > 0)
    RegisterForSingleUpdate(5.0)
    Debug.Trace("OnPlayerLoadGame() - has been reached..  " +self)    ; info only
ENDIF
ENDEVENT

EVENT OnUpdate()
    IF (iUpdate == -1)
        iUpdate = 1
    ENDIF

IF ( iUpdate )
ELSE
    RETURN    ; - STOP - /1  mod has been uninstalled
ENDIF
;---------------------
    Debug.Notification("Checking for perk...")

    actor playerRef = self.GetActorReference()    ; if self is a player alias script, this is working
;;; actor playerRef = Game.GetPlayer()            ; this works in general for all scripts (without semicolons infront)

IF playerRef.HasPerk(myPerk)
    ; http://www.creationkit.com/index.php?title=Talk:HasPerk_-_Actor
ELSE
    Debug.Notification("Special player perk not found!")
    RETURN    ; - STOP - /2
ENDIF
;---------------------
;;; playerRef.AddPerk(myPerk)
    playerRef.RemovePerk(myPerk)                  ; probably you can only remove a perk, that was added by script before

;;; playerRef.EvaluatePackage()                   ; not needed here, never seen in vanilla scripts
    Utility.Wait(0.1)

    IF playerRef.HasPerk(myPerk)
        Debug.Notification("Failed to remove perk!")
    ELSE
        Debug.Notification("Perk already removed..")
    ENDIF
ENDEVENT

; -----------
; Conclusion: You cannot really remove a vanilla perk by script, which are set on game start!
; -----------
; or another game mechanic added the perk back to the player after OnUpdate() finished.

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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