- Joined
- Mar 27, 2012
- Messages
- 3,232
An in-depth explanation on spellbooks
This is everything that I know about them.
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
- Wrong
- 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.
Note that this tutorial is not meant to teach you how to do everything with them, but only the mechanics behind them. Thus, I will not show every way of using them here, only tell. If I showed everything this tutorial would become very long.
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, as long as another spellbook with the same ID hasn't added them already. .
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 morphs(bear form, chaos, chemical rage) 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)
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)
Since disabling abilities doesn't remove them(only hides and turns off), then you can use disabled spellbooks to add abilities to other spellbooks.
The Spellbook close... thing:
When your unit has a spellbook opened and you add another spellbook with the same ID, then the spellbook closes.
Possible use: Forcefully closing spellbooks.
The spellbook inventory bug:
Imagine a hero unit with usual hero inventory. This unit has 6 item slots.
What if you would add a spellbook with another(or the same) inventory ability?
Well, the answer is: You get 6 more slots.
The slots added this way work like sheets. Each ability has a separate sheet of slots - you can't make 6 slots by adding 2 abilities of 3 slots each.
This bug can be used to create systems for extended inventory, where each item still works as normal, except that unseen items can't be used.
However, the downside is that taking away items from secret slots doesn't remove them from the hero, so they can't be picked up and they still give the stat bonuses to the hero.
Solution: Delete the item and create a new one.
Ability slot bug:
When multiple abilities are added to the same slot in a spellbook, then their positions change. This also applies to simply adding abilities to units.
However, with spellbooks there is the distinct difference, that when usually you can just change the ability position in object editor, then in a spellbook you can not.
Furthermore, the position changes apply to that ability in all spellbooks, not just that one.
The way to fix it is here.
Abilities in a spellbook are always added from left to right and from up to down. The object editor positions do not matter. Furthermore, since spellbooks on a unit are actually stored through the base order ID and not the rawcode of the spellbook, then shared spellbooks also collide here.
For instance, if you add the first spellbook that has 3 abilities, then the abilities are put in slots 0-2.
When you now add another spellbook, with another 3 abilities, then it will once again try to put them in slots 0-2, but the positions collide, which creates havoc.
For instance, if you add the first spellbook that has 3 abilities, then the abilities are put in slots 0-2.
When you now add another spellbook, with another 3 abilities, then it will once again try to put them in slots 0-2, but the positions collide, which creates havoc.
----------
TheHelper about spellbooks
------
TheHelper
------
My explanation
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)
------
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 actually fighting the consequences, not the cause. What you really should do is making a copy of the spellbook for the morphed unit.
------
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. But you can(probably) order the unit to use the spellbook ability.
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)
It turns out, that if you assign a hotkey to the spellbook and then order the player to press that key, like this:
- Game - Force Player 1 (Red) to press the key A
Note that you should still make sure that player has this unit selected, and no other, to prevent unwanted effects.
With a little thinking I came to the conclusion that it's also possible to close all spellbooks, with 2 simple actions.
- Selection - Clear selection for Player 1 (Red)
- Selection - Select (Triggering unit) for Player 1 (Red)
----------
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 spellbook's base order ID, NOT rawcode. that's why spellbooks "collide".
*All abilities added by spellbooks are tagged. The tag tells which spellbook the ability belongs to. However, it only remembers the order ID, not the rawcode of the spellbook.
*Spellbook abilities are stored in a separate list that is associated with the ability rawcode.
*A spellbook can contain from 0-12 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.
*If a spellbook contains more than 11 abilities, then the cancel button might get pushed off the command card.
*Abilities in spellbooks don't fully collide with abilities in other spellbooks, even when the order IDs are the same. This means that you can have multiples of the same castable ability on the same unit, without any major bugs. Explanation
Wrong
has been claimed, but proven false. *When a spellbook is removed, then the game removes all other spellbooks that have the same ID. Proof
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
http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/set-spell-ui-position-spellbook-240242/
If you know anything more about them, then please tell.
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: