• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Spellbook causes spell cast events to fire twice

Status
Not open for further replies.
Level 39
Joined
Feb 27, 2007
Messages
4,994
Was messing around making a demo map and used Roar ('Aroa') as a basic no-target ability when I noticed it was running all of my cast triggers twice. Weird, so I investigated and I found that the vast majority of the time a unit cast Aroa it ran all of the spell cast events for it twice. There were some times I was unable to reproduce this behavior, usually when casting Aroa immediately after another spell that does not have this bug.

I checked CAST, EFFECT, FINISH, and ENDCAST with the same behavior for all of them. In my attached test map you can select the spellbreakers to the right and order them to cast war stomp or roar (both unmodified), which then displays a message. The message shows the handle ID of the caster and the total number of cast events so far recorded since the map started. For Warstomp the message only appears once, but for Roar it shows twice with an increased count the second time!

This is happening because the spellbreakers also have the default spellbook ability which (you guessed it) includes Aroa in it. In short: casting a spell from outside a spellbook triggers the on-cast events an additional time if the spell is also inside the spellbook. It was my understanding that spellbooks were contained entities and that this kind of weird collision shouldn't happen. i.e spellbook A has CrippleA and spellbook B has CrippleB but I can cast each independently of one another by opening their books and casting from within them. What don't I know?

Not sure of the usefulness of this but... it's definitely a bug. I'm running 1.29.something so perhaps it just got fixed and I didn't know about it. Here's my example library and the map is attached:
JASS:
library RoarDoubleCast initializer Init

globals
   private integer Count = 0
endglobals

//unnecessary but it's here anyway
private function Conditions takes nothing returns boolean
   return true
endfunction

private function OnCast takes nothing returns nothing
   set Count = Count+1
   call BJDebugMsg("Caster: "+I2S(GetHandleId(GetTriggerUnit()))+", count: "+I2S(Count))
endfunction

private function Init takes nothing returns nothing
   local trigger Cast = CreateTrigger()
   call TriggerRegisterAnyUnitEventBJ(Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT)
   call TriggerAddCondition(Cast, Condition(function Conditions))
   call TriggerAddAction(Cast, function OnCast)
endfunction

endlibrary
 

Attachments

  • Test Fixed.w3x
    40 KB · Views: 28
Last edited:
Level 13
Joined
May 10, 2009
Messages
868
Well, I tested your map on 1.30.4 (1.30e), and the same problem still persists. Not only that, but the spell is, in fact, cast twice for every single aspect; mana consumption, spawned special effects. I even added a third spell book to the spell breaker unit type, added Aroa to it, and the event fired 3 times - just as expected. hehe
 
Don't know too much about spellbooks, but also just tested a bit. (patch 1.30.4)

Yeh, all spells that share order id seem to be fired (which actually seems normal to me), no matter if casted of inside a spellbook, or from a normally added spell.
Also, all spellbooks having one shared orderId go fully on cooldown with the casted spell, getting not useable during that cooldown.

Do you also have an example where you experienced the opposite, allowing to cast independently, with sharing same order id?

Xonok seems to strengthen the sharing-theory: The Theory Behind Spellbooks
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.

But he also notes:
Facts
...

*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
*call* @Xonok ^^
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
Well, I tested your map on 1.30.4 (1.30e), and the same problem still persists. Not only that, but the spell is, in fact, cast twice for every single aspect; mana consumption, spawned special effects. I even added a third spell book to the spell breaker unit type, added Aroa to it, and the event fired 3 times - just as expected. hehe
I checked and it works for non-targeted abilities only. With a unit/point target it just gets stuck trying to order the second cast without a target, while with a non-targeted spell it actually does get fully cast twice. I set War Stomp to deal 25 damage and with this way it dealt 50. This results in the lockout of that spell even though it visually does not appear to be cooling down, though the corresponding spell inside the book is castable at this time.

With a buff like Roar the visual display was... inconsistent. It used the buff icon (but not on the first cast where there was no buff icon shown) and damage increase values from the spell on the unit but the the attached buff special effect from the spell in the spellbook. Map below.
Do you also have an example where you experienced the opposite, allowing to cast independently, with sharing same order id?
No, it was just my understanding that spellbooks allowed for repeating base spells in this way such as to keep them separate. It seems I was wrong (?)
 

Attachments

  • Test Fixed.w3x
    41.6 KB · Views: 19
Status
Not open for further replies.
Top