Jump to content

[LE] Retroactive Necromage- need scripting help!


Recommended Posts

For understanding: The quest (your new created quest that has attached the script "RetroactiveNecromageScript") runs once (maybe twice) at the moment you run a new game or a loaded game.

If you run the quest on new game the player cannot be a vampire.

If you run the quest on a loaded game first time and the player is not a vampire, times later quest is still running and the player transforms to any vampire race there exists no event that will be

triggered to run myF_Test() again.

 

Hopefully I do not have explained to confused.

; -- EVENTs -- 3

EVENT OnInit()
; keep in mind: Do NOT overwhelming this init event with a lot of code !!!
    RegisterForSingleUpdateGameTime(0.0)    ; trigger next event OnUpdateGameTime() as fast as possible
ENDEVENT

EVENT OnUpdateGameTime()
    RegisterForSingleUpdate(1.0)                    ; test first time after 1.0 second
ENDEVENT

EVENT OnUpdate()
    myF_Test()

    IF ( ResetOnce )
    ELSE
          RegisterForSingleUpdate(5.0)            ; trigger event again after 5.0 seconds
    ENDIF
ENDEVENT

Can you remember what I wrote earlier, find out the right event.

You decided to use a "quest script" instead of a "ReferenceAlias script" prefilled with player.

Edited by ReDragon2013
Link to comment
Share on other sites

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

So, what I'm doing is testing using two saves with the prepared character (level 81, purchased perks affected by the Necromage Vampire build).

 

1: Save without Necromage and Vampire, (but with the vampire disease). The purpose of this save is to test if the script will appropriately run in the background during a new or in-process game where the player does not have Necromage or Vampirism, and if saving/loading will be required to force the script to behave appropriately. Your new example code fixes that potential issue, so thanks!

 

2: Save with Necromage and stage 1 Vampirism. The purpose of this save is to test that the script will work with an in-progress game, where a player has both Necromage and Vampirism. It serves as a quick way to determine if the script will properly run, since the save will load with the player already ready for the script to replace perks and spells.

 

All of the testing I have done with this in-progress mod so far has been with the 2nd save, the one with both Necromage and stage 1 Vampirism. In short, the script is consistently failing to recognize the player as a vampire despite the game loading with the player having Stage 1 Vampirism.

Edited by Galcyon
Link to comment
Share on other sites

Ok, just ran another test, and I think I found out what's happening.

 

For some reason, the script isn't registering the player, period. Switched the order of True/false checks, and now it's claiming that the Player doesn't have Necromage.

 

So, the most likely problem is that the script isn't properly referring to the player, instead of us not properly defining vampirism or perks.

 

I can see the definitions of referring to the player here, but the examples that page provides are... kinda poor, since there's two ways to refer to the player, and the examples are doing a poor job doing something as basic as, say, showing how to refer to the player to see if they do or don't have something. Or maybe they do, and I'm just too Papyrus-illiterate to understand without better examples. So how do I refer to the player in the game the script will understand?

Edited by Galcyon
Link to comment
Share on other sites

Are you tracking the player in a Quest Alias? If not, you should be. Then you can add that Reference Alias as a property on your script. Or better yet, simply attach the script to the Quest Alias and use the OnRaceSwitchComplete event handler to detect when the player becomes a vampire.

 

It would be helpful if you could upload your plugin and scripts somewhere so that we can see exactly what you're working with.

Link to comment
Share on other sites

It would be helpful if you could upload your plugin and scripts somewhere so that we can see exactly what you're working with.

The entire script is posted at the last post of the prior page, under spoilers. It's functioning as a simple "run in background" script, so I don't think uploading the whole .esp is absolutely necessary; it's literally a "boot up CK, make new quest, shove the script into the new quest" deal.

Edited by Galcyon
Link to comment
Share on other sites

 

The entire script is posted at the last post of the prior page, under spoilers. It's functioning as a simple "run in background" script, so I don't think uploading the whole .esp is absolutely necessary; it's literally a "boot up CK, make new quest, shove the script into the new quest" deal.

 

