HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spellbook keeps visible?!?

10-25-2007, 04:48 PM#1
XieLong
I have created a Spell which grants the user a kind of activable 'thorn shield' (of the Crypt Lord). The activation-ability is immolation. I made this trigger, to add a spellbook with the thorn shield inside when the immolation is activated:
Code:
Thorn Shield Activation
    Events
        Unit - A unit Is issued an order with no target
    Conditions
        (Issued order) Equal to Night Elf Demon Hunter - Activate Immolation
    Actions
        Unit - Add Spellbook (Thorn Shield) to (Ordered unit)
        Unit - Set level of Spellbook (Thorn Shield) for (Ordered unit) to (Level of Thorn Shield [Nature] for (Ordered unit))
        Player - Disable Spellbook (Thorn Shield) for (Owner of (Ordered unit))
The adding works fine, but there is the problem that the spellbook keeps visible although i deactivated it.
There is another trigger for the deactivation of the immolation:
Code:
Thorn Shield DeActivation
    Events
        Unit - A unit Is issued an order with no target
    Conditions
        (Issued order) Equal to Night Elf Demon Hunter - Deactivate Immolation
    Actions
        Unit - Remove Spellbook (Thorn Shield) from (Ordered unit)
Can someone tell me, why the spellbook keeps visible?

I don't know if it is important, but the hero have also another spellbook (the whole time, which is visible). But both spellbooks have different 'BasicOrderIds'...
10-25-2007, 07:10 PM#2
moyack
I had the same problem and according to this tutorial (http://www.wc3campaigns.net/showthread.php?t=81742), you must disable the spellbook at map initialization, not when the unit cast the ability.

This is the part related to SpellBooks:
Quote:
Originally Posted by The Warcraft III Ability Guide
Aspb (Spellbook): The spellbook is basically a container for up to 11 other abilities. It can hold active spells as well as autocast and passive spells and even hero skills. The first wonderful thing about the spellbook is that it gives you the effect of passive abilities in it even if the spellbook ability itself is disabled for the player. So it can be used to hide the icon of whichever passive ability you want and to save slots on the command card. The other wonderful thing is that you can add spells to a spellbook at runtime and remove them again. That is done by giving the unit a second spellbook with the spell that should be added and disabling this second spellbook. That way the skill will show up on the first spellbook but the second one can't be seen on the unit. To make this work both spellbook abilities must have the same base order id. For each skill you want to add at runtime you will need such an adder ability. The third cool thing is that hero abilities in spell books are levelable via the levelup menu. The problem is that they will start at level 1 and not at level 0 if they are in the spellbook from the beginning. That's easy to fix with triggers. Just normally give them to the hero first in the object editor. Then catch when level 1 is learned, remove the skill and add it to the spellbook.

Collapse JASS:
function Learn_Actions takes nothing returns nothing
  if GetLearnedSkillLevel() == 1 and GetLearnedSkill() == <hero skill> then
    call UnitRemoveAbility(GetTriggerUnit(), GetLearnedSkill())
    call UnitAddAbility(GetLearningUnit(), <adder spellbook ability>)
    call MakeUnitAbilityPermanent(u, <adder spellbook ability>)
    call MakeUnitAbilityPermanent(u, <ability inside spellbook>)
  endif
endfunction

function Learn takes nothing returns nothing
  local trigger t = CreateTrigger()
  call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_SKILL)
  call TriggerAddAction(t, function Learn_Actions)
endfunction
Of course the adder ability has to be disabled from the beginning for the owner of the unit. To prevent bugs the number of minimum skills in a spellbook should equal the maximum number of skills. Unfortunately there are also some tiny problems. Active abilities in spellbooks can't be used from triggers it seems. Also the tome of retraining will totally mess your system up if you have hero skills in the spellbook. And spells added at runtime won't turn the spellbook icon blue if there's not enough mana. But these small drawbacks usually don't matter.
10-25-2007, 07:44 PM#3
XieLong
Unfortunately doesn't work this either ;_;
i am despaired...
10-26-2007, 12:02 PM#4
Malf
Umm, you disable a Spellbook ability, let's call it SB1. Then make another spellbook ability, let's call it SB2.

Now add SB1 to your hero in Object Editor, under normal skills.
Now add the thorn shield ability to SB2 in Object Editor. To add it, click on SB2 and scroll down its data field until you see a field named something like "Data - Spell List" Double click that and select your thorn shield ability.

Now everything is set, we must add SB2 whenever your hero casts your immolation ability.

Trigger:
Thorn Shield Activation
Collapse Events
Unit - A unit Is issued an order with no target
Collapse Conditions
(Issued order) Equal to Night Elf Demon Hunter - Activate Immolation
Collapse Actions
Unit - Add SB2 (Second Spellbook) to (Ordered unit)
Unit - Set level of SB2 (Second Spellbook) for (Ordered unit) to (Level of Thorn Shield [Nature] for (Ordered unit))
Player - Disable SB2 (Second Spellbook) for (Owner of (Ordered unit))
Trigger:
Thorn Shield DeActivation
Collapse Events
Unit - A unit Is issued an order with no target
Collapse Conditions
(Issued order) Equal to Night Elf Demon Hunter - Deactivate Immolation
Collapse Actions
Unit - Remove SB2 (Second Spellbook) from (Ordered unit)

EDIT: I would also like to point out to you something you should know about Immolation, especially if your immolation ability costs mana per second.

When you run out of mana, Immolation is deactivated, BUT your hero will NOT be ordered to deactivate immolation. So be very careful about that.
10-26-2007, 02:26 PM#5
XieLong
I don't really get your point: The triggers are the same as mine... and why should i create another spellbook (SB1), just to disable it?
10-26-2007, 03:13 PM#6
Malf
You create another spellbook just to disable it at start because you can't disable it when the unit casts the spell.

Just follow the steps I told you and you should be fine.
10-30-2007, 10:11 PM#7
XieLong
Perhaps I'm just to dump, but it doesn't work anyway -.-
What I've done:
- Created a Spellbook(empty)
- Added the Spellbook(empty) to my hero (within OE)
- Disabled Spellbook(empty) at Map Initialization/0.01 Seconds (tried both)
- Disabled the Spellbook(Thorn Shield) on cast

but it doesn't work... i dont get it, cause none of the Spellbooks disappears... and i dont have a plan why not! It's very strange, cause i already have had a spell (in another map) which works fine:
Trigger:
Propaganda Trommel
Collapse Events
Unit - A unit Learns a skill
Collapse Conditions
(Learned Hero Skill) Equal to (Custom Ability Propaganda Trommel )
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Spellbook (Mob Führer) for (Learning Hero)) Greater than 0
Collapse Then - Actions
Unit - Set level of Spellbook (Mob Führer) for (Learning Hero) to (Learned skill level)
Collapse Else - Actions
Unit - Add Spellbook (Mob Führer) to (Learning Hero)
Player - Disable Spellbook (Mob Führer) for (Owner of (Learning Hero))
/\ works perfect...

€: Ok, i dont know really why, but now all works fine (without secondary SB etc) *close*