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
256
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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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