Did you set the properties on your script? If you just "shove the script into the new quest" (not sure what that is supposed to mean), your check to determine if the player has the necromage perk will fail because the property is empty.

Link to comment
Share on other sites

 

 

The entire script is posted at the last post of the prior page, under spoilers. It's functioning as a simple "run in background" script, so I don't think uploading the whole .esp is absolutely necessary; it's literally a "boot up CK, make new quest, shove the script into the new quest" deal.

 

Did you set the properties on your script? If you just "shove the script into the new quest" (not sure what that is supposed to mean), your check to determine if the player has the necromage perk will fail because the property is empty.

 

 

Reproducing the current script (again) under the spoiler:

 

 

ScriptName RetroactiveNecromageScript extends Quest

    Quest PROPERTY PlayerVampireQuest auto        ; use autofill [QUST:000EAFD5]    
    ; this quest runs start game enabled and has the script "PlayerVampireQuestScript" attached,

; we get next property from "PlayerVampireQuestScript.psc" directly
; Int PROPERTY VampireStatus auto Conditional
; used to track if the player is a vampire {0 = Not a Vampire, 1 = Vampire, 2,3,4 = Vampire Stage 2,3,4}

  Perk PROPERTY necromage auto          ; fill with your new created perk
  Perk PROPERTY atronach  auto          ;
  Perk PROPERTY AvoidDeath   auto       ;
  Perk PROPERTY DualFlurry30 auto       ;
  Perk PROPERTY DualFlurry50 auto       ;
  Perk PROPERTY ExtraPockets auto       ;
  Perk PROPERTY FistsOfSteel auto       ;
  Perk PROPERTY MagicResistance30 auto  ;
  Perk PROPERTY MagicResistance50 auto  ;
  Perk PROPERTY MagicResistance70 auto  ;
  Perk PROPERTY MuffledMovement auto    ;
  Perk PROPERTY PowerShot       auto    ;
  Perk PROPERTY QuickReflexes   auto    ;
  Perk PROPERTY QuickShot   auto        ;
  Perk PROPERTY Recovery30  auto        ;
  Perk PROPERTY Recovery50  auto        ;
  Perk PROPERTY Snakeblood  auto        ;
  Perk PROPERTY WindWalker  auto        ;
  Perk PROPERTY T01DibellaReward  auto  ;
  Perk PROPERTY T02MaraReward  auto     ;
  Perk PROPERTY MQBladesDragonResearch  auto     ;
  Perk PROPERTY dunFrostflowAbyssPerk  auto      ;
  Perk PROPERTY NN01Perk  auto          ;
 
  Spell PROPERTY T01DibellaRewardAbility     auto
  Spell PROPERTY MS04Reward                  auto
  Spell PROPERTY MS04RewardNoDisplay         auto
  Spell PROPERTY TGCrownProfit               auto
  Spell PROPERTY dunFrostflowAbyssBoon       auto
  Spell PROPERTY NN01Spell                   auto
  Spell PROPERTY RaceArgonianResistDisease   auto
  Spell PROPERTY RaceBreton       auto
  Spell PROPERTY RaceDarkElf      auto
  Spell PROPERTY RaceImperial     auto
  Spell PROPERTY RaceKhajiitClaws auto
  Spell PROPERTY RaceNord         auto
  Spell PROPERTY RaceRedguard     auto
  Spell PROPERTY RaceWoodElf      auto

  Bool ResetOnce    ; [default=false]
    ; this sets up a variable to prevent the script from constantly resetting perks and abilities once conditions have been met

; https://www.creationkit.com/index.php?title=RemoveSpell_-_Actor
; https://www.creationkit.com/index.php?title=HasPerk_-_Actor
; https://www.creationkit.com/index.php?title=AddPerk_-_Actor

; https://www.creationkit.com/index.php?title=RegisterForSingleUpdateGameTime_-_Form
; https://www.creationkit.com/index.php?title=OnUpdateGameTime_-_Form


; -- EVENTs -- 2
 
