X-Git-Url: https://deadsoftware.ru/gitweb?p=cavecraft.git;a=blobdiff_plain;f=src%2Fworldgen.mpsrc;h=e9e7a0618bd60cf31207f7de75c59255a0b7e903;hp=ca522107373f7ae63dccc066994cebef4b34d858;hb=HEAD;hpb=1ef13d5bd0592dde48cc837e05b13e93e82db25b diff --git a/src/worldgen.mpsrc b/src/worldgen.mpsrc index ca52210..e9e7a06 100644 --- a/src/worldgen.mpsrc +++ b/src/worldgen.mpsrc @@ -17,7 +17,8 @@ interface implementation -uses maps,randoms,vars,items,func, player, chest, items_store; + + uses maps, randoms, vars, func, player, chest, items_store, Items, Blocks; function rnd_min:integer; begin @@ -407,104 +408,42 @@ procedure create_bonus_chest(chx,chy:integer); end; end; + // Генерирует чанки руды в камне типа block с максимальной вероятность percent процентов + // Начиная с уровня starty и размером не более maxsize*maxsize + // С ростом глубины вероятность растёт + procedure GenOreChunks(block, percent, starty, maxsize : Integer); + const + preq = 100000; + var + x, y, i, j : Integer; + begin + for x := 0 to MAP_W do + for y := starty to MAP_H do + if RandomBoolean(y * percent * preq / MAP_H, 100 * preq) then + for i := 0 to rnd(maxsize) - 1 do + for j := 0 to rnd(maxsize) - 1 do + if RandomBoolean(50, 100) and (GetMap(x + i, y + j) = 3) then + SetMap(block, x + i, y + j); + end; + procedure genallrudes; - var - ix,iy,iu,iv:integer; begin - //алмазы - for ix:=0 to 255 do - for iy:=111 to 127 do - if (rnd_pr(1,1,0)=1) then - begin - for iu:=0 to 2 do - for iv:=0 to 2 do - if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(10,19,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); - ix:=ix+3; - end; - - //золото - for ix:=0 to 255 do - for iy:=95 to 127 do - if (rnd_pr(3,1,0)=1) then - begin - for iu:=0 to 2 do - for iv:=0 to 2 do - if (ix+iu<255) and (iy+iv<126) then - if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(20,16,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); - ix:=ix+3; - end; - - //лазурит - for ix:=0 to 255 do - for iy:=107 to 127 do - if (rnd_pr(2,1,0)=1) then - begin - for iu:=0 to 2 do - for iv:=0 to 2 do - if (ix+iu<255) and (iy+iv<126) then - if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(40,54,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); - ix:=ix+3; - end; - - //редстоун - for ix:=0 to 255 do - for iy:=107 to 127 do - if (rnd_pr(2,1,0)=1) then - begin - for iu:=0 to 2 do - for iv:=0 to 2 do - if (ix+iu<255) and (iy+iv<126) then - if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(40,20,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); - ix:=ix+3; - end; - - //железо - for ix:=0 to 255 do - for iy:=63 to 127 do - if (rnd_pr(4,1,0)=1) then - begin - for iu:=0 to 2 do - for iv:=0 to 2 do - if (ix+iu<255) and (iy+iv<126) then - if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(40,17,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); - ix:=ix+3; - end; - - //уголь - for ix:=0 to 255 do - for iy:=0 to 127 do - if (rnd_pr(6,1,0)=1) then - begin - for iu:=0 to 2 do - for iv:=0 to 2 do - if (ix+iu<255) and (iy+iv<126) then - if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(50,18,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); - ix:=ix+3; - end; - - //гравий - for ix:=0 to 255 do - for iy:=63 to 126 do - if (rnd_pr(2,1,0)=1) then - begin - for iu:=0 to rnd(5) do - for iv:=0 to rnd(5) do - if (ix+iu<255) and (iy+iv<126) then - if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(90,8,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); - ix:=ix+3; - end; - - //земля на камне - for ix:=0 to 255 do - for iy:=63 to 127 do - if (rnd_pr(1,1,0)=1) then - begin - for iu:=0 to rnd(5) do - for iv:=0 to rnd(5) do - if (ix+iu<255) and (iy+iv<126) then - if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(90,1,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); - ix:=ix+3; - end; + (* Алмазная руда *) + GenOreChunks(19, 1, 111, 3); + (* Золотая руда *) + GenOreChunks(16, 2, 95, 3); + (* Лазуритовая руда *) + GenOreChunks(54, 2, 107, 3); + (* Красная руда *) + GenOreChunks(20, 2, 107, 3); + (* Железная руда *) + GenOreChunks(17, 3, 63, 3); + (* Угольная руда *) + GenOreChunks(18, 4, 0, 6); + (* Гравий *) + GenOreChunks(8, 2, 0, 6); + (* Грязь *) + GenOreChunks(8, 2, 0, 6); end; procedure dec_0(ix,iy:integer); @@ -637,8 +576,8 @@ procedure create_bonus_chest(chx,chy:integer); l:=rnd(26); if rnd(75)=rnd(75) then begin - chest.setItem(133 ,l, id); - chest.setSum(getItemMax(133), l, id); + chest.setItem(Items.pickaxe3 ,l, id); + chest.setSum(Items.GetMaximum(Items.pickaxe3), l, id); end; else if rnd(25)=rnd(25) then begin