What seems to be a weird problem

Tinki3

Special Member
Reaction score
418
Note

Just before anyone asks, this code is for a spell request.
The requester requested the local handle vars system to be used.

The spell creates a number of treants that orbit the caster for a duration,
knocking any enemies they collide with backwards.

The problem

PJASS gives me 82 compile errors for this code.
Why? Well, that is what I'm trying to work out, currently.

The first error starts inside the Knockback function from the line: exitwhen d.k == null (inside the loop), which is a syntax error.
All other errors continue along the Knock function, and right the way through the Rotate_Plants function.

I can't see what the problem is here, though it seems struct-related.
All the code seems as it should be, fine, unless I've missed something.

Any ideas?

JASS:
scope CorruptedPlantShield

globals
    //Raw Codes
    private constant integer CPS_Ability_ID = 'A005'  //Raw code of "Corrupted Plant Shield" spell
    private constant integer Corrupted_Plant_ID = 'u000'  //Raw code of "Corrupted Plant (Corrupted Plant Shield)" unit
    //Configuration Globals
    private constant integer No_of_Plants = 5  //No. of plants to fly around caster
    private constant boolean Destroys_Objects = true  //Set to false to not destroy objects
    private constant string SFX_Path = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdl"  //Created on plants initially
    private constant string SFX_Path2 = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl"  //Created on enemies when affected by spell
    private constant string SFX_Path3 = "Abilities\\Weapons\\ChimaeraAcidMissile\\ChimaeraAcidMissile.mdl"  //Created on the plants for duration of spell
    private constant string SFX_Path4 = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"  //Created on enemies when affected by spell
    private constant real AoE = 140.0  //Area-radius in which enemies are picked to be affected by spell
    private constant real Plant_Dist = 180.0  //Range-offset of plants from caster
    private constant real Rotate_Speed = 7.7  //Speed in which plants orbit caster
    private constant real Duration = 25.0  //Time in secs spell lasts
    private constant real Knockback_Dist = 300.0  //Distance enemies are knocked
    private constant real Knockback_Speed = 25.0  //Speed enemies are knocked-back at
endglobals

private struct dat
    unit u = GetTriggerUnit()
    unit array plant[50]
    real array ang[50]
    real count = Duration
    real Dmg
    effect array sfx[50]
    group dmg = CreateGroup()
    integer c = 1
    unit k[250]
    real dist[250]
    real speed[250]
    real Ang[250]
endstruct

//Damage calculation
private function Damage takes real lvl returns real
    return lvl * 75
endfunction

private function GG_Objects takes nothing returns nothing
    call KillDestructable(GetEnumDestructable())
endfunction

private function filter takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(bj_ghoul[489])) and IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) != true and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true and GetWidgetLife(GetFilterUnit()) > 0.405
endfunction

private function Knockback takes nothing returns nothing
    local timer T = GetExpiredTimer()
    local dat d = dat(GetHandleInt(T, "d"))
    local integer i = 1
    local real X
    local real Y
    local real PX
    local real PY
    local rect R

    loop
        exitwhen d.k<i> == null
        set X = GetUnitX(d.k<i>)
        set Y = GetUnitY(d.k<i>)
        set PX = X + d.speed<i> * Cos(d.Ang<i> * bj_DEGTORAD)
        set PY = Y + d.speed<i> * Sin(d.Ang<i> * bj_DEGTORAD)
        set d.dist<i> = d.dist<i> - d.speed<i>
        set d.speed<i> = d.speed<i> * 0.93    
        if d.dist<i> &gt; 0 then
            if Destroys_Objects == true then
                set R = Rect(PX-120, PY-120, PX+120, PY+120)
                call EnumDestructablesInRect(R, null, function GG_Objects)
                call RemoveRect(R)
                set R = null
            endif
            call SetUnitPosition(d.k<i>, PX, PY)
            call DestroyEffect(AddSpecialEffectTarget(SFX_Path2, d.k<i>, &quot;chest&quot;))
        else
            call GroupRemoveUnit(d.dmg, d.k<i>)
            call FlushHandleLocals(T)
            call PauseTimer(T)
            call DestroyTimer(T)
        endif
        set i = i + 1
    endloop
    
    set T = null
endfunction