;-------------
EVENT OnInit()
;-------------
    ; keep in mind: Do NOT overwhelming this init event with a lot of code !!!
    RegisterForSingleUpdateGameTime(0.0)        ; trigger next event OnUpdateGameTime() as fast as possible
ENDEVENT


EVENT OnUpdateGameTime()
    myF_Test()
ENDEVENT


; -- FUNCTIONs -- 3

;------------------
FUNCTION myF_Test()
;------------------
IF ( ResetOnce )
    RETURN    ; - STOP -    player already has had their perks and abilities reset by this script
ENDIF
;---------------------
    actor player = Game.GetPlayer()                            ; get the internal variable once here
    
     int i = myF_IsPlayerVampire()

IF (i < 1)
	Debug.MessageBox("Not a vampire")
    RETURN    ; - STOP -    player is of human race
ENDIF
;---------------------
IF player.HasPerk(necromage)
ELSE
    Debug.MessageBox("No Necromage perk")
    RETURN    ; - STOP -    player is a vampire, but does not have the special necromage perk
ENDIF
;---------------------

; selection 1
; ~~~~~~~~~~~
    TryToReset_Spell(player, T01DibellaRewardAbility)
    TryToReset_Spell(player, MS04Reward)
    TryToReset_Spell(player, MS04RewardNoDisplay)
    TryToReset_Spell(player, TGCrownProfit)
    TryToReset_Spell(player, dunFrostflowAbyssBoon)
    TryToReset_Spell(player, NN01Spell)
    TryToReset_Spell(player, RaceArgonianResistDisease)
    TryToReset_Spell(player, RaceBreton)
    TryToReset_Spell(player, RaceDarkElf)
    TryToReset_Spell(player, RaceImperial)
    TryToReset_Spell(player, RaceKhajiitClaws)
    TryToReset_Spell(player, RaceNord)
    TryToReset_Spell(player, RaceRedguard)
    TryToReset_Spell(player, RaceWoodElf)

; selection 2
; ~~~~~~~~~~~
    TryToReset_Perk(player, atronach)
    TryToReset_Perk(player, AvoidDeath)
    TryToReset_Perk(player, DualFlurry30)
    TryToReset_Perk(player, DualFlurry50)
    TryToReset_Perk(player, ExtraPockets)
    TryToReset_Perk(player, FistsOfSteel)
    TryToReset_Perk(player, MagicResistance30)
    TryToReset_Perk(player, MagicResistance50)
    TryToReset_Perk(player, MagicResistance70)
    TryToReset_Perk(player, MuffledMovement)
    TryToReset_Perk(player, PowerShot)
    TryToReset_Perk(player, QuickReflexes)
    TryToReset_Perk(player, QuickShot)
    TryToReset_Perk(player, Recovery30)
    TryToReset_Perk(player, Recovery50)
    TryToReset_Perk(player, Snakeblood)
    TryToReset_Perk(player, WindWalker)
    TryToReset_Perk(player, T01DibellaReward)
    TryToReset_Perk(player, T02MaraReward)
    TryToReset_Perk(player, MQBladesDragonResearch)
    TryToReset_Perk(player, dunFrostflowAbyssPerk)
    TryToReset_Perk(player, NN01Perk)
    
;---------------------
    ResetOnce = TRUE             ; switch value of script (from False to TRUE) to prevent constantly resetting

    Debug.MessageBox("Perks and Abilities have been retroactively altered!")
ENDFUNCTION


;------------------------------------------------
FUNCTION TryToReset_Spell(Actor player, Spell sp)
;------------------------------------------------
IF player.HasSpell(sp)
    player.RemoveSpell(sp)
 
    player.AddSpell(sp, False)              ; reset this ability
ENDIF
ENDFUNCTION


;---------------------------------------------
FUNCTION TryToReset_Perk(Actor player, Perk p)
;---------------------------------------------
    IF player.HasPerk(p)
        player.RemovePerk(p)

        player.AddPerk(p)                   ; reset perk
    ENDIF
