- Joined
- Nov 29, 2006
- Messages
- 2,482
Okay, so I have this code which is run at map initialization creating doodads all over the map. But the weird thing is that it doesn't fill the whole map; I stops somewhere of 25% on the x-direction, but creates trees on the y-direction. So any help would be appreciated
Please not that I am aware of that this is a custom texted trigger. However I use so many custom scripts since BJ fuctions are completely incompetent, so I think it should be considered to be posted here in the jass section ._.
Im also aware of not nullifying some variables, but I will, its not the main problem.
Also Im wondering, isnt it possible to create local variables on map init? I get a compiling error when I try that.
Edit: I found the problem with the locals (still this trigger is global though)
Anyway here is the code:
/regards
Please not that I am aware of that this is a custom texted trigger. However I use so many custom scripts since BJ fuctions are completely incompetent, so I think it should be considered to be posted here in the jass section ._.
Im also aware of not nullifying some variables, but I will, its not the main problem.
Also Im wondering, isnt it possible to create local variables on map init? I get a compiling error when I try that.
Edit: I found the problem with the locals (still this trigger is global though)
Anyway here is the code:
JASS:
globals
real udg_rx = 0
real udg_ry = 0
rect udg_r = null
integer udg_i1 = 0
location udg_p1 = null
integer udg_i2 = 0
location udg_p2 = null
trigger gg_trg_Tree_Creation = null
endglobals
JASS:
function Trig_Tree_Creation_Actions takes nothing returns nothing
call FogEnableOff( )
call FogMaskEnableOff( )
set udg_r = bj_mapInitialPlayableArea
set udg_rx = (GetRectMaxX(udg_r) - GetRectMinX(udg_r))/128
set udg_ry = (GetRectMaxY(udg_r) - GetRectMinY(udg_r))/128
set udg_p1 = Location(GetRectMinX(udg_r), GetRectMinY(udg_r))
set udg_i1 = 0
loop
exitwhen udg_i1 > R2I(udg_rx)
set udg_i2 = 0
loop
exitwhen udg_i2 > R2I(udg_ry)
set udg_p2 = Location(GetLocationX(udg_p1) + (I2R(udg_i1) * 128), GetLocationY(udg_p1) + (I2R(udg_i2) * 128))
call CreateDestructableLoc( 'ATtr', udg_p2, GetRandomDirectionDeg(), GetRandomReal(0.80, 1.20), GetRandomInt(0, 4) )
call RemoveLocation( udg_p2 )
set udg_p2 = null
set udg_i2 = udg_i2 + 1
endloop
set udg_i1 = udg_i1 + 1
endloop
call RemoveLocation( udg_p1 )
set udg_p1 = null
endfunction
/regards
Last edited: