• 🏆 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!

[vJASS] Timer Bug?

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hi guys,

I am having strange issues involving a system that periodically sets a unit's fly height implemented in a spell. A snippet from the spell:

JASS:
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl", GetUnitX(target), GetUnitY(target)));
Height.change(target, 500.0, 500.0);
TimerStart(GetExpiredTimer(), 2.0, false, function thistype.lowerCaster);
A snippet from the height changing system:

JASS:
public static method change takes unit u, real h, real s returns thistype
    local thistype this = thistype.allocate()
    local real difference = GetUnitFlyHeight(u) - h
    
    if difference != 0.0 then
    
        set .target = u
        set .height = h
        set .speed = s
        set .increment = 0.03 * .speed
        call UnitAddAbility(.target, 'Amrf')
        call UnitRemoveAbility(.target, 'Amrf')
        
        if difference < 0.0 then
            call TimerStart(NewTimerEx(this), 0.03, true, function thistype.raise)
        else
            call TimerStart(NewTimerEx(this), 0.03, true, function thistype.lower)
        endif
        
    endif
    
    return this
endmethod
The issue is this: with the current code (as given above), the unit does not change it's height, but thistype.lowerCaster does execute (used a debug message). Then, if I comment out the one line as follows, the unit magically has its height changed:

JASS:
DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl", GetUnitX(target), GetUnitY(target)));
Height.change(target, 500.0, 500.0);
//TimerStart(GetExpiredTimer(), 2.0, false, function thistype.lowerCaster);

Any ideas? I will explain better if needed. [EDIT: Could it possibly be because the spell is in zinc but the system is in normal vJASS? I'm too lazy to rewrite either one of them to confirm :p]

Thanks,

Mr_Bean
 
Level 16
Joined
Aug 7, 2009
Messages
1,403
The given code seems okay, though I've already managed to break my code by passing wrong type of variables to index operators ([]). My compiler did not tell me about this syntax error, the map was running, but the code was broken and the spell/system stopped at random points. Then randomly commenting out something solved it.

Thus I'd recommend posting the full code in the main post. Maybe the problem slipped my attention, but it could be that the problem is not in this piece of the code.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
I'm fairly certain that I'm only passing integers into the index operators. I will check this and make sure though. Do you think it could be something going out of the array bounds?

The full code of the spell is quite long - about 350 lines. I will post it if I can't find the bug. Thanks for your help.

EDIT: I think I've solved the problem...I released the timer and then used it...so stupid :(
 
Status
Not open for further replies.
Top