Jump to content

[LE] Adding multiple spells with one spell tome not working


EPHHall

Recommended Posts

I'm trying to get a spell tome (Mayhem in this case) to add two spells to the player: the default spell and another spell of my choosing. To do this, I tried adding a spell to the player via a script attached to the spell tome, but it isn't working and I'm not sure why. Here's my script:

Scriptname TeachSpellBook extends ObjectReference
{Adds a spell when the player reads a book
}
Spell Property SpellLearned Auto
Event OnActivate(ObjectReference akActionRef)
Game.getplayer().addspell(SpellLearned)
EndEvent
It compiles fine, so do I need to extend something different maybe? Or am I just using the wrong commands? I'm new to Papyrus, so I would love to learn what's going on here.
Link to comment
Share on other sites

You could try OnRead instead of OnActivate. OnEquipped may also be a viable alternative.

 

OnActivate tends to be for objects that are meant to be interacted with outside of player inventory. Which may very well explain why it isn't doing anything for you.

 

However, I am not certain if events will be triggered by a spell tome. Spell tomes are hardcoded to be removed from the player inventory when the player reads them to learn the spell. This may or may not interfere with the script processing.

 

If changing the events do not help, you might want to try creating a normal book that adds both spells via script instead.

Link to comment
Share on other sites

That is not it. I use OnActivate for the same thing.

 

1. Did you fill the properties of the script?

2. If you use on activate and you pick the book up it will fire.

3. If the book does not have a reference it may not work either. How did you place the book in the cell?

Edited by Masterofnet
Link to comment
Share on other sites

Yes, OnRead runs whenever a book is read whether it was in the game world or in some container (including the player's inventory).

 

I assume the book was originally placed in a container (possibly a merchant chest so the player could purchase it) rather than being placed as a unique item in the game world.

Link to comment
Share on other sites

Yes, OnRead runs whenever a book is read whether it was in the game world or in some container (including the player's inventory).

 

I remember reading a thread you were involved in regarding someone wanting to keep track of every book a player read and someone saying it could not be done because if the book was not an object reference On Read would not fire.

 

I had to use On Activate because for some reason On Read would not fire a function().

Link to comment
Share on other sites

The problem in that other thread was the fact that even though the book can get the OnRead event you can't determine which book is firing the script if the book doesn't have an actual reference. If you attach the same script to a large number of different books (which is what the other mod was doing) then functions like GetBaseObject and any attempts to use self will fail, so the only way to know which book was read would be to add a property to each book script to identify it. The author of that mod didn't want to have to individually fill properties for every book.

 

This case is about a script on a very specific spell tome not trying to attach it to all spell tomes. Although this does mean that this mod will have a conflict with that other one if both are trying to add scripts to the same book.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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