• 🏆 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] Infinite loop problem

Status
Not open for further replies.
Level 12
Joined
Dec 10, 2008
Messages
850
Ok, so I've been editing some spells of mine, and I've run into a... snag... This trigger seems to spin off into an infinite loop, and I can't see why. Everything for the exitwhen is set before hand, and the effects stop after a certain point, but nothing else after happens, not even the first BJDebugMsg() apears. Why?

JASS:
scope Light initializer InitTrig_Light

     globals
          private constant string  Lightning = "HWSB" //RAWCODE!
          private constant integer SPELL_ID  = 'A003'
          private constant integer DUM_ID    = 'h002'
          private constant string  Effect1   = "Abilities\\Spells\\Human\\ReviveHuman\\ReviveHuman.mdl"
          private constant integer DAMBASE   = 50 // This is the base damage. It is multiplyed by the level later
          private constant real    Real1     = 45 //Change the Real stuff up to Real4 to change were the lightning is created(Degrees)
          private constant real    Real2     = 135
          private constant real    Real3     = 225
          private constant real    Real4     = 315
          private constant real    Real5     = 400 // Change this to increase or decrease how far away the lightning is
          private constant real    Real6     = 750 // This changes the area were the effects are created size
          private constant real    Real7     = 500//Change this to set the height of the lightnings in the air.
          private constant real    Real8     = 250//Change this to set the height were the lightning meets above the caster.Set it heigher them Rea7 to make it over the cube.
          boolexpr BOOL // Don't touch this
     endglobals
     
     //Dont go below here unless you know what your doing
     
    private function FilterFunc takes nothing returns boolean        
        local unit u = GetFilterUnit()        
        local boolean ok = GetWidgetLife(u) > .405 and IsUnitEnemy(u,GetOwningPlayer(GetTriggerUnit()))        
        set u = null        
        return ok    
    endfunction 

     private function Light_Conditions takes nothing returns boolean
          return GetSpellAbilityId() == SPELL_ID
     endfunction

     private function Light_Actions takes nothing returns nothing
          local unit      C     = GetSpellAbilityUnit()
          local location  CL    = GetUnitLoc(C)
          local real      CR    = GetUnitX(C)
          local real      RC    = GetUnitY(C)
          local rect      R     = RectFromCenterSizeBJ(CL,Real6,Real6)
          local player    Y     = GetOwningPlayer(C)
          local integer   Level = GetUnitAbilityLevel(C,SPELL_ID)
          local real      X1    = CR + Real5 * Cos(Real1*bj_DEGTORAD)
          local real      X2    = CR + Real5 * Cos(Real2*bj_DEGTORAD)
          local real      X3    = CR + Real5 * Cos(Real3*bj_DEGTORAD)
          local real      X4    = CR + Real5 * Cos(Real4*bj_DEGTORAD)
          local real      Y1    = RC + Real5 * Sin(Real1*bj_DEGTORAD)
          local real      Y2    = RC + Real5 * Sin(Real2*bj_DEGTORAD)
          local real      Y3    = RC + Real5 * Sin(Real3*bj_DEGTORAD)
          local real      Y4    = RC + Real5 * Sin(Real4*bj_DEGTORAD)
          local real      Z1    = GetUnitFlyHeight(C)+Real7
          local real      Z2    = GetUnitFlyHeight(C)+ Real8
          local lightning G1    = AddLightning(Lightning,true,X1,Y1,X2,Y2)
          local lightning G2    = AddLightning(Lightning,true,X2,Y2,X3,Y3)
          local lightning G3    = AddLightning(Lightning,true,X3,Y3,X4,Y4)
          local lightning G4    = AddLightning(Lightning,true,X4,Y4,X1,Y1)
          local lightning G5    = AddLightningEx(Lightning,true,X1,Y1,0,X1,Y1,Z1)
          local lightning G6    = AddLightningEx(Lightning,true,X2,Y2,0,X2,Y2,Z1)
          local lightning G7    = AddLightningEx(Lightning,true,X3,Y3,0,X3,Y3,Z1)
          local lightning G8    = AddLightningEx(Lightning,true,X4,Y4,0,X4,Y4,Z1)
          local lightning G9    = AddLightningEx(Lightning,true,X1,Y1,Z1,X2,Y2,Z1)
          local lightning G10   = AddLightningEx(Lightning,true,X2,Y2,Z1,X3,Y3,Z1)
          local lightning G11   = AddLightningEx(Lightning,true,X3,Y3,Z1,X4,Y4,Z1)
          local lightning G12   = AddLightningEx(Lightning,true,X4,Y4,Z1,X1,Y1,Z1)
          local lightning G13   = AddLightningEx(Lightning,true,X1,Y1,Z1,CR,RC,Z2)
          local lightning G14   = AddLightningEx(Lightning,true,X2,Y2,Z1,CR,RC,Z2)
          local lightning G15   = AddLightningEx(Lightning,true,X3,Y3,Z1,CR,RC,Z2)
          local lightning G16   = AddLightningEx(Lightning,true,X4,Y4,Z1,CR,RC,Z2)
          local lightning G17   = AddLightningEx(Lightning,true,X1,Y1,0,CR,RC,Z2)
          local lightning G18   = AddLightningEx(Lightning,true,X2,Y2,0,CR,RC,Z2)
          local lightning G19   = AddLightningEx(Lightning,true,X3,Y3,0,CR,RC,Z2)
          local lightning G20   = AddLightningEx(Lightning,true,X4,Y4,0,CR,RC,Z2)
          local real      M1
          local real      M2
          local real      X5
          local real      Y5
          local integer   P     =1
          local integer Damage = DAMBASE * Level
          local location  M
          local integer   PE    =30*Level
          local unit      U
          local group     G = CreateGroup()
          loop
               exitwhen P==PE
               set M = GetRandomLocInRect(R)
               call DestroyEffect(AddSpecialEffectLoc(Effect1,M))
               set M = GetRandomLocInRect(R)
               call DestroyEffect(AddSpecialEffectLoc(Effect1,M))
               set M = GetRandomLocInRect(R)
               call DestroyEffect(AddSpecialEffectLoc(Effect1,M))
               set M = GetRandomLocInRect(R)
               call DestroyEffect(AddSpecialEffectLoc(Effect1,M))
               call RemoveLocation(M)      
               call TriggerSleepAction(.3)
               set P=P+1
          endloop
          call BJDebugMsg("1")
          loop
               exitwhen U== null
               set U = FirstOfGroup(G)
               call GroupRemoveUnit(G,U)
               call UnitDamageTarget(C,U,Damage,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
          endloop
          call BJDebugMsg("2")
          call RemoveRect(R)
          call DestroyLightning(G1)
          call DestroyLightning(G2)
          call DestroyLightning(G3)
          call DestroyLightning(G4)
          call DestroyLightning(G5)
          call DestroyLightning(G6)
          call DestroyLightning(G7)
          call DestroyLightning(G8)
          call DestroyLightning(G9)
          call DestroyLightning(G10)
          call DestroyLightning(G11)
          call DestroyLightning(G12)
          call DestroyLightning(G13)
          call DestroyLightning(G14)
          call DestroyLightning(G15)
          call DestroyLightning(G16)
          call DestroyLightning(G17)
          call DestroyLightning(G18)
          call DestroyLightning(G19)
          call DestroyLightning(G20)
          set C=null
     endfunction

//===========================================================================
     private function InitTrig_Light takes nothing returns nothing
          local trigger I = CreateTrigger()
          call TriggerRegisterAnyUnitEventBJ(I,EVENT_PLAYER_UNIT_SPELL_CAST)
          call TriggerAddCondition(I,Condition(function Light_Conditions))
          call TriggerAddAction(I,function Light_Actions)
          set I=null
          call Preload(Effect1)
          call Preload(Lightning)
          set BOOL = Filter(function FilterFunc)
     endfunction
endscope

Edit: Lol at me using [EndJass] to end JASS tags:ugly:
 
Level 12
Joined
Dec 10, 2008
Messages
850
I'm working out how that stuff works, but right now I just wanna fix this problem. I know the rawcode isn't wrong because as I said in my first post, the effects are displayed properly, but nothing else proceeds to happen.

@TriggerHappy: I now it leaks, I don't need to be told that. I care about the problem at hand, not other things that won't improve the wuility ATM.
 
I now it leaks, I don't need to be told that. I care about the problem at hand, not other things that won't improve the wuility ATM.

Well im sorry for trying to help -_-

And thats not all I said either, I actually gave a suggestion.

Anyways, are you waiting 15 seconds to see if the first message displays, like poot said?
 
Status
Not open for further replies.
Top