Thread: SpellEvent
View Single Post
Old 04-10-2009, 03:13 PM   #11
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Quote:
set u = GetSpell.TargetUnit()
That's still blizz like stuff. I would wish this used arguments, you know, if you specified what responses you'd like, then arguments would be possible, maybe too hard.

Quote:
Well, first of all, do event responses still work when you call a function via .evaluate/.execute?
All but GetTriggeringTrigger.

Quote:
Second, how would reading a global array consume more time than calling an event response?
I don't care about speed, it is more about having to remember brand new event response names.

Quote:
Well, unless I require users to specify for every single spell what event responses it is expected to use (which I don't think is very practical)
I actually think it is practical, could use bitflags, well bitflags could be a little slow.

What annoys me the most is thelocation call, the others are in theory not that bad. Also, why store it as location? It could at least be helpful if it converted it to x,y already. It would be nice if you could tell it not to call the location thing.

Quote:
local spellEvent s=spellEvent.allocate()
set s.spellId=GetSpellAbilityId()
set s.caster=GetTriggerUnit()
set s.target=GetSpellTargetUnit()
set s.targetItem=GetSpellTargetItem()
set s.targetDest=GetSpellTargetDestructable()
set s.targetLoc=GetSpellTargetLoc()
set s.finished=false
Well, most of the times, you don't need any of them and could use the responses directly (SPELL_EFFECT/CAST) , the other times, you don't need all of them.

Guess spellId and caster are constants, but there are only 4 other things, it is not that bad:

Collapse JASS:
struct targetType extends array
    static constant integer Unit         = 1
    static constant integer Item         = 2
    static constant integer Destructable = 4
    static constant integer Widget       = 7
    static constant integer Point        = 8
endstruct

//...
call SpellEvent_RegisterFinishResponse(ABILITY_ID,  targetType.Unit +targetType.Item) //maybe it hits both things?

//...
            local spellEvent s=spellEvent.allocate()
            set s.spellId=GetSpellAbilityId()
            set s.caster=GetTriggerUnit()
            if ( flag >= 8) then
                  set s.targetLoc=GetSpellTargetLoc()
                  set flag=flag-8
            endif
            if ( flag >= 4) then
                  set s.targetDest=GetSpellTargetDestructable()
                  set flag=flag-4
            endif
            if ( flag >= 2) then
                  set s.targetItem=GetSpellTargetItem()
                  set flag=flag-2
            endif
            if ( flag >= 1) then
                  set s.target=GetSpellTargetUnit()
            endif

            set s.finished=false
            set spellEvent.casterTable[s.caster]=integer(s)
            return s


Just suggesting here.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote