• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Map crashes on start...

Status
Not open for further replies.
JASS:
globals
unit array fallenhero
timer array fallentimer
endglobals

function TimerExp_Actions takes nothing returns nothing
local timer r = GetExpiredTimer()
local trigger t = GetTriggeringTrigger()
local unit u
local real x 
local real y 
local integer i = 0
local integer i2 = 10
local integer j

loop
    exitwhen i > i2
    set i = i + 1
        if fallentimer[i] == r then
            set j = i
        endif
endloop

set u = fallenhero[j]
set x = GetUnitX(u)
set y = GetUnitY(u)
call ReviveHero(u,x,y,false)
call DestroyTrigger(t)
endfunction

function RevStart_Actions takes nothing returns nothing
local trigger t
local timer r = CreateTimer()
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
local integer i = GetPlayerId(p)

set fallenhero[i] = u
set fallentimer[i] = r
set t = CreateTrigger()
call TriggerRegisterTimerExpireEvent(t,r)
call TriggerAddAction( t, function TimerExp_Actions )

call TimerStart(r,10.00,false,null)
endfunction

function RevStart_Conditions takes nothing returns boolean
return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true
endfunction
//===========================================================================
function InitTrig_RevStart takes nothing returns nothing
    local trigger gg_trg_RevStart = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_RevStart, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(gg_trg_RevStart, Condition( function RevStart_Conditions))
    call TriggerAddAction( gg_trg_RevStart, function RevStart_Actions )
endfunction
whats my problem? everytime I start wc3 with newgen I come to the mainscreen, means my script is bugged. I have disabled this trigger so it has to be this one because without this trigger everything works fine.
 
Level 11
Joined
Feb 18, 2004
Messages
394
#1:
JASS:
native TimerStart takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing

so:

JASS:
globals
    unit array fallenhero
    timer array fallentimer
endglobals

function TimerExp_Actions takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u
    local real x
    local real y
    local integer i = 0
    local integer i2 = 10
    local integer j

    loop
        exitwhen i > i2
        set i = i + 1
        if fallentimer[i] == r then
            set j = i
        endif
    endloop

    set u = fallenhero[j]
    set x = GetUnitX(u)
    set y = GetUnitY(u)
    call ReviveHero(u,x,y,false)
endfunction

function RevStart_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))

    set fallenhero[i] = u
    set fallentimer[i] = r

    call TimerStart(CreateTimer(), 10.0, false, function TimerExp_Actions)
endfunction

function RevStart_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true
endfunction
//===========================================================================
function InitTrig_RevStart takes nothing returns nothing
    local trigger gg_trg_RevStart = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_RevStart, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(gg_trg_RevStart, Condition( function RevStart_Conditions))
    call TriggerAddAction( gg_trg_RevStart, function RevStart_Actions )
endfunction

#2: You use a lot of needless locals... so:
JASS:
globals
    unit array fallenhero
    timer array fallentimer
endglobals

function TimerExp_Actions takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer i = 0
    local integer j
    
    loop
        exitwhen i > 10
        set i = i + 1
        if fallentimer[i] == t then
            set j = i
        endif
    endloop

    call ReviveHero(fallenhero[j], GetUnitX(fallenhero[j]), GetUnitY(fallenhero[j]), false)
    
    call DestroyTimer(GetExpiredTimer())
endfunction

function RevStart_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    
    set fallenhero[i] = GetTriggerUnit()
    set fallentimer[i] = CreateTimer()

    call TimerStart(fallentimer[i], 10.0, false, function TimerExp_Actions)
endfunction

function RevStart_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true
endfunction

function InitTrig_RevStart takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(t, Condition(function RevStart_Conditions))
    call TriggerAddAction(t, function RevStart_Actions)
endfunction

#3: use a frikin' scope. (Check the manual version that comes with your JASS NewGen, its in the jasshelper folder. It will mention scope initializers.)

#4: The latest code I posted parses successfully. (as does your original code) If there is an error preventing the map from loading, its likely not here...

#5: just to mention, your indenting SUCKS
 
Status
Not open for further replies.
Top