• 🏆 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!

[JASS] Spell crashing the game

Status
Not open for further replies.
Level 5
Joined
May 23, 2008
Messages
123
Ok it seems when a person is casting the spell and then with a different hero casts this same spell it crashes the game.

Any ideals why it only happens when its casted the 2nd time? Or do you see any thing wrong with the code?

JASS:
  local unit u = GetTriggerUnit()
  local unit z
  local unit q
  local location l = GetSpellTargetLoc()
  local location l2
  local player p = GetOwningPlayer(u)     
  local integer i = GetUnitAbilityLevel(u,'A00O')
  local integer j = 14
  local integer h = 0
  local integer size = 10


  set z = CreateUnitAtLoc(p,'u009',l,270)
  call SetUnitAbilityLevel(z,'A00L',i)
  call SetUnitLifeBJ( z, 1.00 )
  call SetUnitScalePercent( z, size, size, size )  

  call TriggerSleepAction(.5)

  loop
     exitwhen j == 0       
        
         loop
            exitwhen h > 360
                set l = GetUnitLoc(z)
                set l2 = PolarProjectionBJ(l,500,h)         
                set q = CreateUnitAtLoc(p,'h00F',l2,0)
                call IssueTargetOrder(q,"deathcoil",z)
                call UnitApplyTimedLife(q,'BTLF', 10)
                call RemoveLocation(l2)
            set h = h+45   
          endloop
     
     call RemoveLocation(l)
     call TriggerSleepAction(1)
     if(j!=0) then
       set size = size+10
       call SetUnitScalePercent( z, size, size, size )
     endif
     set h = 0
     set j = j-1
  endloop

  call TriggerSleepAction(2)
  set l = GetUnitLoc(z)
  set q = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_AGGRESSIVE),'n00G',l,270)
  call RemoveUnit( z )


  call RemoveLocation(l)
  call RemoveLocation(l2)
  set l2 = null
  set l = null
  set u = null
  set z = null
  set q = null
  set p = null
 
Level 5
Joined
Dec 18, 2007
Messages
205
SetUnitScalePercent actually requires reals, so change size to a real.
but this is not causing the crash.
can locals have a number as name? i never tested it, but i think they cant, so actually l2 wouldnt work.
there are also other functions like polarprojection, that require reals and you pass integers to them, dont get used to this!!

if this doesnt help, i think i ahve to take a closer look to the code.

greetings
 
Level 5
Joined
May 23, 2008
Messages
123
ok thank you ill try changing them 2 reals, altho i dont see y you cant use intergers when reals are just numbers with decmails. Using 2 and 2.0 does the same thing.

also for the number thing this was posted on hive in the learning jass area
"When naming variables, you can't just use any name. First off, the only characters you can use are any letter in the alphabet, any number, and the underscore character (_). The first letter in a variable name must be a letter, after that you can use numbers, letters, and underscores all you want. Let me make it clear that you can not use spaces in a variable name."
 
Level 5
Joined
Dec 18, 2007
Messages
205
okay. is the code still crashing you map?
and are you sure it is just this code?

and yeah, sometimes you can just replace reals with integers and vica verse (for example in triggerlseepaction), but there are also functions that will crash or show errors when passing an integer instead of a real to the function. otherwise R2I and I2R would be useless.
 
Level 5
Joined
May 23, 2008
Messages
123
Yes it still does not work, but it only crashes when casted a 2nd time, which makes no scence to me because its not using any global varrables so one spell should not effect an other.

Also you never can use real as a interger(unless wc know to cut off the decmails?) Any value of a interger can fit in a real, but not every value of a real can fit into a interger.

I realy thing think that I2R is just for making GUI work more smothly
 
Level 5
Joined
Dec 18, 2007
Messages
205
i know that you cant pass reals to integer values, that makes no sense >.>

please post your complete code including the init trigger and everything. also check all rawcodes of their corectness.

there are also several leaks in the code.
 
Level 5
Joined
May 23, 2008
Messages
123
JASS:
function Trig_chaos_portal_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00O'
endfunction

function Trig_chaos_portal_Actions takes nothing returns nothing
  local unit u = GetTriggerUnit()
  local unit z
  local unit q
  local location l = GetSpellTargetLoc()
  local location l2
  local player p = GetOwningPlayer(u)     
  local integer i = GetUnitAbilityLevel(u,'A00O')
  local integer j = 14
  local integer h = 0
  local integer size = 10


  set z = CreateUnitAtLoc(p,'u009',l,270)
  call SetUnitAbilityLevel(z,'A00L',i)
  call SetUnitLifeBJ( z, 1.00 )
  call SetUnitScalePercent( z, size, size, size )  

  call TriggerSleepAction(.5)

  loop
     exitwhen j == 0       
        
         loop
            exitwhen h > 360
                set l = GetUnitLoc(z)
                set l2 = PolarProjectionBJ(l,500,h)         
                set q = CreateUnitAtLoc(p,'h00F',l2,0)
                call IssueTargetOrder(q,"deathcoil",z)
                call UnitApplyTimedLife(q,'BTLF', 10)
                call RemoveLocation(l2)
            set h = h+45   
          endloop
     
     call RemoveLocation(l)
     call TriggerSleepAction(1)
     if(j!=0) then
       set size = size+10
       call SetUnitScalePercent( z, size, size, size )
     endif
     set h = 0
     set j = j-1
  endloop

  call TriggerSleepAction(2)
  set l = GetUnitLoc(z)
  set q = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_AGGRESSIVE),'n00G',l,270)
  call RemoveUnit( z )


  call RemoveLocation(l)
  call RemoveLocation(l2)
  set l2 = null
  set l = null
  set u = null
  set z = null
  set q = null
  set p = null
