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

[JASS] Jump Spell not working properly

Status
Not open for further replies.
Level 10
Joined
Sep 29, 2006
Messages
447
I'm trying to create a basic jump spell where the blademaster leaps to a target point and does damage in an area. The hero never does any damage, but he jumps and slides appropriately. The function ClimFilter() is never entered for whatever reason (it is called by the GroupEnumUnitsInRange() function).

Please note that I CANNOT use any third party programs, I'm on a mac. This needs to be resolved using the vanilla editor only.

Here's the trigger:

JASS:
function ClimhazzardConditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00D'
endfunction

function ClimFilter takes nothing returns boolean
    local unit caster = udg_globalCaster
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    local unit target = GetFilterUnit()
    local real x2 = GetUnitX(target)
    local real y2 = GetUnitY(target)
    local real physDmg = 150. + I2R(50 + GetUnitAbilityLevel(caster, 'A00D'))
    local real mgcDmg = 50. + I2R(50 + GetUnitAbilityLevel(caster, 'A00D'))
    local real dist = Distance(x, y, x2, y2)

    call BJDebugMsg("ClimFilter entered") //debugging /* text is never displayed, therefore function never entered! */
    if (GetUnitState(target, UNIT_STATE_LIFE) > 0  and IsUnitType(target, UNIT_TYPE_GROUND) and IsUnitEnemy(target, GetOwningPlayer(caster))) then
        call UnitDamageTarget(caster, target, mgcDmg, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        if (dist <= 100.) then
            call UnitDamageTarget(caster, target, physDmg, true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        endif
    endif

    set target = null
    set caster = null
    return false
endfunction

function ClimCallback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local unit caster = LoadUnitHandle(udg_hash, id, 0)
    local real distance = LoadReal(udg_hash, id, 1)
    local real angle = LoadReal(udg_hash, id, 2)
    local real count = LoadReal(udg_hash, id, 3)
    local real slideDist = 30.
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    local real flyHeight = GetUnitFlyHeight(caster)
    local group g

    if (count < distance/2.) then
        call SaveReal(udg_hash, id, 3, count + slideDist)
        call SlideKeepOrder(caster, slideDist, angle, "")
        call SetUnitFlyHeight(caster, flyHeight + 50., 0.)
    elseif (count > distance/2. and count < distance) then
        call SaveReal(udg_hash, id, 3, count + slideDist)
        call SlideKeepOrder(caster, slideDist, angle, "")
        call SetUnitFlyHeight(caster, flyHeight - 50., 0.)
    else
        call PauseTimer(t)
        call DestroyTimer(t)
        set udg_globalCaster = caster
        call SetUnitFlyHeight(caster, 0., 0.)
        call SetUnitTimeScale( udg_globalCaster, 1.00 )
        call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", caster, "origin"))
        call MoveRectTo(udg_destructibleRect, x, y)
        call EnumDestructablesInRect(udg_destructibleRect, Filter(function KillDestructables), null)
        call GroupEnumUnitsInRange(g, x, y, 300., Filter(function ClimFilter))
        call BJDebugMsg("enemies should be grouped") //debugging  /* this function isn't entered! */
        call FlushChildHashtable(udg_hash, id)
    endif

    call DestroyGroup(g)
    set g = null
    set t = null
    set caster = null
endfunction

function ClimhazzardActions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    local real x2 = GetSpellTargetX()
    local real y2 = GetSpellTargetY()
    local real distance = Distance(x, y, x2, y2)
    local real angle = GetAngle(x, y, x2, y2)
    local real count = 0
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)

    call UnitAddAbility(caster, 'Amrf')
    call UnitRemoveAbility(caster, 'Amrf')
    call SetUnitTimeScale( udg_globalCaster, 0.65 )

    call SaveUnitHandle(udg_hash, id, 0, caster)
    call SaveReal(udg_hash, id, 1, distance)
    call SaveReal(udg_hash, id, 2, angle)
    call SaveReal(udg_hash, id, 3, count)
    call TimerStart(t, .02, true, function ClimCallback)

    set caster = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Climhazzard takes nothing returns nothing
    local trigger trigClimhazzard = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trigClimhazzard, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trigClimhazzard, Condition( function ClimhazzardConditions ) )
    call TriggerAddAction( trigClimhazzard, function ClimhazzardActions )
    set trigClimhazzard = null
endfunction

Help is appreciated.
 
So I assume:
JASS:
    else
        call PauseTimer(t)
        call DestroyTimer(t)
        set udg_globalCaster = caster
        call SetUnitFlyHeight(caster, 0., 0.)
        call SetUnitTimeScale( udg_globalCaster, 1.00 )
        call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", caster, "origin"))
        call MoveRectTo(udg_destructibleRect, x, y)
        call EnumDestructablesInRect(udg_destructibleRect, Filter(function KillDestructables), null)
        call GroupEnumUnitsInRange(g, x, y, 300., Filter(function ClimFilter))
        call BJDebugMsg("enemies should be grouped") //debugging  /* this function isn't entered! */
        call FlushChildHashtable(udg_hash, id)
    endif

That portion is never called? Well, instead of doing the whole count > dist and whatnot thing, you should try using a parabola function:
http://www.thehelper.net/forums/showthread.php?t=106212

This way, you can just check when the distance is < 35 and it will provide easier checks. Try replacing it with that and it might work.
 
Level 10
Joined
Sep 29, 2006
Messages
447
JASS:
        call GroupEnumUnitsInRange(g, x, y, 300., Filter(function ClimFilter))
        call BJDebugMsg("enemies should be grouped") //debugging  /* this function isn't entered! */
        call FlushChildHashtable(udg_hash, id)
    endif

Actually, only this portion is never executed. Any idea why? Everything up until the GroupEnumUnitsInRange() functions works properly. I will look into that parabola function though.
 
Last edited:
Level 10
Joined
Sep 29, 2006
Messages
447
Why do you move the region and make no use of it? You could use instead of GroupEnumUnitsInRange, the GroupEnumUnitsInRect and filter them.

The rect is moved and then the next line uses it to destroy all destructibles in the rect. I wouldn't use the rect for units because, a) it's not large enough, and b) rects are square, I want a circle.

For whatever reason, no matter what function I put in the Filter() for GrouEnumUnitsInRange() it is never executed, and depending on where I put the enum function, all functions after it do not execute. It's very strange. Help please.

Edit: When I comment out GroupEnumUnitsInRange() I reach the BJDebugMsg(), so clearly something is wrong with the group enumeration. Anyone have any ideas?
 
Status
Not open for further replies.
Top