diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc
index 0d305849e358ef1108de30fb24a68376cf90e8e9..db30c2db4d50e259f41ad8ed712db6320f5094ab 100644 (file)
--- a/src/CAVE.mpsrc
+++ b/src/CAVE.mpsrc
memory,\r
worldgen,\r
canvas,\r
- items,\r
safeload,\r
mobs,\r
console,\r
chest,\r
inv,\r
items_store,\r
- video;\r
+ video,\r
+ Blocks,\r
+ BlocksLogic,\r
+ Items,\r
+ ItemsLogic,\r
+ Tools;\r
\r
const\r
version_map = 9;\r
float := no;\r
compas := no;\r
for ix := 0 to 7 do\r
- clock[ix] := no;\r
+ Vars.clock[ix] := no;\r
\r
for ix := 0 to maxBlockTex do\r
begin\r
compas:=ld_tex('compass.png',path,'gui/');\r
im:=ld_tex('clock.png',path,'gui/');\r
for ix:=0 to 7 do \r
- clock[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0);\r
+ Vars.clock[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0);\r
if load_back_tex then\r
begin\r
im:=ld_tex('back.png',path,'');\r
item:=inv.getItem(invcur);\r
sum:=inv.getSum(invcur);\r
block:=getMap(x, y);\r
- sblock:=getItemInfo(item);\r
+ sblock := Items.GetData(item);\r
\r
- if getItemType(item)=ITEM_TYPE_BLOCK then\r
- if inv.isNull(invcur)=false then\r
- if getBlockSet(block)=true then\r
+ if (Items.GetType(item) = Items.block) and (Inv.IsNull(invcur) = false) then\r
+ if Blocks.IsOverlapped(block) then\r
// if (coll_xy(x, y)=false) or (getBlockColl(item)=0) then\r
begin\r
if set_block_code(sblock, x, y)=false then\r
for ix:=minx to maxx do\r
for iy:=miny to maxy do\r
begin\r
- if ifosad then if (getBackMap(ix)>=iy) and (osadki=true) and getBlockTrans(getmap(ix,iy)) then\r
- begin\r
- if getBiomMap(ix)=0 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy);\r
- else\r
- if getBiomMap(ix)=2 then drawimage(osad[1,osadki_ani],(ix*16)-camx,(iy*16)-camy);\r
- else\r
- if getBiomMap(ix)=3 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy);\r
- end;\r
- if drw_back then\r
- if getBlockTrans(getmap(ix,iy)) then\r
- draw_back(ix,iy);\r
-\r
- if getBlockFore(getmap(ix,iy))=false then\r
- draw_block(ix,iy);\r
+ if ifosad and osadki and (getBackMap(ix) >= iy) and Blocks.IsTransporent(getmap(ix, iy)) then begin\r
+ if getBiomMap(ix) = 0 then drawimage(osad[0, osadki_ani], (ix * 16) - camx, (iy * 16) - camy)\r
+ else if getBiomMap(ix) = 2 then drawimage(osad[1, osadki_ani], (ix * 16) - camx, (iy * 16) - camy)\r
+ 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 BlocksLogic.Draw(ix, iy, camx, camy);\r
end;\r
{===================[drop]===================}\r
Drop.Draw(camx, camy);\r
for ix:=minx to maxx do\r
for iy:=miny to maxy do\r
begin\r
- if getBlockFore(getmap(ix, iy)) then\r
- 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
drawimage(gui[1],tmp_ax,0);\r
for ix:=0 to 8 do\r
begin\r
- drawItem(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
toolind:=0;\r
end;\r
\r
-procedure usetools(invcur, x, y:integer);\r
- var\r
- item, sum, block:integer;\r
- begin\r
- block:=getmap(x, y);\r
- item:=inv.getItem(invcur);\r
- sum:=inv.getSum(invcur);\r
-\r
- if gamemode=1 then\r
- destroy_block_cr(block, x, y);\r
- else\r
- if (block>0) then\r
- begin\r
- if (getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) then\r
- toolus:=toolus+getToolSpeed(item);\r
- else\r
- toolus:=toolus+1;\r
-\r
- if toolus>=getBlockHP(block) then\r
- begin\r
- if ((getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) and (getToolLvl(item)>=getBlockLvl(block))) or (getBlockLvl(block)<=0) then\r
- begin\r
- setMap(0, x, y);\r
- destroy_block_1(block, x, y);\r
- setMapInfo(0, x, y);\r
- end;\r
- else\r
- begin\r
- setMap(0, x, y);\r
- destroy_block_0(block, x, y);\r
- setMapInfo(0, x, y);\r
- end;\r
-\r
- if getItemType(item)=ITEM_TYPE_TOOL then\r
- begin\r
- inv.setSum(inv.getSum(invcur)-1, invcur);\r
- inv.fixNull(invcur);\r
- end;\r
-\r
- toolus:=0;\r
- toolind:=0;\r
- end;\r
- end;\r
+ procedure usetools(invcur, x, y : integer);\r
+ var\r
+ item, sum, block, tool : integer;\r
+ begin\r
+ block := GetMap(x, y);\r
+ item := Inv.GetItem(invcur);\r
+ sum := Inv.GetSum(invcur);\r
+ tool := Items.GetData(item);\r
+\r
+ if gamemode = 1 then begin\r
+ destroy_block_cr(block, x, y);\r
+ end else if block <> 0 then begin\r
+ if (Items.GetType(item) = Items.tool) and (Blocks.GetTool(block) = Tools.GetType(tool)) then begin\r
+ toolus := toolus + Tools.GetSpeed(tool);\r
+ end else begin\r
+ toolus := toolus + 1;\r
+ end;\r
\r
- if (toolus>0) and (toolus<=getBlockHP(block)) then\r
- toolind:=((toolus*100) div getBlockHP(block)) div 10;\r
- end;\r
+ if toolus >= Blocks.GetResistant(block) then begin\r
+ Debug('usetools: tool = ' + tool);\r
+ if ((Items.GetType(item) = Items.tool) and (Blocks.GetTool(block) = Tools.GetType(tool)) and (Tools.GetLevel(tool) >= Blocks.GetLevel(block))) or (Blocks.GetLevel(block) <= 0) then begin\r
+ SetMap(0, x, y);\r
+ destroy_block_1(block, x, y);\r
+ SetMapInfo(0, x, y);\r
+ end else begin\r
+ SetMap(0, x, y);\r
+ destroy_block_0(block, x, y);\r
+ SetMapInfo(0, x, y);\r
+ end;\r
\r
-function rt_useweap:boolean;\r
- var\r
- x, y, w, h, i, damg:integer;\r
- item:integer;\r
- begin\r
- x:=player.getX;\r
- y:=player.getY;\r
- w:=player.getW;\r
- h:=player.getH;\r
- item:=inv.getItem(invslot);\r
+ if Items.GetType(item) = Items.tool then begin\r
+ Inv.SetSum(Inv.GetSum(invcur) - 1, invcur);\r
+ Inv.FixNull(invcur);\r
+ end;\r
\r
- if getItemType(item)=1 then\r
- damg:=getToolDamg(item);\r
- else\r
- damg:=1;\r
+ toolus:=0;\r
+ toolind:=0;\r
+ end;\r
+ end;\r
\r
- if posi=0 then\r
- i:=Mobs.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3);\r
- else\r
- i:=Mobs.findAndHit(damg, x+(w/2), y, TILE_SIZE+(w/2), h, 2, -3);\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
- if i<>-1 then\r
- begin\r
- inv.setSum(inv.getSum(invslot)-1, invslot);\r
- inv.fixNull(invslot);\r
- rt_useweap:=true;\r
- end;\r
- end;\r
+ function rt_useweap:boolean;\r
+ var\r
+ item : integer;\r
+ x, y, w, h, i, damg : integer;\r
+ begin\r
+ x := Player.GetX;\r
+ y := Player.GetY;\r
+ w := Player.GetW;\r
+ h := Player.GetH;\r
+ item := Inv.GetItem(invslot);\r
+ if Items.GetType(item) = Items.tool then damg := Tools.GetDamage(item) else damg := 1;\r
+\r
+ if posi=0 then i := Mobs.FindAndHit(damg, x - TILE_SIZE, y, TILE_SIZE + (w / 2), h, -2, -3);\r
+ else i := Mobs.FindAndHit(damg, x + (w / 2), y, TILE_SIZE + (w / 2), h, 2, -3);\r
+\r
+ if i >= 0 then begin\r
+ Inv.SetSum(Inv.GetSum(invslot) - 1, invslot);\r
+ Inv.FixNull(invslot);\r
+ rt_useweap := true;\r
+ end;\r
+ end;\r
\r
procedure rt_usetools;\r
var\r
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
\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
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
hp_time:=getrelativetimems;\r
air_time:=getrelativetimems;\r
portal_time:=getrelativetimems;\r
+\r
repeat\r
proc_fps;\r
keyhandler;\r