• 🏆 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] why my we crash?

Status
Not open for further replies.
Level 7
Joined
Mar 22, 2010
Messages
228
i hate to say there are errors

JASS:
function a takes nothing returns nothing
    local unit u
    local integer i
    local real x
    local real y
    local location l
    local integer i2
    local real w = 0

    loop
        set x = GetLocationX(GetRectCenter(gg_rct_1))
        set y = GetLocationY(GetRectCenter(gg_rct_1))
        set u = CreateUnit( player(1), 'hfoo', x, y, 0.)//syntax!!!
        set x = GetLocationX(GetRectCenter(gg_rct_2))
        set y = GetLocationY(GetRectCenter(gg_rct_2))
        set l = Location(x, y)
        call IssuePointOrderLocBJ( u, "attack", l )
        call RemoveLocation( l )
        set l = null
        set u = null
        if i2 == 3 then
            set x = GetLocationX(GetRectCenter(gg_rct_1))
            set y = GetLocationY(GetRectCenter(gg_rct_1))
            set u = CreateUnit( Player(1), 'hrif', x, y, 0.)
            set x = GetLocationX(GetRectCenter(gg_rct_2))
            set y = GetLocationY(GetRectCenter(gg_rct_2))
            set l = Location(x, y)
            call IssuePointOrderLocBJ( u, "attack", l )
            call RemoveLocation( l )
            set u = null
            set l = null
            set i2 = 0
            set w = 30
        else
        endif
        exitwhen i == 5
        set i = 0
        set i2 = i2 + 1
        call TriggerSleepAction( w )
    endloop

endfunction

function InitTrig_a takes nothing returns nothing
    set gg_trg_a = CreateTrigger(   )
    call TriggerAddAction( gg_trg_a, function a )
endfunction

i make a loop that never ends, is that alright?
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
There are several errors:
- player(1) should be Player(1)
- The loop is infinite, you propably wanted to test i2 == 5
- You leak 4 locations
JASS:
set x = GetLocationX(GetRectCenter(gg_rct_1))
set y = GetLocationY(GetRectCenter(gg_rct_1))
set u = CreateUnit( Player(1), 'hrif', x, y, 0.)
set x = GetLocationX(GetRectCenter(gg_rct_2))
set y = GetLocationY(GetRectCenter(gg_rct_2))
set l = Location(x, y)
call IssuePointOrderLocBJ( u, "attack", l )
call RemoveLocation( l )
should look like this:
JASS:
set u = CreateUnit( Player(1), 'hrif', GetRectCenterX(gg_rct_1), GetRectCenterY(gg_rct_1), 0.)
call IssuePointOrder( u, "attack", GetRectCenterX(gg_rct_2), GetRectCenterY(gg_rct_2) )
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
Propably this:
JASS:
function a takes nothing returns nothing
    local unit u
    local integer i2 = 0
    loop
        set u = CreateUnit( Player(1), 'hfoo', GetRectCenterX(gg_rct_1), GetRectCenterY(gg_rct_1), 0.)
        call IssuePointOrder( u, "attack", GetRectCenterX(gg_rct_2), GetRectCenterY(gg_rct_2) )
        if i2 == 3 then
            set u = CreateUnit( Player(1), 'hrif', GetRectCenterX(gg_rct_1), GetRectCenterY(gg_rct_1), 0.)
            call IssuePointOrder( u, "attack", GetRectCenterX(gg_rct_2), GetRectCenterY(gg_rct_2) )
            call TriggerSleepAction( 30 )
        endif
        exitwhen i == 5
        set i2 = i2 + 1
    endloop
    set u = null
endfunction

function InitTrig_a takes nothing returns nothing
    set gg_trg_a = CreateTrigger(   )
    call TriggerAddAction( gg_trg_a, function a )
endfunction
But I not sure what this trigger is supposed to do exactly, so maybe I did some wrong changes. This will spawn 2 'hfoo's and one 'hrif', wait 30 second and spawn two more 'hfoo's
 
Level 7
Joined
Mar 22, 2010
Messages
228
can you make it 3 ?
i want 3 hfoo to be created...

thanks by the way!

Edit: NVM dude, i know what to change, thanks by the way!

EDIT: DUDE my wc3 crashes when the second wave comes.!!!
 
Status
Not open for further replies.
Top