Jump to content

Looking to make a spell tome levelling mod


Recommended Posts

So I want to make a mod that prohibits reading or "eating" a spell tome if you haven't already eaten the one from the level before. So if you find a rank 3 tome but have not consumed the rank 2 yet, a msg will pop up saying you have not learned the preceding rank and therefore cannot learn this one yet.

 

Does someone have an idea as to how I can get this going on?

Link to comment
Share on other sites

A taught spell/skill is an internal native property of a Book type object. If the property is set, internal game engine checks if spell is already known, and if not, adds spell to player and consumes the book.

 

So if you want to make a change like you describe, you need to override every higher tier spell book form.

 

You would need a script, something like:

Scriptname AdvancedSpellTome Extends ObjectReference

Spell Property TaughtSpell Auto
Spell Property PreRequisite Auto
Actor Property PlayerRef Auto
Sound Property UISpellLearned Auto

Event OnRead()
    If PlayerRef.HasSpell(TaughtSpell)
        Debug.Notification("You already know " + TaughtSpell.GetName())
    ElseIf PlayerRef.HasSpell(PreRequisite)
        PlayerRef.AddSpell(TaughtSpell)
        UISpellLearned.Play(PlayerRef)
        Self.Delete()
    Else
        Debug.Notification("You must learn " + PreRequisite.GetName() + " before you can learn " + TaughtSpell.GetName())
    EndIf
EndEvent

I.e. FormID 0010F7F5 - Spell Tome 'ThunderBolt'. Set 'Teaches' selection to 'None' and attach above script.

AutoFill the sound and playerRef properties.

For spells, you would need to fill TaughtSpell with Thunderbolt, and PreRequisite with LightningBolt.

(For all other tomes, you attach same script, just fill spell properties accordingly).

 

Note that will likely mess with mods that rely on Book:GetSpell() (such as Unread Books Glow SE)

Link to comment
Share on other sites

Far as overall scripting goes, setting up the environment and such is really out of scope of this discussion - there are a fair few tutorials on YouTube about that.

I do it in Creation Kit

 

TNT2JGi.jpg

 

Once you click the Add, you can select an existing script or specify creating a new one.

Once a script is created, it is placed in Data\Source\Scripts, and can be edited in external editor (I use NetBeans) and then compiled using Papyrus Script Manager (under Gameplay menu in CK)

Link to comment
Share on other sites

Ah right. In truth I am trying to apply the mod to Enderal but I am having trouble getting the Creation Kit to load up with it so in the interim I was using TES5Edit, which is why I could not see the scripts option. I need to resolve the loadup issue first. Thanks for the great visual feedback!

Link to comment
Share on other sites

I got it running and I am creating the script but it returns 'getname is not a function or does not exist' error. Is there a Creation Kit fixes I need to install or am I overlooking something acutely obvious?

 

I checked the function out and apparently only available with SKSE, which I have installed.

 

EDIT: Extracted SKSE scripts into the right place and was able to compile, but the script in-game doesn't work. The tome is prevented from being learned but even after having learned the spell from a rank lower.

Edited by amokrun1
Link to comment
Share on other sites

I loaded a save and added books through console. I will try a completely new game to see.

 

ED: Just tried new game, same result. And scripts were filled in CK. As in here:

 

Scriptname SpecialTomeLevelSCPT extends ObjectReference

 

Spell Property _48E_FS_Spell_Overstrain Auto

Spell Property _30E_FS_Spell_Overstrain Auto

Actor Property PlayerRef Auto

Sound Property UISpellLearned Auto

 

Event OnRead()

If PlayerRef.HasSpell(_48E_FS_Spell_Overstrain)

Debug.Notification("You already know " + _48E_FS_Spell_Overstrain.GetName())

ElseIf PlayerRef.HasSpell(_30E_FS_Spell_Overstrain)

PlayerRef.AddSpell(_48E_FS_Spell_Overstrain)

UISpellLearned.Play(PlayerRef)

Self.Delete()

Else

Debug.Notification("You must learn " + _30E_FS_Spell_Overstrain.GetName() + " before you can learn " + _48E_FS_Spell_Overstrain.GetName())

EndIf

EndEvent

 

 

 

Perhaps I did not enter the forms correctly?

Edited by amokrun1
Link to comment
Share on other sites

Those are rather weird names there. What you want is a generic script that can be attached to ANY spell book, but you need to make sure to load proper spells into properties.

I.e. I created the script 'PriorRequirementScript', and I attached it to 3 books. But for each book, I filled properties differently. Have you filled properties on your scripts?

 

 

xJYYLq2.jpg

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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