spreading blocks all over the map?

Status
Not open for further replies.
Level 6
Joined
Oct 4, 2008
Messages
263
yeah, i trying to find a way to spread a 'block' all over the map.
the block is really a unit, the size of a human house, and im trying to make a trigger that could fill the map totally with them.

help plz?
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
You can put two loops, integer A and integer B, integer A will be in charge of changing rows, integer B will add the blocks to a row. It really depends on how big your blocks are and how big your map is, but basically start at the left-hand corner (for example) at a point which has the x coordinate equal to minimum x of the map + half of block length, and the y coordinate is max y of the map - half of the block width.

Then in integer B you can move your spawning point each time a little to the right (the distance between those points should be equal to the lenght of the block). Then when you reach the end of your map, integer A can just shift to the second row (starting from left again).

You would need to do some minor calculations.
 
Level 6
Joined
Oct 4, 2008
Messages
263
having done a lot more on my script, i return with new errors!
JASS:
function Trig_mapGeneration takes nothing returns nothing
local real h = GetRectMinX(GetPlayableMapRect())+36
local real v = GetRectMinY(GetPlayableMapRect())+36
    local location array bossplaces
    local integer i = GetRandomInt(1,7)
    local integer j = 0
    local unit u
call DisplayTextToForce(GetForceOfPlayer(Player(0)), "Please Wait While Generating Dungeon"
loop
exitwhen v == GetRectMaxY(GetPlayableMapRect())
loop
exitwhen h == GetRectMaxX(GetPlayableMapRect())
call CreateUnitAtLoc(Player(7), 'h001', Location(h, v), GetRandomReal(0,360))
set h = h + 72
endloop
set v = v + 72
endloop
    loop
      exitwhen j>i
      set bossplaces[j] = Location(GetRandomReal(GetRectMinX(GetPlayableMapRect()), GetRectMaxX(GetPlayableMapRect())), GetRandomReal(GetRectMinY(GetPlayableMapRect()), GetRectMaxY(GetPlayableMapRect()))'
      set j = 1 + j
    endloop
    call MeleeClearNearbyUnits(GetLocationX(bossplaces[0]), GetLocationY(bossplaces[1]), 36)
    set u = CreateUnitAtLoc(Player(7), 'h002', bossplaces[0], GetRandomReal(0, 360))
    set j = 1
    loop
    exitwhen j>i
    call IssuePointOrderLocBJ(u, "move", bossplaces[j])
    set j = j + 1
    endloop
    endfunction
//===========================================================================
function InitTrig_mapGeneration takes nothing returns nothing
    set gg_trg_mapGeneration = CreateTrigger(  )
    call TriggerAddAction( gg_trg_mapGeneration, function Trig_mapGeneration )
endfunction
at lines 8 and 20 (displaytexttoforce, and the one where i set the bossplaces array to its values), it says "expected '"

why would it need a ' at those lines??
 
Level 11
Joined
Apr 6, 2008
Messages
760
that function will prolly crash ur map when its done, major leakage

why create at location when u have x/y

call CreateUnitAtLoc(Player(7), 'h001', Location(h, v), GetRandomReal(0,360))

do this

call CreateUnit(Player(7),'h001',h,v,GetRandomReal(0,360))
 
Level 6
Joined
Oct 4, 2008
Messages
263
is that where it leak, or is it somewhere else?
cuz my map is actually crashing -.-
 
Level 6
Joined
Oct 4, 2008
Messages
263
yes, i did
and i figured its probably because it cant take so many units at once.
 
Level 6
Joined
Oct 4, 2008
Messages
263
you misunderstand me. the problem is that we have well over a thousand units on the screen at once. the computer cant keep track of it all at once, and so warcraft freezes.
i think i have a new idea of how to to this. But it depends on if the jass laguage support two-dimensional arrays. does it do that?
 
Level 6
Joined
Oct 4, 2008
Messages
263
hmm... thats a possibility. but if my new idea works, it wil be a lot better, the dungeons will be a lot more pretty, and... yeah, everything will just work a lot better.

it involves having a two-dimensional array with a value for each position thta a block would fill in case the map were covered(did that make sense?), then clearing a 'path' of zeros through the array. then itll go through the array, and on each '1' it will check if any '0's are adjacent, if so it will spawn a block in the 'location' of the '1', if you get what i mean.
edit: i have a problem with the syntax on this, could anybody help?
JASS:
function mapgeneration takes nothing returns nothing
local integer u = 'h000'
local integer array map
local integer i = 0
local integer j = 0
loop
exitwhen i == 38
loop
exitwhen j == 38
set map[i][j]=1
set j = j + 1
endloop
set i = i+1
set j = 0
endloop
endfunction

on the line where i set the array's value to 1, it come up with a syntax error. i checked the vjass handbook a hundred gazillion times, and i really cannot find the error.
 
Last edited:
I believe the problem is that you have to initilize and destroy 3d arrays, unfortunately I don't know how, but here's a cleaned up version of your code

JASS:
function mapgeneration takes nothing returns nothing
local integer u='h000'
local integer array map //must initilize this as a 3d array! how?
local integer i=0
local integer j=0
loop
	exitwhen i>37
	loop
		exitwhen j>37
		set map[i][j]=1
		set j=j+1
	endloop
set i=i+1
set j=0
endloop
endfunction
 
Status
Not open for further replies.
Top