endfunction

//===========================================================================
function InitTrig_chaos_portal takes nothing returns nothing
    set gg_trg_chaos_portal = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_chaos_portal, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_chaos_portal, Condition( function Trig_chaos_portal_Conditions ) )
    call TriggerAddAction( gg_trg_chaos_portal, function Trig_chaos_portal_Actions )
endfunction

i double checked all the raw codes, they are all correct. If they were wrong i would think it would make the spell not work correctly (which it does), not crash the game.

I thought i took care of all the leaks, mind pointting them out for me?
 
Level 4
Joined
Mar 14, 2009
Messages
98
JASS:
function Trig_chaos_portal_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00O'
endfunction

function Trig_chaos_portal_Actions takes nothing returns nothing
  local unit u = GetTriggerUnit()
  local unit z
  local unit q
  local location l = GetSpellTargetLoc()
  local location l2
  local player p = GetOwningPlayer(u)
  local integer i = GetUnitAbilityLevel(u,'A00O')
  local integer j = 14
  local integer h = 0
  local integer size = 10


  set z = CreateUnitAtLoc(p,'u009',l,270)
  call SetUnitAbilityLevel(z,'A00L',i)
  call SetUnitLifeBJ( z, 1.00 )
  call SetUnitScalePercent( z, size, size, size )

  call TriggerSleepAction(.5)

  loop
     exitwhen j == 0

         loop
            exitwhen h > 360
                set l2 = PolarProjectionBJ(l,500,h)
                set q = CreateUnitAtLoc(p,'h00F',l2,0)
                call IssueTargetOrder(q,"deathcoil",z)
                call UnitApplyTimedLife(q,'BTLF', 10)
                call RemoveLocation(l2)
            set h = h+45
          endloop

     call TriggerSleepAction(1)
     if(j!=0) then
       set size = size+10
       call SetUnitScalePercent( z, size, size, size )
     endif
     set h = 0
     set j = j-1
  endloop

  call TriggerSleepAction(2)
  set l = GetUnitLoc(z)
  set q = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_AGGRESSIVE),'n00G',l,270)
  call RemoveUnit( z )


  call RemoveLocation(l)
  call RemoveLocation(l2)
  set l2 = null
  set l = null
  set u = null
  set z = null
  set q = null
  set p = null
endfunction

//===========================================================================
function InitTrig_chaos_portal takes nothing returns nothing
    set gg_trg_chaos_portal = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_chaos_portal, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_chaos_portal, Condition( function Trig_chaos_portal_Conditions ) )
    call TriggerAddAction( gg_trg_chaos_portal, function Trig_chaos_portal_Actions )
endfunction

I don't think anything is wrong with this apart from optimization and some leak issues. Are you sure no other event is triggering that's causing this crash?
 
Level 5
Joined
May 23, 2008
Messages
123
Well its crashed a few times when this spell was being casted 2 times, its hard to tell what crashes a game when its fulled of 12 randomly people and you cant watch a repaly 2 see what happened the 2nd it crashed. Sadly theirs not error a messages when wc crashes :(.

I removed the spell and the game has not crashed yet so it seems to be his.

If it was easy to find out y the spell crashed the game i would not be here :(
 
Level 5
Joined
Dec 18, 2007
Messages
205
i also don't see the reason why this trigger whould crash, maybe in combination with another trigger, that uses .. well.. some same rawcodes on cast? i really dont know, but this spell should not crash.

test it in another map.

copy the spell to another map, add the dummys and see if the crash also happens in the test map, that would be my last idea.
 
Level 5
Joined
May 23, 2008
Messages
123
well its still making the game crash, could by any chance it be because im basing the casting spell off of death and decay?
 
Level 3
Joined
Sep 11, 2004
Messages
63
change this part
Code:
          loop
            exitwhen h > 360
                set l = GetUnitLoc(z)
                set l2 = PolarProjectionBJ(l,500,h)
                set q = CreateUnitAtLoc(p,'h00F',l2,0)
                call IssueTargetOrder(q,"deathcoil",z)
                call UnitApplyTimedLife(q,'BTLF', 10)
                call RemoveLocation(l2)
            set h = h+45
          endloop
To:
Code:
          set l = GetUnitLoc(z)
          loop
            exitwhen h > 360
                if (GetUnitState(z, UNIT_STATE_LIFE) > 0) then
                  set l2 = PolarProjectionBJ(l,500,h)
                  set q = CreateUnitAtLoc(p,'h00F',l2,0)
                  call IssueTargetOrder(q,"deathcoil",z)
                  call UnitApplyTimedLife(q,'BTLF', 10)
                  call RemoveLocation(l2)
                endif
            set h = h+45
          endloop
 
Status
Not open for further replies.
Top