- Joined
- Feb 27, 2007
- Messages
- 5,578
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:
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
Last edited: