X-Git-Url: https://deadsoftware.ru/gitweb?p=cavecraft.git;a=blobdiff_plain;f=src%2Fworldgen.mpsrc;h=d49159a2428d1f9293956bc1a2aefd0c86cab6a3;hp=ca522107373f7ae63dccc066994cebef4b34d858;hb=45d5263c1b7b20f5fd555c485b1f83237e978241;hpb=3564ef6fb4685bbecd05d027d91a9f7d81385b07 diff --git a/src/worldgen.mpsrc b/src/worldgen.mpsrc index ca52210..d49159a 100644 --- a/src/worldgen.mpsrc +++ b/src/worldgen.mpsrc @@ -407,104 +407,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);