• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

The theory behind spellbooks.

Status
Not open for further replies.
Level 21
Joined
Mar 27, 2012
Messages
3,232
An in-depth explanation on spellbooks

This is everything that I know about them.

Table of Contents:
  • Introduction
  • Definition
  • How spellbooks work
  • Bugs
  • TheHelper about spellbooks(and what's wrong)
  • Facts
  • Links

Introduction

The first tutorial about spellbooks I ever saw was the one in thehelper. However, it made me question a few things that andrewgosu assumed.
Due to that I constantly kept thinking about spellbooks for half a year.
Eventually I realized what was wrong. This is included here.
However, I didn't really think of publishing anything, since I thought that people can figure those things out themselves.

Time went on and on. People constantly asked the same questions and often got the same(wrong) answers. This has been annoying to me.
So now I have decided to end the peoples' ignorance.

Definition

Basic: Spellbook is an ability that allows a unit to replace the abilities in its command card.

How spellbooks work

When a unit gets a spellbook then the abilities are added.
When the spellbook gets removed, then the game checks if the spellbook contains a certain ability. If yes, then the ability will be removed.

Bugs

The "collision" bug:
When you "open" a spellbook, then the spellbook ability itself is not checked. What is checked is its base order ID. That means that if you use multiple spellbooks with the same base order ID, then they share abilities.

The morphing bug:
When a unit with a spellbook morhps to a unit that has the same abilities, then those abilities are not transferred(why add an ability that the unit already has?). That's because spellbooks weren't originally implemented in warcraft and thus the game doesn't check for abilities "in" the spellbook. I say "in" because spellbooks do NOT actually contain the abilities.
How to counter this bug?
You simply make another spellbook with the exact same abilities, name, limits, etc. The only thing different is that it is just a separate ability.

The spellbook disable bug
When you disable a spellbook, like this:
  • Player - Disable Spell Book for Player 1 (Red)
Then the game plays a trick on you.
Since spellbooks don't really contain the abilities(they are added separately), then any abilities inside the spellbook are still on the unit.
HOWEVER, since the spellbook hides all abilities "in" it, then you won't see them before you "open" the spellbook. That means that you can have passive abilities without an icon. In theory it also allows to cast hidden actives with triggers.
  • Unit - Order (Triggering unit) to Human Sorceress - Slow (Target unit of ability being cast)
ALSO, combined with the spellbook disable and "collision" bug it allows for more.
Since disabling abilities doesn't remove them(only hides and turns off), then you can use disabled spellbooks to add abilities to other spellbooks.

TheHelper about spellbooks

http://www.thehelper.net/threads/how-to-make-spellbooks.27637/
This is the only other tutorial about spellbooks that I know of. It is wrong in a few things.
Pasted:
------
WHY DO MY SPELLS DISAPPEAR FROM THE SPELLBOOK AFTER TRANSFORMATION/METAMORPHISM ETC.

This is because the abilities inside the spellbook are not permanent; they are gained via a spellbook.

To fix this issue, you must make the ability permanent. The only way is to use a piece of custom script because the action is not accessible via GUI:

JASS:
call UnitMakeAbilityPermanent(whichUnit, true, abilCode)
Replace whichUnit with the unit who has the ability and abilCode with the raw code of the ability.
------
This assumes that the game re-adds abilities each time that a unit morphs. This is not true, because a specific unit's abilities are tied to the unit instance, which does not change upon morphing.
So, the MakeAbilityPermanent function is actully fighting the consequences, not the cause.
------
HOW TO CAST SPELLS INSIDE A SPELLBOOK WITH TRIGGERS

There is no way to do that because there is no way to open the spellbook with triggers.
------
That is not true, because spellbooks are never really opened. They are an ability that shows/hides abilities.
That's also why you can't open it.
Casting spells inside a spellbook IS possible, but you simply won't know if they are in it.
EXAMPLE:
  • Unit - Order (Triggering unit) to Human Sorceress - Slow (Target unit ofability being cast)
Facts
*All abilities in a spellbook are contained in an array.
*When a spellbook is added to a unit the game checks for any abilities under the spellbooks base order ID, NOT rawcode. that's why spellbooks "collide".
*All abilities added because of spellbooks are tagged. The tag tells which spellbook the ability belongs to.
*Spellbook abilities are stored in a separate list that is associated with the ability rawcode.
*A spellbook can contain from 0-11 abilities. If the minimum is set lower than maximum and there are not enough slots for all abilities, then the abilities inside the spellbook are RANDOM. You can counter this by setting both minimum and maximum to 11.
*Even hero skills can be added to spellbooks and it will still be possible to level them like normally. However, they start at level 1.

Links
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/mysteries-spellbook-33039/
http://www.clancbs.com/downloads_seperate.php?id=348
http://www.wc3c.net/showthread.php?t=80186

If you know anything more about them, then tell. I am planning to make a tutorial on this.
Also, if you want help on using them, then just ask. I am sure that I can show how to do quite about anything.
 
Last edited:
Status
Not open for further replies.
Top