HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

JASS Tutorial Omnislash Problem

05-24-2008, 09:37 AM#1
TGhost
Earlier today I started the JASS Tutorials made by some users from this site (the 7 lesson course thingy), and I got stuck on the last lesson, where you create an omnislash spell.
Now, I tryed some different things, and it seems like the problem is, that the trigger is never actually called. It looks like this:
Collapse JASS:
function Slash_Condition takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function Slash_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local location start_position = GetUnitLoc(caster)
    local group enemies = CreateGroup()
    local unit temp
    local integer max = 5
    local location tempLoc
    call BJDebugMsg("Trigger Called")
    call GroupEnumUnitsInRangeOfLoc(enemies, start_position, 500.00, null)
    loop
        set temp = FirstOfGroup(enemies)
        call BJDebugMsg("Unit Found")
        exitwhen temp == null or max == 0
        if IsUnitEnemy(temp, GetOwningPlayer(caster)) then
            set tempLoc = GetUnitLoc(temp)
            call SetUnitPositionLoc(caster, tempLoc)
            call UnitDamageTarget(caster, temp, 50.0, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
            call TriggerSleepAction(0.5)
        endif
        call GroupRemoveUnit(enemies, temp)
        set max = max-1
    endloop
    call SetUnitPositionLoc(caster, start_position)
    set caster = null
    call RemoveLocation(tempLoc)
    call RemoveLocation(start_position)
    set tempLoc = null
    set start_position = null
    call DestroyGroup(enemies)
    set enemies = null
endfunction

function InitTrig_Slash takes nothing returns nothing
    local trigger gg_trg_Slash = CreateTrigger() 
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Slash, Condition(function Slash_Condition))
    call TriggerAddAction(gg_trg_Slash, function Slash_Actions)
    set gg_trg_Slash = null
endfunction
But the "Trigger Called" string is never actually displayed, so it would seem like the trigger is not actually called at all. Anyone able to see the problem here?

EDIT: Oh, yes. I did check that the ability id is 'A000', so that shouldn't be the issue.

EDIT2: I found out the problem... The trigger wasn't called Slash, so that was the issue...
05-24-2008, 03:48 PM#2
darkwulfv
Well, glad you figured that out. I probably wouldn't have been able to help, as I didn't make that particular lesson =p

Oh, and by the way, that call TriggerSleepAction(0.5) should probably be call PolledWait(.5), so that the spell doesn't run during lag/game pauses/etc.
05-24-2008, 08:07 PM#3
Silvenon
There shouldn't be any TriggerSleepActions or PolledWaits if you know how to code (PolledWait leaks btw, but who cares).
05-24-2008, 09:10 PM#4
TGhost
Quote:
Originally Posted by darkwulfv
Well, glad you figured that out. I probably wouldn't have been able to help, as I didn't make that particular lesson =p

Oh, and by the way, that call TriggerSleepAction(0.5) should probably be [jass]call PolledWait(.5)[/ljass], so that the spell doesn't run during lag/game pauses/etc.

Okay, I'll change that... And thanks for replying.
About the "if you know how to code", you mean you want me to use a timer for something like that? But wouldn't that require me to create a whole new function, that the timer calls on expiring, saving all the variables for retrieval in the new function and everything?
Or do you have another way of doing it?
05-24-2008, 09:29 PM#5
darkwulfv
I think he means timers. But for new coders, what you're doing isn't terrible. (It's not running 10000 times per second or anything), but try to get into the habit of using timers. (and structs)
05-24-2008, 10:42 PM#6
Ignitedstar
It's not exactly relevant, but I do have a question: Why use timers instead of waits? To me, they serve the same function.
05-24-2008, 11:20 PM#7
darkwulfv
Honestly, I'm not sure. Unless you need to wait less than .27 seconds, I guess it wouldn't matter. I mean, maybe there's some efficiency difference, but it would only be major if the spell (or whatever) was used like, 100 times a second. Oh, and apparently "PolledWait" leaks, but the leak is probably so freaking minor that it would only be noticed if you used them a LOT, for a LONG time.
05-24-2008, 11:29 PM#8
grim001
Waits aren't accurate and cause major game problems (units unresponsive) if lots of them are happening at once. They also don't function at intervals lower than ~0.27. You need much lower intervals for decent looking animation.
05-24-2008, 11:44 PM#9
darkwulfv
Waits are actually fairly accurate, I've never had a very big problem with them. But if you're doing anything below .27 you need timers. Otherwise, waits are fine.

I dunno why you'd be using a ton of them at once anyways.
05-24-2008, 11:50 PM#10
Vexorian
Quote:
Originally Posted by grim001
Waits aren't accurate and cause major game problems (units unresponsive) if lots of them are happening at once. They also don't function at intervals lower than ~0.27. You need much lower intervals for decent looking animation.
huh do you have an estimate on the number of waits necessary to do that ?
05-25-2008, 12:12 AM#11
grim001
It happened when I was using a system a long while ago that put every dead unit into a wait loop. When there were 100+ corpses, every unit in the game started to act unresponsive. When I took the wait out the problem stopped. I can't seem to replicate it in a demo map, though.
05-25-2008, 12:18 AM#12
Vexorian
It's odd cause my demo map engine does the same thing, and it would be the only explanation for a locking up bug with my Guardian after some time is elapsed, I think it is the first time I test the old demo map engine in a map with so many creep camps.