I'm making a trigger on vJASS for my map, which set up trees on map initialization.
When I'm trying to test it, it crash when loading is already half complete.
but after changing a bit the trigger, now the map can be loaded.
But, the trees that should be spawned on init isn't there.
Here is the trigger:
after some time debugging, I found out that its the executefunc in the init that cause the whole mess.
but I can't find anything wrong with it, please help.
EDIT : I forgot to tell what the trigger do: it supposed to place tree in random order, so it will always be different from game to game, it has minimum amount of tree requirement per line, if the minimum hasn't reached, it will loop again till it reached the minimum req. Upon placement the tree is also registered into tree respawn trigger.
When I'm trying to test it, it crash when loading is already half complete.
but after changing a bit the trigger, now the map can be loaded.
But, the trees that should be spawned on init isn't there.
Here is the trigger:
JASS:
scope TreeSetup initializer init
globals
private constant real X_DIS = 400
private constant real Y_DIS = 400
private constant real MIN_T = 0.60
private constant real MIN_S = 0.8
private constant real MAX_S = 1.2
private constant real MIN_D = 10
private constant real MAX_D = 60
private constant integer T_ID = 'ITtw'
private constant integer T_VAR = 10
private constant string SFX = "Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl"
private constant boolean USE_SFX = false
endglobals
struct ReviveTree
destructable d
endstruct
private function Res_Tree takes nothing returns nothing
local timer t = GetExpiredTimer()
local ReviveTree data = GetInt(t,0)
call DestructableRestoreLife( data.d, GetDestructableMaxLife(data.d), true )
if USE_SFX then
call DestroyEffect(AddSpecialEffect(SFX,GetDestructableX(data.d),GetDestructableY(data.d)))
endif
call data.destroy()
call Flush(t)
call ReleaseTimer(t)
set t = null
endfunction
private function Revive_Tree takes nothing returns nothing
local timer t = NewTimer()
local destructable d = GetDyingDestructable()
local ReviveTree data = ReviveTree.create()
set data.d = d
call SetInt(t,0,data)
call TimerStart(t,GetRandomReal(MIN_D,MAX_D),false,function Res_Tree)
set t = null
set d = null
endfunction
private function setup takes nothing returns nothing
local trigger trig = CreateTrigger()
local destructable d
// this Game_MinX,MaxX, MinY,and MaxY are globals that declared in library on init.
local real minx = Game_MinX + X_DIS
local real maxx = Game_MaxX - X_DIS
local real miny = Game_MinY + Y_DIS
local real maxy = Game_MaxY - Y_DIS
local real curx = minx
local real cury = miny
local integer check = 0
local integer cur_t = 0
local integer min_t = R2I((maxy-miny)*MIN_T/Y_DIS)
local integer i = 1
local boolean array is_tree
call TriggerAddAction(trig, function Revive_Tree)
loop
exitwhen curx >= maxx
loop
exitwhen cury >= maxy
set check = GetRandomInt(1,2)
if check == 2 and is_tree[i] == false then
set d = CreateDestructable(T_ID,curx,cury,GetRandomReal(0,359),GetRandomReal(MIN_S,MAX_S),GetRandomInt(1,T_VAR))
call TriggerRegisterDeathEvent(trig, d)
set cur_t = cur_t +1
set is_tree[i] = true
endif
set i = i +1
set cury = cury + Y_DIS
if cur_t < min_t then
set i = 1
set cury = miny
endif
endloop
set i = 1
loop
exitwhen i > R2I(min_t/MIN_T)
set is_tree[i] = false
set i = i+1
endloop
set cury = miny
set cur_t = 0
set i = 1
set curx = curx + X_DIS
endloop
set d = null
set trig = null
endfunction
private function init takes nothing returns nothing
call ExecuteFunc("TreeSetup___setup")
endfunction
endscope
but I can't find anything wrong with it, please help.
EDIT : I forgot to tell what the trigger do: it supposed to place tree in random order, so it will always be different from game to game, it has minimum amount of tree requirement per line, if the minimum hasn't reached, it will loop again till it reached the minimum req. Upon placement the tree is also registered into tree respawn trigger.
Last edited: