Jump to content

Add Spells from formlist?


xcafe

Recommended Posts

  • 2 weeks later...

So this isn't working again, and I don't know why!

 

Basically, I have it set up like this:

 

 

State Learning  
    Event OnBeginState()
        ;If spell has reached 100% learned, add spell to player
        if (percentageLearned >= 100)
            CentralQuest.GSL.AddForm(SpellLearned)
            Debug.Notification("You have transcribed " + LearnSpell + ".")
        else
            Debug.Notification("You have learned " + percentageLearned as int + "% of " + LearnSpell + ".")
        endIf

 

 

This here is part of a larger script attached to spelltomes, but this part is the part that adds the spells in the tomes to the formlist.

 

Then my script, here, calls the formlist and uses the function from this post to add the spells to the player.

 

 

State Studying

    Event OnBeginState()
        
        ;This will run as studying begins.
            ;;; Include anything that needs to happen at study start here.
            Int WaitTime = CentralQuest.GSL.GetSize()
             Game.DisablePlayerControls(True, True, True, False, True, True, True, True)
          Game.ForceThirdPerson()
          Debug.SendAnimationEvent(PlayerRef, "ChairReadingStart")
          Utility.Wait(WaitTime * 5.0) ; sets when studying will be complete
          Debug.SendAnimationEvent(PlayerRef, "IdleForceDefaultState")
       Game.EnablePlayerControls()       
           
     AddSpells()   
        

       GoToState("Studied")  ; leave studying state so OnRead can trigger again
    
       EndEvent
EndState






Function AddSpells()
    Debug.Notification("addspells called")
    Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
    Form Entry = CentralQuest.GSL.GetAt(Index)
  If (Entry as Spell)
      PlayerRef.AddSpell(Entry as Spell)
    
       
       EndIf
  Index += 1
   EndWhile

Debug.Notification("spells added")
EndFunction

 

 

Except that it's not doing that. It adds the spell that I have manually added into the formlist through the CK, but none of the ones it should be adding from the tomes. To clarify, it is being called, as all the debugs are going off, it just isn't working. In addition, the function to remove the spells also isn't working. Here's the script for that:

 

 

 

State Studied
    
    Event OnBeginState()
        NotStudied = false
        Debug.Notification("State 'Studied' Entered")
        RegisterForSingleUpdateGameTime(24.0)
    Debug.Notification("Registered for update(24)")
    EndEvent
    
    
    Event OnUpdateGameTime()
        Debug.Notification(GametimeUpdated)
 Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
    Form Entry = CentralQuest.GSL.GetAt(Index)
  If (Entry as Spell)
      PlayerRef.RemoveSpell(Entry as Spell)
     EndIf
  Index += 1
   EndWhile

GoToState("")
EndEvent

EndState

 

 

It's not even removing the spell that's manually added in the formlist, I don't know what the deal is.

 

Here's the full script, for reference:

 

 

 

Scriptname grimoirescript3 extends ObjectReference 
CentralListScript Property CentralQuest Auto
Actor Property PlayerRef Auto
Message Property GMSG Auto
Bool Property NotStudied = True Auto


Event OnRead()
{Begins the studying if conditions are right.}
If (NotStudied)
    If (PlayerRef.GetSitState() < 3)
        Debug.Notification("You must be seated to study your grimoire!")
    Else
        
        Int iButton = GMSG.Show()
        If (iButton == 0) ;yes
            CloseTheBook()
            GoToState("Studying")
        ElseIf (iButton == 1) ;no
            Debug.Notification("You decide not to study your spells right now.")
        EndIf
    EndIf
EndIf
EndEvent

State Studying

    Event OnBeginState()
        
        ;This will run as studying begins.
            ;;; Include anything that needs to happen at study start here.
            Int WaitTime = CentralQuest.GSL.GetSize()
             Game.DisablePlayerControls(True, True, True, False, True, True, True, True)
          Game.ForceThirdPerson()
          Debug.SendAnimationEvent(PlayerRef, "ChairReadingStart")
          Utility.Wait(WaitTime * 5.0) ; sets when studying will be complete
          Debug.SendAnimationEvent(PlayerRef, "IdleForceDefaultState")
       Game.EnablePlayerControls()       
           
     AddSpells()   
        

       GoToState("Studied")  ; leave studying state so OnRead can trigger again
    
       EndEvent
EndState

State Studied
    
    Event OnBeginState()
        NotStudied = false
        Debug.Notification("State 'Studied' Entered")
        RegisterForSingleUpdateGameTime(24.0)
    Debug.Notification("Registered for update(24)")
    EndEvent
    
    
    Event OnUpdateGameTime()
        Debug.Notification(GametimeUpdated)
 Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
    Form Entry = CentralQuest.GSL.GetAt(Index)
  If (Entry as Spell)
      PlayerRef.RemoveSpell(Entry as Spell)
     EndIf
  Index += 1
   EndWhile

GoToState("")
EndEvent

EndState

Function CloseTheBook()
{Close the book and inventory menu too.}
    Game.DisablePlayerControls(false, false, false, false, false, true, false, false)
    Utility.Wait(0.01)
    Game.EnablePlayerControls(false, false, false, false, false, true, false, False)
EndFunction

Function AddSpells()
    Debug.Notification("addspells called")
    Int ListSize = CentralQuest.GSL.GetSize()
Int Index = 0
While Index < ListSize
    Form Entry = CentralQuest.GSL.GetAt(Index)
  If (Entry as Spell)
      PlayerRef.AddSpell(Entry as Spell)
    
       
       EndIf
  Index += 1
   EndWhile

Debug.Notification("spells added")
EndFunction 

 

 

Link to comment
Share on other sites

You are saying that this script did work, but now it is not? In most cases this is due to making changes to the mod and trying to test with a save that already saw the previous version of the mod. If all else fails, always test on a game that has not seen the mod before. Also confirm that the properties are properly assigned. Beyond that, I don't see anything wrong and am clueless as to why it would fail.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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