summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 741fddd)
raw | patch | inline | side by side (parent: 741fddd)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 1 Nov 2014 11:11:38 +0000 (14:11 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 1 Nov 2014 11:11:38 +0000 (14:11 +0300) |
114 files changed:
libs/Lib_bmp.class | [new file with mode: 0644] | patch | blob |
libs/Lib_canvas.class | [new file with mode: 0644] | patch | blob |
libs/Lib_effects.class | [new file with mode: 0644] | patch | blob |
libs/Lib_imgcolor.class | [new file with mode: 0644] | patch | blob |
libs/Lib_items_store.class | [new file with mode: 0644] | patch | blob |
libs/Lib_items_store.java | [new file with mode: 0644] | patch | blob |
libs/Lib_jpeg.class | [new file with mode: 0644] | patch | blob |
libs/Lib_jsr75i.class | [new file with mode: 0644] | patch | blob |
libs/Lib_localfiles.java | [new file with mode: 0644] | patch | blob |
libs/Lib_maps.class | [new file with mode: 0644] | patch | blob |
libs/Lib_memory.class | [new file with mode: 0644] | patch | blob |
libs/Lib_particles_store.class | [new file with mode: 0644] | patch | blob |
libs/Lib_particles_store.java | [new file with mode: 0644] | patch | blob |
libs/Lib_png3.class | [new file with mode: 0644] | patch | blob |
libs/Lib_safeload.class | [new file with mode: 0644] | patch | blob |
libs/Lib_scri.class | [new file with mode: 0644] | patch | blob |
libs/Lib_sensor.class | [new file with mode: 0644] | patch | blob |
res/Adler32.class | [new file with mode: 0644] | patch | blob |
res/Deflate$Config.class | [new file with mode: 0644] | patch | blob |
res/Deflate.class | [new file with mode: 0644] | patch | blob |
res/Encoder.class | [new file with mode: 0644] | patch | blob |
res/JZlib.class | [new file with mode: 0644] | patch | blob |
res/JpegEncoder$DCT.class | [new file with mode: 0644] | patch | blob |
res/JpegEncoder$Huffman.class | [new file with mode: 0644] | patch | blob |
res/JpegEncoder$JpegInfo.class | [new file with mode: 0644] | patch | blob |
res/JpegEncoder.class | [new file with mode: 0644] | patch | blob |
res/META-INF/MANIFEST.MF | [new file with mode: 0644] | patch | blob |
res/StaticTree.class | [new file with mode: 0644] | patch | blob |
res/Tree.class | [new file with mode: 0644] | patch | blob |
res/ZStream.class | [new file with mode: 0644] | patch | blob |
res/autoexec.cfg | [new file with mode: 0644] | patch | blob |
res/back.png | [new file with mode: 0644] | patch | blob |
res/blocks.cfg | [new file with mode: 0644] | patch | blob |
res/crafts.cfg | [new file with mode: 0644] | patch | blob |
res/default_font.png | [new file with mode: 0644] | patch | blob |
res/dl | [new file with mode: 0644] | patch | blob |
res/furnace.cfg | [new file with mode: 0644] | patch | blob |
res/gui/clock.png | [new file with mode: 0644] | patch | blob |
res/gui/compass.png | [new file with mode: 0644] | patch | blob |
res/gui/container.png | [new file with mode: 0644] | patch | blob |
res/gui/creative.png | [new file with mode: 0644] | patch | blob |
res/gui/fastcraft.png | [new file with mode: 0644] | patch | blob |
res/gui/float.png | [new file with mode: 0644] | patch | blob |
res/gui/furnace.png | [new file with mode: 0644] | patch | blob |
res/gui/gui.png | [new file with mode: 0644] | patch | blob |
res/gui/inventory.png | [new file with mode: 0644] | patch | blob |
res/gui/items.png | [new file with mode: 0644] | patch | blob |
res/gui/mapbg.png | [new file with mode: 0644] | patch | blob |
res/gui/partition.png | [new file with mode: 0644] | patch | blob |
res/gui/sign.png | [new file with mode: 0644] | patch | blob |
res/gui/touch.png | [new file with mode: 0644] | patch | blob |
res/inputStream.class | [new file with mode: 0644] | patch | blob |
res/items.cfg | [new file with mode: 0644] | patch | blob |
res/keyboard.cfg | [new file with mode: 0644] | patch | blob |
res/maps.png | [new file with mode: 0644] | patch | blob |
res/mobs/char_ani.png | [new file with mode: 0644] | patch | blob |
res/mobs/chicken_anims.png | [new file with mode: 0644] | patch | blob |
res/mobs/cow.png | [new file with mode: 0644] | patch | blob |
res/mobs/cow2.png | [new file with mode: 0644] | patch | blob |
res/mobs/creeper_anims.png | [new file with mode: 0644] | patch | blob |
res/mobs/pig_anims.png | [new file with mode: 0644] | patch | blob |
res/mobs/pigman_ani.png | [new file with mode: 0644] | patch | blob |
res/mobs/sheep_anims.png | [new file with mode: 0644] | patch | blob |
res/mobs/sheep_fur.png | [new file with mode: 0644] | patch | blob |
res/mobs/spider_ani.png | [new file with mode: 0644] | patch | blob |
res/mobs/zombie_ani.png | [new file with mode: 0644] | patch | blob |
res/pack.png | [new file with mode: 0644] | patch | blob |
res/terrain.png | [new file with mode: 0644] | patch | blob |
res/terrain/explosion.png | [new file with mode: 0644] | patch | blob |
res/terrain/light.png | [new file with mode: 0644] | patch | blob |
res/terrain/moon_phases/moon_phase_0.png | [new file with mode: 0644] | patch | blob |
res/terrain/moon_phases/moon_phase_1.png | [new file with mode: 0644] | patch | blob |
res/terrain/moon_phases/moon_phase_2.png | [new file with mode: 0644] | patch | blob |
res/terrain/moon_phases/moon_phase_3.png | [new file with mode: 0644] | patch | blob |
res/terrain/moon_phases/moon_phase_4.png | [new file with mode: 0644] | patch | blob |
res/terrain/moon_phases/moon_phase_5.png | [new file with mode: 0644] | patch | blob |
res/terrain/moon_phases/moon_phase_6.png | [new file with mode: 0644] | patch | blob |
res/terrain/moon_phases/moon_phase_7.png | [new file with mode: 0644] | patch | blob |
res/terrain/particles.png | [new file with mode: 0644] | patch | blob |
res/terrain/rain.png | [new file with mode: 0644] | patch | blob |
res/terrain/sky.png | [new file with mode: 0644] | patch | blob |
res/terrain/snow.png | [new file with mode: 0644] | patch | blob |
res/terrain/sun.png | [new file with mode: 0644] | patch | blob |
res/textures.cfg | [new file with mode: 0644] | patch | blob |
res/title/background.png | [new file with mode: 0644] | patch | blob |
res/title/cavelogo.png | [new file with mode: 0644] | patch | blob |
res/title/icon.png | [new file with mode: 0644] | patch | blob |
res/title/splashes.txt | [new file with mode: 0644] | patch | blob |
res/tools.cfg | [new file with mode: 0644] | patch | blob |
res/vkeyboard.cfg | [new file with mode: 0644] | patch | blob |
src/CAVE.mpsrc | [new file with mode: 0644] | patch | blob |
src/cellui.mpsrc | [new file with mode: 0644] | patch | blob |
src/chest.mpsrc | [new file with mode: 0644] | patch | blob |
src/console.pas | [new file with mode: 0644] | patch | blob |
src/craft.mpsrc | [new file with mode: 0644] | patch | blob |
src/drop.mpsrc | [new file with mode: 0644] | patch | blob |
src/func.mpsrc | [new file with mode: 0644] | patch | blob |
src/furnace.mpsrc | [new file with mode: 0644] | patch | blob |
src/gameui.mpsrc | [new file with mode: 0644] | patch | blob |
src/inv.mpsrc | [new file with mode: 0644] | patch | blob |
src/invui.mpsrc | [new file with mode: 0644] | patch | blob |
src/items.mpsrc | [new file with mode: 0644] | patch | blob |
src/items_logic.mpsrc | [new file with mode: 0644] | patch | blob |
src/keyboard.mpsrc | [new file with mode: 0644] | patch | blob |
src/mobs.pas | [new file with mode: 0644] | patch | blob |
src/particles.mpsrc | [new file with mode: 0644] | patch | blob |
src/phy.pas | [new file with mode: 0644] | patch | blob |
src/player.mpsrc | [new file with mode: 0644] | patch | blob |
src/randoms.mpsrc | [new file with mode: 0644] | patch | blob |
src/sign.pas | [new file with mode: 0644] | patch | blob |
src/utils.mpsrc | [new file with mode: 0644] | patch | blob |
src/vars.mpsrc | [new file with mode: 0644] | patch | blob |
src/video.pas | [new file with mode: 0644] | patch | blob |
src/worldgen.mpsrc | [new file with mode: 0644] | patch | blob |
diff --git a/libs/Lib_bmp.class b/libs/Lib_bmp.class
new file mode 100644 (file)
index 0000000..c8c46b2
Binary files /dev/null and b/libs/Lib_bmp.class differ
index 0000000..c8c46b2
Binary files /dev/null and b/libs/Lib_bmp.class differ
diff --git a/libs/Lib_canvas.class b/libs/Lib_canvas.class
new file mode 100644 (file)
index 0000000..d14f4af
Binary files /dev/null and b/libs/Lib_canvas.class differ
index 0000000..d14f4af
Binary files /dev/null and b/libs/Lib_canvas.class differ
diff --git a/libs/Lib_effects.class b/libs/Lib_effects.class
new file mode 100644 (file)
index 0000000..79c6238
Binary files /dev/null and b/libs/Lib_effects.class differ
index 0000000..79c6238
Binary files /dev/null and b/libs/Lib_effects.class differ
diff --git a/libs/Lib_imgcolor.class b/libs/Lib_imgcolor.class
new file mode 100644 (file)
index 0000000..9c59916
Binary files /dev/null and b/libs/Lib_imgcolor.class differ
index 0000000..9c59916
Binary files /dev/null and b/libs/Lib_imgcolor.class differ
diff --git a/libs/Lib_items_store.class b/libs/Lib_items_store.class
new file mode 100644 (file)
index 0000000..c6958aa
Binary files /dev/null and b/libs/Lib_items_store.class differ
index 0000000..c6958aa
Binary files /dev/null and b/libs/Lib_items_store.class differ
diff --git a/libs/Lib_items_store.java b/libs/Lib_items_store.java
--- /dev/null
@@ -0,0 +1,322 @@
+class Lib_items_store\r
+ {\r
+ /*Items*/\r
+ static byte[] item_type;\r
+ static byte[] item_tex;\r
+ static int[] item_max;\r
+ static byte[] item_info;\r
+ static byte[] item_flags;\r
+ /*Blocks*/\r
+ static byte[] block_tex;\r
+ static int[] block_hp;\r
+ static byte[] block_coll;\r
+ static byte[] block_tool;\r
+ static byte[] block_lvl;\r
+ static byte[] block_flags;\r
+ static byte[] block_tr;\r
+ static byte[] block_li;\r
+ /*Craft*/\r
+ static byte[] [] craftIN_item;\r
+ static byte[] [] craftIN_sum;\r
+ static byte[] craftOUT_item;\r
+ static int[] craftOUT_sum;\r
+ static byte[] craftOUT_flag;\r
+ /*Tools*/\r
+ static byte[] tool_type;\r
+ static byte[] tool_lvl;\r
+ static byte[] tool_speed;\r
+ static byte[] tool_damg;\r
+\r
+/*Items*/\r
+ public static void resetitems(int len)\r
+ {\r
+ try {\r
+ item_type = new byte[len];\r
+ item_tex = new byte[len];\r
+ item_max = new int[len];\r
+ item_info = new byte[len];\r
+ item_flags = new byte[len];\r
+ } catch(Exception e) {e.printStackTrace();}\r
+ }\r
+\r
+ public static void setitemdata(int id, int type, int tex, int max, int info, int flags)\r
+ {\r
+ try {\r
+ item_type[id] = (byte) type;\r
+ item_tex[id] = (byte) tex;\r
+ item_max[id] = max;\r
+ item_info[id] = (byte) info;\r
+ item_flags[id] = (byte) flags;\r
+ } catch(Exception e) {e.printStackTrace();}\r
+ }\r
+\r
+ public static int getitemtype(int id)\r
+ {\r
+ try {\r
+ return (int) item_type[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getitemtex(int id)\r
+ {\r
+ try {\r
+ return (int) item_tex[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getitemmax(int id)\r
+ {\r
+ try{\r
+ return item_max[id];\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getiteminfo(int id)\r
+ {\r
+ try {\r
+ return (int) item_info[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+ \r
+ public static int getitemflags(int id)\r
+ {\r
+ try {\r
+ return (int) item_flags[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+/*Blocks*/\r
+\r
+ public static void resetblocks(int len)\r
+ {\r
+ try {\r
+ block_tex = new byte[len];\r
+ block_hp = new int[len];\r
+ block_coll = new byte[len];\r
+ block_tool = new byte[len];\r
+ block_lvl = new byte[len];\r
+ block_flags = new byte[len];\r
+ block_tr = new byte[len];\r
+ block_li = new byte[len];\r
+ } catch(Exception e) {e.printStackTrace();}\r
+ }\r
+\r
+ public static void setblockdata(int id, int tex, int hp, int coll, int tool, int lvl, int flags, int tr, int li)\r
+ {\r
+ try {\r
+ block_tex[id] = (byte) tex;\r
+ block_hp[id] = hp;\r
+ block_coll[id] = (byte) coll;\r
+ block_tool[id] = (byte) tool;\r
+ block_lvl[id] = (byte) lvl;\r
+ block_flags[id] = (byte) flags;\r
+ block_tr[id] = (byte) tr;\r
+ block_li[id] = (byte) li;\r
+ } catch(Exception e) {e.printStackTrace();}\r
+ }\r
+\r
+ public static int getblocktex(int id)\r
+ {\r
+ try {\r
+ return (int) block_tex[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getblockhp(int id)\r
+ {\r
+ try {\r
+ return block_hp[id];\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getblockcoll(int id)\r
+ {\r
+ try {\r
+ return (int) block_coll[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getblocktool(int id)\r
+ {\r
+ try {\r
+ return (int) block_tool[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getblocklvl(int id)\r
+ {\r
+ try {\r
+ return (int) block_lvl[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getblockflags(int id)\r
+ {\r
+ try {\r
+ return (int) block_flags[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getblocktr(int id)\r
+ {\r
+ try {\r
+ return (int) block_tr[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int getblockli(int id)\r
+ {\r
+ try {\r
+ return (int) block_li[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ /*Craft*/\r
+ public static void reset_crafts(int len)\r
+ {\r
+ try {\r
+ craftIN_item = new byte[4][len];\r
+ craftIN_sum = new byte[4][len];\r
+ craftOUT_item = new byte[len];\r
+ craftOUT_sum = new int[len];\r
+ craftOUT_flag = new byte[len];\r
+ } catch(Exception e) {e.printStackTrace();}\r
+ }\r
+\r
+ public static void set_craft(int id, int item0, int sum0, int item1, int sum1, int item2, int sum2, int item3, int sum3, int outitem, int outsum, int flag)\r
+ {\r
+ try {\r
+ craftIN_item[0][id] = (byte) item0;\r
+ craftIN_sum[0][id] = (byte) sum0;\r
+ craftIN_item[1][id] = (byte) item1;\r
+ craftIN_sum[1][id] = (byte) sum1;\r
+ craftIN_item[2][id] = (byte) item2;\r
+ craftIN_sum[2][id] = (byte) sum2;\r
+ craftIN_item[3][id] = (byte) item3;\r
+ craftIN_sum[3][id] = (byte) sum3;\r
+ craftOUT_item[id] = (byte) outitem;\r
+ craftOUT_sum[id] = outsum;\r
+ craftOUT_flag[id] = (byte) flag;\r
+ } catch(Exception e) {e.printStackTrace();}\r
+ }\r
+\r
+ public static void set_craftin_item(int id, int num, int item)\r
+ {\r
+ try {\r
+ craftIN_item[num][id] = (byte) item;\r
+ } catch(Exception e) {/*e.printStackTrace();*/}\r
+ }\r
+\r
+ public static void set_craftin_sum(int id, int num, int sum)\r
+ {\r
+ try {\r
+ craftIN_sum[num][id] = (byte) sum;\r
+ } catch(Exception e) {/*e.printStackTrace();*/}\r
+ }\r
+\r
+ public static void set_craftout_item(int id, int item)\r
+ {\r
+ try {\r
+ craftOUT_item[id] = (byte) item;\r
+ } catch(Exception e) {/*e.printStackTrace();*/}\r
+ }\r
+\r
+ public static void set_craftout_sum(int id, int sum)\r
+ {\r
+ try {\r
+ craftOUT_sum[id] = sum;\r
+ } catch(Exception e) {/*e.printStackTrace();*/}\r
+ }\r
+\r
+ public static void set_craftout_flag(int id, int flag)\r
+ {\r
+ try {\r
+ craftOUT_flag[id] = (byte) flag;\r
+ } catch(Exception e) {/*e.printStackTrace();*/}\r
+ }\r
+\r
+ public static int get_craftin_item(int id, int num)\r
+ {\r
+ try {\r
+ return craftIN_item[num][id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int get_craftin_sum(int id, int num)\r
+ {\r
+ try {\r
+ return craftIN_sum[num][id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int get_craftout_item(int id)\r
+ {\r
+ try {\r
+ return craftOUT_item[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int get_craftout_sum(int id)\r
+ {\r
+ try {\r
+ return craftOUT_sum[id];\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int get_craftout_flag(int id)\r
+ {\r
+ try {\r
+ return craftOUT_flag[id] & 0xFF;\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0xFF;}\r
+ }\r
+\r
+/*Tools*/\r
+ public static void resettools(int len)\r
+ {\r
+ try {\r
+ tool_type = new byte[len];\r
+ tool_lvl = new byte[len];\r
+ tool_speed = new byte[len];\r
+ tool_damg = new byte[len];\r
+ } catch(Exception e) {e.printStackTrace();}\r
+ }\r
+\r
+ public static void settooldata(int id, int tool, int lvl, int speed, int damg)\r
+ {\r
+ try {\r
+ tool_type[id] = (byte) tool;\r
+ tool_lvl[id] = (byte) lvl;\r
+ tool_speed[id] = (byte) speed;\r
+ tool_damg[id] = (byte) damg;\r
+ } catch(Exception e) {e.printStackTrace();}\r
+ }\r
+\r
+ public static int gettooltype(int id)\r
+ {\r
+ try {\r
+ return tool_type[item_info[id]];\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int gettoollvl(int id)\r
+ {\r
+ try {\r
+ return tool_lvl[item_info[id]];\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int gettoolspeed(int id)\r
+ {\r
+ try {\r
+ return tool_speed[item_info[id]];\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ public static int gettooldamg(int id)\r
+ {\r
+ try {\r
+ return tool_damg[item_info[id]];\r
+ } catch(Exception e) {/*e.printStackTrace();*/ return 0;}\r
+ }\r
+\r
+ }
\ No newline at end of file
diff --git a/libs/Lib_jpeg.class b/libs/Lib_jpeg.class
new file mode 100644 (file)
index 0000000..0ccf642
Binary files /dev/null and b/libs/Lib_jpeg.class differ
index 0000000..0ccf642
Binary files /dev/null and b/libs/Lib_jpeg.class differ
diff --git a/libs/Lib_jsr75i.class b/libs/Lib_jsr75i.class
new file mode 100644 (file)
index 0000000..997963e
Binary files /dev/null and b/libs/Lib_jsr75i.class differ
index 0000000..997963e
Binary files /dev/null and b/libs/Lib_jsr75i.class differ
diff --git a/libs/Lib_localfiles.java b/libs/Lib_localfiles.java
--- /dev/null
+++ b/libs/Lib_localfiles.java
@@ -0,0 +1,12 @@
+import java.io.*;\r
+\r
+class Lib_localfiles\r
+{\r
+ public static int readunsbyte(InputStream is)\r
+ {\r
+ try{\r
+ DataInputStream dis = new DataInputStream(is);\r
+ return (int) dis.readUnsignedByte();\r
+ } catch(Exception e) {return -1;}\r
+ }\r
+}
\ No newline at end of file
diff --git a/libs/Lib_maps.class b/libs/Lib_maps.class
new file mode 100644 (file)
index 0000000..949f1c9
Binary files /dev/null and b/libs/Lib_maps.class differ
index 0000000..949f1c9
Binary files /dev/null and b/libs/Lib_maps.class differ
diff --git a/libs/Lib_memory.class b/libs/Lib_memory.class
new file mode 100644 (file)
index 0000000..d256c34
Binary files /dev/null and b/libs/Lib_memory.class differ
index 0000000..d256c34
Binary files /dev/null and b/libs/Lib_memory.class differ
diff --git a/libs/Lib_particles_store.class b/libs/Lib_particles_store.class
new file mode 100644 (file)
index 0000000..53fce20
Binary files /dev/null and b/libs/Lib_particles_store.class differ
index 0000000..53fce20
Binary files /dev/null and b/libs/Lib_particles_store.class differ
diff --git a/libs/Lib_particles_store.java b/libs/Lib_particles_store.java
--- /dev/null
@@ -0,0 +1,63 @@
+class Lib_particles_store\r
+ {\r
+ static byte[] particle_type;\r
+ static byte[] particle_ani;\r
+ static short[] particle_x;\r
+ static short[] particle_y;\r
+\r
+ public static void reset_particles(int len)\r
+ {\r
+ particle_type = new byte[len];\r
+ particle_ani = new byte[len];\r
+ particle_x = new short[len];\r
+ particle_y = new short[len];\r
+ }\r
+\r
+ public static void set_particle(int id, int type, int ani, int x, int y)\r
+ {\r
+ particle_type[id] = (byte) type;\r
+ particle_ani[id] = (byte) ani;\r
+ particle_x[id] = (short) x;\r
+ particle_y[id] = (short) y;\r
+ }\r
+\r
+ public static void set_particle_type(int id, int type)\r
+ {\r
+ particle_type[id] = (byte) type;\r
+ }\r
+\r
+ public static void set_particle_ani(int id, int ani)\r
+ {\r
+ particle_ani[id] = (byte) ani;\r
+ }\r
+\r
+ public static void set_particle_x(int id, int x)\r
+ {\r
+ particle_x[id] = (short) x;\r
+ }\r
+\r
+ public static void set_particle_y(int id, int y)\r
+ {\r
+ particle_y[id] = (short) y;\r
+ }\r
+\r
+ public static int get_particle_type(int id)\r
+ {\r
+ return particle_type[id] & 0xFF;\r
+ }\r
+\r
+ public static int get_particle_ani(int id)\r
+ {\r
+ return particle_ani[id] & 0xFF;\r
+ }\r
+\r
+ public static int get_particle_x(int id)\r
+ {\r
+ return particle_x[id];\r
+ }\r
+\r
+ public static int get_particle_y(int id)\r
+ {\r
+ return particle_y[id];\r
+ }\r
+}
\ No newline at end of file
diff --git a/libs/Lib_png3.class b/libs/Lib_png3.class
new file mode 100644 (file)
index 0000000..8818ef1
Binary files /dev/null and b/libs/Lib_png3.class differ
index 0000000..8818ef1
Binary files /dev/null and b/libs/Lib_png3.class differ
diff --git a/libs/Lib_safeload.class b/libs/Lib_safeload.class
new file mode 100644 (file)
index 0000000..0dec1f4
Binary files /dev/null and b/libs/Lib_safeload.class differ
index 0000000..0dec1f4
Binary files /dev/null and b/libs/Lib_safeload.class differ
diff --git a/libs/Lib_scri.class b/libs/Lib_scri.class
new file mode 100644 (file)
index 0000000..29f463d
Binary files /dev/null and b/libs/Lib_scri.class differ
index 0000000..29f463d
Binary files /dev/null and b/libs/Lib_scri.class differ
diff --git a/libs/Lib_sensor.class b/libs/Lib_sensor.class
new file mode 100644 (file)
index 0000000..4e2d699
Binary files /dev/null and b/libs/Lib_sensor.class differ
index 0000000..4e2d699
Binary files /dev/null and b/libs/Lib_sensor.class differ
diff --git a/res/Adler32.class b/res/Adler32.class
new file mode 100644 (file)
index 0000000..d64f244
Binary files /dev/null and b/res/Adler32.class differ
index 0000000..d64f244
Binary files /dev/null and b/res/Adler32.class differ
diff --git a/res/Deflate$Config.class b/res/Deflate$Config.class
new file mode 100644 (file)
index 0000000..bf9ff11
Binary files /dev/null and b/res/Deflate$Config.class differ
index 0000000..bf9ff11
Binary files /dev/null and b/res/Deflate$Config.class differ
diff --git a/res/Deflate.class b/res/Deflate.class
new file mode 100644 (file)
index 0000000..50794d6
Binary files /dev/null and b/res/Deflate.class differ
index 0000000..50794d6
Binary files /dev/null and b/res/Deflate.class differ
diff --git a/res/Encoder.class b/res/Encoder.class
new file mode 100644 (file)
index 0000000..5f05702
Binary files /dev/null and b/res/Encoder.class differ
index 0000000..5f05702
Binary files /dev/null and b/res/Encoder.class differ
diff --git a/res/JZlib.class b/res/JZlib.class
new file mode 100644 (file)
index 0000000..a036122
Binary files /dev/null and b/res/JZlib.class differ
index 0000000..a036122
Binary files /dev/null and b/res/JZlib.class differ
diff --git a/res/JpegEncoder$DCT.class b/res/JpegEncoder$DCT.class
new file mode 100644 (file)
index 0000000..656153a
Binary files /dev/null and b/res/JpegEncoder$DCT.class differ
index 0000000..656153a
Binary files /dev/null and b/res/JpegEncoder$DCT.class differ
diff --git a/res/JpegEncoder$Huffman.class b/res/JpegEncoder$Huffman.class
new file mode 100644 (file)
index 0000000..e2bd3a1
Binary files /dev/null and b/res/JpegEncoder$Huffman.class differ
index 0000000..e2bd3a1
Binary files /dev/null and b/res/JpegEncoder$Huffman.class differ
diff --git a/res/JpegEncoder$JpegInfo.class b/res/JpegEncoder$JpegInfo.class
new file mode 100644 (file)
index 0000000..8cddb3e
Binary files /dev/null and b/res/JpegEncoder$JpegInfo.class differ
index 0000000..8cddb3e
Binary files /dev/null and b/res/JpegEncoder$JpegInfo.class differ
diff --git a/res/JpegEncoder.class b/res/JpegEncoder.class
new file mode 100644 (file)
index 0000000..48f579d
Binary files /dev/null and b/res/JpegEncoder.class differ
index 0000000..48f579d
Binary files /dev/null and b/res/JpegEncoder.class differ
diff --git a/res/META-INF/MANIFEST.MF b/res/META-INF/MANIFEST.MF
--- /dev/null
+++ b/res/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0\r
+MIDlet-1: bin, /icon.png, FW\r
+MIDlet-Name: bin\r
+MIDlet-Vendor: MIDletPascal3\r
+MIDlet-Version: 04082014.214104\r
+MicroEdition-Configuration: CLDC-1.0\r
+MicroEdition-Profile: MIDP-2.0\r
+MIDlet-Icon: /icon.png\r
+Created-By: Build-Script V1.03 (DeaDSoftWare)\r
diff --git a/res/StaticTree.class b/res/StaticTree.class
new file mode 100644 (file)
index 0000000..6baf9d9
Binary files /dev/null and b/res/StaticTree.class differ
index 0000000..6baf9d9
Binary files /dev/null and b/res/StaticTree.class differ
diff --git a/res/Tree.class b/res/Tree.class
new file mode 100644 (file)
index 0000000..b3fc347
Binary files /dev/null and b/res/Tree.class differ
index 0000000..b3fc347
Binary files /dev/null and b/res/Tree.class differ
diff --git a/res/ZStream.class b/res/ZStream.class
new file mode 100644 (file)
index 0000000..afb48d5
Binary files /dev/null and b/res/ZStream.class differ
index 0000000..afb48d5
Binary files /dev/null and b/res/ZStream.class differ
diff --git a/res/autoexec.cfg b/res/autoexec.cfg
--- /dev/null
+++ b/res/autoexec.cfg
@@ -0,0 +1,36 @@
+;Standard execute file for CaveCraft\r
+SET_RESOLUTION 240 320 TRUE\r
+BL_UPD 2\r
+REF_DRP TRUE\r
+GET_DRP TRUE\r
+SPAWN_MOBS TRUE\r
+PRT_UPD TRUE\r
+MAX_FPS 30\r
+DRW_BACK TRUE\r
+DRP_PHY TRUE\r
+DRW_SM TRUE\r
+JPEG_Q 100\r
+LOAD_SM 2\r
+S_WEATHER FALSE\r
+S_LIGHT FALSE\r
+S_PARTICLES FALSE\r
+LOAD_SKY 0\r
+LOAD_BACK_TEX TRUE\r
+LOAD_WEATHER_TEX TRUE\r
+LOAD_PARTICLES_TEX TRUE\r
+LOAD_LIGHT_TEX TRUE\r
+LOAD_GUI_TEX TRUE\r
+MENU_BACKGROUND 1\r
+DRW_DRP TRUE\r
+DRW_STARS TRUE\r
+LD_SETT\r
+LOAD_MINIMAP_TEX TRUE\r
+MAX_PARTICLES 255\r
+EXEC AUTO keyboard.cfg\r
+EXEC AUTO vkeyboard.cfg\r
+EXEC AUTO textures.cfg\r
+EXEC AUTO items.cfg\r
+EXEC AUTO blocks.cfg\r
+EXEC AUTO crafts.cfg\r
+EXEC AUTO tools.cfg\r
+EXEC AUTO furnace.cfg\r
diff --git a/res/back.png b/res/back.png
diff --git a/res/blocks.cfg b/res/blocks.cfg
--- /dev/null
+++ b/res/blocks.cfg
@@ -0,0 +1,250 @@
+;Файл инициализации описания свойств стандартного набора блоков CaveCraft\r
+;Все описанные здесь блоки могут отображаться на карте.\r
+\r
+;Устанавливаем количество блоков\r
+RESET_BLOCKS 124\r
+\r
+;Описание команды установки блока:\r
+;SET_BLOCK [id] [tex] [hp] [coll] [tool] [lvl] [flags] [tr] [li]\r
+;id - индентификатор блока.\r
+;tex - номер текстуры блока из terrain.png. \r
+;hp - прочность блока.\r
+;coll - тип коллизии:\r
+; 0 - проходимый\r
+; 1 - полностью твёрдый\r
+;tool - тип инструмента необходимый для "правильной" поломки болка.\r
+;lvl - минимальный уровень инструмента необходимый для "правильной" поломки блока:\r
+; 0 - руки\r
+; 1 - дерево\r
+; 2 - камень\r
+; 3 - железо\r
+; 4 - золото\r
+; 5 - алмазы\r
+;flags - битовые флаги:\r
+; b001 - объект (полу)прозрачный\r
+; b010 - рисовать за/перед игроком\r
+; b100 - можно устанавливать поверх этого блока\r
+;tr - уровень светопоглощения\r
+;li - уровень светоизлучения\r
+\r
+;Null\r
+SET_BLOCK 0 0 0 0 0 0 b101 0 0\r
+;Земля\r
+SET_BLOCK 1 1 9 1 2 0 b000 15 0\r
+;Трава\r
+SET_BLOCK 2 2 9 1 2 0 b000 15 0\r
+;Камень\r
+SET_BLOCK 3 3 60 1 1 1 b000 15 0\r
+;Доски\r
+SET_BLOCK 4 4 30 1 3 0 b000 15 0\r
+;Булыжник\r
+SET_BLOCK 5 5 60 1 1 1 b000 15 0\r
+;Админиум\r
+SET_BLOCK 6 6 0x7FFFFFFF 1 0 0 b000 15 0\r
+;Песок\r
+SET_BLOCK 7 7 9 1 2 0 b000 15 0\r
+;Гравий\r
+SET_BLOCK 8 8 9 1 2 0 b000 15 0\r
+;Дерево\r
+SET_BLOCK 9 9 30 1 3 0 b000 15 0\r
+;Обсидиан\r
+SET_BLOCK 10 10 1000 1 1 5 b000 15 0\r
+;Книжный шкаф\r
+SET_BLOCK 11 11 24 0 3 0 b000 0 0\r
+;Замшелый булыжник\r
+SET_BLOCK 12 12 40 1 1 1 b000 15 0\r
+;Железный блок\r
+SET_BLOCK 13 13 40 1 1 2 b000 15 0\r
+;Золотой блок\r
+SET_BLOCK 14 14 60 1 1 3 b000 15 0\r
+;Алмазный блок\r
+SET_BLOCK 15 15 60 1 1 3 b000 15 0\r
+;Золотая руда\r
+SET_BLOCK 16 16 65 1 1 3 b000 15 0\r
+;Железная руда\r
+SET_BLOCK 17 17 65 1 1 2 b000 15 0\r
+;Угольная руда\r
+SET_BLOCK 18 18 65 1 1 1 b000 15 0\r
+;Алмазная руда\r
+SET_BLOCK 19 19 65 1 1 3 b000 15 0\r
+;Красная руда\r
+SET_BLOCK 20 20 65 1 1 3 b000 15 6\r
+;Листва\r
+SET_BLOCK 21 21 3 1 4 1 b000 1 0\r
+;Красный цветок\r
+SET_BLOCK 22 22 0 0 0 0 b101 0 0\r
+;Жёлтый цветок\r
+SET_BLOCK 23 23 0 0 0 0 b101 0 0\r
+;Красный гриб\r
+SET_BLOCK 24 24 0 0 0 0 b101 0 0\r
+;Коричневый гриб\r
+SET_BLOCK 25 25 0 0 0 0 b101 0 0\r
+;Факел\r
+SET_BLOCK 26 26 0 0 0 0 b001 0 14\r
+;Динамит\r
+SET_BLOCK 27 27 0 1 0 0 b000 15 0\r
+;Сундук\r
+SET_BLOCK 28 28 39 0 3 0 b000 0 0\r
+;Верстак\r
+SET_BLOCK 29 29 39 0 3 0 b000 0 0\r
+;Кактус\r
+SET_BLOCK 30 30 6 1 0 0 b001 0 0\r
+;Стекло\r
+; -- -- - - - ? ---- - -\r
+SET_BLOCK 31 31 6 1 0 1 b001 1 0\r
+;Шерсть\r
+SET_BLOCK 32 32 12 0 0 0 b000 0 0\r
+SET_BLOCK 33 33 12 0 0 0 b000 0 0\r
+SET_BLOCK 34 34 12 0 0 0 b000 0 0\r
+SET_BLOCK 35 35 12 0 0 0 b000 0 0\r
+SET_BLOCK 36 36 12 0 0 0 b000 0 0\r
+SET_BLOCK 37 37 12 0 0 0 b000 0 0\r
+SET_BLOCK 38 38 12 0 0 0 b000 0 0\r
+SET_BLOCK 39 39 12 0 0 0 b000 0 0\r
+SET_BLOCK 40 40 12 0 0 0 b000 0 0\r
+SET_BLOCK 41 41 12 0 0 0 b000 0 0\r
+SET_BLOCK 42 42 12 0 0 0 b000 0 0\r
+SET_BLOCK 43 43 12 0 0 0 b000 0 0\r
+SET_BLOCK 44 44 12 0 0 0 b000 0 0\r
+SET_BLOCK 45 45 12 0 0 0 b000 0 0\r
+SET_BLOCK 46 46 12 0 0 0 b000 0 0\r
+SET_BLOCK 47 47 12 0 0 0 b000 0 0\r
+;Снег\r
+SET_BLOCK 48 48 9 1 2 0 b000 15 0\r
+;Лестница\r
+SET_BLOCK 49 49 6 0 0 0 b001 0 0\r
+;Вода\r
+SET_BLOCK 50 50 0x7FFFFFFF 0 0 0 b111 1 0\r
+;Лава\r
+SET_BLOCK 51 55 0x7FFFFFFF 0 0 0 b111 15 15\r
+;Саженец\r
+SET_BLOCK 52 60 0 0 0 0 b101 0 0\r
+;Губка\r
+SET_BLOCK 53 61 9 1 0 0 b000 15 0\r
+;Лазуритовая руда\r
+SET_BLOCK 54 62 65 1 1 2 b000 15 0\r
+;Лазуритовый блок\r
+SET_BLOCK 55 63 65 1 1 2 b000 15 0\r
+;Песчаник\r
+SET_BLOCK 56 64 50 1 1 1 b000 15 0\r
+;Высокая трава\r
+SET_BLOCK 57 65 0 0 4 1 b101 0 0\r
+;Сухой куст\r
+SET_BLOCK 58 66 0 0 4 1 b101 0 0\r
+;Паутина\r
+SET_BLOCK 59 67 60 0 4 1 b101 0 0\r
+;Кирпичный блок\r
+SET_BLOCK 60 68 60 1 1 1 b000 15 0\r
+;Снежный блок\r
+SET_BLOCK 61 69 3 1 2 0 b000 15 0\r
+;Лёд\r
+SET_BLOCK 62 70 8 1 1 6 b001 2 0\r
+;Слой снега\r
+SET_BLOCK 63 71 2 0 2 1 b111 1 0\r
+;Глиняный блок\r
+SET_BLOCK 64 72 9 1 2 0 b000 15 0\r
+;Тростник\r
+SET_BLOCK 65 73 0 0 0 0 b111 0 0\r
+;Тыква\r
+SET_BLOCK 66 74 15 1 3 0 b000 15 0\r
+;Светильник джека\r
+SET_BLOCK 67 75 15 1 3 0 b000 15 15\r
+;Каменный кирпич\r
+SET_BLOCK 68 76 60 1 1 1 b000 15 0\r
+SET_BLOCK 69 77 60 1 1 1 b000 15 0\r
+SET_BLOCK 70 78 60 1 1 1 b000 15 0\r
+;Резной кирпич\r
+SET_BLOCK 71 79 60 1 1 1 b000 15 0\r
+;Железная решётка\r
+SET_BLOCK 72 80 60 0 1 1 b011 0 0\r
+;Арбуз\r
+SET_BLOCK 73 81 15 1 0 0 b000 15 0\r
+;Мицелий\r
+SET_BLOCK 74 82 8 1 2 0 b000 15 0\r
+;Дерево(проходимое)\r
+SET_BLOCK 75 98 30 0 3 0 b000 0 0\r
+;Спаунер\r
+SET_BLOCK 76 83 75 0 0 0 b001 0 0\r
+;Кровать\r
+SET_BLOCK 77 84 3 0 0 0 b001 0 0\r
+SET_BLOCK 78 85 3 0 0 0 b001 0 0\r
+;Откр. дверь\r
+SET_BLOCK 79 86 30 0 3 0 b001 0 0\r
+SET_BLOCK 80 102 30 0 3 0 b001 0 0\r
+;Закр. дверь\r
+SET_BLOCK 81 88 30 1 3 0 b011 0 0\r
+SET_BLOCK 82 104 30 1 3 0 b011 0 0\r
+;Берёза\r
+SET_BLOCK 83 90 30 1 3 0 b000 0 0\r
+;Берёза(проходимая)\r
+SET_BLOCK 84 99 30 0 3 0 b000 0 0\r
+;Ель\r
+SET_BLOCK 85 91 30 1 3 0 b000 0 0\r
+;Ель(проходимая)\r
+SET_BLOCK 86 100 30 0 3 0 b000 0 0\r
+;Листва(ель)\r
+SET_BLOCK 87 92 3 1 4 1 b000 1 0\r
+;Краснывй огромный гриб\r
+SET_BLOCK 88 93 3 1 3 0 b000 15 0\r
+SET_BLOCK 89 95 3 0 3 0 b000 0 0\r
+;Коричневый огромный гриб\r
+SET_BLOCK 90 94 3 1 3 0 b000 15 0\r
+SET_BLOCK 91 95 3 0 3 0 b000 0 0\r
+;Забор\r
+SET_BLOCK 92 96 30 1 3 0 b001 0 0\r
+SET_BLOCK 93 101 30 0 3 0 b001 0 0\r
+;Доски(проходимые)\r
+SET_BLOCK 94 97 30 0 3 0 b000 0 0\r
+;Картины\r
+SET_BLOCK 95 106 0 0 0 0 b101 0 0\r
+SET_BLOCK 96 107 0 0 0 0 b101 0 0\r
+SET_BLOCK 97 108 0 0 0 0 b101 0 0\r
+SET_BLOCK 98 109 0 0 0 0 b101 0 0\r
+SET_BLOCK 99 110 0 0 0 0 b101 0 0\r
+SET_BLOCK 100 111 0 0 0 0 b101 0 0\r
+SET_BLOCK 101 112 0 0 0 0 b101 0 0\r
+;Подарочный сундук\r
+SET_BLOCK 102 113 30 0 3 0 b000 0 15\r
+;Лианы\r
+SET_BLOCK 103 114 3 0 4 1 b111 0 0\r
+;Табличка\r
+SET_BLOCK 104 115 15 0 0 0 b001 0 0\r
+;Красный факел\r
+SET_BLOCK 105 116 0 0 0 0 b101 0 7\r
+;Печь\r
+SET_BLOCK 106 117 40 0 3 0 b000 0 0\r
+;Люк\r
+SET_BLOCK 107 118 30 1 3 0 b011 0 0\r
+SET_BLOCK 108 119 30 0 3 0 b001 0 0\r
+;Адский камень\r
+SET_BLOCK 109 120 30 1 1 1 b000 15 0\r
+;Портал в ад\r
+SET_BLOCK 110 129 0x7FFFFFFF 0 0 0 b011 0 11\r
+;Светокамень\r
+SET_BLOCK 111 121 10 1 1 0 b000 0 15\r
+;Листва(берёза)\r
+SET_BLOCK 112 135 3 1 4 1 b000 1 0\r
+;Песок душ\r
+SET_BLOCK 113 122 9 1 2 0 b000 15 0\r
+;Саженец(берёза)\r
+SET_BLOCK 114 123 0 0 0 0 b101 0 0\r
+;Саженец(ель)\r
+SET_BLOCK 115 124 0 0 0 0 b101 0 0\r
+;Лампа\r
+SET_BLOCK 116 125 10 1 1 0 b000 0 0\r
+SET_BLOCK 117 126 10 1 1 0 b000 0 15\r
+;Обсидиан(проходимый)\r
+SET_BLOCK 118 127 1000 0 1 5 b000 15 0\r
+;Стеклянная панель\r
+SET_BLOCK 119 128 6 0 0 1 b001 1 0\r
+;Грядка\r
+SET_BLOCK 120 136 9 1 2 0 b000 15 0\r
+;Торт\r
+SET_BLOCK 121 137 9 0 0 0 b001 0 0\r
+;Пшеница\r
+SET_BLOCK 122 138 1 0 0 0 b101 0 0\r
+;Стебель арбуза\r
+SET_BLOCK 123 139 1 0 0 0 b101 0 0\r
+;Стебель тыквы\r
+SET_BLOCK 124 139 1 0 0 0 b101 0 0\r
+\r
diff --git a/res/crafts.cfg b/res/crafts.cfg
--- /dev/null
+++ b/res/crafts.cfg
@@ -0,0 +1,318 @@
+;Ôàéë èíèöèàëèçàöèè îïèñàíèÿ ðåöåïòîâ êðàôòà\r
+\r
+;Óñòàíàâëèâàåì êîëè÷åñòâî êðàôòîâ\r
+RESET_CRAFTS 84\r
+\r
+;Îïèñàíèå êîìàíä óñòàíîâêè ðåöåïòà êðàôòà:\r
+;SET_CRAFT_IN [id] [cell] [item] [sum]\r
+;id - èäåíòèôèêàòîð êðàôòà\r
+;cell - ÿ÷åéêà èíãðåäèåíòà\r
+;item - èäåíòèôèêàòîð ïðåäìåòà\r
+;sum - íåîáõîäèìîå êîëè÷åñòâî ïðåäìåòîâ\r
+;\r
+;SET_CRAFT_OUT [id] [item] [sum] [flag]\r
+;id - èäåíòèôèêàòîð êðàôòà\r
+;item - èäåíòèôèêàòîð ïîëó÷èâøåãîñÿ ïðåäìåòà ïðåäìåòà\r
+;sum - êîëè÷åñòâî ïîëó÷èâøåãîñÿ ïðåäìåòà ïðåäìåòà\r
+;flag - óñëîâèå ñîçäàíèÿ êðàôòà:\r
+; 0 - íà êîëåíêå :)\r
+; 1 - íà âåðñòàêå\r
+\r
+;Äîñêè(èç äóáà)\r
+SET_CRAFT_IN 0 0 9 1\r
+SET_CRAFT_OUT 0 4 4 0\r
+;Äîñêè(èç áåð¸çû)\r
+SET_CRAFT_IN 1 0 83 1\r
+SET_CRAFT_OUT 1 4 4 0\r
+;Äîñêè(èç åëè)\r
+SET_CRAFT_IN 2 0 85 1\r
+SET_CRAFT_OUT 2 4 4 0\r
+;Ñóíäóê\r
+SET_CRAFT_IN 3 0 4 8\r
+SET_CRAFT_OUT 3 28 1 1\r
+;Âåðñòàê\r
+SET_CRAFT_IN 4 0 4 4\r
+SET_CRAFT_OUT 4 29 1 0\r
+;Ïå÷ü\r
+SET_CRAFT_IN 5 0 5 8\r
+SET_CRAFT_OUT 5 106 1 1\r
+;Äèíàìèò\r
+SET_CRAFT_IN 6 0 7 4\r
+SET_CRAFT_IN 6 1 183 5\r
+SET_CRAFT_OUT 6 27 1 1\r
+;Ãëèíà\r
+SET_CRAFT_IN 7 0 169 4\r
+SET_CRAFT_OUT 7 64 1 0\r
+;Ïåñ÷àíèê\r
+SET_CRAFT_IN 8 0 7 4\r
+SET_CRAFT_OUT 8 56 1 0\r
+;Ñíåæíûé áëîê\r
+SET_CRAFT_IN 9 0 168 4\r
+SET_CRAFT_OUT 9 61 1 0\r
+;Æåëåçíûé áëîê\r
+SET_CRAFT_IN 10 0 164 9\r
+SET_CRAFT_OUT 10 13 1 1\r
+;Çîëîòîé áëîê\r
+SET_CRAFT_IN 11 0 165 9\r
+SET_CRAFT_OUT 11 14 1 1\r
+;Àëìàçíûé áëîê\r
+SET_CRAFT_IN 12 0 162 9\r
+SET_CRAFT_OUT 12 15 1 1\r
+;Ëàçóðèòíûé áëîê\r
+SET_CRAFT_IN 13 0 166 9\r
+SET_CRAFT_OUT 13 55 1 1\r
+;Æåëåçíàÿ ðåø¸òêà\r
+SET_CRAFT_IN 14 0 164 6\r
+SET_CRAFT_OUT 14 72 9 1\r
+;Êèðïè÷íàÿ êëàäêà\r
+SET_CRAFT_IN 15 0 163 4\r
+SET_CRAFT_OUT 15 60 1 0\r
+;Êàìåííûé êèðïè÷\r
+SET_CRAFT_IN 16 0 3 4\r
+SET_CRAFT_OUT 16 68 4 0\r
+;Êíèæíûé øêàô\r
+SET_CRAFT_IN 17 0 4 6\r
+SET_CRAFT_IN 17 1 170 3\r
+SET_CRAFT_OUT 17 11 1 1\r
+;Øåðñòü\r
+SET_CRAFT_IN 18 0 167 4\r
+SET_CRAFT_OUT 18 32 1 0\r
+;Çàáîð\r
+SET_CRAFT_IN 19 0 127 6\r
+SET_CRAFT_OUT 19 92 3 1\r
+;Ëåñòíèöà\r
+SET_CRAFT_IN 20 0 127 7\r
+SET_CRAFT_OUT 20 49 3 1\r
+;Êàðòèíû\r
+SET_CRAFT_IN 21 0 127 8\r
+SET_CRAFT_IN 21 1 32 1\r
+SET_CRAFT_OUT 21 187 1 1\r
+;Äâåðü\r
+SET_CRAFT_IN 22 0 4 6\r
+SET_CRAFT_OUT 22 178 1 1\r
+;Êðîâàòü\r
+SET_CRAFT_IN 23 0 32 3\r
+SET_CRAFT_IN 23 1 4 3\r
+SET_CRAFT_OUT 23 179 1 1\r
+;Òàáëè÷êè\r
+SET_CRAFT_IN 24 0 4 6\r
+SET_CRAFT_IN 24 1 127 1\r
+SET_CRAFT_OUT 24 104 3 1\r
+;Äåðåâÿííàÿ êèðêà\r
+SET_CRAFT_IN 25 0 4 3\r
+SET_CRAFT_IN 25 1 127 2\r
+SET_CRAFT_OUT 25 131 60 1\r
+;Êàìåííàÿ êèðêà\r
+SET_CRAFT_IN 26 0 5 3\r
+SET_CRAFT_IN 26 1 127 2\r
+SET_CRAFT_OUT 26 132 132 1\r
+;Æåëåçíàÿ êèðêà\r
+SET_CRAFT_IN 27 0 164 3\r
+SET_CRAFT_IN 27 1 127 2\r
+SET_CRAFT_OUT 27 133 251 1\r
+;Çîëîòàÿ êèðêà\r
+SET_CRAFT_IN 28 0 165 3\r
+SET_CRAFT_IN 28 1 127 2\r
+SET_CRAFT_OUT 28 135 33 1\r
+;Àëìàçíàÿ êèðêà\r
+SET_CRAFT_IN 29 0 162 3\r
+SET_CRAFT_IN 29 1 127 2\r
+SET_CRAFT_OUT 29 134 1562 1\r
+;Äåðåâÿííàÿ ëîïàòà\r
+SET_CRAFT_IN 30 0 4 1\r
+SET_CRAFT_IN 30 1 127 2\r
+SET_CRAFT_OUT 30 136 60 1\r
+;Êàìåííàÿ ëîïàòà\r
+SET_CRAFT_IN 31 0 5 1\r
+SET_CRAFT_IN 31 1 127 2\r
+SET_CRAFT_OUT 31 137 132 1\r
+;Æåëåçíàÿ ëîïàòà\r
+SET_CRAFT_IN 32 0 164 1\r
+SET_CRAFT_IN 32 1 127 2\r
+SET_CRAFT_OUT 32 138 251 1\r
+;Çîëîòàÿ ëîïàòà\r
+SET_CRAFT_IN 33 0 165 1\r
+SET_CRAFT_IN 33 1 127 2\r
+SET_CRAFT_OUT 33 140 33 1\r
+;Àëìàçíàÿ ëîïàòà\r
+SET_CRAFT_IN 34 0 162 1\r
+SET_CRAFT_IN 34 1 127 2\r
+SET_CRAFT_OUT 34 139 1562 1\r
+;Äåðåâÿííûé òîïîð\r
+SET_CRAFT_IN 35 0 4 3\r
+SET_CRAFT_IN 35 1 127 2\r
+SET_CRAFT_OUT 35 141 60 1\r
+;Êàìåííûé òîïîð\r
+SET_CRAFT_IN 36 0 5 3\r
+SET_CRAFT_IN 36 1 127 2\r
+SET_CRAFT_OUT 36 142 132 1\r
+;Äåðåâÿííûé òîïîð\r
+SET_CRAFT_IN 37 0 164 3\r
+SET_CRAFT_IN 37 1 127 2\r
+SET_CRAFT_OUT 37 143 251 1\r
+;Çîëîòîé òîïîð\r
+SET_CRAFT_IN 38 0 165 3\r
+SET_CRAFT_IN 38 1 127 2\r
+SET_CRAFT_OUT 38 145 33 1\r
+;Àëìàçíûé òîïîð\r
+SET_CRAFT_IN 39 0 162 3\r
+SET_CRAFT_IN 39 1 127 2\r
+SET_CRAFT_OUT 39 144 1562 1\r
+;Íîæíèöû\r
+SET_CRAFT_IN 40 0 164 2\r
+SET_CRAFT_OUT 40 146 259 0\r
+;Äåðåâÿííûé ìå÷\r
+SET_CRAFT_IN 41 0 4 2\r
+SET_CRAFT_IN 41 1 127 1\r
+SET_CRAFT_OUT 41 147 60 1\r
+;Êàìåííûé ìå÷\r
+SET_CRAFT_IN 42 0 5 2\r
+SET_CRAFT_IN 42 1 127 1\r
+SET_CRAFT_OUT 42 148 132 1\r
+;Æåëåçíûé ìå÷\r
+SET_CRAFT_IN 43 0 164 2\r
+SET_CRAFT_IN 43 1 127 1\r
+SET_CRAFT_OUT 43 149 251 1\r
+;Çîëîòîé ìå÷\r
+SET_CRAFT_IN 44 0 165 2\r
+SET_CRAFT_IN 44 1 127 1\r
+SET_CRAFT_OUT 44 151 33 1\r
+;Àëìàçíûé ìå÷\r
+SET_CRAFT_IN 45 0 162 2\r
+SET_CRAFT_IN 45 1 127 1\r
+SET_CRAFT_OUT 45 150 1562 1\r
+;Óäî÷êà\r
+SET_CRAFT_IN 46 0 127 3\r
+SET_CRAFT_IN 46 1 167 2\r
+SET_CRAFT_OUT 46 152 65 1\r
+;Âåäðî\r
+SET_CRAFT_IN 47 0 164 3\r
+SET_CRAFT_OUT 47 171 1 1\r
+;Æåëåçíûé áëîê -> æåëåçíûå ñëèòêè\r
+SET_CRAFT_IN 48 0 13 1\r
+SET_CRAFT_OUT 48 164 9 0\r
+;Çîëîòîé áëîê -> çîëîòûå ñëèòêè\r
+SET_CRAFT_IN 49 0 14 1\r
+SET_CRAFT_OUT 49 165 9 0\r
+;Àëìàçíûé áëîê -> àëìàçû\r
+SET_CRAFT_IN 50 0 15 1\r
+SET_CRAFT_OUT 50 162 9 0\r
+;Ëàçóðèòîâûé áëîê -> óëüòðàìàðèí\r
+SET_CRAFT_IN 51 0 55 1\r
+SET_CRAFT_OUT 51 166 9 0\r
+;Çîëîòîé ñëèòîê -> çîëîòîé ñàìîðîäîê\r
+SET_CRAFT_IN 52 0 165 1\r
+SET_CRAFT_OUT 52 194 9 0\r
+;Çîëîòîé ñàìîðîäîê -> çîëîòîé ñëèòîê\r
+SET_CRAFT_IN 53 0 194 9\r
+SET_CRAFT_OUT 53 165 1 1\r
+;Áóìàãà\r
+SET_CRAFT_IN 54 0 65 3\r
+SET_CRAFT_OUT 54 175 3 1\r
+;Êíèãà\r
+SET_CRAFT_IN 55 0 175 3\r
+SET_CRAFT_IN 55 1 198 1\r
+SET_CRAFT_OUT 55 170 1 0\r
+;Êàðòà\r
+SET_CRAFT_IN 56 0 175 8\r
+SET_CRAFT_IN 56 1 216 1\r
+SET_CRAFT_OUT 56 186 1 1\r
+;Ïàëêè\r
+SET_CRAFT_IN 57 0 4 2\r
+SET_CRAFT_OUT 57 127 4 0\r
+;Ôàêåë\r
+SET_CRAFT_IN 58 0 160 1\r
+SET_CRAFT_IN 58 1 127 1\r
+SET_CRAFT_OUT 58 26 4 0\r
+;Êðàñíûé ôàêåë\r
+SET_CRAFT_IN 59 0 161 1\r
+SET_CRAFT_IN 59 1 127 1\r
+SET_CRAFT_OUT 59 105 1 0\r
+;×àøêà\r
+SET_CRAFT_IN 60 0 4 3\r
+SET_CRAFT_OUT 60 184 4 1\r
+;Òóøåíûå ãðèáû\r
+SET_CRAFT_IN 61 0 184 1\r
+SET_CRAFT_IN 61 1 24 1\r
+SET_CRAFT_IN 61 2 25 1\r
+SET_CRAFT_OUT 61 185 1 0\r
+;Ƹëòûé êðàñèòåëü\r
+SET_CRAFT_IN 62 0 23 1\r
+SET_CRAFT_OUT 62 128 2 0\r
+;Êðàñíûé êðàñèòåëü\r
+SET_CRAFT_IN 63 0 22 1\r
+SET_CRAFT_OUT 63 129 2 0\r
+;Çîëîòîå ÿáëîêî\r
+SET_CRAFT_IN 64 0 201 1\r
+SET_CRAFT_IN 64 1 194 8\r
+SET_CRAFT_OUT 64 202 1 1\r
+;Ëþê\r
+SET_CRAFT_IN 65 0 4 6\r
+SET_CRAFT_OUT 65 108 2 1\r
+;Îãíèâî\r
+SET_CRAFT_IN 66 0 164 1\r
+SET_CRAFT_IN 66 1 207 1\r
+SET_CRAFT_OUT 66 153 65 0\r
+;Ñâåòîêàìåíü\r
+SET_CRAFT_IN 67 0 214 4\r
+SET_CRAFT_OUT 67 111 1 0\r
+;Ëàìïà\r
+SET_CRAFT_IN 68 0 161 4\r
+SET_CRAFT_IN 68 1 111 1\r
+SET_CRAFT_OUT 68 116 1 1\r
+;Êîìïàñ\r
+SET_CRAFT_IN 69 0 161 1\r
+SET_CRAFT_IN 69 1 164 4\r
+SET_CRAFT_OUT 69 216 1 1\r
+;Ñòåêëÿííàÿ ïàíåëü\r
+SET_CRAFT_IN 70 0 31 6\r
+SET_CRAFT_OUT 70 119 16 1\r
+;×àñû\r
+SET_CRAFT_IN 71 0 161 1\r
+SET_CRAFT_IN 71 1 165 4\r
+SET_CRAFT_OUT 71 215 1 1\r
+;Ñàõàð\r
+SET_CRAFT_IN 72 0 65 1\r
+SET_CRAFT_OUT 72 195 1 0\r
+;Õëåá\r
+SET_CRAFT_IN 73 0 218 3\r
+SET_CRAFT_OUT 73 219 1 1\r
+;Òîðò\r
+SET_CRAFT_IN 74 0 174 1\r
+SET_CRAFT_IN 74 1 177 1\r
+SET_CRAFT_IN 74 2 195 2\r
+SET_CRAFT_IN 74 3 218 3\r
+SET_CRAFT_OUT 74 121 1 1\r
+;Äåðåâÿííàÿ ìîòûãà\r
+SET_CRAFT_IN 75 0 4 2\r
+SET_CRAFT_IN 75 1 127 2\r
+SET_CRAFT_OUT 75 154 60 1\r
+;Êàìåííàÿ ìîòûãà\r
+SET_CRAFT_IN 76 0 5 2\r
+SET_CRAFT_IN 76 1 127 2\r
+SET_CRAFT_OUT 76 155 132 1\r
+;Æåëåçíàÿ ìîòûãà\r
+SET_CRAFT_IN 77 0 164 2\r
+SET_CRAFT_IN 77 1 127 2\r
+SET_CRAFT_OUT 77 156 251 1\r
+;Çîëîòàÿ ìîòûãà\r
+SET_CRAFT_IN 78 0 165 2\r
+SET_CRAFT_IN 78 1 127 2\r
+SET_CRAFT_OUT 78 158 33 1\r
+;Àëìàçíàÿ ìîòûãà\r
+SET_CRAFT_IN 79 0 162 2\r
+SET_CRAFT_IN 79 1 127 2\r
+SET_CRAFT_OUT 79 157 1562 1\r
+;Ñåìåíà òûêâû\r
+SET_CRAFT_IN 80 0 66 1\r
+SET_CRAFT_OUT 80 222 4 0\r
+;Ñåìåíà àðáóçà\r
+SET_CRAFT_IN 81 0 176 1\r
+SET_CRAFT_OUT 81 221 1 0\r
+;Àðáóç\r
+SET_CRAFT_IN 82 0 176 9\r
+SET_CRAFT_OUT 82 73 1 1\r
+;Ñâåòèëüíèê Äæåêà\r
+SET_CRAFT_IN 83 0 66 1\r
+SET_CRAFT_IN 83 1 26 1\r
+SET_CRAFT_OUT 83 67 1 0\r
diff --git a/res/default_font.png b/res/default_font.png
new file mode 100644 (file)
index 0000000..d2a98b0
Binary files /dev/null and b/res/default_font.png differ
index 0000000..d2a98b0
Binary files /dev/null and b/res/default_font.png differ
diff --git a/res/dl b/res/dl
diff --git a/res/furnace.cfg b/res/furnace.cfg
--- /dev/null
+++ b/res/furnace.cfg
@@ -0,0 +1,90 @@
+;Ôàéë èíèöèàëèçàöèè îïèñàíèÿ òîïëèâà è ðåöåïòîâ äëÿ ïå÷è\r
+\r
+;Óñòàíàâëèâàåì êîëè÷åñòâî òîïëèâà è ðåöåïòîâ\r
+RESET_FUELS 24\r
+RESET_RECIPES 15\r
+\r
+;Îïèñàíèå êîìàíäû óñòàíîâêè òîïëèâà:\r
+;SET_FUEL [id] [item] [time]\r
+;id - èäåíòèôèêàòîð òîïëèâà.\r
+;item - èäåíòèôèêàòîð ïðåäìåòà, êîòîðûé ìîæåò áûòü èñïîëüçîâàí êàê òîïëèâî.\r
+;time - âðåìÿ ãîðåíèÿ òîïëèâà â ìñ(1/1000 ñåêóíäû).\r
+\r
+;Îïèñàíèå êîìàíäû óñòàíîâêè ðåöåïòà:\r
+;SET_RECIPE [id] [in] [out]\r
+;id - èäåíòèôèêàòîð ðåöåïòà.\r
+;in - èäåíòèôèêàòîð ïðåäìåòà èç êîòîðîãî ïðèñõîäèò ïðèãîòîâëåíèå.\r
+;out - èäåíòèôèêàòîð ðåçóëüòèðóþùåãî ïðåäìåòà.\r
+\r
+;======[Òîïëèâî]======\r
+;Âåäðî ëàâû\r
+SET_FUEL 0 173 1000000\r
+;Óãîëü\r
+SET_FUEL 1 160 80000\r
+;Äîñêè\r
+SET_FUEL 2 4 15000\r
+SET_FUEL 3 94 15000\r
+;Ñàæåíåö\r
+SET_FUEL 4 52 5000\r
+SET_FUEL 5 114 5000\r
+SET_FUEL 6 115 5000\r
+;Ïàëêà\r
+SET_FUEL 7 127 5000\r
+;Çàáîð\r
+SET_FUEL 8 92 15000\r
+SET_FUEL 9 93 15000\r
+;Ëþê\r
+SET_FUEL 10 107 15000\r
+SET_FUEL 11 108 15000\r
+;Äåðåâî\r
+SET_FUEL 12 9 15000\r
+SET_FUEL 13 75 15000\r
+SET_FUEL 14 83 15000\r
+SET_FUEL 15 84 15000\r
+SET_FUEL 16 85 15000\r
+SET_FUEL 17 86 15000\r
+;Âåðñòàê\r
+SET_FUEL 18 29 15000\r
+;Êíèæíûé øêàô\r
+SET_FUEL 19 11 15000\r
+;Ñóíäóê\r
+SET_FUEL 20 28 15000\r
+;Îãðîìíûå ãðèáû\r
+SET_FUEL 21 88 15000\r
+SET_FUEL 22 89 15000\r
+SET_FUEL 23 90 15000\r
+SET_FUEL 24 91 15000\r
+\r
+;======[Ðåöåïòû]======\r
+;Ïåñîê -> ñòåêëî\r
+SET_RECIPE 0 7 31\r
+;Æåëåçíàÿ ðóäà -> æåëåçíûé ñëèòîê\r
+SET_RECIPE 1 17 164\r
+;Çîëîòàÿ ðóäà -> çîëîòîé ñëèòîê\r
+SET_RECIPE 2 16 165\r
+;Êîìîê ãëèíû -> êèðïè÷\r
+SET_RECIPE 3 169 163\r
+;Ñûðàÿ ñâèíèíà -> æàðåíàÿ ñâèíèíà\r
+SET_RECIPE 4 188 189\r
+;Áóëûæíèê -> êàìåíü\r
+SET_RECIPE 5 5 3\r
+;Ñûðàÿ êóðèöà -> æàðåíàÿ êóðèöà\r
+SET_RECIPE 6 203 204\r
+;Ñûðàÿ ãîâÿäèíà -> æàðåíàÿ ãîâÿäèíà\r
+SET_RECIPE 7 199 200\r
+;Ñûðàÿ ðûáà -> æàðåíàÿ ðûáà\r
+SET_RECIPE 8 210 211\r
+;Äåðåâî -> óãîëü\r
+SET_RECIPE 9 9 160\r
+;Áåð¸çà -> óãîëü\r
+SET_RECIPE 10 83 160\r
+;Åëü -> óãîëü\r
+SET_RECIPE 11 85 160\r
+;Óãîëüíàÿ ðóäà -> óãîëü\r
+SET_RECIPE 12 18 160\r
+;Êðàñíàÿ ðóäà -> êðàñíàÿ ïûëü\r
+SET_RECIPE 13 20 161\r
+;Ëàçóðèòîâàÿ ðóäà -> óëüòðàìàðèí\r
+SET_RECIPE 14 54 166\r
+;Àëìàçíàÿ ðóäà -> àëìàç\r
+SET_RECIPE 15 19 162\r
diff --git a/res/gui/clock.png b/res/gui/clock.png
new file mode 100644 (file)
index 0000000..5e79bc5
Binary files /dev/null and b/res/gui/clock.png differ
index 0000000..5e79bc5
Binary files /dev/null and b/res/gui/clock.png differ
diff --git a/res/gui/compass.png b/res/gui/compass.png
new file mode 100644 (file)
index 0000000..32920bd
Binary files /dev/null and b/res/gui/compass.png differ
index 0000000..32920bd
Binary files /dev/null and b/res/gui/compass.png differ
diff --git a/res/gui/container.png b/res/gui/container.png
new file mode 100644 (file)
index 0000000..141d68d
Binary files /dev/null and b/res/gui/container.png differ
index 0000000..141d68d
Binary files /dev/null and b/res/gui/container.png differ
diff --git a/res/gui/creative.png b/res/gui/creative.png
new file mode 100644 (file)
index 0000000..2efabed
Binary files /dev/null and b/res/gui/creative.png differ
index 0000000..2efabed
Binary files /dev/null and b/res/gui/creative.png differ
diff --git a/res/gui/fastcraft.png b/res/gui/fastcraft.png
new file mode 100644 (file)
index 0000000..e8d8925
Binary files /dev/null and b/res/gui/fastcraft.png differ
index 0000000..e8d8925
Binary files /dev/null and b/res/gui/fastcraft.png differ
diff --git a/res/gui/float.png b/res/gui/float.png
new file mode 100644 (file)
index 0000000..7e5008b
Binary files /dev/null and b/res/gui/float.png differ
index 0000000..7e5008b
Binary files /dev/null and b/res/gui/float.png differ
diff --git a/res/gui/furnace.png b/res/gui/furnace.png
new file mode 100644 (file)
index 0000000..ad5295d
Binary files /dev/null and b/res/gui/furnace.png differ
index 0000000..ad5295d
Binary files /dev/null and b/res/gui/furnace.png differ
diff --git a/res/gui/gui.png b/res/gui/gui.png
new file mode 100644 (file)
index 0000000..13ad2f0
Binary files /dev/null and b/res/gui/gui.png differ
index 0000000..13ad2f0
Binary files /dev/null and b/res/gui/gui.png differ
diff --git a/res/gui/inventory.png b/res/gui/inventory.png
new file mode 100644 (file)
index 0000000..f158be5
Binary files /dev/null and b/res/gui/inventory.png differ
index 0000000..f158be5
Binary files /dev/null and b/res/gui/inventory.png differ
diff --git a/res/gui/items.png b/res/gui/items.png
new file mode 100644 (file)
index 0000000..b1f58ac
Binary files /dev/null and b/res/gui/items.png differ
index 0000000..b1f58ac
Binary files /dev/null and b/res/gui/items.png differ
diff --git a/res/gui/mapbg.png b/res/gui/mapbg.png
new file mode 100644 (file)
index 0000000..ff2faaa
Binary files /dev/null and b/res/gui/mapbg.png differ
index 0000000..ff2faaa
Binary files /dev/null and b/res/gui/mapbg.png differ
diff --git a/res/gui/partition.png b/res/gui/partition.png
new file mode 100644 (file)
index 0000000..a4cd941
Binary files /dev/null and b/res/gui/partition.png differ
index 0000000..a4cd941
Binary files /dev/null and b/res/gui/partition.png differ
diff --git a/res/gui/sign.png b/res/gui/sign.png
new file mode 100644 (file)
index 0000000..bfd736f
Binary files /dev/null and b/res/gui/sign.png differ
index 0000000..bfd736f
Binary files /dev/null and b/res/gui/sign.png differ
diff --git a/res/gui/touch.png b/res/gui/touch.png
new file mode 100644 (file)
index 0000000..067164b
Binary files /dev/null and b/res/gui/touch.png differ
index 0000000..067164b
Binary files /dev/null and b/res/gui/touch.png differ
diff --git a/res/inputStream.class b/res/inputStream.class
new file mode 100644 (file)
index 0000000..b130bc4
Binary files /dev/null and b/res/inputStream.class differ
index 0000000..b130bc4
Binary files /dev/null and b/res/inputStream.class differ
diff --git a/res/items.cfg b/res/items.cfg
--- /dev/null
+++ b/res/items.cfg
@@ -0,0 +1,607 @@
+;Ôàéë èíèöèàëèçàöèè ñòàíäàðòíîãî íàáîðà ïðåäìåòîâ CaveCraft\r
+;Âñå ïåðå÷èñëåííûå çäåñü ïðåäìåòû ìîãóò îòáðàæàòüñÿ â èíâåíòàðå èãðîêà.\r
+\r
+;Óñòàíàâëèâàåì êîëè÷åñòâî ïðåäìåòîâ\r
+RESET_ITEMS 222\r
+\r
+;Îïèñàíèå êîìàíäû óñòàíîâêè ïðåäìåòà:\r
+;SET_ITEM [id] [type] [tex] [max] [prt] [flags]\r
+;id - èíäåíòèôèêàòîð ïðåäìåòà.\r
+;type - òèï ïðåäìåòà:\r
+; 0 - áëîê\r
+; 1 - èíñòðóìåíò\r
+; 2 - çàðåçåðâèðîâàíî\r
+; 3 - îáû÷íûé ïðåäìåò\r
+;tex - íîìåð òåêñòóðû, çàâèñèò îò òèïà ïðåäìåòà.\r
+;max - ìàêñèìàëüíîå êîëè÷åñòâî ïðåäìåòîâ â ñòàêå.\r
+;prt - óêàçàòåëü íà ñòðóêòóðó äîïîëíèòåëüíûõ äàííûõ âûáðàíîãî òèïà ïðåäìåòà.\r
+;flags - áèòîâîå ïîëå:\r
+; b0001 - ðèñîâàòü öèôðîâîé èíäèêàòîð\r
+; b0010 - ðèñîâàòü ãðàôè÷åñêèé èíäèêàòîð\r
+; b0100 - ïðåäìåò äåëèìûé\r
+; b1000 - ðèñîâàòü òåêñòóðó èç terrain.png(0)/items.png(1)\r
+\r
+\r
+;======[Áëîêè]======\r
+;Null\r
+SET_ITEM 0 0 0 0 0 b0000\r
+;Çåìëÿ\r
+SET_ITEM 1 0 1 64 1 b0101\r
+;Òðàâà\r
+SET_ITEM 2 0 2 64 2 b0101\r
+;Êàìåíü\r
+SET_ITEM 3 0 3 64 3 b0101\r
+;Äîñêè\r
+SET_ITEM 4 0 4 64 4 b0101\r
+;Áóëûæíèê\r
+SET_ITEM 5 0 5 64 5 b0101\r
+;Àäìèíèóì\r
+SET_ITEM 6 0 6 64 6 b0101\r
+;Ïåñîê\r
+SET_ITEM 7 0 7 64 7 b0101\r
+;Ãðàâèé\r
+SET_ITEM 8 0 8 64 8 b0101\r
+;Äðåâî\r
+SET_ITEM 9 0 9 64 9 b0101\r
+;Îáñèäèàí\r
+SET_ITEM 10 0 10 64 10 b0101\r
+;Êíèæíûé øêàô\r
+SET_ITEM 11 0 11 64 11 b0101\r
+;Çàìøåëûé áóëûæíèê\r
+SET_ITEM 12 0 12 64 12 b0101\r
+;Æåëåçíûé áëîê\r
+SET_ITEM 13 0 13 64 13 b0101\r
+;Çîëîòîé áëîê\r
+SET_ITEM 14 0 14 64 14 b0101\r
+;Àëìàçíûé áëîê\r
+SET_ITEM 15 0 15 64 15 b0101\r
+;Çîëîòààÿ ðóäà\r
+SET_ITEM 16 0 16 64 16 b0101\r
+;Æåëåçíàÿ ðóäà\r
+SET_ITEM 17 0 17 64 17 b0101\r
+;Óãîëüíàÿ ðóäà\r
+SET_ITEM 18 0 18 64 18 b0101\r
+;Àëìàçíàÿ ðóäà\r
+SET_ITEM 19 0 19 64 19 b0101\r
+;Êðàñíàÿ ðóäà\r
+SET_ITEM 20 0 20 64 20 b0101\r
+;Ëèñòâà\r
+SET_ITEM 21 0 21 64 21 b0101\r
+;Êðàñíûé öâåòîê\r
+SET_ITEM 22 0 22 64 22 b0101\r
+;Ƹëòûé öâåòîê\r
+SET_ITEM 23 0 23 64 23 b0101\r
+;Êðàñíûé ãðèá\r
+SET_ITEM 24 0 24 64 24 b0101\r
+;Êîðè÷íåâûé ãðèá\r
+SET_ITEM 25 0 25 64 25 b0101\r
+;Ôàêåë\r
+SET_ITEM 26 0 26 64 26 b0101\r
+;Äèíàìèò\r
+SET_ITEM 27 0 27 64 27 b0101\r
+;Ñóíäóê\r
+SET_ITEM 28 0 28 64 28 b0101\r
+;Âåðñòàê\r
+SET_ITEM 29 0 29 64 29 b0101\r
+;Êàêòóñ\r
+SET_ITEM 30 0 30 64 30 b0101\r
+;Ñòåêëî\r
+SET_ITEM 31 0 31 64 31 b0101\r
+;Øåðñòü\r
+SET_ITEM 32 0 32 64 32 b0101\r
+SET_ITEM 33 0 33 64 33 b0101\r
+SET_ITEM 34 0 34 64 34 b0101\r
+SET_ITEM 35 0 35 64 35 b0101\r
+SET_ITEM 36 0 36 64 36 b0101\r
+SET_ITEM 37 0 37 64 37 b0101\r
+SET_ITEM 38 0 38 64 38 b0101\r
+SET_ITEM 39 0 39 64 39 b0101\r
+SET_ITEM 40 0 40 64 40 b0101\r
+SET_ITEM 41 0 41 64 41 b0101\r
+SET_ITEM 42 0 42 64 42 b0101\r
+SET_ITEM 43 0 43 64 43 b0101\r
+SET_ITEM 44 0 44 64 44 b0101\r
+SET_ITEM 45 0 45 64 45 b0101\r
+SET_ITEM 46 0 46 64 46 b0101\r
+SET_ITEM 47 0 47 64 47 b0101\r
+;Ñíåã\r
+SET_ITEM 48 0 48 64 48 b0101\r
+;Ëåñòíèöà\r
+SET_ITEM 49 0 49 64 49 b0101\r
+;Âîäà\r
+SET_ITEM 50 0 50 64 50 b0101\r
+;Ëàâà\r
+SET_ITEM 51 0 51 64 51 b0101\r
+;Ñàæåíåö\r
+SET_ITEM 52 0 60 64 52 b0101\r
+;Ãóáêà\r
+SET_ITEM 53 0 61 64 53 b0101\r
+;Ëàçóðèòîâàÿ ðóäà\r
+SET_ITEM 54 0 62 64 54 b0101\r
+;Ëàçóðèòîâûé áëîê\r
+SET_ITEM 55 0 63 64 55 b0101\r
+;Ïåñ÷àíèê\r
+SET_ITEM 56 0 64 64 56 b0101\r
+;Âûñîêàÿ òðàâà\r
+SET_ITEM 57 0 65 64 57 b0101\r
+;Ñóõîé êóñò\r
+SET_ITEM 58 0 66 64 58 b0101\r
+;Ïàóòèíà\r
+SET_ITEM 59 0 67 64 59 b0101\r
+;Êèðïè÷íûé áëîê\r
+SET_ITEM 60 0 68 64 60 b0101\r
+;Ñíåæíûé áëîê\r
+SET_ITEM 61 0 69 64 61 b0101\r
+;˸ä\r
+SET_ITEM 62 0 70 64 62 b0101\r
+;Ñëîé ñíåãà\r
+SET_ITEM 63 0 71 64 63 b0101\r
+;Ãëèíÿíûé áëîê\r
+SET_ITEM 64 0 72 64 64 b0101\r
+;Òðîñòíèê\r
+SET_ITEM 65 0 116 64 65 b1101\r
+;Òûêâà\r
+SET_ITEM 66 0 74 64 66 b0101\r
+;Ñâåòèëüíèê Äæåêà\r
+SET_ITEM 67 0 75 64 67 b0101\r
+;Êàìåííûé êèðïè÷\r
+SET_ITEM 68 0 76 64 68 b0101\r
+SET_ITEM 69 0 77 64 69 b0101\r
+SET_ITEM 70 0 78 64 70 b0101\r
+;Ðåçíîé êèðïè÷\r
+SET_ITEM 71 0 79 64 71 b0101\r
+;Æåëåçíàÿ ðåø¸òêà\r
+SET_ITEM 72 0 80 64 72 b0101\r
+;Àðáóç\r
+SET_ITEM 73 0 81 64 73 b0101\r
+;Ìèöåëèé\r
+SET_ITEM 74 0 82 64 74 b0101\r
+;Äåðåâî(ïðîõîäèìîå)\r
+SET_ITEM 75 0 98 64 75 b0101\r
+;Ñïàóíåð\r
+SET_ITEM 76 0 83 64 76 b0101\r
+;Êðîâàòü\r
+SET_ITEM 77 0 84 64 77 b0101\r
+SET_ITEM 78 0 85 64 78 b0101\r
+;Îòêð. äâåðü\r
+SET_ITEM 79 0 86 64 79 b0101\r
+SET_ITEM 80 0 102 64 80 b0101\r
+;Çàêð. äâåðü\r
+SET_ITEM 81 0 88 64 81 b0101\r
+SET_ITEM 82 0 104 64 82 b0101\r
+;áåð¸çà\r
+SET_ITEM 83 0 90 64 83 b0101\r
+SET_ITEM 84 0 99 64 84 b0101\r
+;Åëü\r
+SET_ITEM 85 0 91 64 85 b0101\r
+SET_ITEM 86 0 100 64 86 b0101\r
+;Ëèñòâà åëè\r
+SET_ITEM 87 0 92 64 87 b0101\r
+;Êðàñíûé îãðîìíûé ãðèá\r
+SET_ITEM 88 0 93 64 88 b0101\r
+SET_ITEM 89 0 95 64 89 b0101\r
+;Êîðè÷íåâûé îãðîìíûé ãðèá\r
+SET_ITEM 90 0 94 64 90 b0101\r
+SET_ITEM 91 0 95 64 91 b0101\r
+;Çàáîð\r
+SET_ITEM 92 0 96 64 92 b0101\r
+SET_ITEM 93 0 101 64 93 b0101\r
+;Äîñêè(ïðîõîäèìûå)\r
+SET_ITEM 94 0 97 64 94 b0101\r
+;Êàðòèíû\r
+SET_ITEM 95 0 106 1 95 b0101\r
+SET_ITEM 96 0 107 1 96 b0101\r
+SET_ITEM 97 0 108 1 97 b0101\r
+SET_ITEM 98 0 109 1 98 b0101\r
+SET_ITEM 99 0 110 1 99 b0101\r
+SET_ITEM 100 0 111 1 100 b0101\r
+SET_ITEM 101 0 112 1 101 b0101\r
+;Ëèàíû\r
+SET_ITEM 103 0 114 64 103 b0101\r
+;Òàáëè÷êà \r
+SET_ITEM 104 0 98 16 104 b1101\r
+;Êðàñíûé ôàêåë\r
+SET_ITEM 105 0 116 64 105 b0101\r
+;Ïå÷ü\r
+SET_ITEM 106 0 117 64 106 b0101\r
+;Ëþê\r
+SET_ITEM 107 0 118 64 107 b0101\r
+SET_ITEM 108 0 119 64 108 b0101\r
+;Àäñêèé êàìåíü\r
+SET_ITEM 109 0 120 64 109 b0101\r
+;Ïîðòàë â àä\r
+SET_ITEM 110 0 129 64 110 b0101\r
+;Ñâåòÿùèéñÿ êàìåíü\r
+SET_ITEM 111 0 121 64 111 b0101\r
+;Ëèñòâà(áåð¸çà)\r
+SET_ITEM 112 0 135 64 112 b0101\r
+;Ïåñîê äóø\r
+SET_ITEM 113 0 122 64 113 b0101\r
+;Ñàæåíåö(áåð¸çà)\r
+SET_ITEM 114 0 123 64 114 b0101\r
+;Ñàæåíåö(åëü)\r
+SET_ITEM 115 0 124 64 115 b0101\r
+;Ëàìïà\r
+SET_ITEM 116 0 125 64 116 b0101\r
+SET_ITEM 117 0 126 64 117 b0101\r
+;Îáñèäèàí(ïðîõîäèìûé)\r
+SET_ITEM 118 0 127 64 118 b0101\r
+;Ñòåêëÿííàÿ ïàíåëü\r
+SET_ITEM 119 0 128 64 119 b0101\r
+;Ãðÿäêà\r
+SET_ITEM 120 0 136 64 120 b0101\r
+;Òîðò\r
+SET_ITEM 121 0 137 64 121 b0101\r
+\r
+;======[Ïðåäìåòû]======\r
+;Ïàëêà\r
+SET_ITEM 127 3 0 64 0 b1101\r
+;Ƹëòûé êðàñèòåëü\r
+SET_ITEM 128 3 8 64 0 b1101\r
+;Êðàñíûé êðàñèòåëü\r
+SET_ITEM 129 3 9 64 0 b1101\r
+\r
+;"Íóëåâîé" èíñòðóìåíò\r
+SET_ITEM 130 1 0 0 0 b1010\r
+;Êèðêà\r
+SET_ITEM 131 1 48 60 1 b1010\r
+SET_ITEM 132 1 49 132 2 b1010\r
+SET_ITEM 133 1 50 251 3 b1010\r
+SET_ITEM 134 1 51 1562 4 b1010\r
+SET_ITEM 135 1 52 33 5 b1010\r
+;Ëîïàòà\r
+SET_ITEM 136 1 32 60 6 b1010\r
+SET_ITEM 137 1 33 132 7 b1010\r
+SET_ITEM 138 1 34 251 8 b1010\r
+SET_ITEM 139 1 35 1562 9 b1010\r
+SET_ITEM 140 1 36 33 10 b1010\r
+;Òîïîð\r
+SET_ITEM 141 1 64 60 11 b1010\r
+SET_ITEM 142 1 65 132 12 b1010\r
+SET_ITEM 143 1 66 251 13 b1010\r
+SET_ITEM 144 1 67 1562 14 b1010\r
+SET_ITEM 145 1 68 33 15 b1010\r
+;Íîæíèöû\r
+SET_ITEM 146 1 10 239 16 b1010\r
+;Ìå÷\r
+SET_ITEM 147 1 16 60 17 b1010\r
+SET_ITEM 148 1 17 132 18 b1010\r
+SET_ITEM 149 1 18 251 19 b1010\r
+SET_ITEM 150 1 19 1562 20 b1010\r
+SET_ITEM 151 1 20 33 21 b1010\r
+;Óäî÷êà\r
+SET_ITEM 152 1 101 65 22 b1010\r
+;Îãíèâî\r
+SET_ITEM 153 1 106 65 23 b1010\r
+;Ìîòûãà\r
+SET_ITEM 154 1 80 60 24 b1010\r
+SET_ITEM 155 1 81 132 25 b1010\r
+SET_ITEM 156 1 82 251 26 b1010\r
+SET_ITEM 157 1 83 1562 27 b1010\r
+SET_ITEM 158 1 84 33 28 b1010\r
+\r
+;Óãîëü\r
+SET_ITEM 160 3 2 64 0 b1101\r
+;Êðàñíàÿ ïûëü\r
+SET_ITEM 161 3 7 64 0 b1101\r
+;Àëìàç\r
+SET_ITEM 162 3 6 64 0 b1101\r
+;Êèðïè÷\r
+SET_ITEM 163 3 3 64 0 b1101\r
+;Æåëåçíûé ñëèòîê\r
+SET_ITEM 164 3 4 64 0 b1101\r
+;Çîëîòîé ñëèòîê\r
+SET_ITEM 165 3 5 64 0 b1101\r
+;Óëüòðàìàðèí\r
+SET_ITEM 166 3 11 64 0 b1101\r
+;Íèòü\r
+SET_ITEM 167 3 12 64 0 b1101\r
+;Ñíåæîê\r
+SET_ITEM 168 3 13 16 0 b1101\r
+;Ãëèíà\r
+SET_ITEM 169 3 14 64 0 b1101\r
+;Êíèãà\r
+SET_ITEM 170 3 15 64 0 b1101\r
+;Âåäðî\r
+SET_ITEM 171 3 21 1 0 b1101\r
+;Âåäðî ñ âîäîé\r
+SET_ITEM 172 3 22 1 0 b1101\r
+;Âåäðî ñ ëàâîé\r
+SET_ITEM 173 3 23 1 0 b1101\r
+;Âåäðî ñ ìîëîêîì\r
+SET_ITEM 174 3 24 1 0 b1101\r
+;Áóìàãà\r
+SET_ITEM 175 3 25 64 0 b1101\r
+;Äîëüêà àðáóçà\r
+SET_ITEM 176 3 26 64 0 b1101\r
+;ßéöî\r
+SET_ITEM 177 3 27 64 0 b1101\r
+;Äâåðü\r
+SET_ITEM 178 3 28 64 0 b1101\r
+;Êðîâàòü\r
+SET_ITEM 179 3 30 64 0 b1101\r
+;ßéöî ñ çîìáè\r
+SET_ITEM 180 3 37 64 0 b1101\r
+;ßéöî ñî ñâèíü¸é\r
+SET_ITEM 181 3 38 64 0 b1101\r
+;ßéöî ñ îâöîé\r
+SET_ITEM 182 3 39 64 0 b1101\r
+;Ïîðîõ\r
+SET_ITEM 183 3 31 64 0 b1101\r
+;×àøêà\r
+SET_ITEM 184 3 40 64 0 b1101\r
+;Òóøåíûå ãðèáû\r
+SET_ITEM 185 3 41 64 0 b1101\r
+;Êàðòà\r
+SET_ITEM 186 3 53 1 0 b1101\r
+;Êàðòèíà\r
+SET_ITEM 187 3 54 64 0 b1101\r
+;Ñûðàÿ ñâèíèíà\r
+SET_ITEM 188 3 55 64 0 b1101\r
+;Æàðåíàÿ ñâèíèíà\r
+SET_ITEM 189 3 56 64 0 b1101\r
+;Ãíèëàÿ ïëîòü\r
+SET_ITEM 190 3 57 64 0 b1101\r
+;Êàìåðà\r
+SET_ITEM 191 3 69 1 0 b1101\r
+SET_ITEM 192 3 70 1 0 b1101\r
+SET_ITEM 193 3 71 1 0 b1101\r
+;Çîëîòîé ñàìîðîäîê\r
+SET_ITEM 194 3 42 64 0 b1101\r
+;Ñàõàð\r
+SET_ITEM 195 3 58 64 0 b1101\r
+;Ïàó÷èé ãëàç\r
+SET_ITEM 196 3 74 64 0 b1101\r
+;Ïåðî\r
+SET_ITEM 197 3 85 64 0 b1101\r
+;Êîæà\r
+SET_ITEM 198 3 86 64 0 b1101\r
+;Ñûðàÿ ãîâÿäèíà\r
+SET_ITEM 199 3 87 64 0 b1101\r
+;Æàðåíàÿ ãîâÿäèíà\r
+SET_ITEM 200 3 88 64 0 b1101\r
+;ßáëîêî\r
+SET_ITEM 201 3 89 64 0 b1101\r
+;Çîëîòîå ÿáëîêî\r
+SET_ITEM 202 3 90 64 0 b1101\r
+;Ñûðàÿ êóðèöà\r
+SET_ITEM 203 3 72 64 0 b1101\r
+;Æàðåíàÿ êóðèöà\r
+SET_ITEM 204 3 73 64 0 b1101\r
+;ßéöî ñ êóðèöåé\r
+SET_ITEM 205 3 96 64 0 b1101\r
+;ßéöî ñ êðèïåðîì\r
+SET_ITEM 206 3 97 64 0 b1101\r
+;Êðåìåíü\r
+SET_ITEM 207 3 1 64 0 b1101\r
+;ßéöî ñ êîðîâîé\r
+SET_ITEM 208 3 99 64 0 b1101\r
+;ßéöî ñ ãðèáíîé êîðîâîé\r
+SET_ITEM 209 3 100 64 0 b1101\r
+;Ñûðàÿ ðûáà\r
+SET_ITEM 210 3 102 64 0 b1101\r
+;Æàðåíàÿ ðûáà\r
+SET_ITEM 211 3 103 64 0 b1101\r
+;ßéöî ñ ñâèíîçîìáè\r
+SET_ITEM 212 3 104 64 0 b1101\r
+;ßéöî ñ ïàóêîì\r
+SET_ITEM 213 3 105 64 0 b1101\r
+;Ñâåòîïûëü\r
+SET_ITEM 214 3 107 64 0 b1101\r
+;×àñû\r
+SET_ITEM 215 3 109 1 0 b1101\r
+;Êîìïàñ\r
+SET_ITEM 216 3 108 1 0 b1101\r
+;Ñåìåíà\r
+SET_ITEM 217 3 110 64 0 b1101\r
+;Ïøåíèöà\r
+SET_ITEM 218 3 111 64 0 b1101\r
+;Õëåá\r
+SET_ITEM 219 3 112 64 0 b1101\r
+;Êîñòíàÿ ìóêà\r
+SET_ITEM 220 3 113 64 0 b1101\r
+;Ñåìåíà àðáóçà\r
+SET_ITEM 221 3 114 64 0 b1101\r
+;Ñåìåíà òûêâû\r
+SET_ITEM 222 3 115 64 0 b1101\r
+\r
+;======[Ñïèñîê]======\r
+SET_MAX_ITEM_LIST 194\r
+\r
+SET_ITEM_LIST 0 1\r
+SET_ITEM_LIST 1 2\r
+SET_ITEM_LIST 2 3\r
+SET_ITEM_LIST 3 4\r
+SET_ITEM_LIST 4 5\r
+SET_ITEM_LIST 5 6\r
+SET_ITEM_LIST 6 7\r
+SET_ITEM_LIST 7 8\r
+SET_ITEM_LIST 8 9\r
+SET_ITEM_LIST 9 10\r
+SET_ITEM_LIST 10 11\r
+SET_ITEM_LIST 11 12\r
+SET_ITEM_LIST 12 13\r
+SET_ITEM_LIST 13 14\r
+SET_ITEM_LIST 14 15\r
+SET_ITEM_LIST 15 16\r
+SET_ITEM_LIST 16 17\r
+SET_ITEM_LIST 17 18\r
+SET_ITEM_LIST 18 19\r
+SET_ITEM_LIST 19 20\r
+SET_ITEM_LIST 20 21\r
+SET_ITEM_LIST 21 22\r
+SET_ITEM_LIST 22 23\r
+SET_ITEM_LIST 23 24\r
+SET_ITEM_LIST 24 25\r
+SET_ITEM_LIST 25 26\r
+SET_ITEM_LIST 26 27\r
+SET_ITEM_LIST 27 28\r
+SET_ITEM_LIST 28 29\r
+SET_ITEM_LIST 29 30\r
+SET_ITEM_LIST 30 31\r
+SET_ITEM_LIST 31 32\r
+SET_ITEM_LIST 32 33\r
+SET_ITEM_LIST 33 34\r
+SET_ITEM_LIST 34 35\r
+SET_ITEM_LIST 35 36\r
+SET_ITEM_LIST 36 37\r
+SET_ITEM_LIST 37 38\r
+SET_ITEM_LIST 38 39\r
+SET_ITEM_LIST 39 40\r
+SET_ITEM_LIST 40 41\r
+SET_ITEM_LIST 41 42\r
+SET_ITEM_LIST 42 43\r
+SET_ITEM_LIST 43 44\r
+SET_ITEM_LIST 44 45\r
+SET_ITEM_LIST 45 46\r
+SET_ITEM_LIST 46 47\r
+SET_ITEM_LIST 47 48\r
+SET_ITEM_LIST 48 49\r
+SET_ITEM_LIST 49 50\r
+SET_ITEM_LIST 50 51\r
+SET_ITEM_LIST 51 52\r
+SET_ITEM_LIST 52 53\r
+SET_ITEM_LIST 53 54\r
+SET_ITEM_LIST 54 55\r
+SET_ITEM_LIST 55 56\r
+SET_ITEM_LIST 56 57\r
+SET_ITEM_LIST 57 58\r
+SET_ITEM_LIST 58 59\r
+SET_ITEM_LIST 59 61\r
+SET_ITEM_LIST 60 62\r
+SET_ITEM_LIST 61 64\r
+SET_ITEM_LIST 62 65\r
+SET_ITEM_LIST 63 66\r
+SET_ITEM_LIST 64 67\r
+SET_ITEM_LIST 65 68\r
+SET_ITEM_LIST 66 69\r
+SET_ITEM_LIST 67 70\r
+SET_ITEM_LIST 68 71\r
+SET_ITEM_LIST 69 72\r
+SET_ITEM_LIST 70 73\r
+SET_ITEM_LIST 71 74\r
+SET_ITEM_LIST 72 75\r
+SET_ITEM_LIST 73 76\r
+SET_ITEM_LIST 74 83\r
+SET_ITEM_LIST 75 84\r
+SET_ITEM_LIST 76 85\r
+SET_ITEM_LIST 77 86\r
+SET_ITEM_LIST 78 87\r
+SET_ITEM_LIST 79 88\r
+SET_ITEM_LIST 80 89\r
+SET_ITEM_LIST 81 90\r
+SET_ITEM_LIST 82 91\r
+SET_ITEM_LIST 83 92\r
+SET_ITEM_LIST 84 93\r
+SET_ITEM_LIST 85 94\r
+SET_ITEM_LIST 86 103\r
+SET_ITEM_LIST 87 104\r
+SET_ITEM_LIST 88 105\r
+SET_ITEM_LIST 89 106\r
+SET_ITEM_LIST 90 108\r
+SET_ITEM_LIST 91 109\r
+SET_ITEM_LIST 92 111\r
+SET_ITEM_LIST 93 112\r
+SET_ITEM_LIST 94 113\r
+SET_ITEM_LIST 95 114\r
+SET_ITEM_LIST 96 115\r
+SET_ITEM_LIST 97 116\r
+SET_ITEM_LIST 98 118\r
+SET_ITEM_LIST 99 119\r
+SET_ITEM_LIST 100 121\r
+\r
+SET_ITEM_LIST 101 127\r
+SET_ITEM_LIST 102 128\r
+SET_ITEM_LIST 103 129\r
+SET_ITEM_LIST 104 131\r
+SET_ITEM_LIST 105 132\r
+SET_ITEM_LIST 106 133\r
+SET_ITEM_LIST 107 134\r
+SET_ITEM_LIST 108 135\r
+SET_ITEM_LIST 109 136\r
+SET_ITEM_LIST 110 137\r
+SET_ITEM_LIST 111 138\r
+SET_ITEM_LIST 112 139\r
+SET_ITEM_LIST 113 140\r
+SET_ITEM_LIST 114 141\r
+SET_ITEM_LIST 115 142\r
+SET_ITEM_LIST 116 143\r
+SET_ITEM_LIST 117 144\r
+SET_ITEM_LIST 118 145\r
+SET_ITEM_LIST 119 146\r
+SET_ITEM_LIST 120 147\r
+SET_ITEM_LIST 121 148\r
+SET_ITEM_LIST 122 149\r
+SET_ITEM_LIST 123 150\r
+SET_ITEM_LIST 124 151\r
+SET_ITEM_LIST 125 152\r
+SET_ITEM_LIST 126 153\r
+SET_ITEM_LIST 127 154\r
+SET_ITEM_LIST 128 155\r
+SET_ITEM_LIST 129 156\r
+SET_ITEM_LIST 130 157\r
+SET_ITEM_LIST 131 158\r
+\r
+SET_ITEM_LIST 132 160\r
+SET_ITEM_LIST 133 161\r
+SET_ITEM_LIST 134 162\r
+SET_ITEM_LIST 135 163\r
+SET_ITEM_LIST 136 164\r
+SET_ITEM_LIST 137 165\r
+SET_ITEM_LIST 138 166\r
+SET_ITEM_LIST 139 167\r
+SET_ITEM_LIST 140 168\r
+SET_ITEM_LIST 141 169\r
+SET_ITEM_LIST 142 170\r
+SET_ITEM_LIST 143 171\r
+SET_ITEM_LIST 144 172\r
+SET_ITEM_LIST 145 173\r
+SET_ITEM_LIST 146 174\r
+SET_ITEM_LIST 147 175\r
+SET_ITEM_LIST 148 176\r
+SET_ITEM_LIST 149 177\r
+SET_ITEM_LIST 150 178\r
+SET_ITEM_LIST 151 179\r
+SET_ITEM_LIST 152 180\r
+SET_ITEM_LIST 153 181\r
+SET_ITEM_LIST 154 182\r
+SET_ITEM_LIST 155 183\r
+SET_ITEM_LIST 156 184\r
+SET_ITEM_LIST 157 185\r
+SET_ITEM_LIST 158 186\r
+SET_ITEM_LIST 159 187\r
+SET_ITEM_LIST 160 188\r
+SET_ITEM_LIST 161 189\r
+SET_ITEM_LIST 162 190\r
+SET_ITEM_LIST 163 191\r
+SET_ITEM_LIST 164 192\r
+SET_ITEM_LIST 165 193\r
+SET_ITEM_LIST 166 194\r
+SET_ITEM_LIST 167 195\r
+SET_ITEM_LIST 168 196\r
+SET_ITEM_LIST 169 197\r
+SET_ITEM_LIST 170 198\r
+SET_ITEM_LIST 171 199\r
+SET_ITEM_LIST 172 200\r
+SET_ITEM_LIST 173 201\r
+SET_ITEM_LIST 174 202\r
+SET_ITEM_LIST 175 203\r
+SET_ITEM_LIST 176 204\r
+SET_ITEM_LIST 177 205\r
+SET_ITEM_LIST 178 206\r
+SET_ITEM_LIST 179 207\r
+SET_ITEM_LIST 180 208\r
+SET_ITEM_LIST 181 209\r
+SET_ITEM_LIST 182 210\r
+SET_ITEM_LIST 183 211\r
+SET_ITEM_LIST 184 212\r
+SET_ITEM_LIST 185 213\r
+SET_ITEM_LIST 186 214\r
+SET_ITEM_LIST 187 215\r
+SET_ITEM_LIST 188 216\r
+SET_ITEM_LIST 189 217\r
+SET_ITEM_LIST 190 218\r
+SET_ITEM_LIST 191 219\r
+SET_ITEM_LIST 192 220\r
+SET_ITEM_LIST 193 221\r
+SET_ITEM_LIST 194 222\r
diff --git a/res/keyboard.cfg b/res/keyboard.cfg
--- /dev/null
+++ b/res/keyboard.cfg
@@ -0,0 +1,75 @@
+;Èíèöèàëèçàöèÿ êëàâèàòóðû\r
+;BIND_KEY [type] [keycode1] [keycode2] [keycode3] [keycode4]\r
+;type - äåéñòâèå êëàâèøè:\r
+; KEY_FM_UP=0;\r
+; KEY_FM_DOWN=1;\r
+; KEY_FM_SELECT=2;\r
+;\r
+; KEY_MENU_UP=3;\r
+; KEY_MENU_DOWN=4;\r
+; KEY_MENU_LEFT=5;\r
+; KEY_MENU_RIGHT=6;\r
+; KEY_MENU_SELECT=7;\r
+;\r
+; KEY_FASTINV_PREV=8;\r
+; KEY_FASTINV_NEXT=9;\r
+;\r
+; KEY_CHAT=10;\r
+;\r
+; KEY_PLR_OPENINV=11;\r
+; KEY_PLR_EDITMODE=12;\r
+; KEY_PLR_USE=13;\r
+; KEY_PLR_ATTACK=14;\r
+;\r
+; KEY_PLR_UP=15;\r
+; KEY_PLR_DOWN=16;\r
+; KEY_PLR_LEFT=17;\r
+; KEY_PLR_RIGHT=18;\r
+;\r
+; KEY_MENU=19;\r
+;\r
+; KEY_WIN_UP=20;\r
+; KEY_WIN_DOWN=21;\r
+; KEY_WIN_LEFT=22;\r
+; KEY_WIN_RIGHT=23;\r
+; KEY_WIN_SELECT=24;\r
+; KEY_WIN_ALT=25;\r
+; KEY_WIN_DROP=26;\r
+; KEY_WIN_EXIT=27;\r
+;keycodeN - êîä êëàâèøè\r
+\r
+BIND_KEY 0 -1 50 0 0\r
+BIND_KEY 1 -2 56 0 0\r
+BIND_KEY 2 -5 53 0 0\r
+\r
+BIND_KEY 3 -1 50 0 0\r
+BIND_KEY 4 -2 56 0 0\r
+BIND_KEY 5 -3 52 0 0\r
+BIND_KEY 6 -4 54 0 0\r
+BIND_KEY 7 -5 53 0 0\r
+\r
+BIND_KEY 8 -6 35 0 0\r
+BIND_KEY 9 -7 42 0 0\r
+\r
+BIND_KEY 10 55 0 0 0\r
+\r
+BIND_KEY 11 49 0 0 0\r
+BIND_KEY 12 48 0 0 0\r
+BIND_KEY 13 51 0 0 0\r
+BIND_KEY 14 -5 53 0 0\r
+\r
+BIND_KEY 15 -1 50 0 0\r
+BIND_KEY 16 -2 56 0 0\r
+BIND_KEY 17 -3 52 0 0\r
+BIND_KEY 18 -4 54 0 0\r
+\r
+BIND_KEY 19 57 0 0 0\r
+\r
+BIND_KEY 20 -1 50 0 0\r
+BIND_KEY 21 -2 56 0 0\r
+BIND_KEY 22 -3 52 0 0\r
+BIND_KEY 23 -4 54 0 0\r
+BIND_KEY 24 -5 53 0 0\r
+BIND_KEY 25 49 0 0 0\r
+BIND_KEY 26 51 0 0 0\r
+BIND_KEY 27 57 0 0 0\r
diff --git a/res/maps.png b/res/maps.png
diff --git a/res/mobs/char_ani.png b/res/mobs/char_ani.png
new file mode 100644 (file)
index 0000000..ab8bc78
Binary files /dev/null and b/res/mobs/char_ani.png differ
index 0000000..ab8bc78
Binary files /dev/null and b/res/mobs/char_ani.png differ
diff --git a/res/mobs/chicken_anims.png b/res/mobs/chicken_anims.png
new file mode 100644 (file)
index 0000000..1def594
Binary files /dev/null and b/res/mobs/chicken_anims.png differ
index 0000000..1def594
Binary files /dev/null and b/res/mobs/chicken_anims.png differ
diff --git a/res/mobs/cow.png b/res/mobs/cow.png
new file mode 100644 (file)
index 0000000..af1f07d
Binary files /dev/null and b/res/mobs/cow.png differ
index 0000000..af1f07d
Binary files /dev/null and b/res/mobs/cow.png differ
diff --git a/res/mobs/cow2.png b/res/mobs/cow2.png
new file mode 100644 (file)
index 0000000..dbbfc4f
Binary files /dev/null and b/res/mobs/cow2.png differ
index 0000000..dbbfc4f
Binary files /dev/null and b/res/mobs/cow2.png differ
diff --git a/res/mobs/creeper_anims.png b/res/mobs/creeper_anims.png
new file mode 100644 (file)
index 0000000..dbb78bb
Binary files /dev/null and b/res/mobs/creeper_anims.png differ
index 0000000..dbb78bb
Binary files /dev/null and b/res/mobs/creeper_anims.png differ
diff --git a/res/mobs/pig_anims.png b/res/mobs/pig_anims.png
new file mode 100644 (file)
index 0000000..87cc86d
Binary files /dev/null and b/res/mobs/pig_anims.png differ
index 0000000..87cc86d
Binary files /dev/null and b/res/mobs/pig_anims.png differ
diff --git a/res/mobs/pigman_ani.png b/res/mobs/pigman_ani.png
new file mode 100644 (file)
index 0000000..52a606a
Binary files /dev/null and b/res/mobs/pigman_ani.png differ
index 0000000..52a606a
Binary files /dev/null and b/res/mobs/pigman_ani.png differ
diff --git a/res/mobs/sheep_anims.png b/res/mobs/sheep_anims.png
new file mode 100644 (file)
index 0000000..ffc027b
Binary files /dev/null and b/res/mobs/sheep_anims.png differ
index 0000000..ffc027b
Binary files /dev/null and b/res/mobs/sheep_anims.png differ
diff --git a/res/mobs/sheep_fur.png b/res/mobs/sheep_fur.png
new file mode 100644 (file)
index 0000000..e5d0577
Binary files /dev/null and b/res/mobs/sheep_fur.png differ
index 0000000..e5d0577
Binary files /dev/null and b/res/mobs/sheep_fur.png differ
diff --git a/res/mobs/spider_ani.png b/res/mobs/spider_ani.png
new file mode 100644 (file)
index 0000000..f10d159
Binary files /dev/null and b/res/mobs/spider_ani.png differ
index 0000000..f10d159
Binary files /dev/null and b/res/mobs/spider_ani.png differ
diff --git a/res/mobs/zombie_ani.png b/res/mobs/zombie_ani.png
new file mode 100644 (file)
index 0000000..a1e05fd
Binary files /dev/null and b/res/mobs/zombie_ani.png differ
index 0000000..a1e05fd
Binary files /dev/null and b/res/mobs/zombie_ani.png differ
diff --git a/res/pack.png b/res/pack.png
diff --git a/res/terrain.png b/res/terrain.png
new file mode 100644 (file)
index 0000000..d1af4a8
Binary files /dev/null and b/res/terrain.png differ
index 0000000..d1af4a8
Binary files /dev/null and b/res/terrain.png differ
diff --git a/res/terrain/explosion.png b/res/terrain/explosion.png
new file mode 100644 (file)
index 0000000..5c7d72a
Binary files /dev/null and b/res/terrain/explosion.png differ
index 0000000..5c7d72a
Binary files /dev/null and b/res/terrain/explosion.png differ
diff --git a/res/terrain/light.png b/res/terrain/light.png
new file mode 100644 (file)
index 0000000..d2dbc52
Binary files /dev/null and b/res/terrain/light.png differ
index 0000000..d2dbc52
Binary files /dev/null and b/res/terrain/light.png differ
diff --git a/res/terrain/moon_phases/moon_phase_0.png b/res/terrain/moon_phases/moon_phase_0.png
new file mode 100644 (file)
index 0000000..0e44c89
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_0.png differ
index 0000000..0e44c89
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_0.png differ
diff --git a/res/terrain/moon_phases/moon_phase_1.png b/res/terrain/moon_phases/moon_phase_1.png
new file mode 100644 (file)
index 0000000..8e5a01f
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_1.png differ
index 0000000..8e5a01f
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_1.png differ
diff --git a/res/terrain/moon_phases/moon_phase_2.png b/res/terrain/moon_phases/moon_phase_2.png
new file mode 100644 (file)
index 0000000..760c6e3
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_2.png differ
index 0000000..760c6e3
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_2.png differ
diff --git a/res/terrain/moon_phases/moon_phase_3.png b/res/terrain/moon_phases/moon_phase_3.png
new file mode 100644 (file)
index 0000000..fe09721
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_3.png differ
index 0000000..fe09721
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_3.png differ
diff --git a/res/terrain/moon_phases/moon_phase_4.png b/res/terrain/moon_phases/moon_phase_4.png
new file mode 100644 (file)
index 0000000..f427cfb
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_4.png differ
index 0000000..f427cfb
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_4.png differ
diff --git a/res/terrain/moon_phases/moon_phase_5.png b/res/terrain/moon_phases/moon_phase_5.png
new file mode 100644 (file)
index 0000000..b26a28d
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_5.png differ
index 0000000..b26a28d
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_5.png differ
diff --git a/res/terrain/moon_phases/moon_phase_6.png b/res/terrain/moon_phases/moon_phase_6.png
new file mode 100644 (file)
index 0000000..4f5bc7a
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_6.png differ
index 0000000..4f5bc7a
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_6.png differ
diff --git a/res/terrain/moon_phases/moon_phase_7.png b/res/terrain/moon_phases/moon_phase_7.png
new file mode 100644 (file)
index 0000000..4201800
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_7.png differ
index 0000000..4201800
Binary files /dev/null and b/res/terrain/moon_phases/moon_phase_7.png differ
diff --git a/res/terrain/particles.png b/res/terrain/particles.png
new file mode 100644 (file)
index 0000000..c8026d2
Binary files /dev/null and b/res/terrain/particles.png differ
index 0000000..c8026d2
Binary files /dev/null and b/res/terrain/particles.png differ
diff --git a/res/terrain/rain.png b/res/terrain/rain.png
new file mode 100644 (file)
index 0000000..54ab30c
Binary files /dev/null and b/res/terrain/rain.png differ
index 0000000..54ab30c
Binary files /dev/null and b/res/terrain/rain.png differ
diff --git a/res/terrain/sky.png b/res/terrain/sky.png
new file mode 100644 (file)
index 0000000..885e4e2
Binary files /dev/null and b/res/terrain/sky.png differ
index 0000000..885e4e2
Binary files /dev/null and b/res/terrain/sky.png differ
diff --git a/res/terrain/snow.png b/res/terrain/snow.png
new file mode 100644 (file)
index 0000000..9290fa8
Binary files /dev/null and b/res/terrain/snow.png differ
index 0000000..9290fa8
Binary files /dev/null and b/res/terrain/snow.png differ
diff --git a/res/terrain/sun.png b/res/terrain/sun.png
new file mode 100644 (file)
index 0000000..85cccda
Binary files /dev/null and b/res/terrain/sun.png differ
index 0000000..85cccda
Binary files /dev/null and b/res/terrain/sun.png differ
diff --git a/res/textures.cfg b/res/textures.cfg
--- /dev/null
+++ b/res/textures.cfg
@@ -0,0 +1,291 @@
+;Èíèöàëèçàöèÿ òåêñòóð áëîêîâ è ïðåäìåòîâ\r
+\r
+;Óñòàíàâëèâàåì êîëè÷åñòâî çàãðóæàåìûõ òåêñòóð\r
+RESET_ITEMS_TEX 116\r
+RESET_BLOCKS_TEX 143\r
+\r
+;SET_CANV_TEX [type] [id] [x] [y] [w] [h]\r
+\r
+LOAD_TEX terrain.png\r
+SET_CANV_TEX BLOCK 0 0 0 16 16\r
+SET_CANV_TEX BLOCK 1 16 0 16 16\r
+SET_CANV_TEX BLOCK 2 32 0 16 16\r
+SET_CANV_TEX BLOCK 3 48 0 16 16\r
+SET_CANV_TEX BLOCK 4 64 0 16 16\r
+SET_CANV_TEX BLOCK 5 80 0 16 16\r
+SET_CANV_TEX BLOCK 6 96 0 16 16\r
+SET_CANV_TEX BLOCK 7 112 0 16 16\r
+SET_CANV_TEX BLOCK 8 128 0 16 16\r
+SET_CANV_TEX BLOCK 9 144 0 16 16\r
+SET_CANV_TEX BLOCK 10 160 0 16 16\r
+SET_CANV_TEX BLOCK 11 176 0 16 16\r
+SET_CANV_TEX BLOCK 12 192 0 16 16\r
+SET_CANV_TEX BLOCK 13 208 0 16 16\r
+SET_CANV_TEX BLOCK 14 224 0 16 16\r
+SET_CANV_TEX BLOCK 15 240 0 16 16\r
+\r
+SET_CANV_TEX BLOCK 16 0 16 16 16\r
+SET_CANV_TEX BLOCK 17 16 16 16 16\r
+SET_CANV_TEX BLOCK 18 32 16 16 16\r
+SET_CANV_TEX BLOCK 19 48 16 16 16\r
+SET_CANV_TEX BLOCK 20 64 16 16 16\r
+SET_CANV_TEX BLOCK 21 80 16 16 16\r
+SET_CANV_TEX BLOCK 22 96 16 16 16\r
+SET_CANV_TEX BLOCK 23 112 16 16 16\r
+SET_CANV_TEX BLOCK 24 128 16 16 16\r
+SET_CANV_TEX BLOCK 25 144 16 16 16\r
+SET_CANV_TEX BLOCK 26 160 16 16 16\r
+SET_CANV_TEX BLOCK 27 176 16 16 16\r
+SET_CANV_TEX BLOCK 28 192 16 16 16\r
+SET_CANV_TEX BLOCK 29 208 16 16 16\r
+SET_CANV_TEX BLOCK 30 224 16 16 16\r
+SET_CANV_TEX BLOCK 31 240 16 16 16\r
+\r
+SET_CANV_TEX BLOCK 32 0 32 16 16\r
+SET_CANV_TEX BLOCK 33 16 32 16 16\r
+SET_CANV_TEX BLOCK 34 32 32 16 16\r
+SET_CANV_TEX BLOCK 35 48 32 16 16\r
+SET_CANV_TEX BLOCK 36 64 32 16 16\r
+SET_CANV_TEX BLOCK 37 80 32 16 16\r
+SET_CANV_TEX BLOCK 38 96 32 16 16\r
+SET_CANV_TEX BLOCK 39 112 32 16 16\r
+SET_CANV_TEX BLOCK 40 128 32 16 16\r
+SET_CANV_TEX BLOCK 41 144 32 16 16\r
+SET_CANV_TEX BLOCK 42 160 32 16 16\r
+SET_CANV_TEX BLOCK 43 176 32 16 16\r
+SET_CANV_TEX BLOCK 44 192 32 16 16\r
+SET_CANV_TEX BLOCK 45 208 32 16 16\r
+SET_CANV_TEX BLOCK 46 224 32 16 16\r
+SET_CANV_TEX BLOCK 47 240 32 16 16\r
+\r
+SET_CANV_TEX BLOCK 48 0 48 16 16\r
+SET_CANV_TEX BLOCK 49 16 48 16 16\r
+SET_CANV_TEX BLOCK 50 32 48 16 16\r
+SET_CANV_TEX BLOCK 51 48 48 16 16\r
+SET_CANV_TEX BLOCK 52 64 48 16 16\r
+SET_CANV_TEX BLOCK 53 80 48 16 16\r
+SET_CANV_TEX BLOCK 54 96 48 16 16\r
+SET_CANV_TEX BLOCK 55 112 48 16 16\r
+SET_CANV_TEX BLOCK 56 128 48 16 16\r
+SET_CANV_TEX BLOCK 57 144 48 16 16\r
+SET_CANV_TEX BLOCK 58 160 48 16 16\r
+SET_CANV_TEX BLOCK 59 176 48 16 16\r
+SET_CANV_TEX BLOCK 60 192 48 16 16\r
+SET_CANV_TEX BLOCK 61 208 48 16 16\r
+SET_CANV_TEX BLOCK 62 224 48 16 16\r
+SET_CANV_TEX BLOCK 63 240 48 16 16\r
+\r
+SET_CANV_TEX BLOCK 64 0 64 16 16\r
+SET_CANV_TEX BLOCK 65 16 64 16 16\r
+SET_CANV_TEX BLOCK 66 32 64 16 16\r
+SET_CANV_TEX BLOCK 67 48 64 16 16\r
+SET_CANV_TEX BLOCK 68 64 64 16 16\r
+SET_CANV_TEX BLOCK 69 80 64 16 16\r
+SET_CANV_TEX BLOCK 70 96 64 16 16\r
+SET_CANV_TEX BLOCK 71 112 64 16 16\r
+SET_CANV_TEX BLOCK 72 128 64 16 16\r
+SET_CANV_TEX BLOCK 73 144 64 16 16\r
+SET_CANV_TEX BLOCK 74 160 64 16 16\r
+SET_CANV_TEX BLOCK 75 176 64 16 16\r
+SET_CANV_TEX BLOCK 76 192 64 16 16\r
+SET_CANV_TEX BLOCK 77 208 64 16 16\r
+SET_CANV_TEX BLOCK 78 224 64 16 16\r
+SET_CANV_TEX BLOCK 79 240 64 16 16\r
+\r
+SET_CANV_TEX BLOCK 80 0 80 16 16\r
+SET_CANV_TEX BLOCK 81 16 80 16 16\r
+SET_CANV_TEX BLOCK 82 32 80 16 16\r
+SET_CANV_TEX BLOCK 83 48 80 16 16\r
+SET_CANV_TEX BLOCK 84 64 80 16 16\r
+SET_CANV_TEX BLOCK 85 80 80 16 16\r
+SET_CANV_TEX BLOCK 86 96 80 16 16\r
+SET_CANV_TEX BLOCK 87 112 80 16 16\r
+SET_CANV_TEX BLOCK 88 128 80 16 16\r
+SET_CANV_TEX BLOCK 89 144 80 16 16\r
+SET_CANV_TEX BLOCK 90 160 80 16 16\r
+SET_CANV_TEX BLOCK 91 176 80 16 16\r
+SET_CANV_TEX BLOCK 92 192 80 16 16\r
+SET_CANV_TEX BLOCK 93 208 80 16 16\r
+SET_CANV_TEX BLOCK 94 224 80 16 16\r
+SET_CANV_TEX BLOCK 95 240 80 16 16\r
+\r
+SET_CANV_TEX BLOCK 96 0 96 16 16\r
+SET_CANV_TEX BLOCK 97 16 96 16 16\r
+SET_CANV_TEX BLOCK 98 32 96 16 16\r
+SET_CANV_TEX BLOCK 99 48 96 16 16\r
+SET_CANV_TEX BLOCK 100 64 96 16 16\r
+SET_CANV_TEX BLOCK 101 80 96 16 16\r
+SET_CANV_TEX BLOCK 102 96 96 16 16\r
+SET_CANV_TEX BLOCK 103 112 96 16 16\r
+SET_CANV_TEX BLOCK 104 128 96 16 16\r
+SET_CANV_TEX BLOCK 105 144 96 16 16\r
+SET_CANV_TEX BLOCK 106 160 96 16 16\r
+SET_CANV_TEX BLOCK 107 176 96 16 16\r
+SET_CANV_TEX BLOCK 108 192 96 16 16\r
+SET_CANV_TEX BLOCK 109 208 96 16 16\r
+SET_CANV_TEX BLOCK 110 224 96 16 16\r
+SET_CANV_TEX BLOCK 111 240 96 16 16\r
+\r
+SET_CANV_TEX BLOCK 112 0 112 16 16\r
+SET_CANV_TEX BLOCK 113 16 112 16 16\r
+SET_CANV_TEX BLOCK 114 32 112 16 16\r
+SET_CANV_TEX BLOCK 115 48 112 16 16\r
+SET_CANV_TEX BLOCK 116 64 112 16 16\r
+SET_CANV_TEX BLOCK 117 80 112 16 16\r
+SET_CANV_TEX BLOCK 118 96 112 16 16\r
+SET_CANV_TEX BLOCK 119 112 112 16 16\r
+SET_CANV_TEX BLOCK 120 128 112 16 16\r
+SET_CANV_TEX BLOCK 121 144 112 16 16\r
+SET_CANV_TEX BLOCK 122 160 112 16 16\r
+SET_CANV_TEX BLOCK 123 176 112 16 16\r
+SET_CANV_TEX BLOCK 124 192 112 16 16\r
+SET_CANV_TEX BLOCK 125 208 112 16 16\r
+SET_CANV_TEX BLOCK 126 224 112 16 16\r
+SET_CANV_TEX BLOCK 127 240 112 16 16\r
+\r
+SET_CANV_TEX BLOCK 128 0 128 16 16\r
+SET_CANV_TEX BLOCK 129 16 128 16 16\r
+SET_CANV_TEX BLOCK 130 32 128 16 16\r
+SET_CANV_TEX BLOCK 131 48 128 16 16\r
+SET_CANV_TEX BLOCK 132 64 128 16 16\r
+SET_CANV_TEX BLOCK 133 80 128 16 16\r
+SET_CANV_TEX BLOCK 134 96 128 16 16\r
+SET_CANV_TEX BLOCK 135 112 128 16 16\r
+SET_CANV_TEX BLOCK 136 128 128 16 16\r
+SET_CANV_TEX BLOCK 137 144 128 16 16\r
+SET_CANV_TEX BLOCK 138 160 128 16 16\r
+SET_CANV_TEX BLOCK 139 176 128 16 16\r
+SET_CANV_TEX BLOCK 140 192 128 16 16\r
+SET_CANV_TEX BLOCK 141 208 128 16 16\r
+SET_CANV_TEX BLOCK 142 224 128 16 16\r
+SET_CANV_TEX BLOCK 143 240 128 16 16\r
+\r
+\r
+LOAD_TEX gui/items.png\r
+\r
+SET_CANV_TEX ITEM 0 0 0 16 16\r
+SET_CANV_TEX ITEM 1 16 0 16 16\r
+SET_CANV_TEX ITEM 2 32 0 16 16\r
+SET_CANV_TEX ITEM 3 48 0 16 16\r
+SET_CANV_TEX ITEM 4 64 0 16 16\r
+SET_CANV_TEX ITEM 5 80 0 16 16\r
+SET_CANV_TEX ITEM 6 96 0 16 16\r
+SET_CANV_TEX ITEM 7 112 0 16 16\r
+SET_CANV_TEX ITEM 8 128 0 16 16\r
+SET_CANV_TEX ITEM 9 144 0 16 16\r
+SET_CANV_TEX ITEM 10 160 0 16 16\r
+SET_CANV_TEX ITEM 11 176 0 16 16\r
+SET_CANV_TEX ITEM 12 192 0 16 16\r
+SET_CANV_TEX ITEM 13 208 0 16 16\r
+SET_CANV_TEX ITEM 14 224 0 16 16\r
+SET_CANV_TEX ITEM 15 240 0 16 16\r
+\r
+SET_CANV_TEX ITEM 16 0 16 16 16\r
+SET_CANV_TEX ITEM 17 16 16 16 16\r
+SET_CANV_TEX ITEM 18 32 16 16 16\r
+SET_CANV_TEX ITEM 19 48 16 16 16\r
+SET_CANV_TEX ITEM 20 64 16 16 16\r
+SET_CANV_TEX ITEM 21 80 16 16 16\r
+SET_CANV_TEX ITEM 22 96 16 16 16\r
+SET_CANV_TEX ITEM 23 112 16 16 16\r
+SET_CANV_TEX ITEM 24 128 16 16 16\r
+SET_CANV_TEX ITEM 25 144 16 16 16\r
+SET_CANV_TEX ITEM 26 160 16 16 16\r
+SET_CANV_TEX ITEM 27 176 16 16 16\r
+SET_CANV_TEX ITEM 28 192 16 16 16\r
+SET_CANV_TEX ITEM 29 208 16 16 16\r
+SET_CANV_TEX ITEM 30 224 16 16 16\r
+SET_CANV_TEX ITEM 31 240 16 16 16\r
+\r
+SET_CANV_TEX ITEM 32 0 32 16 16\r
+SET_CANV_TEX ITEM 33 16 32 16 16\r
+SET_CANV_TEX ITEM 34 32 32 16 16\r
+SET_CANV_TEX ITEM 35 48 32 16 16\r
+SET_CANV_TEX ITEM 36 64 32 16 16\r
+SET_CANV_TEX ITEM 37 80 32 16 16\r
+SET_CANV_TEX ITEM 38 96 32 16 16\r
+SET_CANV_TEX ITEM 39 112 32 16 16\r
+SET_CANV_TEX ITEM 40 128 32 16 16\r
+SET_CANV_TEX ITEM 41 144 32 16 16\r
+SET_CANV_TEX ITEM 42 160 32 16 16\r
+SET_CANV_TEX ITEM 43 176 32 16 16\r
+SET_CANV_TEX ITEM 44 192 32 16 16\r
+SET_CANV_TEX ITEM 45 208 32 16 16\r
+SET_CANV_TEX ITEM 46 224 32 16 16\r
+SET_CANV_TEX ITEM 47 240 32 16 16\r
+\r
+SET_CANV_TEX ITEM 48 0 48 16 16\r
+SET_CANV_TEX ITEM 49 16 48 16 16\r
+SET_CANV_TEX ITEM 50 32 48 16 16\r
+SET_CANV_TEX ITEM 51 48 48 16 16\r
+SET_CANV_TEX ITEM 52 64 48 16 16\r
+SET_CANV_TEX ITEM 53 80 48 16 16\r
+SET_CANV_TEX ITEM 54 96 48 16 16\r
+SET_CANV_TEX ITEM 55 112 48 16 16\r
+SET_CANV_TEX ITEM 56 128 48 16 16\r
+SET_CANV_TEX ITEM 57 144 48 16 16\r
+SET_CANV_TEX ITEM 58 160 48 16 16\r
+SET_CANV_TEX ITEM 59 176 48 16 16\r
+SET_CANV_TEX ITEM 60 192 48 16 16\r
+SET_CANV_TEX ITEM 61 208 48 16 16\r
+SET_CANV_TEX ITEM 62 224 48 16 16\r
+SET_CANV_TEX ITEM 63 240 48 16 16\r
+\r
+SET_CANV_TEX ITEM 64 0 64 16 16\r
+SET_CANV_TEX ITEM 65 16 64 16 16\r
+SET_CANV_TEX ITEM 66 32 64 16 16\r
+SET_CANV_TEX ITEM 67 48 64 16 16\r
+SET_CANV_TEX ITEM 68 64 64 16 16\r
+SET_CANV_TEX ITEM 69 80 64 16 16\r
+SET_CANV_TEX ITEM 70 96 64 16 16\r
+SET_CANV_TEX ITEM 71 112 64 16 16\r
+SET_CANV_TEX ITEM 72 128 64 16 16\r
+SET_CANV_TEX ITEM 73 144 64 16 16\r
+SET_CANV_TEX ITEM 74 160 64 16 16\r
+SET_CANV_TEX ITEM 75 176 64 16 16\r
+SET_CANV_TEX ITEM 76 192 64 16 16\r
+SET_CANV_TEX ITEM 77 208 64 16 16\r
+SET_CANV_TEX ITEM 78 224 64 16 16\r
+SET_CANV_TEX ITEM 79 240 64 16 16\r
+\r
+SET_CANV_TEX ITEM 80 0 80 16 16\r
+SET_CANV_TEX ITEM 81 16 80 16 16\r
+SET_CANV_TEX ITEM 82 32 80 16 16\r
+SET_CANV_TEX ITEM 83 48 80 16 16\r
+SET_CANV_TEX ITEM 84 64 80 16 16\r
+SET_CANV_TEX ITEM 85 80 80 16 16\r
+SET_CANV_TEX ITEM 86 96 80 16 16\r
+SET_CANV_TEX ITEM 87 112 80 16 16\r
+SET_CANV_TEX ITEM 88 128 80 16 16\r
+SET_CANV_TEX ITEM 89 144 80 16 16\r
+SET_CANV_TEX ITEM 90 160 80 16 16\r
+SET_CANV_TEX ITEM 91 176 80 16 16\r
+SET_CANV_TEX ITEM 92 192 80 16 16\r
+SET_CANV_TEX ITEM 93 208 80 16 16\r
+SET_CANV_TEX ITEM 94 224 80 16 16\r
+SET_CANV_TEX ITEM 95 240 80 16 16\r
+\r
+SET_CANV_TEX ITEM 96 0 96 16 16\r
+SET_CANV_TEX ITEM 97 16 96 16 16\r
+SET_CANV_TEX ITEM 98 32 96 16 16\r
+SET_CANV_TEX ITEM 99 48 96 16 16\r
+SET_CANV_TEX ITEM 100 64 96 16 16\r
+SET_CANV_TEX ITEM 101 80 96 16 16\r
+SET_CANV_TEX ITEM 102 96 96 16 16\r
+SET_CANV_TEX ITEM 103 112 96 16 16\r
+SET_CANV_TEX ITEM 104 128 96 16 16\r
+SET_CANV_TEX ITEM 105 144 96 16 16\r
+SET_CANV_TEX ITEM 106 160 96 16 16\r
+SET_CANV_TEX ITEM 107 176 96 16 16\r
+SET_CANV_TEX ITEM 108 192 96 16 16\r
+SET_CANV_TEX ITEM 109 208 96 16 16\r
+SET_CANV_TEX ITEM 110 224 96 16 16\r
+SET_CANV_TEX ITEM 111 240 96 16 16\r
+\r
+SET_CANV_TEX ITEM 112 0 112 16 16\r
+SET_CANV_TEX ITEM 113 16 112 16 16\r
+SET_CANV_TEX ITEM 114 32 112 16 16\r
+SET_CANV_TEX ITEM 115 48 112 16 16\r
+SET_CANV_TEX ITEM 116 64 112 16 16\r
+\r
+RESET_TEX\r
diff --git a/res/title/background.png b/res/title/background.png
new file mode 100644 (file)
index 0000000..958c66c
Binary files /dev/null and b/res/title/background.png differ
index 0000000..958c66c
Binary files /dev/null and b/res/title/background.png differ
diff --git a/res/title/cavelogo.png b/res/title/cavelogo.png
new file mode 100644 (file)
index 0000000..96b9193
Binary files /dev/null and b/res/title/cavelogo.png differ
index 0000000..96b9193
Binary files /dev/null and b/res/title/cavelogo.png differ
diff --git a/res/title/icon.png b/res/title/icon.png
new file mode 100644 (file)
index 0000000..205666d
Binary files /dev/null and b/res/title/icon.png differ
index 0000000..205666d
Binary files /dev/null and b/res/title/icon.png differ
diff --git a/res/title/splashes.txt b/res/title/splashes.txt
--- /dev/null
+++ b/res/title/splashes.txt
@@ -0,0 +1,41 @@
+38\r
+It's a begin...\r
+TEST\r
+It's been a long time...\r
+CORE!\r
+Kernel panic: Fatal exception\r
+DeaDSoftWare\r
+02:14AM 29 August 1997\r
+DeaDDooMER\r
+4815162342\r
+07.06.1997\r
+Almost open source!\r
+32768 blocks.\r
+Also try Minecraft!\r
+Knee-deep in the dead!\r
+DeaDSoftWare.Ru\r
+Keep calm and play CaveCraft\r
+Also try DooM 2D!\r
+Made in USSR!\r
+Only singleplayer!\r
+Touch Screen compatible!\r
+It's free!\r
+Enjoy\r
+CaveCraft.3dn.ru\r
+Random splash!\r
+Hello Notch!\r
+20 GOTO 10!\r
+LOL!\r
+MOV AX, 0B800h;\r
+Must have!\r
+Jeb_ HOPKOMAH!\r
+The cake is not a lie!\r
+Made on MidletPascal!\r
+Hell Machine of Dr. DooM!\r
+New free bugs!\r
+SoftWare is DeaD!\r
+Have fun!\r
+It's BETA!\r
+At least 20% cooler!\r
+Also try Galaxian: New Dimension!\r
+§DPinkie watching for you!\r
diff --git a/res/tools.cfg b/res/tools.cfg
--- /dev/null
+++ b/res/tools.cfg
@@ -0,0 +1,51 @@
+;Ôàéë èíèöèàëèçàöèè îïèñàíèÿ ñâîéñòâ ñòàíäàðòíîãî íàáîðà èíñòðóìåíòîâ CaveCraft\r
+\r
+;Óñòàíàâëèâàåì êîëè÷åñòâî èíñòðóìåíòîâ\r
+RESET_TOOLS 28\r
+\r
+;Îïèñàíèå êîìàíäû óñòàíîâêè èíñòðóìåíòà:\r
+;SET_TOOL [id] [tool] [lvl] [speed] [damg]\r
+;id - èäåíòèôèêàòîð èíñòðóìåíòà.\r
+;tool - òèï èíñòðóìåíòà.\r
+;lvl - óðîâåíü èíñòðóìåíòà.\r
+;speed - ñêîðîñòü èíñòðóìåíòà.\r
+;damg - óðîí íàíîñèìûé èíñòðóìåíòîì.\r
+\r
+;Null\r
+SET_TOOL 0 0 0 0 1\r
+;Êèðêè\r
+SET_TOOL 1 1 1 2 1\r
+SET_TOOL 2 1 2 3 1\r
+SET_TOOL 3 1 3 4 1\r
+SET_TOOL 4 1 5 6 1\r
+SET_TOOL 5 1 4 6 1\r
+;Ëîïàòû\r
+SET_TOOL 6 2 1 2 1\r
+SET_TOOL 7 2 2 3 1\r
+SET_TOOL 8 2 3 4 1\r
+SET_TOOL 9 2 5 6 1\r
+SET_TOOL 10 2 4 6 1\r
+;Òîïîðû\r
+SET_TOOL 11 3 1 2 1\r
+SET_TOOL 12 3 2 3 1\r
+SET_TOOL 13 3 3 4 1\r
+SET_TOOL 14 3 5 6 1\r
+SET_TOOL 15 3 4 6 1\r
+;Íîæíèöû\r
+SET_TOOL 16 4 1 5 1\r
+;Ìå÷è\r
+SET_TOOL 17 5 1 2 4\r
+SET_TOOL 18 5 2 3 5\r
+SET_TOOL 19 5 3 4 6\r
+SET_TOOL 20 5 5 6 7\r
+SET_TOOL 21 5 4 6 4\r
+;Óäî÷êà\r
+SET_TOOL 22 0 0 0 1\r
+;Îãíèâî\r
+SET_TOOL 23 0 0 0 1\r
+;Ìîòûãè\r
+SET_TOOL 24 6 1 2 1\r
+SET_TOOL 25 6 2 3 1\r
+SET_TOOL 26 6 3 4 1\r
+SET_TOOL 27 6 5 6 1\r
+SET_TOOL 28 6 4 6 1
\ No newline at end of file
diff --git a/res/vkeyboard.cfg b/res/vkeyboard.cfg
--- /dev/null
+++ b/res/vkeyboard.cfg
@@ -0,0 +1,112 @@
+MAX_VKEYS 11\r
+\r
+LOAD_TEX gui/touch.png\r
+SET_CANV_TEX VKEY 0 32 96 32 32\r
+SET_CANV_TEX VKEY 1 0 0 32 32\r
+SET_CANV_TEX VKEY 2 32 0 32 32\r
+SET_CANV_TEX VKEY 3 64 0 32 32\r
+SET_CANV_TEX VKEY 4 0 32 32 32\r
+SET_CANV_TEX VKEY 5 32 32 32 32\r
+SET_CANV_TEX VKEY 6 64 32 32 32\r
+SET_CANV_TEX VKEY 7 0 64 32 32\r
+SET_CANV_TEX VKEY 8 32 64 32 32\r
+SET_CANV_TEX VKEY 9 64 64 32 32\r
+SET_CANV_TEX VKEY 10 0 96 32 32\r
+SET_CANV_TEX VKEY 11 64 96 32 32\r
+\r
+RESET_TEX\r
+\r
+;SET_VKEY [id] [keycode] [x] [y]\r
+STACK 2\r
+\r
+;NUM 0\r
+;y:=getHeight-32\r
+PUSH $SCREEN_H\r
+PUSH 32\r
+SUB\r
+;x:=getWidth-64\r
+PUSH $SCREEN_W\r
+PUSH 64\r
+SUB\r
+SET_VKEY 0 48 POP POP\r
+\r
+;NUM 1\r
+PUSH $SCREEN_H\r
+PUSH 96\r
+SUB\r
+PUSH $SCREEN_W\r
+PUSH 32\r
+SUB\r
+SET_VKEY 1 49 POP POP\r
+\r
+;NUM 2\r
+PUSH $SCREEN_H\r
+PUSH 96\r
+SUB\r
+SET_VKEY 2 50 32 POP\r
+\r
+;NUM 3\r
+PUSH $SCREEN_H\r
+PUSH 96\r
+SUB\r
+PUSH $SCREEN_W\r
+PUSH 64\r
+SUB\r
+SET_VKEY 3 51 POP POP\r
+\r
+;NUM 4\r
+PUSH $SCREEN_H\r
+PUSH 64\r
+SUB\r
+SET_VKEY 4 52 0 POP\r
+\r
+;NUM 5\r
+PUSH $SCREEN_H\r
+PUSH 96\r
+SUB\r
+PUSH $SCREEN_W\r
+PUSH 96\r
+SUB\r
+SET_VKEY 5 53 POP POP\r
+\r
+;NUM 6\r
+PUSH $SCREEN_H\r
+PUSH 64\r
+SUB\r
+SET_VKEY 6 54 64 POP\r
+\r
+;NUM 7\r
+PUSH $SCREEN_H\r
+PUSH 32\r
+SUB\r
+PUSH $SCREEN_W\r
+PUSH 32\r
+SUB\r
+SET_VKEY 7 55 POP POP\r
+\r
+;NUM 8\r
+PUSH $SCREEN_H\r
+PUSH 32\r
+SUB\r
+SET_VKEY 8 56 32 POP\r
+\r
+;NUM 9\r
+PUSH $SCREEN_H\r
+PUSH 32\r
+SUB\r
+PUSH $SCREEN_W\r
+PUSH 96\r
+SUB\r
+SET_VKEY 9 57 POP POP\r
+\r
+;NUM *\r
+SET_VKEY 10 42 0 0\r
+\r
+;NUM #\r
+PUSH $SCREEN_W\r
+PUSH 32\r
+SUB\r
+SET_VKEY 11 35 POP 0\r
+\r
+STACK -1\r
+\r
diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc
--- /dev/null
+++ b/src/CAVE.mpsrc
@@ -0,0 +1,3092 @@
+program CAVE;\r
+\r
+uses\r
+ sign,\r
+ jsr75i,\r
+ drop,\r
+ invui,\r
+ vars,\r
+ particles_store,\r
+ randoms,\r
+ memory,\r
+ worldgen,\r
+ canvas,\r
+ items,\r
+ safeload,\r
+ mob,\r
+ console,\r
+ effects,\r
+ particles,\r
+ keyboard,\r
+ maps,\r
+ phy,\r
+ utils,\r
+ func,\r
+ CellUI,\r
+ furnace,\r
+ player,\r
+ items_logic,\r
+ chest,\r
+ inv,\r
+ items_store,\r
+ video;\r
+\r
+const\r
+ version='BETA 9';\r
+ version_map=8;\r
+\r
+var\r
+ keymode,updx,updy:integer;\r
+ seed,nextseed:integer;\r
+ free_ram:real;\r
+\r
+ light:array [0..15] of image;\r
+ bg:array[0..1] of image;\r
+ osad:array [0..1,0..7] of image;\r
+ back:array [0..8] of image;\r
+ gui:array [0..34] of image;\r
+ tue:array [0..9] of image;\r
+ \r
+ sign_im:image;\r
+ sky:image;\r
+ sun:image;\r
+ moon:image;\r
+ moon_phase:integer;\r
+ toolus,toolind:integer;\r
+ osadki_ani:integer;\r
+ sd,sav_fl:string;\r
+ global_light:integer;\r
+ world_typ:integer;\r
+ float:image;\r
+\r
+ msg:array [0..4] of string;\r
+ msg_time:array[0..4] of integer;\r
+ last_sleep_x,last_sleep_y:integer;\r
+\r
+ ifminimap:boolean;\r
+ gt:integer;\r
+\r
+ del,dt,time:integer;\r
+\r
+ deb:boolean;\r
+\r
+procedure newworld;\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ if nextseed=0 then seed:=getrelativetimems; else seed:=nextseed;\r
+ nextseed:=0;\r
+ srand(seed);\r
+ if world_typ=0 then genworld;\r
+ else\r
+ if world_typ=1 then genflat;\r
+ world_typ:=0;\r
+ player.setX(get_spawn_x*16+4);\r
+ player.setY(get_spawn_y*16);\r
+ pl_world:=0;\r
+ end;\r
+\r
+procedure drwrect(x,y,w,h,t:integer);\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to t do\r
+ drawrect(x+i,y+i,w-i*2,h-i*2);\r
+ end;\r
+\r
+procedure proc_fps;\r
+ begin\r
+ dt:=GetRelativeTimeMs - time;\r
+ time:=GetRelativeTimeMs;\r
+ fps:=1000/dt;\r
+ end;\r
+\r
+procedure maxfps;\r
+ begin\r
+ if fps<s_max_fps then if del>0 then del:=del-1;\r
+ if fps>s_max_fps then if del<200 then del:=del+1;\r
+ delay(del);\r
+ end;\r
+\r
+procedure cleartextures;\r
+ var\r
+ no:image;\r
+ ix,iy,iz:integer;\r
+ begin\r
+ bg[0]:=no;\r
+ bg[1]:=no;\r
+ float:=no;\r
+ compas:=no;\r
+ for ix:=0 to 7 do clock[ix]:=no;\r
+\r
+ {for ix:=0 to maxBlockTex do\r
+ begin\r
+ tex[ix]:=no;\r
+ tex8[ix]:=no;\r
+ end;\r
+ for ix:=0 to maxItemTex do\r
+ begin\r
+ item[ix]:=no;\r
+ item8[ix]:=no;\r
+ end;}\r
+ for ix:=0 to 8 do back[ix]:=no;\r
+\r
+ player.freeSkin;\r
+\r
+ for ix:=0 to 34 do\r
+ gui[ix]:=no;\r
+\r
+ for ix:=0 to 9 do tue[ix]:=no;\r
+\r
+ for ix:=0 to 7 do osad[0,ix]:=no;\r
+ for ix:=0 to 7 do osad[1,ix]:=no;\r
+\r
+ for ix:=0 to 15 do light[ix]:=no;\r
+\r
+ for ix:=0 to 7 do\r
+ begin\r
+ pr_1[ix]:=no;\r
+ pr_2[ix]:=no;\r
+ pr_3[ix]:=no;\r
+ pr_4[ix]:=no;\r
+ pr_5[ix]:=no;\r
+ end;\r
+ bubble:=no;\r
+\r
+ for ix:=0 to 15 do\r
+ pr_boom[ix]:=no;\r
+\r
+ mob.freeSkin;\r
+\r
+ sky:=no;\r
+\r
+ sun:=no;\r
+ moon:=no;\r
+\r
+ sign_im:=no;\r
+\r
+ for ix:=0 to CONST_MAX_CURS do\r
+ LoadCurImg(no, ix);\r
+\r
+ //resetVirtualKeyboard(-1);\r
+ end;\r
+\r
+procedure create_msg(s:string);\r
+ var\r
+ i,t:integer;\r
+ begin\r
+ for i:=3 downto 0 do\r
+ begin\r
+ if i=0 then break;\r
+ msg_time[i]:=msg_time[i-1];\r
+ msg[i]:=msg[i-1];\r
+ end;\r
+ msg_time[0]:=getrelativetimems;\r
+ msg[0]:=s;\r
+ end;\r
+\r
+procedure loadtexture(path:string);\r
+ var\r
+ ix,iy,iz:integer;\r
+ im:image;\r
+ begin\r
+ cleartextures;\r
+ im:=ld_tex('background.png',path,'title/');\r
+ for ix:=0 to 1 do\r
+ bg[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0);\r
+ float:=ld_tex('float.png',path,'gui/');\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
+ if load_back_tex then\r
+ begin\r
+ im:=ld_tex('back.png',path,'');\r
+ for ix:=0 to 8 do back[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0);\r
+ end;\r
+\r
+ player.loadSkin('char_ani.png', path);\r
+ mob.loadSkin(path);\r
+\r
+ im:=ld_tex('gui.png',path,'gui/');\r
+ gui[0]:=rotate_image_from_image(im,0,0,16,16,0);\r
+ LoadCurImg(gui[0], CUR_SELECT1);\r
+ gui[1]:=rotate_image_from_image(im,0,16,168,21,0);\r
+ gui[3]:=rotate_image_from_image(im,16,0,16,16,0);\r
+ LoadCurImg(gui[3], CUR_SELECT2);\r
+ gui[6]:=rotate_image_from_image(im,0,56,120,12,0);\r
+ gui[7]:=rotate_image_from_image(im,0,68,120,12,0);\r
+ gui[8]:=rotate_image_from_image(im,0,80,120,12,0);\r
+ gui[13]:=rotate_image_from_image(im,1,93,9,9,0);//hp\r
+ gui[14]:=rotate_image_from_image(im,12,93,9,9,0);//hp\r
+ gui[15]:=rotate_image_from_image(im,23,93,9,9,0);//hp\r
+ gui[17]:=rotate_image_from_image(im,120,56,18,18,0);\r
+\r
+ gui[26]:=rotate_image_from_image(im,89,93,9,9,0);//hunger\r
+ gui[27]:=rotate_image_from_image(im,100,93,9,9,0);//hunger\r
+ gui[28]:=rotate_image_from_image(im,111,93,9,9,0);//hunger\r
+\r
+ gui[29]:=rotate_image_from_image(im,67,93,9,9,0);//air\r
+ gui[30]:=rotate_image_from_image(im,78,93,9,9,0);//air\r
+\r
+ gui[31]:=rotate_image_from_image(im,122,93,9,9,0);//hp hardcore\r
+ gui[32]:=rotate_image_from_image(im,133,93,9,9,0);//hp hardcore\r
+ gui[33]:=rotate_image_from_image(im,144,93,9,9,0);//hp hardcore\r
+\r
+ gui[20]:=rotate_image_from_image(im,121,75,9,13,0);\r
+ gui[21]:=rotate_image_from_image(im,130,75,9,13,0);\r
+ gui[22]:=rotate_image_from_image(im,0,103,120,12,0);\r
+\r
+ if load_minimap_tex then gui[16]:=ld_tex('mapbg.png',path,'gui/');\r
+\r
+ for ix:=0 to 9 do tue[ix]:=rotate_image_from_image(im,16*ix,40,16,16,0);\r
+\r
+ if load_weather_tex then\r
+ begin\r
+ im:=ld_tex('rain.png',path,'terrain/');\r
+ for ix:=0 to 7 do osad[0,ix]:=rotate_image_from_image(im,16*ix,0,16,16,0);\r
+ im:=ld_tex('snow.png',path,'terrain/');\r
+ for ix:=0 to 7 do osad[1,ix]:=rotate_image_from_image(im,16*ix,0,16,16,0);\r
+ end;\r
+\r
+ if load_light_tex then\r
+ begin\r
+ im:=ld_tex('light.png',path,'terrain/');\r
+ for ix:=0 to 15 do light[ix]:=rotate_image_from_image(im,16*ix,0,16,16,0);\r
+ end;\r
+\r
+ if load_particles_tex then\r
+ begin\r
+ im:=ld_tex('particles.png',path,'terrain/');\r
+ for ix:=0 to 7 do\r
+ begin\r
+ pr_1[ix]:=rotate_image_from_image(im,8*ix,0,8,8,0);\r
+ pr_2[ix]:=rotate_image_from_image(im,8*ix,8,8,8,0);\r
+ pr_3[ix]:=rotate_image_from_image(im,8*ix,16,8,8,0);\r
+ pr_4[ix]:=rotate_image_from_image(im,8*ix,24,8,8,0);\r
+ pr_5[ix]:=rotate_image_from_image(im,8*ix,32,8,8,0);\r
+ end;\r
+ bubble:=rotate_image_from_image(im,0,40,8,8,0);\r
+ im:=ld_tex('explosion.png',path,'terrain/');\r
+ for ix:=0 to 15 do\r
+ pr_boom[ix]:=rotate_image_from_image(im,32*ix,0,32,32,0);\r
+ end;\r
+\r
+ im:=ld_tex('partition.png',path,'gui/');\r
+ gui[18]:=rotate_image_from_image(im,0,0,84,42,0);\r
+ gui[19]:=rotate_image_from_image(im,0,42,4,4,0);\r
+\r
+ if load_sky_siz<=0 then\r
+ sky:=ld_tex('sky.png',path,'terrain/');\r
+ else\r
+ sky:=resize_image(ld_tex('sky.png',path,'terrain/'),load_sky_siz,2);\r
+\r
+ if load_sm=1 then\r
+ begin\r
+ sun:=ld_tex('sun.png',path,'terrain/');\r
+ moon:=ld_tex('moon_phase_0.png',path,'terrain/moon_phases/');\r
+ end; else\r
+ if load_sm=2 then\r
+ begin\r
+ sun:=resize_image(ld_tex('sun.png',path,'terrain/'),(getWidth+getHeight)/5,(getWidth+getHeight)/5);\r
+ moon:=resize_image(ld_tex('moon_phase_0.png',path,'terrain/moon_phases/'),(getWidth+getHeight)/5,(getWidth+getHeight)/5);\r
+ end;\r
+\r
+ //load_virt_tex(ld_tex('touch.png',path,'gui/'));\r
+ end;\r
+\r
+procedure cleargame;\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ jmp:=false;\r
+ keymode:=0;\r
+ updx:=0;\r
+ updy:=0;\r
+ toolus:=0;\r
+ toolind:=0;\r
+ osadki_ani:=0;\r
+ global_light:=15;\r
+ pl_world:=0;\r
+\r
+ camx:=0;\r
+ camy:=0;\r
+ curx:=0;\r
+ cury:=0;\r
+\r
+ player.setX(0);\r
+ player.setY(0);\r
+ last_sleep_x:=0;\r
+ last_sleep_y:=0;\r
+\r
+ fly:=false;\r
+ game_time:=0;\r
+ clock_stage:=0;\r
+ hp:=20;\r
+ hunger:=20;\r
+ air:=21;\r
+ moon_phase:=0;\r
+ posi:=0;\r
+ velx:=0;\r
+ vely:=0;\r
+ invslot:=0;\r
+\r
+ osadki:=false;\r
+\r
+ //anim_del2:=0;\r
+\r
+ inv.resetData;\r
+\r
+ chest.resetData;\r
+\r
+ {for ix:=0 to 15 do\r
+ begin\r
+ b_furnace[ix]:=false;\r
+ for iy:=0 to 4 do\r
+ begin\r
+ furnace[ix,iy].item_i:=0;\r
+ furnace[ix,iy].sum_i:=0;\r
+ furnace_gg[ix].f_gor:=15;\r
+ furnace_gg[ix].fire_time:=0;\r
+ furnace_gg[ix].f_got:=0;\r
+ furnace_gg[ix].got_time:=0;\r
+ end;\r
+ end;}\r
+\r
+ drop.resetData;\r
+\r
+ mob.resetData;\r
+\r
+ //gb_up_pa:=0;\r
+ reset_particles(max_particles+1);\r
+\r
+ for ix:=0 to 255 do\r
+ begin\r
+ setBackMap(0, ix);\r
+ setBiomMap(0, ix);\r
+ for iy:=0 to 127 do\r
+ begin\r
+ setmap(0,ix,iy);\r
+ setmapinfo(0,ix,iy);\r
+ setmaplight(0,ix,iy);\r
+ end;\r
+ end;\r
+\r
+ for ix:=0 to 31 do\r
+ begin\r
+ b_sign[ix]:=false;\r
+ t_sign[ix]:='';\r
+ end;\r
+\r
+ for ix:=0 to CONST_MAX_LAYERS do\r
+ ClearLayer(ix);\r
+ end;\r
+\r
+procedure drw_load_line(s:string;percent:integer);\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to getHeight/16 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+ drawfonttext(s,(getWidth/2)-(length(s)*8/2),(getHeight/2)-8);\r
+ setcolor(128,128,128);\r
+ fillrect(getwidth/2-50,getheight/2+6,100,3);\r
+ setcolor(128,255,128);\r
+ fillrect(getwidth/2-50,getheight/2+6,percent,3);\r
+ drawfonttext(integertostring(percent)+'%',getwidth/2-(length(integertostring(percent)+'%')*8)/2,getheight/2+12);\r
+ drawVideo;\r
+ end;\r
+\r
+function getFlatMap(i:integer):integer;\r
+ var\r
+ ix, iy:integer;\r
+ begin\r
+ iy:=i div 256;\r
+ ix:=i-iy*256;\r
+ getFlatMap:=getmap(ix,iy);\r
+ end;\r
+\r
+procedure setFlatMap(n, i:integer);\r
+ var\r
+ ix, iy:integer;\r
+ begin\r
+ iy:=i div 256;\r
+ ix:=i-iy*256;\r
+ setmap(n,ix,iy);\r
+ end;\r
+\r
+function getFlatMapInfo(i:integer):integer;\r
+ var\r
+ ix, iy:integer;\r
+ begin\r
+ iy:=i div 256;\r
+ ix:=i-iy*256;\r
+ getFlatMapInfo:=getmapinfo(ix,iy);\r
+ end;\r
+\r
+procedure setFlatMapInfo(n, i:integer);\r
+ var\r
+ ix, iy:integer;\r
+ begin\r
+ iy:=i div 256;\r
+ ix:=i-iy*256;\r
+ setmapinfo(n,ix,iy);\r
+ end;\r
+\r
+procedure SaveMapRLE;\r
+ var\r
+ i:integer;\r
+ id, s:integer;\r
+ begin\r
+ repeat\r
+ id:=getFlatMap(i);\r
+ for s:=0 to 255 do\r
+ if (id<>getFlatMap(i+s)) or (i+s>32767) then\r
+ break;\r
+\r
+ write_byte(id);\r
+ write_byte(s-1);\r
+\r
+ i:=i+s;\r
+ until i>32767;\r
+ end;\r
+\r
+procedure SaveMapInfoRLE;\r
+ var\r
+ i:integer;\r
+ id, s:integer;\r
+ begin\r
+ repeat\r
+ id:=getFlatMapInfo(i);\r
+ for s:=0 to 255 do\r
+ if (id<>getFlatMapInfo(i+s)) or (i+s>32767) then\r
+ break;\r
+\r
+ write_byte(id);\r
+ write_byte(s-1);\r
+\r
+ i:=i+s;\r
+ until i>32767;\r
+ end;\r
+\r
+procedure LoadMapRLE;\r
+ var\r
+ i:integer;\r
+ id, s, j:integer;\r
+ begin\r
+ repeat\r
+ id:=read_byte;\r
+ s:=read_byte;\r
+ for j:=0 to s do\r
+ setFlatMap(id, i+j);\r
+\r
+ i:=i+s+1;\r
+ until i>32767;\r
+ end;\r
+\r
+procedure LoadMapInfoRLE;\r
+ var\r
+ i:integer;\r
+ id, s, j:integer;\r
+ begin\r
+ repeat\r
+ id:=read_byte;\r
+ s:=read_byte;\r
+ for j:=0 to s do\r
+ setFlatMapInfo(id, i+j);\r
+\r
+ i:=i+s+1;\r
+ until i>32767;\r
+ end;\r
+\r
+procedure saveworld(path:string);\r
+ var\r
+ ix,iy:integer;\r
+ world_name:string;\r
+ begin\r
+ if pl_world=0 then world_name:='world.sav';\r
+ else\r
+ if pl_world=1 then world_name:='nether.sav';\r
+ if file_exists(path)<>1 then if create_folder(path)=1 then debug('Folder created!');\r
+ if file_exists(path+world_name)>0 then delete_file(path+world_name);\r
+ if file_exists(path+world_name)<>1 then file_create(path+world_name);\r
+ if open_file(path+world_name)=1 then\r
+ begin\r
+ writeint(player.getX);\r
+ writeint(player.getX);\r
+ //Matrix\r
+ //Matrix\r
+ SaveMapRLE;\r
+ SaveMapInfoRLE;\r
+ drw_load_line('Background',50);\r
+ //Background and biomes\r
+ for ix:=0 to 255 do\r
+ begin\r
+ write_byte(getBackMap(ix));\r
+ write_byte(getBiomMap(ix));\r
+ end;\r
+ drw_load_line('Chests',55);\r
+ //Chests\r
+ chest.saveData;\r
+ drw_load_line('Furnaces',60);\r
+ //Furnaces\r
+ /* for ix:=0 to 15 do\r
+ begin\r
+ writebool(b_furnace[ix]);\r
+ writeint(furnace_gg[ix].f_gor);\r
+ writeint(furnace_gg[ix].f_got);\r
+ for iy:=0 to 4 do\r
+ begin\r
+ write_byte(furnace[ix,iy].item_i);\r
+ writeint(furnace[ix,iy].sum_i);\r
+ end;\r
+ end;*/\r
+ drw_load_line('Mobs',70);\r
+ //Mobs\r
+ mob.saveData;\r
+ drw_load_line('Drop',80);\r
+ //Drop\r
+ drop.saveData;\r
+ drw_load_line('Particles',85);\r
+ //Particles\r
+ writeint(max_particles);\r
+ write_byte(gb_up_pa);\r
+ for ix:=0 to max_particles do\r
+ begin\r
+ write_byte(get_particle_type(ix));\r
+ write_byte(get_particle_ani(ix));\r
+ writeint(get_particle_x(ix));\r
+ writeint(get_particle_y(ix));\r
+ end;\r
+ drw_load_line('Other',90);\r
+ //Other\r
+ write_byte(updx);\r
+ write_byte(updy);\r
+ writebool(osadki);\r
+ write_byte(osadki_ani);\r
+ write_byte(global_light);\r
+ writebool(fly);\r
+ writeint(game_time);\r
+ write_byte(clock_stage);\r
+ for ix:=0 to 31 do\r
+ begin\r
+ writebool(b_sign[ix]);\r
+ writestr(t_sign[ix]);\r
+ end;\r
+ flush;\r
+ drw_load_line('Ready',100);\r
+ if close_file(path+world_name)=1 then debug('World Saved!');\r
+ end;\r
+ end;\r
+\r
+procedure savegame(path:string);\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ drw_load_line('Basic',0);\r
+ if file_exists(path+'player.dat')=1 then delete_file(path+'player.dat');\r
+ if file_exists(path)<>1 then if create_folder(path)=1 then debug('Folder created!');\r
+ if file_exists(path+'player.dat')<>1 then file_create(path+'player.dat');\r
+ if open_file(path+'player.dat')=1 then\r
+ begin\r
+ //Head\r
+ write_byte(version_map);\r
+ write_byte(gamemode);\r
+ writebool(cheats);\r
+ writeint(seed);\r
+ write_byte(pl_world);\r
+ //Player\r
+ writeint(last_sleep_x);\r
+ writeint(last_sleep_y);\r
+ write_byte(velx);\r
+ write_byte(vely);\r
+ write_byte(invslot);\r
+ write_byte(posi);\r
+ write_byte(hp);\r
+ write_byte(hunger);\r
+ write_byte(moon_phase);\r
+ writebool(jmp);\r
+ inv.saveData;\r
+ if close_file(path+'player.dat')=1 then debug('Saved!');\r
+ drw_load_line('Matrix',10);\r
+ saveworld(path);\r
+ end;\r
+end;\r
+\r
+\r
+function version_err(ver:integer):boolean;\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to getHeight/16 do\r
+ begin\r
+ drawimage(bg[0],ix*16,iy*16);\r
+ end;\r
+ if version_map=ver then version_err:=true; else\r
+ if version_map>ver then\r
+ begin\r
+ drawfonttext('Old save format!',(getWidth/2)-60,(getHeight/2)-4);\r
+ drawVideo;\r
+ delay(3000);\r
+ version_err:=false;\r
+ end; else\r
+ if version_map<ver then\r
+ begin\r
+ drawfonttext('New save format!',(getWidth/2)-60,(getHeight/2)-4);\r
+ drawVideo;\r
+ delay(3000);\r
+ version_err:=false;\r
+ end;\r
+ end;\r
+\r
+\r
+function loadworld(path:string):boolean;\r
+ var\r
+ ix,iy,ver:integer;\r
+ world_name:string;\r
+ begin\r
+ if pl_world=0 then world_name:='world.sav';\r
+ else\r
+ if pl_world=1 then world_name:='nether.sav';\r
+ if file_exists(path)=1 then\r
+ begin\r
+ if file_exists(path+world_name)=1 then\r
+ begin\r
+ if open_file(path+world_name)=1 then\r
+ begin\r
+ player.setX(readint);\r
+ player.setY(readint);\r
+ //Matrix\r
+ LoadMapRLE;\r
+ LoadMapInfoRLE;\r
+ drw_load_line('Background',50);\r
+ //Background and biomes\r
+ for ix:=0 to 255 do\r
+ begin\r
+ setBackMap(read_byte, ix);\r
+ setBiomMap(read_byte, ix);\r
+ end;\r
+ drw_load_line('Chests',55);\r
+ //Chests\r
+ chest.loadData;\r
+ drw_load_line('Furnaces',60);\r
+ //Furnaces\r
+ /* for ix:=0 to 15 do\r
+ begin\r
+ b_furnace[ix]:=readbool;\r
+ furnace_gg[ix].f_gor:=readint;\r
+ furnace_gg[ix].f_got:=readint;\r
+ for iy:=0 to 4 do\r
+ begin\r
+ furnace[ix,iy].item_i:=read_byte;\r
+ furnace[ix,iy].sum_i:=readint;\r
+ end;\r
+ end;*/\r
+ drw_load_line('Mobs',70);\r
+ //Mobs\r
+ mob.loadData;\r
+ drw_load_line('Drop',80);\r
+ //Drop\r
+ drop.loadData;\r
+ drw_load_line('Particles',85);\r
+ //Particles\r
+ max_particles:=readint;\r
+ reset_particles(max_particles+1);\r
+ gb_up_pa:=read_byte;\r
+ for ix:=0 to max_particles do\r
+ begin\r
+ set_particle_type(ix,read_byte);\r
+ set_particle_ani(ix,read_byte);\r
+ set_particle_x(ix,readint);\r
+ set_particle_y(ix,readint);\r
+ end;\r
+ drw_load_line('Other',90);\r
+ //Other\r
+ updx:=read_byte;\r
+ updy:=read_byte;\r
+ osadki:=readbool;\r
+ osadki_ani:=read_byte;\r
+ global_light:=read_byte;\r
+ fly:=readbool;\r
+ game_time:=readint;\r
+ clock_stage:=read_byte;\r
+ for ix:=0 to 31 do\r
+ begin\r
+ b_sign[ix]:=readbool;\r
+ t_sign[ix]:=readstr;\r
+ end;\r
+ drw_load_line('Ready',100);\r
+ ///////////////////////\r
+ if close_file(path+world_name)=1 then begin loadworld:=true; debug('World loaded!'); end;\r
+ end; else begin loadworld:=false; debug('File not opened!'); end;\r
+ end; else begin loadworld:=false; debug('File not exists!'); end;\r
+ end; else begin loadworld:=false; debug('Folder not exists!'); end;\r
+ end;\r
+\r
+function loadgame(path:string):boolean;\r
+var\r
+ ix,iy,ver:integer;\r
+ begin\r
+ drw_load_line('Basic',0);\r
+ if file_exists(path)=1 then\r
+ begin\r
+ if file_exists(path+'player.dat')=1 then\r
+ begin\r
+ if open_file(path+'player.dat')=1 then\r
+ begin\r
+ //Head\r
+ ver:=read_byte;\r
+ if version_err(ver)=false then\r
+ begin\r
+ if close_file(path+'player.dat')=1 then loadgame:=false;\r
+ exit;\r
+ end;\r
+ gamemode:=read_byte;\r
+ cheats:=readbool;\r
+ seed:=readint;\r
+ pl_world:=read_byte;\r
+ //Player;\r
+ last_sleep_x:=readint;\r
+ last_sleep_y:=readint;\r
+ velx:=read_byte;\r
+ vely:=read_byte;\r
+ invslot:=read_byte;\r
+ posi:=read_byte;\r
+ hp:=read_byte;\r
+ hunger:=read_byte;\r
+ moon_phase:=read_byte;\r
+ jmp:=readbool;\r
+ inv.loadData;\r
+ drw_load_line('Matrix',10);\r
+ if close_file(path+'player.dat')=1 then loadgame:=loadworld(path);\r
+ end; else loadgame:=false;\r
+ end; else loadgame:=false;\r
+ end; else loadgame:=false;\r
+end;\r
+\r
+procedure drawdeadlogo;\r
+ var\r
+ dead:image;\r
+ begin\r
+ setcolor(0,0,0);\r
+ fillrect(0,0,getWidth,getHeight);\r
+ dead:=loadimage('/dl');\r
+ drawimage(dead,(getWidth/2)-(getimagewidth(dead)/2),(getHeight/2)-(getimageheight(dead)/2));\r
+ drawfonttext(#119+#119+#119+#46+#100+#101+#97+#100+#115+#111+#102+#116+#119+#97+#114+#101+#46+#114+#117,getWidth/2-80,(getHeight/2)+(getimageheight(dead)/2));\r
+ drawfonttext('Loading...',(getWidth/2)-(40),getHeight-8);\r
+ drawVideo;\r
+ delay(500);\r
+ end;\r
+\r
+procedure newgame;\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to getHeight/16 do\r
+ begin\r
+ drawimage(bg[0],ix*16,iy*16);\r
+ end;\r
+ drawfonttext('Generation World...',(getWidth/2)-(76),(getHeight/2)-4);\r
+ drawVideo;\r
+ delay(1);\r
+ cleargame;\r
+ game_time:=45000;\r
+ newworld;\r
+ //if s_spawn_mob then begin if pl_world=0 then begin megaspawn; end; else begin netherspawn; end; end;\r
+ if gamemode=1 then fly:=true else fly:=false;\r
+ debug('New game!');\r
+ end;\r
+\r
+function gettext(text,text_f:string; max,typ:integer;):string;\r
+ var\r
+ textField_id:integer;\r
+ exitCmd,cli:command;\r
+ begin\r
+ clearForm;\r
+ exitCmd:=createCommand('Ok',CM_OK,1);\r
+ showForm;\r
+ addCommand(exitCmd);\r
+ textField_id:=formAddTextField(text,text_f,max,typ);\r
+ drawVideo;\r
+ delay(100);\r
+ repeat\r
+ cli:=getClickedCommand;\r
+ until cli=exitCmd;\r
+ gettext:=formGetText(textField_id);\r
+ showCanvas;\r
+ end;\r
+\r
+procedure drw_btn(text:string; cur,ccur,h,ty:integer);\r
+ var\r
+ m_x,m_y,i:integer;\r
+ begin\r
+ m_x:=(getWidth/2)-(120/2);\r
+ m_y:=h+((getHeight/2))-((getimageheight(gui[7])-2*cur)/2)+((getimageheight(gui[7])+2)*cur);\r
+ if ty=0 then\r
+ begin\r
+ if ccur=cur then drawimage(gui[22],m_x+i*4,m_y); else drawimage(gui[6],m_x+i*8,m_y);\r
+ end; else\r
+ if ty=1 then\r
+ begin\r
+ if ccur=cur then drawimage(gui[8],m_x+i*8,m_y); else drawimage(gui[7],m_x+i*8,m_y);\r
+ end;\r
+ setclip(0,0,getwidth,getheight);\r
+ m_x:=(getWidth/2)-(length(text)*8/2);\r
+ m_y:=h+((getHeight/2))-((getimageheight(gui[7])-2*cur)/2)+((getimageheight(gui[7])+2)*cur)+((getimageheight(gui[7])-8)/2);\r
+ drawfonttext(text,m_x,m_y);\r
+ end;\r
+\r
+procedure drw_txt(str:string; xx,n,t:integer);\r
+ var\r
+ m_x,m_y:integer;\r
+ begin\r
+ m_x:=(getWidth/2)-(length(str)*8/2);\r
+ m_y:=xx+32+(8*n);\r
+ if t=0 then drawfonttext(str,0,m_y); else\r
+ if t=1 then drawfonttext(str,m_x,m_y);\r
+ end;\r
+\r
+function pos_end(s:string; c:char):integer;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=length(s)-1 downto 0 do\r
+ begin\r
+ if getchar(s,i)=c then\r
+ begin\r
+ pos_end:=i;\r
+ exit;\r
+ end;\r
+ end;\r
+ pos_end:=-1;\r
+ end;\r
+\r
+function getroot(cancel_b:boolean):string;\r
+ var\r
+ m_cur,max_r,pars,ix,iy:integer;\r
+ rr:string;\r
+ im:image;\r
+ roots:array [0..15] of string;\r
+ begin\r
+ im:=rotate_image_from_image(ld_tex('background.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','title/'),16,0,16,16,0);\r
+ rr:=get_roots;\r
+ if cancel_b then roots[0]:='<CANCEL>';\r
+ if cancel_b then max_r:=1; else max_r:=0;\r
+ while pos(rr,'|')<>-1 do\r
+ begin\r
+ pars:=pos(rr,'|');\r
+ roots[max_r]:=copy(rr,0,pars-1);\r
+ rr:=copy(rr,pars+1,length(rr));\r
+ max_r:=max_r+1;\r
+ end;\r
+ max_r:=max_r-1;\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_FM_UP) then begin m_cur:=m_cur-1; if m_cur<0 then m_cur:=max_r; end;\r
+ if clickedKey(KEY_FM_DOWN) then begin m_cur:=m_cur+1; if m_cur>max_r then m_cur:=0; end;\r
+ if clickedKey(KEY_FM_SELECT) then\r
+ begin\r
+ if (m_cur=0) and (cancel_b) then\r
+ begin\r
+ getroot:='';\r
+ exit;\r
+ end;\r
+ else\r
+ begin\r
+ getroot:=roots[m_cur];\r
+ exit;\r
+ end;\r
+ end;\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to getHeight/16 do\r
+ drawimage(im,ix*16,iy*16);\r
+\r
+ setcolor(0,0,0);\r
+ fillrect(0,m_cur*8,getWidth-1,8);\r
+ for ix:=0 to max_r do\r
+ begin\r
+ drawfonttext(roots[ix],0,ix*8);\r
+ end;\r
+ setcolor(255,255,255);\r
+ drawrect(0,m_cur*8,getWidth-1,8);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+function filemanager(cancel_b:boolean):string;\r
+ var\r
+ m_cur,ix,iy,max_r,pars:integer;\r
+ im:image;\r
+ last,rr,root,path:string;\r
+ names:array [0..255] of string;\r
+ begin\r
+ im:=rotate_image_from_image(ld_tex('background.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','title/'),16,0,16,16,0);\r
+ names[0]:='<..>';\r
+ names[1]:='<OK>';\r
+ root:=getroot(cancel_b);\r
+ if root='' then\r
+ begin\r
+ filemanager:='';\r
+ exit;\r
+ end;\r
+ path:=root;\r
+ if cancel_b then names[2]:='<CANCEL>';\r
+ rr:=get_dirs(path);\r
+ if cancel_b then max_r:=3; else max_r:=2;\r
+ while pos(rr,'|')<>-1 do\r
+ begin\r
+ pars:=pos(rr,'|');\r
+ names[max_r]:=copy(rr,0,pars-1);\r
+ rr:=copy(rr,pars+1,length(rr));\r
+ max_r:=max_r+1;\r
+ end;\r
+ max_r:=max_r-1;\r
+\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_FM_UP) then begin m_cur:=m_cur-1; if m_cur<0 then m_cur:=max_r; end;\r
+ if clickedKey(KEY_FM_DOWN) then begin m_cur:=m_cur+1; if m_cur>max_r then m_cur:=0; end;\r
+ if clickedKey(KEY_FM_SELECT) then\r
+ begin\r
+ if m_cur=0 then\r
+ begin\r
+ debug('path:'+path);\r
+ debug('lol:'+pos_end(path,'/'));\r
+ if (path=root) or (path=root+'/') then\r
+ begin\r
+ root:=getroot(cancel_b);\r
+ if root='' then\r
+ begin\r
+ filemanager:='';\r
+ exit;\r
+ end;\r
+ path:=root;\r
+ end;\r
+ else\r
+ begin\r
+ path:=copy(path,0,pos_end(path,'/'));\r
+ if cancel_b then names[2]:='<CANCEL>';\r
+ rr:=get_dirs(path);\r
+ if cancel_b then max_r:=3; else max_r:=2;\r
+ while pos(rr,'|')<>-1 do\r
+ begin\r
+ pars:=pos(rr,'|');\r
+ names[max_r]:=copy(rr,0,pars-1);\r
+ rr:=copy(rr,pars+1,length(rr));\r
+ max_r:=max_r+1;\r
+ end;\r
+ max_r:=max_r-1;\r
+ end;\r
+ end; else\r
+ if m_cur=1 then\r
+ begin\r
+ debug('<OK>');\r
+ filemanager:=path;\r
+ exit;\r
+ end; else\r
+ if (m_cur=2) and (cancel_b) then\r
+ begin\r
+ debug('<CANCEL>');\r
+ filemanager:='';\r
+ exit;\r
+ end; else\r
+ begin\r
+ path:=path+'/'+names[m_cur];\r
+\r
+ if cancel_b then names[2]:='<CANCEL>';\r
+ rr:=get_dirs(path);\r
+ if cancel_b then max_r:=3; else max_r:=2;\r
+ while pos(rr,'|')<>-1 do\r
+ begin\r
+ pars:=pos(rr,'|');\r
+ names[max_r]:=copy(rr,0,pars-1);\r
+ rr:=copy(rr,pars+1,length(rr));\r
+ max_r:=max_r+1;\r
+ end;\r
+ max_r:=max_r-1;\r
+ m_cur:=0;\r
+ debug('path:'+path);\r
+ end;\r
+ end;\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to getHeight/16 do\r
+ drawimage(im,ix*16,iy*16);\r
+\r
+ setcolor(0,0,0);\r
+ fillrect(0,m_cur*8,getWidth-1,8);\r
+ for ix:=0 to max_r do\r
+ begin\r
+ drawfonttext(names[ix],0,ix*8);\r
+ end;\r
+ setcolor(255,255,255);\r
+ drawrect(0,m_cur*8,getWidth-1,8);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+\r
+ until false;\r
+ end;\r
+\r
+procedure setsd(cancel_b:boolean);\r
+ var\r
+ s:string;\r
+ t:integer;\r
+ rs:recordstore;\r
+ begin\r
+ s:=filemanager(cancel_b);\r
+ if s<>'' then\r
+ begin\r
+ sd:=s;\r
+ if file_exists('/'+sd+'/cavecraft')<>1 then\r
+ if create_folder('/'+sd+'/cavecraft')=1 then debug('/cavecraft created!');\r
+\r
+ if file_exists('/'+sd+'/cavecraft/saves')<>1 then\r
+ if create_folder('/'+sd+'/cavecraft/saves')=1 then debug('/saves created!');\r
+\r
+ if file_exists('/'+sd+'/cavecraft/screenshots')<>1 then\r
+ if create_folder('/'+sd+'/cavecraft/screenshots')=1 then debug('/screenshots created!');\r
+\r
+ if file_exists('/'+sd+'/cavecraft/texturepacks')<>1 then\r
+ if create_folder('/'+sd+'/cavecraft/texturepacks')=1 then debug('/texturepacks created!');\r
+\r
+ deleteRecordStore('SD');\r
+ rs:=openRecordStore('SD');\r
+ t:=addRecordStoreEntry(rs,sd);\r
+ closeRecordStore(rs);\r
+ end;\r
+ end;\r
+\r
+procedure start_uu;\r
+ var\r
+ rs:recordstore;\r
+ ss:string;\r
+ begin\r
+ drawdeadlogo;\r
+ //Load SD\r
+ rs:=openRecordStore('SD');\r
+ sd:=readRecordStoreEntry(rs,1);\r
+ closeRecordStore(rs);\r
+ console.exec('autoexec.cfg', 'AUTO', true);\r
+ if sd='' then\r
+ begin\r
+ init_touch;\r
+ if touchscreen then\r
+ load_key_tex:=1;\r
+ else\r
+ load_key_tex:=0;\r
+ //load_virt_tex(loadimage('/gui/touch.png'));\r
+ setsd(false);\r
+ end;\r
+\r
+ if file_exists('/'+sd+'/cavecraft')<>1 then\r
+ if create_folder('/'+sd+'/cavecraft')=1 then debug('/cavecraft created!');\r
+\r
+ if file_exists('/'+sd+'/cavecraft/saves')<>1 then\r
+ if create_folder('/'+sd+'/cavecraft/saves')=1 then debug('/saves created!');\r
+\r
+ if file_exists('/'+sd+'/cavecraft/screenshots')<>1 then\r
+ if create_folder('/'+sd+'/cavecraft/screenshots')=1 then debug('/screenshots created!');\r
+\r
+ if file_exists('/'+sd+'/cavecraft/texturepacks')<>1 then\r
+ if create_folder('/'+sd+'/cavecraft/texturepacks')=1 then debug('/texturepacks created!');\r
+\r
+ rs:=openRecordStore('TX');\r
+ ss:=readRecordStoreEntry(rs,1);\r
+ closeRecordStore(rs);\r
+\r
+ if ss<>'' then\r
+ begin\r
+ tex_pack:=ss;\r
+ LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/');\r
+ loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/');\r
+ end;\r
+ else\r
+ begin\r
+ LoadDrawFont('/');\r
+ loadtexture('/');\r
+ end;\r
+ end;\r
+\r
+function question(text:string):boolean;\r
+ var\r
+ ix,iy,m_cur:integer;\r
+ begin\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_UP) then begin m_cur:=m_cur-1; if m_cur<0 then m_cur:=1; end;\r
+ if clickedKey(KEY_MENU_DOWN) then begin m_cur:=m_cur+1; if m_cur>1 then m_cur:=0; end;\r
+ if clickedKey(KEY_MENU_SELECT) then begin if m_cur=0 then question:=true; else question:=false; exit; end;\r
+ for ix:=0 to getwidth/16 do for iy:=0 to getheight/16 do drawimage(bg[0],ix*16,iy*16);\r
+ drawfonttext(text,getwidth/2-(length(text)*8)/2,getheight/2-16);\r
+ drw_btn('Yes',0,m_cur,0,1);\r
+ drw_btn('No',1,m_cur,0,1);\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+function menu_game_new:boolean;\r
+ var\r
+ m_cur,tmp_gm,ix,iy,lol:integer;\r
+ tmp_cheats,tmp_bon_chest:boolean;\r
+ newgametxt:array[0..4] of string;\r
+ name,tmp:string;\r
+ begin\r
+ m_cur:=-2;\r
+ newgametxt[0]:='Survival';\r
+ newgametxt[1]:='Creative';\r
+ newgametxt[2]:='Hardcore';\r
+ newgametxt[3]:='Normal';\r
+ newgametxt[4]:='Flat';\r
+ name:='New World';\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_UP) then begin m_cur:=m_cur-1; if m_cur<-2 then m_cur:=5; end;\r
+ if clickedKey(KEY_MENU_DOWN) then begin m_cur:=m_cur+1; if m_cur>5 then m_cur:=-2; end;\r
+ if clickedKey(KEY_MENU_SELECT) then\r
+ begin\r
+ if m_cur=-2 then\r
+ begin\r
+ name:=gettext('Name:',name,10,TF_ANY);\r
+ end; else\r
+ if m_cur=-1 then\r
+ begin\r
+ tmp_gm:=tmp_gm+1; if tmp_gm>2 then tmp_gm:=0;\r
+ if tmp_gm=0 then tmp_cheats:=false;\r
+ if tmp_gm=1 then tmp_cheats:=true;\r
+ if tmp_gm=2 then begin tmp_cheats:=false; tmp_bon_chest:=false; end;\r
+ end; else\r
+ if m_cur=0 then\r
+ begin\r
+ nextseed:=stringtointeger(gettext('Seed:',''+nextseed,10,TF_NUMERIC));\r
+ end; else\r
+ if m_cur=1 then\r
+ begin\r
+ world_typ:=world_typ+1;\r
+ if world_typ>1 then world_typ:=0;\r
+ end; else\r
+ if m_cur=2 then\r
+ begin\r
+ if tmp_gm<2 then tmp_cheats:= not tmp_cheats;\r
+ end; else\r
+ if m_cur=3 then\r
+ begin\r
+ if tmp_gm<2 then tmp_bon_chest:= not tmp_bon_chest;\r
+ end; else\r
+ if m_cur=4 then\r
+ begin\r
+ gamemode:=tmp_gm;\r
+ cheats:=tmp_cheats;\r
+ bon_chest:=tmp_bon_chest;\r
+ tmp:=name;\r
+ while file_exists('/'+sd+'/cavecraft/saves/'+name)=1 do\r
+ begin\r
+ lol:=lol+1;\r
+ name:=tmp+' '+lol;\r
+ end;\r
+ sav_fl:=name;\r
+ newgame;\r
+ menu_game_new:=true;\r
+ break;\r
+ end; else\r
+ if m_cur=5 then\r
+ begin\r
+ break;\r
+ end; else\r
+ end;\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to getHeight/16 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+\r
+ drw_btn('Name:'+name,-2,m_cur,0,1);\r
+ drw_btn('Mode:'+newgametxt[tmp_gm],-1,m_cur,0,1);\r
+ drw_btn('Seed:'+nextseed,0,m_cur,0,1);\r
+ drw_btn('Type:'+newgametxt[world_typ+3],1,m_cur,0,1);\r
+ if tmp_gm<2 then\r
+ drw_btn('Cheats:'+tmp_cheats,2,m_cur,0,1);\r
+ else\r
+ drw_btn('Cheats:'+tmp_cheats,2,m_cur,0,0);\r
+ if tmp_gm<2 then\r
+ drw_btn('Chest:'+tmp_bon_chest,3,m_cur,0,1);\r
+ else\r
+ drw_btn('Chest:'+tmp_bon_chest,3,m_cur,0,0);\r
+ drw_btn('Create',4,m_cur,0,1);\r
+ drw_btn('Cancel',5,m_cur,0,1);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+procedure deleteworld(path:string);\r
+ begin\r
+ if file_exists(path+'player.dat')=1 then delete_file(path+'player.dat');\r
+ if file_exists(path+'world.sav')=1 then delete_file(path+'world.sav');\r
+ if file_exists(path+'nether.sav')=1 then delete_file(path+'nether.sav');\r
+ if file_exists(path+'pic.png')=1 then delete_file(path+'pic.png');\r
+ if file_exists(path)=1 then delete_file(path);\r
+ if file_exists(path)=0 then debug('World deleted!');\r
+ end;\r
+\r
+function menu_game:boolean;\r
+ var\r
+ ix,iy,pars,max_r,cur_name,m_cur:integer;\r
+ mm_t_b:boolean;\r
+ im_game:image;\r
+ rr:string;\r
+ names:array[0..255] of string;\r
+ begin\r
+ rr:=get_dirs('/'+sd+'/cavecraft/saves/');\r
+ while pos(rr,'|')<>-1 do\r
+ begin\r
+ pars:=pos(rr,'|');\r
+ names[max_r]:=copy(rr,0,pars-1);\r
+ rr:=copy(rr,pars+1,length(rr));\r
+ if file_exists('/'+sd+'/cavecraft/saves/'+names[max_r]+'/player.dat')=1 then max_r:=max_r+1;\r
+ end;\r
+ max_r:=max_r-1;\r
+ if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png')=1 then\r
+ im_game:=safely_load_image_fs('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png');\r
+ else im_game:=ld_tex('maps.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','');\r
+\r
+ if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/player.dat')=1 then\r
+ mm_t_b:=true; else mm_t_b:=false;\r
+\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_UP) then\r
+ begin\r
+ m_cur:=m_cur-1;\r
+ if m_cur<0 then m_cur:=3;\r
+ end;\r
+ if clickedKey(KEY_MENU_DOWN) then\r
+ begin\r
+ m_cur:=m_cur+1;\r
+ if m_cur>3 then m_cur:=0;\r
+ end;\r
+\r
+ if clickedKey(KEY_MENU_LEFT) then\r
+ begin\r
+ cur_name:=cur_name-1;\r
+ if cur_name<0 then cur_name:=0;\r
+ if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png')=1 then\r
+ im_game:=safely_load_image_fs('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png');\r
+ else im_game:=ld_tex('maps.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','');\r
+\r
+ if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/player.dat')=1 then\r
+ end;\r
+ if clickedKey(KEY_MENU_RIGHT) then\r
+ begin\r
+ cur_name:=cur_name+1;\r
+ if cur_name>max_r then cur_name:=max_r;\r
+ if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png')=1 then\r
+ im_game:=safely_load_image_fs('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png');\r
+ else im_game:=ld_tex('maps.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','');\r
+\r
+ if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/player.dat')=1 then\r
+ end;\r
+ if clickedKey(KEY_MENU_SELECT) then\r
+ begin\r
+ if m_cur=0 then\r
+ begin\r
+ if max_r>-1 then\r
+ if loadgame('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/') then\r
+ begin\r
+ sav_fl:=names[cur_name];\r
+ menu_game:=true;\r
+ break;\r
+ end;\r
+ end; else\r
+ if m_cur=1 then\r
+ begin\r
+ if menu_game_new then begin menu_game:=true; break; end;\r
+ end; else\r
+ if m_cur=2 then\r
+ begin\r
+ debug('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/');\r
+ if max_r>-1 then\r
+ if question('Are you sure?')=true then deleteworld('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/');\r
+ cur_name:=0;\r
+ max_r:=0;\r
+ rr:=get_dirs('/'+sd+'/cavecraft/saves/');\r
+ while pos(rr,'|')<>-1 do\r
+ begin\r
+ pars:=pos(rr,'|');\r
+ names[max_r]:=copy(rr,0,pars-1);\r
+ rr:=copy(rr,pars+1,length(rr));\r
+ max_r:=max_r+1;\r
+ end;\r
+ max_r:=max_r-1;\r
+ if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png')=1 then\r
+ im_game:=safely_load_image_fs('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png');\r
+ else im_game:=ld_tex('maps.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','');\r
+ end; else\r
+ if m_cur=3 then\r
+ begin\r
+ break;\r
+ end;\r
+ end;\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=1 to 7 do\r
+ drawimage(bg[1],ix*16,iy*16);\r
+ for ix:=0 to getWidth/16 do\r
+ drawimage(bg[0],ix*16,0);\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=8 to getHeight/16 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+\r
+ if max_r>-1 then\r
+ begin\r
+ setcolor(0,0,0);\r
+ fillrect(32,24,getWidth-64,96);\r
+ setclip(32,24,getWidth-64,96);\r
+ drawimage(im_game,(getWidth/2)-(32),32);\r
+ drawfonttext(names[cur_name],(getWidth/2)-(length(names[cur_name])*8/2),104);\r
+ setclip(0,0,getWidth,getHeight);\r
+ setcolor(128,128,128);\r
+ drawrect(32,24,getWidth-64,96);\r
+ if cur_name>0 then drawimage(gui[20],0,58);\r
+ if cur_name<max_r then drawimage(gui[21],getWidth-9,58);\r
+ end;\r
+ else\r
+ begin\r
+ setcolor(0,0,0);\r
+ fillrect(32,24,getWidth-64,96);\r
+ setclip(32,24,getWidth-64,96);\r
+ drawfonttext('No saves!',(getWidth/2)-(length('No saves!')*8/2),104);\r
+ setclip(0,0,getWidth,getHeight);\r
+ setcolor(128,128,128);\r
+ drawrect(32,24,getWidth-64,96);\r
+ end;\r
+\r
+ if mm_t_b then drw_btn('Play',0,m_cur,32,1); else drw_btn('Play',0,m_cur,32,0);\r
+ drw_btn('Create new',1,m_cur,32,1);\r
+ if mm_t_b then drw_btn('Delete',2,m_cur,32,1); else drw_btn('Delete',2,m_cur,32,0);\r
+ drw_btn('Back',3,m_cur,32,1);\r
+ if not mm_t_b then cur_name:=cur_name+1;\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+procedure menu_tex;\r
+ var\r
+ ix,iy,pars,max_r,cur_name,m_cur,t:integer;\r
+ im_game:image;\r
+ rr:string;\r
+ names:array[0..255] of string;\r
+ rs:recordstore;\r
+ begin\r
+ rr:=get_dirs('/'+sd+'/cavecraft/texturepacks/');\r
+ names[0]:='Default';\r
+ max_r:=1;\r
+ while pos(rr,'|')<>-1 do\r
+ begin\r
+ pars:=pos(rr,'|');\r
+ names[max_r]:=copy(rr,0,pars-1);\r
+ rr:=copy(rr,pars+1,length(rr));\r
+ max_r:=max_r+1;\r
+ end;\r
+ max_r:=max_r-1;\r
+ im_game:=loadimage('/pack.png');\r
+\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_UP) then\r
+ begin\r
+ m_cur:=m_cur-1;\r
+ if m_cur<0 then m_cur:=1;\r
+ end;\r
+ if clickedKey(KEY_MENU_DOWN) then\r
+ begin\r
+ m_cur:=m_cur+1;\r
+ if m_cur>1 then m_cur:=0;\r
+ end;\r
+\r
+ if clickedKey(KEY_MENU_LEFT) then\r
+ begin\r
+ cur_name:=cur_name-1;\r
+ if cur_name<0 then cur_name:=0;\r
+ im_game:=ld_tex('pack.png','/'+sd+'/cavecraft/texturepacks/'+names[cur_name]+'/','');\r
+ end;\r
+ if clickedKey(KEY_MENU_RIGHT) then\r
+ begin\r
+ cur_name:=cur_name+1;\r
+ if cur_name>max_r then cur_name:=max_r;\r
+ im_game:=ld_tex('pack.png','/'+sd+'/cavecraft/texturepacks/'+names[cur_name]+'/','');\r
+ end;\r
+ if clickedKey(KEY_MENU_SELECT) then\r
+ begin\r
+ if m_cur=0 then begin\r
+ if cur_name>0 then\r
+ begin\r
+ tex_pack:=names[cur_name];\r
+ LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/');\r
+ loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/');\r
+ deleteRecordStore('TX');\r
+ rs:=openRecordStore('TX');\r
+ t:=addRecordStoreEntry(rs,tex_pack);\r
+ closeRecordStore(rs);\r
+ end;\r
+ else\r
+ begin\r
+ tex_pack:='';\r
+ loadtexture('/');\r
+ deleteRecordStore('TX');\r
+ rs:=openRecordStore('TX');\r
+ t:=addRecordStoreEntry(rs,'');\r
+ closeRecordStore(rs);\r
+ end;\r
+ end;\r
+ if m_cur=1 then break;\r
+ break;\r
+ end;\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=1 to 7 do\r
+ drawimage(bg[1],ix*16,iy*16);\r
+ for ix:=0 to getWidth/16 do\r
+ drawimage(bg[0],ix*16,0);\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=8 to getHeight/16 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+\r
+ if max_r>-1 then\r
+ begin\r
+ setcolor(0,0,0);\r
+ fillrect(32,24,getWidth-64,96);\r
+ setclip(32,24,getWidth-64,96);\r
+ drawimage(im_game,(getWidth/2)-(32),32);\r
+ drawfonttext(names[cur_name],(getWidth/2)-(length(names[cur_name])*8/2),104);\r
+ setclip(0,0,getWidth,getHeight);\r
+ setcolor(128,128,128);\r
+ drawrect(32,24,getWidth-64,96);\r
+ if cur_name>0 then drawimage(gui[20],0,58);\r
+ if cur_name<max_r then drawimage(gui[21],getWidth-9,58);\r
+ end;\r
+\r
+ drw_btn('Done',0,m_cur,32,1);\r
+ drw_btn('Back',1,m_cur,32,1);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+procedure menu_sett;\r
+var\r
+ ix,iy,m_cur:integer;\r
+ begin\r
+ m_cur:=-3;\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_UP) then\r
+ begin\r
+ m_cur:=m_cur-1;\r
+ if m_cur<-3 then m_cur:=5;\r
+ end;\r
+ if clickedKey(KEY_MENU_DOWN) then\r
+ begin\r
+ m_cur:=m_cur+1;\r
+ if m_cur>5 then m_cur:=-3;\r
+ end;\r
+ if clickedKey(KEY_MENU_SELECT) then\r
+ begin\r
+ if m_cur=-3 then\r
+ begin\r
+ light_type:=light_type+1;\r
+ if light_type>2 then light_type:=0;\r
+ end; else\r
+ if m_cur=-2 then\r
+ begin\r
+ ifosad:=not ifosad;\r
+ end; else\r
+ if m_cur=-1 then\r
+ begin\r
+ s_particles:=not s_particles;\r
+ end; else\r
+ if m_cur=0 then\r
+ begin\r
+ drawgui:=not drawgui;\r
+ end; else\r
+ if m_cur=1 then\r
+ begin\r
+ if question('Are you sure?')=true then\r
+ begin\r
+ if load_key_tex=0 then\r
+ begin\r
+ load_key_tex:=1;\r
+ init_touch;\r
+ //load_virt_tex(ld_tex('touch.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/'));\r
+ end;\r
+ else\r
+ if load_key_tex=1 then\r
+ begin\r
+ load_key_tex:=0;\r
+ resetVirtualKeyboard(-1);\r
+ end;\r
+ end;\r
+ end;\r
+ if m_cur=2 then\r
+ begin\r
+ s_jpeg_quality:=stringtointeger(gettext('JPEG quality:',''+s_jpeg_quality,3,TF_NUMERIC));\r
+ if s_jpeg_quality>100 then s_jpeg_quality:=100; else\r
+ if s_jpeg_quality<0 then s_jpeg_quality:=0;\r
+ end; else\r
+ if m_cur=3 then\r
+ begin\r
+ setsd(true);\r
+ end; else\r
+ if m_cur=4 then\r
+ begin\r
+ deleteRecordStore('S');\r
+ deleteRecordStore('SD');\r
+ deleteRecordStore('TX');\r
+ halt;\r
+ end; else\r
+ if m_cur=5 then\r
+ begin\r
+ save_settings;\r
+ break;\r
+ end; else\r
+ end;\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to getHeight/16 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+\r
+ drw_btn('Light:'+light_type,-3,m_cur,0,1);\r
+ drw_btn('Weather:'+ifosad,-2,m_cur,0,1);\r
+ drw_btn('Particles:'+s_particles,-1,m_cur,0,1);\r
+ drw_btn('Hide GUI:'+not drawgui,0,m_cur,0,1);\r
+ drw_btn('Touch:'+(load_key_tex>0),1,m_cur,0,1);\r
+ drw_btn('JPEG:'+s_jpeg_quality,2,m_cur,0,1);\r
+ drw_btn('Set Root',3,m_cur,0,1);\r
+ drw_btn('Reset',4,m_cur,0,1);\r
+ drw_btn('Back',5,m_cur,0,1);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+procedure menu_help;\r
+ var\r
+ ix,iy,cur:integer;\r
+ begin\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_SELECT) then break;\r
+ if pressedKey(KEY_MENU_UP) then cur:=cur+1;\r
+ if pressedKey(KEY_MENU_DOWN) then cur:=cur-1;\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=2 to (getHeight/16)-2 do\r
+ drawimage(bg[1],ix*16,iy*16);\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to 1 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=(getHeight/16)-2 to getHeight/16 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+\r
+ setclip(0,32,getWidth,(getHeight/16-4)*16);\r
+\r
+ drw_txt('Controls:',cur,0,1);\r
+ drw_txt('Left - Move left',cur,1,0);\r
+ drw_txt('Right - Move right',cur,2,0);\r
+ drw_txt('Up - Jump',cur,3,0);\r
+ drw_txt('Down - Put a block under you',cur,4,0);\r
+ drw_txt('1 - Inventory',cur,5,0);\r
+ drw_txt('Duble 1 - Craft',cur,6,0);\r
+ drw_txt('3 - Use block',cur,7,0);\r
+ drw_txt('7 - Debug info',cur,8,0);\r
+ drw_txt('Hold 7 - Console',cur,9,0);\r
+ drw_txt('9 - Pause',cur,10,0);\r
+ drw_txt('*, # - Browse inventory',cur,11,0);\r
+ drw_txt('0 - Edit mode',cur,12,0);\r
+\r
+ drw_txt('In inventory/chest:',cur,14,1);\r
+ drw_txt('3 - Enject object',cur,15,0);\r
+ drw_txt('Hold 3 - Enject stack',cur,16,0);\r
+ drw_txt('5 - Move the stack',cur,17,0);\r
+ drw_txt('Hold 5 - Divide stack',cur,18,0);\r
+\r
+ setclip(0,0,getWidth,getHeight);\r
+\r
+ drw_btn('Back',0,0,getHeight-getHeight/2-16-6,1);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+procedure menu_about;\r
+ var\r
+ ix,iy,cur:integer;\r
+ begin\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_SELECT) then break;\r
+ if pressedKey(KEY_MENU_UP) then cur:=cur+1;\r
+ if pressedKey(KEY_MENU_DOWN) then cur:=cur-1;\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=2 to (getHeight/16)-2 do\r
+ drawimage(bg[1],ix*16,iy*16);\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to 1 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=(getHeight/16)-2 to getHeight/16 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+\r
+ setclip(0,32,getWidth,(getHeight/16-4)*16);\r
+\r
+ drw_txt('Developers:',cur,0,1);\r
+ drw_txt(#68+#101+#97+#68+#68+#111+#111+#77+#69+#82+' - Programmer',cur,1,0);//dead\r
+ drw_txt(#102+#114+#101+#100+#45+#98+#111+#121+' - Programmer',cur,2,0);//fred-boy\r
+ drw_txt(#65+#110+#100+#114+#101+#121+#53+#57+' - Programmer',cur,3,0);//andrey59\r
+ drw_txt(#89+#117+#82+#97+#78+#110+#78+#122+#90+#90+' - Artist',cur,4,0);//yura\r
+ drw_txt(#83+#97+#115+#104+#97+#71+' - Artist and idea generator',cur,5,0);//sasha\r
+ drw_txt(#66+#97+#74+#108+#101+#72+#84+#105+#72+' - Artist and tester',cur,6,0);//valentin\r
+ drw_txt(#65+#103+#114+#101+#115+#115+#111+#82+' - Tester',cur,7,0);//agressor\r
+ drw_txt(#118+#111+#108+#121+#97+#95+#110+#97+#115+#116+#97+#110+#101+' - Tester',cur,8,0);//volya\r
+ drw_txt(#97+#98+#97+#100+#111+#110+' - Tester',cur,9,0);//abadon\r
+ drw_txt(#77+#111+#110+#111+#103+#114+#111+#109+' - Tester',cur,10,0);//monogrom\r
+ drw_txt(#75+#97+#108+#116+#101+#114+' - Tester',cur,11,0);//kalter\r
+\r
+ drw_txt('Thanks:',cur,12,1);\r
+ drw_txt('Piligrim and 0vZ - Lib_jsr75i',cur,13,0);\r
+ drw_txt('Piligrim - Lib_effects',cur,14,0);\r
+ drw_txt('Kurdt - Lib_canvas',cur,15,0);\r
+ drw_txt('ViNT - Lib_png and Lib_bmp',cur,16,0);\r
+ drw_txt('aleshka - Lib_jpeg',cur,17,0);\r
+ drw_txt('Roman_V - Lib_safeload',cur,18,0);\r
+\r
+ drw_txt('Site: '+#104+#116+#116+#112+#58+#47+#47+#100+#101+#97+#100+#115+#111+#102+#116+#119+#97+#114+#101+#46+#114+#117,cur,21,0);\r
+ drw_txt(#68+#101+#97+#68+#83+#111+#102+#116+#87+#97+#114+#101+' 2012-'+getyear(getcurrenttime),cur,22,0);\r
+\r
+ drw_txt('Hello! :D',cur,100,1);\r
+\r
+ setclip(0,0,getWidth,getHeight);\r
+\r
+ drw_btn('Back',0,0,getHeight-getHeight/2-16-6,1);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+function sm_siz:integer;\r
+ begin\r
+ sm_siz:=(getWidth+getHeight)/5;\r
+ end;\r
+\r
+function sm_siz4:integer;\r
+ begin\r
+ sm_siz4:=sm_siz/4;\r
+ end;\r
+\r
+procedure draw_menu_back;\r
+ var\r
+ ix, iy:integer;\r
+ begin\r
+ for ix:=0 to getWidth/16 do\r
+ for iy:=0 to getHeight/16 do\r
+ drawimage(bg[0],ix*16,iy*16);\r
+ end;\r
+\r
+procedure menu;\r
+ var\r
+ m_cur,ix,iy,iz:integer;\r
+ key,spl_i:integer;\r
+ splash:string;\r
+ res:resource;\r
+ time:integer;\r
+ cavelogo:image;\r
+ spl_y,spl_del:integer;\r
+ spl_y_b:boolean;\r
+ begin\r
+ cavelogo:=ld_tex('cavelogo.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','title/');\r
+ splash:='#ERROR';\r
+ spl_y:=getimageheight(cavelogo);\r
+ spl_y_b:=true;\r
+ spl_del:=getrelativetimems;\r
+ res:=openResource('/title/splashes.txt');\r
+ if ResourceAvailable(res) then\r
+ begin\r
+ spl_i:=stringtointeger(readline(res));\r
+ iy:=random(spl_i-1)+1;\r
+ debug('SPLASH #'+iy);\r
+ for ix:=1 to iy do\r
+ splash:=readline(res);\r
+ closeresource(res);\r
+ end;\r
+ time:=getcurrenttime;\r
+ if (getmonth(time)=5) and (getday(time)=7) then splash:='Happy birthday, DeaDDooMER!';\r
+ if ((getmonth(time)=0) and (getday(time)<3)) or ((getmonth(time)=11) and (getday(time)>29)) then splash:='Happy New Year!';\r
+ repeat\r
+ proc_fps;\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_UP) then\r
+ begin\r
+ m_cur:=m_cur-1;\r
+ if m_cur<0 then m_cur:=5;\r
+ end;\r
+ if clickedKey(KEY_MENU_DOWN) then\r
+ begin\r
+ m_cur:=m_cur+1;\r
+ if m_cur>5 then m_cur:=0;\r
+ end;\r
+ if clickedKey(KEY_MENU_SELECT) then\r
+ begin\r
+ if m_cur=0 then begin if menu_game then break; end;\r
+ else\r
+ if m_cur=1 then menu_tex;\r
+ else\r
+ if m_cur=2 then menu_sett;\r
+ else\r
+ if m_cur=3 then menu_help;\r
+ else\r
+ if m_cur=4 then menu_about;\r
+ else\r
+ if m_cur=5 then begin save_settings; halt; end;\r
+ end;\r
+\r
+ draw_menu_back;\r
+\r
+ drawimage(cavelogo,(getWidth/2)-(getimagewidth(cavelogo)/2),0);\r
+ setcolor(255,255,0);\r
+\r
+ DrawFontTextSpec(splash, (getWidth/2)-(length(splash)*FONT_SYM_SIZE/2), spl_y, FONT_YELLOW_COLOR, true);\r
+\r
+ if spl_y_b then begin if getrelativetimems-spl_del>64 then begin spl_y:=spl_y+1; spl_del:=getrelativetimems; end; if spl_y>getimageheight(cavelogo)+2 then spl_y_b:=false; end;\r
+ if not spl_y_b then begin if getrelativetimems-spl_del>64 then begin spl_y:=spl_y-1; spl_del:=getrelativetimems; end; if spl_y<getimageheight(cavelogo)+1 then spl_y_b:=true; end;\r
+ drawfonttext(version,0,getHeight-8);\r
+\r
+ drw_btn('Singleplayer',0,m_cur,0,1);\r
+ drw_btn('Texture Packs',1,m_cur,0,1);\r
+ drw_btn('Options',2,m_cur,0,1);\r
+ drw_btn('Help',3,m_cur,0,1);\r
+ drw_btn('About',4,m_cur,0,1);\r
+ drw_btn('Quit Game',5,m_cur,0,1);\r
+\r
+ drawVideo;\r
+ maxfps;\r
+ until false;\r
+ end;\r
+\r
+function setBlock(invcur, x, y:integer):boolean;\r
+ var\r
+ item, sum, block, sblock:integer;\r
+ begin\r
+ item:=inv.getItem(invcur);\r
+ sum:=inv.getSum(invcur);\r
+ block:=getMap(x, y);\r
+ sblock:=getItemInfo(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 (coll_xy(x, y)=false) or (getBlockColl(item)=0) then\r
+ begin\r
+ if set_block_code(sblock, x, y)=false then\r
+ begin\r
+\r
+ setmap(sblock, x, y);\r
+ if gamemode<>1 then\r
+ begin\r
+ inv.setSum(inv.getSum(invcur)-1, invcur);\r
+ inv.fixNull(invcur);\r
+ end;\r
+\r
+ setBlock:=true;\r
+ end;\r
+ end;\r
+ end;\r
+\r
+procedure fishing;\r
+ var\r
+ x, y:integer;\r
+ begin\r
+ x:=player.getX;\r
+ y:=player.getY;\r
+ if (getrelativetimems-fish_time>5000) and (getmap(fx,fy)=50) then\r
+ begin\r
+ if (random(3)=2) and (getmap(fx,fy)=50) then\r
+ begin\r
+ drop.create(210,1,x,y);\r
+ fish:=false;\r
+ end;\r
+ inv.setSum(inv.getSum(invslot)-1, invslot);\r
+ inv.fixNull(invslot);\r
+ fish:=false;\r
+ end; else\r
+ if (getrelativetimems-fish_time<5000) and (getmap(fx,fy)=50) and (fish=true) then\r
+ begin\r
+ if getmap(fx,fy-1)=50 then fy:=fy-1;\r
+ end;\r
+ end;\r
+\r
+procedure drawminimap;\r
+ var\r
+ ix,iy,tmp_gx,tmp_gy,minx,miny,maxx,maxy,loc_camx,loc_camy,x,y:integer;\r
+ begin\r
+ x:=player.getX;\r
+ y:=player.getY;\r
+ if load_minimap_tex then\r
+ begin\r
+ tmp_gx:=(getWidth/2)-(getimagewidth(gui[16])/2);\r
+ tmp_gy:=(getHeight/2)-(getimageheight(gui[16])/2);\r
+ end;\r
+ else\r
+ begin\r
+ tmp_gx:=(getWidth/2)-(64/2);\r
+ tmp_gy:=(getHeight/2)-(64/2);\r
+ end;\r
+\r
+ loc_camx:=(x+4)-(864/2);\r
+ loc_camy:=(y+4)-(864/2);\r
+ if loc_camx<0 then loc_camx:=0;\r
+ if loc_camx>4096-864 then loc_camx:=4096-864;\r
+ if loc_camy<0 then loc_camy:=0;\r
+ if loc_camy>2048-864 then loc_camy:=2048-864;\r
+ minx:=loc_camx/16;\r
+ miny:=loc_camy/16;\r
+ maxx:=(loc_camx+864)/16;\r
+ maxy:=(loc_camy+864)/16;\r
+ if minx<0 then minx:=0;\r
+ if miny<0 then miny:=0;\r
+ if maxx>255 then maxx:=255;\r
+ if maxy>127 then maxy:=127;\r
+\r
+ if load_minimap_tex then\r
+ drawimage(gui[16],tmp_gx,tmp_gy);\r
+ else\r
+ begin\r
+ setcolor(214,190,150);\r
+ fillrect(tmp_gx,tmp_gy,64,64);\r
+ end;\r
+\r
+ for ix:=minx to maxx do\r
+ for iy:=miny to maxy do\r
+ begin\r
+ if (getmap(ix,iy)=1) or (getmap(ix,iy)=2) or (getmap(ix,iy)=74) then setcolor(121,85,58); else\r
+ if (getmap(ix,iy)=4) or (getmap(ix,iy)=9) or (getmap(ix,iy)=11) or (getmap(ix,iy)=28) or (getmap(ix,iy)=29) or ((getmap(ix,iy)>=77) and (getmap(ix,iy)<=86)) or ((getmap(ix,iy)>=88) and (getmap(ix,iy)<=101)) then setcolor(188,152,98); else\r
+ if (getmap(ix,iy)=50) or (getmap(ix,iy)=62) then setcolor(38,92,255); else\r
+ if getmap(ix,iy)=51 then setcolor(255,0,0); else\r
+ if (getmap(ix,iy)=61) or (getmap(ix,iy)=32) then setcolor(255,255,255); else\r
+ setcolor(127,127,127);\r
+\r
+ if (getmap(ix,iy)<>0) then plot(tmp_gx+4+ix-minx,tmp_gy+4+iy-miny);\r
+ end;\r
+ setcolor(0,0,255);\r
+ end;\r
+\r
+procedure draw_sign;\r
+ var\r
+ tmp:string;\r
+ str:array[0..3] of string;\r
+ i,j,tmp_gx,tmp_gy:integer;\r
+ begin\r
+ if load_gui_tex then\r
+ begin\r
+ tmp_gx:=(getWidth/2)-(getimagewidth(sign_im)/2);\r
+ tmp_gy:=(getHeight/2)-(getimageheight(sign_im)/2);\r
+ end;\r
+ else\r
+ begin\r
+ tmp_gx:=(getWidth/2)-(120/2);\r
+ tmp_gy:=(getHeight/2)-(60/2);\r
+ end;\r
+\r
+ tmp:=t_sign[getmapinfo(curx,cury)];\r
+ while pos(tmp,#13)<>-1 do\r
+ begin\r
+ i:=pos(tmp,#13);\r
+ str[j]:=copy(tmp,0,i);\r
+ tmp:=copy(tmp,i+1,length(tmp));\r
+ j:=j+1;\r
+ end;\r
+\r
+ if load_gui_tex then\r
+ drawimage(sign_im,tmp_gx,tmp_gy);\r
+ else\r
+ begin\r
+ setcolor(159,132,77);\r
+ fillrect(tmp_gx,tmp_gy,120,60);\r
+ end;\r
+\r
+ drawfonttext(str[0],tmp_gx+(120/2)-(length(str[0])*8/2),tmp_gy+(60/4/2)+4);\r
+ drawfonttext(str[1],tmp_gx+(120/2)-(length(str[1])*8/2),tmp_gy+(60/4/2)+8+4);\r
+ drawfonttext(str[2],tmp_gx+(120/2)-(length(str[2])*8/2),tmp_gy+(60/4/2)+16+4);\r
+ drawfonttext(str[3],tmp_gx+(120/2)-(length(str[3])*8/2),tmp_gy+(60/4/2)+24+4);\r
+ end;\r
+\r
+procedure draw_back(ix,iy:integer);\r
+ begin\r
+ if getBiomMap(ix)=0 then\r
+ begin\r
+ if (getBackMap(ix)=iy) then drawimage(back[0],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+1=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+2=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+3=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)<iy) then drawimage(back[2],(ix*16)-camx,(iy*16)-camy);\r
+ end; else\r
+ if getBiomMap(ix)=1 then\r
+ begin\r
+ if (getBackMap(ix)=iy) then drawimage(back[4],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+1=iy) then drawimage(back[4],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+2=iy) then drawimage(back[6],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+3=iy) then drawimage(back[6],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)<iy) then drawimage(back[2],(ix*16)-camx,(iy*16)-camy);\r
+ end; else\r
+ if getBiomMap(ix)=2 then\r
+ begin\r
+ if (getBackMap(ix)=iy) then drawimage(back[5],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+1=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+2=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+3=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)<iy) then drawimage(back[2],(ix*16)-camx,(iy*16)-camy);\r
+ end; else\r
+ if getBiomMap(ix)=3 then\r
+ begin\r
+ if (getBackMap(ix)=iy) then drawimage(back[7],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+1=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+2=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)+3=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else\r
+ if (getBackMap(ix)<iy) then drawimage(back[2],(ix*16)-camx,(iy*16)-camy);\r
+ end; else\r
+ if getBiomMap(ix)=4 then\r
+ begin\r
+ drawimage(back[8],(ix*16)-camx,(iy*16)-camy);\r
+ end;\r
+ end;\r
+\r
+procedure draw;\r
+ var\r
+ ix,iy,iz,minx,miny,maxx,maxy,tmp_ax,tim,smy,pa_xo, x, y:integer;\r
+ begin\r
+ x:=player.getX;\r
+ y:=player.getY;\r
+ {===================[sky]===================}\r
+ tim:=10000*getimagewidth(sky)/600000*game_time/10000;\r
+ setcolor(effects.get(sky,tim,0,1),effects.get(sky,tim,0,2),effects.get(sky,tim,0,3));\r
+ fillrect(0,0,getWidth,getHeight);\r
+ srand(seed);\r
+ if drw_stars then\r
+ begin\r
+ setcolor(effects.get(sky,tim,2,1),effects.get(sky,tim,2,2),effects.get(sky,tim,2,3));\r
+ smy:=10000*getWidth*2/600000*game_time/10000;\r
+ for iz:=1 to getWidth do\r
+ begin\r
+ ix:=rnd(getWidth*2)-getWidth+smy;\r
+ if ix>getWidth then ix:=ix-getWidth*2;\r
+ iy:=rnd(getHeight);\r
+ if (ix>-1) and (ix<getWidth) then plot(ix,iy);\r
+ end;\r
+ end;\r
+\r
+ if drw_sm then\r
+ begin\r
+ if load_sm>0 then\r
+ begin\r
+ smy:=10000*(getWidth+getimagewidth(sun))/300000*game_time/10000;\r
+ drawimage(sun,smy-getimagewidth(sun),getHeight/2-getimageheight(sun)/2);\r
+ end;\r
+ else\r
+ begin\r
+ setcolor(255,213,74);\r
+ smy:=10000*(getWidth+sm_siz)/300000*game_time/10000;\r
+ fillrect(smy-sm_siz+sm_siz4,getHeight/2-sm_siz/2+sm_siz4,sm_siz-sm_siz4,sm_siz-sm_siz4);\r
+ end;\r
+\r
+ if load_sm>0 then\r
+ begin\r
+ smy:=10000*(getWidth+getimagewidth(moon))/300000*(game_time-300000)/10000;\r
+ drawimage(moon,smy-getimagewidth(moon),getHeight/2-getimageheight(moon)/2);\r
+ end;\r
+ else\r
+ begin\r
+ setcolor(175,184,204);\r
+ smy:=10000*(getWidth+sm_siz)/300000*(game_time-300000)/10000;\r
+ fillrect(smy-sm_siz+sm_siz4,getHeight/2-sm_siz/2+sm_siz4,sm_siz-sm_siz4,sm_siz-sm_siz4);\r
+ end;\r
+ end;\r
+ {===================[camera]===================}\r
+ camx:=(x+4)-(getWidth/2);\r
+ camy:=(y+4)-(getHeight/2);\r
+ if camx<0 then camx:=0;\r
+ if camx>4096-getWidth then camx:=4096-getWidth;\r
+ if camy>2048-getHeight then camy:=2048-getHeight;\r
+ {===================[max_draw]===================}\r
+ minx:=camx/16;\r
+ miny:=camy/16;\r
+ maxx:=(camx+getWidth)/16;\r
+ maxy:=(camy+getHeight)/16;\r
+ if minx<0 then minx:=0;\r
+ if miny<0 then miny:=0;\r
+ if maxx>255 then maxx:=255;\r
+ if maxy>127 then maxy:=127;\r
+ {===================[draw_back]===================}\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
+ end;\r
+ {===================[drop]===================}\r
+ drop.draw(camx, camy);\r
+ {===================[particles]===================}\r
+ if s_particles then draw_particle;\r
+ {===================[player]===================}\r
+ if hp>0 then\r
+ begin\r
+ player.draw(camx, camy);\r
+ end;\r
+\r
+ {===================[mobs]===================}\r
+ mob.draw(camx, camy);\r
+ {===================[draw_blocks]===================}\r
+ for ix:=minx to maxx do\r
+ for iy:=miny to maxy do\r
+ begin\r
+ if getBlockFore(getmap(ix,iy))=true then\r
+ draw_block(ix,iy);\r
+\r
+ setcolor(0,0,0);\r
+ if (light_type=1) then begin if getmaplight(ix,iy)=0 then fillrect((ix*16)-camx,(iy*16)-camy,16,16); end;\r
+ else\r
+ if light_type=2 then begin if getmaplight(ix,iy)<15 then begin if (ix*16-camx<getWidth) and (ix*16-camx>0-16) and (iy*16-camy<getHeight) and (iy*16-camy>0-16) then drawimage(light[getmaplight(ix,iy)],(ix*16)-camx,(iy*16)-camy); end; end;\r
+ end;\r
+ if (toolus>0) and (toolind<10) and (getmap(curx,cury)>0) then begin if toolind>9 then toolind:=9; drawimage(tue[toolind],curx*16-camx,cury*16-camy); end;\r
+ {===================[gui]===================}\r
+ if drawgui then\r
+ begin\r
+ tmp_ax:=(getWidth/2)-(getImageWidth(gui[1])/2);\r
+\r
+ if keymode=1 then\r
+ drawimage(gui[0],curx*16-camx,cury*16-camy);\r
+\r
+ DrawWindows;\r
+ /*if keymode=2 then\r
+ if gamemode<>1 then\r
+ DrawPlayerInventory;\r
+ else\r
+ drawinv_c; else\r
+ if keymode=3 then drawcraft; else\r
+ if keymode=4 then drawchest; else\r
+ if keymode=5 then draw_sign; else\r
+ if keymode=6 then drawfurnace; else\r
+ if ifminimap then drawminimap;*/\r
+\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
+ end;\r
+ drawimage(gui[17],(invslot*16)+tmp_ax+invslot*2+2,0);\r
+\r
+ if gamemode<>1 then\r
+ begin\r
+ if gamemode=0 then\r
+ begin\r
+ for ix:=0 to (hp div 2)-1 do drawimage(gui[13],ix*9,getHeight-9);\r
+ if (hp mod 2)<>0 then begin drawimage(gui[14],ix*9,getHeight-9); ix:=ix+1 end;\r
+ for ix:=ix to 9 do drawimage(gui[15],ix*9,getHeight-9);\r
+ end; else\r
+ if gamemode=2 then\r
+ begin\r
+ for ix:=0 to (hp div 2)-1 do drawimage(gui[31],ix*9,getHeight-9);\r
+ if (hp mod 2)<>0 then begin drawimage(gui[32],ix*9,getHeight-9); ix:=ix+1 end;\r
+ for ix:=ix to 9 do drawimage(gui[33],ix*9,getHeight-9);\r
+ end;\r
+\r
+ for ix:=0 to (hunger div 2)-1 do drawimage(gui[26],ix*9,getHeight-18);\r
+ if (hunger mod 2)<>0 then begin drawimage(gui[27],ix*9,getHeight-18); ix:=ix+1 end;\r
+ for ix:=ix to 9 do drawimage(gui[28],ix*9,getHeight-18);\r
+\r
+ if getmap((x+4)/16,y/16)=50 then\r
+ begin\r
+ for ix:=0 to (air div 2)-1 do drawimage(gui[29],ix*9,getHeight-27);\r
+ if (air mod 2)<>0 then begin drawimage(gui[30],ix*9,getHeight-27); ix:=ix+1 end;\r
+ end;\r
+ end;\r
+\r
+ for ix:=0 to 3 do\r
+ begin\r
+ drawfonttext(msg[ix],0,getHeight-20-ix*9);\r
+ if getrelativetimems-msg_time[ix]>5000 then msg[ix]:='';\r
+ end;\r
+ end;\r
+ end;\r
+\r
+procedure load_moon(path:string;phase:integer);\r
+ var\r
+ no:image;\r
+ begin\r
+ moon:=no;\r
+ if load_sm=1 then\r
+ begin\r
+ moon:=ld_tex('moon_phase_'+phase+'.png',path,'terrain/moon_phases/');\r
+ end; else\r
+ if load_sm=2 then\r
+ begin\r
+ moon:=resize_image(ld_tex('moon_phase_'+phase+'.png',path,'terrain/moon_phases/'),(getWidth+getHeight)/5,(getWidth+getHeight)/5);\r
+ end;\r
+ end;\r
+\r
+procedure sleep;\r
+ var\r
+ i,ix,iy:integer;\r
+ begin\r
+ if game_time>300000 then\r
+ begin\r
+ if load_light_tex then\r
+ begin\r
+ keymode:=0;\r
+ i:=15;\r
+ while i>0 do\r
+ begin\r
+ for iy:=0 to getheight/16 do\r
+ for ix:=0 to getwidth/16 do\r
+ drawimage(light[i],ix*16,iy*16);\r
+ i:=i-1;\r
+ drawVideo;\r
+ delay(100);\r
+ end;\r
+ moon_phase:=moon_phase+1;\r
+ if moon_phase>7 then moon_phase:=0;\r
+ load_moon('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',moon_phase);\r
+ game_time:=50000;\r
+ last_sleep_x:=curx;\r
+ last_sleep_y:=cury-1;\r
+ i:=1;\r
+ while i<15 do\r
+ begin\r
+ draw;\r
+ for iy:=0 to getheight/16 do\r
+ for ix:=0 to getwidth/16 do\r
+ drawimage(light[i],ix*16,iy*16);\r
+ i:=i+1;\r
+ drawVideo;\r
+ delay(100);\r
+ end;\r
+ end;\r
+ else\r
+ begin\r
+ keymode:=0;\r
+ i:=0;\r
+ while i<=getheight do\r
+ begin\r
+ setcolor(0,0,0);\r
+ fillrect(0,0,getwidth,i);\r
+ i:=i+5;\r
+ drawVideo;\r
+ delay(50);\r
+ end;\r
+ moon_phase:=moon_phase+1;\r
+ if moon_phase>7 then moon_phase:=0;\r
+ load_moon('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',moon_phase);\r
+ game_time:=50000;\r
+ last_sleep_x:=curx;\r
+ last_sleep_y:=cury-1;\r
+ i:=0;\r
+ while i<=getheight do\r
+ begin\r
+ draw;\r
+ setcolor(0,0,0);\r
+ fillrect(0,i,getwidth,getheight);\r
+ i:=i+5;\r
+ drawVideo;\r
+ delay(50);\r
+ end;\r
+ end;\r
+ end; else create_msg('You can sleep only at night');\r
+ end;\r
+\r
+procedure resetToolProgerss;\r
+ begin\r
+ toolus:=0;\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
+\r
+ if (toolus>0) and (toolus<=getBlockHP(block)) then\r
+ toolind:=((toolus*100) div getBlockHP(block)) div 10;\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
+\r
+ if getItemType(item)=1 then\r
+ damg:=getToolDamg(item);\r
+ else\r
+ damg:=1;\r
+\r
+ if posi=0 then\r
+ i:=mob.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3);\r
+ else\r
+ i:=mob.findAndHit(damg, x+(w/2), y, TILE_SIZE+(w/2), h, 2, -3);\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
+\r
+procedure rt_usetools;\r
+ var\r
+ x, y:integer;\r
+ begin\r
+ x:=player.getX;\r
+ y:=player.getY;\r
+\r
+ if posi=0 then curx:=(x div 16)-1; else curx:=(x div 16)+1;\r
+ cury:=y div 16;\r
+ if getmap(curx,cury)=0 then cury:=cury+1;\r
+\r
+ if curx<0 then curx:=0;\r
+ if curx>255 then curx:=255;\r
+ if cury<0 then cury:=0;\r
+ if cury>127 then cury:=127;\r
+\r
+ usetools(invslot, curx, cury);\r
+ end;\r
+\r
+procedure rt_usemob;\r
+ var\r
+ x, y:integer;\r
+ begin\r
+ x:=player.getX;\r
+ y:=player.getY;\r
+\r
+ if posi=0 then curx:=(x div 16)-1; else curx:=(x div 16)+1;\r
+ cury:=y div 16;\r
+ if getmap(curx,cury)=0 then cury:=cury+1;\r
+\r
+ if curx<0 then curx:=0;\r
+ if curx>255 then curx:=255;\r
+ if cury<0 then cury:=0;\r
+ if cury>127 then cury:=127;\r
+\r
+ //usemob(curx,cury);\r
+ end;\r
+\r
+procedure actionUse(invcur, x, y:integer);\r
+ begin\r
+ if setBlock(invcur, x, y)=false then\r
+ if useBlock(invcur, x, y) then\r
+ if useItem(invcur, x, y) then\r
+ end;\r
+\r
+procedure rt_useblock;\r
+ var\r
+ x, y:integer;\r
+ begin\r
+ x:=player.getX;\r
+ y:=player.getY;\r
+\r
+ if posi=0 then curx:=(x div 16)-1; else curx:=(x div 16)+1;\r
+ cury:=y div 16;\r
+ if getmap(curx,cury)=0 then cury:=cury+1;\r
+\r
+ if curx<0 then curx:=0;\r
+ if curx>255 then curx:=255;\r
+ if cury<0 then cury:=0;\r
+ if cury>127 then cury:=127;\r
+\r
+ actionUse(invslot, curx, cury);\r
+ end;\r
+\r
+procedure go_to_nether;\r
+ var\r
+ ix:integer;\r
+ begin\r
+ portal_time:=getrelativetimems;\r
+ savegame('/'+sd+'/cavecraft/saves/'+sav_fl+'/');\r
+ pl_world:=1;\r
+ drw_load_line('Matrix',10);\r
+ if loadworld('/'+sd+'/cavecraft/saves/'+sav_fl+'/')=true then\r
+ begin\r
+ player.setX(get_spawn_x*16+4);\r
+ player.setY((get_up(get_spawn_x)-1)*16);\r
+ end;\r
+ else\r
+ begin\r
+ {for ix:=0 to 31 do\r
+ begin\r
+ mob[ix].m_type:=0;\r
+ mob[ix].m_x:=0;\r
+ mob[ix].m_y:=0;\r
+ mob[ix].m_posi:=0;\r
+ mob[ix].m_velx:=0;\r
+ mob[ix].m_vely:=0;\r
+ mob[ix].m_ani:=0;\r
+ mob[ix].m_min_vely:=0;\r
+ mob[ix].m_hp:=0;\r
+ mob[ix].m_del:=0;\r
+ mob[ix].m_fall:=false;\r
+ mob[ix].m_jmp:=false;\r
+ mob[ix].m_velani:=false;\r
+ end;}\r
+ \r
+ drop.resetData;\r
+ gennether;\r
+ //netherspawn;\r
+ end;\r
+ end;\r
+\r
+procedure go_to_world;\r
+ begin\r
+ portal_time:=getrelativetimems;\r
+ savegame('/'+sd+'/cavecraft/saves/'+sav_fl+'/');\r
+ pl_world:=0;\r
+ drw_load_line('Matrix',10);\r
+ if loadworld('/'+sd+'/cavecraft/saves/'+sav_fl+'/')=true then\r
+ begin\r
+ pl_world:=0;\r
+ end;\r
+ else\r
+ begin\r
+ debug('ERROR!!!');\r
+ pl_world:=0;\r
+ genworld;\r
+ //megaspawn;\r
+ end;\r
+ end;\r
+\r
+procedure plr_is_dead_hardcore;\r
+ begin\r
+ keymode:=0;\r
+ toolus:=0;\r
+ toolind:=0;\r
+\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_SELECT) then\r
+ begin\r
+ deleteworld('/'+sd+'/cavecraft/saves/'+sav_fl+'/');\r
+ menu;\r
+ exit;\r
+ end;\r
+ draw;\r
+ drawfonttext('You died!',getwidth/2-32,getheight/2-16);\r
+\r
+ drw_btn('Delete world',0,0,0,1);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+\r
+ end;\r
+\r
+procedure plr_is_dead;\r
+ var\r
+ m_cur:integer;\r
+ x, y:integer;\r
+ begin\r
+ x:=player.getX;\r
+ y:=player.getY;\r
+ keymode:=0;\r
+ toolus:=0;\r
+ toolind:=0;\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_UP) then\r
+ begin\r
+ m_cur:=m_cur-1;\r
+ if m_cur<0 then m_cur:=1;\r
+ end;\r
+ if clickedKey(KEY_MENU_DOWN) then\r
+ begin\r
+ m_cur:=m_cur+1;\r
+ if m_cur>1 then m_cur:=0;\r
+ end;\r
+ if clickedKey(KEY_MENU_SELECT) then\r
+ begin\r
+ if m_cur=0 then\r
+ begin\r
+ if pl_world=0 then\r
+ begin\r
+ if last_sleep_x=0 then\r
+ begin\r
+ x:=get_spawn_x*16+4;\r
+ y:=get_spawn_y*16;\r
+ end; else\r
+ begin\r
+ x:=last_sleep_x*16+4;\r
+ y:=last_sleep_y*16;\r
+ end;\r
+ end; else\r
+ if pl_world=1 then\r
+ begin\r
+ go_to_world;\r
+ if last_sleep_x=0 then\r
+ begin\r
+ x:=get_spawn_x*16+4;\r
+ y:=get_spawn_y*16;\r
+ end; else\r
+ begin\r
+ x:=last_sleep_x*16+4;\r
+ y:=last_sleep_y*16;\r
+ end;\r
+ end;\r
+ posi:=0;\r
+ curx:=0;\r
+ cury:=0;\r
+ vely:=0;\r
+ jmp:=false;\r
+ hp:=20;\r
+ hunger:=20;\r
+ exit;\r
+ end;\r
+ else\r
+ if m_cur=1 then begin menu; exit; end;\r
+ end;\r
+\r
+ draw;\r
+\r
+ drawfonttext('You died!',getwidth/2-32,getheight/2-16);\r
+\r
+ drw_btn('Respawn',0,m_cur,0,1);\r
+ drw_btn('Main menu',1,m_cur,0,1);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+procedure fast_menu;\r
+ var\r
+ m_cur,i:integer;\r
+ begin\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_UP) then begin m_cur:=m_cur-1; if m_cur<0 then m_cur:=3; end;\r
+ if clickedKey(KEY_MENU_DOWN) then begin m_cur:=m_cur+1; if m_cur>3 then m_cur:=0; end;\r
+ if clickedKey(KEY_MENU_SELECT) then\r
+ begin\r
+ if m_cur=0 then\r
+ begin\r
+ exit;\r
+ end; else\r
+ if m_cur=1 then\r
+ begin\r
+ savegame('/'+sd+'/cavecraft/saves/'+sav_fl+'/');\r
+ exit;\r
+ end; else\r
+ if m_cur=2 then\r
+ begin\r
+ menu_sett;\r
+ end; else\r
+ if m_cur=3 then\r
+ begin\r
+ //clear_gui(keymode);\r
+ menu;\r
+ exit;\r
+ end;\r
+ end;\r
+ draw;\r
+ drawfonttext('Game menu',getwidth/2-36,getheight/2-20);\r
+ drw_btn('Back to Game',0,m_cur,0,1);\r
+ drw_btn('Save Game',1,m_cur,0,1);\r
+ drw_btn('Options',2,m_cur,0,1);\r
+ drw_btn('Quit to Title',3,m_cur,0,1);\r
+\r
+ drawVideo;\r
+ delay(1);\r
+ until false;\r
+ end;\r
+\r
+procedure keyFastInv;\r
+ begin\r
+ if clickedKey(KEY_FASTINV_NEXT) then\r
+ begin\r
+ invslot:=invslot-1;\r
+ if invslot<0 then\r
+ invslot:=8;\r
+ end;\r
+\r
+ if clickedKey(KEY_FASTINV_PREV) then\r
+ begin\r
+ invslot:=invslot+1;\r
+ if invslot>8 then\r
+ invslot:=0;\r
+ end;\r
+ end;\r
+\r
+procedure keyConsole;\r
+ begin\r
+ if clickedKey(KEY_CHAT) then\r
+ SetTimer(1000,T_CONSOLE);\r
+\r
+ if pressedKey(KEY_CHAT) then\r
+ begin\r
+ if GetTimer(T_CONSOLE)=TIMER_OK then\r
+ begin\r
+ call_console;\r
+ ResetTimer(T_CONSOLE);\r
+ end;\r
+ end;\r
+ else\r
+ begin\r
+ if GetTimer(T_CONSOLE)>TIMER_OK then\r
+ begin\r
+ deb:= not deb;\r
+ ResetTimer(T_CONSOLE);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+procedure keyInventory;\r
+ begin\r
+ if clickedKey(KEY_PLR_OPENINV) then\r
+ if gamemode<>1 then\r
+ OpenPlayerInventory;\r
+ else\r
+ OpenCreativeWindow;\r
+ end;\r
+\r
+procedure keyhandler;\r
+ begin\r
+ updateKeys;\r
+\r
+ if WindowKeyHanler then\r
+ begin\r
+ if keymode=0 then\r
+ begin\r
+ keyInventory;\r
+ keyFastInv;\r
+ keyConsole;\r
+\r
+ if clickedKey(KEY_PLR_EDITMODE) then\r
+ begin\r
+ keymode:=1;\r
+ curx:=player.getX div 16;\r
+ cury:=player.getY div 16;\r
+ end;\r
+\r
+ if clickedKey(KEY_PLR_USE) then\r
+ rt_usemob;\r
+\r
+ if clickedKey(KEY_MENU) then\r
+ fast_menu;\r
+\r
+ if clickedKey(KEY_PLR_ATTACK) then\r
+ if rt_useweap=false then\r
+ debug('useweap');\r
+\r
+ if pressedKey(KEY_PLR_ATTACK) then\r
+ begin\r
+ rt_usetools;\r
+ playAnim(ANIM_HAND);\r
+ end;\r
+ else\r
+ begin\r
+ resetToolProgerss;\r
+ cancelAnim(ANIM_HAND);\r
+ end;\r
+\r
+ if pressedKey(KEY_PLR_UP) then\r
+ player.gotoUP;\r
+ if pressedKey(KEY_PLR_DOWN) then\r
+ player.gotoDOWN;\r
+ if pressedKey(KEY_PLR_LEFT) then\r
+ player.gotoLEFT;\r
+ if pressedKey(KEY_PLR_RIGHT) then\r
+ player.gotoRIGHT;\r
+ end;\r
+ else\r
+ if keymode=1 then\r
+ begin\r
+ keyInventory;\r
+ keyFastInv;\r
+ keyConsole;\r
+\r
+ if clickedKey(KEY_PLR_UP) then\r
+ begin\r
+ cury:=cury-1;\r
+ if cury<0 then\r
+ cury:=0;\r
+ end;\r
+ if clickedKey(KEY_PLR_DOWN) then\r
+ begin\r
+ cury:=cury+1;\r
+ if cury>127 then\r
+ cury:=127;\r
+ end;\r
+ if clickedKey(KEY_PLR_LEFT) then\r
+ begin\r
+ curx:=curx-1;\r
+ if curx<0 then\r
+ curx:=0;\r
+ end;\r
+ if clickedKey(KEY_PLR_RIGHT) then\r
+ begin\r
+ curx:=curx+1;\r
+ if curx>255 then\r
+ curx:=255;\r
+ end;\r
+\r
+ if clickedKey(KEY_PLR_EDITMODE) then\r
+ keymode:=0;\r
+\r
+ if clickedKey(KEY_PLR_USE) then\r
+ actionUse(invslot, curx, cury);\r
+\r
+ if pressedKey(KEY_PLR_ATTACK) then\r
+ begin\r
+ usetools(invslot, curx, cury);\r
+ playAnim(ANIM_HAND);\r
+ end;\r
+ else\r
+ begin\r
+ resetToolProgerss;\r
+ cancelAnim(ANIM_HAND);\r
+ end;\r
+\r
+ if clickedKey(KEY_MENU) then\r
+ fast_menu;\r
+ end;\r
+\r
+ end;\r
+\r
+ end;\r
+\r
+procedure phyhandler;\r
+ var\r
+ i:integer;\r
+ begin\r
+ player.calcPhysics;\r
+ mob.updatePhy;\r
+ drop.calcPhy;\r
+ end;\r
+\r
+procedure light_fillrect(l,x,y,r:integer);\r
+ var\r
+ ix,iy,ym,yp,xm,xp:integer;\r
+ begin\r
+ ym:=y-r;\r
+ yp:=y+r;\r
+ xm:=x-r;\r
+ xp:=x+r;\r
+ for ix:=xm to xp do\r
+ for iy:=ym to yp do\r
+ setmaplight(getmaplight(ix,iy)+l,ix,iy);\r
+ end;\r
+\r
+procedure light_rect(l,x,y,r:integer);\r
+ var\r
+ ix,iy,ym,yp,xm,xp:integer;\r
+ begin\r
+ ym:=y-r;\r
+ yp:=y+r;\r
+ xm:=x-r;\r
+ xp:=x+r;\r
+ for ix:=xm to xp do\r
+ begin\r
+ setmaplight(getmaplight(ix,ym)+l,ix,ym);\r
+ setmaplight(getmaplight(ix,yp)+l,ix,yp);\r
+ end;\r
+ for iy:=ym+1 to yp-1 do\r
+ begin\r
+ setmaplight(getmaplight(xm,iy)+l,xm,iy);\r
+ setmaplight(getmaplight(xp,iy)+l,xp,iy);\r
+ end;\r
+ end;\r
+\r
+procedure calc_light(m,x,y:integer);\r
+ var\r
+ ix,iy,l,ss,sf:integer;\r
+ begin\r
+ if light_type=1 then light_fillrect(m,x,y,m/2); else\r
+ for l:=m downto 1 do\r
+ begin\r
+ if ss mod 2=0 then light_rect(l,x,y,ss/2);\r
+ ss:=ss+1;\r
+ end;\r
+ end;\r
+\r
+procedure calc_sun(ix,m:integer);\r
+ var\r
+ iy,ss:integer;\r
+ begin\r
+ ss:=m;\r
+ for iy:=0 to 127 do\r
+ begin\r
+ setmaplight(ss,ix,iy);\r
+ if ss=0 then break;\r
+ ss:=ss-getBlockTr(getmap(ix,iy));\r
+ if ss<0 then ss:=0;\r
+ end;\r
+ for iy:=iy+1 to 127 do\r
+ begin\r
+ setmaplight(0,ix,iy);\r
+ end;\r
+ end;\r
+\r
+procedure kill_plr;\r
+ var\r
+ i:integer;\r
+ begin\r
+ hp:=0;\r
+ for i:=0 to INV_SIZE do\r
+ begin\r
+ if inv.isNull(i)=false then\r
+ player.dropItem(inv.getItem(i), inv.getSum(i));\r
+ inv.setItem(0, i);\r
+ inv.setSum(0, i);\r
+ end;\r
+ if gamemode<2 then plr_is_dead; else plr_is_dead_hardcore;\r
+ end;\r
+\r
+procedure hunger_and_air;\r
+ var\r
+ x, y:integer;\r
+ begin\r
+ x:=player.getX;\r
+ y:=player.getY;\r
+ if gamemode<>1 then\r
+ begin\r
+ if getrelativetimems-hung_time>=90000/(gamemode+1) then\r
+ begin\r
+ hung_time:=getrelativetimems;\r
+ hunger:=hunger-1;\r
+ end;\r
+ if getrelativetimems-hp_time>=5000*(gamemode+1) then\r
+ begin\r
+ if hunger>16 then\r
+ begin\r
+ hp_time:=getrelativetimems;\r
+ hp:=hp+1;\r
+ if hp>20 then hp:=20;\r
+ end; else\r
+ if hunger<1 then\r
+ begin\r
+ hp_time:=getrelativetimems;\r
+ hp:=hp-1;\r
+ if hp<1 then if gamemode<2 then hp:=1;\r
+ end;\r
+ end;\r
+\r
+ if getmap((x+4)/16,y/16)=50 then\r
+ begin\r
+ if getrelativetimems-air_time>=500 then\r
+ begin\r
+ air:=air-1;\r
+ air_time:=getrelativetimems;\r
+ if air<1 then\r
+ begin\r
+ hp_time:=getrelativetimems;\r
+ hp:=hp-2;\r
+ end;\r
+ end;\r
+ end; else\r
+ air:=21;\r
+ end;\r
+ end;\r
+\r
+procedure game;\r
+ var\r
+ ix,iy,minx,maxx,miny,maxy,fps_t,tim, x, y:integer;\r
+ begin\r
+ x:=player.getX;\r
+ y:=player.getY;\r
+\r
+ hunger_and_air;\r
+\r
+ if hunger<0 then hunger:=0;\r
+ if air<0 then air:=0;\r
+\r
+ fps_t:=fps;\r
+ if fps_t<1 then fps_t:=1;\r
+\r
+ if bl_ani5_d then\r
+ if bl_ani5_v=false then\r
+ begin\r
+ bl_ani5:=bl_ani5+1;\r
+ if bl_ani5>4 then\r
+ begin\r
+ bl_ani5:=4;\r
+ bl_ani5_v:=not bl_ani5_v;\r
+ end;\r
+ end;\r
+ else\r
+ begin\r
+ bl_ani5:=bl_ani5-1;\r
+ if bl_ani5<0 then\r
+ begin\r
+ bl_ani5:=0;\r
+ bl_ani5_v:=not bl_ani5_v;\r
+ end;\r
+ end;\r
+ bl_ani5_d:=not bl_ani5_d;\r
+\r
+ drop.reflux;\r
+ player.getDrop;\r
+\r
+ game_time:=game_time+(600000 div (fps_t*1000));\r
+\r
+ if (game_time>600000) or (game_time<0) then\r
+ begin\r
+ game_time:=0;\r
+ moon_phase:=moon_phase+1;\r
+ if moon_phase>7 then moon_phase:=0;\r
+ load_moon('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',moon_phase);\r
+ end;\r
+\r
+ tim:=10000*getimagewidth(sky)/600000*game_time/10000;\r
+ global_light:=effects.get(sky,tim,1,1) {and $F};\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 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
+\r
+ if random(20)=random(20) then create_particle(6,x,y);\r
+\r
+ if gamemode=1 then begin hp:=666; hunger:=666; end;\r
+\r
+ if inv.getItem(invslot)=186 then\r
+ ifminimap:=true;\r
+ else\r
+ ifminimap:=false;\r
+\r
+ //if s_spawn_mob then if random(4096)=1547 then megaspawn;\r
+\r
+ mob.update;\r
+\r
+ if particle_upd then update_particle;\r
+\r
+ if light_type>0 then\r
+ begin\r
+ minx:=camx/16-1;\r
+ maxx:=(camx+getWidth)/16+1;\r
+ if minx<0 then minx:=0;\r
+ if maxx>255 then maxx:=255;\r
+ for ix:=minx to maxx do calc_sun(ix,global_light);\r
+ end;\r
+\r
+ minx:=camx/16-8;\r
+ maxx:=(camx+getWidth)/16+16;\r
+ miny:=camy/16-8;\r
+ maxy:=(camy+getHeight)/16+16;\r
+ if minx<0 then minx:=0;\r
+ if maxx>255 then maxx:=255;\r
+ if miny<0 then miny:=0;\r
+ if maxy>127 then maxy:=127;\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
+ end;\r
+\r
+ minx:=(camx/16)-((getwidth/2)/16);\r
+ miny:=(camy/16)-((getheight/2)/16);\r
+ maxx:=(camx+(getWidth+getWidth/2))/16;\r
+ maxy:=(camy+(getHeight+getHeight/2))/16;\r
+ if minx<0 then minx:=0;\r
+ if miny<0 then miny:=0;\r
+ if maxx>255 then maxx:=255;\r
+ if maxy>127 then maxy:=127;\r
+ if updx<minx then updx:=minx;\r
+ if updy<miny then updy:=miny;\r
+ if updx>maxx then updx:=minx;\r
+ if updy>maxy then updy:=miny;\r
+\r
+ if bl_upd>0 then\r
+ begin\r
+ for ix:=0 to (((2*getWidth/16)*(2*getHeight/16))-1) div ((fps_t*bl_upd)) do\r
+ begin\r
+ updateBlock(updx, updy);\r
+ updx:=updx+1;\r
+ if updx>maxx then\r
+ begin\r
+ updx:=minx;\r
+ updy:=updy+1;\r
+ if updy>maxy then updy:=miny;\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ {if coll_bl(110)=true then\r
+ begin\r
+ if getrelativetimems-portal_time>5000 then\r
+ begin\r
+ if pl_world=0 then begin go_to_nether; portal_time:=getrelativetimems; end; else\r
+ if pl_world=1 then begin go_to_world; portal_time:=getrelativetimems; end;\r
+ end;\r
+ end;\r
+\r
+ if coll_bl(51)=true then hp:=hp-1;\r
+\r
+ if coll_bl(59)=true then\r
+ begin\r
+ if vely<0 then vely:=-1;\r
+ else\r
+ if vely>0 then vely:=1;\r
+ end;}\r
+\r
+ if gamemode<>1 then\r
+ begin\r
+ if hp>20 then hp:=20;\r
+ if hunger>20 then hunger:=20;\r
+ end;\r
+\r
+ if y>2048 then kill_plr;\r
+ if (hp<1) and (gamemode<>1) then kill_plr;\r
+ if fish=true then fishing;\r
+\r
+ if (fish=true) and (inv.getItem(invslot)<>152) then fish:=false;\r
+\r
+ //if (keymode>3) and (cury<(y div 16)-4) then begin clear_gui(keymode); keymode:=0; curx:=x div 16; cury:=y div 16; end;\r
+\r
+ if gamemode<>1 then\r
+ begin\r
+ if cury<(y div 16)-4 then cury:=(y div 16)-4;\r
+ if cury>(y div 16)+5 then cury:=(y div 16)+5;\r
+ if curx<(x div 16)-4 then curx:=(x div 16)-4;\r
+ if curx>(x div 16)+4 then curx:=(x div 16)+4;\r
+ end;\r
+\r
+ UpdateFurnaces;\r
+ end;\r
+\r
+procedure qt_start;\r
+ var\r
+ i:integer;\r
+ begin\r
+ drawgui:=true;\r
+ LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/');\r
+ drawdeadlogo;\r
+ start_uu;\r
+ if load_key_tex=1 then init_touch;\r
+ for i:=0 to 4 do\r
+ begin\r
+ msg[i]:='';\r
+ msg_time[i]:=getrelativetimems;\r
+ end;\r
+ InitMap(MAP_W, MAP_H);\r
+ menu;\r
+ end;\r
+\r
+begin\r
+ qt_start;\r
+ hung_time:=getrelativetimems;\r
+ hp_time:=getrelativetimems;\r
+ air_time:=getrelativetimems;\r
+ portal_time:=getrelativetimems;\r
+ repeat\r
+ proc_fps;\r
+ keyhandler;\r
+ phyhandler;\r
+ game;\r
+ draw;\r
+ drawfonttext(version,getWidth-(length(version)*8),getHeight-8);\r
+ if getrelativetimems-msg_time[4]>500 then begin free_ram:=memory.get_freememory; if free_ram<0 then free_ram:=-free_ram; msg_time[4]:=getrelativetimems; end;\r
+ if deb=true then\r
+ begin\r
+ //drawfonttext('X:'+(x div 16-128),0,0);\r
+ //drawfonttext('Y:'+integertostring(127-(y div 16)),0,8);\r
+ drawfonttext('CURX:'+(curx-128),0,16);\r
+ drawfonttext('CURY:'+cury,0,24);\r
+ drawfonttext('UPDX:'+updx,0,32);\r
+ drawfonttext('UPDY:'+updy,0,40);\r
+ drawfonttext('FPS:'+fps,0,56);\r
+ drawfonttext('Free RAM:'+free_ram/1024+' KB',0,64);\r
+ drawfonttext('Total RAM:'+memory.get_totalmemory div 1024+' KB',0,72);\r
+ drawfonttext('SEED:'+seed,0,88);\r
+ drawfonttext('Game time:'+game_time,0,96);\r
+ end;\r
+\r
+ drawVideo;\r
+ maxfps;\r
+\r
+ until false;\r
+end.\r
diff --git a/src/cellui.mpsrc b/src/cellui.mpsrc
--- /dev/null
+++ b/src/cellui.mpsrc
@@ -0,0 +1,491 @@
+unit cellui;\r
+\r
+interface\r
+ const\r
+ CONST_MAX_LAYERS=1;\r
+ CONST_MAX_CELLS=63;\r
+ CONST_MAX_OFFSETS=1;\r
+ CONST_MAX_CURS=1;\r
+ CONST_MAX_INFO=2;\r
+\r
+ CELL_TYPE_NULL=0;\r
+ CELL_TYPE_PLAYER_INV=1;\r
+ CELL_TYPE_CREWATIVE_INV=2;\r
+ CELL_TYPE_CHEST=3;\r
+ CELL_TYPE_FASTCRAFT=4;\r
+ CELL_TYPE_FURNACE=5;\r
+\r
+ CELL_FLAG_OFFSET=$F;\r
+ CELL_FLAG_INDICATOR=$10;\r
+\r
+ CUR_SELECT1=0;\r
+ CUR_SELECT2=1;\r
+\r
+ WINDOW_NULL=0;\r
+\r
+ FIND_CELL_UP=0;\r
+ FIND_CELL_DOWN=1;\r
+ FIND_CELL_LEFT=2;\r
+ FIND_CELL_RIGHT=3;\r
+\r
+ CELL_W=16;\r
+ CELL_H=16;\r
+\r
+ procedure ClearLayer(n:integer);\r
+ procedure LoadCurImg(img:image; i:integer;);\r
+\r
+ procedure NewLayer;\r
+ procedure DelLayer;\r
+ function CellLayer:integer;\r
+ procedure setCellLayer(n:integer);\r
+\r
+ procedure initCell(cell_type, id, offset, data, x, y:integer; indicator:boolean;);\r
+ function getCellID(i:integer):integer;\r
+ function getCellData(i:integer):integer;\r
+ function getCellX(i:integer):integer;\r
+ function getCellY(i:integer):integer;\r
+ procedure setOffset(newOffset, i:integer;);//i - номер смещения\r
+ function getOffset(i:integer):integer;//i - номер смещения\r
+ function getCellOffset(i:integer):integer;\r
+\r
+ function getItem(i:integer):integer;\r
+ procedure setItem(val, i:integer);\r
+ function getSum(i:integer):integer;\r
+ procedure setSum(val, i:integer);\r
+ procedure fixNullCell(i:integer;);\r
+\r
+ procedure DrawCellLayer(i, x, y:integer);\r
+\r
+ procedure SetWindowInfo(n, i:integer);\r
+ function GetWindowInfo(i:integer):integer;\r
+ procedure SetCur(i:integer);\r
+ function GetCur:integer;\r
+\r
+ procedure SetCurIndex(n, i:integer);\r
+ function GetCurIndex(i:integer):integer;\r
+ procedure SetCurActive(n:boolean; i:integer);\r
+ function GetCurActive(i:integer):boolean;\r
+ procedure SetWindowType(wtype:integer);\r
+ function GetWindowType:integer;\r
+\r
+ procedure DrawCursors(n, x, y:integer);\r
+\r
+ procedure ShiftCurrentCur(find:integer;);\r
+\r
+ function FindCurrentWindowsType:boolean;\r
+\r
+implementation\r
+ uses vars, Canvas, items, console, furnace, chest, inv, func, items_store;\r
+ var\r
+ layer:integer;\r
+ last_cell: array [0..CONST_MAX_LAYERS] of integer;\r
+ inv_type: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer;//Name of virtual massive\r
+ inv_id: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer;//ID of real item massive\r
+ inv_x, inv_y: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer;\r
+ inv_data: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer;\r
+ inv_flags: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer;\r
+\r
+ inv_offset: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_OFFSETS] of integer;//Offset of real item id in inventory\r
+\r
+ WindowType: array [0..CONST_MAX_LAYERS] of integer;\r
+ WindowInfo: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_INFO] of integer;\r
+\r
+ WindowCurCurrent: array [0..CONST_MAX_LAYERS] of integer;\r
+ WindowCurImg: array [0..CONST_MAX_CURS] of image;\r
+ WindowCurIndex: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CURS] of integer;\r
+ WindowCurActive: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CURS] of boolean;\r
+\r
+{=====[Inventory interface functions]=====}\r
+ procedure ClearLayer(n:integer);\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to CONST_MAX_CELLS do\r
+ begin\r
+ last_cell[n]:=0;\r
+ inv_type[n, i]:=CELL_TYPE_NULL;\r
+ inv_id[n, i]:=0;\r
+ inv_x[n, i]:=0;\r
+ inv_y[n, i]:=0;\r
+ inv_data[n, i]:=0;\r
+ inv_flags[n, i]:=0;\r
+ end;\r
+\r
+ for i:=0 to CONST_MAX_OFFSETS do\r
+ inv_offset[n, i]:=0;\r
+\r
+ WindowType[n]:=WINDOW_NULL;\r
+ WindowCurCurrent[n]:=0;\r
+ for i:=0 to CONST_MAX_INFO do\r
+ WindowInfo[n, i]:=0;\r
+ for i:=0 to CONST_MAX_CURS do\r
+ begin\r
+ WindowCurIndex[n, i]:=0;\r
+ WindowCurActive[n, i]:=false;\r
+ end;\r
+ end;\r
+\r
+ procedure LoadCurImg(img:image; i:integer;);\r
+ begin\r
+ WindowCurImg[i]:=img;\r
+ end;\r
+\r
+ procedure NewLayer;\r
+ begin\r
+ layer:=layer+1;\r
+ end;\r
+\r
+ procedure DelLayer;\r
+ begin\r
+ ClearLayer(layer);\r
+ layer:=layer-1;\r
+ end;\r
+\r
+ function CellLayer:integer;\r
+ begin\r
+ CellLayer:=layer;\r
+ end;\r
+\r
+ procedure setCellLayer(n:integer);\r
+ begin\r
+ layer:=n;\r
+ end;\r
+\r
+ procedure initCell(cell_type, id, offset, data, x, y:integer; indicator:boolean;);\r
+ var\r
+ i:integer;\r
+ begin\r
+ i:=last_cell[layer];\r
+ last_cell[layer]:=last_cell[layer]+1;\r
+\r
+ inv_type[layer, i]:=cell_type;\r
+ inv_id[layer, i]:=id;\r
+ inv_x[layer, i]:=x;\r
+ inv_y[layer, i]:=y;\r
+ inv_data[layer, i]:=data;\r
+\r
+ inv_flags[layer, i]:=(offset and CELL_FLAG_OFFSET);\r
+\r
+ if indicator then\r
+ inv_flags[layer, i]:=inv_flags[layer, i] or CELL_FLAG_INDICATOR;\r
+ end;\r
+\r
+ function getCellType(i:integer):integer;\r
+ begin\r
+ getCellType:=inv_type[layer, i];\r
+ end;\r
+\r
+ function getCellX(i:integer):integer;\r
+ begin\r
+ getCellX:=inv_x[layer, i];\r
+ end;\r
+\r
+ function getCellY(i:integer):integer;\r
+ begin\r
+ getCellY:=inv_y[layer, i];\r
+ end;\r
+\r
+ function getCellID(i:integer):integer;\r
+ begin\r
+ getCellID:=inv_id[layer, i];\r
+ end;\r
+\r
+ function getCellData(i:integer):integer;\r
+ begin\r
+ getCellData:=inv_data[layer, i];\r
+ end;\r
+\r
+ function getCellFlagIndicator(i, j:integer):boolean;\r
+ begin\r
+ getCellFlagIndicator:=(inv_flags[i, j] and CELL_FLAG_INDICATOR)>0;\r
+ end;\r
+\r
+ procedure setOffset(newOffset, i:integer;);\r
+ begin\r
+ inv_offset[layer, i]:=newOffset;\r
+ end;\r
+\r
+ function getOffset(i:integer):integer;\r
+ begin\r
+ getOffset:=inv_offset[layer, i];\r
+ end;\r
+\r
+ function getCellOffset(i:integer):integer;\r
+ begin\r
+ getCellOffset:=inv_flags[layer, i] and CELL_FLAG_OFFSET;\r
+ end;\r
+\r
+ function getItemIdx(i, n:integer):integer;\r
+ var\r
+ id, data, _type:integer;\r
+ begin\r
+ id:=inv_id[n, i]+inv_offset[n, inv_flags[n, i] and CELL_FLAG_OFFSET];\r
+ _type:=inv_type[n, i];\r
+ data:=inv_data[n, i];\r
+\r
+ if _type=CELL_TYPE_PLAYER_INV then\r
+ getItemIdx:=inv.getItem(id);\r
+ else\r
+ if _type=CELL_TYPE_CREWATIVE_INV then\r
+ getItemIdx:=getItemList(id);\r
+ else\r
+ if _type=CELL_TYPE_CHEST then\r
+ getItemIdx:=chest.getItem(id, data);\r
+ else\r
+ if _type=CELL_TYPE_FASTCRAFT then\r
+ getItemIdx:=getCraftOutItem(id);\r
+ else\r
+ if _type=CELL_TYPE_FURNACE then\r
+ getItemIdx:=GetFurItem(id, data);\r
+ end;\r
+\r
+ procedure setItemIdx(val, i, n:integer);\r
+ var\r
+ id, data, _type:integer;\r
+ begin\r
+ id:=inv_id[n, i]+inv_offset[n, inv_flags[n, i] and CELL_FLAG_OFFSET];\r
+ _type:=inv_type[n, i];\r
+ data:=inv_data[n, i];\r
+\r
+ if _type=CELL_TYPE_PLAYER_INV then\r
+ inv.setItem(val, id);\r
+ else\r
+ if _type=CELL_TYPE_CHEST then\r
+ chest.setItem(val, id, data);\r
+ else\r
+ if _type=CELL_TYPE_FURNACE then\r
+ SetFurItem(val, id, data);\r
+ end;\r
+\r
+ function getSumIdx(i, n:integer):integer;\r
+ var\r
+ id, data, _type:integer;\r
+ begin\r
+ id:=inv_id[n, i]+inv_offset[n, inv_flags[n, i] and CELL_FLAG_OFFSET];\r
+ _type:=inv_type[n, i];\r
+ data:=inv_data[n, i];\r
+\r
+ if _type=CELL_TYPE_PLAYER_INV then\r
+ getSumIdx:=inv.getSum(id);\r
+ else\r
+ if _type=CELL_TYPE_CREWATIVE_INV then\r
+ getSumIdx:=getItemMax(getItemList(id));\r
+ else\r
+ if _type=CELL_TYPE_CHEST then\r
+ getSumIdx:=chest.getSum(id, data);\r
+ else\r
+ if _type=CELL_TYPE_FASTCRAFT then\r
+ getSumIdx:=getCraftOutSum(id);\r
+ else\r
+ if _type=CELL_TYPE_FURNACE then\r
+ getSumIdx:=GetFurSum(id, data);\r
+ end;\r
+\r
+ procedure setSumIdx(val, i, n:integer);\r
+ var\r
+ id, data, _type:integer;\r
+ begin\r
+ id:=inv_id[n, i]+inv_offset[n, inv_flags[n, i] and CELL_FLAG_OFFSET];\r
+ _type:=inv_type[n, i];\r
+ data:=inv_data[n, i];\r
+\r
+ if _type=CELL_TYPE_PLAYER_INV then\r
+ inv.setSum(val, id);\r
+ else\r
+ if _type=CELL_TYPE_CHEST then\r
+ chest.setSum(val, id, data);\r
+ else\r
+ if _type=CELL_TYPE_FURNACE then\r
+ SetFurSum(val, id, data);\r
+ end;\r
+\r
+ //i - индекс в таблице ячеек\r
+ function getItem(i:integer):integer;\r
+ begin\r
+ getItem:=getItemIdx(i, CellLayer);\r
+ end;\r
+\r
+ procedure setItem(val, i:integer);\r
+ begin\r
+ setItemIdx(val, i, CellLayer);\r
+ end;\r
+\r
+ function getSum(i:integer):integer;\r
+ begin\r
+ getSum:=getSumIdx(i, CellLayer);\r
+ end;\r
+\r
+ procedure setSum(val, i:integer);\r
+ begin\r
+ setSumIdx(val, i, CellLayer);\r
+ end;\r
+\r
+ procedure fixNullCell(i:integer);\r
+ begin\r
+ if (getItem(i)<1) or (getSum(i)<1) then\r
+ begin\r
+ setItem(0, i);\r
+ setSum(0, i);\r
+ end;\r
+ end;\r
+\r
+ procedure DrawCellLayer(i, x, y:integer);\r
+ var\r
+ j:integer;\r
+ begin\r
+ for j:=0 to CONST_MAX_CELLS do\r
+ if inv_type[i, j]<>CELL_TYPE_NULL then\r
+ begin\r
+ drawItem(getItemIdx(j, i), getSumIdx(j, i), x+inv_x[i, j], y+inv_y[i, j], getCellFlagIndicator(i, j));\r
+ end;\r
+ end;\r
+\r
+{======[]======}\r
+\r
+ procedure SetWindowInfo(n, i:integer);\r
+ begin\r
+ WindowInfo[CellLayer, i]:=n;\r
+ end;\r
+\r
+ function GetWindowInfo(i:integer):integer;\r
+ begin\r
+ GetWindowInfo:=WindowInfo[CellLayer, i];\r
+ end;\r
+\r
+ procedure SetCur(i:integer);\r
+ begin\r
+ WindowCurCurrent[CellLayer]:=i;\r
+ end;\r
+\r
+ function GetCur:integer;\r
+ begin\r
+ GetCur:=WindowCurCurrent[CellLayer];\r
+ end;\r
+\r
+ procedure SetCurIndex(n, i:integer);\r
+ begin\r
+ WindowCurIndex[CellLayer, i]:=n;\r
+ end;\r
+\r
+ function GetCurIndex(i:integer):integer;\r
+ begin\r
+ GetCurIndex:=WindowCurIndex[CellLayer, i];\r
+ end;\r
+\r
+ procedure SetCurActive(n:boolean; i:integer);\r
+ begin\r
+ WindowCurActive[CellLayer, i]:=n;\r
+ end;\r
+\r
+ function GetCurActive(i:integer):boolean;\r
+ begin\r
+ GetCurActive:=WindowCurActive[CellLayer, i];\r
+ end;\r
+\r
+ procedure SetWindowType(wtype:integer);\r
+ begin\r
+ WindowType[CellLayer]:=wtype;\r
+ end;\r
+\r
+ function GetWindowType:integer;\r
+ var\r
+ tmp:integer;\r
+ begin\r
+ tmp:=CellLayer;\r
+ if CellLayer<0 then\r
+ GetWindowType:=WINDOW_NULL;\r
+ else\r
+ GetWindowType:=WindowType[CellLayer];\r
+ end;\r
+\r
+ function FindCurrentWindowsType:boolean;\r
+ var\r
+ crrwt, i:integer;\r
+ begin\r
+ crrwt:=GetWindowType;\r
+ for i:=0 to CONST_MAX_LAYERS do\r
+ if (WindowType[i]=crrwt) and (i<>CellLayer) then\r
+ begin\r
+ FindCurrentWindowsType:=true;\r
+ exit;\r
+ end;\r
+ end;\r
+\r
+ procedure DrawCursors(n, x, y:integer);\r
+ var\r
+ i, idx:integer;\r
+ begin\r
+ for i:=0 to CONST_MAX_CURS do\r
+ if WindowCurActive[n, i] then\r
+ begin\r
+ idx:=WindowCurIndex[n, i];\r
+ DrawImage(WindowCurImg[i], x+inv_x[n, idx], y+inv_y[n, idx]);\r
+ end;\r
+ end;\r
+\r
+ procedure ShiftCurrentCur(find:integer;);\r
+ var\r
+ find_i, find_x, find_y:integer;\r
+ res_i, res_x, res_y:integer;\r
+ i, tmp_x, tmp_y:integer;\r
+ begin\r
+ find_i:=GetCurIndex(GetCur);\r
+ find_x:=getCellX(find_i);\r
+ find_y:=getCellY(find_i);\r
+ res_i:=find_i;\r
+ if find=FIND_CELL_UP then\r
+ res_y:=-2147483647;\r
+ if find=FIND_CELL_DOWN then\r
+ res_y:=2147483647;\r
+ if find=FIND_CELL_LEFT then\r
+ res_x:=-2147483647;\r
+ if find=FIND_CELL_RIGHT then\r
+ res_x:=2147483647;\r
+\r
+ for i:=0 to CONST_MAX_CELLS do\r
+ if (getCellType(i)<>CELL_TYPE_NULL) and (i<>find_i) then\r
+ begin\r
+ tmp_x:=getCellX(i);\r
+ tmp_y:=getCellY(i);\r
+ //debug('['+i+']: tmp_y='+tmp_y+'; res_y='+res_y+';');\r
+ if find=FIND_CELL_UP then\r
+ begin\r
+ if (tmp_y<find_y) and (tmp_y>res_y) and (tmp_x>=find_x-CELL_W/2) and (tmp_x<=find_x+CELL_W+CELL_W/2) then\r
+ res_i:=i;\r
+ end;\r
+\r
+ if find=FIND_CELL_DOWN then\r
+ begin\r
+ if ((tmp_y>find_y) and (tmp_y<res_y)) and (tmp_x>=find_x-CELL_W/2) and (tmp_x<=find_x+CELL_W+CELL_W/2) then\r
+ res_i:=i;\r
+ end;\r
+\r
+ if find=FIND_CELL_LEFT then\r
+ begin\r
+ //debug('LEFT ['+i+']: tmp_x='+tmp_x+'; find_x='+find_x+'; res_x='+res_x+';');\r
+ if (tmp_x<find_x) and (tmp_x>res_x) and (tmp_y>=find_y-CELL_H/2) and (tmp_y<=find_y+CELL_H+CELL_H/2) then\r
+ res_i:=i;\r
+ end;\r
+\r
+ if find=FIND_CELL_RIGHT then\r
+ begin\r
+ //debug('RIGHT ['+i+']: tmp_x='+tmp_x+'; find_x='+find_x+'; res_x='+res_x+';');\r
+ if (tmp_x>find_x) and (tmp_x<res_x) and (tmp_y>=find_y-CELL_H/2) and (tmp_y<=find_y+CELL_H+CELL_H/2) then\r
+ res_i:=i;\r
+ end;\r
+\r
+\r
+ if res_i<>find_i then\r
+ begin\r
+ res_x:=getCellX(res_i);\r
+ res_y:=getCellY(res_i);\r
+ end;\r
+ end;\r
+ SetCurIndex(res_i, GetCur);\r
+ end;\r
+\r
+initialization\r
+ layer:=-1;\r
+ WindowCurImg[0]:=loadimage('/terrain/sun.png');\r
+ WindowCurImg[1]:=loadimage('/terrain/moon_phases/moon_phase_0.png');\r
+end.\r
diff --git a/src/chest.mpsrc b/src/chest.mpsrc
--- /dev/null
+++ b/src/chest.mpsrc
@@ -0,0 +1,128 @@
+unit chest;\r
+\r
+interface\r
+ const\r
+ MAX_CHEST=31;\r
+\r
+ function create(x, y:integer):integer;\r
+ procedure destroy(drp:boolean; x, y:integer);\r
+\r
+ function getItem(n, i:integer):integer;\r
+ function getSum(n, i:integer):integer;\r
+ procedure setItem(val, n, i:integer);\r
+ procedure setSum(val, n, i:integer);\r
+\r
+ procedure resetData;\r
+ procedure saveData;\r
+ procedure loadData;\r
+\r
+implementation\r
+ uses maps, drop, vars, jsr75i, func;\r
+ const\r
+ MAX_CELL=26;\r
+ CHEST_ERROR=-1;\r
+ var\r
+ chest_b: array [0..MAX_CHEST] of boolean;\r
+ chest_item, chest_sum: array [0..MAX_CELL, 0..MAX_CHEST] of integer;\r
+\r
+ function getItem(n, i:integer):integer;\r
+ begin\r
+ getItem:=chest_item[n, i];\r
+ end;\r
+\r
+ function getSum(n, i:integer):integer;\r
+ begin\r
+ getSum:=chest_sum[n, i];\r
+ end;\r
+\r
+ procedure setItem(val, n, i:integer);\r
+ begin\r
+ chest_item[n, i]:=val;\r
+ end;\r
+\r
+ procedure setSum(val, n, i:integer);\r
+ begin\r
+ chest_sum[n, i]:=val;\r
+ end;\r
+\r
+ function create(x, y:integer):integer;\r
+ var\r
+ i, j:integer;\r
+ begin\r
+ for i:=0 to MAX_CHEST do\r
+ if chest_b[i]=false then\r
+ begin\r
+ chest_b[i]:=true;\r
+ for j:=0 to MAX_CELL do\r
+ begin\r
+ setItem(0, j, i);\r
+ setSum(0, j, i);\r
+ end;\r
+ setMapInfo(i, x, y);\r
+ create:=i;\r
+ exit;\r
+ end;\r
+ create:=CHEST_ERROR;\r
+ end;\r
+\r
+ procedure destroy(drp:boolean; x, y:integer);\r
+ var\r
+ i, j:integer;\r
+ begin\r
+ i:=getMapInfo(x, y);\r
+ chest_b[i]:=false;\r
+ for j:=0 to MAX_CELL do\r
+ begin\r
+ if drp then\r
+ drop.create(getItem(j, i), getSum(j, i), x*16+4, y*16+4);\r
+ setItem(0, j, i);\r
+ setSum(0, j, i);\r
+ end;\r
+ end;\r
+\r
+ procedure resetData;\r
+ var\r
+ i, j:integer;\r
+ begin\r
+ for i:=0 to MAX_CHEST do\r
+ begin\r
+ chest_b[i]:=false;\r
+ for j:=0 to MAX_CELL do\r
+ begin\r
+ setItem(0, j, i);\r
+ setSum(0, j, i);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure saveData;\r
+ var\r
+ i, j:integer;\r
+ begin\r
+ for i:=0 to MAX_CHEST do\r
+ begin\r
+ writebool(chest_b[i]);\r
+ for j:=0 to MAX_CELL do\r
+ begin\r
+ write_byte(getItem(j, i));\r
+ writeint(getSum(j, i));\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure loadData;\r
+ var\r
+ i, j:integer;\r
+ begin\r
+ for i:=0 to MAX_CHEST do\r
+ begin\r
+ chest_b[i]:=readbool;\r
+ for j:=0 to MAX_CELL do\r
+ begin\r
+ setItem(read_byte, j, i);\r
+ setSum(ReadInt, j, i);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+end.\r
diff --git a/src/console.pas b/src/console.pas
--- /dev/null
+++ b/src/console.pas
@@ -0,0 +1,954 @@
+unit console;\r
+\r
+interface\r
+ const\r
+ version='BETA 8 FIX';\r
+ var\r
+ osadki:boolean;\r
+ bl_upd:integer;\r
+ s_get_drp:boolean;\r
+ particle_upd:boolean;\r
+ drw_back:boolean;\r
+ drw_sm:boolean;\r
+ s_max_fps:integer;\r
+ s_jpeg_quality:integer;\r
+ drawgui:boolean;\r
+ light_type:integer;\r
+\r
+ ifosad:boolean;\r
+ //s_particles:boolean; - module\r
+\r
+ load_sm:integer;\r
+ load_sky_siz:integer;\r
+ load_back_tex:boolean;\r
+ load_weather_tex:boolean;\r
+ load_particles_tex:boolean;\r
+ load_light_tex:boolean;\r
+ load_gui_tex:boolean;\r
+\r
+ menu_background:integer;\r
+\r
+ load_minimap_tex:boolean;\r
+\r
+ //load_key_tex:integer;\r
+\r
+ drw_stars:boolean;\r
+\r
+ cheats:boolean;\r
+\r
+ sd:string;\r
+\r
+ //max_particles:integer; - module\r
+\r
+ procedure save_settings;\r
+ procedure load_settings;\r
+ procedure call_console;\r
+ procedure exec(s, search:string; acces:boolean);\r
+ procedure addToLog(str:string);\r
+\r
+implementation\r
+uses keyboard,particles_store,vars,maps,items,canvas,mob,worldgen,jsr75i,particles,func, player,sensor, drop, inv, furnace, items_store, video;\r
+const\r
+ CON_LOG_SIZE=9;\r
+ PARSER_MAX_STR=15;\r
+ MAX_IMGREG=2;\r
+var\r
+ logSTR: array [0..CON_LOG_SIZE] of string;\r
+ lastCommand:string;\r
+\r
+ parseStr:string;\r
+ EOFstr, ENDstr:boolean;\r
+\r
+ stack: array [0..0] of integer;\r
+ stack_pointer:integer;\r
+\r
+ autoexec_acces:boolean;\r
+ regimg:image;\r
+\r
+ procedure resetStack(size:integer);\r
+ begin\r
+ stack_pointer:=0;\r
+ size:=size+1;\r
+ bytecode\r
+ iload 0;\r
+ newarray 10;\r
+ putstatic field 'console', 'stack', '[I';\r
+ end;\r
+ end;\r
+\r
+ procedure pushStack(i:integer;);\r
+ begin\r
+ stack[stack_pointer]:=i;\r
+ stack_pointer:=stack_pointer+1;\r
+ end;\r
+\r
+ function popStack:integer;\r
+ begin\r
+ stack_pointer:=stack_pointer-1;\r
+ popStack:=stack[stack_pointer];\r
+ end;\r
+\r
+ procedure swapStack;\r
+ var\r
+ tmp:integer;\r
+ begin\r
+ tmp:=stack[stack_pointer-2];\r
+ stack[stack_pointer-2]:=stack[stack_pointer-1];\r
+ stack[stack_pointer-1]:=tmp;\r
+ end;\r
+\r
+ procedure dupStack;\r
+ begin\r
+ stack[stack_pointer]:=stack[stack_pointer-1];\r
+ stack_pointer:=stack_pointer+1;\r
+ end;\r
+\r
+ procedure resetTmpImg;\r
+ var\r
+ nullimg:image;\r
+ begin\r
+ regimg:=nullimg;\r
+ end;\r
+\r
+procedure addToLog(str:string);\r
+ var\r
+ i:integer;\r
+ begin\r
+ debug('::'+str);\r
+ for i:=CON_LOG_SIZE-1 downto 0 do\r
+ logSTR[i+1]:=logSTR[i];\r
+ logSTR[0]:=str;\r
+ end;\r
+\r
+ procedure setTexture(img:image; name:string; i:integer);\r
+ begin\r
+ name:=UpCase(name);\r
+ if name='BLOCK' then\r
+ begin\r
+ tex[i]:=img;\r
+ tex8[i]:=resize_image(img, 8, 8);\r
+ end;\r
+ else\r
+ if name='ITEM' then\r
+ begin\r
+ item[i]:=img;\r
+ item8[i]:=resize_image(img, 8, 8);\r
+ end;\r
+ else\r
+ if name='VKEY' then\r
+ setVkeyImg(img, i);\r
+ else\r
+ addToLog('Error: unknown texture type "'+name+'"');\r
+ end;\r
+\r
+procedure save_settings;\r
+ var\r
+ rs:recordstore;\r
+ t:integer;\r
+ begin\r
+ deleteRecordStore('S');\r
+ rs:=openRecordStore('S');\r
+ t:=addRecordStoreEntry(rs,version);\r
+ t:=addRecordStoreEntry(rs,''+light_type);\r
+ t:=addRecordStoreEntry(rs,''+ifosad);\r
+ t:=addRecordStoreEntry(rs,''+s_particles);\r
+ t:=addRecordStoreEntry(rs,''+drawgui);\r
+ t:=addRecordStoreEntry(rs,''+s_jpeg_quality);\r
+ t:=addRecordStoreEntry(rs,''+load_key_tex);\r
+ closeRecordStore(rs);\r
+ end;\r
+\r
+function sett_ld_bool(s:string):boolean;\r
+ begin\r
+ if s='true' then sett_ld_bool:=true;\r
+ end;\r
+\r
+procedure load_settings;\r
+ var\r
+ rs:recordstore;\r
+ begin\r
+ rs:=openRecordStore('S');\r
+ if readRecordStoreEntry(rs,1)<>version then\r
+ begin\r
+ debug(readRecordStoreEntry(rs,1));\r
+ closeRecordStore(rs);\r
+ exit;\r
+ end;\r
+ light_type:=stringtointeger(readRecordStoreEntry(rs,2));\r
+ ifosad:=sett_ld_bool(readRecordStoreEntry(rs,3));\r
+ s_particles:=sett_ld_bool(readRecordStoreEntry(rs,4));\r
+ drawgui:=sett_ld_bool(readRecordStoreEntry(rs,5));\r
+ s_jpeg_quality:=stringtointeger(readRecordStoreEntry(rs,6));\r
+ load_key_tex:=stringtointeger(readRecordStoreEntry(rs,7));\r
+ closeRecordStore(rs);\r
+ end;\r
+\r
+function isEOS(c:integer):boolean;\r
+ var\r
+ ch:char;\r
+ begin\r
+ ch:=chr(c);\r
+ if (ch=#$0A) or (ch=#$0D) then\r
+ isEOS:=true;\r
+ end;\r
+\r
+function isSpace(c:integer;):boolean;\r
+ var\r
+ ch:char;\r
+ begin\r
+ ch:=chr(c);\r
+ if ((ch=' ') or (ch=#$09) or (ch=#$0B) or isEOS(c)) then\r
+ isSpace:=true;\r
+ end;\r
+\r
+function nextByte(res:resource):integer;\r
+ var\r
+ i:integer;\r
+ begin\r
+ i:=ReadByte(res);\r
+ if i=EOF then\r
+ EOFstr:=true;\r
+ if isEOS(i) then\r
+ ENDstr:=true;\r
+\r
+ nextByte:=i and $FF;\r
+ end;\r
+\r
+function ReadString(res:resource):string;\r
+ var\r
+ b:integer;\r
+ tmpstr:string;\r
+ begin\r
+ ENDstr:=false;\r
+ repeat\r
+ b:=nextByte(res);\r
+ if EOFstr or ENDstr then\r
+ break;\r
+\r
+ tmpstr:=tmpstr+chr(b);\r
+ forever;\r
+ ReadString:=tmpstr;\r
+ end;\r
+\r
+function nextChar:integer;\r
+ var\r
+ i:integer;\r
+ begin\r
+ ENDstr:=false;\r
+ if length(parseStr)>0 then\r
+ begin\r
+ i:=ord(getChar(parseStr, 0));\r
+ parseStr:=copy(parseStr, 1, length(parseStr));\r
+ if isEOS(i) then\r
+ ENDstr:=true;\r
+ end;\r
+ else\r
+ begin\r
+ parseStr:='';\r
+ ENDstr:=true;\r
+ end;\r
+\r
+ nextChar:=i;\r
+ end;\r
+\r
+procedure clearSpaces;\r
+ var\r
+ i:integer;\r
+ begin\r
+ repeat\r
+ i:=nextChar;\r
+ if ENDstr then\r
+ exit;\r
+\r
+ {Symbol ';' is one line commentary}\r
+ if i=$3B then\r
+ begin\r
+ repeat\r
+ i:=nextChar;\r
+ if ENDstr then\r
+ exit;\r
+ forever;\r
+ end;\r
+\r
+ if isSpace(i)=false then\r
+ begin\r
+ //Go back\r
+ parseStr:=chr(i)+parseStr;\r
+ exit;\r
+ end;\r
+ forever;\r
+ end;\r
+\r
+function nextWord:string;\r
+ var\r
+ str:string;\r
+ i:integer;\r
+ begin\r
+ ENDstr:=false;\r
+ clearSpaces;\r
+ repeat\r
+ i:=nextChar;\r
+\r
+ if ENDstr then\r
+ begin\r
+ nextWord:=str;\r
+ exit;\r
+ end;\r
+\r
+ if isSpace(i) then\r
+ begin\r
+ //Go back\r
+ parseStr:=chr(i)+parseStr;\r
+ nextWord:=str;\r
+ exit;\r
+ end;\r
+ else\r
+ str:=str+chr(i);\r
+ forever;\r
+ end;\r
+\r
+function strToBool(str:string):boolean;\r
+ begin\r
+ str:=UpCase(str);\r
+ if str='TRUE' then\r
+ strToBool:=true;\r
+ else\r
+ if str='FALSE' then\r
+ strToBool:=true;\r
+ else\r
+ if StringToInteger(str)<>0 then\r
+ strToBool:=true;\r
+ else\r
+ strToBool:=false;\r
+ end;\r
+\r
+//Перевод строки в целое число. base - система счисления\r
+function Str2Dec(str:string; base:integer;):integer;\r
+ var\r
+ i, tmp, res:integer;\r
+ ch:char;\r
+ neg:boolean;\r
+ begin\r
+ str:=UpCase(str);\r
+ if GetChar(str, 0)='-' then\r
+ begin\r
+ neg:=true;\r
+ i:=i+1;\r
+ end;\r
+\r
+ for i:=i to length(str)-1 do\r
+ begin\r
+ ch:=GetChar(str, i);\r
+ if ((ch>='0') and (ch<='9')) then\r
+ tmp:=ord(ch)-$30;\r
+ else\r
+ if ((ch>='A') and (ch<=chr($36+base))) then\r
+ tmp:=ord(ch)-$37;\r
+ else\r
+ begin\r
+ addToLog('Error! I cant decode "'+str+'" -> "'+ch+'"');\r
+ Str2Dec:=0;\r
+ exit;\r
+ end;\r
+\r
+ res:=res*base+tmp;\r
+ end;\r
+\r
+ if neg then\r
+ Str2Dec:=-res;\r
+ else\r
+ Str2Dec:=res;\r
+ end;\r
+\r
+function getVar(name:string):integer;\r
+ begin\r
+ name:=UpCase(name);\r
+\r
+ if name='SCREEN_W' then\r
+ getVar:=getWidth;\r
+ else\r
+ if name='SCREEN_H' then\r
+ getVar:=getHeight;\r
+ else\r
+ addToLog('Unknown variable "'+name+'"');\r
+ end;\r
+\r
+procedure setVar(name:string; value:integer);\r
+ begin\r
+ name:=UpCase(name);\r
+\r
+ addToLog('I cant set variable "'+name+'"');\r
+ end;\r
+\r
+function DecodeInt(str:string):integer;\r
+ var\r
+ head:char;\r
+ num:string;\r
+ begin\r
+ if str='' then\r
+ begin\r
+ addToLog('DecodeInt getted null string!');\r
+ DecodeInt:=0;\r
+ exit;\r
+ end;\r
+\r
+ str:=UpCase(str);\r
+ head:=getchar(str, 0);\r
+ num:=copy(str, 1, length(str));\r
+\r
+ if str='TRUE' then\r
+ DecodeInt:=1;\r
+ else\r
+ if str='FALSE' then\r
+ DecodeInt:=0;\r
+ else\r
+ if str='POP' then\r
+ DecodeInt:=popStack;\r
+ else\r
+ if head='$' then\r
+ DecodeInt:=getVar(num);\r
+ else\r
+ if (head='0') and (getchar(str, 1)='X') then\r
+ begin\r
+ DecodeInt:=Str2Dec(copy(str, 2, length(str)), 16);\r
+ end;\r
+ else\r
+ if (head='0') and (length(str)>1) then\r
+ begin\r
+ DecodeInt:=Str2Dec(num, 8);\r
+ end;\r
+ else\r
+ if head='B' then\r
+ begin\r
+ DecodeInt:=Str2Dec(num, 2);\r
+ end;\r
+ else\r
+ if ((head>='0') and (head<='9')) or (head='-') then\r
+ begin\r
+ DecodeInt:=Str2Dec(str, 10);\r
+\r
+ end;\r
+ else\r
+ addToLog('Error! I cant decode "'+str+'"');\r
+ end;\r
+\r
+procedure exeCommand(str:string);\r
+ var\r
+ com, tmp, tmp2:string;\r
+ i:integer;\r
+ begin\r
+ parseStr:=str;\r
+ clearSpaces;\r
+ if parseStr='' then\r
+ exit;\r
+\r
+ com:=UpCase(nextWord);\r
+\r
+ if (cheats) or (autoexec_acces) or (gamemode=1) then\r
+ begin\r
+ if com='TIME' then\r
+ game_time:=decodeInt(nextWord);\r
+ else\r
+ if com='FLY' then\r
+ fly:=strToBool(nextWord);\r
+ else\r
+ if com='PL_HP' then\r
+ hp:=decodeInt(nextWord);\r
+ else\r
+ if com='PL_EP' then\r
+ hunger:=decodeInt(nextWord);\r
+ else\r
+ if com='GIVE' then\r
+ player.dropItem(decodeInt(nextWord), decodeInt(nextWord));\r
+ else\r
+ if com='PL_TP' then\r
+ begin\r
+ player.setX(decodeInt(nextWord));\r
+ player.setY(decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='GAMEMODE' then\r
+ begin\r
+ gamemode:=decodeInt(nextWord);\r
+ fly:=false;\r
+ end;\r
+ else\r
+ {if com='KILL_MOBS' then\r
+ for i:=0 to 31 do\r
+ begin\r
+ mob[i].m_type:=0;\r
+ mob[i].m_hp:=0;\r
+ end;\r
+ else}\r
+ if com='SPAWN' then\r
+ begin\r
+ player.setX(get_spawn_x*16+4);\r
+ player.setY(get_spawn_y*16);\r
+ end;\r
+ else\r
+ {if com='SPAWN_MOBS' then\r
+ s_spawn_mob:=strToBool(nextWord);\r
+ else}\r
+ {if com='SURVIVAL' then\r
+ begin\r
+ fly:=false;\r
+ gamemode:=0;\r
+ hp:=20;\r
+ hunger:=20;\r
+ for i:=0 to 35 do\r
+ begin\r
+ inv[i].item_i:=0;\r
+ inv[i].sum_i:=0;\r
+ end;\r
+ end;\r
+ else}\r
+ if com='CLEAR_INVENTORY' then\r
+ begin\r
+ inv.resetData;\r
+ end;\r
+ else\r
+\r
+ end;\r
+\r
+ if com='I_AM_CHEATER' then\r
+ begin\r
+ if nextWord=#$36+#$36+#$36 then\r
+ cheats:=not cheats;\r
+ else\r
+ cheats:=false;\r
+ end;\r
+ else\r
+ if com='HALT' then\r
+ halt;\r
+ else\r
+ if com='WEATHER' then\r
+ osadki:=strToBool(nextWord);\r
+ else\r
+ {if com='MEGASPAWN' then\r
+ megaspawn;\r
+ else}\r
+ if com='REF_DRP' then\r
+ ref_drp:=strToBool(nextWord);\r
+ else\r
+ if com='BL_UPD' then\r
+ bl_upd:=decodeInt(nextWord);\r
+ else\r
+ if com='GET_DRP' then\r
+ s_get_drp:=strToBool(nextWord);\r
+ else\r
+ {if com='AI_UPD' then\r
+ ai_upd:=strToBool(nextWord);\r
+ else}\r
+ if com='PRT_UPD' then\r
+ particle_upd:=strToBool(nextWord);\r
+ else\r
+ if com='MAX_FPS' then\r
+ s_max_fps:=decodeInt(nextWord); else\r
+ if com='DRW_BACK' then\r
+ drw_back:=strToBool(nextWord);\r
+ else\r
+ {if com='DRW_MOBS' then\r
+ drw_mobs:=strToBool(nextWord);\r
+ else}\r
+ if com='DRP_PHY' then\r
+ drp_phy:=strToBool(nextWord);\r
+ else\r
+ if com='DRW_SM' then\r
+ drw_sm:=strToBool(nextWord);\r
+ else\r
+ if com='JPEG_Q' then\r
+ begin\r
+ s_jpeg_quality:=decodeInt(nextWord);\r
+ if s_jpeg_quality>100 then\r
+ s_jpeg_quality:=100;\r
+ else if s_jpeg_quality<0 then\r
+ s_jpeg_quality:=0;\r
+ end;\r
+ else\r
+ if com='LOAD_SM' then\r
+ load_sm:=decodeInt(nextWord);\r
+ else\r
+ if com='S_WEATHER' then\r
+ ifosad:=strToBool(nextWord);\r
+ else\r
+ if com='S_HIDE_GUI' then\r
+ drawgui:=strToBool(nextWord);\r
+ else\r
+ if com='S_LIGHT' then\r
+ light_type:=decodeInt(nextWord);\r
+ else\r
+ if com='S_PARTICLES' then\r
+ s_particles:=strToBool(nextWord);\r
+ else\r
+ if com='LOAD_SKY' then\r
+ load_sky_siz:=decodeInt(nextWord);\r
+ else\r
+ {if com='LOAD_MOB_TEX' then\r
+ load_mob_tex:=strToBool(nextWord);\r
+ else}\r
+ if com='LOAD_BACK_TEX' then\r
+ load_back_tex:=strToBool(nextWord);\r
+ else\r
+ if com='LOAD_WEATHER_TEX' then\r
+ load_weather_tex:=strToBool(nextWord);\r
+ else\r
+ if com='LOAD_PARTICLES_TEX' then\r
+ load_particles_tex:=strToBool(nextWord);\r
+ else\r
+ if com='LOAD_LIGHT_TEX' then\r
+ load_light_tex:=strToBool(nextWord);\r
+ else\r
+ if com='LOAD_GUI_TEX' then\r
+ load_gui_tex:=strToBool(nextWord);\r
+ else\r
+ if com='MENU_BACKGROUND' then\r
+ menu_background:=decodeInt(nextWord);\r
+ else\r
+ if com='DRW_DRP' then\r
+ drw_drp:=strToBool(nextWord);\r
+ else\r
+ if com='DRW_STARS' then\r
+ drw_stars:=strToBool(nextWord);\r
+ else\r
+ if com='SV_SETT' then\r
+ save_settings;\r
+ else\r
+ if com='LD_SETT' then\r
+ load_settings;\r
+ else\r
+ if com='LOAD_MINIMAP_TEX' then\r
+ load_minimap_tex:=strToBool(nextWord);\r
+ else\r
+ if com='MAX_PARTICLES' then\r
+ begin\r
+ max_particles:=decodeInt(nextWord);\r
+ reset_particles(max_particles+1);\r
+ end;\r
+ else\r
+ if com='EXEC' then\r
+ begin\r
+ tmp:=nextWord;\r
+ exec(nextWord, tmp, autoexec_acces);\r
+ end;\r
+ else\r
+ if com='RESET_ITEMS' then\r
+ begin\r
+ resetItems(decodeInt(nextWord)+1);\r
+ //addToLog('Max items: '+decodeInt(parsed_str[1]));\r
+ end;\r
+ else\r
+ if com='SET_ITEM' then\r
+ begin\r
+ setItemData(decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='RESET_BLOCKS' then\r
+ begin\r
+ resetBlocks(decodeInt(nextWord)+1);\r
+ //addToLog('Max blocks: '+decodeInt(parsed_str[1]));\r
+ end;\r
+ else\r
+ if com='SET_BLOCK' then\r
+ begin\r
+ setBlockData(decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='RESET_TOOLS' then\r
+ begin\r
+ resetTools(decodeInt(nextWord)+1);\r
+ //addToLog('Max tools: '+decodeInt(parsed_str[1]));\r
+ end;\r
+ else\r
+ if com='SET_TOOL' then\r
+ begin\r
+ setToolData(decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='RESET_FUELS' then\r
+ begin\r
+ furnace.setMaxFuel(decodeInt(nextWord));\r
+ //addToLog('Max fuel: '+decodeInt(parsed_str[1]));\r
+ end;\r
+ else\r
+ if com='SET_FUEL' then\r
+ begin\r
+ furnace.initFuel(decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='RESET_RECIPES' then\r
+ begin\r
+ furnace.setMaxRecipes(decodeInt(nextWord));\r
+ //addToLog('Max recipes: '+decodeInt(parsed_str[1]));\r
+ end;\r
+ else\r
+ if com='SET_RECIPE' then\r
+ begin\r
+ furnace.initRecipe(decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='RESET_CRAFTS' then\r
+ begin\r
+ resetCrafts(decodeInt(nextWord));\r
+ //addToLog('Max crafts: '+decodeInt(parsed_str[1]));\r
+ end;\r
+ else\r
+ if com='SET_CRAFT_IN' then\r
+ begin\r
+ setCraftIn(decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='SET_CRAFT_OUT' then\r
+ begin\r
+ setCraftOUT(decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='RESET_BLOCKS_TEX' then\r
+ begin\r
+ initBlockTex(decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='RESET_ITEMS_TEX' then\r
+ begin\r
+ initItemTex(decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='LOAD_TEX' then\r
+ regimg:=ld_tex(nextWord, '/'+sd+'/cavecraft/', '');\r
+ else\r
+ if com='RESET_TEX' then\r
+ resetTmpImg;\r
+ else\r
+ if com='SET_TEX' then\r
+ setTexture(regimg,\r
+ nextWord,\r
+ decodeInt(nextWord));\r
+ if com='SET_CANV_TEX' then\r
+ begin\r
+ tmp:=nextWord;\r
+ tmp2:=nextWord;\r
+ setTexture(rotate_image_from_image(regimg,\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ 0),\r
+ tmp,\r
+ decodeInt(tmp2));\r
+ end;\r
+ else\r
+ if com='SET_MAX_ITEM_LIST' then\r
+ setMaxItemList(decodeInt(nextWord));\r
+ else\r
+ if com='SET_ITEM_LIST' then\r
+ setItemList(decodeInt(nextWord),\r
+ decodeInt(nextWord));\r
+ else\r
+ if com='BIND_KEY' then\r
+ begin\r
+ tmp:=nextWord;\r
+ for i:=0 to MAX_KEY_BIND do\r
+ keyboard.bindKey(decodeInt(tmp), i, decodeInt(nextWord));\r
+ end;\r
+ else\r
+ if com='STACK' then\r
+ resetStack(decodeInt(nextWord));\r
+ else\r
+ if com='PUSH' then\r
+ pushStack(decodeInt(nextWord));\r
+ else\r
+ if com='POP' then\r
+ i:=popStack;\r
+ else\r
+ if com='SWAP' then\r
+ swapStack;\r
+ else\r
+ if com='DUP' then\r
+ dupStack;\r
+ else\r
+ if com='ADD' then\r
+ pushStack(popStack+popStack);\r
+ else\r
+ if com='SUB' then\r
+ begin\r
+ i:=popStack;\r
+ pushStack(popStack-i);\r
+ end;\r
+ else\r
+ if com='MUL' then\r
+ pushStack(popStack*popStack);\r
+ else\r
+ if com='DIV' then\r
+ begin\r
+ i:=popStack;\r
+ pushStack(popStack/i);\r
+ end;\r
+ else\r
+ if com='MOD' then\r
+ begin\r
+ i:=popStack;\r
+ pushStack(popStack mod i);\r
+ end;\r
+ else\r
+ if com='SET' then\r
+ setVar(nextWord, decodeInt(nextWord));\r
+ else\r
+ if com='POPSET' then\r
+ setVar(nextWord, popStack);\r
+ else\r
+ if com='MAX_VKEYS' then\r
+ resetVirtualKeyboard(decodeInt(nextWord));\r
+ else\r
+ if com='SET_VKEY' then\r
+ bindVKey(decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord),\r
+ decodeInt(nextWord));\r
+ else\r
+ if com='SET_RESOLUTION' then\r
+ initVideo(decodeInt(nextWord), decodeInt(nextWord), strToBool(nextWord));\r
+ else\r
+ //addToLog('Unknown command "'+com+'"');\r
+ end;\r
+\r
+procedure call_console;\r
+ var\r
+ commandTxt:integer;\r
+ i, tmpid:integer;\r
+ exitCmd, exeCmd, Clicked:command;\r
+ str:string;\r
+ begin\r
+\r
+ setFont(FONT_FACE_SYSTEM,FONT_STYLE_PLAIN,FONT_SIZE_SMALL);\r
+\r
+ repeat\r
+ ClearForm;\r
+\r
+ exitCmd:=createCommand('Exit', CM_EXIT, 1);\r
+ exeCmd:=createCommand('Execute', CM_OK, 1);\r
+ addCommand(exitCmd);\r
+ addCommand(exeCmd);\r
+\r
+ commandTxt:=formAddTextField('Enter command:', ''+lastCommand, 32, TF_ANY);\r
+\r
+ for i:=0 to CON_LOG_SIZE do\r
+ tmpid:=formAddString(logSTR[i]+chr(10));\r
+\r
+ ShowForm;\r
+ Repaint;\r
+\r
+ repeat\r
+ Clicked:=getClickedCommand;\r
+ if Clicked=exitCmd then\r
+ begin\r
+ lastCommand:=formGetText(commandTxt);\r
+ showCanvas;\r
+ exit;\r
+ end;\r
+ else\r
+ if Clicked=exeCmd then\r
+ begin\r
+ str:=formGetText(commandTxt);\r
+ addToLog(str);\r
+ exeCommand(str);\r
+ lastCommand:='';\r
+ break;\r
+ end;\r
+ forever;\r
+ forever;\r
+ end;\r
+\r
+procedure exec(s, search:string; acces:boolean);\r
+ var\r
+ res:resource;\r
+ str:string;\r
+ tmp_acces, tmpEOF:boolean;\r
+ begin\r
+ tmp_acces:=autoexec_acces;\r
+ autoexec_acces:=acces;\r
+\r
+ search:=UpCase(search);\r
+\r
+ if search='LOCAL' then\r
+ begin\r
+ addToLog('Load file "'+s+'" at LOCAL!');\r
+ res:=OpenResource('/'+s);\r
+ end;\r
+ else\r
+ if search='SD' then\r
+ begin\r
+ if open_file('/'+sd+'/cavecraft/'+s)=1 then\r
+ begin\r
+ addToLog('Load file "'+s+'" at SD!');\r
+ res:=get_stream;\r
+ end;\r
+ end;\r
+ else\r
+ if search='AUTO' then\r
+ begin\r
+ addToLog('path "/'+sd+'/cavecraft/'+s+'"');\r
+ if file_exists('/'+sd+'/cavecraft/'+s)=1 then\r
+ begin\r
+ if open_file('/'+sd+'/cavecraft/'+s)=1 then\r
+ begin\r
+ addToLog('Load file "'+s+'" at SD(AUTO)!');\r
+ res:=get_stream;\r
+ end;\r
+ end;\r
+ else\r
+ begin\r
+ addToLog('Load file "'+s+'" at LOCAL(AUTO)!');\r
+ res:=OpenResource('/'+s);\r
+ end;\r
+ end;\r
+ else\r
+ begin\r
+ addToLog('Unknown load type "'+search+'", file "'+s+'" not executed!');\r
+ autoexec_acces:=tmp_acces;\r
+ exit;\r
+ end;\r
+\r
+ if ResourceAvailable(res) then\r
+ repeat\r
+ str:=ReadString(res);\r
+ tmpEOF:=EOFstr;\r
+ //addToLog('Exec: "'+str+'"');\r
+ exeCommand(str);\r
+ EOFstr:=tmpEOF;\r
+ until EOFstr;\r
+ else\r
+ addToLog('Execute file "'+s+'" not found!');\r
+\r
+ CloseResource(res);\r
+ autoexec_acces:=tmp_acces;\r
+ end;\r
+\r
+initialization\r
+\r
+end.\r
diff --git a/src/craft.mpsrc b/src/craft.mpsrc
--- /dev/null
+++ b/src/craft.mpsrc
@@ -0,0 +1,92 @@
+unit craft;\r
+\r
+interface\r
+ procedure createCraft(id, mode:integer);\r
+ function canCreateCraft(id, mode:integer):boolean;\r
+\r
+implementation\r
+ uses vars, items, func, player, inv, items_store;\r
+\r
+procedure createCraft(id, mode:integer);\r
+ var\r
+ i, j, tmp_sum, tmp_s, item, sum:integer;\r
+ begin\r
+ if canCreateCraft(id, mode)=false then\r
+ exit;\r
+\r
+ //Выпиливаем все необходимые предметы\r
+ for i:=0 to 3 do\r
+ begin\r
+ tmp_sum:=getCraftInSum(id, i);\r
+ for j:=0 to INV_SIZE do\r
+ begin\r
+ item:=inv.getItem(j);\r
+ sum:=inv.getSum(j);\r
+\r
+ if getCraftInItem(id, i)=item then\r
+ begin\r
+ tmp_s:=tmp_sum-sum;\r
+\r
+ if tmp_s<1 then\r
+ begin\r
+ sum:=sum-tmp_sum;\r
+ inv.setSum(sum, j);\r
+ inv.fixNull(j);\r
+ break;\r
+ end;\r
+ else\r
+ begin\r
+ sum:=0;\r
+ tmp_sum:=tmp_s;\r
+ inv.setSum(sum, j);\r
+ inv.fixNull(j);\r
+ end;\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ item:=getCraftOutItem(id);\r
+ sum:=getCraftOutSum(id);\r
+\r
+ sum:=inv.giveItem(item, sum);\r
+ if sum>0 then\r
+ player.dropItem(sum, sum);\r
+ end;\r
+\r
+//Проверка, может ли игрок сделать этот крафт.\r
+function canCreateCraft(id, mode:integer):boolean;\r
+ var\r
+ i, j, tmp_sum:integer;\r
+ canCreate:boolean;\r
+ begin\r
+ //Если место крафта подходит, то продолжаем крафт\r
+ if mode>=getCraftOutFlag(id) then\r
+ canCreate:=true;\r
+ else\r
+ exit;\r
+\r
+ //Проверяем каждую ячейку крафта\r
+ for i:=0 to 3 do\r
+ begin\r
+ //Получаем общуюю сумму подходящего предмета\r
+ tmp_sum:=0;\r
+ if getCraftInItem(id, i)>0 then\r
+ begin\r
+ for j:=0 to INV_SIZE do\r
+ begin\r
+ if getCraftInItem(id, i)=inv.getItem(j) then\r
+ tmp_sum:=tmp_sum+inv.getSum(j);\r
+ end;\r
+\r
+ //Проверяем, подходит ли количество предметов\r
+ if tmp_sum>=getCraftInSum(id, i) then\r
+ canCreate:=canCreate and true;\r
+ else\r
+ exit;\r
+ end;\r
+ end;\r
+\r
+ canCreateCraft:=canCreate;\r
+ end;\r
+\r
+end.\r
diff --git a/src/drop.mpsrc b/src/drop.mpsrc
--- /dev/null
+++ b/src/drop.mpsrc
@@ -0,0 +1,214 @@
+unit drop;\r
+\r
+interface\r
+ var\r
+ drp_phy, drw_drp, ref_drp:boolean;\r
+\r
+ function max:integer;\r
+ function getX(i:integer):integer;\r
+ function getY(i:integer):integer;\r
+ function getW:integer;\r
+ function getH:integer;\r
+ function getItem(i:integer):integer;\r
+ function getSum(i:integer):integer;\r
+ procedure setItem(val, i:integer);\r
+ procedure setSum(val, i:integer);\r
+ function isNull(i:integer):boolean;\r
+ procedure fixNull(i:integer);\r
+\r
+ procedure draw(camx, camy:integer);\r
+ procedure calcPhy;\r
+ procedure reflux;\r
+\r
+ procedure create(item, sum, x, y:integer);\r
+ procedure resetData;\r
+ procedure saveData;\r
+ procedure loadData;\r
+\r
+implementation\r
+ uses phy, jsr75i, vars, items_store, items, func;\r
+ const\r
+ MAX_DROP=255;\r
+ DROP_W=8;\r
+ DROP_H=8;\r
+ var\r
+ drop_x, drop_y, drop_vely: array [0..MAX_DROP] of integer;\r
+ drop_item, drop_sum: array [0..MAX_DROP] of integer;\r
+\r
+ old_drop, ref_drp_count:integer;\r
+\r
+ function max:integer;\r
+ begin\r
+ max:=MAX_DROP;\r
+ end;\r
+\r
+ function getX(i:integer):integer;\r
+ begin\r
+ getX:=drop_x[i];\r
+ end;\r
+\r
+ function getY(i:integer):integer;\r
+ begin\r
+ getY:=drop_y[i];\r
+ end;\r
+\r
+ function getW:integer;\r
+ begin\r
+ getW:=DROP_W;\r
+ end;\r
+\r
+ function getH:integer;\r
+ begin\r
+ getH:=DROP_H;\r
+ end;\r
+\r
+ function getItem(i:integer):integer;\r
+ begin\r
+ getItem:=drop_item[i];\r
+ end;\r
+\r
+ function getSum(i:integer):integer;\r
+ begin\r
+ getSum:=drop_sum[i];\r
+ end;\r
+\r
+ procedure setItem(val, i:integer);\r
+ begin\r
+ drop_item[i]:=val;\r
+ end;\r
+\r
+ procedure setSum(val, i:integer);\r
+ begin\r
+ drop_sum[i]:=val;\r
+ end;\r
+\r
+ function isNull(i:integer):boolean;\r
+ begin\r
+ if (drop_item[i]<1) or (drop_sum[i]<1) then\r
+ isNull:=true;\r
+ end;\r
+\r
+ procedure fixNull(i:integer);\r
+ begin\r
+ if isNull(i) then\r
+ begin\r
+ drop_item[i]:=0;\r
+ drop_sum[i]:=0;\r
+ end;\r
+ end;\r
+\r
+ procedure create(item, sum, x, y:integer);\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to MAX_DROP do\r
+ if isNull(i) then\r
+ begin\r
+ drop_item[i]:=item;\r
+ drop_sum[i]:=sum;\r
+ drop_x[i]:=x;\r
+ drop_y[i]:=y;\r
+ drop_vely[i]:=0;\r
+ exit;\r
+ end;\r
+\r
+ drop_item[old_drop]:=item;\r
+ drop_sum[old_drop]:=sum;\r
+ drop_x[old_drop]:=x;\r
+ drop_y[old_drop]:=y;\r
+ drop_vely[old_drop]:=0;\r
+\r
+ old_drop:=old_drop+1;\r
+ if old_drop>MAX_DROP then\r
+ old_drop:=0;\r
+ end;\r
+\r
+ procedure calcPhy;\r
+ var\r
+ i:integer;\r
+ begin\r
+ if drp_phy then\r
+ for i:=0 to MAX_DROP do\r
+ if isNull(i)=false then\r
+ begin\r
+ phy.loadObject(drop_x[i], drop_y[i], DROP_W, DROP_H, 0, drop_vely[i], false);\r
+ phy.calc(true);\r
+ drop_x[i]:=phy.getX;\r
+ drop_y[i]:=phy.getY;\r
+ drop_vely[i]:=phy.getVelY;\r
+ end;\r
+ end;\r
+\r
+ procedure draw(camx, camy:integer);\r
+ var\r
+ i:integer;\r
+ begin\r
+ if drw_drp then\r
+ for i:=0 to 255 do\r
+ if isNull(i)=false then\r
+ drawSmallItem(drop_item[i], drop_x[i]-camx, drop_y[i]-camy);\r
+ end;\r
+\r
+ procedure reflux;\r
+ var\r
+ i:integer;\r
+ begin\r
+ if ref_drp then\r
+ begin\r
+ for i:=ref_drp_count+1 to MAX_DROP do\r
+ if (isNull(ref_drp_count) and isNull(i))=false then\r
+ if (drop_item[ref_drp_count]=drop_item[i]) and (drop_x[ref_drp_count]=drop_x[i]) and (drop_y[ref_drp_count]=drop_y[i]) then\r
+ begin\r
+ drop_sum[ref_drp_count]:=drop_sum[ref_drp_count]+drop_sum[i];\r
+ drop_item[i]:=0;\r
+ drop_sum[i]:=0;\r
+ end;\r
+\r
+ ref_drp_count:=ref_drp_count+1;\r
+ if ref_drp_count>MAX_DROP then ref_drp_count:=0;\r
+ end;\r
+ end;\r
+\r
+ procedure resetData;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to MAX_DROP do\r
+ begin\r
+ drop_item[i]:=0;\r
+ drop_sum[i]:=0;\r
+ drop_x[i]:=0;\r
+ drop_y[i]:=0;\r
+ drop_vely[i]:=0;\r
+ end;\r
+ end;\r
+\r
+ procedure saveData;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to MAX_DROP do\r
+ begin\r
+ write_byte(drop_item[i]);\r
+ writeint(drop_sum[i]);\r
+ writeint(drop_x[i]);\r
+ writeint(drop_y[i]);\r
+ write_byte(drop_vely[i]);\r
+ end;\r
+ end;\r
+\r
+ procedure loadData;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to MAX_DROP do\r
+ begin\r
+ drop_item[i]:=read_byte;\r
+ drop_sum[i]:=ReadInt;\r
+ drop_x[i]:=ReadInt;\r
+ drop_y[i]:=ReadInt;\r
+ drop_vely[i]:=read_byte;\r
+ end;\r
+ end;\r
+\r
+end.\r
diff --git a/src/func.mpsrc b/src/func.mpsrc
--- /dev/null
+++ b/src/func.mpsrc
@@ -0,0 +1,324 @@
+unit func;\r
+\r
+interface\r
+ function get_spawn_x:integer;//Возвращает блок по X где должен появиться игрок\r
+ function get_spawn_y:integer;//Возвращает блок по Y где должен появиться игрок\r
+ procedure draw_block(xx,yy:integer);\r
+ procedure drawSmallItem(item, x, y:integer);\r
+ procedure drawItem(item, sum, x, y:integer; indicator:boolean;);\r
+ procedure LoadDrawFont(s:string);\r
+ procedure DrawFontTextSpec(str:string; x, y, color:integer; spec:boolean;);\r
+ procedure DrawFontText(str:string; x, y:integer);\r
+function ld_tex(name,path,folder:string):image;\r
+function readint:integer;\r
+procedure writeint(intt:integer);\r
+procedure writebool(bo:boolean);\r
+function readbool:boolean;\r
+procedure writestr(s:string);\r
+function readstr:string;\r
+\r
+implementation\r
+ uses canvas,imgcolor,jsr75i, vars, safeload, items,maps, items_store;\r
+\r
+ //Загрузка изображения из текстурпака, ели такого нет, то происходит загрузка из архива игры\r
+function ld_tex(name,path,folder:string):image;\r
+ begin\r
+ if tex_pack<>'' then\r
+ begin\r
+ if file_exists(path+folder+name)=1 then\r
+ begin\r
+ ld_tex:=safely_load_image_fs(path+folder+name);\r
+ end; else ld_tex:=loadimage('/'+folder+name);\r
+ end;\r
+ if tex_pack='' then ld_tex:=loadimage('/'+folder+name);\r
+ end;\r
+\r
+function readint:integer;\r
+ var\r
+ b:integer;\r
+ begin\r
+ b:=b or (read_uns_byte<<24);\r
+ b:=b or (read_uns_byte<<16);\r
+ b:=b or (read_uns_byte<<8);\r
+ b:=b or (read_uns_byte);\r
+ readint:=b;\r
+ end;\r
+\r
+procedure writeint(intt:integer);\r
+ begin\r
+ write_byte((intt>>24) and $FF);\r
+ write_byte((intt>>16) and $FF);\r
+ write_byte((intt>>8) and $FF);\r
+ write_byte((intt) and $FF);\r
+ end;\r
+\r
+procedure writebool(bo:boolean);\r
+ begin\r
+ if bo=true then\r
+ write_byte(1);\r
+ else\r
+ write_byte(0);\r
+ end;\r
+\r
+function readbool:boolean;\r
+ begin\r
+ readbool:=read_byte>0;\r
+ end;\r
+\r
+procedure writestr(s:string);\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to length(s) do\r
+ write_byte(ord(getChar(s,i)));\r
+ end;\r
+\r
+function readstr:string;\r
+ var\r
+ i,b:integer;\r
+ str:string;\r
+ begin\r
+ repeat\r
+ b:=read_byte;\r
+ if b=0 then break;\r
+ str:=str+chr(b);\r
+ until false;\r
+ readstr:=str;\r
+ end;\r
+\r
+//Получение точки спавна\r
+ function get_spawn_x:integer;\r
+ begin\r
+ get_spawn_x:=(255 div 2);\r
+ end;\r
+\r
+ function get_spawn_y:integer;\r
+ var\r
+ iy:integer;\r
+ begin\r
+ for iy:=0 to 127 do\r
+ if getmap(get_spawn_x,iy)<>0 then begin get_spawn_y:=(iy-2); break; end;\r
+ end;\r
+\r
+ procedure drawSmallItem(item, x, y:integer);\r
+ begin\r
+ if getItemTexType(item)=0 then\r
+ drawimage(tex8[getBlockTex(item)], x, y);\r
+ else\r
+ if getItemTexType(item)=1 then\r
+ drawimage(item8[getItemTex(item)], x, y);\r
+ end;\r
+\r
+ procedure draw_block(xx,yy:integer);\r
+ begin\r
+ if (getmap(xx,yy)=123) or (getmap(xx,yy)=124) then\r
+ begin\r
+ setclip((xx*16)-camx,(yy*16)-camy,16,16);\r
+ if getmapinfo(xx,yy)<9 then drawimage(tex[142],(xx*16)-camx,(yy*16)-camy+(16-getmapinfo(xx,yy)*2)); else\r
+ if getmapinfo(xx,yy)=9 then drawimage(tex[143],(xx*16)-camx,(yy*16)-camy);\r
+ setclip(0,0,getwidth,getheight);\r
+ end; else\r
+ if (getmap(xx,yy)=92) or (getmap(xx,yy)=93) then\r
+ begin\r
+ if (getBlockSet(getmap(xx-1,yy))=false) and (getBlockSet(getmap(xx+1,yy))=true) then setclip((xx*16)-camx,(yy*16)-camy,10,16); else\r
+ if (getBlockSet(getmap(xx+1,yy))=false) and (getBlockSet(getmap(xx-1,yy))=true) then setclip((xx*16)-camx+6,(yy*16)-camy,10,16); else\r
+ if (getBlockSet(getmap(xx+1,yy))=true) and (getBlockSet(getmap(xx-1,yy))=true) then setclip((xx*16)-camx+6,(yy*16)-camy,4,16);\r
+ drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy);\r
+ setclip(0,0,getwidth,getheight);\r
+ end; else\r
+ if getmap(xx,yy)=27 then\r
+ begin\r
+ drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy);\r
+ if getmapinfo(xx,yy)<>0 then begin if random(8)<random(6) then begin setcolor(255,255,255); fillrect((xx*16)-camx,(yy*16)-camy,16,16); end; end;\r
+ end; else\r
+ if getmap(xx,yy)=50 then\r
+ begin\r
+ drawimage(tex[getBlockTex(getmap(xx,yy))+bl_ani5],(xx*16)-camx,(yy*16)-camy);\r
+ end; else\r
+ if getmap(xx,yy)=51 then\r
+ begin\r
+ drawimage(tex[getBlockTex(getmap(xx,yy))+bl_ani5],(xx*16)-camx,(yy*16)-camy);\r
+ end; else\r
+ if getmap(xx,yy)=110 then\r
+ begin\r
+ drawimage(tex[getBlockTex(getmap(xx,yy))+bl_ani5],(xx*16)-camx,(yy*16)-camy);\r
+ end; else\r
+ /*if getmap(xx,yy)=106 then\r
+ begin\r
+ if (furnace_gg[getmapinfo(xx,yy)].f_gor<15) or (furnace_gg[getmapinfo(xx,yy)].f_got>0) then\r
+ drawimage(tex[134],xx*16-camx,yy*16-camy);\r
+ else\r
+ drawimage(tex[get_block(0,getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy);\r
+ end; else*/\r
+ if getmap(xx,yy)=121 then\r
+ begin\r
+ setclip((xx*16)-camx,(yy*16)-camy,getmapinfo(xx,yy),16);\r
+ drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy);\r
+ setclip(0,0,getWidth,getHeight);\r
+ end; else\r
+ if getmap(xx,yy)=122 then\r
+ begin\r
+ drawimage(tex[getBlockTex(getmap(xx,yy))+getmapinfo(xx,yy)],(xx*16)-camx,(yy*16)-camy);\r
+ end; else\r
+ if getmap(xx,yy)<>0 then\r
+ drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy);\r
+ end;\r
+\r
+ procedure drawItem(item, sum, x, y:integer; indicator:boolean;);\r
+ var\r
+ pa_xo,ugol:integer;\r
+ begin\r
+ if sum>0 then\r
+ begin\r
+ if getItemTexType(item)=0 then\r
+ drawimage(tex[getBlockTex(item)], x, y);\r
+ else\r
+ if getItemTexType(item)=1 then\r
+ drawimage(vars.item[getItemTex(item)], x, y);\r
+\r
+ if item=216 then\r
+ begin\r
+ drawimage(compas, x, y);\r
+ setcolor(255,0,0);\r
+ setclip(x+2, y+2, 12, 10);\r
+ if pl_world=0 then\r
+ drawline(get_spawn_x*16-camx, get_spawn_y*16-camy, x+8, y+7);\r
+ else\r
+ if pl_world=1 then\r
+ drawline(random(getWidth), random(getHeight), x+8, y+7);\r
+ setclip(0, 0, getWidth, getheight);\r
+ end;\r
+ else\r
+ if item=215 then\r
+ begin\r
+ drawimage(clock[clock_stage], x, y);\r
+ end;\r
+ end;\r
+\r
+ if (sum>1) and indicator then\r
+ begin\r
+ if getItemIndLine(item) then\r
+ begin\r
+ pa_xo:=10000*16/getItemMax(item)*sum/10000;\r
+ if pa_xo<=3 then\r
+ setcolor(255,0,0);\r
+ else\r
+ setcolor(0,255,0);\r
+ drawline(x, y+14, x+pa_xo, y+14);\r
+ end;\r
+\r
+ if getItemIndNum(item) then\r
+ drawfonttext(''+sum, x, y+8);\r
+ end;\r
+ end;\r
+\r
+\r
+//Загрузка шрифта из файла под именем s\r
+procedure LoadDrawFont(s:string);\r
+ var\r
+ ix:integer;\r
+ im:image;\r
+ begin\r
+ im:=ld_tex('default_font.png', s, '');\r
+ for ix:=0 to FONT_MAX_SYM do\r
+ font[ix]:=rotate_image_from_image(im, ix*FONT_SYM_SIZE, 0, FONT_SYM_SIZE, FONT_SYM_SIZE, 0);\r
+ end;\r
+\r
+//Рисование текста графическим шрифтом\r
+procedure DrawFontTextSpec(str:string; x, y, color:integer; spec:boolean;);\r
+ const\r
+ FONT_UNKNOWN_SYM=$3F;\r
+ FONT_SPEC_SYM=$FFA7;//UTF8\r
+ var\r
+ ch, i, spec_c:integer;\r
+ tch:char;\r
+ begin\r
+ for i:=0 to length(str)-1 do\r
+ begin\r
+ ch:=ord(getChar(str, i));\r
+\r
+ if (spec) and (ch=FONT_SPEC_SYM) then\r
+ begin\r
+ \r
+ i:=i+1;\r
+ if i<=length(str)-2 then\r
+ begin\r
+ ch:=ord(getChar(str, i+1));\r
+ tch:=getChar(UpCase(str), i);\r
+ if tch='0' then\r
+ color:=$FF000000;\r
+ else\r
+ if tch='1' then\r
+ color:=$FF0000AA;\r
+ else\r
+ if tch='2' then\r
+ color:=$FF00AA00;\r
+ else\r
+ if tch='3' then\r
+ color:=$FF00AAAA;\r
+ else\r
+ if tch='4' then\r
+ color:=$FFAA0000;\r
+ else\r
+ if tch='5' then\r
+ color:=$FFAA00AA;\r
+ else\r
+ if tch='6' then\r
+ color:=$FFAA5500;\r
+ else\r
+ if tch='7' then\r
+ color:=$FFAAAAAA;\r
+ else\r
+ if tch='8' then\r
+ color:=$FF555555;\r
+ else\r
+ if tch='9' then\r
+ color:=$FF5555FF;\r
+ else\r
+ if tch='A' then\r
+ color:=$FF55FF55;\r
+ else\r
+ if tch='B' then\r
+ color:=$FF55FFFF;\r
+ else\r
+ if tch='C' then\r
+ color:=$FFFF5555;\r
+ else\r
+ if tch='D' then\r
+ color:=$FFFF55FF;\r
+ else\r
+ if tch='E' then\r
+ color:=$FFFFFF55;\r
+ else\r
+ if tch='F' then\r
+ color:=$FFFFFFFF;\r
+ else\r
+ begin\r
+ i:=i-2;\r
+ ch:=ord(getChar(str, i));\r
+ spec_c:=spec_c-2;\r
+ end;\r
+\r
+ i:=i+1;\r
+ spec_c:=spec_c+2;\r
+ end;\r
+ end;\r
+\r
+ if ch>FONT_MAX_SYM then\r
+ ch:=FONT_UNKNOWN_SYM;\r
+\r
+ if color=FONT_STD_COLOR then\r
+ DrawImage(font[ch],x+((i-spec_c)*FONT_SYM_SIZE),y);\r
+ else\r
+ DrawImage(ReplaceImgColor(font[ch], FONT_STD_COLOR, color), x+((i-spec_c)*FONT_SYM_SIZE), y);\r
+ end;\r
+ end;\r
+\r
+//Рисование текста графическим шрифтом со стандартным цветом\r
+procedure DrawFontText(str:string; x, y:integer);\r
+ begin\r
+ DrawFontTextSpec(str, x, y, FONT_STD_COLOR, true);\r
+ end;\r
+\r
+\r
+end.\r
diff --git a/src/furnace.mpsrc b/src/furnace.mpsrc
--- /dev/null
+++ b/src/furnace.mpsrc
@@ -0,0 +1,369 @@
+unit furnace;\r
+\r
+interface\r
+ const\r
+ MAX_FURNACE=31;\r
+ MAX_FURNACE_CELLS=2;\r
+ \r
+ ITEM_IN_FIRE=10000;\r
+\r
+ FURNACE_IN=0;\r
+ FURNACE_FUEL=1;\r
+ FURNACE_OUT=2;\r
+\r
+ FURNACE_ERROR=-1;\r
+\r
+ procedure setMaxFuel(i:integer);\r
+ procedure setMaxRecipes(i:integer);\r
+ procedure initFuel(id, item, time:integer);\r
+ procedure initRecipe(id, in_item, out_item:integer);\r
+\r
+ function getTime:integer;\r
+ function startFuelTime(furid:integer):integer;\r
+ function endFuelTime(furid:integer):integer;\r
+ function startProgTime(furid:integer):integer;\r
+ function endProgTime(furid:integer):integer;\r
+ function FuelTime(i:integer):integer;\r
+ function ProgTime(i:integer):integer;\r
+\r
+ function GetFurItem(cell, furid:integer;):integer;\r
+ procedure SetFurItem(val, cell, furid:integer;);\r
+ function GetFurSum(cell, furid:integer;):integer;\r
+ procedure SetFurSum(val, cell, furid:integer;);\r
+\r
+ function CreateFurnace(x, y:integer;):integer;\r
+ procedure DestroyFurnace(x, y:integer);\r
+ procedure UpdateFurnaces;\r
+\r
+ function furnaceBurn(i:integer):boolean;\r
+ function itemBurn(i:integer):boolean;\r
+\r
+implementation\r
+ uses maps, drop, items_store, items;\r
+ var\r
+ furnace_b: array [0..MAX_FURNACE] of boolean;\r
+ furnace_item, furnace_sum: array [0..MAX_FURNACE, 0..MAX_FURNACE_CELLS] of integer;\r
+ furnace_fstart, furnace_ftime, furnace_prstart: array [0..MAX_FURNACE] of integer;\r
+\r
+ time:integer;\r
+ maxFuel, maxRecipe:integer;\r
+ fuel_item, fuel_time: array [0..0] of integer;\r
+ recept_in, recept_out: array [0..0] of integer;\r
+\r
+ function getTime:integer;\r
+ begin\r
+ getTime:=time;\r
+ end;\r
+\r
+ procedure UpdateTime;\r
+ begin\r
+ time:=getRelativeTimeMs;\r
+ end;\r
+\r
+ function startFuelTime(i:integer):integer;\r
+ begin\r
+ startFuelTime:=furnace_fstart[i];\r
+ end;\r
+\r
+ function endFuelTime(i:integer):integer;\r
+ begin\r
+ endFuelTime:=furnace_fstart[i]+furnace_ftime[i];\r
+ end;\r
+\r
+ function FuelTime(i:integer):integer;\r
+ begin\r
+ FuelTime:=furnace_ftime[i];\r
+ end;\r
+\r
+ procedure updateFuelTime(fueltime, i:integer);\r
+ begin\r
+ furnace_fstart[i]:=getTime;\r
+ furnace_ftime[i]:=fueltime;\r
+ end;\r
+\r
+ function startProgTime(i:integer):integer;\r
+ begin\r
+ startProgTime:=furnace_prstart[i];\r
+ end;\r
+\r
+ function endProgTime(i:integer):integer;\r
+ begin\r
+ endProgTime:=furnace_prstart[i]+ITEM_IN_FIRE;\r
+ end;\r
+\r
+ function ProgTime(i:integer):integer;\r
+ begin\r
+ ProgTime:=ITEM_IN_FIRE;\r
+ end;\r
+\r
+ procedure setMaxFuel(i:integer;);\r
+ begin\r
+ maxFuel:=i;\r
+ i:=i+1;\r
+ bytecode\r
+ iload 0;\r
+ newarray 10;\r
+ putstatic field 'furnace', 'fuel_item', '[I';\r
+ end;\r
+ bytecode\r
+ iload 0;\r
+ newarray 10;\r
+ putstatic field 'furnace', 'fuel_time', '[I';\r
+ end;\r
+ end;\r
+\r
+ procedure setMaxRecipes(i:integer);\r
+ begin\r
+ maxRecipe:=i;\r
+ i:=i+1;\r
+ bytecode\r
+ iload 0;\r
+ newarray 10;\r
+ putstatic field 'furnace', 'recept_in', '[I';\r
+ end;\r
+ bytecode\r
+ iload 0;\r
+ newarray 10;\r
+ putstatic field 'furnace', 'recept_out', '[I';\r
+ end;\r
+ end;\r
+\r
+ procedure initFuel(id, item, time:integer);\r
+ begin\r
+ fuel_item[id]:=item;\r
+ fuel_time[id]:=time;\r
+ end;\r
+\r
+ procedure initRecipe(id, in_item, out_item:integer);\r
+ begin\r
+ recept_in[id]:=in_item;\r
+ recept_out[id]:=out_item;\r
+ end;\r
+\r
+ procedure ResetProgress(furid:integer);\r
+ begin\r
+ furnace_prstart[furid]:=getTime;\r
+ end;\r
+\r
+ function GetFurItem(cell, furid:integer;):integer;\r
+ begin\r
+ GetFurItem:=furnace_item[furid, cell];\r
+ end;\r
+\r
+ procedure SetFurItem(val, cell, furid:integer;);\r
+ begin\r
+ furnace_item[furid, cell]:=val;\r
+ end;\r
+\r
+ function GetFurSum(cell, furid:integer;):integer;\r
+ begin\r
+ GetFurSum:=furnace_sum[furid, cell];\r
+ end;\r
+\r
+ procedure SetFurSum(val, cell, furid:integer;);\r
+ begin\r
+ furnace_sum[furid, cell]:=val;\r
+ end;\r
+\r
+ function FurCellIsNull(cell, furid:integer;):boolean;\r
+ begin\r
+ if (GetFurItem(cell, furid)<1) or (GetFurSum(cell, furid)<1) then\r
+ FurCellIsNull:=true;\r
+ end;\r
+\r
+ procedure fixNull(cell, furid:integer;);\r
+ begin\r
+ if FurCellIsNull(cell, furid) then\r
+ begin\r
+ SetFurItem(0, cell, furid);\r
+ SetFurSum(0, cell, furid);\r
+ end;\r
+ end;\r
+\r
+ function CreateFurnace(x, y:integer;):integer;\r
+ var\r
+ i, j:integer;\r
+ begin\r
+ for i:=0 to MAX_FURNACE do\r
+ if furnace_b[i]=false then\r
+ begin\r
+ furnace_b[i]:=true;\r
+ for j:=0 to MAX_FURNACE_CELLS do\r
+ begin\r
+ furnace_item[i, j]:=0;\r
+ furnace_sum[i, j]:=0;\r
+ end;\r
+ furnace_fstart[i]:=getTime;\r
+ furnace_ftime[i]:=0;\r
+ furnace_prstart[i]:=getTime;\r
+ setMapInfo(i, x, y);\r
+ CreateFurnace:=i;\r
+ exit;\r
+ end;\r
+ CreateFurnace:=FURNACE_ERROR;\r
+ end;\r
+\r
+ function FindFuel(furid:integer):integer;\r
+ var\r
+ i:integer;\r
+ begin\r
+ if FurCellIsNull(FURNACE_FUEL, furid)=false then\r
+ for i:=0 to maxFuel do\r
+ if GetFurItem(FURNACE_FUEL, furid)=fuel_item[i] then\r
+ begin\r
+ FindFuel:=i;\r
+ exit;\r
+ end;\r
+ FindFuel:=FURNACE_ERROR;\r
+ end;\r
+\r
+ procedure DestroyFurnace(x, y:integer);\r
+ var\r
+ i, j:integer;\r
+ begin\r
+ i:=getMapInfo(x, y);\r
+ furnace_b[i]:=false;\r
+ for j:=0 to MAX_FURNACE_CELLS do\r
+ begin\r
+ if FurCellIsNull(j, i)=false then\r
+ drop.create(furnace_item[i, j], furnace_sum[i, j], x*16+4, y*16+4)\r
+ furnace_item[i, j]:=0;\r
+ furnace_sum[i, j]:=0;\r
+ end;\r
+ furnace_fstart[i]:=getTime;\r
+ furnace_ftime[i]:=0;\r
+ furnace_prstart[i]:=getTime;\r
+ end;\r
+\r
+ function GetReceptOut(in_item:integer;):integer;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to maxRecipe do\r
+ if in_item=recept_in[i] then\r
+ begin\r
+ GetReceptOut:=recept_out[i];\r
+ exit;\r
+ end;\r
+ GetReceptOut:=FURNACE_ERROR;\r
+ end;\r
+\r
+ function canUpdate(i:integer):boolean;\r
+ var\r
+ itemIN, itemOUT, sumOUT, recipeOUT:integer;\r
+ begin\r
+ fixNull(FURNACE_IN, i);\r
+ fixNull(FURNACE_OUT, i);\r
+\r
+ itemIN:=GetFurItem(FURNACE_IN, i);\r
+ itemOUT:=GetFurItem(FURNACE_OUT, i);\r
+ sumOUT:=GetFurSum(FURNACE_OUT, i);\r
+ recipeOUT:=GetReceptOut(itemIN);\r
+\r
+ if (itemIN<>0) and (recipeOUT<>FURNACE_ERROR) then\r
+ if (itemOUT=0) or ((itemOUT=recipeOUT) and (sumOUT<getItemMax(itemOUT))) then\r
+ canUpdate:=true;\r
+ end;\r
+\r
+ function furnaceBurn(i:integer):boolean;\r
+ begin\r
+ if (getTime>=startFuelTime(i)) and (getTime<=endFuelTime(i)) then\r
+ furnaceBurn:=true;\r
+ end;\r
+\r
+ function itemBurn(i:integer):boolean;\r
+ begin\r
+ if FurCellIsNull(FURNACE_IN, i)=false then\r
+ if (getTime>=startProgTime(i)) and (getTime<=endProgTime(i)) then\r
+ itemBurn:=true;\r
+ end;\r
+\r
+ procedure useFuel(i:integer;);\r
+ var\r
+ fuelid, item, sum:integer;\r
+ begin\r
+ fuelid:=FindFuel(i);\r
+ item:=GetFurItem(FURNACE_FUEL, i);\r
+ sum:=GetFurSum(FURNACE_FUEL, i);\r
+\r
+ if getItemDiv(item) then\r
+ begin\r
+ sum:=sum-1;\r
+ if sum<0 then\r
+ item:=0;\r
+ end;\r
+ else\r
+ begin\r
+ item:=0;\r
+ sum:=0;\r
+ end;\r
+\r
+ updateFuelTime(fuel_time[fuelid], i);\r
+\r
+ SetFurItem(item, FURNACE_FUEL, i);\r
+ SetFurSum(sum, FURNACE_FUEL, i);\r
+ end;\r
+\r
+ procedure createOutItem(i:integer);\r
+ var\r
+ itemIN, sumIN, itemOUT, sumOUT, recipeOUT:integer;\r
+ begin\r
+ itemIN:=GetFurItem(FURNACE_IN, i);\r
+ sumIN:=GetFurSum(FURNACE_IN, i);\r
+ itemOUT:=GetFurItem(FURNACE_OUT, i);\r
+ sumOUT:=GetFurSum(FURNACE_OUT, i);\r
+ recipeOUT:=GetReceptOut(itemIN);\r
+\r
+ if getItemDiv(itemIN) then\r
+ begin\r
+ sumIN:=sumIN-1;\r
+ if sumIN<0 then\r
+ itemIN:=0;\r
+ end;\r
+ else\r
+ begin\r
+ itemIN:=0;\r
+ sumIN:=0;\r
+ end;\r
+\r
+ itemOUT:=recipeOUT;\r
+ sumOUT:=sumOUT+1;\r
+\r
+ SetFurItem(itemIN, FURNACE_IN, i);\r
+ SetFurSum(sumIN, FURNACE_IN, i);\r
+ SetFurItem(itemOUT, FURNACE_OUT, i);\r
+ SetFurSum(sumOUT, FURNACE_OUT, i);\r
+ end;\r
+\r
+ procedure UpdateFurnaces;\r
+ var\r
+ i, fuelid:integer;\r
+ begin\r
+ for i:=0 to MAX_FURNACE do\r
+ if furnace_b[i] then\r
+ if canUpdate(i) then\r
+ begin\r
+ if furnaceBurn(i) then\r
+ begin\r
+ if itemBurn(i)=false then\r
+ begin\r
+ createOutItem(i);\r
+ ResetProgress(i);\r
+ end;\r
+ end;\r
+ else\r
+ begin\r
+ fuelid:=FindFuel(i);\r
+ if fuelid=FURNACE_ERROR then\r
+ ResetProgress(i);\r
+ else\r
+ useFuel(i);\r
+ end;\r
+ end;\r
+ else\r
+ ResetProgress(i);\r
+\r
+ UpdateTime;\r
+ end;\r
+\r
+end.\r
diff --git a/src/gameui.mpsrc b/src/gameui.mpsrc
--- /dev/null
+++ b/src/gameui.mpsrc
@@ -0,0 +1,99 @@
+unit gameui;\r
+\r
+interface\r
+ const\r
+ UI_MAX_STACK=2;//3\r
+ UI_MAX_ELEMENTS=62;//63\r
+\r
+ UI_TYPE_NULL=0;\r
+\r
+ UI_ERROR=-1;\r
+\r
+ procedure NewUILayer;\r
+ procedure DelUILayer;\r
+ function addUIElement(el_type, x, y:integer):integer;\r
+ procedure delUIElement(i:integer);\r
+ procedure clearUIElements;\r
+ function getUIx(i:integer):integer;\r
+ function getUIy(i:integer):integer;\r
+ function getUIw(i:integer):integer;\r
+ function getUIh(i:integer):integer;\r
+\r
+implementation\r
+//Main UI functions and vars\r
+ var\r
+ layer:integer;\r
+ ui_type: array [0..UI_MAX_STACK, 0..UI_MAX_ELEMENTS] of integer;\r
+ ui_x: array [0..UI_MAX_STACK, 0..UI_MAX_ELEMENTS] of integer;\r
+ ui_y: array [0..UI_MAX_STACK, 0..UI_MAX_ELEMENTS] of integer;\r
+\r
+ procedure NewUILayer;\r
+ begin\r
+ layer:=layer+1;\r
+ //Test\r
+ ui_type[layer, 0]:=ui_type[layer, 0];\r
+ end;\r
+\r
+ procedure DelUILayer;\r
+ begin\r
+ layer:=layer-1;\r
+ //Test\r
+ ui_type[layer, 0]:=ui_type[layer, 0];\r
+ end;\r
+\r
+ //Return id added element or UI_ERROR\r
+ function addUIElement(el_type, x, y:integer):integer;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to UI_MAX_ELEMENTS do\r
+ if ui_type[layer, i]=UI_TYPE_NULL then\r
+ begin\r
+ ui_type[layer, i]:=el_type;\r
+ ui_x[layer, i]:=x;\r
+ ui_y[layer, i]:=y;\r
+ addUIElement:=i;\r
+ exit;\r
+ end;\r
+\r
+ addUIElement:=UI_ERROR;\r
+ end;\r
+\r
+ procedure delUIElement(i:integer);\r
+ begin\r
+ ui_type[layer, i]:=UI_TYPE_NULL;\r
+ ui_x[layer, i]:=0;\r
+ ui_y[layer, i]:=0;\r
+ end;\r
+\r
+ procedure clearUIElements;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to UI_MAX_ELEMENTS do\r
+ delUIElement(i);\r
+ end;\r
+\r
+ function getUIx(i:integer):integer;\r
+ begin\r
+ getUIx:=ui_x[layer, i];\r
+ end;\r
+\r
+ function getUIy(i:integer):integer;\r
+ begin\r
+ getUIy:=ui_y[layer, i];\r
+ end;\r
+\r
+ function getUIw(i:integer):integer;\r
+ begin\r
+ getUIw:=0;\r
+ end;\r
+\r
+ function getUIh(i:integer):integer;\r
+ begin\r
+ getUIh:=0;\r
+ end;\r
+\r
+initialization\r
+\r
+end.\r
diff --git a/src/inv.mpsrc b/src/inv.mpsrc
--- /dev/null
+++ b/src/inv.mpsrc
@@ -0,0 +1,148 @@
+unit inv;\r
+\r
+interface\r
+ const\r
+ INV_SIZE=35;\r
+\r
+\r
+ function getItem(i:integer):integer;\r
+ function getSum(i:integer):integer;\r
+ procedure setItem(val, i:integer);\r
+ procedure setSum(val, i:integer);\r
+ function isNull(i:integer):boolean;\r
+ procedure fixNull(i:integer);\r
+\r
+ function giveItem(ityp, isum:integer):integer;\r
+\r
+ procedure resetData;\r
+ procedure saveData;\r
+ procedure loadData;\r
+\r
+implementation\r
+ uses items_store, vars, jsr75i, items, func;\r
+ var\r
+ inv_item: array [0..INV_SIZE] of integer;\r
+ inv_sum: array [0..INV_SIZE] of integer;\r
+\r
+ function getItem(i:integer):integer;\r
+ begin\r
+ getItem:=inv_item[i];\r
+ end;\r
+\r
+ function getSum(i:integer):integer;\r
+ begin\r
+ getSum:=inv_sum[i];\r
+ end;\r
+\r
+ procedure setItem(val, i:integer);\r
+ begin\r
+ inv_item[i]:=val;\r
+ end;\r
+\r
+ procedure setSum(val, i:integer);\r
+ begin\r
+ inv_sum[i]:=val;\r
+ end;\r
+\r
+ function isNull(i:integer):boolean;\r
+ begin\r
+ if (getItem(i)<1) or (getSum(i)<1) then\r
+ isNull:=true;\r
+ end;\r
+\r
+ procedure fixNull(i:integer);\r
+ begin\r
+ if isNull(i) then\r
+ begin\r
+ setItem(0, i);\r
+ setSum(0, i);\r
+ end;\r
+ end;\r
+\r
+ //Добавить предмет в инвентарь, возващает количество не полученых предметов.\r
+function giveItem(ityp, isum:integer):integer;\r
+ var\r
+ i, item, sum:integer;\r
+ begin\r
+ //Ищем такой же предмет только если он имеет возможность делиться\r
+ if getItemDiv(ityp) then\r
+ for i:=0 to INV_SIZE do\r
+ begin\r
+ item:=getItem(i);\r
+ sum:=getSum(i);\r
+\r
+ if (item=ityp) and (isNull(i)=false) then\r
+ if isum<getItemMax(ityp) then\r
+ begin\r
+ sum:=sum+isum;\r
+ isum:=0;\r
+\r
+ if sum>getItemMax(ityp) then\r
+ begin\r
+ isum:=sum-getItemMax(ityp);\r
+ sum:=sum-isum;\r
+ end;\r
+\r
+ setSum(sum, i);\r
+\r
+ if isum<1 then\r
+ exit;\r
+ end;\r
+ end;\r
+\r
+ for i:=0 to INV_SIZE do\r
+ if isNull(i) then\r
+ begin\r
+ sum:=isum;\r
+ isum:=0;\r
+\r
+ if sum>getItemMax(ityp) then\r
+ begin\r
+ isum:=sum-getItemMax(ityp);\r
+ sum:=sum-isum;\r
+ end;\r
+\r
+ setItem(ityp, i);\r
+ setSum(sum, i);\r
+\r
+ if isum<1 then\r
+ exit;\r
+ end;\r
+\r
+ giveItem:=isum;\r
+ end;\r
+\r
+ procedure resetData;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to INV_SIZE do\r
+ begin\r
+ setItem(0, i);\r
+ setSum(0, i);\r
+ end;\r
+ end;\r
+\r
+ procedure saveData;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to INV_SIZE do\r
+ begin\r
+ write_byte(getItem(i));\r
+ WriteInt(getSum(i));\r
+ end;\r
+ end;\r
+\r
+ procedure loadData;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to INV_SIZE do\r
+ begin\r
+ setItem(read_byte, i);\r
+ setSum(ReadInt, i);\r
+ end;\r
+ end;\r
+\r
+end.\r
diff --git a/src/invui.mpsrc b/src/invui.mpsrc
--- /dev/null
+++ b/src/invui.mpsrc
@@ -0,0 +1,859 @@
+unit invui;\r
+\r
+interface\r
+ procedure OpenFurnaceWindow(furid:integer);\r
+ procedure OpenFastCraftWindow(mode:integer);\r
+ procedure OpenChestWindow(n:integer;);\r
+ procedure OpenCreativeWindow;\r
+ procedure OpenPlayerInventory;\r
+ procedure DrawWindows;\r
+ function WindowKeyHanler:boolean;\r
+\r
+implementation\r
+ uses vars, CellUI, console, Canvas, items, utils, craft, furnace, func, items_store, player, keyboard;\r
+ const\r
+ WINDOW_PLAYER_INV=1;\r
+ WINDOW_DIV_ITEMS=2;\r
+ WINDOW_CEATIVE_INV=3;\r
+ WINDOW_CHEST_INV=4;\r
+ WINDOW_FASTCRAFT=5;\r
+ WINDOW_FURNACE=6;\r
+\r
+ INV_MODE_SELECT1=0;\r
+ INV_MODE_SELECT2=1;\r
+ INV_MODE_SELECT2_DIV=2;\r
+\r
+ MAX_CREATIVE_OFFSET=248;//32*8-8\r
+ MAX_FASTCRAFT_OFFSET=232;//24*10-8\r
+\r
+ WINDOW_INFO_INVMODE=0;\r
+ WINDOW_INFO_DIVRES=1;\r
+ WINDOW_INFO_FUR_ID=2;\r
+\r
+ WINDOW_INFO_DIV_ITEM=0;\r
+ WINDOW_INFO_DIV_SUM1=1;\r
+ WINDOW_INFO_DIV_SUM2=2;\r
+\r
+ WINDOW_INFO_FC_MODE=0;\r
+\r
+ var\r
+ InvWindowImg:image;\r
+ DivWindowImg, DivScrollImg:image;\r
+ CrWindowImg, CrScrollImg:image;\r
+ ChestWindowImg:image;\r
+ fcWindowImg, fcScrollImg, fcCanCraftImg:image;\r
+ furWindowImg, furFireImg, furProgressImg:image;\r
+\r
+ function calcScrollBar(scrollSize, buttonSize, maxEl, currentEl:integer):integer;\r
+ const\r
+ DivAccuracy=100000;\r
+ begin\r
+ if (currentEl=0) or (maxEl=0) then\r
+ calcScrollBar:=0;\r
+ else\r
+ if (currentEl<>maxEl) then\r
+ calcScrollBar:=DivAccuracy*(scrollSize-buttonSize)/maxEl*currentEl/DivAccuracy;\r
+ else\r
+ calcScrollBar:=scrollSize-buttonSize;\r
+ end;\r
+\r
+ procedure OpenFurnaceWindow(furid:integer);\r
+ var\r
+ i, j, id:integer;\r
+ begin\r
+ NewLayer;\r
+ SetWindowType(WINDOW_FURNACE);\r
+ SetCurActive(true, CUR_SELECT1);\r
+\r
+ SetWindowInfo(furid, WINDOW_INFO_FUR_ID);\r
+\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ furWindowImg:=ld_tex('furnace.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/');\r
+ furFireImg:=rotate_image_from_image(furWindowImg, 0, 166, 14, 14, 0);\r
+ furProgressImg:=rotate_image_from_image(furWindowImg, 14, 166, 24, 17, 0);\r
+ furWindowImg:=rotate_image_from_image(furWindowImg, 0, 0, 176, 166, 0);\r
+ end;\r
+\r
+ for j:=0 to 8 do\r
+ begin\r
+ initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18, true);\r
+ id:=id+1;\r
+ end;\r
+\r
+ for i:=1 to 3 do\r
+ for j:=0 to 8 do\r
+ begin\r
+ initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18+4, true);\r
+ id:=id+1;\r
+ end;\r
+\r
+ initCell(CELL_TYPE_FURNACE, FURNACE_IN, 0, furid, 56, 97, true);\r
+ initCell(CELL_TYPE_FURNACE, FURNACE_FUEL, 0, furid, 56, 133, true);\r
+ initCell(CELL_TYPE_FURNACE, FURNACE_OUT, 0, furid, 116, 115, true);\r
+ end;\r
+\r
+ procedure DrawFurnaceWindow(x, y:integer);\r
+ var\r
+ furid, i, time:integer;\r
+ begin\r
+ furid:=GetWindowInfo(WINDOW_INFO_FUR_ID);\r
+\r
+ DrawImage(furWindowImg, x, y);\r
+\r
+ time:=furnace.getTime;\r
+ if furnaceBurn(furid) then\r
+ begin\r
+ i:=calcScrollBar(14, 0, furnace.FuelTime(furid), furnace.endFuelTime(furid)-time);\r
+ debug('i: '+i+'; time: '+time+'; fueltime:'+furnace.FuelTime(furid)+'; c: '+(furnace.endFuelTime(furid)-time));\r
+ SetClip(x+56, y+130-i, 18, i);\r
+ DrawImage(furFireImg, x+56, y+116);\r
+\r
+ if itemBurn(furid) then\r
+ begin\r
+ i:=calcScrollBar(24, 0, furnace.ProgTime(furid), furnace.endProgTime(furid)-time);\r
+\r
+ SetClip(x+79, y+114, 24-i, 17);\r
+ DrawImage(furProgressImg, x+79, y+114);\r
+ end;\r
+\r
+ SetClip(0, 0, getWidth, getHeight);\r
+ end;\r
+\r
+ end;\r
+\r
+ procedure CloseFurnaceWindow;\r
+ var\r
+ nullimg:image;\r
+ begin\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ furWindowImg:=nullimg;\r
+ furFireImg:=nullimg;\r
+ furProgressImg:=nullimg;\r
+ end;\r
+ DelLayer;\r
+ end;\r
+\r
+ procedure OpenFastCraftWindow(mode:integer);\r
+ var\r
+ i, j, id:integer;\r
+ begin\r
+ NewLayer;\r
+ SetWindowType(WINDOW_FASTCRAFT);\r
+ SetCurActive(true, CUR_SELECT1);\r
+\r
+ SetWindowInfo(mode, WINDOW_INFO_FC_MODE);\r
+\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ fcWindowImg:=ld_tex('fastcraft.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/');\r
+ fcScrollImg:=rotate_image_from_image(fcWindowImg, 0, 126, 12, 15, 0);\r
+ fcCanCraftImg:=rotate_image_from_image(fcWindowImg, 12, 126, 20, 18, 0);\r
+ fcWindowImg:=rotate_image_from_image(fcWindowImg, 0, 0, 176, 126, 0);\r
+ end;\r
+\r
+ for i:=0 to 2 do\r
+ for j:=0 to 7 do\r
+ begin\r
+ initCell(CELL_TYPE_FASTCRAFT, id, 0, -1, 8+j*18, 66+i*18, false);\r
+ id:=id+1;\r
+ end;\r
+ end;\r
+\r
+ procedure DrawFastCraftWindow(x, y:integer);\r
+ var\r
+ mode, craftid:integer;\r
+ i, j, id:integer;\r
+ begin\r
+ mode:=GetWindowInfo(WINDOW_INFO_FC_MODE);\r
+ craftid:=getCellID(GetCurIndex(GetCur))+GetOffset(0);//FIX IT! Indexes\r
+\r
+ DrawImage(fcWindowImg, x, y);\r
+ if canCreateCraft(craftid, mode) then\r
+ DrawImage(fcCanCraftImg, x+87, y+26);\r
+\r
+ for i:=0 to 1 do\r
+ for j:=0 to 1 do\r
+ begin\r
+ drawItem(getCraftInItem(craftid, id), getCraftInSum(craftid, id), x+52+j*18, y+17+i*18, true);\r
+ id:=id+1;\r
+ end;\r
+\r
+ drawItem(getCraftOutItem(craftid), getCraftOutSum(craftid), x+108, y+27, true);\r
+\r
+ i:=calcScrollBar(52, getImageHeight(fcScrollImg), MAX_FASTCRAFT_OFFSET, getOffset(0));\r
+ drawimage(fcScrollImg, x+156, y+66+i);\r
+ end;\r
+\r
+ procedure CloseFastCraftWindow;\r
+ var\r
+ nullimg:image;\r
+ begin\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ fcWindowImg:=nullimg;\r
+ fcScrollImg:=nullimg;\r
+ fcCanCraftImg:=nullimg;\r
+ end;\r
+ DelLayer;\r
+ end;\r
+\r
+ procedure FindFastCraftUD(n:integer;);\r
+ var\r
+ old_cur, offset:integer;\r
+ begin\r
+ old_cur:=GetCurIndex(GetCur);\r
+ offset:=getOffset(0);\r
+\r
+ if n<0 then\r
+ ShiftCurrentCur(FIND_CELL_UP);\r
+ if n>0 then\r
+ ShiftCurrentCur(FIND_CELL_DOWN);\r
+\r
+ if old_cur=GetCurIndex(GetCur) then\r
+ begin\r
+ if n<0 then\r
+ begin\r
+ offset:=offset-8;\r
+ if offset<0 then\r
+ offset:=0;\r
+ end;\r
+ else\r
+ if n>0 then\r
+ begin\r
+ offset:=offset+8;\r
+ if offset>MAX_FASTCRAFT_OFFSET then\r
+ offset:=MAX_FASTCRAFT_OFFSET;\r
+ end;\r
+ end;\r
+\r
+ SetOffset(offset, 0);\r
+ end;\r
+\r
+ procedure OpenChestWindow(n:integer;);\r
+ var\r
+ i, j, id:integer;\r
+ begin\r
+ NewLayer;\r
+ SetWindowType(WINDOW_CHEST_INV);\r
+ SetCurActive(true, CUR_SELECT1);\r
+\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ ChestWindowImg:=ld_tex('container.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/');\r
+ end;\r
+\r
+ for j:=0 to 8 do\r
+ begin\r
+ initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18, true);\r
+ id:=id+1;\r
+ end;\r
+\r
+ for i:=1 to 3 do\r
+ for j:=0 to 8 do\r
+ begin\r
+ initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18+4, true);\r
+ id:=id+1;\r
+ end;\r
+\r
+ id:=0;\r
+ for i:=0 to 2 do\r
+ for j:=0 to 8 do\r
+ begin\r
+ initCell(CELL_TYPE_CHEST, id, 0, n, 8+j*18, 88+i*18, true);\r
+ id:=id+1;\r
+ end;\r
+ end;\r
+\r
+ procedure CloseChestWindow;\r
+ var\r
+ nullimg:image;\r
+ begin\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ ChestWindowImg:=nullimg;\r
+ end;\r
+ DelLayer;\r
+ end;\r
+\r
+ procedure OpenCreativeWindow;\r
+ var\r
+ i, j, id:integer;\r
+ begin\r
+ NewLayer;\r
+ SetWindowType(WINDOW_CEATIVE_INV);\r
+ SetCurActive(true, CUR_SELECT1);\r
+\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ CrWindowImg:=ld_tex('creative.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/');\r
+ CrScrollImg:=rotate_image_from_image(CrWindowImg, 0, 108, 12, 15, 0);\r
+ CrWindowImg:=rotate_image_from_image(CrWindowImg, 0, 0, 176, 108, 0);\r
+ end;\r
+\r
+ for j:=0 to 8 do\r
+ begin\r
+ initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18, true);\r
+ id:=id+1;\r
+ end;\r
+\r
+ id:=0;\r
+ for i:=0 to 3 do\r
+ for j:=0 to 7 do\r
+ begin\r
+ initCell(CELL_TYPE_CREWATIVE_INV, id, 1, -1, 8+j*18, 30+i*18, false);\r
+ id:=id+1;\r
+ end;\r
+ end;\r
+\r
+ procedure DrawCreativeWindow(x, y:integer;);\r
+ var\r
+ scroll, i:integer;\r
+ begin\r
+ DrawImage(CrWindowImg, x, y);\r
+ scroll:=getOffset(1);\r
+ i:=calcScrollBar(70, getImageHeight(CrScrollImg), MAX_CREATIVE_OFFSET, scroll);\r
+ drawimage(CrScrollImg, x+156, y+30+i);\r
+ end;\r
+\r
+ procedure FindCeativeUD(n:integer;);\r
+ var\r
+ old_cur, offset:integer;\r
+ begin\r
+ old_cur:=GetCurIndex(GetCur);\r
+ offset:=getOffset(1);\r
+\r
+ if n<0 then\r
+ ShiftCurrentCur(FIND_CELL_UP);\r
+ if n>0 then\r
+ ShiftCurrentCur(FIND_CELL_DOWN);\r
+\r
+ if old_cur=GetCurIndex(GetCur) then\r
+ begin\r
+ if n<0 then\r
+ begin\r
+ offset:=offset-8;\r
+ if offset<0 then\r
+ offset:=0;\r
+ end;\r
+ else\r
+ if n>0 then\r
+ begin\r
+ offset:=offset+8;\r
+ if offset>MAX_CREATIVE_OFFSET then\r
+ offset:=MAX_CREATIVE_OFFSET;\r
+ end;\r
+ end;\r
+\r
+ SetOffset(offset, 1);\r
+ end;\r
+\r
+ procedure CloseCreativeWindow;\r
+ var\r
+ nullimg:image;\r
+ begin\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ CrWindowImg:=nullimg;\r
+ CrScrollImg:=nullimg;\r
+ end;\r
+ DelLayer;\r
+ end;\r
+\r
+ procedure OpenDivWindow;\r
+ var\r
+ item, sum:integer;\r
+ begin\r
+ debug('Open Div Window');\r
+ item:=getItem(GetCurIndex(GetCur));\r
+ sum:=getSum(GetCurIndex(GetCur));\r
+\r
+ NewLayer;\r
+ SetWindowType(WINDOW_DIV_ITEMS);\r
+\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ DivWindowImg:=ld_tex('partition.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/');\r
+ DivScrollImg:=rotate_image_from_image(DivWindowImg, 0, 50, 15, 12, 0);\r
+ DivWindowImg:=rotate_image_from_image(DivWindowImg, 0, 0, 88, 50, 0);\r
+ end;\r
+\r
+ SetWindowInfo(item, WINDOW_INFO_DIV_ITEM);\r
+ SetWindowInfo(sum, WINDOW_INFO_DIV_SUM1);\r
+ end;\r
+\r
+ procedure DivScroll(pp:integer);\r
+ var\r
+ sum1, sum2:integer;\r
+ begin\r
+ sum1:=GetWindowInfo(WINDOW_INFO_DIV_SUM1);\r
+ sum2:=GetWindowInfo(WINDOW_INFO_DIV_SUM2);\r
+\r
+ sum2:=sum2+pp;\r
+ if sum2<0 then\r
+ sum2:=0;\r
+ if sum2>sum1 then\r
+ sum2:=sum1;\r
+\r
+ SetWindowInfo(sum2, WINDOW_INFO_DIV_SUM2);\r
+ end;\r
+\r
+ procedure DrawDivWindow(x, y:integer);\r
+ var\r
+ i, item, sum1, sum2:integer;\r
+ begin\r
+ DrawImage(DivWindowImg, x, y);\r
+\r
+ item:=GetWindowInfo(WINDOW_INFO_DIV_ITEM);\r
+ sum1:=GetWindowInfo(WINDOW_INFO_DIV_SUM1);\r
+ sum2:=GetWindowInfo(WINDOW_INFO_DIV_SUM2);\r
+\r
+ drawItem(item, (sum1-sum2), x+8, y+8, true);\r
+ drawItem(item, sum2, x+64, y+8, true);\r
+\r
+ i:=calcScrollBar(72, getImageWidth(DivScrollImg), sum1, sum2);\r
+\r
+ drawimage(DivScrollImg, x+8+i, y+30);\r
+ end;\r
+\r
+ procedure CloseDivWindow(return_val:boolean);\r
+ var\r
+ res:integer;\r
+ nullimg:image;\r
+ begin\r
+ debug('Close Div Window');\r
+ res:=GetWindowInfo(WINDOW_INFO_DIV_SUM2);\r
+ //Если таких окон нет, то чистим память\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ DivWindowImg:=nullimg;\r
+ DivScrollImg:=nullimg;\r
+ end;\r
+ DelLayer;\r
+ SetWindowInfo(res, WINDOW_INFO_DIVRES);\r
+\r
+ if return_val then\r
+ begin\r
+ SetCur(CUR_SELECT2);\r
+ SetCurActive(true, CUR_SELECT2);\r
+ SetCurIndex(GetCurIndex(CUR_SELECT1), CUR_SELECT2);\r
+ SetWindowInfo(INV_MODE_SELECT2_DIV, WINDOW_INFO_INVMODE);\r
+ end;\r
+ end;\r
+\r
+ procedure OpenPlayerInventory;\r
+ var\r
+ i, j, id:integer;\r
+ begin\r
+ NewLayer;\r
+ SetWindowType(WINDOW_PLAYER_INV);\r
+ SetCurActive(true, CUR_SELECT1);\r
+\r
+ //Если таких окон нет, то загружаем графику\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ InvWindowImg:=ld_tex('inventory.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/');\r
+ end;\r
+\r
+ for j:=0 to 8 do\r
+ begin\r
+ initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18, true);\r
+ id:=id+1;\r
+ end;\r
+\r
+ for i:=1 to 3 do\r
+ for j:=0 to 8 do\r
+ begin\r
+ initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18+4, true);\r
+ id:=id+1;\r
+ end;\r
+ end;\r
+\r
+ procedure ClosePlayerInventory;\r
+ var\r
+ nullimg:image;\r
+ begin\r
+ debug('Close Player Inventory');\r
+ //Если таких окон нет, то чистим память\r
+ if FindCurrentWindowsType=false then\r
+ begin\r
+ InvWindowImg:=nullimg;\r
+ end;\r
+ DelLayer;\r
+ end;\r
+\r
+ procedure DrawWindows;\r
+ var\r
+ max:integer;\r
+ i, wtype, x, y:integer;\r
+ begin\r
+ max:=CellLayer;\r
+ for i:=0 to max do\r
+ begin\r
+ setCellLayer(i);\r
+ wtype:=GetWindowType;\r
+ if wtype=WINDOW_PLAYER_INV then\r
+ begin\r
+ x:=getWidth/2-getImageWidth(InvWindowImg)/2;\r
+ y:=getHeight/2-getImageHeight(InvWindowImg)/2;\r
+ DrawImage(InvWindowImg, x, y);\r
+ end;\r
+ else\r
+ if wtype=WINDOW_DIV_ITEMS then\r
+ begin\r
+ x:=getWidth/2-getImageWidth(DivWindowImg)/2;\r
+ y:=getHeight/2-getImageHeight(DivWindowImg)/2;\r
+ DrawDivWindow(x, y);\r
+ end;\r
+ else\r
+ if wtype=WINDOW_CEATIVE_INV then\r
+ begin\r
+ x:=getWidth/2-getImageWidth(CrWindowImg)/2;\r
+ y:=getHeight/2-getImageHeight(CrWindowImg)/2;\r
+ DrawCreativeWindow(x, y);\r
+ end;\r
+ else\r
+ if wtype=WINDOW_CHEST_INV then\r
+ begin\r
+ x:=getWidth/2-getImageWidth(ChestWindowImg)/2;\r
+ y:=getHeight/2-getImageHeight(ChestWindowImg)/2;\r
+ DrawImage(ChestWindowImg, x, y);\r
+ end;\r
+ else\r
+ if wtype=WINDOW_FASTCRAFT then\r
+ begin\r
+ x:=getWidth/2-getImageWidth(fcWindowImg)/2;\r
+ y:=getHeight/2-getImageHeight(fcWindowImg)/2;\r
+ DrawFastCraftWindow(x, y);\r
+ end;\r
+ else\r
+ if wtype=WINDOW_FURNACE then\r
+ begin\r
+ x:=getWidth/2-getImageWidth(furWindowImg)/2;\r
+ y:=getHeight/2-getImageHeight(furWindowImg)/2;\r
+ DrawFurnaceWindow(x, y);\r
+ end;\r
+ DrawCellLayer(i, x, y);\r
+ DrawCursors(i, x, y);\r
+ end;\r
+ end;\r
+\r
+ procedure OpSwapItems(Idx1, Idx2:integer);\r
+ var\r
+ tmp_item, tmp_sum:integer;\r
+ begin\r
+ tmp_item:=getItem(Idx1);\r
+ tmp_sum:=getSum(Idx1);\r
+\r
+ setItem(getItem(Idx2), Idx1);\r
+ setSum(getSum(Idx2), Idx1);\r
+\r
+ setItem(tmp_item, Idx2);\r
+ setSum(tmp_sum, Idx2);\r
+ end;\r
+\r
+ function OpAddItems(Idx1, Idx2:integer):boolean;\r
+ var\r
+ tmp_item1, tmp_sum1:integer;\r
+ tmp_item2, tmp_sum2:integer;\r
+ fresult:boolean;\r
+ begin\r
+ tmp_item1:=GetItem(Idx1);\r
+ tmp_sum1:=GetSum(Idx1);\r
+ tmp_item2:=GetItem(Idx2);\r
+ tmp_sum2:=GetSum(Idx2);\r
+ fresult:=true;\r
+\r
+ if (tmp_item1=tmp_item2) and (Idx1<>Idx2) then\r
+ if tmp_sum2<getItemMax(tmp_item2) then\r
+ begin\r
+ tmp_sum2:=tmp_sum2+tmp_sum1;\r
+ tmp_sum1:=0;\r
+\r
+ if tmp_sum2>getItemMax(tmp_item2) then\r
+ begin\r
+ tmp_sum1:=tmp_sum2-getItemMax(tmp_item2);\r
+ tmp_sum2:=tmp_sum2-tmp_sum1;\r
+ end;\r
+\r
+ if tmp_sum1<=0 then\r
+ tmp_item1:=0;\r
+\r
+ fresult:=false;\r
+ end;\r
+\r
+ SetItem(tmp_item1, Idx1);\r
+ SetSum(tmp_sum1, Idx1);\r
+ SetItem(tmp_item2, Idx2);\r
+ SetSum(tmp_sum2, Idx2);\r
+ OpAddItems:=fresult;\r
+ end;\r
+\r
+ procedure SetActiveCursor(n:integer;);\r
+ var\r
+ n2:integer;\r
+ begin\r
+ if n=CUR_SELECT1 then\r
+ n2:=CUR_SELECT2;\r
+ else\r
+ n2:=CUR_SELECT1;\r
+\r
+ SetCur(n);\r
+ SetCurActive(true, n);\r
+ SetCurIndex(GetCurIndex(n2), n);\r
+ end;\r
+\r
+ procedure decItem(curidx:integer);\r
+ begin\r
+ SetSum(GetSum(curidx)-1, curidx);\r
+ fixNullCell(curidx);\r
+ end;\r
+\r
+ procedure HandlerSelect2Div;\r
+ var\r
+ idx1, idx2:integer;\r
+ begin\r
+ idx1:=GetCurIndex(CUR_SELECT1);\r
+ idx2:=GetCurIndex(CUR_SELECT2);\r
+\r
+ if GetItem(idx2)=0 then\r
+ begin\r
+ SetItem(GetItem(idx1), idx2);\r
+ SetSum(GetWindowInfo(WINDOW_INFO_DIVRES), idx2);\r
+\r
+ SetSum(GetSum(idx1)-GetSum(idx2), idx1);\r
+ fixNullCell(idx1);\r
+ end;\r
+ end;\r
+\r
+ procedure Select;\r
+ var\r
+ mode:integer;\r
+ begin\r
+ mode:=GetWindowInfo(WINDOW_INFO_INVMODE);\r
+\r
+ //Нажали кнопку - выбрали первый элемент\r
+ if mode=INV_MODE_SELECT1 then\r
+ begin\r
+ //Активируем второй курсор и ставим его над первым курсором\r
+ SetActiveCursor(CUR_SELECT2);\r
+ SetWindowInfo(INV_MODE_SELECT2, WINDOW_INFO_INVMODE);\r
+ end;\r
+ else\r
+ //Нажали кнопку - выбрали второй элемент, произвели сложение и переходим к режиму выбора первого элемента.\r
+ if mode=INV_MODE_SELECT2 then\r
+ begin\r
+ //Складывваем предметы курсора 1 и курсора 2\r
+ if OpAddItems(GetCurIndex(CUR_SELECT1), GetCurIndex(CUR_SELECT2)) then\r
+ OpSwapItems(GetCurIndex(CUR_SELECT1), GetCurIndex(CUR_SELECT2));\r
+ //Передаём управление первому курсору\r
+ SetActiveCursor(CUR_SELECT1);\r
+ SetCurActive(false, CUR_SELECT2);\r
+ SetWindowInfo(INV_MODE_SELECT1, WINDOW_INFO_INVMODE);\r
+ end;\r
+ else\r
+ if mode=INV_MODE_SELECT2_DIV then\r
+ begin\r
+ HandlerSelect2Div;\r
+ SetActiveCursor(CUR_SELECT1);\r
+ SetCurActive(false, CUR_SELECT2);\r
+ SetWindowInfo(INV_MODE_SELECT1, WINDOW_INFO_INVMODE);\r
+ end;\r
+ end;\r
+\r
+ function CanDivItem:boolean;\r
+ begin\r
+ if getItemDiv(getItem(GetCurIndex(GetCur))) then\r
+ if (GetCur=CUR_SELECT1) and (getSum(GetCurIndex(GetCur))>0) then\r
+ CanDivItem:=true;\r
+ end;\r
+\r
+ procedure StdCellKeyHandler;\r
+ begin\r
+ if clickedKey(KEY_WIN_SELECT) then\r
+ SetTimer(1000, T_KEY_DIVITEM);\r
+\r
+ if pressedKey(KEY_WIN_SELECT) then\r
+ begin\r
+ if GetTimer(T_KEY_DIVITEM)=TIMER_OK then\r
+ begin\r
+ if CanDivItem then\r
+ OpenDivWindow;\r
+ ResetTimer(T_KEY_DIVITEM);\r
+ end;\r
+ end;\r
+ else\r
+ begin\r
+ if GetTimer(T_KEY_DIVITEM)>TIMER_OK then\r
+ begin\r
+ Select;\r
+ ResetTimer(T_KEY_DIVITEM);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure keyDrop;\r
+ var\r
+ item, curidx:integer;\r
+ begin\r
+ curidx:=GetCurIndex(GetCur);\r
+ item:=getItem(curidx);\r
+\r
+ if clickedKey(KEY_WIN_DROP) then\r
+ SetTimer(1000, T_KEY_DROPITEM);\r
+\r
+ if pressedKey(KEY_WIN_DROP) then\r
+ begin\r
+ if GetTimer(T_KEY_DROPITEM)=TIMER_OK then\r
+ begin\r
+ player.dropItem(item, GetSum(curidx));\r
+ SetItem(0, curidx);\r
+ SetSum(0, curidx);\r
+ ResetTimer(T_KEY_DROPITEM);\r
+ end;\r
+ end;\r
+ else\r
+ begin\r
+ if GetTimer(T_KEY_DROPITEM)>TIMER_OK then\r
+ begin\r
+ if getItemDiv(item) then\r
+ begin\r
+ player.dropItem(item, 1);\r
+ decItem(curidx);\r
+ end;\r
+ ResetTimer(T_KEY_DROPITEM);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ function WindowKeyHanler:boolean;\r
+ var\r
+ WinType:integer;\r
+ craftid, mode:integer;\r
+ begin\r
+ WinType:=GetWindowType;\r
+ if WinType=WINDOW_PLAYER_INV then\r
+ begin\r
+ if clickedKey(KEY_WIN_UP) then\r
+ ShiftCurrentCur(FIND_CELL_UP);\r
+ if clickedKey(KEY_WIN_DOWN) then\r
+ ShiftCurrentCur(FIND_CELL_DOWN);\r
+ if clickedKey(KEY_WIN_LEFT) then\r
+ ShiftCurrentCur(FIND_CELL_LEFT);\r
+ if clickedKey(KEY_WIN_RIGHT) then\r
+ ShiftCurrentCur(FIND_CELL_RIGHT);\r
+\r
+ StdCellKeyHandler;\r
+ keyDrop;\r
+\r
+ if clickedKey(KEY_WIN_EXIT) then\r
+ ClosePlayerInventory;\r
+\r
+ if clickedKey(KEY_WIN_ALT) then\r
+ begin\r
+ ClosePlayerInventory;\r
+ OpenFastCraftWindow(0);\r
+ end;\r
+ end;\r
+ else\r
+ if WinType=WINDOW_DIV_ITEMS then\r
+ begin\r
+ if clickedKey(KEY_WIN_LEFT) then\r
+ DivScroll(-1);\r
+ if clickedKey(KEY_WIN_RIGHT) then\r
+ DivScroll(1);\r
+\r
+ if clickedKey(KEY_WIN_SELECT) then\r
+ CloseDivWindow(true);\r
+\r
+ if clickedKey(KEY_WIN_EXIT) then\r
+ CloseDivWindow(false);\r
+ end;\r
+ else\r
+ if WinType=WINDOW_CEATIVE_INV then\r
+ begin\r
+ if clickedKey(KEY_WIN_UP) then\r
+ FindCeativeUD(-1);\r
+ if clickedKey(KEY_WIN_DOWN) then\r
+ FindCeativeUD(1);\r
+ if clickedKey(KEY_WIN_LEFT) then\r
+ ShiftCurrentCur(FIND_CELL_LEFT);\r
+ if clickedKey(KEY_WIN_RIGHT) then\r
+ ShiftCurrentCur(FIND_CELL_RIGHT);\r
+\r
+ StdCellKeyHandler;\r
+ keyDrop;\r
+\r
+ if clickedKey(KEY_WIN_EXIT) then\r
+ CloseCreativeWindow;\r
+ end;\r
+ else\r
+ if WinType=WINDOW_CHEST_INV then\r
+ begin\r
+ if clickedKey(KEY_WIN_UP) then\r
+ ShiftCurrentCur(FIND_CELL_UP);\r
+ if clickedKey(KEY_WIN_DOWN) then\r
+ ShiftCurrentCur(FIND_CELL_DOWN);\r
+ if clickedKey(KEY_WIN_LEFT) then\r
+ ShiftCurrentCur(FIND_CELL_LEFT);\r
+ if clickedKey(KEY_WIN_RIGHT) then\r
+ ShiftCurrentCur(FIND_CELL_RIGHT);\r
+\r
+ StdCellKeyHandler;\r
+ keyDrop;\r
+\r
+ if clickedKey(KEY_WIN_EXIT) then\r
+ CloseChestWindow;\r
+ end;\r
+ else\r
+ if WinType=WINDOW_FASTCRAFT then\r
+ begin\r
+ if clickedKey(KEY_WIN_UP) then\r
+ FindFastCraftUD(-1);\r
+ if clickedKey(KEY_WIN_DOWN) then\r
+ FindFastCraftUD(1);\r
+ if clickedKey(KEY_WIN_LEFT) then\r
+ ShiftCurrentCur(FIND_CELL_LEFT);\r
+ if clickedKey(KEY_WIN_RIGHT) then\r
+ ShiftCurrentCur(FIND_CELL_RIGHT);\r
+\r
+ if clickedKey(KEY_WIN_SELECT) then\r
+ begin\r
+ mode:=GetWindowInfo(WINDOW_INFO_FC_MODE);\r
+ craftid:=getCellID(GetCurIndex(GetCur))+GetOffset(0);\r
+ createCraft(craftid, mode);\r
+ end;\r
+\r
+ if clickedKey(KEY_WIN_ALT) then\r
+ begin\r
+ CloseChestWindow;\r
+ OpenPlayerInventory;\r
+ end;\r
+\r
+ if clickedKey(KEY_WIN_EXIT) then\r
+ CloseChestWindow;\r
+ end;\r
+ else\r
+ if WinType=WINDOW_FURNACE then\r
+ begin\r
+ if clickedKey(KEY_WIN_UP) then\r
+ ShiftCurrentCur(FIND_CELL_UP);\r
+ if clickedKey(KEY_WIN_DOWN) then\r
+ ShiftCurrentCur(FIND_CELL_DOWN);\r
+ if clickedKey(KEY_WIN_LEFT) then\r
+ ShiftCurrentCur(FIND_CELL_LEFT);\r
+ if clickedKey(KEY_WIN_RIGHT) then\r
+ ShiftCurrentCur(FIND_CELL_RIGHT);\r
+\r
+ StdCellKeyHandler;\r
+ keyDrop;\r
+\r
+ if clickedKey(KEY_WIN_EXIT) then\r
+ CloseFurnaceWindow;\r
+ end;\r
+ else\r
+ WindowKeyHanler:=true;\r
+ end;\r
+\r
+end.\r
diff --git a/src/items.mpsrc b/src/items.mpsrc
--- /dev/null
+++ b/src/items.mpsrc
@@ -0,0 +1,98 @@
+unit items;\r
+\r
+interface\r
+ const\r
+ ITEM_TYPE_BLOCK=0;\r
+ ITEM_TYPE_TOOL=1;\r
+\r
+ ITEM_FLAG_IND1=1;\r
+ ITEM_FLAG_IND2=2;\r
+ ITEM_FLAG_DIV=4;\r
+ ITEM_FLAG_TEX=8;\r
+ var\r
+ compas:image;\r
+ clock:array[0..7] of image;\r
+ none0:image;\r
+ clock_stage:integer;\r
+\r
+ function getBlockTrans(id:integer;):boolean;\r
+ function getBlockFore(id:integer;):boolean;\r
+ function getBlockSet(id:integer;):boolean;\r
+\r
+ function getItemIndNum(id:integer):boolean;\r
+ function getItemIndLine(id:integer):boolean;\r
+ function getItemDiv(id:integer):boolean;\r
+ function getItemTexType(id:integer):integer;\r
+\r
+ procedure setMaxItemList(i:integer);\r
+ procedure setItemList(item, i:integer);\r
+ function getItemList(i:integer):integer;\r
+\r
+implementation\r
+ uses items_store;\r
+ const\r
+ BLOCK_FLAG_Trans=1;\r
+ BLOCK_FLAG_FORE=2;\r
+ BLOCK_FLAG_SET=4;\r
+\r
+ var\r
+ itemListSize:integer;\r
+ itemList: array [0..0] of integer;\r
+\r
+ function getBlockTrans(id:integer;):boolean;\r
+ begin\r
+ getBlockTrans:=(getBlockFlags(id) and BLOCK_FLAG_Trans)>0;\r
+ end;\r
+\r
+ function getBlockFore(id:integer;):boolean;\r
+ begin\r
+ getBlockFore:=(getBlockFlags(id) and BLOCK_FLAG_FORE)>0;\r
+ end;\r
+\r
+ function getBlockSet(id:integer;):boolean;\r
+ begin\r
+ getBlockSet:=(getBlockFlags(id) and BLOCK_FLAG_SET)>0;\r
+ end;\r
+\r
+ function getItemIndNum(id:integer):boolean;\r
+ begin\r
+ getItemIndNum:=(getItemFlags(id) and ITEM_FLAG_IND1)>0;\r
+ end;\r
+\r
+ function getItemIndLine(id:integer):boolean;\r
+ begin\r
+ getItemIndLine:=(getItemFlags(id) and ITEM_FLAG_IND2)>0;\r
+ end;\r
+\r
+ function getItemDiv(id:integer):boolean;\r
+ begin\r
+ getItemDiv:=(getItemFlags(id) and ITEM_FLAG_DIV)>0;\r
+ end;\r
+\r
+ function getItemTexType(id:integer):integer;\r
+ begin\r
+ getItemTexType:=(getItemFlags(id) and ITEM_FLAG_TEX)>>3;\r
+ end;\r
+\r
+ procedure setMaxItemList(i:integer);\r
+ begin\r
+ itemListSize:=i;\r
+ i:=i+1;\r
+ bytecode\r
+ iload 0;\r
+ newarray 10;\r
+ putstatic field 'items', 'itemlist', '[I';\r
+ end;\r
+ end;\r
+\r
+ procedure setItemList(i, item:integer);\r
+ begin\r
+ itemList[i]:=item;\r
+ end;\r
+\r
+ function getItemList(i:integer):integer;\r
+ begin\r
+ if (i>=0) and (i<=itemListSize) then\r
+ getItemList:=itemList[i];\r
+ end;\r
+end.\r
diff --git a/src/items_logic.mpsrc b/src/items_logic.mpsrc
--- /dev/null
+++ b/src/items_logic.mpsrc
@@ -0,0 +1,1432 @@
+unit items_logic;\r
+\r
+interface\r
+ function set_block_code(it,xx,yy:integer):boolean;//Выполнение кода при установке блока\r
+ procedure destroy_block_cr(id,xx,yy:integer);//Выполнение кода при разрушении блока в креативе\r
+ procedure destroy_block_0(id,xx,yy:integer);//Выполнение кода при разрушении блока не "тем" инструментом\r
+ procedure destroy_block_1(id,xx,yy:integer);//Выполнение кода при разрушении блока "нужным" инструментом\r
+\r
+ function useBlock(invcur, x, y:integer):boolean;\r
+ function useItem(invcur, x, y:integer):boolean;\r
+\r
+ procedure updateBlock(x, y:integer);\r
+\r
+implementation\r
+ uses invui, maps, drop, console, furnace, png3, func, jpeg, mob, vars, bmp, items, chest, inv, player, items_store, particles, worldgen, phy, sign;\r
+\r
+procedure usebonemeal(block:integer);\r
+ var\r
+ ix,iy,rnd_set:integer;\r
+ begin\r
+ if block=2 then\r
+ begin\r
+ for ix:=curx-4 to curx+4 do\r
+ for iy:=cury-4 to cury+4 do\r
+ begin\r
+ if (getmap(ix,iy+1)=2) and (getmap(ix,iy)=0) then\r
+ begin\r
+ rnd_set:=random(3);\r
+ if rnd_set=0 then setmap(22,ix,iy); else\r
+ if rnd_set=1 then setmap(23,ix,iy); else\r
+ if rnd_set=2 then setmap(57,ix,iy); else\r
+ end;\r
+ end;\r
+ inv.setSum(inv.getSum(invslot)-1, invslot);\r
+ inv.fixNull(invslot);\r
+ end; else\r
+ if block=122 then\r
+ begin\r
+ setmapinfo(3,curx,cury);\r
+ inv.setSum(inv.getSum(invslot)-1, invslot);\r
+ inv.fixNull(invslot);\r
+ end;\r
+ else\r
+ if (block=123) or (block=124) then\r
+ begin\r
+ setmapinfo(8,curx,cury);\r
+ inv.setSum(inv.getSum(invslot)-1, invslot);\r
+ inv.fixNull(invslot);\r
+ end;\r
+ else\r
+ if block=52 then\r
+ begin\r
+ genwood1(curx, cury);\r
+ inv.setSum(inv.getSum(invslot)-1, invslot);\r
+ inv.fixNull(invslot);\r
+ end;\r
+ else\r
+ if block=114 then\r
+ begin\r
+ genwood2(curx, cury);\r
+ inv.setSum(inv.getSum(invslot)-1, invslot);\r
+ inv.fixNull(invslot);\r
+ end;\r
+ else\r
+ if block=115 then\r
+ begin\r
+ genwood3(curx, cury);\r
+ inv.setSum(inv.getSum(invslot)-1, invslot);\r
+ inv.fixNull(invslot);\r
+ end;\r
+ end;\r
+\r
+function searchportal(ix,iy:integer):boolean;\r
+ begin\r
+ if (getmap(ix+1,iy)=10) and (getmap(ix-1,iy-1)=10) and (getmap(ix+2,iy-1)=10) and (getmap(ix-1,iy-2)=10) and (getmap(ix+2,iy-2)=10) and (getmap(ix-1,iy-3)=10) and (getmap(ix+2,iy-3)=10) and (getmap(ix,iy-4)=10) and (getmap(ix+1,iy-4)=10) then\r
+ searchportal:=true; else\r
+ searchportal:=false;\r
+ end;\r
+\r
+procedure create_screenshot_png;\r
+ var\r
+ screen:image;\r
+ date:string;\r
+ i,time:integer;\r
+ begin\r
+ time:=getCurrentTime;\r
+ screen:=ImageFromCanvas(0,0,getWidth,getHeight);\r
+ date:=''+getWeekDay(time)+'-'+getMonth(time)+'-'+getDay(time)+'_'+getHour(time)+'.'+getMinute(time)+'.'+getSecond(time);\r
+ i:=save_png(screen,sd+'/cavecraft/screenshots/'+date+'.png');\r
+ addToLog('Screenshot saved!');\r
+ end;\r
+\r
+procedure create_screenshot_jpeg;\r
+ var\r
+ screen:image;\r
+ date:string;\r
+ time:integer;\r
+ begin\r
+ time:=getCurrentTime;\r
+ screen:=ImageFromCanvas(0,0,getWidth,getHeight);\r
+ date:=''+getWeekDay(time)+'-'+getMonth(time)+'-'+getDay(time)+'_'+getHour(time)+'.'+getMinute(time)+'.'+getSecond(time);\r
+ jpeg.saveimagetofile(screen,s_jpeg_quality,'/'+sd+'/cavecraft/screenshots/'+date+'.jpg');\r
+ addToLog('Screenshot saved!');\r
+ end;\r
+\r
+procedure create_screenshot_bmp;\r
+ var\r
+ screen:image;\r
+ date:string;\r
+ time:integer;\r
+ begin\r
+ time:=getCurrentTime;\r
+ screen:=ImageFromCanvas(0,0,getWidth,getHeight);\r
+ date:=''+getWeekDay(time)+'-'+getMonth(time)+'-'+getDay(time)+'_'+getHour(time)+'.'+getMinute(time)+'.'+getSecond(time);\r
+ savebmp(screen,'/'+sd+'/cavecraft/screenshots/'+date+'.bmp');\r
+ addToLog('Screenshot saved!');\r
+ end;\r
+\r
+procedure boom(rr,mm,xx,yy:integer);\r
+ var\r
+ ix,iy,iz,ir,imob,erru,minhp:integer;\r
+ rays:array [0..359] of integer;\r
+ mobs_minhp:array[0..31] of integer;\r
+ begin\r
+ {setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ for iz:=0 to 359 do\r
+ rays[iz]:=mm;\r
+\r
+ for ir:=1 to rr do\r
+ for iz:=0 to 359 do\r
+ if rays[iz]>0 then\r
+ begin\r
+ if (iz>=0) and (iz<=180) and (ir=1) then erru:=-1; else erru:=0;\r
+ if (iz>=180) and (iz<=360) and (ir=1) then erru:=1; else erru:=0;\r
+ ix:=xx+trunc(cos(iz)*ir)+erru;\r
+ iy:=yy+trunc(sin(iz)*ir)+erru;\r
+ rays[iz]:=rays[iz]-getBlockHp(getmap(ix,iy));\r
+ if rays[iz]<0 then rays[iz]:=0;\r
+ if coll_boom(ix,iy)=true then minhp:=minhp+(rays[iz]*2);\r
+ for imob:=0 to 31 do\r
+ if mob[imob].m_hp>0 then\r
+ begin\r
+ if mob_coll_boom(imob,ix,iy)=true then begin mobs_minhp[imob]:=mobs_minhp[imob]+(rays[iz]*2); mob[imob].m_hp:=0; end;\r
+ end;\r
+ if getmap(ix,iy)=27 then boom(4,100,ix,iy);\r
+ if getBlockHp(getmap(ix,iy))<=mm then\r
+ begin\r
+ if 30<=random(100) then destroy_block_1(getmap(ix,iy),ix,iy);\r
+ setmap(0,ix,iy);\r
+ create_particle(7,(ix*16)+8-16,(iy*16)+8-16);\r
+ end;\r
+ end;\r
+ minhp:=minhp/360;\r
+ hp:=hp-minhp;\r
+ for imob:=0 to 31 do\r
+ begin\r
+ mobs_minhp[imob]:=mobs_minhp[imob]/360;\r
+ mob[imob].m_hp:=mob[imob].m_hp-mobs_minhp[imob];\r
+ end;}\r
+ end;\r
+\r
+procedure destroy_block_cr(id, xx, yy:integer);\r
+ begin\r
+ if id=27 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if id=28 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ chest.destroy(false, xx, yy);\r
+ end; else\r
+ if id=62 then\r
+ begin\r
+ setmap(50,xx,yy);\r
+ end; else\r
+ if id=62 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if id=66 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(8,xx+1,yy);\r
+ end; else\r
+ if id=73 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(8,xx+1,yy);\r
+ end; else\r
+ if id=77 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmap(0,xx+1,yy);\r
+ end; else\r
+ if id=78 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmap(0,xx-1,yy);\r
+ end; else\r
+ if id=79 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmap(0,xx,yy+1);\r
+ end; else\r
+ if id=80 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmap(0,xx,yy-1);\r
+ end; else\r
+ if id=81 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmap(0,xx,yy-1);\r
+ end; else\r
+ if id=82 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmap(0,xx,yy-1);\r
+ end; else\r
+ if id=102 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ chest.destroy(false, xx, yy);\r
+ end; else\r
+ if id=104 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ destsign(getmapinfo(xx,yy));\r
+ end; else\r
+ if id=106 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ DestroyFurnace(xx, yy);\r
+ end; else\r
+ if id=121 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if id=122 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end;\r
+ end;\r
+\r
+ function set_block_code(it,xx,yy:integer):boolean;//Если false тогда блок устанавливается\r
+ begin\r
+ if it=28 then\r
+ begin\r
+ if chest.create(xx,yy)=-1 then set_block_code:=true;\r
+ end; else\r
+ if it=102 then\r
+ begin\r
+ if chest.create(xx,yy)=-1 then set_block_code:=true;\r
+ end;\r
+ if it=104 then\r
+ begin\r
+ if createsign(xx,yy)=-1 then set_block_code:=true;\r
+ end; else\r
+ if it=106 then\r
+ begin\r
+ if CreateFurnace(xx, yy)=FURNACE_ERROR then\r
+ set_block_code:=true;\r
+ end; else\r
+ if it=121 then\r
+ begin\r
+ setmapinfo(16,xx,yy);\r
+ set_block_code:=false;\r
+ end; else\r
+ set_block_code:=false;\r
+ end;\r
+\r
+ procedure destroy_block_0(id,xx,yy:integer);\r
+ begin\r
+ if id=27 then\r
+ begin\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if id=21 then\r
+ begin\r
+ if random(8)=random(8) then drop.create(201,1,xx*16+4,yy*16+4); else\r
+ if random(5)=random(5) then drop.create(52,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=28 then\r
+ begin\r
+ chest.destroy(false, xx, yy);\r
+ end; else\r
+ if id=57 then\r
+ begin\r
+ if random(4)=random(4) then drop.create(217,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=62 then\r
+ begin\r
+ setmap(50,xx,yy);\r
+ end; else\r
+ if id=62 then\r
+ begin\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if id=77 then\r
+ begin\r
+ setmap(0,xx+1,yy);\r
+ end; else\r
+ if id=78 then\r
+ begin\r
+ setmap(0,xx-1,yy);\r
+ end; else\r
+ if id=79 then\r
+ begin\r
+ setmap(0,xx,yy+1);\r
+ end; else\r
+ if id=80 then\r
+ begin\r
+ setmap(0,xx,yy-1);\r
+ end; else\r
+ if id=81 then\r
+ begin\r
+ setmap(0,xx,yy+1);\r
+ end; else\r
+ if id=82 then\r
+ begin\r
+ setmap(0,xx,yy-1);\r
+ end; else\r
+ if id=102 then\r
+ begin\r
+ chest.destroy(true, xx, yy);\r
+ end; else\r
+ if id=104 then\r
+ begin\r
+ destsign(getmapinfo(xx,yy));\r
+ end; else\r
+ if id=106 then\r
+ begin\r
+ DestroyFurnace(xx, yy);\r
+ end; else\r
+ if id=112 then\r
+ begin\r
+ if random(8)=random(8) then drop.create(201,1,xx*16+4,yy*16+4); else\r
+ if random(5)=random(5) then drop.create(114,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=87 then\r
+ begin\r
+ if random(10)=random(10) then drop.create(115,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=121 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if id=122 then\r
+ begin\r
+ if getmapinfo(xx,yy)<3 then drop.create(217,random(4),xx*16+4,yy*16+4); else\r
+ if getmapinfo(xx,yy)=3 then begin drop.create(217,random(4),xx*16+4,yy*16+4); drop.create(218,1,xx*16+4,yy*16+4); end;\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end;\r
+ if (id=123) or (id=124) then\r
+ begin\r
+ drop.create(221+(id-123),random(4),xx*16+4,yy*16+4);\r
+ end;\r
+ //setmap(0,xx,yy);\r
+ //setmapinfo(0,xx,yy);\r
+ end;\r
+\r
+ procedure destroy_block_1(id,xx,yy:integer);\r
+ begin\r
+ if id=27 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if id=2 then\r
+ begin\r
+ drop.create(1,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=3 then\r
+ begin\r
+ drop.create(5,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=8 then\r
+ begin\r
+ if random(10)=random(10) then drop.create(207,1,xx*16+4,yy*16+4); else\r
+ drop.create(8,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=11 then\r
+ begin\r
+ drop.create(170,3,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=18 then\r
+ begin\r
+ drop.create(160,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=19 then\r
+ begin\r
+ drop.create(162,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=20 then\r
+ begin\r
+ drop.create(161,4+random(2),xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=28 then\r
+ begin\r
+ chest.destroy(true, xx, yy);\r
+ drop.create(28,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=48 then\r
+ begin\r
+ drop.create(1,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=50 then\r
+ begin\r
+ drop.create(0,0,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=51 then\r
+ begin\r
+ drop.create(0,0,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=54 then\r
+ begin\r
+ drop.create(166,4+random(4),xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=59 then\r
+ begin\r
+ drop.create(167,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=61 then\r
+ begin\r
+ drop.create(168,4+random(2),xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=62 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ end; else\r
+ if id=63 then\r
+ begin\r
+ drop.create(168,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=64 then\r
+ begin\r
+ drop.create(169,4,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=66 then\r
+ begin\r
+ setmapinfo(8,xx+1,yy);\r
+ drop.create(66,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=73 then\r
+ begin\r
+ drop.create(176,3+random(4),xx*16+4,yy*16+4);\r
+ setmapinfo(8,xx+1,yy);\r
+ end; else\r
+ if id=74 then\r
+ begin\r
+ drop.create(1,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=75 then\r
+ begin\r
+ drop.create(9,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=76 then\r
+ begin\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if id=77 then\r
+ begin\r
+ drop.create(179,1,xx*16+4,yy*16+4);\r
+ setmap(0,xx+1,yy);\r
+ end; else\r
+ if id=78 then\r
+ begin\r
+ drop.create(179,1,xx*16+4,yy*16+4);\r
+ setmap(0,xx-1,yy);\r
+ end; else\r
+ if id=79 then\r
+ begin\r
+ drop.create(178,1,xx*16+4,yy*16+4);\r
+ setmap(0,xx,yy+1);\r
+ end; else\r
+ if id=80 then\r
+ begin\r
+ drop.create(178,1,xx*16+4,yy*16+4);\r
+ setmap(0,xx,yy-1);\r
+ end; else\r
+ if id=81 then\r
+ begin\r
+ drop.create(178,1,xx*16+4,yy*16+4);\r
+ setmap(0,xx,yy+1);\r
+ end; else\r
+ if id=82 then\r
+ begin\r
+ drop.create(178,1,xx*16+4,yy*16+4);\r
+ setmap(0,xx,yy-1);\r
+ end; else\r
+ if id=84 then\r
+ begin\r
+ drop.create(83,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=86 then\r
+ begin\r
+ drop.create(85,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=88 then\r
+ begin\r
+ drop.create(24,random(3)-1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=89 then\r
+ begin\r
+ drop.create(24,random(3)-1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=90 then\r
+ begin\r
+ drop.create(25,random(3)-1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=91 then\r
+ begin\r
+ drop.create(25,random(3)-1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=93 then\r
+ begin\r
+ drop.create(92,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=94 then\r
+ begin\r
+ drop.create(4,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=95 then\r
+ begin\r
+ drop.create(187,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=95 then\r
+ begin\r
+ drop.create(187,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=95 then\r
+ begin\r
+ drop.create(187,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=96 then\r
+ begin\r
+ drop.create(187,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=97 then\r
+ begin\r
+ drop.create(187,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=98 then\r
+ begin\r
+ drop.create(187,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=99 then\r
+ begin\r
+ drop.create(187,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=100 then\r
+ begin\r
+ drop.create(187,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=101 then\r
+ begin\r
+ drop.create(187,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=102 then\r
+ begin\r
+ chest.destroy(true, xx, yy);\r
+ drop.create(28,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=104 then\r
+ begin\r
+ destsign(getmapinfo(xx,yy));\r
+ drop.create(104,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=106 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ DestroyFurnace(xx, yy);\r
+ end; else\r
+ if id=107 then\r
+ begin\r
+ drop.create(108,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=111 then\r
+ begin\r
+ drop.create(214,random(4)+1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=117 then\r
+ begin\r
+ drop.create(116,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=118 then\r
+ begin\r
+ drop.create(10,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=120 then\r
+ begin\r
+ drop.create(1,1,xx*16+4,yy*16+4);\r
+ end; else\r
+ if id=121 then\r
+ begin\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if id=122 then\r
+ begin\r
+ if getmapinfo(xx,yy)<3 then drop.create(217,random(2),xx*16+4,yy*16+4); else\r
+ if getmapinfo(xx,yy)=3 then begin drop.create(217,random(2),xx*16+4,yy*16+4); drop.create(218,1,xx*16+4,yy*16+4); end;\r
+ setmap(0,xx,yy);\r
+ setmapinfo(0,xx,yy);\r
+ end; else\r
+ if (id=123) or (id=124) then\r
+ begin\r
+ drop.create(221+(id-123),random(4),xx*16+4,yy*16+4);\r
+ end; else\r
+ begin\r
+ setmapinfo(0,xx,yy);\r
+ drop.create(id,1,xx*16+4,yy*16+4);\r
+ end;\r
+ end;\r
+\r
+ procedure decItem(invcur:integer);\r
+ begin\r
+ if gamemode<>1 then\r
+ begin\r
+ inv.setSum(inv.getSum(invcur)-1, invcur);\r
+ inv.fixNull(invcur);\r
+ end;\r
+ end;\r
+\r
+ //Возвращает true если блок небыл использован.\r
+ function useBlock(invcur, x, y:integer):boolean;\r
+ var\r
+ item, sum, block, info:integer;\r
+ begin\r
+ item:=inv.getItem(invcur);\r
+ sum:=inv.getSum(invcur);\r
+ block:=getMap(x, y);\r
+ info:=getMapInfo(x, y);\r
+\r
+ if (block=28) or (block=102) then\r
+ begin\r
+ if info<=MAX_CHEST then\r
+ OpenChestWindow(info);\r
+ end;\r
+ else\r
+ if block=29 then\r
+ OpenFastCraftWindow(1);\r
+ else\r
+ if block=79 then\r
+ begin\r
+ setMap(81, x, y);\r
+ setMap(82, x, y+1);\r
+ end;\r
+ else\r
+ if block=80 then\r
+ begin\r
+ setMap(81, x, y-1);\r
+ setMap(82, x, y);\r
+ end;\r
+ else\r
+ if block=81 then\r
+ begin\r
+ setMap(79, x, y);\r
+ setMap(80, x, y+1);\r
+ end;\r
+ else\r
+ if block=82 then\r
+ begin\r
+ setMap(79, x, y-1);\r
+ setMap(80, x, y);\r
+ end;\r
+ /*else\r
+ if block=104 then\r
+ keymode:=5;*/\r
+ else\r
+ if block=106 then\r
+ OpenFurnaceWindow(info);\r
+ else\r
+ if block=107 then\r
+ setMap(108, x, y);\r
+ else\r
+ if block=108 then\r
+ setMap(107, x, y);\r
+ else\r
+ if block=116 then\r
+ setMap(117, x, y);\r
+ else\r
+ if block=117 then\r
+ setMap(116, x, y);\r
+ else\r
+ if block=121 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+2;\r
+ info:=info-2;\r
+ if (info=14) or (info=2) then\r
+ info:=info-2;\r
+ if info<1 then\r
+ setMap(0, x, y);\r
+ else\r
+ setMapInfo(info, x, y);\r
+ end;\r
+ end;\r
+ else\r
+ useBlock:=true;\r
+\r
+ /*\r
+\r
+\r
+ if (getmap(curx,cury)=1) or (getmap(curx,cury)=2) or (getmap(curx,cury)=48) or (getmap(curx,cury)=74) then\r
+ begin\r
+ if (get_item(0, item)=1) and (get_tool(0, item)=6) and (sum>0) and (getmap(curx,cury-1)=0) then\r
+ begin\r
+ setmap(120,curx,cury);\r
+ inv.setSum(inv.getSum(invslot)-1, invslot);\r
+ inv.fixNull(invslot);\r
+ end;\r
+ end;\r
+ else\r
+ if (getmap(curx,cury)=77) or (getmap(curx,cury)=78) then\r
+ begin\r
+ if pl_world=0 then\r
+ sleep;\r
+ else\r
+ boom(4,100,curx,cury);\r
+ end;*/\r
+ end;\r
+\r
+ function useItem(invcur, x, y:integer):boolean;\r
+ var\r
+ item, sum, block, info:integer;\r
+ begin\r
+ if inv.isNull(invcur) then\r
+ useItem:=true;\r
+\r
+ item:=inv.getItem(invcur);\r
+ sum:=inv.getSum(invcur);\r
+ block:=getMap(x, y);\r
+ info:=getMapInfo(x, y);\r
+\r
+ if item=171 then\r
+ begin\r
+ if block=50 then\r
+ begin\r
+ inv.setItem(172, invcur);\r
+ setMap(0, x, y);\r
+ end;\r
+ else\r
+ if block=51 then\r
+ begin\r
+ inv.setItem(173, invcur);\r
+ setMap(0, x, y);\r
+ end;\r
+ end;\r
+ else\r
+ if item=220 then\r
+ usebonemeal(block);\r
+ else\r
+ if item=217 then\r
+ begin\r
+ if (block=120) and (getMap(x, y-1)=0) then\r
+ begin\r
+ setMap(122, x, y-1);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=221 then\r
+ begin\r
+ if (block=120) and (getMap(x, y-1)=0) then\r
+ begin\r
+ setMap(123, x, y-1);\r
+ setMapInfo(1, x, y-1);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=222 then\r
+ begin\r
+ if (block=120) and (getMap(x, y-1)=0) then\r
+ begin\r
+ setMap(124, x, y-1);\r
+ setMapInfo(1, x, y-1);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=172 then\r
+ begin\r
+ if (block=0) then\r
+ begin\r
+ inv.setItem(171, invcur);\r
+ setMap(50, x, y);\r
+ end;\r
+ end;\r
+ else\r
+ if item=173 then\r
+ begin\r
+ if (block=0) then\r
+ begin\r
+ inv.setItem(171, invcur);\r
+ setMap(51, x, y);\r
+ end;\r
+ end;\r
+ else\r
+ if item=176 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+2;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=177 then\r
+ begin\r
+ {if random(10)=random(10) then\r
+ create_mob(4, x*16, y*16);}\r
+ decItem(invcur);\r
+ end;\r
+ else\r
+ if item=178 then\r
+ begin\r
+ if (block=0) and (getMap(x, y-1)=0) then\r
+ begin\r
+ setMap(81, x, y-1);\r
+ setMap(82, x, y);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=179 then\r
+ begin\r
+ if (block=0) and (getMap(x+1, y)=0) then\r
+ begin\r
+ setMap(77, x, y);\r
+ setMap(78, x+1, y);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=180 then\r
+ begin\r
+ if getBlockColl(block)=0 then\r
+ begin\r
+ mob.create(M_ZOMBY, x*16, y*16);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=181 then\r
+ begin\r
+ if getBlockColl(block)=0 then\r
+ begin\r
+ //create_mob(2, x*16, y*16);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=182 then\r
+ begin\r
+ if getBlockColl(block)=0 then\r
+ begin\r
+ //create_mob(3, x*16, y*16);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=185 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ inv.setItem(184, invslot);\r
+ hunger:=hunger+6;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ end;\r
+ end;\r
+ else\r
+ if item=187 then\r
+ begin\r
+ if block=0 then\r
+ begin\r
+ setMap(95+random(7), x, y);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=188 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+3;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=189 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+8;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=190 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+4;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=191 then\r
+ create_screenshot_png;\r
+ else\r
+ if item=192 then\r
+ create_screenshot_jpeg;\r
+ else\r
+ if item=193 then\r
+ create_screenshot_bmp;\r
+ else\r
+ if item=196 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hp:=hp-4;\r
+ hunger:=hunger+2;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=199 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+3;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=200 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+8;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=201 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+4;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=202 then\r
+ begin\r
+ if hp<20 then\r
+ begin\r
+ hp:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=203 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+2;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=204 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+6;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=205 then\r
+ begin\r
+ if getBlockColl(block)=0 then\r
+ begin\r
+ //create_mob(4, x*16, y*16);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=206 then\r
+ begin\r
+ if getBlockColl(block)=0 then\r
+ begin\r
+ //create_mob(5, x*16, y*16);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=208 then\r
+ begin\r
+ if getBlockColl(block)=0 then\r
+ begin\r
+ //create_mob(6, x*16, y*16);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=209 then\r
+ begin\r
+ if getBlockColl(block)=0 then\r
+ begin\r
+ //create_mob(7, x*16, y*16);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=213 then\r
+ begin\r
+ if getBlockColl(block)=0 then\r
+ begin\r
+ //create_mob(8, x*16, y*16);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=212 then\r
+ begin\r
+ if getBlockColl(block)=0 then\r
+ begin\r
+ //create_mob(10, x*16, y*16);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=210 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+2;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=211 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+5;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=219 then\r
+ begin\r
+ if hunger<20 then\r
+ begin\r
+ hunger:=hunger+5;\r
+ if hunger>20 then\r
+ hunger:=20;\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=153 then\r
+ begin\r
+ if block=10 then\r
+ begin\r
+ if searchportal(x , y)=true then\r
+ begin\r
+ genportal(x-1, y-4);\r
+ decItem(invcur);\r
+ end;\r
+ else\r
+ if searchportal(x-1, y)=true then\r
+ begin\r
+ genportal(x-2, y-4);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if block=27 then\r
+ begin\r
+ setmapinfo(getrelativetimems/1000-(getrelativetimems/1000 div 100*100),curx,cury);\r
+ decItem(invcur);\r
+ end;\r
+ end;\r
+ else\r
+ if item=152 then\r
+ begin\r
+ if block=50 then\r
+ begin\r
+ fish:=true;\r
+ fish_time:=getrelativetimems;\r
+ fx:=curx;\r
+ fy:=cury;\r
+ end;\r
+ end;\r
+ else\r
+ useItem:=true;\r
+ end;\r
+\r
+procedure fluidLogic(x, y, ifbx, thenbx, ifby, thenby:integer);\r
+ var\r
+ block, blockXm1, blockXp1, blockYp1:integer;\r
+ begin\r
+ block:=getMap(x, y);\r
+ blockXm1:=getMap(x-1, y);\r
+ blockXp1:=getMap(x+1, y);\r
+ blockYp1:=getMap(x, y+1);\r
+\r
+ //Если внизу условный блок, то заменяем.\r
+ if blockYp1=ifby then\r
+ setMap(thenby, x, y+1);\r
+ else\r
+ //Если нижний блок можно уничтожить, то ставим туда копию\r
+ if getBlockSet(blockYp1) then\r
+ begin\r
+ destroy_block_0(blockYp1, x, y+1);\r
+ setMap(block, x, y+1);\r
+ end;\r
+ //Если ничего не можем, то пытаемся течь по сторонам\r
+ else\r
+ begin\r
+ if blockXm1=ifbx then\r
+ setMap(thenbx, x-1, y);\r
+ else\r
+ if getBlockSet(blockXm1) then\r
+ begin\r
+ destroy_block_1(blockXm1, x-1, y);\r
+ setMap(block, x-1, y);\r
+ end;\r
+\r
+ if blockXp1=ifbx then\r
+ setMap(thenbx, x+1, y);\r
+ else\r
+ if getBlockSet(blockXp1) then\r
+ begin\r
+ destroy_block_1(blockXp1, x+1, y);\r
+ setMap(block, x+1, y);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+procedure updateBlock(x, y:integer);\r
+ const\r
+ GRASS_RND=128;\r
+ TORCH_RND=128;\r
+ SPAWN_RND=128;\r
+ SPAWN_RAD=128;\r
+ GENWOOD_RND=1024;\r
+ LIAN_RND=32;\r
+ CORN_RND=512;\r
+ var\r
+ plx, ply, block, light, info:integer;\r
+ begin\r
+ plx:=player.getX;\r
+ ply:=player.getY;\r
+ block:=getMap(x, y);\r
+ light:=getMapLight(x, y);\r
+ info:=getMapInfo(x, y);\r
+\r
+ if block=2 then\r
+ begin\r
+ //Трава разрастается при условии что освещение выше чем 3\r
+ if (getBlockSet(getMap(x, y-1))=false) or (light=0) then\r
+ setMap(1, x, y);\r
+ else\r
+ if light>3 then\r
+ begin\r
+ if (getMap(x-1, y)=1) and (getMap(x-1, y-1)=0) then\r
+ if random(GRASS_RND)=random(GRASS_RND) then\r
+ setMap(2, x-1, y);\r
+\r
+ if (getMap(x+1, y)=1) and (getMap(x+1, y-1)=0) then\r
+ if random(GRASS_RND)=random(GRASS_RND) then\r
+ setMap(2, x+1, y);\r
+ end;\r
+ end;\r
+ else\r
+ if block=7 then\r
+ begin\r
+ if getBlockSet(getMap(x, y+1)) then\r
+ begin\r
+ setMap(0, x, y);\r
+ setMap(7, x, y+1);\r
+ end;\r
+ end;\r
+ else\r
+ if block=8 then\r
+ begin\r
+ if getBlockSet(getMap(x, y+1)) then\r
+ begin\r
+ setMap(0, x, y);\r
+ setMap(8, x, y+1);\r
+ end;\r
+ end;\r
+ else\r
+ if block=26 then\r
+ begin\r
+ if random(TORCH_RND)=random(TORCH_RND) then\r
+ create_particle(2, x*16+4, y*16+4);\r
+ end;\r
+ else\r
+ if block=50 then\r
+ begin\r
+ fluidLogic(x, y, 51, 10, 51, 10);\r
+ end;\r
+ else\r
+ if block=51 then\r
+ begin\r
+ fluidLogic(x, y, 50, 5, 50, 3);\r
+ end;\r
+ else\r
+ if block=63 then\r
+ begin\r
+ if (light>7) or (getMap(x, y+1)=0) then\r
+ setmap(0, x, y);\r
+ end;\r
+ else\r
+ if block=74 then\r
+ begin\r
+ if getBlockSet(getMap(x, y-1))=false then\r
+ setMap(1, x, y);\r
+ else\r
+ if light>3 then\r
+ begin\r
+ if (getMap(x-1, y)=1) and (getMap(x-1, y-1)=0) then\r
+ if random(GRASS_RND)=random(GRASS_RND) then\r
+ setMap(74, x-1, y);\r
+\r
+ if (getMap(x+1, y)=1) and (getMap(x+1, y-1)=0) then\r
+ if random(GRASS_RND)=random(GRASS_RND) then\r
+ setMap(74, x+1, y);\r
+ end;\r
+ end;\r
+ else\r
+ if block=77 then\r
+ begin\r
+ if getmap(x+1, y)<>78 then\r
+ setMap(0, x, y);\r
+ end;\r
+ else\r
+ if block=78 then\r
+ begin\r
+ if getmap(x-1, y)<>77 then\r
+ setMap(0, x, y);\r
+ end;\r
+ else\r
+ if block=79 then\r
+ begin\r
+ if getmap( x, y+1)<>80 then\r
+ setMap(0, x, y);\r
+ end;\r
+ else\r
+ if block=80 then\r
+ begin\r
+ if getmap(x, y-1)<>79 then\r
+ setMap(0, x, y);\r
+ end;\r
+ else\r
+ if block=81 then\r
+ begin\r
+ if getmap(x, y+1)<>82 then\r
+ setMap(0, x, y);\r
+ end; else\r
+ if block=82 then\r
+ begin\r
+ if getmap(x, y-1)<>81 then\r
+ setmap(0, x, y);\r
+ end; else\r
+ if block=76 then\r
+ begin\r
+ {if CollTwoObj(plx, ply, player.getW, player.getH, x*16-SPAWN_RAD, y*16-SPAWN_RAD, x*16+SPAWN_RAD, y*16+SPAWN_RAD) then\r
+ if random(SPAWN_RND)=random(SPAWN_RND) then\r
+ create_mob(getMapInfo(x, y), x*16,(y-2)*16);}\r
+ end;\r
+ else\r
+ if block=52 then\r
+ begin\r
+ if random(GENWOOD_RND)=random(GENWOOD_RND) then\r
+ genwood1(x, y);\r
+ end;\r
+ else\r
+ if block=114 then\r
+ begin\r
+ if random(GENWOOD_RND)=random(GENWOOD_RND) then\r
+ genwood2(x, y);\r
+ end;\r
+ else\r
+ if block=115 then\r
+ begin\r
+ if random(GENWOOD_RND)=random(GENWOOD_RND) then\r
+ genwood3(x, y);\r
+ end;\r
+ else\r
+ if block=103 then\r
+ begin\r
+ if (getmap(x, y-1)=0) then\r
+ setmap(0, x, y);\r
+ else\r
+ if (getmap(x, y+1)=0) and (random(LIAN_RND)=random(LIAN_RND)) then\r
+ setmap(103, x, y+1);\r
+ end;\r
+ else\r
+ if block=105 then\r
+ begin\r
+ if random(TORCH_RND)=random(TORCH_RND) then\r
+ create_particle(4, x*16+4, y*16+4);\r
+ end;\r
+ else\r
+ if block=110 then\r
+ begin\r
+ if (getmap(x-1, y)=0) or (getmap(x+1, y)=0) or (getmap(x, y-1)=0) or (getmap(x, y+1)=0) then\r
+ setmap(0, x, y);\r
+ end;\r
+ else\r
+ if block=30 then\r
+ begin\r
+ if (random(GENWOOD_RND)=random(GENWOOD_RND)) and (getMap(x, y+2)<>30) then\r
+ setMap(30, x, y-1);\r
+ if (getMap(x, y+1)<>7) or (getMap(x, y+1)<>30) then\r
+ begin\r
+ setMap(0, x, y);\r
+ destroy_block_1(block, x, y);\r
+ end;\r
+ end; else\r
+ if block=65 then\r
+ begin\r
+ if (random(GENWOOD_RND)=random(GENWOOD_RND)) and (getMap(x, y+2)<>65) then\r
+ setMap(65, x, y-1);\r
+ if (getMap(x, y+1)=0) then\r
+ begin\r
+ setMap(0, x, y);\r
+ destroy_block_1(block, x, y);\r
+ end;\r
+ end;\r
+ else\r
+ if block=122 then\r
+ begin\r
+ if random(CORN_RND)=random(CORN_RND) then\r
+ info:=info+1;\r
+ if info>3 then\r
+ info:=3;\r
+ if getmap(x, y+1)<>120 then\r
+ setMap(0, x, y);\r
+ setMapInfo(info, x, y);\r
+ end; else\r
+ if block=123 then\r
+ begin\r
+ if random(CORN_RND)=random(CORN_RND) then\r
+ info:=info+1;\r
+ if info>9 then\r
+ info:=9;\r
+ if getmap(x, y+1)<>120 then\r
+ setMap(0, x, y);\r
+\r
+ if (info=0) and (getMap(x-1, y)=0) and (getBlockColl(getMap(x-1, y+1))>0) then\r
+ setmap(73, x-1, y);\r
+\r
+ if (getMap(x-1, y)=73) and (getMapinfo(x, y)<>9) then\r
+ info:=9;\r
+\r
+ setMapInfo(info, x, y);\r
+ end;\r
+ else\r
+ if block=124 then\r
+ begin\r
+ if random(CORN_RND)=random(CORN_RND) then\r
+ info:=info+1;\r
+ if info>9 then\r
+ info:=9;\r
+ if getmap(x, y+1)<>120 then\r
+ setMap(0, x, y);\r
+\r
+ if (info=0) and (getMap(x-1, y)=0) and (getBlockColl(getMap(x-1, y+1))>0) then\r
+ setmap(66, x-1, y);\r
+\r
+ if (getMap(x-1, y)=66) and (getMapinfo(x, y)<>9) then\r
+ info:=9;\r
+\r
+ setMapInfo(info, x, y);\r
+ end;\r
+ else\r
+ if block=27 then\r
+ begin\r
+ if info<>0 then\r
+ if getrelativetimems/1000-(getrelativetimems/1000 div 100*100)-info>3 then\r
+ boom(4, 100, x, y);\r
+ end;\r
+ end;\r
+\r
+end.\r
diff --git a/src/keyboard.mpsrc b/src/keyboard.mpsrc
--- /dev/null
+++ b/src/keyboard.mpsrc
@@ -0,0 +1,227 @@
+unit keyboard;\r
+\r
+interface\r
+ const\r
+ MAX_KEY_TYPES=27;\r
+ MAX_KEY_BIND=3;\r
+\r
+ KEY_FM_UP=0;\r
+ KEY_FM_DOWN=1;\r
+ KEY_FM_SELECT=2;\r
+\r
+ KEY_MENU_UP=3;\r
+ KEY_MENU_DOWN=4;\r
+ KEY_MENU_LEFT=5;\r
+ KEY_MENU_RIGHT=6;\r
+ KEY_MENU_SELECT=7;\r
+\r
+ KEY_FASTINV_PREV=8;\r
+ KEY_FASTINV_NEXT=9;\r
+\r
+ KEY_CHAT=10;\r
+\r
+ KEY_PLR_OPENINV=11;\r
+ KEY_PLR_EDITMODE=12;\r
+ KEY_PLR_USE=13;\r
+ KEY_PLR_ATTACK=14;\r
+\r
+ KEY_PLR_UP=15;\r
+ KEY_PLR_DOWN=16;\r
+ KEY_PLR_LEFT=17;\r
+ KEY_PLR_RIGHT=18;\r
+\r
+ KEY_MENU=19;\r
+\r
+ KEY_WIN_UP=20;\r
+ KEY_WIN_DOWN=21;\r
+ KEY_WIN_LEFT=22;\r
+ KEY_WIN_RIGHT=23;\r
+ KEY_WIN_SELECT=24;\r
+ KEY_WIN_ALT=25;\r
+ KEY_WIN_DROP=26;\r
+ KEY_WIN_EXIT=27;\r
+\r
+\r
+ var\r
+ s_cl:boolean;\r
+ load_key_tex:integer;\r
+ scrMulX, scrMulY:integer;\r
+\r
+ function touchscreen:boolean;\r
+ procedure init_touch;\r
+ function senClicked(ix,iy,xx,yy:integer):boolean;\r
+ function senPressed(ix,iy,xx,yy:integer):boolean;\r
+ //function get_key_clicked:integer;\r
+ //function get_key_pressed:integer;\r
+ procedure draw_virtual_keys;\r
+\r
+ procedure bindKey(keytype, id, keycode:integer);\r
+ function clickedKey(keytype:integer):boolean;\r
+ function pressedKey(keytype:integer):boolean;\r
+ procedure updateKeys;\r
+\r
+ procedure resetVirtualKeyboard(i:integer);\r
+ procedure bindVKey(i, keycode, x, y:integer);\r
+ procedure setVkeyImg(img:image; i:integer);\r
+\r
+implementation\r
+uses sensor,vars,canvas, func;\r
+ var\r
+ key_bind: array [0..MAX_KEY_BIND, 0..MAX_KEY_TYPES] of integer;\r
+ clicked_key, pressed_key:integer;\r
+\r
+ v_keycode: array [0..0] of integer;\r
+ v_keyx: array [0..0] of integer;\r
+ v_keyy: array [0..0] of integer;\r
+ v_keyimg: array [0..0] of image;\r
+ v_max:integer;\r
+\r
+ procedure resetVirtualKeyboard(i:integer);\r
+ var\r
+ nullimg:image;\r
+ v:integer;\r
+ begin\r
+ v_max:=i;\r
+ i:=i+1;\r
+ \r
+ bytecode\r
+ iload 0;\r
+ newarray 10;\r
+ putstatic field 'keyboard', 'v_keycode', '[I';\r
+ end;\r
+ bytecode\r
+ iload 0;\r
+ newarray 10;\r
+ putstatic field 'keyboard', 'v_keyx', '[I';\r
+ end;\r
+ bytecode\r
+ iload 0;\r
+ newarray 10;\r
+ putstatic field 'keyboard', 'v_keyy', '[I';\r
+ end;\r
+ bytecode\r
+ iload 0;\r
+ multianewarray class '[Ljavax/microedition/lcdui/Image;', 1;\r
+ putstatic field 'keyboard', 'v_keyimg', '[Ljavax/microedition/lcdui/Image;';\r
+ end;\r
+ for v:=0 to v_max do\r
+ v_keyimg[v]:=nullimg;\r
+ end;\r
+\r
+ procedure setVkeyImg(img:image; i:integer);\r
+ begin\r
+ v_keyimg[i]:=img;\r
+ end;\r
+\r
+ procedure bindVKey(i, keycode, x, y:integer;);\r
+ begin\r
+ v_keycode[i]:=keycode;\r
+ v_keyx[i]:=x;\r
+ v_keyy[i]:=y;\r
+ end;\r
+\r
+ procedure bindKey(keytype, id, keycode:integer);\r
+ begin\r
+ key_bind[id, keytype]:=keycode;\r
+ end;\r
+\r
+ function clickedKey(keytype:integer):boolean;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to MAX_KEY_BIND do\r
+ if (key_bind[i, keytype]=clicked_key) and (key_bind[i, keytype]<>0) then\r
+ begin\r
+ clickedKey:=true;\r
+ exit;\r
+ end;\r
+ end;\r
+\r
+ function pressedKey(keytype:integer):boolean;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to MAX_KEY_BIND do\r
+ if (key_bind[i, keytype]=pressed_key) and (key_bind[i, keytype]<>0) then\r
+ begin\r
+ pressedKey:=true;\r
+ exit;\r
+ end;\r
+ end;\r
+\r
+function touchscreen:boolean;\r
+ begin\r
+ setcolor(0, 0, 0);\r
+ fillrect(0, 0, getWidth, getHeight);\r
+ drawfonttext('Press 5', getWidth/2-(length('Press 5')*8)/2, getHeight-16);\r
+ drawfonttext('or touch the screen.', getWidth/2-(length('or touch the screen.')*8)/2, getHeight-8);\r
+ repaint;\r
+ delay(1);\r
+ repeat\r
+ updateKeys;\r
+ if clickedKey(KEY_MENU_SELECT) then\r
+ begin\r
+ touchscreen:=false;\r
+ exit;\r
+ end;\r
+ if pointer_state=1 then\r
+ begin\r
+ touchscreen:=true;\r
+ exit;\r
+ end;\r
+ forever;\r
+ end;\r
+\r
+procedure init_touch;\r
+ begin\r
+ sensor.init;\r
+ end;\r
+\r
+function senClicked(ix,iy,xx,yy:integer):boolean;\r
+ begin\r
+ if (pointer_state=1) and (s_cl=false) then\r
+ if (pointer_pressed_x>ix*scrMulX) and (pointer_pressed_y>iy*scrMulY) and (pointer_pressed_x<(ix+xx)*scrMulX) and (pointer_pressed_y<(iy+yy)*scrMulY) then\r
+ begin\r
+ s_cl:=true;\r
+ senClicked:=true;\r
+ end;\r
+ end;\r
+\r
+function senPressed(ix,iy,xx,yy:integer):boolean;\r
+ begin\r
+ if (pointer_state=1) then\r
+ if (pointer_pressed_x>ix*scrMulX) and (pointer_pressed_y>iy*scrMulY) and (pointer_pressed_x<(ix+xx)*scrMulX) and (pointer_pressed_y<(iy+yy)*scrMulY) then\r
+ senPressed:=true;\r
+ end;\r
+\r
+ procedure updateKeys;\r
+ var\r
+ i:integer;\r
+ begin\r
+ clicked_key:=getKeyClicked;\r
+ pressed_key:=getKeyPressed;\r
+\r
+ if pointer_state=0 then\r
+ s_cl:=false;\r
+\r
+ for i:=0 to v_max do\r
+ begin\r
+ if senClicked(v_keyx[i], v_keyy[i], getImageWidth(v_keyimg[i]), getImageHeight(v_keyimg[i])) then\r
+ clicked_key:=v_keycode[i];\r
+ if senPressed(v_keyx[i], v_keyy[i], getImageWidth(v_keyimg[i]), getImageHeight(v_keyimg[i])) then\r
+ pressed_key:=v_keycode[i];\r
+ end;\r
+ end;\r
+\r
+procedure draw_virtual_keys;\r
+ var\r
+ i:integer;\r
+ begin\r
+ if load_key_tex=1 then\r
+ for i:=0 to v_max do\r
+ drawImage(v_keyimg[i], v_keyx[i], v_keyy[i]);\r
+ end;\r
+\r
+initialization\r
+ v_max:=-1;\r
+end.\r
diff --git a/src/mobs.pas b/src/mobs.pas
--- /dev/null
+++ b/src/mobs.pas
@@ -0,0 +1,577 @@
+unit mob;\r
+\r
+interface\r
+ const\r
+ M_NONE=0;\r
+ M_ZOMBY=1;\r
+\r
+ MOB_TYPES=1;\r
+\r
+ procedure create(_type, x, y:integer);//Создать моба\r
+ function findAndHit(value, x, y, w, h, addvx, addvy:integer):integer;\r
+\r
+ procedure update;//Обновление логики\r
+ procedure updatePhy;//Обновление физики\r
+ procedure draw(camx, camy:integer);//Отрисовка\r
+\r
+ procedure saveData;//Сохранение всех данных\r
+ procedure loadData;//Загрузка всех данных\r
+ procedure resetData;//Сброс всех данных\r
+\r
+ procedure loadSkin(path:string);//Загрузка текстур\r
+ procedure freeSkin;//Выгрузка текстур\r
+\r
+implementation\r
+ uses phy, player, canvas, func;\r
+ const\r
+ MAX_MOBS=31;\r
+ MAX_ANIMREG=3;\r
+\r
+ AI_NONE=0;\r
+ AI_ZLOY=1;\r
+ var\r
+ mob_type, mob_x, mob_y, mob_vx, mob_vy, mob_posi, mob_hp:array [0..MAX_MOBS] of integer;\r
+ mob_jmp:array [0..MAX_MOBS] of boolean;\r
+ mob_anim:array [0..MAX_MOBS, 0..MAX_ANIMREG] of integer;\r
+ tab_w, tab_h, tab_hp, tab_speedx, tab_jumph, tab_ai:array [0..MOB_TYPES] of integer;\r
+\r
+ texture_left, texture_right:array [0..MOB_TYPES, 0..0] of image;\r
+ tex_x, tex_y, tex_w, tex_h:array [0..1, 0..MOB_TYPES, 0..0] of integer;\r
+\r
+ part_max: array [0..MOB_TYPES] of integer;\r
+ part_tex, part_x, part_y, part_anim: array [0..MOB_TYPES, 0..0] of integer;\r
+ \r
+ function getType(i:integer):integer;\r
+ begin\r
+ getType:=mob_type[i];\r
+ end;\r
+\r
+ function getX(i:integer):integer;\r
+ begin\r
+ getX:=mob_x[i];\r
+ end;\r
+\r
+ function getY(i:integer):integer;\r
+ begin\r
+ getY:=mob_y[i];\r
+ end;\r
+\r
+ function getVX(i:integer):integer;\r
+ begin\r
+ getVX:=mob_vx[i];\r
+ end;\r
+\r
+ function getVY(i:integer):integer;\r
+ begin\r
+ getVY:=mob_vy[i];\r
+ end;\r
+\r
+ function getPosi(i:integer):integer;\r
+ begin\r
+ getPosi:=mob_posi[i];\r
+ end;\r
+\r
+ function getHp(i:integer):integer;\r
+ begin\r
+ getHp:=mob_hp[i];\r
+ end;\r
+\r
+ function getW(i:integer):integer;\r
+ begin\r
+ getW:=tab_w[mob_type[i]];\r
+ end;\r
+\r
+ function getH(i:integer):integer;\r
+ begin\r
+ getH:=tab_h[mob_type[i]];\r
+ end;\r
+\r
+ function getSpeedX(i:integer):integer;\r
+ begin\r
+ getSpeedX:=tab_speedx[mob_type[i]];\r
+ end;\r
+\r
+ function getJumpH(i:integer):integer;\r
+ begin\r
+ getJumpH:=tab_jumph[mob_type[i]];\r
+ end;\r
+\r
+ function getJmp(i:integer):boolean;\r
+ begin\r
+ getJmp:=mob_jmp[i];\r
+ end;\r
+\r
+ procedure setType(value, i:integer);\r
+ begin\r
+ mob_type[i]:=value;\r
+ end;\r
+\r
+ procedure setX(value, i:integer);\r
+ begin\r
+ mob_x[i]:=value;\r
+ end;\r
+\r
+ procedure setY(value, i:integer);\r
+ begin\r
+ mob_y[i]:=value;\r
+ end;\r
+\r
+ procedure setVX(value, i:integer);\r
+ begin\r
+ mob_vx[i]:=value;\r
+ end;\r
+\r
+ procedure setVY(value, i:integer);\r
+ begin\r
+ mob_vy[i]:=value;\r
+ end;\r
+\r
+ procedure setPosi(value, i:integer);\r
+ begin\r
+ mob_posi[i]:=value;\r
+ end;\r
+\r
+ procedure setHp(value, i:integer);\r
+ begin\r
+ mob_hp[i]:=value;\r
+ end;\r
+\r
+ procedure setJmp(value:boolean; i:integer);\r
+ begin\r
+ mob_jmp[i]:=value;\r
+ end;\r
+\r
+ procedure initTab(_type, w, h, hp, speedx, jumph, ai:integer);\r
+ begin\r
+ tab_w[_type]:=w;\r
+ tab_h[_type]:=h;\r
+ tab_hp[_type]:=hp;\r
+ tab_speedx[_type]:=speedx;\r
+ tab_jumph[_type]:=jumph;\r
+ tab_ai[_type]:=ai;\r
+ end;\r
+\r
+ procedure initTexture(img:image; mobtype, texid, posi, centerx, centery:integer);\r
+ begin\r
+ tex_w[posi, mobtype, texid]:=getImageWidth(img);\r
+ tex_h[posi, mobtype, texid]:=getImageHeight(img);\r
+ if posi=0 then\r
+ texture_left[mobtype, texid]:=img;\r
+ else\r
+ texture_right[mobtype, texid]:=img;\r
+ tex_x[posi, mobtype, texid]:=centerx;\r
+ tex_y[posi, mobtype, texid]:=centery;\r
+ end;\r
+\r
+ procedure setMaxTextures(mobtype, max:integer);\r
+ var\r
+ i:integer;\r
+ begin\r
+ max:=max+1;\r
+ debug('setMaxTextures(mobtype, max:integer);');\r
+ bytecode\r
+ getstatic field 'mob', 'texture_left', '[[Ljavax/microedition/lcdui/Image;';\r
+ iload 0;\r
+ iload 1;\r
+ multianewarray class '[Ljavax/microedition/lcdui/Image;', 1;\r
+ aastore;\r
+\r
+ getstatic field 'mob', 'texture_right', '[[Ljavax/microedition/lcdui/Image;';\r
+ iload 0;\r
+ iload 1;\r
+ multianewarray class '[Ljavax/microedition/lcdui/Image;', 1;\r
+ aastore;\r
+ end;\r
+\r
+ for i:=0 to 1 do\r
+ bytecode\r
+ //tex_x[i][mobtype]=new int[max];\r
+ getstatic field 'mob', 'tex_x', '[[[I';\r
+ iload_2; \r
+ aaload; \r
+ iload_0; \r
+ iload_1;\r
+ multianewarray class '[I', 1; \r
+ aastore;\r
+\r
+ getstatic field 'mob', 'tex_y', '[[[I';\r
+ iload_2; \r
+ aaload; \r
+ iload_0; \r
+ iload_1;\r
+ multianewarray class '[I', 1; \r
+ aastore;\r
+\r
+ getstatic field 'mob', 'tex_w', '[[[I';\r
+ iload_2; \r
+ aaload; \r
+ iload_0; \r
+ iload_1;\r
+ multianewarray class '[I', 1; \r
+ aastore;\r
+ \r
+ getstatic field 'mob', 'tex_h', '[[[I';\r
+ iload_2; \r
+ aaload; \r
+ iload_0; \r
+ iload_1;\r
+ multianewarray class '[I', 1; \r
+ aastore;\r
+ end;\r
+ end;\r
+\r
+ procedure setMaxParts(mobtype, max:integer);\r
+ begin\r
+ part_max[mobtype]:=max;\r
+ max:=max+1;\r
+ \r
+ bytecode\r
+ getstatic field 'mob', 'part_tex', '[[I';\r
+ iload_0; \r
+ iload_1;\r
+ multianewarray class '[I', 1; \r
+ aastore;\r
+\r
+ getstatic field 'mob', 'part_x', '[[I';\r
+ iload_0; \r
+ iload_1;\r
+ multianewarray class '[I', 1; \r
+ aastore;\r
+\r
+ getstatic field 'mob', 'part_y', '[[I';\r
+ iload_0; \r
+ iload_1;\r
+ multianewarray class '[I', 1; \r
+ aastore;\r
+\r
+ getstatic field 'mob', 'part_anim', '[[I';\r
+ iload_0; \r
+ iload_1;\r
+ multianewarray class '[I', 1; \r
+ aastore;\r
+ end;\r
+ end;\r
+\r
+ procedure initPart(mobtype, partid, tex, x, y, animreg:integer);\r
+ begin\r
+ part_tex[mobtype, partid]:=tex;\r
+ part_x[mobtype, partid]:=x;\r
+ part_y[mobtype, partid]:=y;\r
+ part_anim[mobtype, partid]:=animreg;\r
+ end;\r
+\r
+procedure loadPhy(i:integer);\r
+ begin\r
+ phy.loadObject(mob_x[i], mob_y[i], tab_w[mob_type[i]], tab_h[mob_type[i]], mob_vx[i], mob_vy[i], mob_jmp[i]);\r
+ end;\r
+\r
+procedure storePhy(i:integer);\r
+ begin\r
+ mob_x[i]:=phy.getX;\r
+ mob_y[i]:=phy.getY;\r
+ mob_vx[i]:=phy.getVelX;\r
+ mob_vy[i]:=phy.getVelY;\r
+ mob_jmp[i]:=phy.getJmp;\r
+ end;\r
+\r
+{===== =====}\r
+\r
+ procedure create(_type, x, y:integer);//Создать моба\r
+ var\r
+ i, j:integer;\r
+ begin\r
+ debug('Create mob '+_type+' @ '+x+'x'+y);\r
+ for i:=0 to MAX_MOBS do\r
+ if mob_type[i]=M_NONE then\r
+ begin\r
+ mob_type[i]:=_type;\r
+ mob_x[i]:=x;\r
+ mob_y[i]:=y;\r
+ mob_vx[i]:=0;\r
+ mob_vy[i]:=0;\r
+ mob_posi[i]:=0;\r
+ mob_hp[i]:=tab_hp[_type];\r
+ mob_jmp[i]:=false;\r
+ for j:=0 to MAX_ANIMREG do\r
+ mob_anim[i, j]:=0;\r
+\r
+ debug('Created mob is '+i);\r
+ exit;\r
+ end;\r
+ end;\r
+\r
+ procedure die(i:integer);//Убить\r
+ begin\r
+ mob_type[i]:=M_NONE;\r
+ end;\r
+\r
+ procedure hit(value, i:integer);//Нанести урон\r
+ var\r
+ hp:integer;\r
+ begin\r
+ hp:=getHp(i)-value;\r
+ if hp>0 then\r
+ setHp(hp, i);\r
+ else\r
+ die(i);\r
+ end;\r
+\r
+ function findAndHit(value, x, y, w, h, addvx, addvy:integer):integer;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to MAX_MOBS do\r
+ if getType(i)<>M_NONE then\r
+ if CollTwoObj(x, y, w, h, getX(i), getY(i), getW(i), getH(i)) then\r
+ begin\r
+ setVX(getVX(i)+addvx, i);\r
+ setVX(getVY(i)+addvy, i);\r
+ hit(value, i);\r
+ findAndHit:=i;\r
+ exit;\r
+ end;\r
+\r
+ findAndHit:=-1;\r
+ end;\r
+\r
+ procedure goUp(i:integer);\r
+ begin\r
+ loadPhy(i);\r
+ phy.jumpObj(getJumpH(i));\r
+ storePhy(i);\r
+ end;\r
+\r
+ procedure goDown(i:integer);\r
+ begin\r
+ \r
+ end;\r
+\r
+ procedure goLeft(i:integer);\r
+ begin\r
+ setVX(-getSpeedX(i), i);\r
+ setPosi(0, i);\r
+ end;\r
+\r
+ procedure goRight(i:integer);\r
+ begin\r
+ setVX(getSpeedX(i), i);\r
+ setPosi(1, i);\r
+ end;\r
+\r
+ function testSolid(i, vector:integer):boolean;\r
+ var\r
+ x, y:integer;\r
+ begin\r
+ y:=((getY(i)+getH(i)))/16-1;\r
+\r
+ if vector<0 then\r
+ begin\r
+ x:=(getX(i)/16)-1;\r
+ end;\r
+ else\r
+ if vector>0 then\r
+ begin\r
+ x:=((getX(i)+getW(i))/16){+1};\r
+ end;\r
+ else\r
+ x:=((getX(i)+getW(i)/2)/16);\r
+\r
+ testSolid:=phy.isSolid(x, y, getVX(i), getVY(i));\r
+ end;\r
+\r
+ procedure updateZloyAiAnim(i:integer);\r
+ const\r
+ DEL=1;\r
+ var\r
+ a_a, a_d, a_f:integer;\r
+ begin\r
+ a_a:=mob_anim[i, 1];\r
+ a_d:=mob_anim[i, 2];\r
+ a_f:=mob_anim[i, 3];\r
+\r
+ a_d:=a_d+1;\r
+ if a_d>DEL then\r
+ begin\r
+ a_d:=0;\r
+ a_a:=a_a+1;\r
+ if a_f=1 then\r
+ begin\r
+ a_a:=0;\r
+ a_f:=0;\r
+ end;\r
+ else\r
+ if a_a=3 then\r
+ begin\r
+ a_a:=1;\r
+ a_f:=1;\r
+ end;\r
+ end;\r
+\r
+ mob_anim[i, 1]:=a_a;\r
+ mob_anim[i, 2]:=a_d;\r
+ mob_anim[i, 3]:=a_f;\r
+ end;\r
+\r
+ procedure updateZloyAi(i:integer);\r
+ begin\r
+ if player.getX<getX(i) then\r
+ begin\r
+ goLeft(i);\r
+ updateZloyAiAnim(i);\r
+ if testSolid(i, -1) then\r
+ goUp(i);\r
+ end;\r
+ else\r
+ if player.getX>getX(i) then\r
+ begin\r
+ goRight(i);\r
+ updateZloyAiAnim(i);\r
+ if testSolid(i, 1) then\r
+ goUp(i);\r
+ end;\r
+ end;\r
+\r
+ procedure update;//Обновление логики\r
+ var\r
+ i, _type, ai:integer;\r
+ begin\r
+ for i:=0 to MAX_MOBS do\r
+ begin\r
+ _type:=getType(i);\r
+\r
+ if _type<>M_NONE then\r
+ begin\r
+ ai:=tab_ai[_type];\r
+ if ai=AI_ZLOY then\r
+ updateZloyAi(i);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure updatePhy;//Обновление физики\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to MAX_MOBS do\r
+ begin\r
+ loadPhy(i);\r
+ phy.calc(true);\r
+ storePhy(i);\r
+ end;\r
+ end;\r
+\r
+ procedure drawPart(mobtype, texid, posi, anim, x, y, camx, camy:integer);\r
+ begin\r
+ x:=x-tex_x[posi, mobtype, texid]-camx;\r
+ y:=y-tex_y[posi, mobtype, texid]-camy;\r
+\r
+ if CollTwoObj(x, y, tex_w[posi, mobtype, texid], tex_h[posi, mobtype, texid], 0, 0, getWidth, getHeight) then\r
+ if posi=0 then\r
+ drawImage(texture_left[mobtype, texid+anim], x, y);\r
+ else\r
+ drawImage(texture_right[mobtype, texid+anim], x, y);\r
+ end;\r
+\r
+ procedure draw(camx, camy:integer);//Отрисовка\r
+ var\r
+ i, j, _type:integer;\r
+ begin\r
+ for i:=0 to MAX_MOBS do\r
+ begin\r
+ _type:=mob_type[i];\r
+ if _type<>M_NONE then\r
+ begin\r
+ for j:=0 to part_max[_type] do\r
+ drawPart(_type, part_tex[_type, j], mob_posi[i], mob_anim[i, part_anim[_type, j]], mob_x[i]+part_x[_type, j], mob_y[i]+part_y[_type, j], camx, camy);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure loadSkin(path:string);//Загрузка текстур\r
+ var\r
+ im:image;\r
+ begin\r
+ setMaxTextures(M_ZOMBY, 5);\r
+ im:=ld_tex('zombie_ani.png', path, 'mobs/');\r
+ // IMG, TYPE, ID, POSI, X, Y \r
+ initTexture(rotate_image_from_image(im, 6, 2, 8, 8, 0), M_ZOMBY, 0, 0, 4, 8);//head[left]\r
+ initTexture(rotate_image_from_image(im, 8, 10, 4, 12, 0), M_ZOMBY, 1, 0, 2, 0);//body[left]\r
+ initTexture(rotate_image_from_image(im, 0, 10, 12, 4, 0), M_ZOMBY, 2, 0, 10, 2);//hands[left]\r
+ initTexture(rotate_image_from_image(im, 0, 52, 12, 12, 0), M_ZOMBY, 3, 0, 6, 0);//legs[left]\r
+ initTexture(rotate_image_from_image(im, 13, 52, 12, 12, 0), M_ZOMBY, 4, 0, 6, 0);\r
+ initTexture(rotate_image_from_image(im, 26, 52, 12, 12, 0), M_ZOMBY, 5, 0, 6, 0);\r
+\r
+ initTexture(rotate_image_from_image(im, 27, 2, 8, 8, 0), M_ZOMBY, 0, 1, 4, 8);//head[right]\r
+ initTexture(rotate_image_from_image(im, 29, 10, 4, 12, 0), M_ZOMBY, 1, 1, 2, 0);//body[right]\r
+ initTexture(rotate_image_from_image(im, 29, 10, 12, 4, 0), M_ZOMBY, 2, 1, 2, 2);//hands[right]\r
+ initTexture(rotate_image_from_image(im, 39, 52, 12, 12, 0), M_ZOMBY, 3, 1, 6, 0);//legs[right]\r
+ initTexture(rotate_image_from_image(im, 52, 52, 12, 12, 0), M_ZOMBY, 4, 1, 6, 0);\r
+ initTexture(rotate_image_from_image(im, 65, 52, 12, 12, 0), M_ZOMBY, 5, 1, 6, 0);\r
+ end;\r
+\r
+ procedure freeSkin;//Выгрузка текстур\r
+ var\r
+ i, j, len:integer;\r
+ nullimg:image;\r
+ begin\r
+ for i:=0 to MOB_TYPES do\r
+ begin\r
+ bytecode\r
+ getstatic field 'mob', 'texture_left', '[[Ljavax/microedition/lcdui/Image;';\r
+ iload_0;//i\r
+ aaload;\r
+ arraylength;\r
+ iconst_1;\r
+ isub;\r
+ istore_2;//len\r
+ end;\r
+ for j:=0 to len do\r
+ begin\r
+ texture_left[i, j]:=nullimg;\r
+ texture_right[i, j]:=nullimg;\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure saveData;//Сохранение всех данных\r
+ begin\r
+\r
+ end;\r
+\r
+ procedure loadData;//Загрузка всех данных\r
+ begin\r
+\r
+ end;\r
+\r
+ procedure resetData;//Сброс всех данных\r
+ var\r
+ i, j:integer;\r
+ begin\r
+ for i:=0 to MAX_MOBS do\r
+ begin\r
+ mob_type[i]:=M_NONE;\r
+ mob_x[i]:=0;\r
+ mob_y[i]:=0;\r
+ mob_vx[i]:=0;\r
+ mob_vy[i]:=0;\r
+ mob_posi[i]:=0;\r
+ mob_hp[i]:=0;\r
+ mob_jmp[i]:=false;\r
+ for j:=0 to MAX_ANIMREG do\r
+ mob_anim[i, j]:=0;\r
+ end;\r
+ end;\r
+\r
+initialization\r
+ // TYPE W H HP SX JH, AI_TYPE\r
+ initTab(M_NONE, 0, 0, 0, 0, 0, AI_NONE);\r
+ setMaxParts(M_NONE, -1);\r
+\r
+ initTab(M_ZOMBY, 8, 32, 10, 1, 7, AI_ZLOY);\r
+ setMaxParts(M_ZOMBY, 3);\r
+ // TYPE PART, TEX, X, Y ANIM\r
+ initPart(M_ZOMBY, 0, 0, 4, 8, 0);//Head\r
+ initPart(M_ZOMBY, 1, 1, 4, 8, 0);//Body\r
+ initPart(M_ZOMBY, 2, 2, 4, 10, 0);//Hands\r
+ initPart(M_ZOMBY, 3, 3, 4, 20, 1);//Legs\r
+end.\r
diff --git a/src/particles.mpsrc b/src/particles.mpsrc
--- /dev/null
+++ b/src/particles.mpsrc
@@ -0,0 +1,139 @@
+unit particles;\r
+\r
+interface\r
+ var\r
+ bubble:image;\r
+ pr_1:array [0..7] of image;\r
+ none1:image;\r
+ pr_2:array [0..7] of image;\r
+ none2:image;\r
+ pr_3:array [0..7] of image;\r
+ none3:image;\r
+ pr_4:array [0..7] of image;\r
+ none4:image;\r
+ pr_5:array [0..7] of image;\r
+ none5:image;\r
+ pr_boom:array [0..15] of image;\r
+ none6:image;\r
+ \r
+ max_particles:integer;\r
+ s_particles:boolean;\r
+ gb_up_pa:integer;\r
+\r
+ procedure create_particle(tp,ix,iy:integer);\r
+ procedure update_particle;\r
+ procedure draw_particle;\r
+\r
+implementation\r
+ uses vars,maps,particles_store;\r
+\r
+procedure create_particle(tp,ix,iy:integer);\r
+ var\r
+ i:integer;\r
+ begin\r
+ if s_particles=true then\r
+ for i:=0 to max_particles do\r
+ if get_particle_type(i)=0 then\r
+ begin\r
+ set_particle(i,tp,0,ix,iy);\r
+ exit;\r
+ end;\r
+ end;\r
+\r
+procedure null_particle(i:integer);\r
+ begin\r
+ set_particle(i,0,0,0,0);\r
+ end;\r
+\r
+procedure pr_ai_1(i,maxani:integer);\r
+ begin\r
+ set_particle_y(i,get_particle_y(i)-1);\r
+ set_particle_ani(i,get_particle_ani(i)+1);\r
+ if get_particle_ani(i)>maxani then null_particle(i);\r
+ end;\r
+\r
+procedure pr_ai_bubble(i:integer);\r
+ var\r
+ xx,yy:integer;\r
+ begin\r
+ set_particle_y(i,get_particle_y(i)-1);\r
+ xx:=get_particle_x(i) div 16;\r
+ yy:=get_particle_y(i) div 16;\r
+ if getmap(xx,yy)<>50 then null_particle(i);\r
+ end;\r
+\r
+procedure pr_ai_boom(i:integer);\r
+ begin\r
+ set_particle_ani(i,get_particle_ani(i)+1);\r
+ if get_particle_ani(i)>15 then null_particle(i);\r
+ end;\r
+\r
+procedure update_particle;\r
+ var\r
+ i:integer;\r
+ begin\r
+ if s_particles=true then\r
+ begin\r
+ for i:=0 to max_particles do\r
+ if get_particle_type(i)>0 then\r
+ begin\r
+ if get_particle_type(i)=1 then pr_ai_1(i,5); else\r
+ if get_particle_type(i)=2 then pr_ai_1(i,5); else\r
+ if get_particle_type(i)=3 then pr_ai_1(i,5); else\r
+ if get_particle_type(i)=4 then pr_ai_1(i,5); else\r
+ if get_particle_type(i)=5 then pr_ai_1(i,5); else\r
+ if get_particle_type(i)=6 then pr_ai_bubble(i); else\r
+ if get_particle_type(i)=7 then pr_ai_boom(i); else\r
+ null_particle(i);\r
+ end;\r
+ gb_up_pa:=gb_up_pa+1;\r
+ if gb_up_pa>=2 then gb_up_pa:=0;\r
+ end;\r
+ end;\r
+\r
+procedure draw_particle;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to max_particles do\r
+ if get_particle_type(i)>0 then\r
+ begin\r
+ if get_particle_type(i)=1 then\r
+ begin\r
+ if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
+ drawimage(pr_1[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
+ end; else\r
+ if get_particle_type(i)=2 then\r
+ begin\r
+ if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
+ drawimage(pr_2[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
+ end; else\r
+ if get_particle_type(i)=3 then\r
+ begin\r
+ if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
+ drawimage(pr_3[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
+ end; else\r
+ if get_particle_type(i)=4 then\r
+ begin\r
+ if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
+ drawimage(pr_4[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
+ end; else\r
+ if get_particle_type(i)=5 then\r
+ begin\r
+ if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
+ drawimage(pr_4[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
+ end; else\r
+ if get_particle_type(i)=6 then\r
+ begin\r
+ if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
+ drawimage(bubble,get_particle_x(i)-camx,get_particle_y(i)-camy);\r
+ end; else\r
+ if get_particle_type(i)=7 then\r
+ begin\r
+ if (get_particle_x(i)-camx>-32) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-32) and (get_particle_y(i)-camy<getheight) then\r
+ drawimage(pr_boom[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+end.\r
diff --git a/src/phy.pas b/src/phy.pas
--- /dev/null
+++ b/src/phy.pas
@@ -0,0 +1,325 @@
+unit phy;\r
+\r
+interface\r
+ procedure loadObject(_x, _y, _w, _h, _velx, _vely:integer; _jmp:boolean);\r
+\r
+ function isSolid(x, y, velx, vely:integer):boolean;\r
+\r
+ function mapCollType(_type, x, y, w, h:integer):boolean;\r
+\r
+ function CollTwoObj(x1,y1,w1,h1,x2,y2,w2,h2:integer):boolean;\r
+\r
+ procedure jumpObj(vel:integer);\r
+ procedure calc(gravity:boolean);\r
+\r
+ function getX:integer;\r
+ function getY:integer;\r
+ function getVelX:integer;\r
+ function getVelY:integer;\r
+ function getJmp:boolean;\r
+\r
+ function canSeeObj(x1, y1, x2, y2:integer):boolean;\r
+\r
+implementation\r
+ uses items_store, maps;\r
+ const\r
+ MAX_VELY=32;\r
+ TILE_SIZE=16;\r
+ var\r
+ x, y, w, h, velx, vely:integer;\r
+ jmp:boolean;\r
+\r
+function CollTwoObj(x1,y1,w1,h1,x2,y2,w2,h2:integer):boolean;\r
+ begin\r
+ if (x1+w1>x2) and (x1<x2+w2) and (y1+h1>y2) and (y1<y2+h2) then\r
+ CollTwoObj:=true;\r
+ end;\r
+\r
+ procedure loadObject(_x, _y, _w, _h, _velx, _vely:integer; _jmp:boolean);\r
+ begin\r
+ x:=_x;\r
+ y:=_y;\r
+ w:=_w;\r
+ h:=_h;\r
+ velx:=_velx;\r
+ vely:=_vely;\r
+ jmp:=_jmp;\r
+ end;\r
+\r
+ function isSolid(x, y, velx, vely:integer):boolean;\r
+ begin\r
+ if getBlockColl(getMap(x, y))<>0 then\r
+ isSolid:=true;\r
+ end;\r
+\r
+ function mapColl(x, y, w, h, velx, vely:integer):boolean;\r
+ var\r
+ i, j:integer;\r
+ minx, miny, maxx, maxy:integer;\r
+ begin\r
+ minx:=x div TILE_SIZE;\r
+ miny:=y div TILE_SIZE;\r
+ maxx:=(x+w-1) div TILE_SIZE;\r
+ maxy:=(y+h-1) div TILE_SIZE;\r
+ for i:=minx to maxx do\r
+ for j:=miny to maxy do\r
+ begin\r
+ if isSolid(i, j, velx, vely) then\r
+ begin\r
+ mapColl:=true;\r
+ exit;\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ function canSeeObj(x1, y1, x2, y2:integer):boolean;\r
+ var\r
+ deltax, deltay:integer;\r
+ signx, signy:integer;\r
+ error, error2:integer;\r
+ begin\r
+ x1:=x1/TILE_SIZE;\r
+ y1:=y1/TILE_SIZE;\r
+ x2:=x2/TILE_SIZE;\r
+ y2:=y2/TILE_SIZE;\r
+ \r
+ deltax:=abs(x2-x1);\r
+ deltay:=abs(y2-y1);\r
+\r
+ if x1<x2 then\r
+ signx:=1;\r
+ else\r
+ signx:=-1;\r
+\r
+ if y1<y2 then\r
+ signy:=1;\r
+ else\r
+ signy:=-1;\r
+\r
+ error:=deltaX-deltaY;\r
+\r
+ while((x1<>x2) or (y1<>y2)) do\r
+ begin\r
+ if isSolid(x1, y1, 0, 0) then\r
+ exit;\r
+\r
+ error2:=error<<1;\r
+ if error2>-deltaY then\r
+ begin\r
+ error:=error-deltaY;\r
+ x1:=x1+signX;\r
+ end;\r
+\r
+ if error2<deltaX then\r
+ begin\r
+ error:=error+deltaX;\r
+ y1:=y1+signY;\r
+ end;\r
+ end;\r
+ canSeeObj:=true;\r
+ end;\r
+\r
+ function mapCollType(_type, x, y, w, h:integer):boolean;\r
+ var\r
+ i, j:integer;\r
+ minx, miny, maxx, maxy:integer;\r
+ begin\r
+ minx:=x div TILE_SIZE;\r
+ miny:=y div TILE_SIZE;\r
+ maxx:=(x+w-1) div TILE_SIZE;\r
+ maxy:=(y+h-1) div TILE_SIZE;\r
+ for i:=minx to maxx do\r
+ for j:=miny to maxy do\r
+ begin\r
+ if getMap(i, j)=_type then\r
+ begin\r
+ mapCollType:=true;\r
+ exit;\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure calcGravity;\r
+ var\r
+ i:integer;\r
+ begin\r
+ vely:=vely+1;\r
+ if vely>MAX_VELY then\r
+ vely:=MAX_VELY;\r
+\r
+ jmp:=false;\r
+\r
+ if vely>0 then\r
+ for i:=1 to vely do\r
+ begin\r
+ y:=y+1;\r
+ if mapColl(x, y, w, h, velx, vely) then\r
+ begin\r
+ y:=y-1;\r
+ vely:=0;\r
+ jmp:=true;\r
+ break;\r
+ end;\r
+ end;\r
+ else\r
+ for i:=1 to abs(vely) do\r
+ begin\r
+ y:=y-1;\r
+ if mapColl(x, y, w, h, velx, vely) then\r
+ begin\r
+ y:=y+1;\r
+ vely:=0;\r
+ jmp:=false;\r
+ break;\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ function fixVYup:boolean;\r
+ begin\r
+ if (vely>-5) and\r
+ (mapCollType(49, x, y, w, h) or \r
+ mapCollType(103, x, y, w, h) or\r
+ mapCollType(108, x, y, w, h)) then\r
+ vely:=vely-2;\r
+ else\r
+ if (vely>-4) and\r
+ (mapCollType(50, x, y, w, h) or \r
+ mapCollType(51, x, y, w, h)) then\r
+ vely:=vely-2;\r
+ else\r
+ fixVYup:=true;\r
+ end;\r
+\r
+ procedure fixVYdown;\r
+ begin\r
+ if (vely>5) and\r
+ (mapCollType(49, x, y, w, h) or \r
+ mapCollType(103, x, y, w, h)) then\r
+ vely:=5;\r
+ else\r
+ if (vely>4) and\r
+ (mapCollType(50, x, y, w, h) or \r
+ mapCollType(51, x, y, w, h)) then\r
+ vely:=4;\r
+ end;\r
+\r
+ procedure jumpObj(vel:integer);\r
+ begin\r
+ if fixVYup then\r
+ if jmp then\r
+ begin\r
+ vely:=-vel;\r
+ jmp:=false;\r
+ end;\r
+ end;\r
+\r
+ procedure calcX;\r
+ var\r
+ i:integer;\r
+ begin\r
+ if velx>0 then\r
+ for i:=1 to velx do\r
+ begin\r
+ x:=x+1;\r
+ if mapColl(x, y, w, h, velx, vely) then\r
+ begin\r
+ x:=x-1;\r
+ velx:=0;\r
+ break;\r
+ end;\r
+ end;\r
+ else\r
+ if velx<0 then\r
+ for i:=1 to abs(velx) do //there for-downto-do have a bug!\r
+ begin\r
+ x:=x-1;\r
+ if mapColl(x, y, w, h, velx, vely) then\r
+ begin\r
+ x:=x+1;\r
+ velx:=0;\r
+ break;\r
+ end;\r
+ end;\r
+\r
+ if velx>0 then\r
+ velx:=velx-1;\r
+ else\r
+ if velx<0 then\r
+ velx:=velx+1;\r
+ end;\r
+\r
+ procedure calcY;\r
+ var\r
+ i:integer;\r
+ begin\r
+ if vely>0 then\r
+ for i:=1 to vely do\r
+ begin\r
+ y:=y+1;\r
+ if mapColl(x, y, w, h, velx, vely) then\r
+ begin\r
+ y:=y-1;\r
+ vely:=0;\r
+ break;\r
+ end;\r
+ end;\r
+ else\r
+ if vely<0 then\r
+ for i:=1 to abs(vely) do //there for-downto-do have a bug!\r
+ begin\r
+ y:=y-1;\r
+ if mapColl(x, y, w, h, velx, vely) then\r
+ begin\r
+ y:=y+1;\r
+ velx:=0;\r
+ break;\r
+ end;\r
+ end;\r
+\r
+ if vely>0 then\r
+ vely:=vely-1;\r
+ else\r
+ if vely<0 then\r
+ vely:=vely+1;\r
+ end;\r
+\r
+ function getX:integer;\r
+ begin\r
+ getX:=x;\r
+ end;\r
+\r
+ function getY:integer;\r
+ begin\r
+ getY:=y;\r
+ end;\r
+\r
+ function getVelX:integer;\r
+ begin\r
+ getVelX:=velx;\r
+ end;\r
+\r
+ function getVelY:integer;\r
+ begin\r
+ getVelY:=vely;\r
+ end;\r
+\r
+ function getJmp:boolean;\r
+ begin\r
+ getJmp:=jmp;\r
+ end;\r
+\r
+ procedure calc(gravity:boolean);\r
+ begin\r
+ calcX;\r
+\r
+ if gravity then\r
+ begin\r
+ calcGravity;\r
+ fixVYdown;\r
+ end;\r
+ else \r
+ calcY;\r
+ end;\r
+\r
+end.\r
diff --git a/src/player.mpsrc b/src/player.mpsrc
--- /dev/null
+++ b/src/player.mpsrc
@@ -0,0 +1,363 @@
+unit player;\r
+\r
+interface\r
+ const\r
+ ANIM_HAND=0;\r
+ ANIM_LEGS=1;\r
+\r
+ var\r
+ fly:boolean;\r
+ hp, hunger, air:integer;\r
+ posi:integer;//Сторона в которую повёрнут игрок\r
+ velx,vely:integer;//Переменные для физики игрока\r
+ jmp, an_pr:boolean;\r
+ s_get_drp:boolean;\r
+ invslot:integer;\r
+\r
+ procedure setX(val:integer);\r
+ procedure setY(val:integer);\r
+ function getX:integer;\r
+ function getY:integer;\r
+ function getW:integer;\r
+ function getH:integer;\r
+\r
+ procedure loadSkin(str, path:string);\r
+ procedure freeSkin;\r
+ procedure draw(camx, camy:integer);\r
+ procedure playAnim(anim:integer);\r
+ procedure cancelAnim(anim:integer);\r
+\r
+ procedure dropItem(item, sum:integer);\r
+\r
+ procedure calcPhysics;\r
+\r
+ procedure gotoUP;\r
+ procedure gotoDOWN;\r
+ procedure gotoLEFT;\r
+ procedure gotoRIGHT;\r
+\r
+ procedure getDrop;\r
+\r
+implementation\r
+ uses func, phy, vars, Canvas, drop, items, jsr75i, inv;\r
+ const\r
+ PLAYER_W=8;\r
+ PLAYER_H=32;\r
+ PLAYER_SPEED=2;\r
+\r
+ POSI_LEFT=0;\r
+ POSI_RIGHT=1;\r
+ PLAYER_ANIM_DEL=1;\r
+ var\r
+ plx, ply:integer;\r
+\r
+ //Skin\r
+ PlayerBody: array [0..1] of image;\r
+ PlayerHand: array [0..1, 0..3] of image;\r
+ PlayerLegs: array [0..1, 0..2] of image;\r
+ animHand, animLegs, animDelay:integer;\r
+\r
+ procedure setX(val:integer);\r
+ begin\r
+ plx:=val;\r
+ end;\r
+\r
+ procedure setY(val:integer);\r
+ begin\r
+ ply:=val;\r
+ end;\r
+\r
+ function getX:integer;\r
+ begin\r
+ getX:=plx;\r
+ end;\r
+\r
+ function getY:integer;\r
+ begin\r
+ getY:=ply;\r
+ end;\r
+\r
+ function getW:integer;\r
+ begin\r
+ getW:=PLAYER_W;\r
+ end;\r
+\r
+ function getH:integer;\r
+ begin\r
+ getH:=PLAYER_H;\r
+ end;\r
+\r
+ procedure setVelX(val:integer);\r
+ begin\r
+ velx:=val;\r
+ end;\r
+\r
+ procedure setVelY(val:integer);\r
+ begin\r
+ vely:=val;\r
+ end;\r
+\r
+ function getVelX:integer;\r
+ begin\r
+ getVelX:=velx;\r
+ end;\r
+\r
+ function getVelY:integer;\r
+ begin\r
+ getVelY:=vely;\r
+ end;\r
+\r
+ procedure setJmp(val:boolean);\r
+ begin\r
+ jmp:=val;\r
+ end;\r
+\r
+ function getJmp:boolean;\r
+ begin\r
+ getJmp:=jmp;\r
+ end;\r
+\r
+ procedure dropItem(item, sum:integer);\r
+ begin\r
+ if posi=POSI_LEFT then\r
+ drop.create(item, sum, getX-8, getY);\r
+ else\r
+ drop.create(item, sum, getX+getW, getY);\r
+ end;\r
+\r
+ procedure loadSkin(str, path:string);\r
+ var\r
+ im:image;\r
+ i:integer;\r
+ begin\r
+ im:=ld_tex(str, path, 'mobs/');\r
+\r
+ PlayerBody[POSI_LEFT]:=rotate_image_from_image(im, 0, 0, 8, 20, 0);\r
+ PlayerBody[POSI_RIGHT]:=rotate_image_from_image(im, 8, 0, 8, 20, 0);\r
+\r
+ PlayerHand[POSI_LEFT, 0]:=rotate_image_from_image(im, 40, 0, 4, 12, 0);\r
+ PlayerHand[POSI_RIGHT, 0]:=rotate_image_from_image(im, 44, 0, 4, 12, 0);\r
+\r
+ for i:=1 to 3 do\r
+ begin\r
+ PlayerHand[POSI_LEFT, i]:=rotate_image_from_image(im, 16, (i-1)*6, 12, 6, 0);\r
+ PlayerHand[POSI_RIGHT, i]:=rotate_image_from_image(im, 28, (i-1)*6, 12, 6, 0);\r
+ end;\r
+\r
+ for i:=0 to 2 do\r
+ begin\r
+ PlayerLegs[POSI_LEFT, i]:=rotate_image_from_image(im, i*12, 20, 12, 12, 0);\r
+ PlayerLegs[POSI_RIGHT, i]:=rotate_image_from_image(im, 36+i*12, 20, 12, 12, 0);\r
+ end;\r
+ end;\r
+\r
+ procedure freeSkin;\r
+ var\r
+ i, j:integer;\r
+ nullimg:image;\r
+ begin\r
+ for i:=0 to 1 do\r
+ begin\r
+ PlayerBody[i]:=nullimg;\r
+ for j:=0 to 3 do\r
+ PlayerHand[i, j]:=nullimg;\r
+ for j:=0 to 2 do\r
+ PlayerLegs[i, j]:=nullimg;\r
+ end;\r
+ end;\r
+\r
+ procedure playAnim(anim:integer);\r
+ begin\r
+ if anim=ANIM_HAND then\r
+ begin\r
+ animHand:=animHand+1;\r
+ if animHand>3 then\r
+ animHand:=1;\r
+ end;\r
+ else\r
+ if anim=ANIM_LEGS then\r
+ begin\r
+ if animDelay=0 then\r
+ begin\r
+ animLegs:=animLegs+1;\r
+ if animLegs>2 then\r
+ animLegs:=0;\r
+ end;\r
+\r
+ animDelay:=animDelay+1;\r
+ if animDelay>PLAYER_ANIM_DEL then\r
+ animDelay:=0;\r
+ end;\r
+ end;\r
+\r
+ procedure cancelAnim(anim:integer);\r
+ begin\r
+ if anim=ANIM_HAND then\r
+ begin\r
+ animHand:=0;\r
+ end;\r
+ else\r
+ if anim=ANIM_LEGS then\r
+ begin\r
+ animLegs:=0;\r
+ end;\r
+ end;\r
+\r
+ procedure draw(camx, camy:integer);\r
+ var\r
+ x, y:integer;\r
+ begin\r
+ x:=getX;\r
+ y:=getY;\r
+\r
+ DrawImage(PlayerBody[posi], x-camx, y-camy);\r
+ DrawImage(PlayerLegs[posi, animLegs], x-2-camx, y+20-camy);\r
+\r
+ if animHand=0 then\r
+ drawSmallItem(inv.getItem(invslot), x-camx, y+14-camy);\r
+ else\r
+ if posi=POSI_RIGHT then\r
+ drawSmallItem(inv.getItem(invslot), x+10-camx, y+5-camy+animHand);\r
+ else\r
+ if posi=POSI_LEFT then\r
+ drawSmallItem(inv.getItem(invslot), x-10-camx, y+5-camy+animHand);\r
+\r
+ if (animHand=0) or (posi=POSI_RIGHT) then\r
+ DrawImage(PlayerHand[posi, animHand], x+2-camx, y+8-camy);\r
+ else\r
+ DrawImage(PlayerHand[posi, animHand], x-6-camx, y+8-camy);\r
+ end;\r
+\r
+procedure loadPhy;\r
+ begin\r
+ phy.loadObject(getX, getY, getW, getH, getVelX, getVelY, getJmp);\r
+ end;\r
+\r
+procedure storePhy;\r
+ begin\r
+ setX(phy.getX);\r
+ setY(phy.getY);\r
+ setVelX(phy.getVelX);\r
+ setVelY(phy.getVelY);\r
+ setJmp(phy.getJmp);\r
+ end;\r
+\r
+ //Player collision.\r
+{function coll:boolean;\r
+ begin\r
+ coll:=CollObj(getX, getY, getW, getH);\r
+ end;\r
+\r
+//Player collision by block id.\r
+function coll_bl(id:integer):boolean;\r
+ begin\r
+ coll_bl:=CollObjBlock(getX, getY, getW, getH, id);\r
+ end;\r
+\r
+//Player collision by XY.\r
+function coll_xy(xx,yy:integer):boolean;\r
+ begin\r
+ coll_xy:=CollObjXY(getX, getY, getW, getH, xx, yy);\r
+ end;\r
+\r
+//Controll jump velocity\r
+procedure jmp_ctrl;\r
+ begin\r
+ if (coll_bl(49)) or (coll_bl(103)) or (coll_bl(108)) then\r
+ vely:=5;\r
+ if (coll_bl(50)) or (coll_bl(51)) then\r
+ vely:=4;\r
+ if (coll_bl(0)) and (coll_bl(50) or coll_bl(51)) then\r
+ vely:=7;\r
+ end;\r
+\r
+//Controll fall velocity\r
+ procedure phy_ctrl;\r
+ begin\r
+ if (coll_bl(49)) or (coll_bl(103)) then\r
+ vely:=-5;\r
+ if (coll_bl(50)) or (coll_bl(51)) then\r
+ if vely<-4 then\r
+ vely:=-4;\r
+ end;}\r
+\r
+ procedure calcPhysics;\r
+ var\r
+ old_vely:integer;\r
+ cl:boolean;\r
+ begin\r
+ loadPhy;\r
+ phy.calc(not fly);\r
+ storePhy;\r
+\r
+ {if fly=false then\r
+ begin\r
+ old_vely:=vely;\r
+ calcGravY(getX, getY, getW, getH, CONST_PHY_ACC, vely, CONST_PHY_MAXVEL, jmp);\r
+ setY(PhyGetY);\r
+ vely:=PhyGetVelY;\r
+ jmp:=PhyGetJump;\r
+ cl:=PhyGetColl;\r
+\r
+ if cl then\r
+ if old_vely<-10 then\r
+ hp:=(hp-(abs(old_vely)-10));\r
+ end;}\r
+ end;\r
+\r
+ procedure gotoUP;\r
+ begin\r
+ if fly then\r
+ setVelY(-PLAYER_SPEED);\r
+ else\r
+ begin\r
+ loadPhy;\r
+ jumpObj(7);\r
+ storePhy;\r
+ end;\r
+ end;\r
+\r
+ procedure gotoDOWN;\r
+ begin\r
+ if fly then\r
+ setVelY(PLAYER_SPEED);\r
+ end;\r
+\r
+ procedure gotoLEFT;\r
+ begin\r
+ setVelX(-PLAYER_SPEED);\r
+\r
+ posi:=POSI_LEFT;\r
+\r
+ if fly=false then\r
+ playAnim(ANIM_LEGS);\r
+ end;\r
+\r
+ procedure gotoRIGHT;\r
+ begin\r
+ setVelX(PLAYER_SPEED);\r
+\r
+ posi:=POSI_RIGHT;\r
+\r
+ if fly=false then\r
+ playAnim(ANIM_LEGS);\r
+ end;\r
+\r
+ procedure getDrop;\r
+ var\r
+ i, maxd, sum:integer;\r
+ begin\r
+ maxd:=drop.max;\r
+ for i:=0 to maxd do\r
+ if drop.isNull(i)=false then\r
+ if CollTwoObj(getX, getY, getW, getH, drop.getX(i), drop.getY(i), drop.getW, drop.getH) then\r
+ begin\r
+ sum:=inv.giveItem(drop.getItem(i), drop.getSum(i));\r
+ drop.setSum(sum, i);\r
+ drop.fixNull(i);\r
+ end;\r
+ end;\r
+\r
+initialization\r
+\r
+end.\r
diff --git a/src/randoms.mpsrc b/src/randoms.mpsrc
--- /dev/null
+++ b/src/randoms.mpsrc
@@ -0,0 +1,37 @@
+unit randoms;\r
+\r
+interface\r
+ procedure srand(s:integer);//Устанавливает зерно для ГПСЧ\r
+ function rand:integer;//Возвращает случайное число\r
+ function rnd(max:integer):integer;//Возвращает число от 0 до max\r
+ function rnd_pr(pr,p1,p2:integer):integer;\r
+\r
+implementation\r
+ var\r
+ next:integer;\r
+\r
+ function rand:integer;\r
+ begin\r
+ next:=next xor (next << 13);\r
+ next:=next xor (next >>> 17);\r
+ next:=next xor (next << 5);\r
+ rand:=abs(next);\r
+ end;\r
+\r
+ procedure srand(s:integer);\r
+ begin\r
+ //Debug('srand('+s+')');\r
+ next:=s;\r
+ end;\r
+\r
+ function rnd(max:integer):integer;\r
+ begin\r
+ rnd:=rand mod max;\r
+ end;\r
+\r
+ function rnd_pr(pr,p1,p2:integer):integer;\r
+ begin\r
+ if pr>=rnd(101) then rnd_pr:=p1; else rnd_pr:=p2;\r
+ end;\r
+\r
+end.
\ No newline at end of file
diff --git a/src/sign.pas b/src/sign.pas
--- /dev/null
+++ b/src/sign.pas
@@ -0,0 +1,63 @@
+unit sign;
+
+interface
+ var
+ b_sign:array [0..31] of boolean;
+ none0:boolean;
+ t_sign:array [0..31] of string;
+ none1:boolean;
+
+ function createsign(ii,ij:integer):integer;
+ procedure destsign(id:integer);
+
+implementation
+uses maps;
+
+function createsign(ii,ij:integer):integer;
+ var
+ ix,ymp:integer;
+ tx:array [0..3] of integer;
+ exitCmd,cli:command;
+ begin
+ for ix:=0 to 31 do
+ if b_sign[ix]=false then
+ begin
+ b_sign[ix]:=true;
+ t_sign[ix]:='';
+ setmapinfo(ix,ii,ij);
+ debug('Sg'+ix);
+
+ clearForm;
+ exitCmd:=createCommand('Ok',CM_OK,1);
+ showForm;
+ addCommand(exitCmd);
+ ymp:=formAddString('Text:');
+ tx[0]:=formAddTextField('','',15,TF_ANY);
+ tx[1]:=formAddTextField('','',15,TF_ANY);
+ tx[2]:=formAddTextField('','',15,TF_ANY);
+ tx[3]:=formAddTextField('','',15,TF_ANY);
+ repaint;
+ delay(100);
+ repeat
+ cli:=getClickedCommand;
+ until cli=exitCmd;
+ t_sign[ix]:=formGetText(tx[0])+#13+formGetText(tx[1])+#13+formGetText(tx[2])+#13+formGetText(tx[3])+#13;
+ showCanvas;
+
+ createsign:=0;
+ exit;
+ end; else
+ createsign:=-1;
+ end;
+
+procedure destsign(id:integer);
+ var
+ ix:integer;
+ begin
+ b_sign[id]:=false;
+ t_sign[id]:='';
+ end;
+
+initialization
+
+end.
diff --git a/src/utils.mpsrc b/src/utils.mpsrc
--- /dev/null
+++ b/src/utils.mpsrc
@@ -0,0 +1,63 @@
+unit utils;\r
+\r
+interface\r
+const\r
+ MaxTimers=2;\r
+ TIMER_ERROR=-1;\r
+ TIMER_OK=0;\r
+\r
+ T_CONSOLE=0;//Timer for call console\r
+ T_KEY_DIVITEM=1;\r
+ T_KEY_DROPITEM=2;\r
+\r
+procedure SetTimer(t,i:integer);\r
+function GetTimer(i:integer):integer;\r
+procedure ResetTimer(i:integer);\r
+procedure ResetAllTimers;\r
+\r
+implementation\r
+ var\r
+ Timer_value:array [0..MaxTimers] of integer;\r
+ Timer_time:array [0..MaxTimers] of integer;\r
+\r
+procedure SetTimer(t,i:integer);\r
+ begin\r
+ Timer_value[i]:=t;\r
+ Timer_time[i]:=getrelativetimems;\r
+ end;\r
+\r
+function GetTimer(i:integer):integer;\r
+ var\r
+ dt:integer;\r
+ begin\r
+ if Timer_value[i]>-1 then\r
+ begin\r
+ dt:=Timer_time[i]-getrelativetimems;\r
+ Timer_value[i]:=Timer_value[i]+dt;\r
+ if Timer_value[i]<0 then Timer_value[i]:=0;\r
+ Timer_time[i]:=getrelativetimems;\r
+ GetTimer:=Timer_value[i];\r
+ end;\r
+ else GetTimer:=-1;\r
+ end;\r
+\r
+procedure ResetTimer(i:integer);\r
+ begin\r
+ Timer_value[i]:=-1;\r
+ Timer_time[i]:=-1;\r
+ end;\r
+\r
+procedure ResetAllTimers;\r
+ var\r
+ i:integer;\r
+ begin\r
+ for i:=0 to MaxTimers do\r
+ begin\r
+ Timer_value[i]:=-1;\r
+ Timer_time[i]:=-1;\r
+ end;\r
+ end;\r
+\r
+initialization\r
+ ResetAllTimers;\r
+end.\r
diff --git a/src/vars.mpsrc b/src/vars.mpsrc
--- /dev/null
+++ b/src/vars.mpsrc
@@ -0,0 +1,90 @@
+unit vars;\r
+\r
+interface\r
+ const\r
+ max_sounds=13;\r
+\r
+ FONT_STD_COLOR=$FFFFFFFF;\r
+ FONT_YELLOW_COLOR=$FFFFFF00;\r
+ FONT_MAX_SYM=127;\r
+ FONT_SYM_SIZE=8;\r
+\r
+ MAP_W=256;\r
+ MAP_H=128;\r
+\r
+ TILE_SIZE=16;\r
+\r
+ var\r
+ pl_world:integer;//мир в котором находится игрок (0 - обычный мир, 1 - нижний мир)\r
+ fps:integer;//Текущий фпс, можно использовать для синхронизации\r
+ camx,camy:integer;//Координаты камеры\r
+ curx,cury:integer;//Координаты курсора игрока\r
+ game_time:integer;//Игровое время\r
+ gamemode:integer;//Режим игры\r
+ bon_chest:boolean;//Генерировать бонусный сундук?\r
+ //invslot:integer;//номер слота на "поясе"\r
+\r
+\r
+ tex_pack:string; \r
+ bl_ani5:integer;\r
+\r
+ bl_ani5_v,bl_ani5_d:boolean;\r
+\r
+ fish:boolean;\r
+ \r
+\r
+ fish_time:integer;\r
+ hung_time,hp_time,air_time,portal_time:integer;\r
+ fx,fy:integer;\r
+\r
+ maxBlockTex, maxItemTex:integer;\r
+\r
+ tex:array [0..0] of image;\r
+ none0:image;\r
+ tex8:array [0..0] of image;\r
+ none1:image;\r
+ item:array [0..0] of image;\r
+ none2:image;\r
+ item8:array [0..0] of image;\r
+ none3:image;\r
+ font:array [0..127] of image;\r
+ none4:image;\r
+\r
+ procedure initBlockTex(i:integer);\r
+ procedure initItemTex(i:integer);\r
+\r
+implementation\r
+\r
+ procedure initBlockTex(i:integer);\r
+ begin\r
+ maxblocktex:=i;\r
+ i:=i+1;\r
+ bytecode\r
+ iload 0;\r
+ multianewarray class '[Ljavax/microedition/lcdui/Image;', 1;\r
+ putstatic field 'vars', 'tex', '[Ljavax/microedition/lcdui/Image;';\r
+ end;\r
+ bytecode\r
+ iload 0;\r
+ multianewarray class '[Ljavax/microedition/lcdui/Image;', 1;\r
+ putstatic field 'vars', 'tex8', '[Ljavax/microedition/lcdui/Image;';\r
+ end;\r
+ end;\r
+\r
+ procedure initItemTex(i:integer);\r
+ begin\r
+ maxItemTex:=i;\r
+ i:=i+1;\r
+ bytecode\r
+ iload 0;\r
+ multianewarray class '[Ljavax/microedition/lcdui/Image;', 1;\r
+ putstatic field 'vars', 'item', '[Ljavax/microedition/lcdui/Image;';\r
+ end;\r
+ bytecode\r
+ iload 0;\r
+ multianewarray class '[Ljavax/microedition/lcdui/Image;', 1;\r
+ putstatic field 'vars', 'item8', '[Ljavax/microedition/lcdui/Image;';\r
+ end;\r
+ end;\r
+\r
+end.\r
diff --git a/src/video.pas b/src/video.pas
--- /dev/null
+++ b/src/video.pas
@@ -0,0 +1,66 @@
+unit video;\r
+\r
+interface\r
+ procedure initVideo(scrW, scrH:integer; canScale:boolean;);\r
+ procedure drawVideo;\r
+\r
+implementation\r
+ uses scri, keyboard;\r
+ var\r
+ useRes:boolean;\r
+\r
+ procedure initVideo(scrW, scrH:integer; canScale:boolean;);\r
+ var\r
+ tmp:integer;\r
+ begin\r
+ keyboard.scrMulX:=1;\r
+ keyboard.scrMulY:=1;\r
+ useRes:=false;\r
+ if (getWidth>getHeight) and (scrW<scrH) then\r
+ begin\r
+ tmp:=scrW;\r
+ scrW:=scrH;\r
+ scrH:=tmp;\r
+ end;\r
+\r
+ if ((getWidth>scrW) and (getHeight>scrH)) or ((getHeight>scrW) and (getWidth>scrH)) then\r
+ begin\r
+ debug('Scaling: '+getWidth+'x'+getHeight+' -> '+scrW+'x'+scrH);\r
+ if getWidth<getHeight then\r
+ scrH:=getHeight/(getWidth/scrW);\r
+ else\r
+ scrW:=getWidth/(getHeight/scrH);\r
+\r
+ scrH:=getHeight/(getWidth/scrW);\r
+ scrW:=getWidth/(getHeight/scrH);\r
+\r
+ debug('Scaling result: '+getWidth+'x'+getHeight+' -> '+scrW+'x'+scrH);\r
+\r
+ ScriCreate(scrW, scrH);\r
+ if canScale then\r
+ begin\r
+ keyboard.scrMulX:=getWidth/scrW;\r
+ keyboard.scrMulY:=getHeight/scrH;\r
+ ScriScale(getWidth/scrW, getHeight/scrH);\r
+ ScriPosition(0, 0);\r
+ ScriSwap;\r
+ useRes:=true;\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure drawVideo;\r
+ begin\r
+ draw_virtual_keys;\r
+ if useRes then\r
+ begin\r
+ ScriSwap;\r
+ ScriDraw;\r
+ Repaint;\r
+ ScriSwap;\r
+ end;\r
+ else\r
+ Repaint;\r
+ end;\r
+\r
+end.\r
diff --git a/src/worldgen.mpsrc b/src/worldgen.mpsrc
--- /dev/null
+++ b/src/worldgen.mpsrc
@@ -0,0 +1,963 @@
+//Thanks:\r
+//ZeroNoWing\r
+//Andrey59\r
+\r
+unit worldgen;\r
+\r
+interface\r
+ procedure genworld;//Вызывается из главного модуля для начала генерации мира\r
+ procedure gennether;\r
+ procedure genflat;\r
+ procedure genportal(xx,yy:integer);\r
+ function get_up(Xi:integer):integer;\r
+\r
+ procedure genwood1(xx,yy:integer);//дуб\r
+ procedure genwood2(xx,yy:integer);//берёза\r
+ procedure genwood3(xx,yy:integer);//ель\r
+\r
+\r
+implementation\r
+uses maps,randoms,vars,items,func, player, chest, items_store;\r
+\r
+ function rnd_min:integer;\r
+ begin\r
+ rnd_min:=rnd(3)-1;\r
+ end;\r
+\r
+procedure create_bonus_chest(chx,chy:integer);\r
+ var\r
+ ix,l,id,time:integer;\r
+ begin\r
+ time:=getcurrenttime;\r
+ if ((getmonth(time)=0) and (getday(time)<3)) or ((getmonth(time)=11) and (getday(time)>29)) then\r
+ setmap(102,chx,chy);\r
+ else\r
+ setmap(28,chx,chy);\r
+ setmap(26,chx-1,chy);\r
+ setmap(26,chx+1,chy);\r
+ setmapinfo(31,chx,chy);\r
+ id:=chest.create(chx,chy);\r
+ debug('Bonus Chest');\r
+ for ix:=1 to rnd(10)+1 do\r
+ begin\r
+ l:=rnd(26);\r
+ if rnd(2)=rnd(2) then\r
+ begin\r
+ chest.setItem(127 ,l, id);\r
+ chest.setSum(rnd(6)+1, l, id);\r
+ end; else\r
+ if rnd(2)=rnd(2) then\r
+ begin\r
+ chest.setItem(9 ,l, id);\r
+ chest.setSum(rnd(4)+1, l, id);\r
+ end; else\r
+ if rnd(2)=rnd(2) then\r
+ begin\r
+ chest.setItem(4 ,l, id);\r
+ chest.setSum(rnd(4)+1, l, id);\r
+ end; else\r
+ if rnd(2)=rnd(2) then\r
+ begin\r
+ chest.setItem(131 ,l, id);\r
+ chest.setSum(60, l, id);\r
+ end; else\r
+ if rnd(2)=rnd(2) then\r
+ begin\r
+ chest.setItem(132 ,l, id);\r
+ chest.setSum(132, l, id);\r
+ end;\r
+ if rnd(2)=rnd(2) then\r
+ begin\r
+ chest.setItem(141 ,l, id);\r
+ chest.setSum(60, l, id);\r
+ end; else\r
+ if rnd(2)=rnd(2) then\r
+ begin\r
+ chest.setItem(142 ,l, id);\r
+ chest.setSum(132, l, id);\r
+ end;\r
+ if rnd(2)=rnd(2) then\r
+ begin\r
+ chest.setItem(147 ,l, id);\r
+ chest.setSum(60, l, id);\r
+ end; else\r
+ if rnd(2)=rnd(2) then\r
+ begin\r
+ chest.setItem(201 ,l, id);\r
+ chest.setSum(rnd(16), l, id);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure genflat;\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to 255 do\r
+ begin\r
+ setmap(2,ix,121);\r
+ setmap(1,ix,122);\r
+ setmap(1,ix,123);\r
+ setmap(3,ix,124);\r
+ setmap(3,ix,125);\r
+ setmap(3,ix,126);\r
+ setmap(6,ix,127);\r
+\r
+ setBackMap(121, ix);\r
+ setBiomMap(0, ix);\r
+ end;\r
+ if bon_chest then create_bonus_chest(get_spawn_x,get_spawn_y+1);\r
+ delay(200);\r
+ end;\r
+\r
+ procedure drawmap;\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to 255 do\r
+ for iy:=0 to 127 do\r
+ begin\r
+ if getmap(ix,iy)<>0 then setcolor(0,0,0); else setcolor(255,255,255);\r
+ plot(ix,iy);\r
+ end;\r
+ repaint;\r
+ delay(1);\r
+ end;\r
+\r
+ procedure gencave(xx,yy:integer);\r
+ var\r
+ ix,iy:integer;\r
+ mask:array [0..63,0..63] of boolean;\r
+ begin\r
+ for ix:=0 to 63 do\r
+ for iy:=0 to 63 do\r
+ mask[ix,iy]:=true;\r
+ ix:=(63+1)/2-1;\r
+ iy:=(63+1)/2-1;\r
+ while (ix>=0) and (ix<=63) and (iy>=0) and (iy<=63) do\r
+ begin\r
+ ix:=ix+rnd_min;\r
+ iy:=iy+rnd_min;\r
+ if (ix>=0) and (ix<=63) and (iy>=0) and (iy<=63) then mask[ix,iy]:=false;\r
+ end;\r
+ for ix:=1 to 62 do\r
+ for iy:=1 to 62 do\r
+ begin\r
+ if mask[ix,iy]=true then\r
+ if mask[ix-1,iy]=false then\r
+ if mask[ix+1,iy]=false then\r
+ mask[ix,iy]:=false;\r
+ end;\r
+\r
+ for ix:=0 to 63 do\r
+ for iy:=0 to 63 do\r
+ begin\r
+ if mask[ix,iy]=false then setmap(0,xx+ix,yy+iy);\r
+ end;\r
+ end;\r
+\r
+ procedure genportal(xx,yy:integer);\r
+ begin\r
+ setmap(10,xx+1,yy);\r
+ setmap(10,xx+2,yy);\r
+ setmap(118,xx,yy+1);\r
+ setmap(118,xx+3,yy+1);\r
+ setmap(118,xx,yy+2);\r
+ setmap(118,xx+3,yy+2);\r
+ setmap(118,xx,yy+3);\r
+ setmap(118,xx+3,yy+3);\r
+ setmap(10,xx+1,yy+4);\r
+ setmap(10,xx+2,yy+4);\r
+ setmap(110,xx+1,yy+1);\r
+ setmap(110,xx+2,yy+1);\r
+ setmap(110,xx+1,yy+2);\r
+ setmap(110,xx+2,yy+2);\r
+ setmap(110,xx+1,yy+3);\r
+ setmap(110,xx+2,yy+3);\r
+ end;\r
+\r
+ procedure genportal_big(xx,yy:integer);\r
+ begin\r
+ setmap(10,xx,yy);\r
+ setmap(10,xx+1,yy);\r
+ setmap(10,xx+2,yy);\r
+ setmap(10,xx+3,yy);\r
+ setmap(118,xx,yy+1);\r
+ setmap(118,xx+3,yy+1);\r
+ setmap(118,xx,yy+2);\r
+ setmap(118,xx+3,yy+2);\r
+ setmap(118,xx,yy+3);\r
+ setmap(118,xx+3,yy+3);\r
+ setmap(10,xx,yy+4);\r
+ setmap(10,xx+1,yy+4);\r
+ setmap(10,xx+2,yy+4);\r
+ setmap(10,xx+3,yy+4);\r
+ setmap(110,xx+1,yy+1);\r
+ setmap(110,xx+2,yy+1);\r
+ setmap(110,xx+1,yy+2);\r
+ setmap(110,xx+2,yy+2);\r
+ setmap(110,xx+1,yy+3);\r
+ setmap(110,xx+2,yy+3);\r
+ end;\r
+\r
+ procedure surprisechest(x,y:integer);\r
+ var\r
+ ix,l,id:integer;\r
+ begin\r
+ id:=chest.create(x, y);\r
+ debug('Surprise!');\r
+ setmap(102,x,y);\r
+ for ix:=1 to rnd(8) do\r
+ begin\r
+ l:=rnd(26);\r
+ if rnd(22)=1 then\r
+ begin\r
+ chest.setItem(162 ,l, id);\r
+ chest.setSum(rnd(5), l, id);\r
+ end; else\r
+ if rnd(11)=1 then\r
+ begin\r
+ chest.setItem(165 ,l, id);\r
+ chest.setSum(rnd(6), l, id);\r
+ end; else\r
+ if rnd(11)=1 then\r
+ begin\r
+ chest.setItem(181 ,l, id);\r
+ chest.setSum(rnd(2), l, id);\r
+ end; else\r
+ if rnd(11)=1 then\r
+ begin\r
+ chest.setItem(182 ,l, id);\r
+ chest.setSum(rnd(2), l, id);\r
+ end; else\r
+ if rnd(11)=1 then\r
+ begin\r
+ chest.setItem(176 ,l, id);\r
+ chest.setSum(rnd(32), l, id);\r
+ end; else\r
+ if rnd(11)=1 then\r
+ begin\r
+ chest.setItem(183 ,l, id);\r
+ chest.setSum(rnd(10)+1, l, id);\r
+ end; else\r
+ if rnd(11)=1 then\r
+ begin\r
+ chest.setItem(186 ,l, id);\r
+ chest.setSum(1, l, id);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure genwood1(xx,yy:integer);//дуб\r
+ begin\r
+ setmap(75,xx,yy);\r
+ setmap(75,xx,yy-1);\r
+ setmap(75,xx,yy-2);\r
+ setmap(21,xx,yy-3);\r
+ setmap(21,xx,yy-4);\r
+ setmap(21,xx,yy-5);\r
+ setmap(21,xx-1,yy-3);\r
+ setmap(21,xx-1,yy-4);\r
+ setmap(21,xx+1,yy-3);\r
+ setmap(21,xx+1,yy-4);\r
+ end;\r
+\r
+ procedure genwood2(xx,yy:integer);//берёза\r
+ begin\r
+ setmap(84,xx,yy);\r
+ setmap(84,xx,yy-1);\r
+ setmap(84,xx,yy-2);\r
+ setmap(112,xx,yy-3);\r
+ setmap(112,xx,yy-4);\r
+ setmap(112,xx,yy-5);\r
+ setmap(112,xx-1,yy-3);\r
+ setmap(112,xx-1,yy-4);\r
+ setmap(112,xx+1,yy-3);\r
+ setmap(112,xx+1,yy-4);\r
+ end;\r
+\r
+ procedure genwood3(xx,yy:integer);//ель\r
+ var\r
+ time:integer;\r
+ begin\r
+ setmap(87,xx,yy-5);\r
+ setmap(87,xx-1,yy-4); setmap(87,xx,yy-4); setmap(87,xx+1,yy-4);\r
+ setmap(86,xx,yy-3);\r
+ setmap(87,xx-1,yy-2); setmap(86,xx,yy-2); setmap(87,xx+1,yy-2);\r
+ setmap(87,xx-2,yy-1); setmap(87,xx-1,yy-1); setmap(86,xx,yy-1); setmap(87,xx+1,yy-1); setmap(87,xx+2,yy-1);\r
+ setmap(86,xx,yy);\r
+ time:=getcurrenttime;\r
+ if ((getmonth(time)=0) and (getday(time)<3)) or ((getmonth(time)=11) and (getday(time)>29)) then\r
+ begin\r
+ if rnd(3)=1 then surprisechest(xx-1,yy);\r
+ if rnd(3)=1 then surprisechest(xx+1,yy);\r
+ end;\r
+ end;\r
+\r
+ procedure genfungus1(xx,yy:integer);//красный гриб\r
+ begin\r
+ setmap(88,xx-1,yy-4); setmap(88,xx,yy-4); setmap(88,xx+1,yy-4);\r
+ setmap(88,xx-2,yy-3); setmap(88,xx-1,yy-3); setmap(88,xx,yy-3); setmap(88,xx+1,yy-3); setmap(88,xx+2,yy-3);\r
+ setmap(88,xx-2,yy-2); setmap(88,xx-1,yy-2); setmap(88,xx,yy-2); setmap(88,xx+1,yy-2); setmap(88,xx+2,yy-2);\r
+ setmap(89,xx,yy-1);\r
+ setmap(89,xx,yy);\r
+ end;\r
+\r
+ procedure genfungus2(xx,yy:integer);//коричневый гриб\r
+ begin\r
+ setmap(90,xx-2,yy-4); setmap(90,xx-1,yy-4); setmap(90,xx,yy-4); setmap(90,xx+1,yy-4); setmap(90,xx+2,yy-4);\r
+ setmap(91,xx,yy-3);\r
+ setmap(91,xx,yy-2);\r
+ setmap(91,xx,yy-1);\r
+ setmap(91,xx,yy);\r
+ end;\r
+\r
+ procedure gencactus(xx,yy:integer);\r
+ begin\r
+ setmap(30,xx,yy);\r
+ setmap(30,xx,yy-1);\r
+ setmap(30,xx,yy-2);\r
+ end;\r
+\r
+ procedure gencane(xx,yy:integer);\r
+ begin\r
+ setmap(65,xx,yy);\r
+ setmap(65,xx,yy-1);\r
+ setmap(65,xx,yy-2);\r
+ end;\r
+\r
+ procedure treasurechest(x,y:integer);\r
+ var\r
+ ix,l,id:integer;\r
+ begin\r
+ id:=chest.create(x, y);\r
+ debug('Treasure Chest');\r
+ setmap(28,x,y);\r
+ for ix:=1 to rnd(8) do\r
+ begin\r
+ l:=rnd(26);\r
+ if rnd(22)=rnd(22) then\r
+ begin\r
+ chest.setItem(161 ,l, id);\r
+ chest.setSum(rnd(4)+1, l, id);\r
+ end; else\r
+ if rnd(11)=rnd(11) then\r
+ begin\r
+ chest.setItem(164 ,l, id);\r
+ chest.setSum(rnd(4)+1, l, id);\r
+ end; else\r
+ if rnd(11)=rnd(11) then\r
+ begin\r
+ chest.setItem(183 ,l, id);\r
+ chest.setSum(rnd(4)+1, l, id);\r
+ end; else\r
+ if rnd(11)=rnd(11) then\r
+ begin\r
+ chest.setItem(167 ,l, id);\r
+ chest.setSum(rnd(4)+1, l, id);\r
+ end; else\r
+ if rnd(11)=rnd(11) then\r
+ begin\r
+ chest.setItem(171 ,l, id);\r
+ chest.setSum(1, l, id);\r
+ end; else\r
+ if rnd(4)=rnd(4) then\r
+ begin\r
+ chest.setItem(220 ,l, id);\r
+ chest.setSum(rnd(8)+8, l, id);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure genteasures(xx,yy:integer);\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to 6 do\r
+ for iy:=0 to 6 do\r
+ begin\r
+ setmap(0,xx+ix,yy+iy);\r
+ end;\r
+ for ix:=0 to 6 do\r
+ begin\r
+ setmap(12,xx+ix,yy);\r
+ setmap(12,xx+ix,yy+6);\r
+ setmap(12,xx,yy+ix);\r
+ setmap(12,xx+6,yy+ix);\r
+ end;\r
+\r
+ setmap(76,xx+3,yy+5);\r
+ setmapinfo(1,xx+3,yy+5);\r
+\r
+ if rnd(2)=1 then\r
+ treasurechest(xx+1,yy+5);\r
+\r
+ if rnd(2)=1 then\r
+ treasurechest(xx+5,yy+5);\r
+ end;\r
+\r
+ procedure genrude(t,r,xx,yy,xxx,yyy:integer);\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to xxx do\r
+ for iy:=0 to yyy do\r
+ begin\r
+ if getmap(xx+ix,yy+iy)=3 then if rnd(r+1)-1=0 then setmap(t,xx+ix,yy+iy);\r
+ end;\r
+ end;\r
+\r
+ procedure genallrudes;\r
+ var\r
+ ix,iy,iu,iv:integer;\r
+ begin\r
+ //алмазы\r
+ for ix:=0 to 255 do\r
+ for iy:=111 to 127 do\r
+ if (rnd_pr(1,1,0)=1) then\r
+ begin\r
+ for iu:=0 to 2 do\r
+ for iv:=0 to 2 do\r
+ if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(10,19,getmap(ix+iu,iy+iv)),ix+iu,iy+iv);\r
+ ix:=ix+3;\r
+ end;\r
+\r
+ //золото\r
+ for ix:=0 to 255 do\r
+ for iy:=95 to 127 do\r
+ if (rnd_pr(3,1,0)=1) then\r
+ begin\r
+ for iu:=0 to 2 do\r
+ for iv:=0 to 2 do\r
+ if (ix+iu<255) and (iy+iv<126) then\r
+ if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(20,16,getmap(ix+iu,iy+iv)),ix+iu,iy+iv);\r
+ ix:=ix+3;\r
+ end;\r
+\r
+ //лазурит\r
+ for ix:=0 to 255 do\r
+ for iy:=107 to 127 do\r
+ if (rnd_pr(2,1,0)=1) then\r
+ begin\r
+ for iu:=0 to 2 do\r
+ for iv:=0 to 2 do\r
+ if (ix+iu<255) and (iy+iv<126) then\r
+ if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(40,54,getmap(ix+iu,iy+iv)),ix+iu,iy+iv);\r
+ ix:=ix+3;\r
+ end;\r
+\r
+ //редстоун\r
+ for ix:=0 to 255 do\r
+ for iy:=107 to 127 do\r
+ if (rnd_pr(2,1,0)=1) then\r
+ begin\r
+ for iu:=0 to 2 do\r
+ for iv:=0 to 2 do\r
+ if (ix+iu<255) and (iy+iv<126) then\r
+ if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(40,20,getmap(ix+iu,iy+iv)),ix+iu,iy+iv);\r
+ ix:=ix+3;\r
+ end;\r
+\r
+ //железо\r
+ for ix:=0 to 255 do\r
+ for iy:=63 to 127 do\r
+ if (rnd_pr(4,1,0)=1) then\r
+ begin\r
+ for iu:=0 to 2 do\r
+ for iv:=0 to 2 do\r
+ if (ix+iu<255) and (iy+iv<126) then\r
+ if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(40,17,getmap(ix+iu,iy+iv)),ix+iu,iy+iv);\r
+ ix:=ix+3;\r
+ end;\r
+\r
+ //уголь\r
+ for ix:=0 to 255 do\r
+ for iy:=0 to 127 do\r
+ if (rnd_pr(6,1,0)=1) then\r
+ begin\r
+ for iu:=0 to 2 do\r
+ for iv:=0 to 2 do\r
+ if (ix+iu<255) and (iy+iv<126) then\r
+ if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(50,18,getmap(ix+iu,iy+iv)),ix+iu,iy+iv);\r
+ ix:=ix+3;\r
+ end;\r
+\r
+ //гравий\r
+ for ix:=0 to 255 do\r
+ for iy:=63 to 126 do\r
+ if (rnd_pr(2,1,0)=1) then\r
+ begin\r
+ for iu:=0 to rnd(5) do\r
+ for iv:=0 to rnd(5) do\r
+ if (ix+iu<255) and (iy+iv<126) then\r
+ if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(90,8,getmap(ix+iu,iy+iv)),ix+iu,iy+iv);\r
+ ix:=ix+3;\r
+ end;\r
+\r
+ //земля на камне\r
+ for ix:=0 to 255 do\r
+ for iy:=63 to 127 do\r
+ if (rnd_pr(1,1,0)=1) then\r
+ begin\r
+ for iu:=0 to rnd(5) do\r
+ for iv:=0 to rnd(5) do\r
+ if (ix+iu<255) and (iy+iv<126) then\r
+ if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(90,1,getmap(ix+iu,iy+iv)),ix+iu,iy+iv);\r
+ ix:=ix+3;\r
+ end;\r
+ end;\r
+\r
+ procedure dec_0(ix,iy:integer);\r
+ var\r
+ t:integer;\r
+ begin\r
+ t:=rnd(30);\r
+ if t=0 then setmap(22,ix,iy); else\r
+ if t=1 then setmap(23,ix,iy); else\r
+ if t=2 then setmap(24,ix,iy); else\r
+ if t=3 then setmap(25,ix,iy); else\r
+ if (t>3) and (t<8) then setmap(57,ix,iy); else\r
+ if t=8 then genwood1(ix,iy); else\r
+ if t=9 then genwood2(ix,iy); else\r
+ if t=10 then setmap(66,ix,iy); else\r
+ if t=11 then setmap(73,ix,iy); else\r
+ if t>11 then begin if (getmap(ix-1,iy+1)=50) or (getmap(ix+1,iy+1)=50) then gencane(ix,iy); end; else\r
+ exit;\r
+ end;\r
+\r
+ procedure dec_1(ix,iy:integer);\r
+ var\r
+ t:integer;\r
+ begin\r
+ t:=rnd(25);\r
+ if t=0 then setmap(58,ix,iy); else\r
+ if t=1 then gencactus(ix,iy); else\r
+ if t>2 then begin if (getmap(ix-1,iy+1)=50) or (getmap(ix+1,iy+1)=50) then gencane(ix,iy); end; else\r
+ exit;\r
+ end;\r
+\r
+ procedure dec_2(ix,iy:integer);\r
+ var\r
+ t:integer;\r
+ begin\r
+ t:=rnd(30);\r
+ if t=0 then setmap(22,ix,iy); else\r
+ if t=1 then setmap(23,ix,iy); else\r
+ if t=2 then genwood1(ix,iy); else\r
+ if t=3 then genwood2(ix,iy); else\r
+ if t=4 then genwood3(ix,iy); else\r
+ if t=5 then setmap(66,ix,iy); else\r
+ exit;\r
+ end;\r
+\r
+ procedure dec_3(ix,iy:integer);\r
+ var\r
+ t:integer;\r
+ begin\r
+ t:=rnd(20);\r
+ if t=1 then setmap(24,ix,iy); else\r
+ if t=2 then setmap(25,ix,iy); else\r
+ if t=3 then genfungus1(ix,iy); else\r
+ if t=4 then genfungus2(ix,iy); else\r
+ exit;\r
+ end;\r
+\r
+ procedure decorator;\r
+ var\r
+ ix,iy,t:integer;\r
+ begin\r
+ for ix:=0 to 255 do\r
+ for iy:=0 to 127 do\r
+ if getmap(ix,iy)<>0 then\r
+ begin\r
+ if (getBiomMap(ix)=0) then\r
+ begin\r
+ iy:=iy-1;\r
+ if (getmap(ix,iy+1)=2) and (getmap(ix,iy)=0) then dec_0(ix,iy);\r
+ break;\r
+ end; else\r
+ if (getBiomMap(ix)=1) then\r
+ begin\r
+ iy:=iy-1;\r
+ if (getmap(ix,iy+1)=7) and (getmap(ix,iy)=0) then dec_1(ix,iy);\r
+ break;\r
+ end; else\r
+ if (getBiomMap(ix)=2) then\r
+ begin\r
+ iy:=iy-1;\r
+ if (getmap(ix,iy+1)=48) and (getmap(ix,iy)=0) then dec_2(ix,iy);\r
+ break;\r
+ end; else\r
+ if (getBiomMap(ix)=3) then\r
+ begin\r
+ iy:=iy-1;\r
+ if (getmap(ix,iy+1)=74) and (getmap(ix,iy)=0) then dec_3(ix,iy);\r
+ break;\r
+ end; else\r
+ break;\r
+ end;\r
+ end;\r
+\r
+ procedure genwater;\r
+ var\r
+ ix,iy,i:integer;\r
+ g:boolean;\r
+ begin\r
+ for ix:=0 to 255 do\r
+ for iy:=0 to 127 do\r
+ begin\r
+ if rnd(5)=rnd(6) then g:=not g;\r
+ if iy>63 then\r
+ if (getmap(ix,iy)=2) or (getmap(ix,iy)=48) or (getmap(ix,iy)=74) then\r
+ begin\r
+ if g then\r
+ for i:=0 to rnd(4) do setmap(64,ix,iy+i);\r
+ else setmap(1,ix,iy);\r
+ break;\r
+ end; else\r
+ if (getmap(ix,iy)=7) then\r
+ begin\r
+ if g then\r
+ for i:=0 to rnd(4) do setmap(64,ix,iy+i);\r
+ break;\r
+ end;\r
+ if getmap(ix,iy)<>0 then break;\r
+ if iy>=63 then if getmap(ix,iy)=0 then setmap(50,ix,iy);\r
+ end;\r
+ end;\r
+\r
+ procedure minechest(x,y:integer);\r
+ var\r
+ ix,l,id:integer;\r
+ begin\r
+ id:=chest.create(x,y);\r
+ setmap(28,x,y);\r
+ for ix:=1 to rnd(6)+4 do\r
+ begin\r
+ l:=rnd(26);\r
+ if rnd(75)=rnd(75) then\r
+ begin\r
+ chest.setItem(133 ,l, id);\r
+ chest.setSum(getItemMax(133), l, id);\r
+ end; else\r
+ if rnd(25)=rnd(25) then\r
+ begin\r
+ chest.setItem(162 ,l, id);\r
+ chest.setSum(rnd(2)+1, l, id);\r
+ end; else\r
+ if rnd(15)=rnd(15) then\r
+ begin\r
+ chest.setItem(165 ,l, id);\r
+ chest.setSum(rnd(3)+1, l, id);\r
+ end; else\r
+ if rnd(15)=rnd(15) then\r
+ begin\r
+ chest.setItem(166 ,l, id);\r
+ chest.setSum(rnd(6)+4, l, id);\r
+ end; else\r
+ if rnd(15)=rnd(15) then\r
+ begin\r
+ chest.setItem(161 ,l, id);\r
+ chest.setSum(rnd(6)+4, l, id);\r
+ end; else\r
+ if rnd(15)=rnd(15) then\r
+ begin\r
+ chest.setItem(160 ,l, id);\r
+ chest.setSum(rnd(6)+3, l, id);\r
+ end; else\r
+ if rnd(15)=rnd(15) then\r
+ begin\r
+ chest.setItem(164 ,l, id);\r
+ chest.setSum(rnd(5)+1, l, id);\r
+ end; else\r
+ if rnd(4)=rnd(4) then\r
+ begin\r
+ chest.setItem(220 ,l, id);\r
+ chest.setSum(rnd(8)+8, l, id);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ procedure minestruc0(x,y:integer);\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to 3 do\r
+ for iy:=0 to 2 do\r
+ setmap(0,x+ix,y+iy);\r
+\r
+ if rnd(8)=0 then setmap(26,x+1,y+1);\r
+\r
+ for ix:=0 to 3 do\r
+ if getmap(x+ix,y+3)=0 then setmap(4,x+ix,y+3);\r
+ end;\r
+\r
+ procedure minestruc1(x,y:integer);\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to 2 do\r
+ for iy:=0 to 2 do\r
+ setmap(0,x+ix,y+iy);\r
+\r
+ if rnd(8)=0 then setmap(59,x,y);\r
+ if rnd(8)=0 then setmap(59,x+2,y);\r
+ setmap(4,x+1,y);\r
+ setmap(93,x+1,y+1);\r
+ setmap(93,x+1,y+2);\r
+ for ix:=0 to 2 do\r
+ if getmap(x+ix,y+3)=0 then setmap(4,x+ix,y+3);\r
+ end;\r
+\r
+ procedure minestruc2(x,y:integer);\r
+ var\r
+ ix,iy:integer;\r
+ begin\r
+ for ix:=0 to 2 do\r
+ for iy:=0 to 2 do\r
+ setmap(0,x+ix,y+iy);\r
+\r
+ if rnd(8)=0 then setmap(59,x+1,y);\r
+\r
+ for iy:=0 to 2 do\r
+ begin\r
+ setmap(94,x,y+iy);\r
+ setmap(94,x+2,y+iy);\r
+ end;\r
+ for ix:=0 to 2 do\r
+ if getmap(x+ix,y+3)=0 then setmap(4,x+ix,y+3);\r
+ end;\r
+\r
+ procedure minestruc3(x,y:integer);\r
+ var\r
+ ix,iy,id,l:integer;\r
+ begin\r
+ for ix:=0 to 2 do\r
+ for iy:=0 to 2 do\r
+ setmap(0,x+ix,y+iy);\r
+\r
+ minechest(x+1,y+2);\r
+\r
+ for ix:=0 to 2 do\r
+ if getmap(x+ix,y+3)=0 then setmap(4,x+ix,y+3);\r
+ end;\r
+\r
+ procedure genmines(x,y:integer);\r
+ var\r
+ mask:array[0..15,0..15] of integer;\r
+ ix,iy,by:integer;\r
+ begin\r
+ for iy:=0 to 15 do\r
+ for ix:=0 to 15 do\r
+ mask[ix,iy]:=-1;\r
+\r
+ for iy:=rnd(8)+8 downto rnd(8) do\r
+ for ix:=rnd(8) to rnd(8)+8 do\r
+ begin\r
+ if ix-1>=0 then\r
+ begin\r
+ if mask[ix-1,iy]=-1 then mask[ix,iy]:=rnd(3); else\r
+ if mask[ix-1,iy]=0 then if rnd(16)=5 then mask[ix,iy]:=2; else mask[ix,iy]:=1; else\r
+ if mask[ix-1,iy]=1 then mask[ix,iy]:=0; else\r
+ if mask[ix-1,iy]=2 then mask[ix,iy]:=rnd(3); else\r
+ if mask[ix-1,iy]=3 then mask[ix,iy]:=rnd(3);\r
+ end;\r
+\r
+ if mask[ix,iy]=0 then\r
+ begin\r
+ if rnd(16)=0 then mask[ix,iy]:=3;\r
+ end;\r
+ end;\r
+\r
+ for iy:=15 downto 0 do\r
+ for ix:=0 to 15 do\r
+ begin\r
+ if rnd(16)=0 then by:=rnd_min;;\r
+ if mask[ix,iy]=0 then minestruc0(x+(3*ix),y+(4*iy+by)); else\r
+ if mask[ix,iy]=1 then minestruc1(x+(3*ix),y+(4*iy+by)); else\r
+ if mask[ix,iy]=2 then minestruc2(x+(3*ix),y+(4*iy+by)); else\r
+ if mask[ix,iy]=3 then minestruc3(x+(3*ix),y+(4*iy+by));\r
+ end;\r
+ end;\r
+\r
+ function get_up(Xi:integer):integer;\r
+ var\r
+ iy:integer;\r
+ begin\r
+ for iy:=127 downto 0 do\r
+ if getmap(xi,iy)=0 then begin get_up:=iy; break; end;\r
+ end;\r
+\r
+ function get_down(Xi:integer):integer;\r
+ var\r
+ iy:integer;\r
+ begin\r
+ for iy:=2 to 127 do\r
+ if getmap(xi,iy)=0 then begin get_down:=iy; break; end;\r
+ end;\r
+\r
+ procedure gensoulsand(gx,gy:integer;);\r
+ var\r
+ ix2,iy2:integer;\r
+ begin\r
+ for ix2:=gx-2-rnd(3) to gx+2+rnd(3) do\r
+ for iy2:=gy-1-rnd(2) to gy+1+rnd(2) do\r
+ setmap(rnd_pr(80,113,getmap(ix2,iy2)),ix2,iy2);\r
+ end;\r
+\r
+ procedure genglowstone(gx,gy:integer;);\r
+ var\r
+ ix2,iy2:integer;\r
+ begin\r
+ for ix2:=gx-1-rnd(2) to gx+1+rnd(2) do\r
+ for iy2:=gy-1-rnd(2) to gy+rnd(2) do\r
+ setmap(rnd_pr(85,111,getmap(ix2,iy2)),ix2,iy2);\r
+ end;\r
+\r
+ procedure gennether;\r
+ var\r
+ ix,iy,h,wtd,ty,ga,tmp:integer;\r
+ begin\r
+ for ix:=0 to 255 do\r
+ for iy:=1 to 126 do\r
+ begin\r
+ if (getmap(ix,iy)<>10) or (getmap(ix,iy)<>110) then\r
+ setmap(109,ix,iy);\r
+ end;\r
+ h:=63;\r
+ ty:=4;\r
+ for ix:=0 to 255 do\r
+ begin\r
+ wtd:=rnd(100);\r
+ if (wtd>0) and (wtd<30) then h:=h+1;\r
+ if (wtd>29) and (wtd<60) then h:=h-1;\r
+ if wtd=0 then h:=h+(2+rnd(3));\r
+ if wtd=99 then h:=h-(2+rnd(3));\r
+ if h<30 then h:=31;\r
+ if h>70 then h:=69;\r
+ setBiomMap(ty, ix);\r
+ setBackMap(0, ix);\r
+ for iy:=h-10-(1-rnd(3)) to h+rnd(2) do\r
+ begin\r
+ setmap(0,ix,iy);\r
+ end;\r
+ end;\r
+\r
+ for ix:=0 to 255 do\r
+ for iy:=65 to 127 do\r
+ begin\r
+ if getmap(ix,iy)=0 then setmap(51,ix,iy);\r
+ end;\r
+\r
+ for ix:=1 to rnd(3)+3 do begin iy:=rnd(256); debug('SoulSand'); gensoulsand(iy,get_up(iy)); end;\r
+ for ix:=1 to rnd(4)+7 do begin iy:=rnd(256); debug('GlowStone - '+iy); genglowstone(iy,get_down(iy)); end;\r
+\r
+ for ix:=0 to 255 do\r
+ begin\r
+ setmap(6,ix,127);\r
+ setmap(6,ix,0);\r
+ end;\r
+ player.setX(get_spawn_x*16+4);\r
+ player.setY((get_up(get_spawn_x)-1)*16);\r
+ setmap(109,get_spawn_x,get_up(get_spawn_x)+1);\r
+ setmap(0,get_spawn_x,get_up(get_spawn_x));\r
+ setmap(0,get_spawn_x,get_up(get_spawn_x)-1);\r
+ genportal_big(get_spawn_x-2,(get_up(get_spawn_x)-1)-2);\r
+ end;\r
+\r
+ procedure genworld;\r
+ var\r
+ ix,iy,h,wtd,ty,ga,tmp:integer;\r
+ begin\r
+ pl_world:=0;\r
+ for ix:=0 to 255 do\r
+ for iy:=0 to 127 do\r
+ setmap(0,ix,iy);\r
+ h:=63;\r
+ ty:=rnd(4);\r
+ for ix:=0 to 255 do\r
+ begin\r
+ wtd:=rnd(100);\r
+ if (wtd>0) and (wtd<30) then h:=h+1;\r
+ if (wtd>29) and (wtd<60) then h:=h-1;\r
+ if wtd=0 then h:=h+(2+rnd(3));\r
+ if wtd=99 then h:=h-(2+rnd(3));\r
+ if h<0 then h:=0;\r
+ if h>80 then h:=80;\r
+ if wtd=rnd(100) then begin ty:=rnd(4); debug('Biome:'+ty); end;\r
+ setBiomMap(ty, ix);\r
+ setBackMap(h, ix);\r
+ if getBackMap(ix)>63 then\r
+ setBackMap(63, ix);\r
+ for iy:=h to 127 do\r
+ begin\r
+ if ty=0 then\r
+ begin\r
+ if iy=h then setmap(2,ix,iy);\r
+ if (iy>h) and (iy<h+4) then setmap(1,ix,iy);\r
+ if iy>h+3 then setmap(3,ix,iy);\r
+ end; else\r
+ if ty=1 then\r
+ begin\r
+ if (iy>=h) and (iy<=h+1) then setmap(7,ix,iy);\r
+ if iy=h+2 then setmap(rnd_pr(50,56,7),ix,iy);\r
+ if iy=h+3 then setmap(56,ix,iy);\r
+ if iy>h+3 then setmap(3,ix,iy);\r
+ end; else\r
+ if ty=2 then\r
+ begin\r
+ if iy=h then setmap(48,ix,iy);\r
+ if (iy>h) and (iy<h+4) then setmap(1,ix,iy);\r
+ if iy>h+3 then setmap(3,ix,iy);\r
+ end; else\r
+ if ty=3 then\r
+ begin\r
+ if iy=h then setmap(74,ix,iy);\r
+ if (iy>h) and (iy<h+4) then setmap(1,ix,iy);\r
+ if iy>h+3 then setmap(3,ix,iy);\r
+ end;\r
+ end;\r
+ end;\r
+\r
+ genallrudes;\r
+\r
+ for ix:=1 to rnd(4)+1 do begin debug('Cave'); gencave(rnd(256),64-rnd(10)); end;\r
+\r
+ for ix:=1 to rnd(3) do begin debug('Mine'); genmines(rnd(256),rnd(64)+64); end;\r
+\r
+ for ix:=1 to rnd(4) do begin debug('Treasure'); genteasures(rnd(256),rnd(64)+64); end;\r
+\r
+ genwater;\r
+\r
+ for ix:=0 to 255 do\r
+ for iy:=117 to 127 do\r
+ begin\r
+ if getmap(ix,iy)=0 then setmap(51,ix,iy);\r
+ end;\r
+\r
+ decorator;\r
+\r
+ for ix:=0 to 255 do\r
+ begin\r
+ if getBiomMap(ix)=2 then\r
+ for iy:=0 to 127 do\r
+ if getmap(ix,iy)<>0 then\r
+ begin\r
+ if getmap(ix,iy)=50 then setmap(62,ix,iy); else\r
+ if (getmap(ix,iy)<>22) and (getmap(ix,iy)<>23) then setmap(63,ix,iy-1);\r
+ break;\r
+ end;\r
+ end;\r
+\r
+ for ix:=0 to 255 do setmap(6,ix,127);\r
+\r
+ if bon_chest then create_bonus_chest(get_spawn_x,get_spawn_y+1);\r
+\r
+ //drawmap;\r
+ delay(200);\r
+ debug('World Generated!');\r
+ end;\r
+\r
+initialization\r
+ \r
+end.\r