ENDFUNCTION

;---------------------------------
Int FUNCTION myF_IsPlayerVampire()
;---------------------------------
IF (PlayerVampireQuest) && PlayerVampireQuest.IsRunning()
ELSE
    ; Debug.MessageBox("PlayerVampireQuest is not running!")
    Return -1
ENDIF
;---------
    int i = (PlayerVampireQuest as PlayerVampireQuestScript).VampireStatus
    Return i     ; (i > 0) player is a vampire
ENDFUNCTION

 

 

 

Additionally, when I say "shove the script into the new quest", it's basically shorthand for the guide here. Which, in my experience, literally means "open up the CK, make a new quest, do not touch anything because the default selections will already have it set up to run on game load, and put the script in the last tab where scripts go, making sure you have it selected for extends quest".

Link to comment
Share on other sites

 

Additionally, when I say "shove the script into the new quest", it's basically shorthand for the guide here. Which, in my experience, literally means "open up the CK, make a new quest, do not touch anything because the default selections will already have it set up to run on game load, and put the script in the last tab where scripts go, making sure you have it selected for extends quest".

 

But did you click "Auto-Fill All" in the properties dialog?

Link to comment
Share on other sites

 

 

Scriptname RN_PlayerScript extends ReferenceAlias

GlobalVariable Property PlayerIsVampire Auto

Perk Property necromage Auto

FormList Property RN_PerkList Auto
FormList Property RN_SpellList Auto

Bool Complete = False

Event OnRaceSwitchComplete()
  If Complete
    Debug.TraceAndBox("Player perks and abilities have already ben re-applied.")
    Return
  EndIf

  Utility.Wait(1.0)
  ResetPlayerAbilities()
EndEvent

Function ResetPlayerAbilities()
  If PlayerIsVampire.GetValueInt() == 0
    Debug.TraceAndBox("Player is not a Vampire.")
    Return
  Else
    Debug.TraceAndBox("Player has turned into a Vampire.")
  EndIf

  Actor PlayerRef = Self.GetReference() as Actor

  If !PlayerRef.HasPerk(necromage)
    Debug.TraceAndBox("Player does not have the Necromage perk.")
    Return
  Else
    Debug.TraceAndBox("Player has the Necromage perk.")
  EndIf

  Complete = True

  ResetPerks()
  ResetSpells()

  Debug.TraceAndBox("Player perks and abilities have been re-applied.")
EndFunction

Function ResetSpells()
  Actor PlayerRef = Self.GetReference() as Actor
  Int Index = RN_SpellList.GetSize()

  While Index
    Index -= 1
    Spell s = RN_SpellList.GetAt(Index) as Spell

    If PlayerRef.HasSpell(s)
      PlayerRef.RemoveSpell(s)
      PlayerRef.AddSpell(s, False)
      Debug.TraceAndBox("Re-applied ability " + s)
    EndIf
  EndWhile
EndFunction

Function ResetPerks()
  Actor PlayerRef = Self.GetReference() as Actor
  Int Index = RN_PerkList.GetSize()

  While Index
    Index -= 1
    Perk p = RN_PerkList.GetAt(Index) as Perk

    If PlayerRef.HasPerk(p)
      PlayerRef.RemovePerk(p)
      PlayerRef.AddPerk(p)
      Debug.TraceAndBox("Re-applied perk " + p)
    EndIf
  EndWhile
EndFunction

 

 

 

This is how I would do it. Quest with Quest Alias filled with Player, and two Form Lists containing the perks and abilities that you want to reset.

Link to comment
Share on other sites

This is how I would do it. Quest with Quest Alias filled with Player, and two Form Lists containing the perks and abilities that you want to reset.

Cool, and I think I now see why the prior attempts at pointing to the player failed.

 

And yeah, ReDragon did mention something about Form Lists (actually looks like Arrays now), so that's also something to think about. Right now, I want to make sure the script works before any further tinkering/shrinking gets involved.

 

I'll update this thread, either because I need further help, or because I'm announcing the mod's initial release.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...