DEADSOFTWARE

blocks.cfg -> Blocks.pas
[cavecraft.git] / src / CAVE.mpsrc
index 830a6abac54eaeb688b7640322757eff3c4e9781..a43998d85f579e1be265f6d7b286907bd3f7f7a5 100644 (file)
@@ -1,7 +1,6 @@
 program CAVE;\r
 \r
 uses\r
- Items,\r
  sign,\r
  jsr75i,\r
  drop,\r
@@ -29,7 +28,10 @@ uses
  inv,\r
  items_store,\r
  video,\r
- Blocks;\r
+ Blocks,\r
+ BlocksLogic,\r
+ Items,\r
+ ItemsLogic;\r
 \r
 const\r
   version_map = 9;\r
@@ -1967,7 +1969,7 @@ procedure draw;
       else if getBiomMap(ix) = 3 then drawimage(osad[0, osadki_ani], (ix * 16) - camx, (iy * 16) - camy)\r
     end;\r
     if drw_back and Blocks.IsTransporent(getmap(ix, iy)) then draw_back(ix, iy);\r
-    if Blocks.IsForeground(getmap(ix,iy)) = false then draw_block(ix,iy);\r
+    if Blocks.IsForeground(getmap(ix,iy)) = false then BlocksLogic.Draw(ix, iy, camx, camy);\r
    end;\r
   {===================[drop]===================}\r
   Drop.Draw(camx, camy);\r
@@ -1981,7 +1983,7 @@ procedure draw;
   for ix:=minx to maxx do\r
   for iy:=miny to maxy do\r
     begin\r
-      if Blocks.IsForeground(getmap(ix, iy)) then draw_block(ix, iy);\r
+      if Blocks.IsForeground(getmap(ix, iy)) then BlocksLogic.Draw(ix, iy, camx, camy);\r
 \r
       setcolor(0, 0, 0);\r
       if light_type = 1 then\r
@@ -2028,7 +2030,7 @@ procedure draw;
     drawimage(gui[1],tmp_ax,0);\r
     for ix:=0 to 8 do\r
      begin\r
-      Items.Draw(inv.getItem(ix), inv.getSum(ix), (ix*16)+tmp_ax+ix*2+4, 1, true);\r
+      ItemsLogic.Draw(inv.getItem(ix), inv.getSum(ix), (ix*16)+tmp_ax+ix*2+4, 1, true);\r
      end;\r
     drawimage(gui[17],(invslot*16)+tmp_ax+invslot*2+2,0);\r
 \r
@@ -2169,14 +2171,14 @@ procedure usetools(invcur, x, y:integer);
   else\r
   if (block>0) then\r
    begin\r
-    if (Items.GetType(item) = Items.tool) and (getBlockTool(block)=getToolType(item)) then\r
+    if (Items.GetType(item) = Items.tool) and (Blocks.GetTool(block) = getToolType(item)) then\r
      toolus:=toolus+getToolSpeed(item);\r
     else\r
      toolus:=toolus+1;\r
 \r
-    if toolus>=getBlockHP(block) then\r
+    if toolus >= Blocks.GetResistant(block) then\r
      begin\r
-      if ((Items.GetType(item) = Items.tool) and (getBlockTool(block)=getToolType(item)) and (getToolLvl(item)>=getBlockLvl(block))) or (getBlockLvl(block)<=0) then\r
+      if ((Items.GetType(item) = Items.tool) and (Blocks.GetTool(block) = getToolType(item)) and (getToolLvl(item) >= Blocks.GetLevel(block))) or (Blocks.GetLevel(block) <= 0) then\r
        begin\r
         setMap(0, x, y);\r
         destroy_block_1(block, x, y);\r
@@ -2200,8 +2202,9 @@ procedure usetools(invcur, x, y:integer);
      end;\r
    end;\r
 \r
-  if (toolus>0) and (toolus<=getBlockHP(block)) then\r
-   toolind:=((toolus*100) div getBlockHP(block)) div 10;\r
+  if (toolus > 0) and (toolus <= Blocks.GetResistant(block)) then begin\r
+    toolind := ((toolus * 100) div Blocks.GetResistant(block)) div 10;\r
+  end;\r
  end;\r
 \r
 function rt_useweap:boolean;\r
@@ -2717,7 +2720,7 @@ procedure calc_sun(ix,m:integer);
    begin\r
     setmaplight(ss,ix,iy);\r
     if ss=0 then break;\r
-    ss:=ss-getBlockTr(getmap(ix,iy));\r
+    ss := ss - Blocks.GetLightAbsorbtion(getmap(ix, iy));\r
     if ss<0 then ss:=0;\r
    end;\r
   for iy:=iy+1 to 127 do\r
@@ -2844,9 +2847,10 @@ procedure game;
 \r
   if clock_stage<>game_time div 75000 then begin clock_stage:=clock_stage+1; if clock_stage>7 then clock_stage:=0; end;\r
 \r
-  if x<0 then x:=0;\r
-  if x+8>4094 then x:=4086;\r
-  if getBlockColl(getmap(x div 16, y div 16))>0 then hp:=hp-1;\r
+  if x < 0 then x := 0;\r
+  else if x + 8 > 4094 then x := 4086;\r
+  if Blocks.IsSolid(getmap(x div 16, y div 16)) then hp := hp - 1;\r
+\r
   if random(4096)=random(4096) then begin osadki:=not osadki; end;\r
   osadki_ani:=osadki_ani+1;\r
   if osadki_ani>7 then osadki_ani:=0;\r
@@ -2885,9 +2889,11 @@ procedure game;
   for ix:=minx to maxx do\r
   for iy:=miny to maxy do\r
    begin\r
-    if light_type=0 then setmaplight(15,ix,iy);\r
-     else\r
-    if light_type>0 then if getBlockLi(getmap(ix,iy))>0 then calc_light(getBlockLi(getmap(ix,iy)),ix,iy);\r
+    if light_type = 0 then begin\r
+      SetMapLight(15, ix, iy);\r
+    end else if (light_type > 0) and (Blocks.GetLightEmission(getmap(ix, iy)) > 0) then begin\r
+      calc_light(Blocks.GetLightEmission(GetMap(ix, iy)), ix, iy);\r
+    end;\r
    end;\r
 \r
   minx:=(camx/16)-((getwidth/2)/16);\r
@@ -3106,7 +3112,7 @@ procedure draw_debug;
       else if id = Items.painting5 then name := 'painting5'\r
       else if id = Items.painting6 then name := 'painting6'\r
       else if id = Items.painting7 then name := 'painting7'\r
-      else if id = Items.reservedBlockItem1 then name := 'reservedBlockItem1'\r
+      else if id = Items.giftChest then name := 'giftChest'\r
       else if id = Items.vines then name := 'vines'\r
       else if id = Items.sign then name := 'sign'\r
       else if id = Items.redstoneTorch then name := 'redstoneTorch'\r
@@ -3126,11 +3132,11 @@ procedure draw_debug;
       else if id = Items.glassPlane then name := 'glassPlane'\r
       else if id = Items.farmland then name := 'farmland'\r
       else if id = Items.cake then name := 'cake'\r
-      else if id = Items.reservedBlockItem2 then name := 'reservedBlockItem2'\r
-      else if id = Items.reservedBlockItem3 then name := 'reservedBlockItem3'\r
-      else if id = Items.reservedBlockItem4 then name := 'reservedBlockItem4'\r
-      else if id = Items.reservedBlockItem5 then name := 'reservedBlockItem5'\r
-      else if id = Items.reservedBlockItem6 then name := 'reservedBlockItem6'\r
+      else if id = Items.wheatBlock then name := 'wheatBlock'\r
+      else if id = Items.melonStem then name := 'melonStem'\r
+      else if id = Items.pumpkinStem then name := 'pumpkinStem'\r
+      else if id = Items.burningFurnace then name := 'burningFurnace'\r
+      else if id = Items.reservedBlockItem then name := 'reservedBlockItem'\r
       else if id = Items.stick then name := 'stick'\r
       else if id = Items.dandelionYellow then name := 'dandelionYellow'\r
       else if id = Items.roseRed then name := 'roseRed'\r
@@ -3271,6 +3277,21 @@ procedure draw_debug;
         for id := 0 to 194 do begin\r
           Debug('  InitOrdItem(' + ItemToString(Items.GetOrdinary(id)) + ');');\r
         end;\r
+\r
+        for id := 0 to 125 do begin\r
+          Debug('  InitBlock(' + ItemToString(id) + ', ' +\r
+                Blocks.GetTexture(id) + ', ' +\r
+                Blocks.GetResistant(id) + ', ' +\r
+                Blocks.GetTool(id) + ', ' +\r
+                Blocks.GetLevel(id) + ', ' +\r
+                Blocks.GetLightAbsorbtion(id) + ', ' +\r
+                Blocks.GetLightEmission(id) + ', ' +\r
+                Blocks.IsSolid(id) + ', ' +\r
+                Blocks.IsTransporent(id) + ', ' +\r
+                Blocks.IsForeground(id) + ', ' +\r
+                Blocks.IsOverlapped(id) + ');'\r
+          );\r
+        end;\r
       end;\r
 \r
 begin\r