private function Rotate_Plants takes nothing returns nothing   
    local timer t = GetExpiredTimer()
    local dat d = dat(GetHandleInt(t, &quot;d&quot;)) 
    local real UX = GetUnitX(d.u)
    local real UY = GetUnitY(d.u)
    local integer i = 1
    local real PX
    local real PY
    local rect R
    local group g
    local timer T
    
    set d.count = d.count - 0.03
    
    if d.count &gt; 0 then
        set bj_ghoul[489] = d.u
        loop
            exitwhen i &gt; No_of_Plants
            set g = CreateGroup()
            set d.ang<i> = d.ang<i> + Rotate_Speed
            set PX = UX + Plant_Dist * Cos(d.ang<i> * bj_DEGTORAD)
            set PY = UY + Plant_Dist * Sin(d.ang<i> * bj_DEGTORAD)
            call SetUnitPosition(d.plant<i>, PX, PY)
            call SetUnitFacing(d.plant<i>, d.ang<i> + 90)
            call GroupEnumUnitsInRange(g, PX, PY, AoE, Condition(function filter))
            loop
                set d.k[d.c] = FirstOfGroup(g)
                exitwhen d.k[d.c] == null
                call GroupRemoveUnit(g, d.k[d.c])
                if IsUnitInGroup(d.k[d.c], d.dmg) != true then
                    call UnitDamageTarget(d.u, d.k[d.c], d.Dmg, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
                    call DestroyEffect(AddSpecialEffectTarget(SFX_Path4, d.k[d.c], &quot;chest&quot;))
                    call GroupAddUnit(d.dmg, d.k[d.c])
                    set T = CreateTimer()
                    set d.Ang[d.c] = Atan2(GetUnitY(d.k[d.c])-GetUnitY(d.u), GetUnitX(d.k[d.c])-GetUnitX(d.u)) * bj_RADTODEG + 90
                    set d.dist[d.c] = Knockback_Dist
                    set d.speed[d.c] = Knockback_Speed
                    call SetHandleInt(T, &quot;d&quot;, d)
                    call TimerStart(T, 0.03, true, function Knockback)
                    set T = null
                endif
                set d.c = d.c + 1
            endloop
            if Destroys_Objects == true then
                set R = Rect(PX-AoE, PY-AoE, PX+AoE, PY+AoE)
                call EnumDestructablesInRect(R, null, function GG_Objects)
                call RemoveRect(R)
                set R = null
            endif
            call DestroyGroup(g)
            set g = null
            set i = i + 1
        endloop
    else
        set i = 1
        loop
            exitwhen i &gt; No_of_Plants
            call RemoveUnit(d.plant<i>)
            call DestroyEffect(d.sfx<i>)
            set i = i + 1
        endloop
        call GroupClear(d.dmg)
        call DestroyGroup(d.dmg)
        call d.destroy()
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
    endif
    
    set t = null
endfunction

private function Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local dat d = dat.create()
    local real UX = GetUnitX(d.u)
    local real UY = GetUnitY(d.u)
    local integer i = 1
    
    set d.Dmg = Damage(GetUnitAbilityLevel(d.u, CPS_Ability_ID))
    
    loop
        exitwhen i &gt; No_of_Plants
        set d.ang<i> = 360/No_of_Plants * i
        set d.plant<i> = CreateUnit(GetOwningPlayer(d.u), Corrupted_Plant_ID, UX + Plant_Dist * Cos(d.ang<i> * bj_DEGTORAD), UY + Plant_Dist * Sin(d.ang<i> * bj_DEGTORAD), d.ang<i> + 90)
        set d.sfx<i> = AddSpecialEffectTarget(SFX_Path3, d.plant<i>, &quot;chest&quot;)
        call DestroyEffect(AddSpecialEffectTarget(SFX_Path, d.plant<i>, &quot;origin&quot;))
        set i = i + 1
    endloop
    
    call SetHandleInt(t, &quot;d&quot;, d)
    call TimerStart(t, 0.03, true, function Rotate_Plants)
    
    set t = null
endfunction

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == CPS_Ability_ID
endfunction

function InitTrig_Corrupted_Plant_Shield takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

endscope</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
 

waaaks!

Zinctified
Reaction score
255
maybe theres an option in new gen that you forgot to checked? or unchecked?
 
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