Can Anyone see the problem???

Linconius

New Member
Reaction score
0
Can anyone see the problem in this code???

JASS:
scope FFScope initializer FFInitialize

    private function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
        if ( not ( GetSpellAbilityId() == 'A000' ) ) then
            return false
        endif
        return true
    endfunction

    private struct FFStruct
        unit TrigUnit
        player TrigPlayer
        integer Level
        real UnitX
        real UnitY
        real TargetX
        real TargetY
        real Angle
        effect Effect
    endstruct

    private function FFMove takes nothing returns nothing
    //Begin Variables
        local timer t = GetExpiredTimer()
        local FFStruct FFData = GetTimerData(t)
        local unit u
        local unit d
        local real h
        local real r
        local integer i
        local group g = NewGroup()
    //End Variables
        set FFData.UnitX = GetOffsetX(FFData.UnitX, FFData.Angle, 45.00)
        set FFData.UnitY = GetOffsetY(FFData.UnitY, FFData.Angle, 45.00)
        if GetDistanceXY(FFData.UnitX - FFData.TargetX, FFData.UnitY - FFData.TargetY) > 25.00 then
            call SetUnitVertexColor(FFData.TrigUnit, 255, 255, 255, 0)
            call SetUnitInvulnerable(FFData.TrigUnit, true)
            call PauseUnit(FFData.TrigUnit, true)
            call SetUnitXY(FFData.TrigUnit, FFData.UnitX, FFData.UnitY)
            call SetUnitFacing(FFData.TrigUnit, FFData.Angle)
            call SetTimerData(t, FFData)
        else
            call ReleaseTimer(t)
            call GroupEnumUnitsInRange(g, FFData.TargetX, FFData.TargetY, 250, null)
            loop
                call GroupRefresh(g)
                call DisplayTextToForce( GetPlayersAll(), "Stage 1" )
                set u = FirstOfGroup(g)
                call DisplayTextToForce( GetPlayersAll(), "Stage 2" )
                exitwhen u == null
                call DisplayTextToForce( GetPlayersAll(), "Stage 3" )
                if not IsUnitType(u, UNIT_TYPE_STRUCTURE) and /*
                 */not IsUnitType(u, UNIT_TYPE_MECHANICAL) and /*
                 */not IsUnitAlly(u, FFData.TrigPlayer) and /*
                 */not IsUnitAlive(u)  then
                    set h = SquareRoot(Pow(GetUnitX(u) - FFData.TargetX, 2) + Pow(GetUnitY(u) - FFData.TargetY, 2))
                    set i = i + 1
                    if h <= 100.00 then
                        set r = 200 * I2R(FFData.Level + 1)
                    else//           <---------------- here we do the math for each level rather than use ifs
                        set r = ((200 * I2R(FFData.Level + 1)) - (2 * I2R(FFData.Level + 1)) / 3 * (h - 100))
                    endif
                endif
                call DisplayTextToForce(GetPlayersAll(), "Stage 4")//<<<<<---------------------------------------------------STAGE 4
                call UnitDamageTarget(FFData.TrigUnit, u, r, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
                call DisplayTextToForce( GetPlayersAll(), "Stage 5" )
                call GroupRemoveUnit(g, u)
                call DisplayTextToForce( GetPlayersAll(), "Stage 6" )
            endloop
            call UnitApplyTimedLife(d, 'BTLF', 1.00)
            call SetUnitXY(FFData.TrigUnit, FFData.TargetX, FFData.TargetY)
            call SetUnitFacing(FFData.TrigUnit, FFData.Angle)
            call SetUnitVertexColor(FFData.TrigUnit, 255, 255, 255, 255)
            call SetUnitInvulnerable(FFData.TrigUnit, false)
            call PauseUnit(FFData.TrigUnit, false)
            call DestroyEffect(FFData.Effect)
            call SFXExpire(3.00, AddSpecialEffect("war3mapImported\\IceNova.mdx", FFData.TargetX, FFData.TargetY))
            if i > 0 then
                call UnitDamageTarget(FFData.TrigUnit, FFData.TrigUnit, 200 * (FFData.Level + 1), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
            endif
        endif
        call SelectUnitForPlayerSingle(FFData.TrigUnit, FFData.TrigPlayer)
        call ReleaseGroup(g)
        call FFData.destroy()
        set u = null
        set g = null
        set t = null
    endfunction

    private function FFActions takes nothing returns nothing
        local timer t = NewTimer()
        local FFStruct FFData = FFStruct.create()
        set FFData.TrigUnit = GetTriggerUnit()
        set FFData.TrigPlayer = GetTriggerPlayer()
        set FFData.UnitX = GetUnitX(FFData.TrigUnit)
        set FFData.UnitY = GetUnitY(FFData.TrigUnit)
        set FFData.TargetX = GetSpellTargetX()
        set FFData.TargetY = GetSpellTargetY()
        set FFData.Level = GetUnitAbilityLevel(FFData.TrigUnit, GetSpellAbilityId())
        set FFData.Angle = GetAngleXY(FFData.UnitX, FFData.UnitY, FFData.TargetX, FFData.TargetY)
        call SetUnitVertexColor(FFData.TrigUnit, 255, 255, 255, 0)
        call SetUnitInvulnerable(FFData.TrigUnit, true)
        call PauseUnit(FFData.TrigUnit, true)
        set FFData.Effect = AddSpecialEffectTarget("", FFData.TrigUnit, "")
        call SFXExpire(3.00, FFData.Effect)
        call SelectUnitForPlayerSingle(FFData.TrigUnit, FFData.TrigPlayer)
        set t = NewTimerEx(FFData)
        call TimerStart(t, 0.03, true, function FFMove)
        call FFData.destroy()
        set t = null
    endfunction

    //===========================================================================
    private function FFInitialize takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( t, Condition( function Trig_Untitled_Trigger_001_Conditions ) )
        call TriggerAddAction(t, function FFActions)
    endfunction

endscope


This code compiles with no syntax errors, yet when the skill is used, the loop gets to stage 4 on its first run, then just... stops.

Try compiling and playing the map yourself, it doesn't work :-S

Please help if you know the problem.
 

Attachments

  • linTest.w3x
    37.3 KB · Views: 219
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top