[JASS] Can't find the Issue.

Status
Not open for further replies.
Level 1
Joined
Dec 6, 2016
Messages
5
I was trying to create a Ravage spell version and for some reason the loop isn't working well. Using 1.30v
JASS:
function RavageLoop takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer i = GetHandleId(t) - 1048576
    local integer r = 0
    local unit u = udg_RavageCaster[i]
    local real x = udg_RavageX[i]
    local real y = udg_RavageY[i]
    local unit u2
    local unit u3
    local real ux
    local real uy
    local real d
    local real arc
    local real dy
    local real dx
    local player p = GetOwningPlayer(u)
    local group g = CreateGroup()
        if udg_RavageTime[i] < 1.00 then
             set udg_RavageTime[i] = udg_RavageTime[i] + 0.2
             set d = udg_RavageRange[i]
             set udg_RavageRange[i] = udg_RavageRange[i] + 212.5
             call GroupEnumUnitsInRange( g, x, y, udg_RavageRange[i], null)
             loop
                 set u2 = FirstOfGroup(g)
                 exitwhen u2 == null
                 call GroupRemoveUnit(g, u2)
                 if ( IsUnitType(u2, UNIT_TYPE_STRUCTURE) != true ) and IsUnitAliveBJ(u2) and IsUnitEnemy(u2, p) and (IsUnitInGroup(u2, udg_AirKnokbackUnits) != true)  then
                       set ux = GetUnitX(u2)
                       set uy = GetUnitY(u2)
                       call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Undead\\Impale\\ImpaleHitTarget.mdl", ux, uy ))
                       call UnitDamageTarget( u, u2, udg_RavageDamage[i], true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null )
                       call UnitAddAbility( u2, 'Amrf' )
                       call GroupAddUnit( udg_AirKnokbackUnits, u2 )
                       call AirKnockBackStart( u2, 400, 1.00)
                       call SetUnitPathing( u2, false )
                       call UnitRemoveAbility( u2 , 'Amrf' )
                       set u3 = CreateUnit( p, 'u001', ux, uy, 0)
                       call UnitAddAbility( u3, 'A001')
                       call IssueTargetOrder( u3, "firebolt", u2)
                       call UnitApplyTimedLife( u3, 'BTLF', 1.00 )
                  endif
              endloop
                 //call EnumRavageUnits( u, udg_RavageDamage[i], udg_RavageX[i], udg_RavageY[i], udg_RavageRange[i])
              loop
                   set r = r + 1
                   exitwhen r == 19
                   set arc = Deg2Rad(20*r)
                   set dy = udg_RavageY[i] + udg_RavageRange[i]*Sin(arc)
                   set dx = udg_RavageX[i] + udg_RavageRange[i]*Cos(arc)
                   call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Undead\\Impale\\ImpaleMissTarget.mdl", dx, dy ))
               endloop
        else
             call PauseTimer(t)
             call DestroyTimer(t)        
        endif
        set u = null     
        set t = null
        call DestroyGroup(g)
        set p = null
        set g = null
endfunction

All in this function works very well except for the first loop , who for some reason is working very very very glitchy even when I can't see any problem with it, pls someone help.
 

Attachments

  • Ravage.w3x
    40.4 KB · Views: 30
Last edited:
Level 1
Joined
Dec 6, 2016
Messages
5
Sadly the map hasn't any type of Damage engine, is made just for showing the troublesome loop.
If you download the map and try the spell you will notice that it works very strange, ignoring even conditions, so in other words, I have no idea what is happening with it.
 
After some tests, I suspect that the following function might cause such buggy behavior:

JASS:
function AirKnockBackStart takes unit u, real highmax, real time returns nothing

The unit ends up getting added to the knockback group a LOT of times, due to the fact that there are no functional safety checks performed by the function. (Check if the unit is already in the knockback group).

 
Level 1
Joined
Dec 6, 2016
Messages
5
Okey I fix it and it wasn't a group issue but a weird unnecessary change with this function
JASS:
if udg_AirKnock_TimeCurrent[i] < udg_AirKnock_Time[i]  then
     set udg_AirKnock_TimeCurrent[i] = ( udg_AirKnock_TimeCurrent[i] + 0.03125 )
     if ( udg_AirKnock_TimeCurrent[i] < ( udg_AirKnock_Time[i] / 2.00 )) then
          set rate = ( ( udg_AirKnock_HeighMax[i] - udg_AirKnock_Heigh[i] ) * 0.15 )
          set udg_AirKnock_Heigh[i] = ( udg_AirKnock_Heigh[i] + rate )
          call SetUnitFlyHeight( u, udg_AirKnock_Heigh[i], 0.00 )
     else
          set rate = ( ( udg_AirKnock_HeighMax[i] - udg_AirKnock_Heigh[i] ) * 0.18 )
          set udg_AirKnock_Heigh[i] = ( udg_AirKnock_Heigh[i] - rate )
          call SetUnitFlyHeight( u, udg_AirKnock_Heigh[i], 0.00 )
     endif      
endif
if udg_AirKnock_TimeCurrent[i] >= udg_AirKnock_Time[i] then
     call GroupRemoveUnit( udg_AirKnokbackUnits, u )
     call SetUnitFlyHeight( u, 0.00, ( rate * 100.00 ) )
     call SetUnitPathing( u, true )
     set udg_AirKnock_Heigh[i] = 0
     set udg_AKB_Target[i] = null
     call PauseTimer(t)
     call DestroyTimer(t)
     set t = null
     set u = null
endif

I just added an extra "if" when it can be replaced with a "else", being honest I can't understand why this change ruins all the function but good thing it was fixed.
 
Status
Not open for further replies.
Top