From: DeaDDooMER Date: Sat, 1 Nov 2014 11:11:38 +0000 (+0300) Subject: BETA 9 Build 11 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=1ef13d5bd0592dde48cc837e05b13e93e82db25b;p=cavecraft.git BETA 9 Build 11 --- diff --git a/libs/Lib_bmp.class b/libs/Lib_bmp.class new file mode 100644 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 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 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 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 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 new file mode 100644 index 0000000..01e2720 --- /dev/null +++ b/libs/Lib_items_store.java @@ -0,0 +1,322 @@ +class Lib_items_store + { + /*Items*/ + static byte[] item_type; + static byte[] item_tex; + static int[] item_max; + static byte[] item_info; + static byte[] item_flags; + /*Blocks*/ + static byte[] block_tex; + static int[] block_hp; + static byte[] block_coll; + static byte[] block_tool; + static byte[] block_lvl; + static byte[] block_flags; + static byte[] block_tr; + static byte[] block_li; + /*Craft*/ + static byte[] [] craftIN_item; + static byte[] [] craftIN_sum; + static byte[] craftOUT_item; + static int[] craftOUT_sum; + static byte[] craftOUT_flag; + /*Tools*/ + static byte[] tool_type; + static byte[] tool_lvl; + static byte[] tool_speed; + static byte[] tool_damg; + +/*Items*/ + public static void resetitems(int len) + { + try { + item_type = new byte[len]; + item_tex = new byte[len]; + item_max = new int[len]; + item_info = new byte[len]; + item_flags = new byte[len]; + } catch(Exception e) {e.printStackTrace();} + } + + public static void setitemdata(int id, int type, int tex, int max, int info, int flags) + { + try { + item_type[id] = (byte) type; + item_tex[id] = (byte) tex; + item_max[id] = max; + item_info[id] = (byte) info; + item_flags[id] = (byte) flags; + } catch(Exception e) {e.printStackTrace();} + } + + public static int getitemtype(int id) + { + try { + return (int) item_type[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getitemtex(int id) + { + try { + return (int) item_tex[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getitemmax(int id) + { + try{ + return item_max[id]; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getiteminfo(int id) + { + try { + return (int) item_info[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getitemflags(int id) + { + try { + return (int) item_flags[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + +/*Blocks*/ + + public static void resetblocks(int len) + { + try { + block_tex = new byte[len]; + block_hp = new int[len]; + block_coll = new byte[len]; + block_tool = new byte[len]; + block_lvl = new byte[len]; + block_flags = new byte[len]; + block_tr = new byte[len]; + block_li = new byte[len]; + } catch(Exception e) {e.printStackTrace();} + } + + public static void setblockdata(int id, int tex, int hp, int coll, int tool, int lvl, int flags, int tr, int li) + { + try { + block_tex[id] = (byte) tex; + block_hp[id] = hp; + block_coll[id] = (byte) coll; + block_tool[id] = (byte) tool; + block_lvl[id] = (byte) lvl; + block_flags[id] = (byte) flags; + block_tr[id] = (byte) tr; + block_li[id] = (byte) li; + } catch(Exception e) {e.printStackTrace();} + } + + public static int getblocktex(int id) + { + try { + return (int) block_tex[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getblockhp(int id) + { + try { + return block_hp[id]; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getblockcoll(int id) + { + try { + return (int) block_coll[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getblocktool(int id) + { + try { + return (int) block_tool[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getblocklvl(int id) + { + try { + return (int) block_lvl[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getblockflags(int id) + { + try { + return (int) block_flags[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getblocktr(int id) + { + try { + return (int) block_tr[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int getblockli(int id) + { + try { + return (int) block_li[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + /*Craft*/ + public static void reset_crafts(int len) + { + try { + craftIN_item = new byte[4][len]; + craftIN_sum = new byte[4][len]; + craftOUT_item = new byte[len]; + craftOUT_sum = new int[len]; + craftOUT_flag = new byte[len]; + } catch(Exception e) {e.printStackTrace();} + } + + 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) + { + try { + craftIN_item[0][id] = (byte) item0; + craftIN_sum[0][id] = (byte) sum0; + craftIN_item[1][id] = (byte) item1; + craftIN_sum[1][id] = (byte) sum1; + craftIN_item[2][id] = (byte) item2; + craftIN_sum[2][id] = (byte) sum2; + craftIN_item[3][id] = (byte) item3; + craftIN_sum[3][id] = (byte) sum3; + craftOUT_item[id] = (byte) outitem; + craftOUT_sum[id] = outsum; + craftOUT_flag[id] = (byte) flag; + } catch(Exception e) {e.printStackTrace();} + } + + public static void set_craftin_item(int id, int num, int item) + { + try { + craftIN_item[num][id] = (byte) item; + } catch(Exception e) {/*e.printStackTrace();*/} + } + + public static void set_craftin_sum(int id, int num, int sum) + { + try { + craftIN_sum[num][id] = (byte) sum; + } catch(Exception e) {/*e.printStackTrace();*/} + } + + public static void set_craftout_item(int id, int item) + { + try { + craftOUT_item[id] = (byte) item; + } catch(Exception e) {/*e.printStackTrace();*/} + } + + public static void set_craftout_sum(int id, int sum) + { + try { + craftOUT_sum[id] = sum; + } catch(Exception e) {/*e.printStackTrace();*/} + } + + public static void set_craftout_flag(int id, int flag) + { + try { + craftOUT_flag[id] = (byte) flag; + } catch(Exception e) {/*e.printStackTrace();*/} + } + + public static int get_craftin_item(int id, int num) + { + try { + return craftIN_item[num][id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int get_craftin_sum(int id, int num) + { + try { + return craftIN_sum[num][id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int get_craftout_item(int id) + { + try { + return craftOUT_item[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int get_craftout_sum(int id) + { + try { + return craftOUT_sum[id]; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int get_craftout_flag(int id) + { + try { + return craftOUT_flag[id] & 0xFF; + } catch(Exception e) {/*e.printStackTrace();*/ return 0xFF;} + } + +/*Tools*/ + public static void resettools(int len) + { + try { + tool_type = new byte[len]; + tool_lvl = new byte[len]; + tool_speed = new byte[len]; + tool_damg = new byte[len]; + } catch(Exception e) {e.printStackTrace();} + } + + public static void settooldata(int id, int tool, int lvl, int speed, int damg) + { + try { + tool_type[id] = (byte) tool; + tool_lvl[id] = (byte) lvl; + tool_speed[id] = (byte) speed; + tool_damg[id] = (byte) damg; + } catch(Exception e) {e.printStackTrace();} + } + + public static int gettooltype(int id) + { + try { + return tool_type[item_info[id]]; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int gettoollvl(int id) + { + try { + return tool_lvl[item_info[id]]; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int gettoolspeed(int id) + { + try { + return tool_speed[item_info[id]]; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + public static int gettooldamg(int id) + { + try { + return tool_damg[item_info[id]]; + } catch(Exception e) {/*e.printStackTrace();*/ return 0;} + } + + } \ No newline at end of file diff --git a/libs/Lib_jpeg.class b/libs/Lib_jpeg.class new file mode 100644 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 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 new file mode 100644 index 0000000..01eda1d --- /dev/null +++ b/libs/Lib_localfiles.java @@ -0,0 +1,12 @@ +import java.io.*; + +class Lib_localfiles +{ + public static int readunsbyte(InputStream is) + { + try{ + DataInputStream dis = new DataInputStream(is); + return (int) dis.readUnsignedByte(); + } catch(Exception e) {return -1;} + } +} \ No newline at end of file diff --git a/libs/Lib_maps.class b/libs/Lib_maps.class new file mode 100644 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 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 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 new file mode 100644 index 0000000..606d3df --- /dev/null +++ b/libs/Lib_particles_store.java @@ -0,0 +1,63 @@ +class Lib_particles_store + { + static byte[] particle_type; + static byte[] particle_ani; + static short[] particle_x; + static short[] particle_y; + + public static void reset_particles(int len) + { + particle_type = new byte[len]; + particle_ani = new byte[len]; + particle_x = new short[len]; + particle_y = new short[len]; + } + + public static void set_particle(int id, int type, int ani, int x, int y) + { + particle_type[id] = (byte) type; + particle_ani[id] = (byte) ani; + particle_x[id] = (short) x; + particle_y[id] = (short) y; + } + + public static void set_particle_type(int id, int type) + { + particle_type[id] = (byte) type; + } + + public static void set_particle_ani(int id, int ani) + { + particle_ani[id] = (byte) ani; + } + + public static void set_particle_x(int id, int x) + { + particle_x[id] = (short) x; + } + + public static void set_particle_y(int id, int y) + { + particle_y[id] = (short) y; + } + + public static int get_particle_type(int id) + { + return particle_type[id] & 0xFF; + } + + public static int get_particle_ani(int id) + { + return particle_ani[id] & 0xFF; + } + + public static int get_particle_x(int id) + { + return particle_x[id]; + } + + public static int get_particle_y(int id) + { + return particle_y[id]; + } +} \ No newline at end of file diff --git a/libs/Lib_png3.class b/libs/Lib_png3.class new file mode 100644 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 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 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 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 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 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 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 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 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 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 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 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 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 new file mode 100644 index 0000000..c70341f --- /dev/null +++ b/res/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +MIDlet-1: bin, /icon.png, FW +MIDlet-Name: bin +MIDlet-Vendor: MIDletPascal3 +MIDlet-Version: 04082014.214104 +MicroEdition-Configuration: CLDC-1.0 +MicroEdition-Profile: MIDP-2.0 +MIDlet-Icon: /icon.png +Created-By: Build-Script V1.03 (DeaDSoftWare) diff --git a/res/StaticTree.class b/res/StaticTree.class new file mode 100644 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 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 index 0000000..afb48d5 Binary files /dev/null and b/res/ZStream.class differ diff --git a/res/autoexec.cfg b/res/autoexec.cfg new file mode 100644 index 0000000..9dd39be --- /dev/null +++ b/res/autoexec.cfg @@ -0,0 +1,36 @@ +;Standard execute file for CaveCraft +SET_RESOLUTION 240 320 TRUE +BL_UPD 2 +REF_DRP TRUE +GET_DRP TRUE +SPAWN_MOBS TRUE +PRT_UPD TRUE +MAX_FPS 30 +DRW_BACK TRUE +DRP_PHY TRUE +DRW_SM TRUE +JPEG_Q 100 +LOAD_SM 2 +S_WEATHER FALSE +S_LIGHT FALSE +S_PARTICLES FALSE +LOAD_SKY 0 +LOAD_BACK_TEX TRUE +LOAD_WEATHER_TEX TRUE +LOAD_PARTICLES_TEX TRUE +LOAD_LIGHT_TEX TRUE +LOAD_GUI_TEX TRUE +MENU_BACKGROUND 1 +DRW_DRP TRUE +DRW_STARS TRUE +LD_SETT +LOAD_MINIMAP_TEX TRUE +MAX_PARTICLES 255 +EXEC AUTO keyboard.cfg +EXEC AUTO vkeyboard.cfg +EXEC AUTO textures.cfg +EXEC AUTO items.cfg +EXEC AUTO blocks.cfg +EXEC AUTO crafts.cfg +EXEC AUTO tools.cfg +EXEC AUTO furnace.cfg diff --git a/res/back.png b/res/back.png new file mode 100644 index 0000000..8b652f2 Binary files /dev/null and b/res/back.png differ diff --git a/res/blocks.cfg b/res/blocks.cfg new file mode 100644 index 0000000..32a2eca --- /dev/null +++ b/res/blocks.cfg @@ -0,0 +1,250 @@ +;Файл инициализации описания свойств стандартного набора блоков CaveCraft +;Все описанные здесь блоки могут отображаться на карте. + +;Устанавливаем количество блоков +RESET_BLOCKS 124 + +;Описание команды установки блока: +;SET_BLOCK [id] [tex] [hp] [coll] [tool] [lvl] [flags] [tr] [li] +;id - индентификатор блока. +;tex - номер текстуры блока из terrain.png. +;hp - прочность блока. +;coll - тип коллизии: +; 0 - проходимый +; 1 - полностью твёрдый +;tool - тип инструмента необходимый для "правильной" поломки болка. +;lvl - минимальный уровень инструмента необходимый для "правильной" поломки блока: +; 0 - руки +; 1 - дерево +; 2 - камень +; 3 - железо +; 4 - золото +; 5 - алмазы +;flags - битовые флаги: +; b001 - объект (полу)прозрачный +; b010 - рисовать за/перед игроком +; b100 - можно устанавливать поверх этого блока +;tr - уровень светопоглощения +;li - уровень светоизлучения + +;Null +SET_BLOCK 0 0 0 0 0 0 b101 0 0 +;Земля +SET_BLOCK 1 1 9 1 2 0 b000 15 0 +;Трава +SET_BLOCK 2 2 9 1 2 0 b000 15 0 +;Камень +SET_BLOCK 3 3 60 1 1 1 b000 15 0 +;Доски +SET_BLOCK 4 4 30 1 3 0 b000 15 0 +;Булыжник +SET_BLOCK 5 5 60 1 1 1 b000 15 0 +;Админиум +SET_BLOCK 6 6 0x7FFFFFFF 1 0 0 b000 15 0 +;Песок +SET_BLOCK 7 7 9 1 2 0 b000 15 0 +;Гравий +SET_BLOCK 8 8 9 1 2 0 b000 15 0 +;Дерево +SET_BLOCK 9 9 30 1 3 0 b000 15 0 +;Обсидиан +SET_BLOCK 10 10 1000 1 1 5 b000 15 0 +;Книжный шкаф +SET_BLOCK 11 11 24 0 3 0 b000 0 0 +;Замшелый булыжник +SET_BLOCK 12 12 40 1 1 1 b000 15 0 +;Железный блок +SET_BLOCK 13 13 40 1 1 2 b000 15 0 +;Золотой блок +SET_BLOCK 14 14 60 1 1 3 b000 15 0 +;Алмазный блок +SET_BLOCK 15 15 60 1 1 3 b000 15 0 +;Золотая руда +SET_BLOCK 16 16 65 1 1 3 b000 15 0 +;Железная руда +SET_BLOCK 17 17 65 1 1 2 b000 15 0 +;Угольная руда +SET_BLOCK 18 18 65 1 1 1 b000 15 0 +;Алмазная руда +SET_BLOCK 19 19 65 1 1 3 b000 15 0 +;Красная руда +SET_BLOCK 20 20 65 1 1 3 b000 15 6 +;Листва +SET_BLOCK 21 21 3 1 4 1 b000 1 0 +;Красный цветок +SET_BLOCK 22 22 0 0 0 0 b101 0 0 +;Жёлтый цветок +SET_BLOCK 23 23 0 0 0 0 b101 0 0 +;Красный гриб +SET_BLOCK 24 24 0 0 0 0 b101 0 0 +;Коричневый гриб +SET_BLOCK 25 25 0 0 0 0 b101 0 0 +;Факел +SET_BLOCK 26 26 0 0 0 0 b001 0 14 +;Динамит +SET_BLOCK 27 27 0 1 0 0 b000 15 0 +;Сундук +SET_BLOCK 28 28 39 0 3 0 b000 0 0 +;Верстак +SET_BLOCK 29 29 39 0 3 0 b000 0 0 +;Кактус +SET_BLOCK 30 30 6 1 0 0 b001 0 0 +;Стекло +; -- -- - - - ? ---- - - +SET_BLOCK 31 31 6 1 0 1 b001 1 0 +;Шерсть +SET_BLOCK 32 32 12 0 0 0 b000 0 0 +SET_BLOCK 33 33 12 0 0 0 b000 0 0 +SET_BLOCK 34 34 12 0 0 0 b000 0 0 +SET_BLOCK 35 35 12 0 0 0 b000 0 0 +SET_BLOCK 36 36 12 0 0 0 b000 0 0 +SET_BLOCK 37 37 12 0 0 0 b000 0 0 +SET_BLOCK 38 38 12 0 0 0 b000 0 0 +SET_BLOCK 39 39 12 0 0 0 b000 0 0 +SET_BLOCK 40 40 12 0 0 0 b000 0 0 +SET_BLOCK 41 41 12 0 0 0 b000 0 0 +SET_BLOCK 42 42 12 0 0 0 b000 0 0 +SET_BLOCK 43 43 12 0 0 0 b000 0 0 +SET_BLOCK 44 44 12 0 0 0 b000 0 0 +SET_BLOCK 45 45 12 0 0 0 b000 0 0 +SET_BLOCK 46 46 12 0 0 0 b000 0 0 +SET_BLOCK 47 47 12 0 0 0 b000 0 0 +;Снег +SET_BLOCK 48 48 9 1 2 0 b000 15 0 +;Лестница +SET_BLOCK 49 49 6 0 0 0 b001 0 0 +;Вода +SET_BLOCK 50 50 0x7FFFFFFF 0 0 0 b111 1 0 +;Лава +SET_BLOCK 51 55 0x7FFFFFFF 0 0 0 b111 15 15 +;Саженец +SET_BLOCK 52 60 0 0 0 0 b101 0 0 +;Губка +SET_BLOCK 53 61 9 1 0 0 b000 15 0 +;Лазуритовая руда +SET_BLOCK 54 62 65 1 1 2 b000 15 0 +;Лазуритовый блок +SET_BLOCK 55 63 65 1 1 2 b000 15 0 +;Песчаник +SET_BLOCK 56 64 50 1 1 1 b000 15 0 +;Высокая трава +SET_BLOCK 57 65 0 0 4 1 b101 0 0 +;Сухой куст +SET_BLOCK 58 66 0 0 4 1 b101 0 0 +;Паутина +SET_BLOCK 59 67 60 0 4 1 b101 0 0 +;Кирпичный блок +SET_BLOCK 60 68 60 1 1 1 b000 15 0 +;Снежный блок +SET_BLOCK 61 69 3 1 2 0 b000 15 0 +;Лёд +SET_BLOCK 62 70 8 1 1 6 b001 2 0 +;Слой снега +SET_BLOCK 63 71 2 0 2 1 b111 1 0 +;Глиняный блок +SET_BLOCK 64 72 9 1 2 0 b000 15 0 +;Тростник +SET_BLOCK 65 73 0 0 0 0 b111 0 0 +;Тыква +SET_BLOCK 66 74 15 1 3 0 b000 15 0 +;Светильник джека +SET_BLOCK 67 75 15 1 3 0 b000 15 15 +;Каменный кирпич +SET_BLOCK 68 76 60 1 1 1 b000 15 0 +SET_BLOCK 69 77 60 1 1 1 b000 15 0 +SET_BLOCK 70 78 60 1 1 1 b000 15 0 +;Резной кирпич +SET_BLOCK 71 79 60 1 1 1 b000 15 0 +;Железная решётка +SET_BLOCK 72 80 60 0 1 1 b011 0 0 +;Арбуз +SET_BLOCK 73 81 15 1 0 0 b000 15 0 +;Мицелий +SET_BLOCK 74 82 8 1 2 0 b000 15 0 +;Дерево(проходимое) +SET_BLOCK 75 98 30 0 3 0 b000 0 0 +;Спаунер +SET_BLOCK 76 83 75 0 0 0 b001 0 0 +;Кровать +SET_BLOCK 77 84 3 0 0 0 b001 0 0 +SET_BLOCK 78 85 3 0 0 0 b001 0 0 +;Откр. дверь +SET_BLOCK 79 86 30 0 3 0 b001 0 0 +SET_BLOCK 80 102 30 0 3 0 b001 0 0 +;Закр. дверь +SET_BLOCK 81 88 30 1 3 0 b011 0 0 +SET_BLOCK 82 104 30 1 3 0 b011 0 0 +;Берёза +SET_BLOCK 83 90 30 1 3 0 b000 0 0 +;Берёза(проходимая) +SET_BLOCK 84 99 30 0 3 0 b000 0 0 +;Ель +SET_BLOCK 85 91 30 1 3 0 b000 0 0 +;Ель(проходимая) +SET_BLOCK 86 100 30 0 3 0 b000 0 0 +;Листва(ель) +SET_BLOCK 87 92 3 1 4 1 b000 1 0 +;Краснывй огромный гриб +SET_BLOCK 88 93 3 1 3 0 b000 15 0 +SET_BLOCK 89 95 3 0 3 0 b000 0 0 +;Коричневый огромный гриб +SET_BLOCK 90 94 3 1 3 0 b000 15 0 +SET_BLOCK 91 95 3 0 3 0 b000 0 0 +;Забор +SET_BLOCK 92 96 30 1 3 0 b001 0 0 +SET_BLOCK 93 101 30 0 3 0 b001 0 0 +;Доски(проходимые) +SET_BLOCK 94 97 30 0 3 0 b000 0 0 +;Картины +SET_BLOCK 95 106 0 0 0 0 b101 0 0 +SET_BLOCK 96 107 0 0 0 0 b101 0 0 +SET_BLOCK 97 108 0 0 0 0 b101 0 0 +SET_BLOCK 98 109 0 0 0 0 b101 0 0 +SET_BLOCK 99 110 0 0 0 0 b101 0 0 +SET_BLOCK 100 111 0 0 0 0 b101 0 0 +SET_BLOCK 101 112 0 0 0 0 b101 0 0 +;Подарочный сундук +SET_BLOCK 102 113 30 0 3 0 b000 0 15 +;Лианы +SET_BLOCK 103 114 3 0 4 1 b111 0 0 +;Табличка +SET_BLOCK 104 115 15 0 0 0 b001 0 0 +;Красный факел +SET_BLOCK 105 116 0 0 0 0 b101 0 7 +;Печь +SET_BLOCK 106 117 40 0 3 0 b000 0 0 +;Люк +SET_BLOCK 107 118 30 1 3 0 b011 0 0 +SET_BLOCK 108 119 30 0 3 0 b001 0 0 +;Адский камень +SET_BLOCK 109 120 30 1 1 1 b000 15 0 +;Портал в ад +SET_BLOCK 110 129 0x7FFFFFFF 0 0 0 b011 0 11 +;Светокамень +SET_BLOCK 111 121 10 1 1 0 b000 0 15 +;Листва(берёза) +SET_BLOCK 112 135 3 1 4 1 b000 1 0 +;Песок душ +SET_BLOCK 113 122 9 1 2 0 b000 15 0 +;Саженец(берёза) +SET_BLOCK 114 123 0 0 0 0 b101 0 0 +;Саженец(ель) +SET_BLOCK 115 124 0 0 0 0 b101 0 0 +;Лампа +SET_BLOCK 116 125 10 1 1 0 b000 0 0 +SET_BLOCK 117 126 10 1 1 0 b000 0 15 +;Обсидиан(проходимый) +SET_BLOCK 118 127 1000 0 1 5 b000 15 0 +;Стеклянная панель +SET_BLOCK 119 128 6 0 0 1 b001 1 0 +;Грядка +SET_BLOCK 120 136 9 1 2 0 b000 15 0 +;Торт +SET_BLOCK 121 137 9 0 0 0 b001 0 0 +;Пшеница +SET_BLOCK 122 138 1 0 0 0 b101 0 0 +;Стебель арбуза +SET_BLOCK 123 139 1 0 0 0 b101 0 0 +;Стебель тыквы +SET_BLOCK 124 139 1 0 0 0 b101 0 0 + diff --git a/res/crafts.cfg b/res/crafts.cfg new file mode 100644 index 0000000..b758f8f --- /dev/null +++ b/res/crafts.cfg @@ -0,0 +1,318 @@ +;Ôàéë èíèöèàëèçàöèè îïèñàíèÿ ðåöåïòîâ êðàôòà + +;Óñòàíàâëèâàåì êîëè÷åñòâî êðàôòîâ +RESET_CRAFTS 84 + +;Îïèñàíèå êîìàíä óñòàíîâêè ðåöåïòà êðàôòà: +;SET_CRAFT_IN [id] [cell] [item] [sum] +;id - èäåíòèôèêàòîð êðàôòà +;cell - ÿ÷åéêà èíãðåäèåíòà +;item - èäåíòèôèêàòîð ïðåäìåòà +;sum - íåîáõîäèìîå êîëè÷åñòâî ïðåäìåòîâ +; +;SET_CRAFT_OUT [id] [item] [sum] [flag] +;id - èäåíòèôèêàòîð êðàôòà +;item - èäåíòèôèêàòîð ïîëó÷èâøåãîñÿ ïðåäìåòà ïðåäìåòà +;sum - êîëè÷åñòâî ïîëó÷èâøåãîñÿ ïðåäìåòà ïðåäìåòà +;flag - óñëîâèå ñîçäàíèÿ êðàôòà: +; 0 - íà êîëåíêå :) +; 1 - íà âåðñòàêå + +;Äîñêè(èç äóáà) +SET_CRAFT_IN 0 0 9 1 +SET_CRAFT_OUT 0 4 4 0 +;Äîñêè(èç áåð¸çû) +SET_CRAFT_IN 1 0 83 1 +SET_CRAFT_OUT 1 4 4 0 +;Äîñêè(èç åëè) +SET_CRAFT_IN 2 0 85 1 +SET_CRAFT_OUT 2 4 4 0 +;Ñóíäóê +SET_CRAFT_IN 3 0 4 8 +SET_CRAFT_OUT 3 28 1 1 +;Âåðñòàê +SET_CRAFT_IN 4 0 4 4 +SET_CRAFT_OUT 4 29 1 0 +;Ïå÷ü +SET_CRAFT_IN 5 0 5 8 +SET_CRAFT_OUT 5 106 1 1 +;Äèíàìèò +SET_CRAFT_IN 6 0 7 4 +SET_CRAFT_IN 6 1 183 5 +SET_CRAFT_OUT 6 27 1 1 +;Ãëèíà +SET_CRAFT_IN 7 0 169 4 +SET_CRAFT_OUT 7 64 1 0 +;Ïåñ÷àíèê +SET_CRAFT_IN 8 0 7 4 +SET_CRAFT_OUT 8 56 1 0 +;Ñíåæíûé áëîê +SET_CRAFT_IN 9 0 168 4 +SET_CRAFT_OUT 9 61 1 0 +;Æåëåçíûé áëîê +SET_CRAFT_IN 10 0 164 9 +SET_CRAFT_OUT 10 13 1 1 +;Çîëîòîé áëîê +SET_CRAFT_IN 11 0 165 9 +SET_CRAFT_OUT 11 14 1 1 +;Àëìàçíûé áëîê +SET_CRAFT_IN 12 0 162 9 +SET_CRAFT_OUT 12 15 1 1 +;Ëàçóðèòíûé áëîê +SET_CRAFT_IN 13 0 166 9 +SET_CRAFT_OUT 13 55 1 1 +;Æåëåçíàÿ ðåø¸òêà +SET_CRAFT_IN 14 0 164 6 +SET_CRAFT_OUT 14 72 9 1 +;Êèðïè÷íàÿ êëàäêà +SET_CRAFT_IN 15 0 163 4 +SET_CRAFT_OUT 15 60 1 0 +;Êàìåííûé êèðïè÷ +SET_CRAFT_IN 16 0 3 4 +SET_CRAFT_OUT 16 68 4 0 +;Êíèæíûé øêàô +SET_CRAFT_IN 17 0 4 6 +SET_CRAFT_IN 17 1 170 3 +SET_CRAFT_OUT 17 11 1 1 +;Øåðñòü +SET_CRAFT_IN 18 0 167 4 +SET_CRAFT_OUT 18 32 1 0 +;Çàáîð +SET_CRAFT_IN 19 0 127 6 +SET_CRAFT_OUT 19 92 3 1 +;Ëåñòíèöà +SET_CRAFT_IN 20 0 127 7 +SET_CRAFT_OUT 20 49 3 1 +;Êàðòèíû +SET_CRAFT_IN 21 0 127 8 +SET_CRAFT_IN 21 1 32 1 +SET_CRAFT_OUT 21 187 1 1 +;Äâåðü +SET_CRAFT_IN 22 0 4 6 +SET_CRAFT_OUT 22 178 1 1 +;Êðîâàòü +SET_CRAFT_IN 23 0 32 3 +SET_CRAFT_IN 23 1 4 3 +SET_CRAFT_OUT 23 179 1 1 +;Òàáëè÷êè +SET_CRAFT_IN 24 0 4 6 +SET_CRAFT_IN 24 1 127 1 +SET_CRAFT_OUT 24 104 3 1 +;Äåðåâÿííàÿ êèðêà +SET_CRAFT_IN 25 0 4 3 +SET_CRAFT_IN 25 1 127 2 +SET_CRAFT_OUT 25 131 60 1 +;Êàìåííàÿ êèðêà +SET_CRAFT_IN 26 0 5 3 +SET_CRAFT_IN 26 1 127 2 +SET_CRAFT_OUT 26 132 132 1 +;Æåëåçíàÿ êèðêà +SET_CRAFT_IN 27 0 164 3 +SET_CRAFT_IN 27 1 127 2 +SET_CRAFT_OUT 27 133 251 1 +;Çîëîòàÿ êèðêà +SET_CRAFT_IN 28 0 165 3 +SET_CRAFT_IN 28 1 127 2 +SET_CRAFT_OUT 28 135 33 1 +;Àëìàçíàÿ êèðêà +SET_CRAFT_IN 29 0 162 3 +SET_CRAFT_IN 29 1 127 2 +SET_CRAFT_OUT 29 134 1562 1 +;Äåðåâÿííàÿ ëîïàòà +SET_CRAFT_IN 30 0 4 1 +SET_CRAFT_IN 30 1 127 2 +SET_CRAFT_OUT 30 136 60 1 +;Êàìåííàÿ ëîïàòà +SET_CRAFT_IN 31 0 5 1 +SET_CRAFT_IN 31 1 127 2 +SET_CRAFT_OUT 31 137 132 1 +;Æåëåçíàÿ ëîïàòà +SET_CRAFT_IN 32 0 164 1 +SET_CRAFT_IN 32 1 127 2 +SET_CRAFT_OUT 32 138 251 1 +;Çîëîòàÿ ëîïàòà +SET_CRAFT_IN 33 0 165 1 +SET_CRAFT_IN 33 1 127 2 +SET_CRAFT_OUT 33 140 33 1 +;Àëìàçíàÿ ëîïàòà +SET_CRAFT_IN 34 0 162 1 +SET_CRAFT_IN 34 1 127 2 +SET_CRAFT_OUT 34 139 1562 1 +;Äåðåâÿííûé òîïîð +SET_CRAFT_IN 35 0 4 3 +SET_CRAFT_IN 35 1 127 2 +SET_CRAFT_OUT 35 141 60 1 +;Êàìåííûé òîïîð +SET_CRAFT_IN 36 0 5 3 +SET_CRAFT_IN 36 1 127 2 +SET_CRAFT_OUT 36 142 132 1 +;Äåðåâÿííûé òîïîð +SET_CRAFT_IN 37 0 164 3 +SET_CRAFT_IN 37 1 127 2 +SET_CRAFT_OUT 37 143 251 1 +;Çîëîòîé òîïîð +SET_CRAFT_IN 38 0 165 3 +SET_CRAFT_IN 38 1 127 2 +SET_CRAFT_OUT 38 145 33 1 +;Àëìàçíûé òîïîð +SET_CRAFT_IN 39 0 162 3 +SET_CRAFT_IN 39 1 127 2 +SET_CRAFT_OUT 39 144 1562 1 +;Íîæíèöû +SET_CRAFT_IN 40 0 164 2 +SET_CRAFT_OUT 40 146 259 0 +;Äåðåâÿííûé ìå÷ +SET_CRAFT_IN 41 0 4 2 +SET_CRAFT_IN 41 1 127 1 +SET_CRAFT_OUT 41 147 60 1 +;Êàìåííûé ìå÷ +SET_CRAFT_IN 42 0 5 2 +SET_CRAFT_IN 42 1 127 1 +SET_CRAFT_OUT 42 148 132 1 +;Æåëåçíûé ìå÷ +SET_CRAFT_IN 43 0 164 2 +SET_CRAFT_IN 43 1 127 1 +SET_CRAFT_OUT 43 149 251 1 +;Çîëîòîé ìå÷ +SET_CRAFT_IN 44 0 165 2 +SET_CRAFT_IN 44 1 127 1 +SET_CRAFT_OUT 44 151 33 1 +;Àëìàçíûé ìå÷ +SET_CRAFT_IN 45 0 162 2 +SET_CRAFT_IN 45 1 127 1 +SET_CRAFT_OUT 45 150 1562 1 +;Óäî÷êà +SET_CRAFT_IN 46 0 127 3 +SET_CRAFT_IN 46 1 167 2 +SET_CRAFT_OUT 46 152 65 1 +;Âåäðî +SET_CRAFT_IN 47 0 164 3 +SET_CRAFT_OUT 47 171 1 1 +;Æåëåçíûé áëîê -> æåëåçíûå ñëèòêè +SET_CRAFT_IN 48 0 13 1 +SET_CRAFT_OUT 48 164 9 0 +;Çîëîòîé áëîê -> çîëîòûå ñëèòêè +SET_CRAFT_IN 49 0 14 1 +SET_CRAFT_OUT 49 165 9 0 +;Àëìàçíûé áëîê -> àëìàçû +SET_CRAFT_IN 50 0 15 1 +SET_CRAFT_OUT 50 162 9 0 +;Ëàçóðèòîâûé áëîê -> óëüòðàìàðèí +SET_CRAFT_IN 51 0 55 1 +SET_CRAFT_OUT 51 166 9 0 +;Çîëîòîé ñëèòîê -> çîëîòîé ñàìîðîäîê +SET_CRAFT_IN 52 0 165 1 +SET_CRAFT_OUT 52 194 9 0 +;Çîëîòîé ñàìîðîäîê -> çîëîòîé ñëèòîê +SET_CRAFT_IN 53 0 194 9 +SET_CRAFT_OUT 53 165 1 1 +;Áóìàãà +SET_CRAFT_IN 54 0 65 3 +SET_CRAFT_OUT 54 175 3 1 +;Êíèãà +SET_CRAFT_IN 55 0 175 3 +SET_CRAFT_IN 55 1 198 1 +SET_CRAFT_OUT 55 170 1 0 +;Êàðòà +SET_CRAFT_IN 56 0 175 8 +SET_CRAFT_IN 56 1 216 1 +SET_CRAFT_OUT 56 186 1 1 +;Ïàëêè +SET_CRAFT_IN 57 0 4 2 +SET_CRAFT_OUT 57 127 4 0 +;Ôàêåë +SET_CRAFT_IN 58 0 160 1 +SET_CRAFT_IN 58 1 127 1 +SET_CRAFT_OUT 58 26 4 0 +;Êðàñíûé ôàêåë +SET_CRAFT_IN 59 0 161 1 +SET_CRAFT_IN 59 1 127 1 +SET_CRAFT_OUT 59 105 1 0 +;×àøêà +SET_CRAFT_IN 60 0 4 3 +SET_CRAFT_OUT 60 184 4 1 +;Òóøåíûå ãðèáû +SET_CRAFT_IN 61 0 184 1 +SET_CRAFT_IN 61 1 24 1 +SET_CRAFT_IN 61 2 25 1 +SET_CRAFT_OUT 61 185 1 0 +;Ƹëòûé êðàñèòåëü +SET_CRAFT_IN 62 0 23 1 +SET_CRAFT_OUT 62 128 2 0 +;Êðàñíûé êðàñèòåëü +SET_CRAFT_IN 63 0 22 1 +SET_CRAFT_OUT 63 129 2 0 +;Çîëîòîå ÿáëîêî +SET_CRAFT_IN 64 0 201 1 +SET_CRAFT_IN 64 1 194 8 +SET_CRAFT_OUT 64 202 1 1 +;Ëþê +SET_CRAFT_IN 65 0 4 6 +SET_CRAFT_OUT 65 108 2 1 +;Îãíèâî +SET_CRAFT_IN 66 0 164 1 +SET_CRAFT_IN 66 1 207 1 +SET_CRAFT_OUT 66 153 65 0 +;Ñâåòîêàìåíü +SET_CRAFT_IN 67 0 214 4 +SET_CRAFT_OUT 67 111 1 0 +;Ëàìïà +SET_CRAFT_IN 68 0 161 4 +SET_CRAFT_IN 68 1 111 1 +SET_CRAFT_OUT 68 116 1 1 +;Êîìïàñ +SET_CRAFT_IN 69 0 161 1 +SET_CRAFT_IN 69 1 164 4 +SET_CRAFT_OUT 69 216 1 1 +;Ñòåêëÿííàÿ ïàíåëü +SET_CRAFT_IN 70 0 31 6 +SET_CRAFT_OUT 70 119 16 1 +;×àñû +SET_CRAFT_IN 71 0 161 1 +SET_CRAFT_IN 71 1 165 4 +SET_CRAFT_OUT 71 215 1 1 +;Ñàõàð +SET_CRAFT_IN 72 0 65 1 +SET_CRAFT_OUT 72 195 1 0 +;Õëåá +SET_CRAFT_IN 73 0 218 3 +SET_CRAFT_OUT 73 219 1 1 +;Òîðò +SET_CRAFT_IN 74 0 174 1 +SET_CRAFT_IN 74 1 177 1 +SET_CRAFT_IN 74 2 195 2 +SET_CRAFT_IN 74 3 218 3 +SET_CRAFT_OUT 74 121 1 1 +;Äåðåâÿííàÿ ìîòûãà +SET_CRAFT_IN 75 0 4 2 +SET_CRAFT_IN 75 1 127 2 +SET_CRAFT_OUT 75 154 60 1 +;Êàìåííàÿ ìîòûãà +SET_CRAFT_IN 76 0 5 2 +SET_CRAFT_IN 76 1 127 2 +SET_CRAFT_OUT 76 155 132 1 +;Æåëåçíàÿ ìîòûãà +SET_CRAFT_IN 77 0 164 2 +SET_CRAFT_IN 77 1 127 2 +SET_CRAFT_OUT 77 156 251 1 +;Çîëîòàÿ ìîòûãà +SET_CRAFT_IN 78 0 165 2 +SET_CRAFT_IN 78 1 127 2 +SET_CRAFT_OUT 78 158 33 1 +;Àëìàçíàÿ ìîòûãà +SET_CRAFT_IN 79 0 162 2 +SET_CRAFT_IN 79 1 127 2 +SET_CRAFT_OUT 79 157 1562 1 +;Ñåìåíà òûêâû +SET_CRAFT_IN 80 0 66 1 +SET_CRAFT_OUT 80 222 4 0 +;Ñåìåíà àðáóçà +SET_CRAFT_IN 81 0 176 1 +SET_CRAFT_OUT 81 221 1 0 +;Àðáóç +SET_CRAFT_IN 82 0 176 9 +SET_CRAFT_OUT 82 73 1 1 +;Ñâåòèëüíèê Äæåêà +SET_CRAFT_IN 83 0 66 1 +SET_CRAFT_IN 83 1 26 1 +SET_CRAFT_OUT 83 67 1 0 diff --git a/res/default_font.png b/res/default_font.png new file mode 100644 index 0000000..d2a98b0 Binary files /dev/null and b/res/default_font.png differ diff --git a/res/dl b/res/dl new file mode 100644 index 0000000..3c5828a Binary files /dev/null and b/res/dl differ diff --git a/res/furnace.cfg b/res/furnace.cfg new file mode 100644 index 0000000..cc0065d --- /dev/null +++ b/res/furnace.cfg @@ -0,0 +1,90 @@ +;Ôàéë èíèöèàëèçàöèè îïèñàíèÿ òîïëèâà è ðåöåïòîâ äëÿ ïå÷è + +;Óñòàíàâëèâàåì êîëè÷åñòâî òîïëèâà è ðåöåïòîâ +RESET_FUELS 24 +RESET_RECIPES 15 + +;Îïèñàíèå êîìàíäû óñòàíîâêè òîïëèâà: +;SET_FUEL [id] [item] [time] +;id - èäåíòèôèêàòîð òîïëèâà. +;item - èäåíòèôèêàòîð ïðåäìåòà, êîòîðûé ìîæåò áûòü èñïîëüçîâàí êàê òîïëèâî. +;time - âðåìÿ ãîðåíèÿ òîïëèâà â ìñ(1/1000 ñåêóíäû). + +;Îïèñàíèå êîìàíäû óñòàíîâêè ðåöåïòà: +;SET_RECIPE [id] [in] [out] +;id - èäåíòèôèêàòîð ðåöåïòà. +;in - èäåíòèôèêàòîð ïðåäìåòà èç êîòîðîãî ïðèñõîäèò ïðèãîòîâëåíèå. +;out - èäåíòèôèêàòîð ðåçóëüòèðóþùåãî ïðåäìåòà. + +;======[Òîïëèâî]====== +;Âåäðî ëàâû +SET_FUEL 0 173 1000000 +;Óãîëü +SET_FUEL 1 160 80000 +;Äîñêè +SET_FUEL 2 4 15000 +SET_FUEL 3 94 15000 +;Ñàæåíåö +SET_FUEL 4 52 5000 +SET_FUEL 5 114 5000 +SET_FUEL 6 115 5000 +;Ïàëêà +SET_FUEL 7 127 5000 +;Çàáîð +SET_FUEL 8 92 15000 +SET_FUEL 9 93 15000 +;Ëþê +SET_FUEL 10 107 15000 +SET_FUEL 11 108 15000 +;Äåðåâî +SET_FUEL 12 9 15000 +SET_FUEL 13 75 15000 +SET_FUEL 14 83 15000 +SET_FUEL 15 84 15000 +SET_FUEL 16 85 15000 +SET_FUEL 17 86 15000 +;Âåðñòàê +SET_FUEL 18 29 15000 +;Êíèæíûé øêàô +SET_FUEL 19 11 15000 +;Ñóíäóê +SET_FUEL 20 28 15000 +;Îãðîìíûå ãðèáû +SET_FUEL 21 88 15000 +SET_FUEL 22 89 15000 +SET_FUEL 23 90 15000 +SET_FUEL 24 91 15000 + +;======[Ðåöåïòû]====== +;Ïåñîê -> ñòåêëî +SET_RECIPE 0 7 31 +;Æåëåçíàÿ ðóäà -> æåëåçíûé ñëèòîê +SET_RECIPE 1 17 164 +;Çîëîòàÿ ðóäà -> çîëîòîé ñëèòîê +SET_RECIPE 2 16 165 +;Êîìîê ãëèíû -> êèðïè÷ +SET_RECIPE 3 169 163 +;Ñûðàÿ ñâèíèíà -> æàðåíàÿ ñâèíèíà +SET_RECIPE 4 188 189 +;Áóëûæíèê -> êàìåíü +SET_RECIPE 5 5 3 +;Ñûðàÿ êóðèöà -> æàðåíàÿ êóðèöà +SET_RECIPE 6 203 204 +;Ñûðàÿ ãîâÿäèíà -> æàðåíàÿ ãîâÿäèíà +SET_RECIPE 7 199 200 +;Ñûðàÿ ðûáà -> æàðåíàÿ ðûáà +SET_RECIPE 8 210 211 +;Äåðåâî -> óãîëü +SET_RECIPE 9 9 160 +;Áåð¸çà -> óãîëü +SET_RECIPE 10 83 160 +;Åëü -> óãîëü +SET_RECIPE 11 85 160 +;Óãîëüíàÿ ðóäà -> óãîëü +SET_RECIPE 12 18 160 +;Êðàñíàÿ ðóäà -> êðàñíàÿ ïûëü +SET_RECIPE 13 20 161 +;Ëàçóðèòîâàÿ ðóäà -> óëüòðàìàðèí +SET_RECIPE 14 54 166 +;Àëìàçíàÿ ðóäà -> àëìàç +SET_RECIPE 15 19 162 diff --git a/res/gui/clock.png b/res/gui/clock.png new file mode 100644 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 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 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 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 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 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 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 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 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 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 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 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 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 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 index 0000000..b130bc4 Binary files /dev/null and b/res/inputStream.class differ diff --git a/res/items.cfg b/res/items.cfg new file mode 100644 index 0000000..fa3ab7d --- /dev/null +++ b/res/items.cfg @@ -0,0 +1,607 @@ +;Ôàéë èíèöèàëèçàöèè ñòàíäàðòíîãî íàáîðà ïðåäìåòîâ CaveCraft +;Âñå ïåðå÷èñëåííûå çäåñü ïðåäìåòû ìîãóò îòáðàæàòüñÿ â èíâåíòàðå èãðîêà. + +;Óñòàíàâëèâàåì êîëè÷åñòâî ïðåäìåòîâ +RESET_ITEMS 222 + +;Îïèñàíèå êîìàíäû óñòàíîâêè ïðåäìåòà: +;SET_ITEM [id] [type] [tex] [max] [prt] [flags] +;id - èíäåíòèôèêàòîð ïðåäìåòà. +;type - òèï ïðåäìåòà: +; 0 - áëîê +; 1 - èíñòðóìåíò +; 2 - çàðåçåðâèðîâàíî +; 3 - îáû÷íûé ïðåäìåò +;tex - íîìåð òåêñòóðû, çàâèñèò îò òèïà ïðåäìåòà. +;max - ìàêñèìàëüíîå êîëè÷åñòâî ïðåäìåòîâ â ñòàêå. +;prt - óêàçàòåëü íà ñòðóêòóðó äîïîëíèòåëüíûõ äàííûõ âûáðàíîãî òèïà ïðåäìåòà. +;flags - áèòîâîå ïîëå: +; b0001 - ðèñîâàòü öèôðîâîé èíäèêàòîð +; b0010 - ðèñîâàòü ãðàôè÷åñêèé èíäèêàòîð +; b0100 - ïðåäìåò äåëèìûé +; b1000 - ðèñîâàòü òåêñòóðó èç terrain.png(0)/items.png(1) + + +;======[Áëîêè]====== +;Null +SET_ITEM 0 0 0 0 0 b0000 +;Çåìëÿ +SET_ITEM 1 0 1 64 1 b0101 +;Òðàâà +SET_ITEM 2 0 2 64 2 b0101 +;Êàìåíü +SET_ITEM 3 0 3 64 3 b0101 +;Äîñêè +SET_ITEM 4 0 4 64 4 b0101 +;Áóëûæíèê +SET_ITEM 5 0 5 64 5 b0101 +;Àäìèíèóì +SET_ITEM 6 0 6 64 6 b0101 +;Ïåñîê +SET_ITEM 7 0 7 64 7 b0101 +;Ãðàâèé +SET_ITEM 8 0 8 64 8 b0101 +;Äðåâî +SET_ITEM 9 0 9 64 9 b0101 +;Îáñèäèàí +SET_ITEM 10 0 10 64 10 b0101 +;Êíèæíûé øêàô +SET_ITEM 11 0 11 64 11 b0101 +;Çàìøåëûé áóëûæíèê +SET_ITEM 12 0 12 64 12 b0101 +;Æåëåçíûé áëîê +SET_ITEM 13 0 13 64 13 b0101 +;Çîëîòîé áëîê +SET_ITEM 14 0 14 64 14 b0101 +;Àëìàçíûé áëîê +SET_ITEM 15 0 15 64 15 b0101 +;Çîëîòààÿ ðóäà +SET_ITEM 16 0 16 64 16 b0101 +;Æåëåçíàÿ ðóäà +SET_ITEM 17 0 17 64 17 b0101 +;Óãîëüíàÿ ðóäà +SET_ITEM 18 0 18 64 18 b0101 +;Àëìàçíàÿ ðóäà +SET_ITEM 19 0 19 64 19 b0101 +;Êðàñíàÿ ðóäà +SET_ITEM 20 0 20 64 20 b0101 +;Ëèñòâà +SET_ITEM 21 0 21 64 21 b0101 +;Êðàñíûé öâåòîê +SET_ITEM 22 0 22 64 22 b0101 +;Ƹëòûé öâåòîê +SET_ITEM 23 0 23 64 23 b0101 +;Êðàñíûé ãðèá +SET_ITEM 24 0 24 64 24 b0101 +;Êîðè÷íåâûé ãðèá +SET_ITEM 25 0 25 64 25 b0101 +;Ôàêåë +SET_ITEM 26 0 26 64 26 b0101 +;Äèíàìèò +SET_ITEM 27 0 27 64 27 b0101 +;Ñóíäóê +SET_ITEM 28 0 28 64 28 b0101 +;Âåðñòàê +SET_ITEM 29 0 29 64 29 b0101 +;Êàêòóñ +SET_ITEM 30 0 30 64 30 b0101 +;Ñòåêëî +SET_ITEM 31 0 31 64 31 b0101 +;Øåðñòü +SET_ITEM 32 0 32 64 32 b0101 +SET_ITEM 33 0 33 64 33 b0101 +SET_ITEM 34 0 34 64 34 b0101 +SET_ITEM 35 0 35 64 35 b0101 +SET_ITEM 36 0 36 64 36 b0101 +SET_ITEM 37 0 37 64 37 b0101 +SET_ITEM 38 0 38 64 38 b0101 +SET_ITEM 39 0 39 64 39 b0101 +SET_ITEM 40 0 40 64 40 b0101 +SET_ITEM 41 0 41 64 41 b0101 +SET_ITEM 42 0 42 64 42 b0101 +SET_ITEM 43 0 43 64 43 b0101 +SET_ITEM 44 0 44 64 44 b0101 +SET_ITEM 45 0 45 64 45 b0101 +SET_ITEM 46 0 46 64 46 b0101 +SET_ITEM 47 0 47 64 47 b0101 +;Ñíåã +SET_ITEM 48 0 48 64 48 b0101 +;Ëåñòíèöà +SET_ITEM 49 0 49 64 49 b0101 +;Âîäà +SET_ITEM 50 0 50 64 50 b0101 +;Ëàâà +SET_ITEM 51 0 51 64 51 b0101 +;Ñàæåíåö +SET_ITEM 52 0 60 64 52 b0101 +;Ãóáêà +SET_ITEM 53 0 61 64 53 b0101 +;Ëàçóðèòîâàÿ ðóäà +SET_ITEM 54 0 62 64 54 b0101 +;Ëàçóðèòîâûé áëîê +SET_ITEM 55 0 63 64 55 b0101 +;Ïåñ÷àíèê +SET_ITEM 56 0 64 64 56 b0101 +;Âûñîêàÿ òðàâà +SET_ITEM 57 0 65 64 57 b0101 +;Ñóõîé êóñò +SET_ITEM 58 0 66 64 58 b0101 +;Ïàóòèíà +SET_ITEM 59 0 67 64 59 b0101 +;Êèðïè÷íûé áëîê +SET_ITEM 60 0 68 64 60 b0101 +;Ñíåæíûé áëîê +SET_ITEM 61 0 69 64 61 b0101 +;˸ä +SET_ITEM 62 0 70 64 62 b0101 +;Ñëîé ñíåãà +SET_ITEM 63 0 71 64 63 b0101 +;Ãëèíÿíûé áëîê +SET_ITEM 64 0 72 64 64 b0101 +;Òðîñòíèê +SET_ITEM 65 0 116 64 65 b1101 +;Òûêâà +SET_ITEM 66 0 74 64 66 b0101 +;Ñâåòèëüíèê Äæåêà +SET_ITEM 67 0 75 64 67 b0101 +;Êàìåííûé êèðïè÷ +SET_ITEM 68 0 76 64 68 b0101 +SET_ITEM 69 0 77 64 69 b0101 +SET_ITEM 70 0 78 64 70 b0101 +;Ðåçíîé êèðïè÷ +SET_ITEM 71 0 79 64 71 b0101 +;Æåëåçíàÿ ðåø¸òêà +SET_ITEM 72 0 80 64 72 b0101 +;Àðáóç +SET_ITEM 73 0 81 64 73 b0101 +;Ìèöåëèé +SET_ITEM 74 0 82 64 74 b0101 +;Äåðåâî(ïðîõîäèìîå) +SET_ITEM 75 0 98 64 75 b0101 +;Ñïàóíåð +SET_ITEM 76 0 83 64 76 b0101 +;Êðîâàòü +SET_ITEM 77 0 84 64 77 b0101 +SET_ITEM 78 0 85 64 78 b0101 +;Îòêð. äâåðü +SET_ITEM 79 0 86 64 79 b0101 +SET_ITEM 80 0 102 64 80 b0101 +;Çàêð. äâåðü +SET_ITEM 81 0 88 64 81 b0101 +SET_ITEM 82 0 104 64 82 b0101 +;áåð¸çà +SET_ITEM 83 0 90 64 83 b0101 +SET_ITEM 84 0 99 64 84 b0101 +;Åëü +SET_ITEM 85 0 91 64 85 b0101 +SET_ITEM 86 0 100 64 86 b0101 +;Ëèñòâà åëè +SET_ITEM 87 0 92 64 87 b0101 +;Êðàñíûé îãðîìíûé ãðèá +SET_ITEM 88 0 93 64 88 b0101 +SET_ITEM 89 0 95 64 89 b0101 +;Êîðè÷íåâûé îãðîìíûé ãðèá +SET_ITEM 90 0 94 64 90 b0101 +SET_ITEM 91 0 95 64 91 b0101 +;Çàáîð +SET_ITEM 92 0 96 64 92 b0101 +SET_ITEM 93 0 101 64 93 b0101 +;Äîñêè(ïðîõîäèìûå) +SET_ITEM 94 0 97 64 94 b0101 +;Êàðòèíû +SET_ITEM 95 0 106 1 95 b0101 +SET_ITEM 96 0 107 1 96 b0101 +SET_ITEM 97 0 108 1 97 b0101 +SET_ITEM 98 0 109 1 98 b0101 +SET_ITEM 99 0 110 1 99 b0101 +SET_ITEM 100 0 111 1 100 b0101 +SET_ITEM 101 0 112 1 101 b0101 +;Ëèàíû +SET_ITEM 103 0 114 64 103 b0101 +;Òàáëè÷êà +SET_ITEM 104 0 98 16 104 b1101 +;Êðàñíûé ôàêåë +SET_ITEM 105 0 116 64 105 b0101 +;Ïå÷ü +SET_ITEM 106 0 117 64 106 b0101 +;Ëþê +SET_ITEM 107 0 118 64 107 b0101 +SET_ITEM 108 0 119 64 108 b0101 +;Àäñêèé êàìåíü +SET_ITEM 109 0 120 64 109 b0101 +;Ïîðòàë â àä +SET_ITEM 110 0 129 64 110 b0101 +;Ñâåòÿùèéñÿ êàìåíü +SET_ITEM 111 0 121 64 111 b0101 +;Ëèñòâà(áåð¸çà) +SET_ITEM 112 0 135 64 112 b0101 +;Ïåñîê äóø +SET_ITEM 113 0 122 64 113 b0101 +;Ñàæåíåö(áåð¸çà) +SET_ITEM 114 0 123 64 114 b0101 +;Ñàæåíåö(åëü) +SET_ITEM 115 0 124 64 115 b0101 +;Ëàìïà +SET_ITEM 116 0 125 64 116 b0101 +SET_ITEM 117 0 126 64 117 b0101 +;Îáñèäèàí(ïðîõîäèìûé) +SET_ITEM 118 0 127 64 118 b0101 +;Ñòåêëÿííàÿ ïàíåëü +SET_ITEM 119 0 128 64 119 b0101 +;Ãðÿäêà +SET_ITEM 120 0 136 64 120 b0101 +;Òîðò +SET_ITEM 121 0 137 64 121 b0101 + +;======[Ïðåäìåòû]====== +;Ïàëêà +SET_ITEM 127 3 0 64 0 b1101 +;Ƹëòûé êðàñèòåëü +SET_ITEM 128 3 8 64 0 b1101 +;Êðàñíûé êðàñèòåëü +SET_ITEM 129 3 9 64 0 b1101 + +;"Íóëåâîé" èíñòðóìåíò +SET_ITEM 130 1 0 0 0 b1010 +;Êèðêà +SET_ITEM 131 1 48 60 1 b1010 +SET_ITEM 132 1 49 132 2 b1010 +SET_ITEM 133 1 50 251 3 b1010 +SET_ITEM 134 1 51 1562 4 b1010 +SET_ITEM 135 1 52 33 5 b1010 +;Ëîïàòà +SET_ITEM 136 1 32 60 6 b1010 +SET_ITEM 137 1 33 132 7 b1010 +SET_ITEM 138 1 34 251 8 b1010 +SET_ITEM 139 1 35 1562 9 b1010 +SET_ITEM 140 1 36 33 10 b1010 +;Òîïîð +SET_ITEM 141 1 64 60 11 b1010 +SET_ITEM 142 1 65 132 12 b1010 +SET_ITEM 143 1 66 251 13 b1010 +SET_ITEM 144 1 67 1562 14 b1010 +SET_ITEM 145 1 68 33 15 b1010 +;Íîæíèöû +SET_ITEM 146 1 10 239 16 b1010 +;Ìå÷ +SET_ITEM 147 1 16 60 17 b1010 +SET_ITEM 148 1 17 132 18 b1010 +SET_ITEM 149 1 18 251 19 b1010 +SET_ITEM 150 1 19 1562 20 b1010 +SET_ITEM 151 1 20 33 21 b1010 +;Óäî÷êà +SET_ITEM 152 1 101 65 22 b1010 +;Îãíèâî +SET_ITEM 153 1 106 65 23 b1010 +;Ìîòûãà +SET_ITEM 154 1 80 60 24 b1010 +SET_ITEM 155 1 81 132 25 b1010 +SET_ITEM 156 1 82 251 26 b1010 +SET_ITEM 157 1 83 1562 27 b1010 +SET_ITEM 158 1 84 33 28 b1010 + +;Óãîëü +SET_ITEM 160 3 2 64 0 b1101 +;Êðàñíàÿ ïûëü +SET_ITEM 161 3 7 64 0 b1101 +;Àëìàç +SET_ITEM 162 3 6 64 0 b1101 +;Êèðïè÷ +SET_ITEM 163 3 3 64 0 b1101 +;Æåëåçíûé ñëèòîê +SET_ITEM 164 3 4 64 0 b1101 +;Çîëîòîé ñëèòîê +SET_ITEM 165 3 5 64 0 b1101 +;Óëüòðàìàðèí +SET_ITEM 166 3 11 64 0 b1101 +;Íèòü +SET_ITEM 167 3 12 64 0 b1101 +;Ñíåæîê +SET_ITEM 168 3 13 16 0 b1101 +;Ãëèíà +SET_ITEM 169 3 14 64 0 b1101 +;Êíèãà +SET_ITEM 170 3 15 64 0 b1101 +;Âåäðî +SET_ITEM 171 3 21 1 0 b1101 +;Âåäðî ñ âîäîé +SET_ITEM 172 3 22 1 0 b1101 +;Âåäðî ñ ëàâîé +SET_ITEM 173 3 23 1 0 b1101 +;Âåäðî ñ ìîëîêîì +SET_ITEM 174 3 24 1 0 b1101 +;Áóìàãà +SET_ITEM 175 3 25 64 0 b1101 +;Äîëüêà àðáóçà +SET_ITEM 176 3 26 64 0 b1101 +;ßéöî +SET_ITEM 177 3 27 64 0 b1101 +;Äâåðü +SET_ITEM 178 3 28 64 0 b1101 +;Êðîâàòü +SET_ITEM 179 3 30 64 0 b1101 +;ßéöî ñ çîìáè +SET_ITEM 180 3 37 64 0 b1101 +;ßéöî ñî ñâèíü¸é +SET_ITEM 181 3 38 64 0 b1101 +;ßéöî ñ îâöîé +SET_ITEM 182 3 39 64 0 b1101 +;Ïîðîõ +SET_ITEM 183 3 31 64 0 b1101 +;×àøêà +SET_ITEM 184 3 40 64 0 b1101 +;Òóøåíûå ãðèáû +SET_ITEM 185 3 41 64 0 b1101 +;Êàðòà +SET_ITEM 186 3 53 1 0 b1101 +;Êàðòèíà +SET_ITEM 187 3 54 64 0 b1101 +;Ñûðàÿ ñâèíèíà +SET_ITEM 188 3 55 64 0 b1101 +;Æàðåíàÿ ñâèíèíà +SET_ITEM 189 3 56 64 0 b1101 +;Ãíèëàÿ ïëîòü +SET_ITEM 190 3 57 64 0 b1101 +;Êàìåðà +SET_ITEM 191 3 69 1 0 b1101 +SET_ITEM 192 3 70 1 0 b1101 +SET_ITEM 193 3 71 1 0 b1101 +;Çîëîòîé ñàìîðîäîê +SET_ITEM 194 3 42 64 0 b1101 +;Ñàõàð +SET_ITEM 195 3 58 64 0 b1101 +;Ïàó÷èé ãëàç +SET_ITEM 196 3 74 64 0 b1101 +;Ïåðî +SET_ITEM 197 3 85 64 0 b1101 +;Êîæà +SET_ITEM 198 3 86 64 0 b1101 +;Ñûðàÿ ãîâÿäèíà +SET_ITEM 199 3 87 64 0 b1101 +;Æàðåíàÿ ãîâÿäèíà +SET_ITEM 200 3 88 64 0 b1101 +;ßáëîêî +SET_ITEM 201 3 89 64 0 b1101 +;Çîëîòîå ÿáëîêî +SET_ITEM 202 3 90 64 0 b1101 +;Ñûðàÿ êóðèöà +SET_ITEM 203 3 72 64 0 b1101 +;Æàðåíàÿ êóðèöà +SET_ITEM 204 3 73 64 0 b1101 +;ßéöî ñ êóðèöåé +SET_ITEM 205 3 96 64 0 b1101 +;ßéöî ñ êðèïåðîì +SET_ITEM 206 3 97 64 0 b1101 +;Êðåìåíü +SET_ITEM 207 3 1 64 0 b1101 +;ßéöî ñ êîðîâîé +SET_ITEM 208 3 99 64 0 b1101 +;ßéöî ñ ãðèáíîé êîðîâîé +SET_ITEM 209 3 100 64 0 b1101 +;Ñûðàÿ ðûáà +SET_ITEM 210 3 102 64 0 b1101 +;Æàðåíàÿ ðûáà +SET_ITEM 211 3 103 64 0 b1101 +;ßéöî ñ ñâèíîçîìáè +SET_ITEM 212 3 104 64 0 b1101 +;ßéöî ñ ïàóêîì +SET_ITEM 213 3 105 64 0 b1101 +;Ñâåòîïûëü +SET_ITEM 214 3 107 64 0 b1101 +;×àñû +SET_ITEM 215 3 109 1 0 b1101 +;Êîìïàñ +SET_ITEM 216 3 108 1 0 b1101 +;Ñåìåíà +SET_ITEM 217 3 110 64 0 b1101 +;Ïøåíèöà +SET_ITEM 218 3 111 64 0 b1101 +;Õëåá +SET_ITEM 219 3 112 64 0 b1101 +;Êîñòíàÿ ìóêà +SET_ITEM 220 3 113 64 0 b1101 +;Ñåìåíà àðáóçà +SET_ITEM 221 3 114 64 0 b1101 +;Ñåìåíà òûêâû +SET_ITEM 222 3 115 64 0 b1101 + +;======[Ñïèñîê]====== +SET_MAX_ITEM_LIST 194 + +SET_ITEM_LIST 0 1 +SET_ITEM_LIST 1 2 +SET_ITEM_LIST 2 3 +SET_ITEM_LIST 3 4 +SET_ITEM_LIST 4 5 +SET_ITEM_LIST 5 6 +SET_ITEM_LIST 6 7 +SET_ITEM_LIST 7 8 +SET_ITEM_LIST 8 9 +SET_ITEM_LIST 9 10 +SET_ITEM_LIST 10 11 +SET_ITEM_LIST 11 12 +SET_ITEM_LIST 12 13 +SET_ITEM_LIST 13 14 +SET_ITEM_LIST 14 15 +SET_ITEM_LIST 15 16 +SET_ITEM_LIST 16 17 +SET_ITEM_LIST 17 18 +SET_ITEM_LIST 18 19 +SET_ITEM_LIST 19 20 +SET_ITEM_LIST 20 21 +SET_ITEM_LIST 21 22 +SET_ITEM_LIST 22 23 +SET_ITEM_LIST 23 24 +SET_ITEM_LIST 24 25 +SET_ITEM_LIST 25 26 +SET_ITEM_LIST 26 27 +SET_ITEM_LIST 27 28 +SET_ITEM_LIST 28 29 +SET_ITEM_LIST 29 30 +SET_ITEM_LIST 30 31 +SET_ITEM_LIST 31 32 +SET_ITEM_LIST 32 33 +SET_ITEM_LIST 33 34 +SET_ITEM_LIST 34 35 +SET_ITEM_LIST 35 36 +SET_ITEM_LIST 36 37 +SET_ITEM_LIST 37 38 +SET_ITEM_LIST 38 39 +SET_ITEM_LIST 39 40 +SET_ITEM_LIST 40 41 +SET_ITEM_LIST 41 42 +SET_ITEM_LIST 42 43 +SET_ITEM_LIST 43 44 +SET_ITEM_LIST 44 45 +SET_ITEM_LIST 45 46 +SET_ITEM_LIST 46 47 +SET_ITEM_LIST 47 48 +SET_ITEM_LIST 48 49 +SET_ITEM_LIST 49 50 +SET_ITEM_LIST 50 51 +SET_ITEM_LIST 51 52 +SET_ITEM_LIST 52 53 +SET_ITEM_LIST 53 54 +SET_ITEM_LIST 54 55 +SET_ITEM_LIST 55 56 +SET_ITEM_LIST 56 57 +SET_ITEM_LIST 57 58 +SET_ITEM_LIST 58 59 +SET_ITEM_LIST 59 61 +SET_ITEM_LIST 60 62 +SET_ITEM_LIST 61 64 +SET_ITEM_LIST 62 65 +SET_ITEM_LIST 63 66 +SET_ITEM_LIST 64 67 +SET_ITEM_LIST 65 68 +SET_ITEM_LIST 66 69 +SET_ITEM_LIST 67 70 +SET_ITEM_LIST 68 71 +SET_ITEM_LIST 69 72 +SET_ITEM_LIST 70 73 +SET_ITEM_LIST 71 74 +SET_ITEM_LIST 72 75 +SET_ITEM_LIST 73 76 +SET_ITEM_LIST 74 83 +SET_ITEM_LIST 75 84 +SET_ITEM_LIST 76 85 +SET_ITEM_LIST 77 86 +SET_ITEM_LIST 78 87 +SET_ITEM_LIST 79 88 +SET_ITEM_LIST 80 89 +SET_ITEM_LIST 81 90 +SET_ITEM_LIST 82 91 +SET_ITEM_LIST 83 92 +SET_ITEM_LIST 84 93 +SET_ITEM_LIST 85 94 +SET_ITEM_LIST 86 103 +SET_ITEM_LIST 87 104 +SET_ITEM_LIST 88 105 +SET_ITEM_LIST 89 106 +SET_ITEM_LIST 90 108 +SET_ITEM_LIST 91 109 +SET_ITEM_LIST 92 111 +SET_ITEM_LIST 93 112 +SET_ITEM_LIST 94 113 +SET_ITEM_LIST 95 114 +SET_ITEM_LIST 96 115 +SET_ITEM_LIST 97 116 +SET_ITEM_LIST 98 118 +SET_ITEM_LIST 99 119 +SET_ITEM_LIST 100 121 + +SET_ITEM_LIST 101 127 +SET_ITEM_LIST 102 128 +SET_ITEM_LIST 103 129 +SET_ITEM_LIST 104 131 +SET_ITEM_LIST 105 132 +SET_ITEM_LIST 106 133 +SET_ITEM_LIST 107 134 +SET_ITEM_LIST 108 135 +SET_ITEM_LIST 109 136 +SET_ITEM_LIST 110 137 +SET_ITEM_LIST 111 138 +SET_ITEM_LIST 112 139 +SET_ITEM_LIST 113 140 +SET_ITEM_LIST 114 141 +SET_ITEM_LIST 115 142 +SET_ITEM_LIST 116 143 +SET_ITEM_LIST 117 144 +SET_ITEM_LIST 118 145 +SET_ITEM_LIST 119 146 +SET_ITEM_LIST 120 147 +SET_ITEM_LIST 121 148 +SET_ITEM_LIST 122 149 +SET_ITEM_LIST 123 150 +SET_ITEM_LIST 124 151 +SET_ITEM_LIST 125 152 +SET_ITEM_LIST 126 153 +SET_ITEM_LIST 127 154 +SET_ITEM_LIST 128 155 +SET_ITEM_LIST 129 156 +SET_ITEM_LIST 130 157 +SET_ITEM_LIST 131 158 + +SET_ITEM_LIST 132 160 +SET_ITEM_LIST 133 161 +SET_ITEM_LIST 134 162 +SET_ITEM_LIST 135 163 +SET_ITEM_LIST 136 164 +SET_ITEM_LIST 137 165 +SET_ITEM_LIST 138 166 +SET_ITEM_LIST 139 167 +SET_ITEM_LIST 140 168 +SET_ITEM_LIST 141 169 +SET_ITEM_LIST 142 170 +SET_ITEM_LIST 143 171 +SET_ITEM_LIST 144 172 +SET_ITEM_LIST 145 173 +SET_ITEM_LIST 146 174 +SET_ITEM_LIST 147 175 +SET_ITEM_LIST 148 176 +SET_ITEM_LIST 149 177 +SET_ITEM_LIST 150 178 +SET_ITEM_LIST 151 179 +SET_ITEM_LIST 152 180 +SET_ITEM_LIST 153 181 +SET_ITEM_LIST 154 182 +SET_ITEM_LIST 155 183 +SET_ITEM_LIST 156 184 +SET_ITEM_LIST 157 185 +SET_ITEM_LIST 158 186 +SET_ITEM_LIST 159 187 +SET_ITEM_LIST 160 188 +SET_ITEM_LIST 161 189 +SET_ITEM_LIST 162 190 +SET_ITEM_LIST 163 191 +SET_ITEM_LIST 164 192 +SET_ITEM_LIST 165 193 +SET_ITEM_LIST 166 194 +SET_ITEM_LIST 167 195 +SET_ITEM_LIST 168 196 +SET_ITEM_LIST 169 197 +SET_ITEM_LIST 170 198 +SET_ITEM_LIST 171 199 +SET_ITEM_LIST 172 200 +SET_ITEM_LIST 173 201 +SET_ITEM_LIST 174 202 +SET_ITEM_LIST 175 203 +SET_ITEM_LIST 176 204 +SET_ITEM_LIST 177 205 +SET_ITEM_LIST 178 206 +SET_ITEM_LIST 179 207 +SET_ITEM_LIST 180 208 +SET_ITEM_LIST 181 209 +SET_ITEM_LIST 182 210 +SET_ITEM_LIST 183 211 +SET_ITEM_LIST 184 212 +SET_ITEM_LIST 185 213 +SET_ITEM_LIST 186 214 +SET_ITEM_LIST 187 215 +SET_ITEM_LIST 188 216 +SET_ITEM_LIST 189 217 +SET_ITEM_LIST 190 218 +SET_ITEM_LIST 191 219 +SET_ITEM_LIST 192 220 +SET_ITEM_LIST 193 221 +SET_ITEM_LIST 194 222 diff --git a/res/keyboard.cfg b/res/keyboard.cfg new file mode 100644 index 0000000..458963e --- /dev/null +++ b/res/keyboard.cfg @@ -0,0 +1,75 @@ +;Èíèöèàëèçàöèÿ êëàâèàòóðû +;BIND_KEY [type] [keycode1] [keycode2] [keycode3] [keycode4] +;type - äåéñòâèå êëàâèøè: +; KEY_FM_UP=0; +; KEY_FM_DOWN=1; +; KEY_FM_SELECT=2; +; +; KEY_MENU_UP=3; +; KEY_MENU_DOWN=4; +; KEY_MENU_LEFT=5; +; KEY_MENU_RIGHT=6; +; KEY_MENU_SELECT=7; +; +; KEY_FASTINV_PREV=8; +; KEY_FASTINV_NEXT=9; +; +; KEY_CHAT=10; +; +; KEY_PLR_OPENINV=11; +; KEY_PLR_EDITMODE=12; +; KEY_PLR_USE=13; +; KEY_PLR_ATTACK=14; +; +; KEY_PLR_UP=15; +; KEY_PLR_DOWN=16; +; KEY_PLR_LEFT=17; +; KEY_PLR_RIGHT=18; +; +; KEY_MENU=19; +; +; KEY_WIN_UP=20; +; KEY_WIN_DOWN=21; +; KEY_WIN_LEFT=22; +; KEY_WIN_RIGHT=23; +; KEY_WIN_SELECT=24; +; KEY_WIN_ALT=25; +; KEY_WIN_DROP=26; +; KEY_WIN_EXIT=27; +;keycodeN - êîä êëàâèøè + +BIND_KEY 0 -1 50 0 0 +BIND_KEY 1 -2 56 0 0 +BIND_KEY 2 -5 53 0 0 + +BIND_KEY 3 -1 50 0 0 +BIND_KEY 4 -2 56 0 0 +BIND_KEY 5 -3 52 0 0 +BIND_KEY 6 -4 54 0 0 +BIND_KEY 7 -5 53 0 0 + +BIND_KEY 8 -6 35 0 0 +BIND_KEY 9 -7 42 0 0 + +BIND_KEY 10 55 0 0 0 + +BIND_KEY 11 49 0 0 0 +BIND_KEY 12 48 0 0 0 +BIND_KEY 13 51 0 0 0 +BIND_KEY 14 -5 53 0 0 + +BIND_KEY 15 -1 50 0 0 +BIND_KEY 16 -2 56 0 0 +BIND_KEY 17 -3 52 0 0 +BIND_KEY 18 -4 54 0 0 + +BIND_KEY 19 57 0 0 0 + +BIND_KEY 20 -1 50 0 0 +BIND_KEY 21 -2 56 0 0 +BIND_KEY 22 -3 52 0 0 +BIND_KEY 23 -4 54 0 0 +BIND_KEY 24 -5 53 0 0 +BIND_KEY 25 49 0 0 0 +BIND_KEY 26 51 0 0 0 +BIND_KEY 27 57 0 0 0 diff --git a/res/maps.png b/res/maps.png new file mode 100644 index 0000000..e2bc8a1 Binary files /dev/null and b/res/maps.png differ diff --git a/res/mobs/char_ani.png b/res/mobs/char_ani.png new file mode 100644 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 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 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 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 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 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 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 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 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 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 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 new file mode 100644 index 0000000..e2bc8a1 Binary files /dev/null and b/res/pack.png differ diff --git a/res/terrain.png b/res/terrain.png new file mode 100644 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 index 0000000..85cccda Binary files /dev/null and b/res/terrain/sun.png differ diff --git a/res/textures.cfg b/res/textures.cfg new file mode 100644 index 0000000..b211ca2 --- /dev/null +++ b/res/textures.cfg @@ -0,0 +1,291 @@ +;Èíèöàëèçàöèÿ òåêñòóð áëîêîâ è ïðåäìåòîâ + +;Óñòàíàâëèâàåì êîëè÷åñòâî çàãðóæàåìûõ òåêñòóð +RESET_ITEMS_TEX 116 +RESET_BLOCKS_TEX 143 + +;SET_CANV_TEX [type] [id] [x] [y] [w] [h] + +LOAD_TEX terrain.png +SET_CANV_TEX BLOCK 0 0 0 16 16 +SET_CANV_TEX BLOCK 1 16 0 16 16 +SET_CANV_TEX BLOCK 2 32 0 16 16 +SET_CANV_TEX BLOCK 3 48 0 16 16 +SET_CANV_TEX BLOCK 4 64 0 16 16 +SET_CANV_TEX BLOCK 5 80 0 16 16 +SET_CANV_TEX BLOCK 6 96 0 16 16 +SET_CANV_TEX BLOCK 7 112 0 16 16 +SET_CANV_TEX BLOCK 8 128 0 16 16 +SET_CANV_TEX BLOCK 9 144 0 16 16 +SET_CANV_TEX BLOCK 10 160 0 16 16 +SET_CANV_TEX BLOCK 11 176 0 16 16 +SET_CANV_TEX BLOCK 12 192 0 16 16 +SET_CANV_TEX BLOCK 13 208 0 16 16 +SET_CANV_TEX BLOCK 14 224 0 16 16 +SET_CANV_TEX BLOCK 15 240 0 16 16 + +SET_CANV_TEX BLOCK 16 0 16 16 16 +SET_CANV_TEX BLOCK 17 16 16 16 16 +SET_CANV_TEX BLOCK 18 32 16 16 16 +SET_CANV_TEX BLOCK 19 48 16 16 16 +SET_CANV_TEX BLOCK 20 64 16 16 16 +SET_CANV_TEX BLOCK 21 80 16 16 16 +SET_CANV_TEX BLOCK 22 96 16 16 16 +SET_CANV_TEX BLOCK 23 112 16 16 16 +SET_CANV_TEX BLOCK 24 128 16 16 16 +SET_CANV_TEX BLOCK 25 144 16 16 16 +SET_CANV_TEX BLOCK 26 160 16 16 16 +SET_CANV_TEX BLOCK 27 176 16 16 16 +SET_CANV_TEX BLOCK 28 192 16 16 16 +SET_CANV_TEX BLOCK 29 208 16 16 16 +SET_CANV_TEX BLOCK 30 224 16 16 16 +SET_CANV_TEX BLOCK 31 240 16 16 16 + +SET_CANV_TEX BLOCK 32 0 32 16 16 +SET_CANV_TEX BLOCK 33 16 32 16 16 +SET_CANV_TEX BLOCK 34 32 32 16 16 +SET_CANV_TEX BLOCK 35 48 32 16 16 +SET_CANV_TEX BLOCK 36 64 32 16 16 +SET_CANV_TEX BLOCK 37 80 32 16 16 +SET_CANV_TEX BLOCK 38 96 32 16 16 +SET_CANV_TEX BLOCK 39 112 32 16 16 +SET_CANV_TEX BLOCK 40 128 32 16 16 +SET_CANV_TEX BLOCK 41 144 32 16 16 +SET_CANV_TEX BLOCK 42 160 32 16 16 +SET_CANV_TEX BLOCK 43 176 32 16 16 +SET_CANV_TEX BLOCK 44 192 32 16 16 +SET_CANV_TEX BLOCK 45 208 32 16 16 +SET_CANV_TEX BLOCK 46 224 32 16 16 +SET_CANV_TEX BLOCK 47 240 32 16 16 + +SET_CANV_TEX BLOCK 48 0 48 16 16 +SET_CANV_TEX BLOCK 49 16 48 16 16 +SET_CANV_TEX BLOCK 50 32 48 16 16 +SET_CANV_TEX BLOCK 51 48 48 16 16 +SET_CANV_TEX BLOCK 52 64 48 16 16 +SET_CANV_TEX BLOCK 53 80 48 16 16 +SET_CANV_TEX BLOCK 54 96 48 16 16 +SET_CANV_TEX BLOCK 55 112 48 16 16 +SET_CANV_TEX BLOCK 56 128 48 16 16 +SET_CANV_TEX BLOCK 57 144 48 16 16 +SET_CANV_TEX BLOCK 58 160 48 16 16 +SET_CANV_TEX BLOCK 59 176 48 16 16 +SET_CANV_TEX BLOCK 60 192 48 16 16 +SET_CANV_TEX BLOCK 61 208 48 16 16 +SET_CANV_TEX BLOCK 62 224 48 16 16 +SET_CANV_TEX BLOCK 63 240 48 16 16 + +SET_CANV_TEX BLOCK 64 0 64 16 16 +SET_CANV_TEX BLOCK 65 16 64 16 16 +SET_CANV_TEX BLOCK 66 32 64 16 16 +SET_CANV_TEX BLOCK 67 48 64 16 16 +SET_CANV_TEX BLOCK 68 64 64 16 16 +SET_CANV_TEX BLOCK 69 80 64 16 16 +SET_CANV_TEX BLOCK 70 96 64 16 16 +SET_CANV_TEX BLOCK 71 112 64 16 16 +SET_CANV_TEX BLOCK 72 128 64 16 16 +SET_CANV_TEX BLOCK 73 144 64 16 16 +SET_CANV_TEX BLOCK 74 160 64 16 16 +SET_CANV_TEX BLOCK 75 176 64 16 16 +SET_CANV_TEX BLOCK 76 192 64 16 16 +SET_CANV_TEX BLOCK 77 208 64 16 16 +SET_CANV_TEX BLOCK 78 224 64 16 16 +SET_CANV_TEX BLOCK 79 240 64 16 16 + +SET_CANV_TEX BLOCK 80 0 80 16 16 +SET_CANV_TEX BLOCK 81 16 80 16 16 +SET_CANV_TEX BLOCK 82 32 80 16 16 +SET_CANV_TEX BLOCK 83 48 80 16 16 +SET_CANV_TEX BLOCK 84 64 80 16 16 +SET_CANV_TEX BLOCK 85 80 80 16 16 +SET_CANV_TEX BLOCK 86 96 80 16 16 +SET_CANV_TEX BLOCK 87 112 80 16 16 +SET_CANV_TEX BLOCK 88 128 80 16 16 +SET_CANV_TEX BLOCK 89 144 80 16 16 +SET_CANV_TEX BLOCK 90 160 80 16 16 +SET_CANV_TEX BLOCK 91 176 80 16 16 +SET_CANV_TEX BLOCK 92 192 80 16 16 +SET_CANV_TEX BLOCK 93 208 80 16 16 +SET_CANV_TEX BLOCK 94 224 80 16 16 +SET_CANV_TEX BLOCK 95 240 80 16 16 + +SET_CANV_TEX BLOCK 96 0 96 16 16 +SET_CANV_TEX BLOCK 97 16 96 16 16 +SET_CANV_TEX BLOCK 98 32 96 16 16 +SET_CANV_TEX BLOCK 99 48 96 16 16 +SET_CANV_TEX BLOCK 100 64 96 16 16 +SET_CANV_TEX BLOCK 101 80 96 16 16 +SET_CANV_TEX BLOCK 102 96 96 16 16 +SET_CANV_TEX BLOCK 103 112 96 16 16 +SET_CANV_TEX BLOCK 104 128 96 16 16 +SET_CANV_TEX BLOCK 105 144 96 16 16 +SET_CANV_TEX BLOCK 106 160 96 16 16 +SET_CANV_TEX BLOCK 107 176 96 16 16 +SET_CANV_TEX BLOCK 108 192 96 16 16 +SET_CANV_TEX BLOCK 109 208 96 16 16 +SET_CANV_TEX BLOCK 110 224 96 16 16 +SET_CANV_TEX BLOCK 111 240 96 16 16 + +SET_CANV_TEX BLOCK 112 0 112 16 16 +SET_CANV_TEX BLOCK 113 16 112 16 16 +SET_CANV_TEX BLOCK 114 32 112 16 16 +SET_CANV_TEX BLOCK 115 48 112 16 16 +SET_CANV_TEX BLOCK 116 64 112 16 16 +SET_CANV_TEX BLOCK 117 80 112 16 16 +SET_CANV_TEX BLOCK 118 96 112 16 16 +SET_CANV_TEX BLOCK 119 112 112 16 16 +SET_CANV_TEX BLOCK 120 128 112 16 16 +SET_CANV_TEX BLOCK 121 144 112 16 16 +SET_CANV_TEX BLOCK 122 160 112 16 16 +SET_CANV_TEX BLOCK 123 176 112 16 16 +SET_CANV_TEX BLOCK 124 192 112 16 16 +SET_CANV_TEX BLOCK 125 208 112 16 16 +SET_CANV_TEX BLOCK 126 224 112 16 16 +SET_CANV_TEX BLOCK 127 240 112 16 16 + +SET_CANV_TEX BLOCK 128 0 128 16 16 +SET_CANV_TEX BLOCK 129 16 128 16 16 +SET_CANV_TEX BLOCK 130 32 128 16 16 +SET_CANV_TEX BLOCK 131 48 128 16 16 +SET_CANV_TEX BLOCK 132 64 128 16 16 +SET_CANV_TEX BLOCK 133 80 128 16 16 +SET_CANV_TEX BLOCK 134 96 128 16 16 +SET_CANV_TEX BLOCK 135 112 128 16 16 +SET_CANV_TEX BLOCK 136 128 128 16 16 +SET_CANV_TEX BLOCK 137 144 128 16 16 +SET_CANV_TEX BLOCK 138 160 128 16 16 +SET_CANV_TEX BLOCK 139 176 128 16 16 +SET_CANV_TEX BLOCK 140 192 128 16 16 +SET_CANV_TEX BLOCK 141 208 128 16 16 +SET_CANV_TEX BLOCK 142 224 128 16 16 +SET_CANV_TEX BLOCK 143 240 128 16 16 + + +LOAD_TEX gui/items.png + +SET_CANV_TEX ITEM 0 0 0 16 16 +SET_CANV_TEX ITEM 1 16 0 16 16 +SET_CANV_TEX ITEM 2 32 0 16 16 +SET_CANV_TEX ITEM 3 48 0 16 16 +SET_CANV_TEX ITEM 4 64 0 16 16 +SET_CANV_TEX ITEM 5 80 0 16 16 +SET_CANV_TEX ITEM 6 96 0 16 16 +SET_CANV_TEX ITEM 7 112 0 16 16 +SET_CANV_TEX ITEM 8 128 0 16 16 +SET_CANV_TEX ITEM 9 144 0 16 16 +SET_CANV_TEX ITEM 10 160 0 16 16 +SET_CANV_TEX ITEM 11 176 0 16 16 +SET_CANV_TEX ITEM 12 192 0 16 16 +SET_CANV_TEX ITEM 13 208 0 16 16 +SET_CANV_TEX ITEM 14 224 0 16 16 +SET_CANV_TEX ITEM 15 240 0 16 16 + +SET_CANV_TEX ITEM 16 0 16 16 16 +SET_CANV_TEX ITEM 17 16 16 16 16 +SET_CANV_TEX ITEM 18 32 16 16 16 +SET_CANV_TEX ITEM 19 48 16 16 16 +SET_CANV_TEX ITEM 20 64 16 16 16 +SET_CANV_TEX ITEM 21 80 16 16 16 +SET_CANV_TEX ITEM 22 96 16 16 16 +SET_CANV_TEX ITEM 23 112 16 16 16 +SET_CANV_TEX ITEM 24 128 16 16 16 +SET_CANV_TEX ITEM 25 144 16 16 16 +SET_CANV_TEX ITEM 26 160 16 16 16 +SET_CANV_TEX ITEM 27 176 16 16 16 +SET_CANV_TEX ITEM 28 192 16 16 16 +SET_CANV_TEX ITEM 29 208 16 16 16 +SET_CANV_TEX ITEM 30 224 16 16 16 +SET_CANV_TEX ITEM 31 240 16 16 16 + +SET_CANV_TEX ITEM 32 0 32 16 16 +SET_CANV_TEX ITEM 33 16 32 16 16 +SET_CANV_TEX ITEM 34 32 32 16 16 +SET_CANV_TEX ITEM 35 48 32 16 16 +SET_CANV_TEX ITEM 36 64 32 16 16 +SET_CANV_TEX ITEM 37 80 32 16 16 +SET_CANV_TEX ITEM 38 96 32 16 16 +SET_CANV_TEX ITEM 39 112 32 16 16 +SET_CANV_TEX ITEM 40 128 32 16 16 +SET_CANV_TEX ITEM 41 144 32 16 16 +SET_CANV_TEX ITEM 42 160 32 16 16 +SET_CANV_TEX ITEM 43 176 32 16 16 +SET_CANV_TEX ITEM 44 192 32 16 16 +SET_CANV_TEX ITEM 45 208 32 16 16 +SET_CANV_TEX ITEM 46 224 32 16 16 +SET_CANV_TEX ITEM 47 240 32 16 16 + +SET_CANV_TEX ITEM 48 0 48 16 16 +SET_CANV_TEX ITEM 49 16 48 16 16 +SET_CANV_TEX ITEM 50 32 48 16 16 +SET_CANV_TEX ITEM 51 48 48 16 16 +SET_CANV_TEX ITEM 52 64 48 16 16 +SET_CANV_TEX ITEM 53 80 48 16 16 +SET_CANV_TEX ITEM 54 96 48 16 16 +SET_CANV_TEX ITEM 55 112 48 16 16 +SET_CANV_TEX ITEM 56 128 48 16 16 +SET_CANV_TEX ITEM 57 144 48 16 16 +SET_CANV_TEX ITEM 58 160 48 16 16 +SET_CANV_TEX ITEM 59 176 48 16 16 +SET_CANV_TEX ITEM 60 192 48 16 16 +SET_CANV_TEX ITEM 61 208 48 16 16 +SET_CANV_TEX ITEM 62 224 48 16 16 +SET_CANV_TEX ITEM 63 240 48 16 16 + +SET_CANV_TEX ITEM 64 0 64 16 16 +SET_CANV_TEX ITEM 65 16 64 16 16 +SET_CANV_TEX ITEM 66 32 64 16 16 +SET_CANV_TEX ITEM 67 48 64 16 16 +SET_CANV_TEX ITEM 68 64 64 16 16 +SET_CANV_TEX ITEM 69 80 64 16 16 +SET_CANV_TEX ITEM 70 96 64 16 16 +SET_CANV_TEX ITEM 71 112 64 16 16 +SET_CANV_TEX ITEM 72 128 64 16 16 +SET_CANV_TEX ITEM 73 144 64 16 16 +SET_CANV_TEX ITEM 74 160 64 16 16 +SET_CANV_TEX ITEM 75 176 64 16 16 +SET_CANV_TEX ITEM 76 192 64 16 16 +SET_CANV_TEX ITEM 77 208 64 16 16 +SET_CANV_TEX ITEM 78 224 64 16 16 +SET_CANV_TEX ITEM 79 240 64 16 16 + +SET_CANV_TEX ITEM 80 0 80 16 16 +SET_CANV_TEX ITEM 81 16 80 16 16 +SET_CANV_TEX ITEM 82 32 80 16 16 +SET_CANV_TEX ITEM 83 48 80 16 16 +SET_CANV_TEX ITEM 84 64 80 16 16 +SET_CANV_TEX ITEM 85 80 80 16 16 +SET_CANV_TEX ITEM 86 96 80 16 16 +SET_CANV_TEX ITEM 87 112 80 16 16 +SET_CANV_TEX ITEM 88 128 80 16 16 +SET_CANV_TEX ITEM 89 144 80 16 16 +SET_CANV_TEX ITEM 90 160 80 16 16 +SET_CANV_TEX ITEM 91 176 80 16 16 +SET_CANV_TEX ITEM 92 192 80 16 16 +SET_CANV_TEX ITEM 93 208 80 16 16 +SET_CANV_TEX ITEM 94 224 80 16 16 +SET_CANV_TEX ITEM 95 240 80 16 16 + +SET_CANV_TEX ITEM 96 0 96 16 16 +SET_CANV_TEX ITEM 97 16 96 16 16 +SET_CANV_TEX ITEM 98 32 96 16 16 +SET_CANV_TEX ITEM 99 48 96 16 16 +SET_CANV_TEX ITEM 100 64 96 16 16 +SET_CANV_TEX ITEM 101 80 96 16 16 +SET_CANV_TEX ITEM 102 96 96 16 16 +SET_CANV_TEX ITEM 103 112 96 16 16 +SET_CANV_TEX ITEM 104 128 96 16 16 +SET_CANV_TEX ITEM 105 144 96 16 16 +SET_CANV_TEX ITEM 106 160 96 16 16 +SET_CANV_TEX ITEM 107 176 96 16 16 +SET_CANV_TEX ITEM 108 192 96 16 16 +SET_CANV_TEX ITEM 109 208 96 16 16 +SET_CANV_TEX ITEM 110 224 96 16 16 +SET_CANV_TEX ITEM 111 240 96 16 16 + +SET_CANV_TEX ITEM 112 0 112 16 16 +SET_CANV_TEX ITEM 113 16 112 16 16 +SET_CANV_TEX ITEM 114 32 112 16 16 +SET_CANV_TEX ITEM 115 48 112 16 16 +SET_CANV_TEX ITEM 116 64 112 16 16 + +RESET_TEX diff --git a/res/title/background.png b/res/title/background.png new file mode 100644 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 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 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 new file mode 100644 index 0000000..8188470 --- /dev/null +++ b/res/title/splashes.txt @@ -0,0 +1,41 @@ +38 +It's a begin... +TEST +It's been a long time... +CORE! +Kernel panic: Fatal exception +DeaDSoftWare +02:14AM 29 August 1997 +DeaDDooMER +4815162342 +07.06.1997 +Almost open source! +32768 blocks. +Also try Minecraft! +Knee-deep in the dead! +DeaDSoftWare.Ru +Keep calm and play CaveCraft +Also try DooM 2D! +Made in USSR! +Only singleplayer! +Touch Screen compatible! +It's free! +Enjoy +CaveCraft.3dn.ru +Random splash! +Hello Notch! +20 GOTO 10! +LOL! +MOV AX, 0B800h; +Must have! +Jeb_ HOPKOMAH! +The cake is not a lie! +Made on MidletPascal! +Hell Machine of Dr. DooM! +New free bugs! +SoftWare is DeaD! +Have fun! +It's BETA! +At least 20% cooler! +Also try Galaxian: New Dimension! +§DPinkie watching for you! diff --git a/res/tools.cfg b/res/tools.cfg new file mode 100644 index 0000000..c19f962 --- /dev/null +++ b/res/tools.cfg @@ -0,0 +1,51 @@ +;Ôàéë èíèöèàëèçàöèè îïèñàíèÿ ñâîéñòâ ñòàíäàðòíîãî íàáîðà èíñòðóìåíòîâ CaveCraft + +;Óñòàíàâëèâàåì êîëè÷åñòâî èíñòðóìåíòîâ +RESET_TOOLS 28 + +;Îïèñàíèå êîìàíäû óñòàíîâêè èíñòðóìåíòà: +;SET_TOOL [id] [tool] [lvl] [speed] [damg] +;id - èäåíòèôèêàòîð èíñòðóìåíòà. +;tool - òèï èíñòðóìåíòà. +;lvl - óðîâåíü èíñòðóìåíòà. +;speed - ñêîðîñòü èíñòðóìåíòà. +;damg - óðîí íàíîñèìûé èíñòðóìåíòîì. + +;Null +SET_TOOL 0 0 0 0 1 +;Êèðêè +SET_TOOL 1 1 1 2 1 +SET_TOOL 2 1 2 3 1 +SET_TOOL 3 1 3 4 1 +SET_TOOL 4 1 5 6 1 +SET_TOOL 5 1 4 6 1 +;Ëîïàòû +SET_TOOL 6 2 1 2 1 +SET_TOOL 7 2 2 3 1 +SET_TOOL 8 2 3 4 1 +SET_TOOL 9 2 5 6 1 +SET_TOOL 10 2 4 6 1 +;Òîïîðû +SET_TOOL 11 3 1 2 1 +SET_TOOL 12 3 2 3 1 +SET_TOOL 13 3 3 4 1 +SET_TOOL 14 3 5 6 1 +SET_TOOL 15 3 4 6 1 +;Íîæíèöû +SET_TOOL 16 4 1 5 1 +;Ìå÷è +SET_TOOL 17 5 1 2 4 +SET_TOOL 18 5 2 3 5 +SET_TOOL 19 5 3 4 6 +SET_TOOL 20 5 5 6 7 +SET_TOOL 21 5 4 6 4 +;Óäî÷êà +SET_TOOL 22 0 0 0 1 +;Îãíèâî +SET_TOOL 23 0 0 0 1 +;Ìîòûãè +SET_TOOL 24 6 1 2 1 +SET_TOOL 25 6 2 3 1 +SET_TOOL 26 6 3 4 1 +SET_TOOL 27 6 5 6 1 +SET_TOOL 28 6 4 6 1 \ No newline at end of file diff --git a/res/vkeyboard.cfg b/res/vkeyboard.cfg new file mode 100644 index 0000000..6dc7150 --- /dev/null +++ b/res/vkeyboard.cfg @@ -0,0 +1,112 @@ +MAX_VKEYS 11 + +LOAD_TEX gui/touch.png +SET_CANV_TEX VKEY 0 32 96 32 32 +SET_CANV_TEX VKEY 1 0 0 32 32 +SET_CANV_TEX VKEY 2 32 0 32 32 +SET_CANV_TEX VKEY 3 64 0 32 32 +SET_CANV_TEX VKEY 4 0 32 32 32 +SET_CANV_TEX VKEY 5 32 32 32 32 +SET_CANV_TEX VKEY 6 64 32 32 32 +SET_CANV_TEX VKEY 7 0 64 32 32 +SET_CANV_TEX VKEY 8 32 64 32 32 +SET_CANV_TEX VKEY 9 64 64 32 32 +SET_CANV_TEX VKEY 10 0 96 32 32 +SET_CANV_TEX VKEY 11 64 96 32 32 + +RESET_TEX + +;SET_VKEY [id] [keycode] [x] [y] +STACK 2 + +;NUM 0 +;y:=getHeight-32 +PUSH $SCREEN_H +PUSH 32 +SUB +;x:=getWidth-64 +PUSH $SCREEN_W +PUSH 64 +SUB +SET_VKEY 0 48 POP POP + +;NUM 1 +PUSH $SCREEN_H +PUSH 96 +SUB +PUSH $SCREEN_W +PUSH 32 +SUB +SET_VKEY 1 49 POP POP + +;NUM 2 +PUSH $SCREEN_H +PUSH 96 +SUB +SET_VKEY 2 50 32 POP + +;NUM 3 +PUSH $SCREEN_H +PUSH 96 +SUB +PUSH $SCREEN_W +PUSH 64 +SUB +SET_VKEY 3 51 POP POP + +;NUM 4 +PUSH $SCREEN_H +PUSH 64 +SUB +SET_VKEY 4 52 0 POP + +;NUM 5 +PUSH $SCREEN_H +PUSH 96 +SUB +PUSH $SCREEN_W +PUSH 96 +SUB +SET_VKEY 5 53 POP POP + +;NUM 6 +PUSH $SCREEN_H +PUSH 64 +SUB +SET_VKEY 6 54 64 POP + +;NUM 7 +PUSH $SCREEN_H +PUSH 32 +SUB +PUSH $SCREEN_W +PUSH 32 +SUB +SET_VKEY 7 55 POP POP + +;NUM 8 +PUSH $SCREEN_H +PUSH 32 +SUB +SET_VKEY 8 56 32 POP + +;NUM 9 +PUSH $SCREEN_H +PUSH 32 +SUB +PUSH $SCREEN_W +PUSH 96 +SUB +SET_VKEY 9 57 POP POP + +;NUM * +SET_VKEY 10 42 0 0 + +;NUM # +PUSH $SCREEN_W +PUSH 32 +SUB +SET_VKEY 11 35 POP 0 + +STACK -1 + diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc new file mode 100644 index 0000000..ccdef84 --- /dev/null +++ b/src/CAVE.mpsrc @@ -0,0 +1,3092 @@ +program CAVE; + +uses + sign, + jsr75i, + drop, + invui, + vars, + particles_store, + randoms, + memory, + worldgen, + canvas, + items, + safeload, + mob, + console, + effects, + particles, + keyboard, + maps, + phy, + utils, + func, + CellUI, + furnace, + player, + items_logic, + chest, + inv, + items_store, + video; + +const + version='BETA 9'; + version_map=8; + +var + keymode,updx,updy:integer; + seed,nextseed:integer; + free_ram:real; + + light:array [0..15] of image; + bg:array[0..1] of image; + osad:array [0..1,0..7] of image; + back:array [0..8] of image; + gui:array [0..34] of image; + tue:array [0..9] of image; + + sign_im:image; + sky:image; + sun:image; + moon:image; + moon_phase:integer; + toolus,toolind:integer; + osadki_ani:integer; + sd,sav_fl:string; + global_light:integer; + world_typ:integer; + float:image; + + msg:array [0..4] of string; + msg_time:array[0..4] of integer; + last_sleep_x,last_sleep_y:integer; + + ifminimap:boolean; + gt:integer; + + del,dt,time:integer; + + deb:boolean; + +procedure newworld; + var + ix,iy:integer; + begin + if nextseed=0 then seed:=getrelativetimems; else seed:=nextseed; + nextseed:=0; + srand(seed); + if world_typ=0 then genworld; + else + if world_typ=1 then genflat; + world_typ:=0; + player.setX(get_spawn_x*16+4); + player.setY(get_spawn_y*16); + pl_world:=0; + end; + +procedure drwrect(x,y,w,h,t:integer); + var + i:integer; + begin + for i:=0 to t do + drawrect(x+i,y+i,w-i*2,h-i*2); + end; + +procedure proc_fps; + begin + dt:=GetRelativeTimeMs - time; + time:=GetRelativeTimeMs; + fps:=1000/dt; + end; + +procedure maxfps; + begin + if fps0 then del:=del-1; + if fps>s_max_fps then if del<200 then del:=del+1; + delay(del); + end; + +procedure cleartextures; + var + no:image; + ix,iy,iz:integer; + begin + bg[0]:=no; + bg[1]:=no; + float:=no; + compas:=no; + for ix:=0 to 7 do clock[ix]:=no; + + {for ix:=0 to maxBlockTex do + begin + tex[ix]:=no; + tex8[ix]:=no; + end; + for ix:=0 to maxItemTex do + begin + item[ix]:=no; + item8[ix]:=no; + end;} + for ix:=0 to 8 do back[ix]:=no; + + player.freeSkin; + + for ix:=0 to 34 do + gui[ix]:=no; + + for ix:=0 to 9 do tue[ix]:=no; + + for ix:=0 to 7 do osad[0,ix]:=no; + for ix:=0 to 7 do osad[1,ix]:=no; + + for ix:=0 to 15 do light[ix]:=no; + + for ix:=0 to 7 do + begin + pr_1[ix]:=no; + pr_2[ix]:=no; + pr_3[ix]:=no; + pr_4[ix]:=no; + pr_5[ix]:=no; + end; + bubble:=no; + + for ix:=0 to 15 do + pr_boom[ix]:=no; + + mob.freeSkin; + + sky:=no; + + sun:=no; + moon:=no; + + sign_im:=no; + + for ix:=0 to CONST_MAX_CURS do + LoadCurImg(no, ix); + + //resetVirtualKeyboard(-1); + end; + +procedure create_msg(s:string); + var + i,t:integer; + begin + for i:=3 downto 0 do + begin + if i=0 then break; + msg_time[i]:=msg_time[i-1]; + msg[i]:=msg[i-1]; + end; + msg_time[0]:=getrelativetimems; + msg[0]:=s; + end; + +procedure loadtexture(path:string); + var + ix,iy,iz:integer; + im:image; + begin + cleartextures; + im:=ld_tex('background.png',path,'title/'); + for ix:=0 to 1 do + bg[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); + float:=ld_tex('float.png',path,'gui/'); + compas:=ld_tex('compass.png',path,'gui/'); + im:=ld_tex('clock.png',path,'gui/'); + for ix:=0 to 7 do + clock[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); + if load_back_tex then + begin + im:=ld_tex('back.png',path,''); + for ix:=0 to 8 do back[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); + end; + + player.loadSkin('char_ani.png', path); + mob.loadSkin(path); + + im:=ld_tex('gui.png',path,'gui/'); + gui[0]:=rotate_image_from_image(im,0,0,16,16,0); + LoadCurImg(gui[0], CUR_SELECT1); + gui[1]:=rotate_image_from_image(im,0,16,168,21,0); + gui[3]:=rotate_image_from_image(im,16,0,16,16,0); + LoadCurImg(gui[3], CUR_SELECT2); + gui[6]:=rotate_image_from_image(im,0,56,120,12,0); + gui[7]:=rotate_image_from_image(im,0,68,120,12,0); + gui[8]:=rotate_image_from_image(im,0,80,120,12,0); + gui[13]:=rotate_image_from_image(im,1,93,9,9,0);//hp + gui[14]:=rotate_image_from_image(im,12,93,9,9,0);//hp + gui[15]:=rotate_image_from_image(im,23,93,9,9,0);//hp + gui[17]:=rotate_image_from_image(im,120,56,18,18,0); + + gui[26]:=rotate_image_from_image(im,89,93,9,9,0);//hunger + gui[27]:=rotate_image_from_image(im,100,93,9,9,0);//hunger + gui[28]:=rotate_image_from_image(im,111,93,9,9,0);//hunger + + gui[29]:=rotate_image_from_image(im,67,93,9,9,0);//air + gui[30]:=rotate_image_from_image(im,78,93,9,9,0);//air + + gui[31]:=rotate_image_from_image(im,122,93,9,9,0);//hp hardcore + gui[32]:=rotate_image_from_image(im,133,93,9,9,0);//hp hardcore + gui[33]:=rotate_image_from_image(im,144,93,9,9,0);//hp hardcore + + gui[20]:=rotate_image_from_image(im,121,75,9,13,0); + gui[21]:=rotate_image_from_image(im,130,75,9,13,0); + gui[22]:=rotate_image_from_image(im,0,103,120,12,0); + + if load_minimap_tex then gui[16]:=ld_tex('mapbg.png',path,'gui/'); + + for ix:=0 to 9 do tue[ix]:=rotate_image_from_image(im,16*ix,40,16,16,0); + + if load_weather_tex then + begin + im:=ld_tex('rain.png',path,'terrain/'); + for ix:=0 to 7 do osad[0,ix]:=rotate_image_from_image(im,16*ix,0,16,16,0); + im:=ld_tex('snow.png',path,'terrain/'); + for ix:=0 to 7 do osad[1,ix]:=rotate_image_from_image(im,16*ix,0,16,16,0); + end; + + if load_light_tex then + begin + im:=ld_tex('light.png',path,'terrain/'); + for ix:=0 to 15 do light[ix]:=rotate_image_from_image(im,16*ix,0,16,16,0); + end; + + if load_particles_tex then + begin + im:=ld_tex('particles.png',path,'terrain/'); + for ix:=0 to 7 do + begin + pr_1[ix]:=rotate_image_from_image(im,8*ix,0,8,8,0); + pr_2[ix]:=rotate_image_from_image(im,8*ix,8,8,8,0); + pr_3[ix]:=rotate_image_from_image(im,8*ix,16,8,8,0); + pr_4[ix]:=rotate_image_from_image(im,8*ix,24,8,8,0); + pr_5[ix]:=rotate_image_from_image(im,8*ix,32,8,8,0); + end; + bubble:=rotate_image_from_image(im,0,40,8,8,0); + im:=ld_tex('explosion.png',path,'terrain/'); + for ix:=0 to 15 do + pr_boom[ix]:=rotate_image_from_image(im,32*ix,0,32,32,0); + end; + + im:=ld_tex('partition.png',path,'gui/'); + gui[18]:=rotate_image_from_image(im,0,0,84,42,0); + gui[19]:=rotate_image_from_image(im,0,42,4,4,0); + + if load_sky_siz<=0 then + sky:=ld_tex('sky.png',path,'terrain/'); + else + sky:=resize_image(ld_tex('sky.png',path,'terrain/'),load_sky_siz,2); + + if load_sm=1 then + begin + sun:=ld_tex('sun.png',path,'terrain/'); + moon:=ld_tex('moon_phase_0.png',path,'terrain/moon_phases/'); + end; else + if load_sm=2 then + begin + sun:=resize_image(ld_tex('sun.png',path,'terrain/'),(getWidth+getHeight)/5,(getWidth+getHeight)/5); + moon:=resize_image(ld_tex('moon_phase_0.png',path,'terrain/moon_phases/'),(getWidth+getHeight)/5,(getWidth+getHeight)/5); + end; + + //load_virt_tex(ld_tex('touch.png',path,'gui/')); + end; + +procedure cleargame; + var + ix,iy:integer; + begin + jmp:=false; + keymode:=0; + updx:=0; + updy:=0; + toolus:=0; + toolind:=0; + osadki_ani:=0; + global_light:=15; + pl_world:=0; + + camx:=0; + camy:=0; + curx:=0; + cury:=0; + + player.setX(0); + player.setY(0); + last_sleep_x:=0; + last_sleep_y:=0; + + fly:=false; + game_time:=0; + clock_stage:=0; + hp:=20; + hunger:=20; + air:=21; + moon_phase:=0; + posi:=0; + velx:=0; + vely:=0; + invslot:=0; + + osadki:=false; + + //anim_del2:=0; + + inv.resetData; + + chest.resetData; + + {for ix:=0 to 15 do + begin + b_furnace[ix]:=false; + for iy:=0 to 4 do + begin + furnace[ix,iy].item_i:=0; + furnace[ix,iy].sum_i:=0; + furnace_gg[ix].f_gor:=15; + furnace_gg[ix].fire_time:=0; + furnace_gg[ix].f_got:=0; + furnace_gg[ix].got_time:=0; + end; + end;} + + drop.resetData; + + mob.resetData; + + //gb_up_pa:=0; + reset_particles(max_particles+1); + + for ix:=0 to 255 do + begin + setBackMap(0, ix); + setBiomMap(0, ix); + for iy:=0 to 127 do + begin + setmap(0,ix,iy); + setmapinfo(0,ix,iy); + setmaplight(0,ix,iy); + end; + end; + + for ix:=0 to 31 do + begin + b_sign[ix]:=false; + t_sign[ix]:=''; + end; + + for ix:=0 to CONST_MAX_LAYERS do + ClearLayer(ix); + end; + +procedure drw_load_line(s:string;percent:integer); + var + ix,iy:integer; + begin + for ix:=0 to getWidth/16 do + for iy:=0 to getHeight/16 do + drawimage(bg[0],ix*16,iy*16); + drawfonttext(s,(getWidth/2)-(length(s)*8/2),(getHeight/2)-8); + setcolor(128,128,128); + fillrect(getwidth/2-50,getheight/2+6,100,3); + setcolor(128,255,128); + fillrect(getwidth/2-50,getheight/2+6,percent,3); + drawfonttext(integertostring(percent)+'%',getwidth/2-(length(integertostring(percent)+'%')*8)/2,getheight/2+12); + drawVideo; + end; + +function getFlatMap(i:integer):integer; + var + ix, iy:integer; + begin + iy:=i div 256; + ix:=i-iy*256; + getFlatMap:=getmap(ix,iy); + end; + +procedure setFlatMap(n, i:integer); + var + ix, iy:integer; + begin + iy:=i div 256; + ix:=i-iy*256; + setmap(n,ix,iy); + end; + +function getFlatMapInfo(i:integer):integer; + var + ix, iy:integer; + begin + iy:=i div 256; + ix:=i-iy*256; + getFlatMapInfo:=getmapinfo(ix,iy); + end; + +procedure setFlatMapInfo(n, i:integer); + var + ix, iy:integer; + begin + iy:=i div 256; + ix:=i-iy*256; + setmapinfo(n,ix,iy); + end; + +procedure SaveMapRLE; + var + i:integer; + id, s:integer; + begin + repeat + id:=getFlatMap(i); + for s:=0 to 255 do + if (id<>getFlatMap(i+s)) or (i+s>32767) then + break; + + write_byte(id); + write_byte(s-1); + + i:=i+s; + until i>32767; + end; + +procedure SaveMapInfoRLE; + var + i:integer; + id, s:integer; + begin + repeat + id:=getFlatMapInfo(i); + for s:=0 to 255 do + if (id<>getFlatMapInfo(i+s)) or (i+s>32767) then + break; + + write_byte(id); + write_byte(s-1); + + i:=i+s; + until i>32767; + end; + +procedure LoadMapRLE; + var + i:integer; + id, s, j:integer; + begin + repeat + id:=read_byte; + s:=read_byte; + for j:=0 to s do + setFlatMap(id, i+j); + + i:=i+s+1; + until i>32767; + end; + +procedure LoadMapInfoRLE; + var + i:integer; + id, s, j:integer; + begin + repeat + id:=read_byte; + s:=read_byte; + for j:=0 to s do + setFlatMapInfo(id, i+j); + + i:=i+s+1; + until i>32767; + end; + +procedure saveworld(path:string); + var + ix,iy:integer; + world_name:string; + begin + if pl_world=0 then world_name:='world.sav'; + else + if pl_world=1 then world_name:='nether.sav'; + if file_exists(path)<>1 then if create_folder(path)=1 then debug('Folder created!'); + if file_exists(path+world_name)>0 then delete_file(path+world_name); + if file_exists(path+world_name)<>1 then file_create(path+world_name); + if open_file(path+world_name)=1 then + begin + writeint(player.getX); + writeint(player.getX); + //Matrix + //Matrix + SaveMapRLE; + SaveMapInfoRLE; + drw_load_line('Background',50); + //Background and biomes + for ix:=0 to 255 do + begin + write_byte(getBackMap(ix)); + write_byte(getBiomMap(ix)); + end; + drw_load_line('Chests',55); + //Chests + chest.saveData; + drw_load_line('Furnaces',60); + //Furnaces + /* for ix:=0 to 15 do + begin + writebool(b_furnace[ix]); + writeint(furnace_gg[ix].f_gor); + writeint(furnace_gg[ix].f_got); + for iy:=0 to 4 do + begin + write_byte(furnace[ix,iy].item_i); + writeint(furnace[ix,iy].sum_i); + end; + end;*/ + drw_load_line('Mobs',70); + //Mobs + mob.saveData; + drw_load_line('Drop',80); + //Drop + drop.saveData; + drw_load_line('Particles',85); + //Particles + writeint(max_particles); + write_byte(gb_up_pa); + for ix:=0 to max_particles do + begin + write_byte(get_particle_type(ix)); + write_byte(get_particle_ani(ix)); + writeint(get_particle_x(ix)); + writeint(get_particle_y(ix)); + end; + drw_load_line('Other',90); + //Other + write_byte(updx); + write_byte(updy); + writebool(osadki); + write_byte(osadki_ani); + write_byte(global_light); + writebool(fly); + writeint(game_time); + write_byte(clock_stage); + for ix:=0 to 31 do + begin + writebool(b_sign[ix]); + writestr(t_sign[ix]); + end; + flush; + drw_load_line('Ready',100); + if close_file(path+world_name)=1 then debug('World Saved!'); + end; + end; + +procedure savegame(path:string); + var + ix,iy:integer; + begin + drw_load_line('Basic',0); + if file_exists(path+'player.dat')=1 then delete_file(path+'player.dat'); + if file_exists(path)<>1 then if create_folder(path)=1 then debug('Folder created!'); + if file_exists(path+'player.dat')<>1 then file_create(path+'player.dat'); + if open_file(path+'player.dat')=1 then + begin + //Head + write_byte(version_map); + write_byte(gamemode); + writebool(cheats); + writeint(seed); + write_byte(pl_world); + //Player + writeint(last_sleep_x); + writeint(last_sleep_y); + write_byte(velx); + write_byte(vely); + write_byte(invslot); + write_byte(posi); + write_byte(hp); + write_byte(hunger); + write_byte(moon_phase); + writebool(jmp); + inv.saveData; + if close_file(path+'player.dat')=1 then debug('Saved!'); + drw_load_line('Matrix',10); + saveworld(path); + end; +end; + + +function version_err(ver:integer):boolean; + var + ix,iy:integer; + begin + for ix:=0 to getWidth/16 do + for iy:=0 to getHeight/16 do + begin + drawimage(bg[0],ix*16,iy*16); + end; + if version_map=ver then version_err:=true; else + if version_map>ver then + begin + drawfonttext('Old save format!',(getWidth/2)-60,(getHeight/2)-4); + drawVideo; + delay(3000); + version_err:=false; + end; else + if version_map-1 do + begin + pars:=pos(rr,'|'); + roots[max_r]:=copy(rr,0,pars-1); + rr:=copy(rr,pars+1,length(rr)); + max_r:=max_r+1; + end; + max_r:=max_r-1; + repeat + updateKeys; + if clickedKey(KEY_FM_UP) then begin m_cur:=m_cur-1; if m_cur<0 then m_cur:=max_r; end; + if clickedKey(KEY_FM_DOWN) then begin m_cur:=m_cur+1; if m_cur>max_r then m_cur:=0; end; + if clickedKey(KEY_FM_SELECT) then + begin + if (m_cur=0) and (cancel_b) then + begin + getroot:=''; + exit; + end; + else + begin + getroot:=roots[m_cur]; + exit; + end; + end; + + for ix:=0 to getWidth/16 do + for iy:=0 to getHeight/16 do + drawimage(im,ix*16,iy*16); + + setcolor(0,0,0); + fillrect(0,m_cur*8,getWidth-1,8); + for ix:=0 to max_r do + begin + drawfonttext(roots[ix],0,ix*8); + end; + setcolor(255,255,255); + drawrect(0,m_cur*8,getWidth-1,8); + + drawVideo; + delay(1); + until false; + end; + +function filemanager(cancel_b:boolean):string; + var + m_cur,ix,iy,max_r,pars:integer; + im:image; + last,rr,root,path:string; + names:array [0..255] of string; + begin + im:=rotate_image_from_image(ld_tex('background.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','title/'),16,0,16,16,0); + names[0]:='<..>'; + names[1]:=''; + root:=getroot(cancel_b); + if root='' then + begin + filemanager:=''; + exit; + end; + path:=root; + if cancel_b then names[2]:=''; + rr:=get_dirs(path); + if cancel_b then max_r:=3; else max_r:=2; + while pos(rr,'|')<>-1 do + begin + pars:=pos(rr,'|'); + names[max_r]:=copy(rr,0,pars-1); + rr:=copy(rr,pars+1,length(rr)); + max_r:=max_r+1; + end; + max_r:=max_r-1; + + repeat + updateKeys; + if clickedKey(KEY_FM_UP) then begin m_cur:=m_cur-1; if m_cur<0 then m_cur:=max_r; end; + if clickedKey(KEY_FM_DOWN) then begin m_cur:=m_cur+1; if m_cur>max_r then m_cur:=0; end; + if clickedKey(KEY_FM_SELECT) then + begin + if m_cur=0 then + begin + debug('path:'+path); + debug('lol:'+pos_end(path,'/')); + if (path=root) or (path=root+'/') then + begin + root:=getroot(cancel_b); + if root='' then + begin + filemanager:=''; + exit; + end; + path:=root; + end; + else + begin + path:=copy(path,0,pos_end(path,'/')); + if cancel_b then names[2]:=''; + rr:=get_dirs(path); + if cancel_b then max_r:=3; else max_r:=2; + while pos(rr,'|')<>-1 do + begin + pars:=pos(rr,'|'); + names[max_r]:=copy(rr,0,pars-1); + rr:=copy(rr,pars+1,length(rr)); + max_r:=max_r+1; + end; + max_r:=max_r-1; + end; + end; else + if m_cur=1 then + begin + debug(''); + filemanager:=path; + exit; + end; else + if (m_cur=2) and (cancel_b) then + begin + debug(''); + filemanager:=''; + exit; + end; else + begin + path:=path+'/'+names[m_cur]; + + if cancel_b then names[2]:=''; + rr:=get_dirs(path); + if cancel_b then max_r:=3; else max_r:=2; + while pos(rr,'|')<>-1 do + begin + pars:=pos(rr,'|'); + names[max_r]:=copy(rr,0,pars-1); + rr:=copy(rr,pars+1,length(rr)); + max_r:=max_r+1; + end; + max_r:=max_r-1; + m_cur:=0; + debug('path:'+path); + end; + end; + + for ix:=0 to getWidth/16 do + for iy:=0 to getHeight/16 do + drawimage(im,ix*16,iy*16); + + setcolor(0,0,0); + fillrect(0,m_cur*8,getWidth-1,8); + for ix:=0 to max_r do + begin + drawfonttext(names[ix],0,ix*8); + end; + setcolor(255,255,255); + drawrect(0,m_cur*8,getWidth-1,8); + + drawVideo; + delay(1); + + until false; + end; + +procedure setsd(cancel_b:boolean); + var + s:string; + t:integer; + rs:recordstore; + begin + s:=filemanager(cancel_b); + if s<>'' then + begin + sd:=s; + if file_exists('/'+sd+'/cavecraft')<>1 then + if create_folder('/'+sd+'/cavecraft')=1 then debug('/cavecraft created!'); + + if file_exists('/'+sd+'/cavecraft/saves')<>1 then + if create_folder('/'+sd+'/cavecraft/saves')=1 then debug('/saves created!'); + + if file_exists('/'+sd+'/cavecraft/screenshots')<>1 then + if create_folder('/'+sd+'/cavecraft/screenshots')=1 then debug('/screenshots created!'); + + if file_exists('/'+sd+'/cavecraft/texturepacks')<>1 then + if create_folder('/'+sd+'/cavecraft/texturepacks')=1 then debug('/texturepacks created!'); + + deleteRecordStore('SD'); + rs:=openRecordStore('SD'); + t:=addRecordStoreEntry(rs,sd); + closeRecordStore(rs); + end; + end; + +procedure start_uu; + var + rs:recordstore; + ss:string; + begin + drawdeadlogo; + //Load SD + rs:=openRecordStore('SD'); + sd:=readRecordStoreEntry(rs,1); + closeRecordStore(rs); + console.exec('autoexec.cfg', 'AUTO', true); + if sd='' then + begin + init_touch; + if touchscreen then + load_key_tex:=1; + else + load_key_tex:=0; + //load_virt_tex(loadimage('/gui/touch.png')); + setsd(false); + end; + + if file_exists('/'+sd+'/cavecraft')<>1 then + if create_folder('/'+sd+'/cavecraft')=1 then debug('/cavecraft created!'); + + if file_exists('/'+sd+'/cavecraft/saves')<>1 then + if create_folder('/'+sd+'/cavecraft/saves')=1 then debug('/saves created!'); + + if file_exists('/'+sd+'/cavecraft/screenshots')<>1 then + if create_folder('/'+sd+'/cavecraft/screenshots')=1 then debug('/screenshots created!'); + + if file_exists('/'+sd+'/cavecraft/texturepacks')<>1 then + if create_folder('/'+sd+'/cavecraft/texturepacks')=1 then debug('/texturepacks created!'); + + rs:=openRecordStore('TX'); + ss:=readRecordStoreEntry(rs,1); + closeRecordStore(rs); + + if ss<>'' then + begin + tex_pack:=ss; + LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); + loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); + end; + else + begin + LoadDrawFont('/'); + loadtexture('/'); + end; + end; + +function question(text:string):boolean; + var + ix,iy,m_cur:integer; + begin + repeat + updateKeys; + if clickedKey(KEY_MENU_UP) then begin m_cur:=m_cur-1; if m_cur<0 then m_cur:=1; end; + if clickedKey(KEY_MENU_DOWN) then begin m_cur:=m_cur+1; if m_cur>1 then m_cur:=0; end; + if clickedKey(KEY_MENU_SELECT) then begin if m_cur=0 then question:=true; else question:=false; exit; end; + for ix:=0 to getwidth/16 do for iy:=0 to getheight/16 do drawimage(bg[0],ix*16,iy*16); + drawfonttext(text,getwidth/2-(length(text)*8)/2,getheight/2-16); + drw_btn('Yes',0,m_cur,0,1); + drw_btn('No',1,m_cur,0,1); + drawVideo; + delay(1); + until false; + end; + +function menu_game_new:boolean; + var + m_cur,tmp_gm,ix,iy,lol:integer; + tmp_cheats,tmp_bon_chest:boolean; + newgametxt:array[0..4] of string; + name,tmp:string; + begin + m_cur:=-2; + newgametxt[0]:='Survival'; + newgametxt[1]:='Creative'; + newgametxt[2]:='Hardcore'; + newgametxt[3]:='Normal'; + newgametxt[4]:='Flat'; + name:='New World'; + repeat + updateKeys; + if clickedKey(KEY_MENU_UP) then begin m_cur:=m_cur-1; if m_cur<-2 then m_cur:=5; end; + if clickedKey(KEY_MENU_DOWN) then begin m_cur:=m_cur+1; if m_cur>5 then m_cur:=-2; end; + if clickedKey(KEY_MENU_SELECT) then + begin + if m_cur=-2 then + begin + name:=gettext('Name:',name,10,TF_ANY); + end; else + if m_cur=-1 then + begin + tmp_gm:=tmp_gm+1; if tmp_gm>2 then tmp_gm:=0; + if tmp_gm=0 then tmp_cheats:=false; + if tmp_gm=1 then tmp_cheats:=true; + if tmp_gm=2 then begin tmp_cheats:=false; tmp_bon_chest:=false; end; + end; else + if m_cur=0 then + begin + nextseed:=stringtointeger(gettext('Seed:',''+nextseed,10,TF_NUMERIC)); + end; else + if m_cur=1 then + begin + world_typ:=world_typ+1; + if world_typ>1 then world_typ:=0; + end; else + if m_cur=2 then + begin + if tmp_gm<2 then tmp_cheats:= not tmp_cheats; + end; else + if m_cur=3 then + begin + if tmp_gm<2 then tmp_bon_chest:= not tmp_bon_chest; + end; else + if m_cur=4 then + begin + gamemode:=tmp_gm; + cheats:=tmp_cheats; + bon_chest:=tmp_bon_chest; + tmp:=name; + while file_exists('/'+sd+'/cavecraft/saves/'+name)=1 do + begin + lol:=lol+1; + name:=tmp+' '+lol; + end; + sav_fl:=name; + newgame; + menu_game_new:=true; + break; + end; else + if m_cur=5 then + begin + break; + end; else + end; + for ix:=0 to getWidth/16 do + for iy:=0 to getHeight/16 do + drawimage(bg[0],ix*16,iy*16); + + drw_btn('Name:'+name,-2,m_cur,0,1); + drw_btn('Mode:'+newgametxt[tmp_gm],-1,m_cur,0,1); + drw_btn('Seed:'+nextseed,0,m_cur,0,1); + drw_btn('Type:'+newgametxt[world_typ+3],1,m_cur,0,1); + if tmp_gm<2 then + drw_btn('Cheats:'+tmp_cheats,2,m_cur,0,1); + else + drw_btn('Cheats:'+tmp_cheats,2,m_cur,0,0); + if tmp_gm<2 then + drw_btn('Chest:'+tmp_bon_chest,3,m_cur,0,1); + else + drw_btn('Chest:'+tmp_bon_chest,3,m_cur,0,0); + drw_btn('Create',4,m_cur,0,1); + drw_btn('Cancel',5,m_cur,0,1); + + drawVideo; + delay(1); + until false; + end; + +procedure deleteworld(path:string); + begin + if file_exists(path+'player.dat')=1 then delete_file(path+'player.dat'); + if file_exists(path+'world.sav')=1 then delete_file(path+'world.sav'); + if file_exists(path+'nether.sav')=1 then delete_file(path+'nether.sav'); + if file_exists(path+'pic.png')=1 then delete_file(path+'pic.png'); + if file_exists(path)=1 then delete_file(path); + if file_exists(path)=0 then debug('World deleted!'); + end; + +function menu_game:boolean; + var + ix,iy,pars,max_r,cur_name,m_cur:integer; + mm_t_b:boolean; + im_game:image; + rr:string; + names:array[0..255] of string; + begin + rr:=get_dirs('/'+sd+'/cavecraft/saves/'); + while pos(rr,'|')<>-1 do + begin + pars:=pos(rr,'|'); + names[max_r]:=copy(rr,0,pars-1); + rr:=copy(rr,pars+1,length(rr)); + if file_exists('/'+sd+'/cavecraft/saves/'+names[max_r]+'/player.dat')=1 then max_r:=max_r+1; + end; + max_r:=max_r-1; + if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png')=1 then + im_game:=safely_load_image_fs('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png'); + else im_game:=ld_tex('maps.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',''); + + if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/player.dat')=1 then + mm_t_b:=true; else mm_t_b:=false; + + repeat + updateKeys; + if clickedKey(KEY_MENU_UP) then + begin + m_cur:=m_cur-1; + if m_cur<0 then m_cur:=3; + end; + if clickedKey(KEY_MENU_DOWN) then + begin + m_cur:=m_cur+1; + if m_cur>3 then m_cur:=0; + end; + + if clickedKey(KEY_MENU_LEFT) then + begin + cur_name:=cur_name-1; + if cur_name<0 then cur_name:=0; + if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png')=1 then + im_game:=safely_load_image_fs('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png'); + else im_game:=ld_tex('maps.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',''); + + if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/player.dat')=1 then + end; + if clickedKey(KEY_MENU_RIGHT) then + begin + cur_name:=cur_name+1; + if cur_name>max_r then cur_name:=max_r; + if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png')=1 then + im_game:=safely_load_image_fs('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png'); + else im_game:=ld_tex('maps.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',''); + + if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/player.dat')=1 then + end; + if clickedKey(KEY_MENU_SELECT) then + begin + if m_cur=0 then + begin + if max_r>-1 then + if loadgame('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/') then + begin + sav_fl:=names[cur_name]; + menu_game:=true; + break; + end; + end; else + if m_cur=1 then + begin + if menu_game_new then begin menu_game:=true; break; end; + end; else + if m_cur=2 then + begin + debug('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/'); + if max_r>-1 then + if question('Are you sure?')=true then deleteworld('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/'); + cur_name:=0; + max_r:=0; + rr:=get_dirs('/'+sd+'/cavecraft/saves/'); + while pos(rr,'|')<>-1 do + begin + pars:=pos(rr,'|'); + names[max_r]:=copy(rr,0,pars-1); + rr:=copy(rr,pars+1,length(rr)); + max_r:=max_r+1; + end; + max_r:=max_r-1; + if file_exists('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png')=1 then + im_game:=safely_load_image_fs('/'+sd+'/cavecraft/saves/'+names[cur_name]+'/pic.png'); + else im_game:=ld_tex('maps.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',''); + end; else + if m_cur=3 then + begin + break; + end; + end; + + for ix:=0 to getWidth/16 do + for iy:=1 to 7 do + drawimage(bg[1],ix*16,iy*16); + for ix:=0 to getWidth/16 do + drawimage(bg[0],ix*16,0); + for ix:=0 to getWidth/16 do + for iy:=8 to getHeight/16 do + drawimage(bg[0],ix*16,iy*16); + + if max_r>-1 then + begin + setcolor(0,0,0); + fillrect(32,24,getWidth-64,96); + setclip(32,24,getWidth-64,96); + drawimage(im_game,(getWidth/2)-(32),32); + drawfonttext(names[cur_name],(getWidth/2)-(length(names[cur_name])*8/2),104); + setclip(0,0,getWidth,getHeight); + setcolor(128,128,128); + drawrect(32,24,getWidth-64,96); + if cur_name>0 then drawimage(gui[20],0,58); + if cur_name-1 do + begin + pars:=pos(rr,'|'); + names[max_r]:=copy(rr,0,pars-1); + rr:=copy(rr,pars+1,length(rr)); + max_r:=max_r+1; + end; + max_r:=max_r-1; + im_game:=loadimage('/pack.png'); + + repeat + updateKeys; + if clickedKey(KEY_MENU_UP) then + begin + m_cur:=m_cur-1; + if m_cur<0 then m_cur:=1; + end; + if clickedKey(KEY_MENU_DOWN) then + begin + m_cur:=m_cur+1; + if m_cur>1 then m_cur:=0; + end; + + if clickedKey(KEY_MENU_LEFT) then + begin + cur_name:=cur_name-1; + if cur_name<0 then cur_name:=0; + im_game:=ld_tex('pack.png','/'+sd+'/cavecraft/texturepacks/'+names[cur_name]+'/',''); + end; + if clickedKey(KEY_MENU_RIGHT) then + begin + cur_name:=cur_name+1; + if cur_name>max_r then cur_name:=max_r; + im_game:=ld_tex('pack.png','/'+sd+'/cavecraft/texturepacks/'+names[cur_name]+'/',''); + end; + if clickedKey(KEY_MENU_SELECT) then + begin + if m_cur=0 then begin + if cur_name>0 then + begin + tex_pack:=names[cur_name]; + LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); + loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); + deleteRecordStore('TX'); + rs:=openRecordStore('TX'); + t:=addRecordStoreEntry(rs,tex_pack); + closeRecordStore(rs); + end; + else + begin + tex_pack:=''; + loadtexture('/'); + deleteRecordStore('TX'); + rs:=openRecordStore('TX'); + t:=addRecordStoreEntry(rs,''); + closeRecordStore(rs); + end; + end; + if m_cur=1 then break; + break; + end; + + for ix:=0 to getWidth/16 do + for iy:=1 to 7 do + drawimage(bg[1],ix*16,iy*16); + for ix:=0 to getWidth/16 do + drawimage(bg[0],ix*16,0); + for ix:=0 to getWidth/16 do + for iy:=8 to getHeight/16 do + drawimage(bg[0],ix*16,iy*16); + + if max_r>-1 then + begin + setcolor(0,0,0); + fillrect(32,24,getWidth-64,96); + setclip(32,24,getWidth-64,96); + drawimage(im_game,(getWidth/2)-(32),32); + drawfonttext(names[cur_name],(getWidth/2)-(length(names[cur_name])*8/2),104); + setclip(0,0,getWidth,getHeight); + setcolor(128,128,128); + drawrect(32,24,getWidth-64,96); + if cur_name>0 then drawimage(gui[20],0,58); + if cur_name5 then m_cur:=-3; + end; + if clickedKey(KEY_MENU_SELECT) then + begin + if m_cur=-3 then + begin + light_type:=light_type+1; + if light_type>2 then light_type:=0; + end; else + if m_cur=-2 then + begin + ifosad:=not ifosad; + end; else + if m_cur=-1 then + begin + s_particles:=not s_particles; + end; else + if m_cur=0 then + begin + drawgui:=not drawgui; + end; else + if m_cur=1 then + begin + if question('Are you sure?')=true then + begin + if load_key_tex=0 then + begin + load_key_tex:=1; + init_touch; + //load_virt_tex(ld_tex('touch.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/')); + end; + else + if load_key_tex=1 then + begin + load_key_tex:=0; + resetVirtualKeyboard(-1); + end; + end; + end; + if m_cur=2 then + begin + s_jpeg_quality:=stringtointeger(gettext('JPEG quality:',''+s_jpeg_quality,3,TF_NUMERIC)); + if s_jpeg_quality>100 then s_jpeg_quality:=100; else + if s_jpeg_quality<0 then s_jpeg_quality:=0; + end; else + if m_cur=3 then + begin + setsd(true); + end; else + if m_cur=4 then + begin + deleteRecordStore('S'); + deleteRecordStore('SD'); + deleteRecordStore('TX'); + halt; + end; else + if m_cur=5 then + begin + save_settings; + break; + end; else + end; + + for ix:=0 to getWidth/16 do + for iy:=0 to getHeight/16 do + drawimage(bg[0],ix*16,iy*16); + + drw_btn('Light:'+light_type,-3,m_cur,0,1); + drw_btn('Weather:'+ifosad,-2,m_cur,0,1); + drw_btn('Particles:'+s_particles,-1,m_cur,0,1); + drw_btn('Hide GUI:'+not drawgui,0,m_cur,0,1); + drw_btn('Touch:'+(load_key_tex>0),1,m_cur,0,1); + drw_btn('JPEG:'+s_jpeg_quality,2,m_cur,0,1); + drw_btn('Set Root',3,m_cur,0,1); + drw_btn('Reset',4,m_cur,0,1); + drw_btn('Back',5,m_cur,0,1); + + drawVideo; + delay(1); + until false; + end; + +procedure menu_help; + var + ix,iy,cur:integer; + begin + repeat + updateKeys; + if clickedKey(KEY_MENU_SELECT) then break; + if pressedKey(KEY_MENU_UP) then cur:=cur+1; + if pressedKey(KEY_MENU_DOWN) then cur:=cur-1; + + for ix:=0 to getWidth/16 do + for iy:=2 to (getHeight/16)-2 do + drawimage(bg[1],ix*16,iy*16); + + for ix:=0 to getWidth/16 do + for iy:=0 to 1 do + drawimage(bg[0],ix*16,iy*16); + + for ix:=0 to getWidth/16 do + for iy:=(getHeight/16)-2 to getHeight/16 do + drawimage(bg[0],ix*16,iy*16); + + setclip(0,32,getWidth,(getHeight/16-4)*16); + + drw_txt('Controls:',cur,0,1); + drw_txt('Left - Move left',cur,1,0); + drw_txt('Right - Move right',cur,2,0); + drw_txt('Up - Jump',cur,3,0); + drw_txt('Down - Put a block under you',cur,4,0); + drw_txt('1 - Inventory',cur,5,0); + drw_txt('Duble 1 - Craft',cur,6,0); + drw_txt('3 - Use block',cur,7,0); + drw_txt('7 - Debug info',cur,8,0); + drw_txt('Hold 7 - Console',cur,9,0); + drw_txt('9 - Pause',cur,10,0); + drw_txt('*, # - Browse inventory',cur,11,0); + drw_txt('0 - Edit mode',cur,12,0); + + drw_txt('In inventory/chest:',cur,14,1); + drw_txt('3 - Enject object',cur,15,0); + drw_txt('Hold 3 - Enject stack',cur,16,0); + drw_txt('5 - Move the stack',cur,17,0); + drw_txt('Hold 5 - Divide stack',cur,18,0); + + setclip(0,0,getWidth,getHeight); + + drw_btn('Back',0,0,getHeight-getHeight/2-16-6,1); + + drawVideo; + delay(1); + until false; + end; + +procedure menu_about; + var + ix,iy,cur:integer; + begin + repeat + updateKeys; + if clickedKey(KEY_MENU_SELECT) then break; + if pressedKey(KEY_MENU_UP) then cur:=cur+1; + if pressedKey(KEY_MENU_DOWN) then cur:=cur-1; + + for ix:=0 to getWidth/16 do + for iy:=2 to (getHeight/16)-2 do + drawimage(bg[1],ix*16,iy*16); + + for ix:=0 to getWidth/16 do + for iy:=0 to 1 do + drawimage(bg[0],ix*16,iy*16); + + for ix:=0 to getWidth/16 do + for iy:=(getHeight/16)-2 to getHeight/16 do + drawimage(bg[0],ix*16,iy*16); + + setclip(0,32,getWidth,(getHeight/16-4)*16); + + drw_txt('Developers:',cur,0,1); + drw_txt(#68+#101+#97+#68+#68+#111+#111+#77+#69+#82+' - Programmer',cur,1,0);//dead + drw_txt(#102+#114+#101+#100+#45+#98+#111+#121+' - Programmer',cur,2,0);//fred-boy + drw_txt(#65+#110+#100+#114+#101+#121+#53+#57+' - Programmer',cur,3,0);//andrey59 + drw_txt(#89+#117+#82+#97+#78+#110+#78+#122+#90+#90+' - Artist',cur,4,0);//yura + drw_txt(#83+#97+#115+#104+#97+#71+' - Artist and idea generator',cur,5,0);//sasha + drw_txt(#66+#97+#74+#108+#101+#72+#84+#105+#72+' - Artist and tester',cur,6,0);//valentin + drw_txt(#65+#103+#114+#101+#115+#115+#111+#82+' - Tester',cur,7,0);//agressor + drw_txt(#118+#111+#108+#121+#97+#95+#110+#97+#115+#116+#97+#110+#101+' - Tester',cur,8,0);//volya + drw_txt(#97+#98+#97+#100+#111+#110+' - Tester',cur,9,0);//abadon + drw_txt(#77+#111+#110+#111+#103+#114+#111+#109+' - Tester',cur,10,0);//monogrom + drw_txt(#75+#97+#108+#116+#101+#114+' - Tester',cur,11,0);//kalter + + drw_txt('Thanks:',cur,12,1); + drw_txt('Piligrim and 0vZ - Lib_jsr75i',cur,13,0); + drw_txt('Piligrim - Lib_effects',cur,14,0); + drw_txt('Kurdt - Lib_canvas',cur,15,0); + drw_txt('ViNT - Lib_png and Lib_bmp',cur,16,0); + drw_txt('aleshka - Lib_jpeg',cur,17,0); + drw_txt('Roman_V - Lib_safeload',cur,18,0); + + 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); + drw_txt(#68+#101+#97+#68+#83+#111+#102+#116+#87+#97+#114+#101+' 2012-'+getyear(getcurrenttime),cur,22,0); + + drw_txt('Hello! :D',cur,100,1); + + setclip(0,0,getWidth,getHeight); + + drw_btn('Back',0,0,getHeight-getHeight/2-16-6,1); + + drawVideo; + delay(1); + until false; + end; + +function sm_siz:integer; + begin + sm_siz:=(getWidth+getHeight)/5; + end; + +function sm_siz4:integer; + begin + sm_siz4:=sm_siz/4; + end; + +procedure draw_menu_back; + var + ix, iy:integer; + begin + for ix:=0 to getWidth/16 do + for iy:=0 to getHeight/16 do + drawimage(bg[0],ix*16,iy*16); + end; + +procedure menu; + var + m_cur,ix,iy,iz:integer; + key,spl_i:integer; + splash:string; + res:resource; + time:integer; + cavelogo:image; + spl_y,spl_del:integer; + spl_y_b:boolean; + begin + cavelogo:=ld_tex('cavelogo.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','title/'); + splash:='#ERROR'; + spl_y:=getimageheight(cavelogo); + spl_y_b:=true; + spl_del:=getrelativetimems; + res:=openResource('/title/splashes.txt'); + if ResourceAvailable(res) then + begin + spl_i:=stringtointeger(readline(res)); + iy:=random(spl_i-1)+1; + debug('SPLASH #'+iy); + for ix:=1 to iy do + splash:=readline(res); + closeresource(res); + end; + time:=getcurrenttime; + if (getmonth(time)=5) and (getday(time)=7) then splash:='Happy birthday, DeaDDooMER!'; + if ((getmonth(time)=0) and (getday(time)<3)) or ((getmonth(time)=11) and (getday(time)>29)) then splash:='Happy New Year!'; + repeat + proc_fps; + updateKeys; + if clickedKey(KEY_MENU_UP) then + begin + m_cur:=m_cur-1; + if m_cur<0 then m_cur:=5; + end; + if clickedKey(KEY_MENU_DOWN) then + begin + m_cur:=m_cur+1; + if m_cur>5 then m_cur:=0; + end; + if clickedKey(KEY_MENU_SELECT) then + begin + if m_cur=0 then begin if menu_game then break; end; + else + if m_cur=1 then menu_tex; + else + if m_cur=2 then menu_sett; + else + if m_cur=3 then menu_help; + else + if m_cur=4 then menu_about; + else + if m_cur=5 then begin save_settings; halt; end; + end; + + draw_menu_back; + + drawimage(cavelogo,(getWidth/2)-(getimagewidth(cavelogo)/2),0); + setcolor(255,255,0); + + DrawFontTextSpec(splash, (getWidth/2)-(length(splash)*FONT_SYM_SIZE/2), spl_y, FONT_YELLOW_COLOR, true); + + 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; + 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_y1 then + begin + inv.setSum(inv.getSum(invcur)-1, invcur); + inv.fixNull(invcur); + end; + + setBlock:=true; + end; + end; + end; + +procedure fishing; + var + x, y:integer; + begin + x:=player.getX; + y:=player.getY; + if (getrelativetimems-fish_time>5000) and (getmap(fx,fy)=50) then + begin + if (random(3)=2) and (getmap(fx,fy)=50) then + begin + drop.create(210,1,x,y); + fish:=false; + end; + inv.setSum(inv.getSum(invslot)-1, invslot); + inv.fixNull(invslot); + fish:=false; + end; else + if (getrelativetimems-fish_time<5000) and (getmap(fx,fy)=50) and (fish=true) then + begin + if getmap(fx,fy-1)=50 then fy:=fy-1; + end; + end; + +procedure drawminimap; + var + ix,iy,tmp_gx,tmp_gy,minx,miny,maxx,maxy,loc_camx,loc_camy,x,y:integer; + begin + x:=player.getX; + y:=player.getY; + if load_minimap_tex then + begin + tmp_gx:=(getWidth/2)-(getimagewidth(gui[16])/2); + tmp_gy:=(getHeight/2)-(getimageheight(gui[16])/2); + end; + else + begin + tmp_gx:=(getWidth/2)-(64/2); + tmp_gy:=(getHeight/2)-(64/2); + end; + + loc_camx:=(x+4)-(864/2); + loc_camy:=(y+4)-(864/2); + if loc_camx<0 then loc_camx:=0; + if loc_camx>4096-864 then loc_camx:=4096-864; + if loc_camy<0 then loc_camy:=0; + if loc_camy>2048-864 then loc_camy:=2048-864; + minx:=loc_camx/16; + miny:=loc_camy/16; + maxx:=(loc_camx+864)/16; + maxy:=(loc_camy+864)/16; + if minx<0 then minx:=0; + if miny<0 then miny:=0; + if maxx>255 then maxx:=255; + if maxy>127 then maxy:=127; + + if load_minimap_tex then + drawimage(gui[16],tmp_gx,tmp_gy); + else + begin + setcolor(214,190,150); + fillrect(tmp_gx,tmp_gy,64,64); + end; + + for ix:=minx to maxx do + for iy:=miny to maxy do + begin + if (getmap(ix,iy)=1) or (getmap(ix,iy)=2) or (getmap(ix,iy)=74) then setcolor(121,85,58); else + 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 + if (getmap(ix,iy)=50) or (getmap(ix,iy)=62) then setcolor(38,92,255); else + if getmap(ix,iy)=51 then setcolor(255,0,0); else + if (getmap(ix,iy)=61) or (getmap(ix,iy)=32) then setcolor(255,255,255); else + setcolor(127,127,127); + + if (getmap(ix,iy)<>0) then plot(tmp_gx+4+ix-minx,tmp_gy+4+iy-miny); + end; + setcolor(0,0,255); + end; + +procedure draw_sign; + var + tmp:string; + str:array[0..3] of string; + i,j,tmp_gx,tmp_gy:integer; + begin + if load_gui_tex then + begin + tmp_gx:=(getWidth/2)-(getimagewidth(sign_im)/2); + tmp_gy:=(getHeight/2)-(getimageheight(sign_im)/2); + end; + else + begin + tmp_gx:=(getWidth/2)-(120/2); + tmp_gy:=(getHeight/2)-(60/2); + end; + + tmp:=t_sign[getmapinfo(curx,cury)]; + while pos(tmp,#13)<>-1 do + begin + i:=pos(tmp,#13); + str[j]:=copy(tmp,0,i); + tmp:=copy(tmp,i+1,length(tmp)); + j:=j+1; + end; + + if load_gui_tex then + drawimage(sign_im,tmp_gx,tmp_gy); + else + begin + setcolor(159,132,77); + fillrect(tmp_gx,tmp_gy,120,60); + end; + + drawfonttext(str[0],tmp_gx+(120/2)-(length(str[0])*8/2),tmp_gy+(60/4/2)+4); + drawfonttext(str[1],tmp_gx+(120/2)-(length(str[1])*8/2),tmp_gy+(60/4/2)+8+4); + drawfonttext(str[2],tmp_gx+(120/2)-(length(str[2])*8/2),tmp_gy+(60/4/2)+16+4); + drawfonttext(str[3],tmp_gx+(120/2)-(length(str[3])*8/2),tmp_gy+(60/4/2)+24+4); + end; + +procedure draw_back(ix,iy:integer); + begin + if getBiomMap(ix)=0 then + begin + if (getBackMap(ix)=iy) then drawimage(back[0],(ix*16)-camx,(iy*16)-camy); else + if (getBackMap(ix)+1=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else + if (getBackMap(ix)+2=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else + if (getBackMap(ix)+3=iy) then drawimage(back[1],(ix*16)-camx,(iy*16)-camy); else + if (getBackMap(ix)getWidth then ix:=ix-getWidth*2; + iy:=rnd(getHeight); + if (ix>-1) and (ix0 then + begin + smy:=10000*(getWidth+getimagewidth(sun))/300000*game_time/10000; + drawimage(sun,smy-getimagewidth(sun),getHeight/2-getimageheight(sun)/2); + end; + else + begin + setcolor(255,213,74); + smy:=10000*(getWidth+sm_siz)/300000*game_time/10000; + fillrect(smy-sm_siz+sm_siz4,getHeight/2-sm_siz/2+sm_siz4,sm_siz-sm_siz4,sm_siz-sm_siz4); + end; + + if load_sm>0 then + begin + smy:=10000*(getWidth+getimagewidth(moon))/300000*(game_time-300000)/10000; + drawimage(moon,smy-getimagewidth(moon),getHeight/2-getimageheight(moon)/2); + end; + else + begin + setcolor(175,184,204); + smy:=10000*(getWidth+sm_siz)/300000*(game_time-300000)/10000; + fillrect(smy-sm_siz+sm_siz4,getHeight/2-sm_siz/2+sm_siz4,sm_siz-sm_siz4,sm_siz-sm_siz4); + end; + end; + {===================[camera]===================} + camx:=(x+4)-(getWidth/2); + camy:=(y+4)-(getHeight/2); + if camx<0 then camx:=0; + if camx>4096-getWidth then camx:=4096-getWidth; + if camy>2048-getHeight then camy:=2048-getHeight; + {===================[max_draw]===================} + minx:=camx/16; + miny:=camy/16; + maxx:=(camx+getWidth)/16; + maxy:=(camy+getHeight)/16; + if minx<0 then minx:=0; + if miny<0 then miny:=0; + if maxx>255 then maxx:=255; + if maxy>127 then maxy:=127; + {===================[draw_back]===================} + for ix:=minx to maxx do + for iy:=miny to maxy do + begin + if ifosad then if (getBackMap(ix)>=iy) and (osadki=true) and getBlockTrans(getmap(ix,iy)) then + begin + if getBiomMap(ix)=0 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy); + else + if getBiomMap(ix)=2 then drawimage(osad[1,osadki_ani],(ix*16)-camx,(iy*16)-camy); + else + if getBiomMap(ix)=3 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy); + end; + if drw_back then + if getBlockTrans(getmap(ix,iy)) then + draw_back(ix,iy); + + if getBlockFore(getmap(ix,iy))=false then + draw_block(ix,iy); + end; + {===================[drop]===================} + drop.draw(camx, camy); + {===================[particles]===================} + if s_particles then draw_particle; + {===================[player]===================} + if hp>0 then + begin + player.draw(camx, camy); + end; + + {===================[mobs]===================} + mob.draw(camx, camy); + {===================[draw_blocks]===================} + for ix:=minx to maxx do + for iy:=miny to maxy do + begin + if getBlockFore(getmap(ix,iy))=true then + draw_block(ix,iy); + + setcolor(0,0,0); + if (light_type=1) then begin if getmaplight(ix,iy)=0 then fillrect((ix*16)-camx,(iy*16)-camy,16,16); end; + else + if light_type=2 then begin if getmaplight(ix,iy)<15 then begin if (ix*16-camx0-16) and (iy*16-camy0-16) then drawimage(light[getmaplight(ix,iy)],(ix*16)-camx,(iy*16)-camy); end; end; + end; + 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; + {===================[gui]===================} + if drawgui then + begin + tmp_ax:=(getWidth/2)-(getImageWidth(gui[1])/2); + + if keymode=1 then + drawimage(gui[0],curx*16-camx,cury*16-camy); + + DrawWindows; + /*if keymode=2 then + if gamemode<>1 then + DrawPlayerInventory; + else + drawinv_c; else + if keymode=3 then drawcraft; else + if keymode=4 then drawchest; else + if keymode=5 then draw_sign; else + if keymode=6 then drawfurnace; else + if ifminimap then drawminimap;*/ + + drawimage(gui[1],tmp_ax,0); + for ix:=0 to 8 do + begin + drawItem(inv.getItem(ix), inv.getSum(ix), (ix*16)+tmp_ax+ix*2+4, 1, true); + end; + drawimage(gui[17],(invslot*16)+tmp_ax+invslot*2+2,0); + + if gamemode<>1 then + begin + if gamemode=0 then + begin + for ix:=0 to (hp div 2)-1 do drawimage(gui[13],ix*9,getHeight-9); + if (hp mod 2)<>0 then begin drawimage(gui[14],ix*9,getHeight-9); ix:=ix+1 end; + for ix:=ix to 9 do drawimage(gui[15],ix*9,getHeight-9); + end; else + if gamemode=2 then + begin + for ix:=0 to (hp div 2)-1 do drawimage(gui[31],ix*9,getHeight-9); + if (hp mod 2)<>0 then begin drawimage(gui[32],ix*9,getHeight-9); ix:=ix+1 end; + for ix:=ix to 9 do drawimage(gui[33],ix*9,getHeight-9); + end; + + for ix:=0 to (hunger div 2)-1 do drawimage(gui[26],ix*9,getHeight-18); + if (hunger mod 2)<>0 then begin drawimage(gui[27],ix*9,getHeight-18); ix:=ix+1 end; + for ix:=ix to 9 do drawimage(gui[28],ix*9,getHeight-18); + + if getmap((x+4)/16,y/16)=50 then + begin + for ix:=0 to (air div 2)-1 do drawimage(gui[29],ix*9,getHeight-27); + if (air mod 2)<>0 then begin drawimage(gui[30],ix*9,getHeight-27); ix:=ix+1 end; + end; + end; + + for ix:=0 to 3 do + begin + drawfonttext(msg[ix],0,getHeight-20-ix*9); + if getrelativetimems-msg_time[ix]>5000 then msg[ix]:=''; + end; + end; + end; + +procedure load_moon(path:string;phase:integer); + var + no:image; + begin + moon:=no; + if load_sm=1 then + begin + moon:=ld_tex('moon_phase_'+phase+'.png',path,'terrain/moon_phases/'); + end; else + if load_sm=2 then + begin + moon:=resize_image(ld_tex('moon_phase_'+phase+'.png',path,'terrain/moon_phases/'),(getWidth+getHeight)/5,(getWidth+getHeight)/5); + end; + end; + +procedure sleep; + var + i,ix,iy:integer; + begin + if game_time>300000 then + begin + if load_light_tex then + begin + keymode:=0; + i:=15; + while i>0 do + begin + for iy:=0 to getheight/16 do + for ix:=0 to getwidth/16 do + drawimage(light[i],ix*16,iy*16); + i:=i-1; + drawVideo; + delay(100); + end; + moon_phase:=moon_phase+1; + if moon_phase>7 then moon_phase:=0; + load_moon('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',moon_phase); + game_time:=50000; + last_sleep_x:=curx; + last_sleep_y:=cury-1; + i:=1; + while i<15 do + begin + draw; + for iy:=0 to getheight/16 do + for ix:=0 to getwidth/16 do + drawimage(light[i],ix*16,iy*16); + i:=i+1; + drawVideo; + delay(100); + end; + end; + else + begin + keymode:=0; + i:=0; + while i<=getheight do + begin + setcolor(0,0,0); + fillrect(0,0,getwidth,i); + i:=i+5; + drawVideo; + delay(50); + end; + moon_phase:=moon_phase+1; + if moon_phase>7 then moon_phase:=0; + load_moon('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',moon_phase); + game_time:=50000; + last_sleep_x:=curx; + last_sleep_y:=cury-1; + i:=0; + while i<=getheight do + begin + draw; + setcolor(0,0,0); + fillrect(0,i,getwidth,getheight); + i:=i+5; + drawVideo; + delay(50); + end; + end; + end; else create_msg('You can sleep only at night'); + end; + +procedure resetToolProgerss; + begin + toolus:=0; + toolind:=0; + end; + +procedure usetools(invcur, x, y:integer); + var + item, sum, block:integer; + begin + block:=getmap(x, y); + item:=inv.getItem(invcur); + sum:=inv.getSum(invcur); + + if gamemode=1 then + destroy_block_cr(block, x, y); + else + if (block>0) then + begin + if (getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) then + toolus:=toolus+getToolSpeed(item); + else + toolus:=toolus+1; + + if toolus>=getBlockHP(block) then + begin + if ((getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) and (getToolLvl(item)>=getBlockLvl(block))) or (getBlockLvl(block)<=0) then + begin + setMap(0, x, y); + destroy_block_1(block, x, y); + setMapInfo(0, x, y); + end; + else + begin + setMap(0, x, y); + destroy_block_0(block, x, y); + setMapInfo(0, x, y); + end; + + if getItemType(item)=ITEM_TYPE_TOOL then + begin + inv.setSum(inv.getSum(invcur)-1, invcur); + inv.fixNull(invcur); + end; + + toolus:=0; + toolind:=0; + end; + end; + + if (toolus>0) and (toolus<=getBlockHP(block)) then + toolind:=((toolus*100) div getBlockHP(block)) div 10; + end; + +function rt_useweap:boolean; + var + x, y, w, h, i, damg:integer; + item:integer; + begin + x:=player.getX; + y:=player.getY; + w:=player.getW; + h:=player.getH; + item:=inv.getItem(invslot); + + if getItemType(item)=1 then + damg:=getToolDamg(item); + else + damg:=1; + + if posi=0 then + i:=mob.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3); + else + i:=mob.findAndHit(damg, x+(w/2), y, TILE_SIZE+(w/2), h, 2, -3); + + if i<>-1 then + begin + inv.setSum(inv.getSum(invslot)-1, invslot); + inv.fixNull(invslot); + rt_useweap:=true; + end; + end; + +procedure rt_usetools; + var + x, y:integer; + begin + x:=player.getX; + y:=player.getY; + + if posi=0 then curx:=(x div 16)-1; else curx:=(x div 16)+1; + cury:=y div 16; + if getmap(curx,cury)=0 then cury:=cury+1; + + if curx<0 then curx:=0; + if curx>255 then curx:=255; + if cury<0 then cury:=0; + if cury>127 then cury:=127; + + usetools(invslot, curx, cury); + end; + +procedure rt_usemob; + var + x, y:integer; + begin + x:=player.getX; + y:=player.getY; + + if posi=0 then curx:=(x div 16)-1; else curx:=(x div 16)+1; + cury:=y div 16; + if getmap(curx,cury)=0 then cury:=cury+1; + + if curx<0 then curx:=0; + if curx>255 then curx:=255; + if cury<0 then cury:=0; + if cury>127 then cury:=127; + + //usemob(curx,cury); + end; + +procedure actionUse(invcur, x, y:integer); + begin + if setBlock(invcur, x, y)=false then + if useBlock(invcur, x, y) then + if useItem(invcur, x, y) then + end; + +procedure rt_useblock; + var + x, y:integer; + begin + x:=player.getX; + y:=player.getY; + + if posi=0 then curx:=(x div 16)-1; else curx:=(x div 16)+1; + cury:=y div 16; + if getmap(curx,cury)=0 then cury:=cury+1; + + if curx<0 then curx:=0; + if curx>255 then curx:=255; + if cury<0 then cury:=0; + if cury>127 then cury:=127; + + actionUse(invslot, curx, cury); + end; + +procedure go_to_nether; + var + ix:integer; + begin + portal_time:=getrelativetimems; + savegame('/'+sd+'/cavecraft/saves/'+sav_fl+'/'); + pl_world:=1; + drw_load_line('Matrix',10); + if loadworld('/'+sd+'/cavecraft/saves/'+sav_fl+'/')=true then + begin + player.setX(get_spawn_x*16+4); + player.setY((get_up(get_spawn_x)-1)*16); + end; + else + begin + {for ix:=0 to 31 do + begin + mob[ix].m_type:=0; + mob[ix].m_x:=0; + mob[ix].m_y:=0; + mob[ix].m_posi:=0; + mob[ix].m_velx:=0; + mob[ix].m_vely:=0; + mob[ix].m_ani:=0; + mob[ix].m_min_vely:=0; + mob[ix].m_hp:=0; + mob[ix].m_del:=0; + mob[ix].m_fall:=false; + mob[ix].m_jmp:=false; + mob[ix].m_velani:=false; + end;} + + drop.resetData; + gennether; + //netherspawn; + end; + end; + +procedure go_to_world; + begin + portal_time:=getrelativetimems; + savegame('/'+sd+'/cavecraft/saves/'+sav_fl+'/'); + pl_world:=0; + drw_load_line('Matrix',10); + if loadworld('/'+sd+'/cavecraft/saves/'+sav_fl+'/')=true then + begin + pl_world:=0; + end; + else + begin + debug('ERROR!!!'); + pl_world:=0; + genworld; + //megaspawn; + end; + end; + +procedure plr_is_dead_hardcore; + begin + keymode:=0; + toolus:=0; + toolind:=0; + + repeat + updateKeys; + if clickedKey(KEY_MENU_SELECT) then + begin + deleteworld('/'+sd+'/cavecraft/saves/'+sav_fl+'/'); + menu; + exit; + end; + draw; + drawfonttext('You died!',getwidth/2-32,getheight/2-16); + + drw_btn('Delete world',0,0,0,1); + + drawVideo; + delay(1); + until false; + + end; + +procedure plr_is_dead; + var + m_cur:integer; + x, y:integer; + begin + x:=player.getX; + y:=player.getY; + keymode:=0; + toolus:=0; + toolind:=0; + repeat + updateKeys; + if clickedKey(KEY_MENU_UP) then + begin + m_cur:=m_cur-1; + if m_cur<0 then m_cur:=1; + end; + if clickedKey(KEY_MENU_DOWN) then + begin + m_cur:=m_cur+1; + if m_cur>1 then m_cur:=0; + end; + if clickedKey(KEY_MENU_SELECT) then + begin + if m_cur=0 then + begin + if pl_world=0 then + begin + if last_sleep_x=0 then + begin + x:=get_spawn_x*16+4; + y:=get_spawn_y*16; + end; else + begin + x:=last_sleep_x*16+4; + y:=last_sleep_y*16; + end; + end; else + if pl_world=1 then + begin + go_to_world; + if last_sleep_x=0 then + begin + x:=get_spawn_x*16+4; + y:=get_spawn_y*16; + end; else + begin + x:=last_sleep_x*16+4; + y:=last_sleep_y*16; + end; + end; + posi:=0; + curx:=0; + cury:=0; + vely:=0; + jmp:=false; + hp:=20; + hunger:=20; + exit; + end; + else + if m_cur=1 then begin menu; exit; end; + end; + + draw; + + drawfonttext('You died!',getwidth/2-32,getheight/2-16); + + drw_btn('Respawn',0,m_cur,0,1); + drw_btn('Main menu',1,m_cur,0,1); + + drawVideo; + delay(1); + until false; + end; + +procedure fast_menu; + var + m_cur,i:integer; + begin + repeat + updateKeys; + if clickedKey(KEY_MENU_UP) then begin m_cur:=m_cur-1; if m_cur<0 then m_cur:=3; end; + if clickedKey(KEY_MENU_DOWN) then begin m_cur:=m_cur+1; if m_cur>3 then m_cur:=0; end; + if clickedKey(KEY_MENU_SELECT) then + begin + if m_cur=0 then + begin + exit; + end; else + if m_cur=1 then + begin + savegame('/'+sd+'/cavecraft/saves/'+sav_fl+'/'); + exit; + end; else + if m_cur=2 then + begin + menu_sett; + end; else + if m_cur=3 then + begin + //clear_gui(keymode); + menu; + exit; + end; + end; + draw; + drawfonttext('Game menu',getwidth/2-36,getheight/2-20); + drw_btn('Back to Game',0,m_cur,0,1); + drw_btn('Save Game',1,m_cur,0,1); + drw_btn('Options',2,m_cur,0,1); + drw_btn('Quit to Title',3,m_cur,0,1); + + drawVideo; + delay(1); + until false; + end; + +procedure keyFastInv; + begin + if clickedKey(KEY_FASTINV_NEXT) then + begin + invslot:=invslot-1; + if invslot<0 then + invslot:=8; + end; + + if clickedKey(KEY_FASTINV_PREV) then + begin + invslot:=invslot+1; + if invslot>8 then + invslot:=0; + end; + end; + +procedure keyConsole; + begin + if clickedKey(KEY_CHAT) then + SetTimer(1000,T_CONSOLE); + + if pressedKey(KEY_CHAT) then + begin + if GetTimer(T_CONSOLE)=TIMER_OK then + begin + call_console; + ResetTimer(T_CONSOLE); + end; + end; + else + begin + if GetTimer(T_CONSOLE)>TIMER_OK then + begin + deb:= not deb; + ResetTimer(T_CONSOLE); + end; + end; + end; + +procedure keyInventory; + begin + if clickedKey(KEY_PLR_OPENINV) then + if gamemode<>1 then + OpenPlayerInventory; + else + OpenCreativeWindow; + end; + +procedure keyhandler; + begin + updateKeys; + + if WindowKeyHanler then + begin + if keymode=0 then + begin + keyInventory; + keyFastInv; + keyConsole; + + if clickedKey(KEY_PLR_EDITMODE) then + begin + keymode:=1; + curx:=player.getX div 16; + cury:=player.getY div 16; + end; + + if clickedKey(KEY_PLR_USE) then + rt_usemob; + + if clickedKey(KEY_MENU) then + fast_menu; + + if clickedKey(KEY_PLR_ATTACK) then + if rt_useweap=false then + debug('useweap'); + + if pressedKey(KEY_PLR_ATTACK) then + begin + rt_usetools; + playAnim(ANIM_HAND); + end; + else + begin + resetToolProgerss; + cancelAnim(ANIM_HAND); + end; + + if pressedKey(KEY_PLR_UP) then + player.gotoUP; + if pressedKey(KEY_PLR_DOWN) then + player.gotoDOWN; + if pressedKey(KEY_PLR_LEFT) then + player.gotoLEFT; + if pressedKey(KEY_PLR_RIGHT) then + player.gotoRIGHT; + end; + else + if keymode=1 then + begin + keyInventory; + keyFastInv; + keyConsole; + + if clickedKey(KEY_PLR_UP) then + begin + cury:=cury-1; + if cury<0 then + cury:=0; + end; + if clickedKey(KEY_PLR_DOWN) then + begin + cury:=cury+1; + if cury>127 then + cury:=127; + end; + if clickedKey(KEY_PLR_LEFT) then + begin + curx:=curx-1; + if curx<0 then + curx:=0; + end; + if clickedKey(KEY_PLR_RIGHT) then + begin + curx:=curx+1; + if curx>255 then + curx:=255; + end; + + if clickedKey(KEY_PLR_EDITMODE) then + keymode:=0; + + if clickedKey(KEY_PLR_USE) then + actionUse(invslot, curx, cury); + + if pressedKey(KEY_PLR_ATTACK) then + begin + usetools(invslot, curx, cury); + playAnim(ANIM_HAND); + end; + else + begin + resetToolProgerss; + cancelAnim(ANIM_HAND); + end; + + if clickedKey(KEY_MENU) then + fast_menu; + end; + + end; + + end; + +procedure phyhandler; + var + i:integer; + begin + player.calcPhysics; + mob.updatePhy; + drop.calcPhy; + end; + +procedure light_fillrect(l,x,y,r:integer); + var + ix,iy,ym,yp,xm,xp:integer; + begin + ym:=y-r; + yp:=y+r; + xm:=x-r; + xp:=x+r; + for ix:=xm to xp do + for iy:=ym to yp do + setmaplight(getmaplight(ix,iy)+l,ix,iy); + end; + +procedure light_rect(l,x,y,r:integer); + var + ix,iy,ym,yp,xm,xp:integer; + begin + ym:=y-r; + yp:=y+r; + xm:=x-r; + xp:=x+r; + for ix:=xm to xp do + begin + setmaplight(getmaplight(ix,ym)+l,ix,ym); + setmaplight(getmaplight(ix,yp)+l,ix,yp); + end; + for iy:=ym+1 to yp-1 do + begin + setmaplight(getmaplight(xm,iy)+l,xm,iy); + setmaplight(getmaplight(xp,iy)+l,xp,iy); + end; + end; + +procedure calc_light(m,x,y:integer); + var + ix,iy,l,ss,sf:integer; + begin + if light_type=1 then light_fillrect(m,x,y,m/2); else + for l:=m downto 1 do + begin + if ss mod 2=0 then light_rect(l,x,y,ss/2); + ss:=ss+1; + end; + end; + +procedure calc_sun(ix,m:integer); + var + iy,ss:integer; + begin + ss:=m; + for iy:=0 to 127 do + begin + setmaplight(ss,ix,iy); + if ss=0 then break; + ss:=ss-getBlockTr(getmap(ix,iy)); + if ss<0 then ss:=0; + end; + for iy:=iy+1 to 127 do + begin + setmaplight(0,ix,iy); + end; + end; + +procedure kill_plr; + var + i:integer; + begin + hp:=0; + for i:=0 to INV_SIZE do + begin + if inv.isNull(i)=false then + player.dropItem(inv.getItem(i), inv.getSum(i)); + inv.setItem(0, i); + inv.setSum(0, i); + end; + if gamemode<2 then plr_is_dead; else plr_is_dead_hardcore; + end; + +procedure hunger_and_air; + var + x, y:integer; + begin + x:=player.getX; + y:=player.getY; + if gamemode<>1 then + begin + if getrelativetimems-hung_time>=90000/(gamemode+1) then + begin + hung_time:=getrelativetimems; + hunger:=hunger-1; + end; + if getrelativetimems-hp_time>=5000*(gamemode+1) then + begin + if hunger>16 then + begin + hp_time:=getrelativetimems; + hp:=hp+1; + if hp>20 then hp:=20; + end; else + if hunger<1 then + begin + hp_time:=getrelativetimems; + hp:=hp-1; + if hp<1 then if gamemode<2 then hp:=1; + end; + end; + + if getmap((x+4)/16,y/16)=50 then + begin + if getrelativetimems-air_time>=500 then + begin + air:=air-1; + air_time:=getrelativetimems; + if air<1 then + begin + hp_time:=getrelativetimems; + hp:=hp-2; + end; + end; + end; else + air:=21; + end; + end; + +procedure game; + var + ix,iy,minx,maxx,miny,maxy,fps_t,tim, x, y:integer; + begin + x:=player.getX; + y:=player.getY; + + hunger_and_air; + + if hunger<0 then hunger:=0; + if air<0 then air:=0; + + fps_t:=fps; + if fps_t<1 then fps_t:=1; + + if bl_ani5_d then + if bl_ani5_v=false then + begin + bl_ani5:=bl_ani5+1; + if bl_ani5>4 then + begin + bl_ani5:=4; + bl_ani5_v:=not bl_ani5_v; + end; + end; + else + begin + bl_ani5:=bl_ani5-1; + if bl_ani5<0 then + begin + bl_ani5:=0; + bl_ani5_v:=not bl_ani5_v; + end; + end; + bl_ani5_d:=not bl_ani5_d; + + drop.reflux; + player.getDrop; + + game_time:=game_time+(600000 div (fps_t*1000)); + + if (game_time>600000) or (game_time<0) then + begin + game_time:=0; + moon_phase:=moon_phase+1; + if moon_phase>7 then moon_phase:=0; + load_moon('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',moon_phase); + end; + + tim:=10000*getimagewidth(sky)/600000*game_time/10000; + global_light:=effects.get(sky,tim,1,1) {and $F}; + + if clock_stage<>game_time div 75000 then begin clock_stage:=clock_stage+1; if clock_stage>7 then clock_stage:=0; end; + + if x<0 then x:=0; + if x+8>4094 then x:=4086; + if getBlockColl(getmap(x div 16, y div 16))>0 then hp:=hp-1; + if random(4096)=random(4096) then begin osadki:=not osadki; end; + osadki_ani:=osadki_ani+1; + if osadki_ani>7 then osadki_ani:=0; + + if random(20)=random(20) then create_particle(6,x,y); + + if gamemode=1 then begin hp:=666; hunger:=666; end; + + if inv.getItem(invslot)=186 then + ifminimap:=true; + else + ifminimap:=false; + + //if s_spawn_mob then if random(4096)=1547 then megaspawn; + + mob.update; + + if particle_upd then update_particle; + + if light_type>0 then + begin + minx:=camx/16-1; + maxx:=(camx+getWidth)/16+1; + if minx<0 then minx:=0; + if maxx>255 then maxx:=255; + for ix:=minx to maxx do calc_sun(ix,global_light); + end; + + minx:=camx/16-8; + maxx:=(camx+getWidth)/16+16; + miny:=camy/16-8; + maxy:=(camy+getHeight)/16+16; + if minx<0 then minx:=0; + if maxx>255 then maxx:=255; + if miny<0 then miny:=0; + if maxy>127 then maxy:=127; + for ix:=minx to maxx do + for iy:=miny to maxy do + begin + if light_type=0 then setmaplight(15,ix,iy); + else + if light_type>0 then if getBlockLi(getmap(ix,iy))>0 then calc_light(getBlockLi(getmap(ix,iy)),ix,iy); + end; + + minx:=(camx/16)-((getwidth/2)/16); + miny:=(camy/16)-((getheight/2)/16); + maxx:=(camx+(getWidth+getWidth/2))/16; + maxy:=(camy+(getHeight+getHeight/2))/16; + if minx<0 then minx:=0; + if miny<0 then miny:=0; + if maxx>255 then maxx:=255; + if maxy>127 then maxy:=127; + if updxmaxx then updx:=minx; + if updy>maxy then updy:=miny; + + if bl_upd>0 then + begin + for ix:=0 to (((2*getWidth/16)*(2*getHeight/16))-1) div ((fps_t*bl_upd)) do + begin + updateBlock(updx, updy); + updx:=updx+1; + if updx>maxx then + begin + updx:=minx; + updy:=updy+1; + if updy>maxy then updy:=miny; + end; + end; + end; + + {if coll_bl(110)=true then + begin + if getrelativetimems-portal_time>5000 then + begin + if pl_world=0 then begin go_to_nether; portal_time:=getrelativetimems; end; else + if pl_world=1 then begin go_to_world; portal_time:=getrelativetimems; end; + end; + end; + + if coll_bl(51)=true then hp:=hp-1; + + if coll_bl(59)=true then + begin + if vely<0 then vely:=-1; + else + if vely>0 then vely:=1; + end;} + + if gamemode<>1 then + begin + if hp>20 then hp:=20; + if hunger>20 then hunger:=20; + end; + + if y>2048 then kill_plr; + if (hp<1) and (gamemode<>1) then kill_plr; + if fish=true then fishing; + + if (fish=true) and (inv.getItem(invslot)<>152) then fish:=false; + + //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; + + if gamemode<>1 then + begin + if cury<(y div 16)-4 then cury:=(y div 16)-4; + if cury>(y div 16)+5 then cury:=(y div 16)+5; + if curx<(x div 16)-4 then curx:=(x div 16)-4; + if curx>(x div 16)+4 then curx:=(x div 16)+4; + end; + + UpdateFurnaces; + end; + +procedure qt_start; + var + i:integer; + begin + drawgui:=true; + LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); + drawdeadlogo; + start_uu; + if load_key_tex=1 then init_touch; + for i:=0 to 4 do + begin + msg[i]:=''; + msg_time[i]:=getrelativetimems; + end; + InitMap(MAP_W, MAP_H); + menu; + end; + +begin + qt_start; + hung_time:=getrelativetimems; + hp_time:=getrelativetimems; + air_time:=getrelativetimems; + portal_time:=getrelativetimems; + repeat + proc_fps; + keyhandler; + phyhandler; + game; + draw; + drawfonttext(version,getWidth-(length(version)*8),getHeight-8); + 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; + if deb=true then + begin + //drawfonttext('X:'+(x div 16-128),0,0); + //drawfonttext('Y:'+integertostring(127-(y div 16)),0,8); + drawfonttext('CURX:'+(curx-128),0,16); + drawfonttext('CURY:'+cury,0,24); + drawfonttext('UPDX:'+updx,0,32); + drawfonttext('UPDY:'+updy,0,40); + drawfonttext('FPS:'+fps,0,56); + drawfonttext('Free RAM:'+free_ram/1024+' KB',0,64); + drawfonttext('Total RAM:'+memory.get_totalmemory div 1024+' KB',0,72); + drawfonttext('SEED:'+seed,0,88); + drawfonttext('Game time:'+game_time,0,96); + end; + + drawVideo; + maxfps; + + until false; +end. diff --git a/src/cellui.mpsrc b/src/cellui.mpsrc new file mode 100644 index 0000000..070ea0e --- /dev/null +++ b/src/cellui.mpsrc @@ -0,0 +1,491 @@ +unit cellui; + +interface + const + CONST_MAX_LAYERS=1; + CONST_MAX_CELLS=63; + CONST_MAX_OFFSETS=1; + CONST_MAX_CURS=1; + CONST_MAX_INFO=2; + + CELL_TYPE_NULL=0; + CELL_TYPE_PLAYER_INV=1; + CELL_TYPE_CREWATIVE_INV=2; + CELL_TYPE_CHEST=3; + CELL_TYPE_FASTCRAFT=4; + CELL_TYPE_FURNACE=5; + + CELL_FLAG_OFFSET=$F; + CELL_FLAG_INDICATOR=$10; + + CUR_SELECT1=0; + CUR_SELECT2=1; + + WINDOW_NULL=0; + + FIND_CELL_UP=0; + FIND_CELL_DOWN=1; + FIND_CELL_LEFT=2; + FIND_CELL_RIGHT=3; + + CELL_W=16; + CELL_H=16; + + procedure ClearLayer(n:integer); + procedure LoadCurImg(img:image; i:integer;); + + procedure NewLayer; + procedure DelLayer; + function CellLayer:integer; + procedure setCellLayer(n:integer); + + procedure initCell(cell_type, id, offset, data, x, y:integer; indicator:boolean;); + function getCellID(i:integer):integer; + function getCellData(i:integer):integer; + function getCellX(i:integer):integer; + function getCellY(i:integer):integer; + procedure setOffset(newOffset, i:integer;);//i - номер смещения + function getOffset(i:integer):integer;//i - номер смещения + function getCellOffset(i:integer):integer; + + function getItem(i:integer):integer; + procedure setItem(val, i:integer); + function getSum(i:integer):integer; + procedure setSum(val, i:integer); + procedure fixNullCell(i:integer;); + + procedure DrawCellLayer(i, x, y:integer); + + procedure SetWindowInfo(n, i:integer); + function GetWindowInfo(i:integer):integer; + procedure SetCur(i:integer); + function GetCur:integer; + + procedure SetCurIndex(n, i:integer); + function GetCurIndex(i:integer):integer; + procedure SetCurActive(n:boolean; i:integer); + function GetCurActive(i:integer):boolean; + procedure SetWindowType(wtype:integer); + function GetWindowType:integer; + + procedure DrawCursors(n, x, y:integer); + + procedure ShiftCurrentCur(find:integer;); + + function FindCurrentWindowsType:boolean; + +implementation + uses vars, Canvas, items, console, furnace, chest, inv, func, items_store; + var + layer:integer; + last_cell: array [0..CONST_MAX_LAYERS] of integer; + inv_type: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer;//Name of virtual massive + inv_id: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer;//ID of real item massive + inv_x, inv_y: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer; + inv_data: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer; + inv_flags: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CELLS] of integer; + + inv_offset: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_OFFSETS] of integer;//Offset of real item id in inventory + + WindowType: array [0..CONST_MAX_LAYERS] of integer; + WindowInfo: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_INFO] of integer; + + WindowCurCurrent: array [0..CONST_MAX_LAYERS] of integer; + WindowCurImg: array [0..CONST_MAX_CURS] of image; + WindowCurIndex: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CURS] of integer; + WindowCurActive: array [0..CONST_MAX_LAYERS, 0..CONST_MAX_CURS] of boolean; + +{=====[Inventory interface functions]=====} + procedure ClearLayer(n:integer); + var + i:integer; + begin + for i:=0 to CONST_MAX_CELLS do + begin + last_cell[n]:=0; + inv_type[n, i]:=CELL_TYPE_NULL; + inv_id[n, i]:=0; + inv_x[n, i]:=0; + inv_y[n, i]:=0; + inv_data[n, i]:=0; + inv_flags[n, i]:=0; + end; + + for i:=0 to CONST_MAX_OFFSETS do + inv_offset[n, i]:=0; + + WindowType[n]:=WINDOW_NULL; + WindowCurCurrent[n]:=0; + for i:=0 to CONST_MAX_INFO do + WindowInfo[n, i]:=0; + for i:=0 to CONST_MAX_CURS do + begin + WindowCurIndex[n, i]:=0; + WindowCurActive[n, i]:=false; + end; + end; + + procedure LoadCurImg(img:image; i:integer;); + begin + WindowCurImg[i]:=img; + end; + + procedure NewLayer; + begin + layer:=layer+1; + end; + + procedure DelLayer; + begin + ClearLayer(layer); + layer:=layer-1; + end; + + function CellLayer:integer; + begin + CellLayer:=layer; + end; + + procedure setCellLayer(n:integer); + begin + layer:=n; + end; + + procedure initCell(cell_type, id, offset, data, x, y:integer; indicator:boolean;); + var + i:integer; + begin + i:=last_cell[layer]; + last_cell[layer]:=last_cell[layer]+1; + + inv_type[layer, i]:=cell_type; + inv_id[layer, i]:=id; + inv_x[layer, i]:=x; + inv_y[layer, i]:=y; + inv_data[layer, i]:=data; + + inv_flags[layer, i]:=(offset and CELL_FLAG_OFFSET); + + if indicator then + inv_flags[layer, i]:=inv_flags[layer, i] or CELL_FLAG_INDICATOR; + end; + + function getCellType(i:integer):integer; + begin + getCellType:=inv_type[layer, i]; + end; + + function getCellX(i:integer):integer; + begin + getCellX:=inv_x[layer, i]; + end; + + function getCellY(i:integer):integer; + begin + getCellY:=inv_y[layer, i]; + end; + + function getCellID(i:integer):integer; + begin + getCellID:=inv_id[layer, i]; + end; + + function getCellData(i:integer):integer; + begin + getCellData:=inv_data[layer, i]; + end; + + function getCellFlagIndicator(i, j:integer):boolean; + begin + getCellFlagIndicator:=(inv_flags[i, j] and CELL_FLAG_INDICATOR)>0; + end; + + procedure setOffset(newOffset, i:integer;); + begin + inv_offset[layer, i]:=newOffset; + end; + + function getOffset(i:integer):integer; + begin + getOffset:=inv_offset[layer, i]; + end; + + function getCellOffset(i:integer):integer; + begin + getCellOffset:=inv_flags[layer, i] and CELL_FLAG_OFFSET; + end; + + function getItemIdx(i, n:integer):integer; + var + id, data, _type:integer; + begin + id:=inv_id[n, i]+inv_offset[n, inv_flags[n, i] and CELL_FLAG_OFFSET]; + _type:=inv_type[n, i]; + data:=inv_data[n, i]; + + if _type=CELL_TYPE_PLAYER_INV then + getItemIdx:=inv.getItem(id); + else + if _type=CELL_TYPE_CREWATIVE_INV then + getItemIdx:=getItemList(id); + else + if _type=CELL_TYPE_CHEST then + getItemIdx:=chest.getItem(id, data); + else + if _type=CELL_TYPE_FASTCRAFT then + getItemIdx:=getCraftOutItem(id); + else + if _type=CELL_TYPE_FURNACE then + getItemIdx:=GetFurItem(id, data); + end; + + procedure setItemIdx(val, i, n:integer); + var + id, data, _type:integer; + begin + id:=inv_id[n, i]+inv_offset[n, inv_flags[n, i] and CELL_FLAG_OFFSET]; + _type:=inv_type[n, i]; + data:=inv_data[n, i]; + + if _type=CELL_TYPE_PLAYER_INV then + inv.setItem(val, id); + else + if _type=CELL_TYPE_CHEST then + chest.setItem(val, id, data); + else + if _type=CELL_TYPE_FURNACE then + SetFurItem(val, id, data); + end; + + function getSumIdx(i, n:integer):integer; + var + id, data, _type:integer; + begin + id:=inv_id[n, i]+inv_offset[n, inv_flags[n, i] and CELL_FLAG_OFFSET]; + _type:=inv_type[n, i]; + data:=inv_data[n, i]; + + if _type=CELL_TYPE_PLAYER_INV then + getSumIdx:=inv.getSum(id); + else + if _type=CELL_TYPE_CREWATIVE_INV then + getSumIdx:=getItemMax(getItemList(id)); + else + if _type=CELL_TYPE_CHEST then + getSumIdx:=chest.getSum(id, data); + else + if _type=CELL_TYPE_FASTCRAFT then + getSumIdx:=getCraftOutSum(id); + else + if _type=CELL_TYPE_FURNACE then + getSumIdx:=GetFurSum(id, data); + end; + + procedure setSumIdx(val, i, n:integer); + var + id, data, _type:integer; + begin + id:=inv_id[n, i]+inv_offset[n, inv_flags[n, i] and CELL_FLAG_OFFSET]; + _type:=inv_type[n, i]; + data:=inv_data[n, i]; + + if _type=CELL_TYPE_PLAYER_INV then + inv.setSum(val, id); + else + if _type=CELL_TYPE_CHEST then + chest.setSum(val, id, data); + else + if _type=CELL_TYPE_FURNACE then + SetFurSum(val, id, data); + end; + + //i - индекс в таблице ячеек + function getItem(i:integer):integer; + begin + getItem:=getItemIdx(i, CellLayer); + end; + + procedure setItem(val, i:integer); + begin + setItemIdx(val, i, CellLayer); + end; + + function getSum(i:integer):integer; + begin + getSum:=getSumIdx(i, CellLayer); + end; + + procedure setSum(val, i:integer); + begin + setSumIdx(val, i, CellLayer); + end; + + procedure fixNullCell(i:integer); + begin + if (getItem(i)<1) or (getSum(i)<1) then + begin + setItem(0, i); + setSum(0, i); + end; + end; + + procedure DrawCellLayer(i, x, y:integer); + var + j:integer; + begin + for j:=0 to CONST_MAX_CELLS do + if inv_type[i, j]<>CELL_TYPE_NULL then + begin + drawItem(getItemIdx(j, i), getSumIdx(j, i), x+inv_x[i, j], y+inv_y[i, j], getCellFlagIndicator(i, j)); + end; + end; + +{======[]======} + + procedure SetWindowInfo(n, i:integer); + begin + WindowInfo[CellLayer, i]:=n; + end; + + function GetWindowInfo(i:integer):integer; + begin + GetWindowInfo:=WindowInfo[CellLayer, i]; + end; + + procedure SetCur(i:integer); + begin + WindowCurCurrent[CellLayer]:=i; + end; + + function GetCur:integer; + begin + GetCur:=WindowCurCurrent[CellLayer]; + end; + + procedure SetCurIndex(n, i:integer); + begin + WindowCurIndex[CellLayer, i]:=n; + end; + + function GetCurIndex(i:integer):integer; + begin + GetCurIndex:=WindowCurIndex[CellLayer, i]; + end; + + procedure SetCurActive(n:boolean; i:integer); + begin + WindowCurActive[CellLayer, i]:=n; + end; + + function GetCurActive(i:integer):boolean; + begin + GetCurActive:=WindowCurActive[CellLayer, i]; + end; + + procedure SetWindowType(wtype:integer); + begin + WindowType[CellLayer]:=wtype; + end; + + function GetWindowType:integer; + var + tmp:integer; + begin + tmp:=CellLayer; + if CellLayer<0 then + GetWindowType:=WINDOW_NULL; + else + GetWindowType:=WindowType[CellLayer]; + end; + + function FindCurrentWindowsType:boolean; + var + crrwt, i:integer; + begin + crrwt:=GetWindowType; + for i:=0 to CONST_MAX_LAYERS do + if (WindowType[i]=crrwt) and (i<>CellLayer) then + begin + FindCurrentWindowsType:=true; + exit; + end; + end; + + procedure DrawCursors(n, x, y:integer); + var + i, idx:integer; + begin + for i:=0 to CONST_MAX_CURS do + if WindowCurActive[n, i] then + begin + idx:=WindowCurIndex[n, i]; + DrawImage(WindowCurImg[i], x+inv_x[n, idx], y+inv_y[n, idx]); + end; + end; + + procedure ShiftCurrentCur(find:integer;); + var + find_i, find_x, find_y:integer; + res_i, res_x, res_y:integer; + i, tmp_x, tmp_y:integer; + begin + find_i:=GetCurIndex(GetCur); + find_x:=getCellX(find_i); + find_y:=getCellY(find_i); + res_i:=find_i; + if find=FIND_CELL_UP then + res_y:=-2147483647; + if find=FIND_CELL_DOWN then + res_y:=2147483647; + if find=FIND_CELL_LEFT then + res_x:=-2147483647; + if find=FIND_CELL_RIGHT then + res_x:=2147483647; + + for i:=0 to CONST_MAX_CELLS do + if (getCellType(i)<>CELL_TYPE_NULL) and (i<>find_i) then + begin + tmp_x:=getCellX(i); + tmp_y:=getCellY(i); + //debug('['+i+']: tmp_y='+tmp_y+'; res_y='+res_y+';'); + if find=FIND_CELL_UP then + begin + if (tmp_yres_y) and (tmp_x>=find_x-CELL_W/2) and (tmp_x<=find_x+CELL_W+CELL_W/2) then + res_i:=i; + end; + + if find=FIND_CELL_DOWN then + begin + if ((tmp_y>find_y) and (tmp_y=find_x-CELL_W/2) and (tmp_x<=find_x+CELL_W+CELL_W/2) then + res_i:=i; + end; + + if find=FIND_CELL_LEFT then + begin + //debug('LEFT ['+i+']: tmp_x='+tmp_x+'; find_x='+find_x+'; res_x='+res_x+';'); + if (tmp_xres_x) and (tmp_y>=find_y-CELL_H/2) and (tmp_y<=find_y+CELL_H+CELL_H/2) then + res_i:=i; + end; + + if find=FIND_CELL_RIGHT then + begin + //debug('RIGHT ['+i+']: tmp_x='+tmp_x+'; find_x='+find_x+'; res_x='+res_x+';'); + if (tmp_x>find_x) and (tmp_x=find_y-CELL_H/2) and (tmp_y<=find_y+CELL_H+CELL_H/2) then + res_i:=i; + end; + + + if res_i<>find_i then + begin + res_x:=getCellX(res_i); + res_y:=getCellY(res_i); + end; + end; + SetCurIndex(res_i, GetCur); + end; + +initialization + layer:=-1; + WindowCurImg[0]:=loadimage('/terrain/sun.png'); + WindowCurImg[1]:=loadimage('/terrain/moon_phases/moon_phase_0.png'); +end. diff --git a/src/chest.mpsrc b/src/chest.mpsrc new file mode 100644 index 0000000..fbd17a8 --- /dev/null +++ b/src/chest.mpsrc @@ -0,0 +1,128 @@ +unit chest; + +interface + const + MAX_CHEST=31; + + function create(x, y:integer):integer; + procedure destroy(drp:boolean; x, y:integer); + + function getItem(n, i:integer):integer; + function getSum(n, i:integer):integer; + procedure setItem(val, n, i:integer); + procedure setSum(val, n, i:integer); + + procedure resetData; + procedure saveData; + procedure loadData; + +implementation + uses maps, drop, vars, jsr75i, func; + const + MAX_CELL=26; + CHEST_ERROR=-1; + var + chest_b: array [0..MAX_CHEST] of boolean; + chest_item, chest_sum: array [0..MAX_CELL, 0..MAX_CHEST] of integer; + + function getItem(n, i:integer):integer; + begin + getItem:=chest_item[n, i]; + end; + + function getSum(n, i:integer):integer; + begin + getSum:=chest_sum[n, i]; + end; + + procedure setItem(val, n, i:integer); + begin + chest_item[n, i]:=val; + end; + + procedure setSum(val, n, i:integer); + begin + chest_sum[n, i]:=val; + end; + + function create(x, y:integer):integer; + var + i, j:integer; + begin + for i:=0 to MAX_CHEST do + if chest_b[i]=false then + begin + chest_b[i]:=true; + for j:=0 to MAX_CELL do + begin + setItem(0, j, i); + setSum(0, j, i); + end; + setMapInfo(i, x, y); + create:=i; + exit; + end; + create:=CHEST_ERROR; + end; + + procedure destroy(drp:boolean; x, y:integer); + var + i, j:integer; + begin + i:=getMapInfo(x, y); + chest_b[i]:=false; + for j:=0 to MAX_CELL do + begin + if drp then + drop.create(getItem(j, i), getSum(j, i), x*16+4, y*16+4); + setItem(0, j, i); + setSum(0, j, i); + end; + end; + + procedure resetData; + var + i, j:integer; + begin + for i:=0 to MAX_CHEST do + begin + chest_b[i]:=false; + for j:=0 to MAX_CELL do + begin + setItem(0, j, i); + setSum(0, j, i); + end; + end; + end; + + procedure saveData; + var + i, j:integer; + begin + for i:=0 to MAX_CHEST do + begin + writebool(chest_b[i]); + for j:=0 to MAX_CELL do + begin + write_byte(getItem(j, i)); + writeint(getSum(j, i)); + end; + end; + end; + + procedure loadData; + var + i, j:integer; + begin + for i:=0 to MAX_CHEST do + begin + chest_b[i]:=readbool; + for j:=0 to MAX_CELL do + begin + setItem(read_byte, j, i); + setSum(ReadInt, j, i); + end; + end; + end; + +end. diff --git a/src/console.pas b/src/console.pas new file mode 100644 index 0000000..d6fb2f3 --- /dev/null +++ b/src/console.pas @@ -0,0 +1,954 @@ +unit console; + +interface + const + version='BETA 8 FIX'; + var + osadki:boolean; + bl_upd:integer; + s_get_drp:boolean; + particle_upd:boolean; + drw_back:boolean; + drw_sm:boolean; + s_max_fps:integer; + s_jpeg_quality:integer; + drawgui:boolean; + light_type:integer; + + ifosad:boolean; + //s_particles:boolean; - module + + load_sm:integer; + load_sky_siz:integer; + load_back_tex:boolean; + load_weather_tex:boolean; + load_particles_tex:boolean; + load_light_tex:boolean; + load_gui_tex:boolean; + + menu_background:integer; + + load_minimap_tex:boolean; + + //load_key_tex:integer; + + drw_stars:boolean; + + cheats:boolean; + + sd:string; + + //max_particles:integer; - module + + procedure save_settings; + procedure load_settings; + procedure call_console; + procedure exec(s, search:string; acces:boolean); + procedure addToLog(str:string); + +implementation +uses keyboard,particles_store,vars,maps,items,canvas,mob,worldgen,jsr75i,particles,func, player,sensor, drop, inv, furnace, items_store, video; +const + CON_LOG_SIZE=9; + PARSER_MAX_STR=15; + MAX_IMGREG=2; +var + logSTR: array [0..CON_LOG_SIZE] of string; + lastCommand:string; + + parseStr:string; + EOFstr, ENDstr:boolean; + + stack: array [0..0] of integer; + stack_pointer:integer; + + autoexec_acces:boolean; + regimg:image; + + procedure resetStack(size:integer); + begin + stack_pointer:=0; + size:=size+1; + bytecode + iload 0; + newarray 10; + putstatic field 'console', 'stack', '[I'; + end; + end; + + procedure pushStack(i:integer;); + begin + stack[stack_pointer]:=i; + stack_pointer:=stack_pointer+1; + end; + + function popStack:integer; + begin + stack_pointer:=stack_pointer-1; + popStack:=stack[stack_pointer]; + end; + + procedure swapStack; + var + tmp:integer; + begin + tmp:=stack[stack_pointer-2]; + stack[stack_pointer-2]:=stack[stack_pointer-1]; + stack[stack_pointer-1]:=tmp; + end; + + procedure dupStack; + begin + stack[stack_pointer]:=stack[stack_pointer-1]; + stack_pointer:=stack_pointer+1; + end; + + procedure resetTmpImg; + var + nullimg:image; + begin + regimg:=nullimg; + end; + +procedure addToLog(str:string); + var + i:integer; + begin + debug('::'+str); + for i:=CON_LOG_SIZE-1 downto 0 do + logSTR[i+1]:=logSTR[i]; + logSTR[0]:=str; + end; + + procedure setTexture(img:image; name:string; i:integer); + begin + name:=UpCase(name); + if name='BLOCK' then + begin + tex[i]:=img; + tex8[i]:=resize_image(img, 8, 8); + end; + else + if name='ITEM' then + begin + item[i]:=img; + item8[i]:=resize_image(img, 8, 8); + end; + else + if name='VKEY' then + setVkeyImg(img, i); + else + addToLog('Error: unknown texture type "'+name+'"'); + end; + +procedure save_settings; + var + rs:recordstore; + t:integer; + begin + deleteRecordStore('S'); + rs:=openRecordStore('S'); + t:=addRecordStoreEntry(rs,version); + t:=addRecordStoreEntry(rs,''+light_type); + t:=addRecordStoreEntry(rs,''+ifosad); + t:=addRecordStoreEntry(rs,''+s_particles); + t:=addRecordStoreEntry(rs,''+drawgui); + t:=addRecordStoreEntry(rs,''+s_jpeg_quality); + t:=addRecordStoreEntry(rs,''+load_key_tex); + closeRecordStore(rs); + end; + +function sett_ld_bool(s:string):boolean; + begin + if s='true' then sett_ld_bool:=true; + end; + +procedure load_settings; + var + rs:recordstore; + begin + rs:=openRecordStore('S'); + if readRecordStoreEntry(rs,1)<>version then + begin + debug(readRecordStoreEntry(rs,1)); + closeRecordStore(rs); + exit; + end; + light_type:=stringtointeger(readRecordStoreEntry(rs,2)); + ifosad:=sett_ld_bool(readRecordStoreEntry(rs,3)); + s_particles:=sett_ld_bool(readRecordStoreEntry(rs,4)); + drawgui:=sett_ld_bool(readRecordStoreEntry(rs,5)); + s_jpeg_quality:=stringtointeger(readRecordStoreEntry(rs,6)); + load_key_tex:=stringtointeger(readRecordStoreEntry(rs,7)); + closeRecordStore(rs); + end; + +function isEOS(c:integer):boolean; + var + ch:char; + begin + ch:=chr(c); + if (ch=#$0A) or (ch=#$0D) then + isEOS:=true; + end; + +function isSpace(c:integer;):boolean; + var + ch:char; + begin + ch:=chr(c); + if ((ch=' ') or (ch=#$09) or (ch=#$0B) or isEOS(c)) then + isSpace:=true; + end; + +function nextByte(res:resource):integer; + var + i:integer; + begin + i:=ReadByte(res); + if i=EOF then + EOFstr:=true; + if isEOS(i) then + ENDstr:=true; + + nextByte:=i and $FF; + end; + +function ReadString(res:resource):string; + var + b:integer; + tmpstr:string; + begin + ENDstr:=false; + repeat + b:=nextByte(res); + if EOFstr or ENDstr then + break; + + tmpstr:=tmpstr+chr(b); + forever; + ReadString:=tmpstr; + end; + +function nextChar:integer; + var + i:integer; + begin + ENDstr:=false; + if length(parseStr)>0 then + begin + i:=ord(getChar(parseStr, 0)); + parseStr:=copy(parseStr, 1, length(parseStr)); + if isEOS(i) then + ENDstr:=true; + end; + else + begin + parseStr:=''; + ENDstr:=true; + end; + + nextChar:=i; + end; + +procedure clearSpaces; + var + i:integer; + begin + repeat + i:=nextChar; + if ENDstr then + exit; + + {Symbol ';' is one line commentary} + if i=$3B then + begin + repeat + i:=nextChar; + if ENDstr then + exit; + forever; + end; + + if isSpace(i)=false then + begin + //Go back + parseStr:=chr(i)+parseStr; + exit; + end; + forever; + end; + +function nextWord:string; + var + str:string; + i:integer; + begin + ENDstr:=false; + clearSpaces; + repeat + i:=nextChar; + + if ENDstr then + begin + nextWord:=str; + exit; + end; + + if isSpace(i) then + begin + //Go back + parseStr:=chr(i)+parseStr; + nextWord:=str; + exit; + end; + else + str:=str+chr(i); + forever; + end; + +function strToBool(str:string):boolean; + begin + str:=UpCase(str); + if str='TRUE' then + strToBool:=true; + else + if str='FALSE' then + strToBool:=true; + else + if StringToInteger(str)<>0 then + strToBool:=true; + else + strToBool:=false; + end; + +//Перевод строки в целое число. base - система счисления +function Str2Dec(str:string; base:integer;):integer; + var + i, tmp, res:integer; + ch:char; + neg:boolean; + begin + str:=UpCase(str); + if GetChar(str, 0)='-' then + begin + neg:=true; + i:=i+1; + end; + + for i:=i to length(str)-1 do + begin + ch:=GetChar(str, i); + if ((ch>='0') and (ch<='9')) then + tmp:=ord(ch)-$30; + else + if ((ch>='A') and (ch<=chr($36+base))) then + tmp:=ord(ch)-$37; + else + begin + addToLog('Error! I cant decode "'+str+'" -> "'+ch+'"'); + Str2Dec:=0; + exit; + end; + + res:=res*base+tmp; + end; + + if neg then + Str2Dec:=-res; + else + Str2Dec:=res; + end; + +function getVar(name:string):integer; + begin + name:=UpCase(name); + + if name='SCREEN_W' then + getVar:=getWidth; + else + if name='SCREEN_H' then + getVar:=getHeight; + else + addToLog('Unknown variable "'+name+'"'); + end; + +procedure setVar(name:string; value:integer); + begin + name:=UpCase(name); + + addToLog('I cant set variable "'+name+'"'); + end; + +function DecodeInt(str:string):integer; + var + head:char; + num:string; + begin + if str='' then + begin + addToLog('DecodeInt getted null string!'); + DecodeInt:=0; + exit; + end; + + str:=UpCase(str); + head:=getchar(str, 0); + num:=copy(str, 1, length(str)); + + if str='TRUE' then + DecodeInt:=1; + else + if str='FALSE' then + DecodeInt:=0; + else + if str='POP' then + DecodeInt:=popStack; + else + if head='$' then + DecodeInt:=getVar(num); + else + if (head='0') and (getchar(str, 1)='X') then + begin + DecodeInt:=Str2Dec(copy(str, 2, length(str)), 16); + end; + else + if (head='0') and (length(str)>1) then + begin + DecodeInt:=Str2Dec(num, 8); + end; + else + if head='B' then + begin + DecodeInt:=Str2Dec(num, 2); + end; + else + if ((head>='0') and (head<='9')) or (head='-') then + begin + DecodeInt:=Str2Dec(str, 10); + + end; + else + addToLog('Error! I cant decode "'+str+'"'); + end; + +procedure exeCommand(str:string); + var + com, tmp, tmp2:string; + i:integer; + begin + parseStr:=str; + clearSpaces; + if parseStr='' then + exit; + + com:=UpCase(nextWord); + + if (cheats) or (autoexec_acces) or (gamemode=1) then + begin + if com='TIME' then + game_time:=decodeInt(nextWord); + else + if com='FLY' then + fly:=strToBool(nextWord); + else + if com='PL_HP' then + hp:=decodeInt(nextWord); + else + if com='PL_EP' then + hunger:=decodeInt(nextWord); + else + if com='GIVE' then + player.dropItem(decodeInt(nextWord), decodeInt(nextWord)); + else + if com='PL_TP' then + begin + player.setX(decodeInt(nextWord)); + player.setY(decodeInt(nextWord)); + end; + else + if com='GAMEMODE' then + begin + gamemode:=decodeInt(nextWord); + fly:=false; + end; + else + {if com='KILL_MOBS' then + for i:=0 to 31 do + begin + mob[i].m_type:=0; + mob[i].m_hp:=0; + end; + else} + if com='SPAWN' then + begin + player.setX(get_spawn_x*16+4); + player.setY(get_spawn_y*16); + end; + else + {if com='SPAWN_MOBS' then + s_spawn_mob:=strToBool(nextWord); + else} + {if com='SURVIVAL' then + begin + fly:=false; + gamemode:=0; + hp:=20; + hunger:=20; + for i:=0 to 35 do + begin + inv[i].item_i:=0; + inv[i].sum_i:=0; + end; + end; + else} + if com='CLEAR_INVENTORY' then + begin + inv.resetData; + end; + else + + end; + + if com='I_AM_CHEATER' then + begin + if nextWord=#$36+#$36+#$36 then + cheats:=not cheats; + else + cheats:=false; + end; + else + if com='HALT' then + halt; + else + if com='WEATHER' then + osadki:=strToBool(nextWord); + else + {if com='MEGASPAWN' then + megaspawn; + else} + if com='REF_DRP' then + ref_drp:=strToBool(nextWord); + else + if com='BL_UPD' then + bl_upd:=decodeInt(nextWord); + else + if com='GET_DRP' then + s_get_drp:=strToBool(nextWord); + else + {if com='AI_UPD' then + ai_upd:=strToBool(nextWord); + else} + if com='PRT_UPD' then + particle_upd:=strToBool(nextWord); + else + if com='MAX_FPS' then + s_max_fps:=decodeInt(nextWord); else + if com='DRW_BACK' then + drw_back:=strToBool(nextWord); + else + {if com='DRW_MOBS' then + drw_mobs:=strToBool(nextWord); + else} + if com='DRP_PHY' then + drp_phy:=strToBool(nextWord); + else + if com='DRW_SM' then + drw_sm:=strToBool(nextWord); + else + if com='JPEG_Q' then + begin + s_jpeg_quality:=decodeInt(nextWord); + if s_jpeg_quality>100 then + s_jpeg_quality:=100; + else if s_jpeg_quality<0 then + s_jpeg_quality:=0; + end; + else + if com='LOAD_SM' then + load_sm:=decodeInt(nextWord); + else + if com='S_WEATHER' then + ifosad:=strToBool(nextWord); + else + if com='S_HIDE_GUI' then + drawgui:=strToBool(nextWord); + else + if com='S_LIGHT' then + light_type:=decodeInt(nextWord); + else + if com='S_PARTICLES' then + s_particles:=strToBool(nextWord); + else + if com='LOAD_SKY' then + load_sky_siz:=decodeInt(nextWord); + else + {if com='LOAD_MOB_TEX' then + load_mob_tex:=strToBool(nextWord); + else} + if com='LOAD_BACK_TEX' then + load_back_tex:=strToBool(nextWord); + else + if com='LOAD_WEATHER_TEX' then + load_weather_tex:=strToBool(nextWord); + else + if com='LOAD_PARTICLES_TEX' then + load_particles_tex:=strToBool(nextWord); + else + if com='LOAD_LIGHT_TEX' then + load_light_tex:=strToBool(nextWord); + else + if com='LOAD_GUI_TEX' then + load_gui_tex:=strToBool(nextWord); + else + if com='MENU_BACKGROUND' then + menu_background:=decodeInt(nextWord); + else + if com='DRW_DRP' then + drw_drp:=strToBool(nextWord); + else + if com='DRW_STARS' then + drw_stars:=strToBool(nextWord); + else + if com='SV_SETT' then + save_settings; + else + if com='LD_SETT' then + load_settings; + else + if com='LOAD_MINIMAP_TEX' then + load_minimap_tex:=strToBool(nextWord); + else + if com='MAX_PARTICLES' then + begin + max_particles:=decodeInt(nextWord); + reset_particles(max_particles+1); + end; + else + if com='EXEC' then + begin + tmp:=nextWord; + exec(nextWord, tmp, autoexec_acces); + end; + else + if com='RESET_ITEMS' then + begin + resetItems(decodeInt(nextWord)+1); + //addToLog('Max items: '+decodeInt(parsed_str[1])); + end; + else + if com='SET_ITEM' then + begin + setItemData(decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord)); + end; + else + if com='RESET_BLOCKS' then + begin + resetBlocks(decodeInt(nextWord)+1); + //addToLog('Max blocks: '+decodeInt(parsed_str[1])); + end; + else + if com='SET_BLOCK' then + begin + setBlockData(decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord)); + end; + else + if com='RESET_TOOLS' then + begin + resetTools(decodeInt(nextWord)+1); + //addToLog('Max tools: '+decodeInt(parsed_str[1])); + end; + else + if com='SET_TOOL' then + begin + setToolData(decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord)); + end; + else + if com='RESET_FUELS' then + begin + furnace.setMaxFuel(decodeInt(nextWord)); + //addToLog('Max fuel: '+decodeInt(parsed_str[1])); + end; + else + if com='SET_FUEL' then + begin + furnace.initFuel(decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord)); + end; + else + if com='RESET_RECIPES' then + begin + furnace.setMaxRecipes(decodeInt(nextWord)); + //addToLog('Max recipes: '+decodeInt(parsed_str[1])); + end; + else + if com='SET_RECIPE' then + begin + furnace.initRecipe(decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord)); + end; + else + if com='RESET_CRAFTS' then + begin + resetCrafts(decodeInt(nextWord)); + //addToLog('Max crafts: '+decodeInt(parsed_str[1])); + end; + else + if com='SET_CRAFT_IN' then + begin + setCraftIn(decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord)); + end; + else + if com='SET_CRAFT_OUT' then + begin + setCraftOUT(decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord)); + end; + else + if com='RESET_BLOCKS_TEX' then + begin + initBlockTex(decodeInt(nextWord)); + end; + else + if com='RESET_ITEMS_TEX' then + begin + initItemTex(decodeInt(nextWord)); + end; + else + if com='LOAD_TEX' then + regimg:=ld_tex(nextWord, '/'+sd+'/cavecraft/', ''); + else + if com='RESET_TEX' then + resetTmpImg; + else + if com='SET_TEX' then + setTexture(regimg, + nextWord, + decodeInt(nextWord)); + if com='SET_CANV_TEX' then + begin + tmp:=nextWord; + tmp2:=nextWord; + setTexture(rotate_image_from_image(regimg, + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + 0), + tmp, + decodeInt(tmp2)); + end; + else + if com='SET_MAX_ITEM_LIST' then + setMaxItemList(decodeInt(nextWord)); + else + if com='SET_ITEM_LIST' then + setItemList(decodeInt(nextWord), + decodeInt(nextWord)); + else + if com='BIND_KEY' then + begin + tmp:=nextWord; + for i:=0 to MAX_KEY_BIND do + keyboard.bindKey(decodeInt(tmp), i, decodeInt(nextWord)); + end; + else + if com='STACK' then + resetStack(decodeInt(nextWord)); + else + if com='PUSH' then + pushStack(decodeInt(nextWord)); + else + if com='POP' then + i:=popStack; + else + if com='SWAP' then + swapStack; + else + if com='DUP' then + dupStack; + else + if com='ADD' then + pushStack(popStack+popStack); + else + if com='SUB' then + begin + i:=popStack; + pushStack(popStack-i); + end; + else + if com='MUL' then + pushStack(popStack*popStack); + else + if com='DIV' then + begin + i:=popStack; + pushStack(popStack/i); + end; + else + if com='MOD' then + begin + i:=popStack; + pushStack(popStack mod i); + end; + else + if com='SET' then + setVar(nextWord, decodeInt(nextWord)); + else + if com='POPSET' then + setVar(nextWord, popStack); + else + if com='MAX_VKEYS' then + resetVirtualKeyboard(decodeInt(nextWord)); + else + if com='SET_VKEY' then + bindVKey(decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord), + decodeInt(nextWord)); + else + if com='SET_RESOLUTION' then + initVideo(decodeInt(nextWord), decodeInt(nextWord), strToBool(nextWord)); + else + //addToLog('Unknown command "'+com+'"'); + end; + +procedure call_console; + var + commandTxt:integer; + i, tmpid:integer; + exitCmd, exeCmd, Clicked:command; + str:string; + begin + + setFont(FONT_FACE_SYSTEM,FONT_STYLE_PLAIN,FONT_SIZE_SMALL); + + repeat + ClearForm; + + exitCmd:=createCommand('Exit', CM_EXIT, 1); + exeCmd:=createCommand('Execute', CM_OK, 1); + addCommand(exitCmd); + addCommand(exeCmd); + + commandTxt:=formAddTextField('Enter command:', ''+lastCommand, 32, TF_ANY); + + for i:=0 to CON_LOG_SIZE do + tmpid:=formAddString(logSTR[i]+chr(10)); + + ShowForm; + Repaint; + + repeat + Clicked:=getClickedCommand; + if Clicked=exitCmd then + begin + lastCommand:=formGetText(commandTxt); + showCanvas; + exit; + end; + else + if Clicked=exeCmd then + begin + str:=formGetText(commandTxt); + addToLog(str); + exeCommand(str); + lastCommand:=''; + break; + end; + forever; + forever; + end; + +procedure exec(s, search:string; acces:boolean); + var + res:resource; + str:string; + tmp_acces, tmpEOF:boolean; + begin + tmp_acces:=autoexec_acces; + autoexec_acces:=acces; + + search:=UpCase(search); + + if search='LOCAL' then + begin + addToLog('Load file "'+s+'" at LOCAL!'); + res:=OpenResource('/'+s); + end; + else + if search='SD' then + begin + if open_file('/'+sd+'/cavecraft/'+s)=1 then + begin + addToLog('Load file "'+s+'" at SD!'); + res:=get_stream; + end; + end; + else + if search='AUTO' then + begin + addToLog('path "/'+sd+'/cavecraft/'+s+'"'); + if file_exists('/'+sd+'/cavecraft/'+s)=1 then + begin + if open_file('/'+sd+'/cavecraft/'+s)=1 then + begin + addToLog('Load file "'+s+'" at SD(AUTO)!'); + res:=get_stream; + end; + end; + else + begin + addToLog('Load file "'+s+'" at LOCAL(AUTO)!'); + res:=OpenResource('/'+s); + end; + end; + else + begin + addToLog('Unknown load type "'+search+'", file "'+s+'" not executed!'); + autoexec_acces:=tmp_acces; + exit; + end; + + if ResourceAvailable(res) then + repeat + str:=ReadString(res); + tmpEOF:=EOFstr; + //addToLog('Exec: "'+str+'"'); + exeCommand(str); + EOFstr:=tmpEOF; + until EOFstr; + else + addToLog('Execute file "'+s+'" not found!'); + + CloseResource(res); + autoexec_acces:=tmp_acces; + end; + +initialization + +end. diff --git a/src/craft.mpsrc b/src/craft.mpsrc new file mode 100644 index 0000000..db148dd --- /dev/null +++ b/src/craft.mpsrc @@ -0,0 +1,92 @@ +unit craft; + +interface + procedure createCraft(id, mode:integer); + function canCreateCraft(id, mode:integer):boolean; + +implementation + uses vars, items, func, player, inv, items_store; + +procedure createCraft(id, mode:integer); + var + i, j, tmp_sum, tmp_s, item, sum:integer; + begin + if canCreateCraft(id, mode)=false then + exit; + + //Выпиливаем все необходимые предметы + for i:=0 to 3 do + begin + tmp_sum:=getCraftInSum(id, i); + for j:=0 to INV_SIZE do + begin + item:=inv.getItem(j); + sum:=inv.getSum(j); + + if getCraftInItem(id, i)=item then + begin + tmp_s:=tmp_sum-sum; + + if tmp_s<1 then + begin + sum:=sum-tmp_sum; + inv.setSum(sum, j); + inv.fixNull(j); + break; + end; + else + begin + sum:=0; + tmp_sum:=tmp_s; + inv.setSum(sum, j); + inv.fixNull(j); + end; + end; + end; + end; + + item:=getCraftOutItem(id); + sum:=getCraftOutSum(id); + + sum:=inv.giveItem(item, sum); + if sum>0 then + player.dropItem(sum, sum); + end; + +//Проверка, может ли игрок сделать этот крафт. +function canCreateCraft(id, mode:integer):boolean; + var + i, j, tmp_sum:integer; + canCreate:boolean; + begin + //Если место крафта подходит, то продолжаем крафт + if mode>=getCraftOutFlag(id) then + canCreate:=true; + else + exit; + + //Проверяем каждую ячейку крафта + for i:=0 to 3 do + begin + //Получаем общуюю сумму подходящего предмета + tmp_sum:=0; + if getCraftInItem(id, i)>0 then + begin + for j:=0 to INV_SIZE do + begin + if getCraftInItem(id, i)=inv.getItem(j) then + tmp_sum:=tmp_sum+inv.getSum(j); + end; + + //Проверяем, подходит ли количество предметов + if tmp_sum>=getCraftInSum(id, i) then + canCreate:=canCreate and true; + else + exit; + end; + end; + + canCreateCraft:=canCreate; + end; + +end. diff --git a/src/drop.mpsrc b/src/drop.mpsrc new file mode 100644 index 0000000..a691f98 --- /dev/null +++ b/src/drop.mpsrc @@ -0,0 +1,214 @@ +unit drop; + +interface + var + drp_phy, drw_drp, ref_drp:boolean; + + function max:integer; + function getX(i:integer):integer; + function getY(i:integer):integer; + function getW:integer; + function getH:integer; + function getItem(i:integer):integer; + function getSum(i:integer):integer; + procedure setItem(val, i:integer); + procedure setSum(val, i:integer); + function isNull(i:integer):boolean; + procedure fixNull(i:integer); + + procedure draw(camx, camy:integer); + procedure calcPhy; + procedure reflux; + + procedure create(item, sum, x, y:integer); + procedure resetData; + procedure saveData; + procedure loadData; + +implementation + uses phy, jsr75i, vars, items_store, items, func; + const + MAX_DROP=255; + DROP_W=8; + DROP_H=8; + var + drop_x, drop_y, drop_vely: array [0..MAX_DROP] of integer; + drop_item, drop_sum: array [0..MAX_DROP] of integer; + + old_drop, ref_drp_count:integer; + + function max:integer; + begin + max:=MAX_DROP; + end; + + function getX(i:integer):integer; + begin + getX:=drop_x[i]; + end; + + function getY(i:integer):integer; + begin + getY:=drop_y[i]; + end; + + function getW:integer; + begin + getW:=DROP_W; + end; + + function getH:integer; + begin + getH:=DROP_H; + end; + + function getItem(i:integer):integer; + begin + getItem:=drop_item[i]; + end; + + function getSum(i:integer):integer; + begin + getSum:=drop_sum[i]; + end; + + procedure setItem(val, i:integer); + begin + drop_item[i]:=val; + end; + + procedure setSum(val, i:integer); + begin + drop_sum[i]:=val; + end; + + function isNull(i:integer):boolean; + begin + if (drop_item[i]<1) or (drop_sum[i]<1) then + isNull:=true; + end; + + procedure fixNull(i:integer); + begin + if isNull(i) then + begin + drop_item[i]:=0; + drop_sum[i]:=0; + end; + end; + + procedure create(item, sum, x, y:integer); + var + i:integer; + begin + for i:=0 to MAX_DROP do + if isNull(i) then + begin + drop_item[i]:=item; + drop_sum[i]:=sum; + drop_x[i]:=x; + drop_y[i]:=y; + drop_vely[i]:=0; + exit; + end; + + drop_item[old_drop]:=item; + drop_sum[old_drop]:=sum; + drop_x[old_drop]:=x; + drop_y[old_drop]:=y; + drop_vely[old_drop]:=0; + + old_drop:=old_drop+1; + if old_drop>MAX_DROP then + old_drop:=0; + end; + + procedure calcPhy; + var + i:integer; + begin + if drp_phy then + for i:=0 to MAX_DROP do + if isNull(i)=false then + begin + phy.loadObject(drop_x[i], drop_y[i], DROP_W, DROP_H, 0, drop_vely[i], false); + phy.calc(true); + drop_x[i]:=phy.getX; + drop_y[i]:=phy.getY; + drop_vely[i]:=phy.getVelY; + end; + end; + + procedure draw(camx, camy:integer); + var + i:integer; + begin + if drw_drp then + for i:=0 to 255 do + if isNull(i)=false then + drawSmallItem(drop_item[i], drop_x[i]-camx, drop_y[i]-camy); + end; + + procedure reflux; + var + i:integer; + begin + if ref_drp then + begin + for i:=ref_drp_count+1 to MAX_DROP do + if (isNull(ref_drp_count) and isNull(i))=false then + 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 + begin + drop_sum[ref_drp_count]:=drop_sum[ref_drp_count]+drop_sum[i]; + drop_item[i]:=0; + drop_sum[i]:=0; + end; + + ref_drp_count:=ref_drp_count+1; + if ref_drp_count>MAX_DROP then ref_drp_count:=0; + end; + end; + + procedure resetData; + var + i:integer; + begin + for i:=0 to MAX_DROP do + begin + drop_item[i]:=0; + drop_sum[i]:=0; + drop_x[i]:=0; + drop_y[i]:=0; + drop_vely[i]:=0; + end; + end; + + procedure saveData; + var + i:integer; + begin + for i:=0 to MAX_DROP do + begin + write_byte(drop_item[i]); + writeint(drop_sum[i]); + writeint(drop_x[i]); + writeint(drop_y[i]); + write_byte(drop_vely[i]); + end; + end; + + procedure loadData; + var + i:integer; + begin + for i:=0 to MAX_DROP do + begin + drop_item[i]:=read_byte; + drop_sum[i]:=ReadInt; + drop_x[i]:=ReadInt; + drop_y[i]:=ReadInt; + drop_vely[i]:=read_byte; + end; + end; + +end. diff --git a/src/func.mpsrc b/src/func.mpsrc new file mode 100644 index 0000000..a80e3ec --- /dev/null +++ b/src/func.mpsrc @@ -0,0 +1,324 @@ +unit func; + +interface + function get_spawn_x:integer;//Возвращает блок по X где должен появиться игрок + function get_spawn_y:integer;//Возвращает блок по Y где должен появиться игрок + procedure draw_block(xx,yy:integer); + procedure drawSmallItem(item, x, y:integer); + procedure drawItem(item, sum, x, y:integer; indicator:boolean;); + procedure LoadDrawFont(s:string); + procedure DrawFontTextSpec(str:string; x, y, color:integer; spec:boolean;); + procedure DrawFontText(str:string; x, y:integer); +function ld_tex(name,path,folder:string):image; +function readint:integer; +procedure writeint(intt:integer); +procedure writebool(bo:boolean); +function readbool:boolean; +procedure writestr(s:string); +function readstr:string; + +implementation + uses canvas,imgcolor,jsr75i, vars, safeload, items,maps, items_store; + + //Загрузка изображения из текстурпака, ели такого нет, то происходит загрузка из архива игры +function ld_tex(name,path,folder:string):image; + begin + if tex_pack<>'' then + begin + if file_exists(path+folder+name)=1 then + begin + ld_tex:=safely_load_image_fs(path+folder+name); + end; else ld_tex:=loadimage('/'+folder+name); + end; + if tex_pack='' then ld_tex:=loadimage('/'+folder+name); + end; + +function readint:integer; + var + b:integer; + begin + b:=b or (read_uns_byte<<24); + b:=b or (read_uns_byte<<16); + b:=b or (read_uns_byte<<8); + b:=b or (read_uns_byte); + readint:=b; + end; + +procedure writeint(intt:integer); + begin + write_byte((intt>>24) and $FF); + write_byte((intt>>16) and $FF); + write_byte((intt>>8) and $FF); + write_byte((intt) and $FF); + end; + +procedure writebool(bo:boolean); + begin + if bo=true then + write_byte(1); + else + write_byte(0); + end; + +function readbool:boolean; + begin + readbool:=read_byte>0; + end; + +procedure writestr(s:string); + var + i:integer; + begin + for i:=0 to length(s) do + write_byte(ord(getChar(s,i))); + end; + +function readstr:string; + var + i,b:integer; + str:string; + begin + repeat + b:=read_byte; + if b=0 then break; + str:=str+chr(b); + until false; + readstr:=str; + end; + +//Получение точки спавна + function get_spawn_x:integer; + begin + get_spawn_x:=(255 div 2); + end; + + function get_spawn_y:integer; + var + iy:integer; + begin + for iy:=0 to 127 do + if getmap(get_spawn_x,iy)<>0 then begin get_spawn_y:=(iy-2); break; end; + end; + + procedure drawSmallItem(item, x, y:integer); + begin + if getItemTexType(item)=0 then + drawimage(tex8[getBlockTex(item)], x, y); + else + if getItemTexType(item)=1 then + drawimage(item8[getItemTex(item)], x, y); + end; + + procedure draw_block(xx,yy:integer); + begin + if (getmap(xx,yy)=123) or (getmap(xx,yy)=124) then + begin + setclip((xx*16)-camx,(yy*16)-camy,16,16); + if getmapinfo(xx,yy)<9 then drawimage(tex[142],(xx*16)-camx,(yy*16)-camy+(16-getmapinfo(xx,yy)*2)); else + if getmapinfo(xx,yy)=9 then drawimage(tex[143],(xx*16)-camx,(yy*16)-camy); + setclip(0,0,getwidth,getheight); + end; else + if (getmap(xx,yy)=92) or (getmap(xx,yy)=93) then + begin + 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 + 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 + 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); + drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy); + setclip(0,0,getwidth,getheight); + end; else + if getmap(xx,yy)=27 then + begin + drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy); + if getmapinfo(xx,yy)<>0 then begin if random(8)0) then + drawimage(tex[134],xx*16-camx,yy*16-camy); + else + drawimage(tex[get_block(0,getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy); + end; else*/ + if getmap(xx,yy)=121 then + begin + setclip((xx*16)-camx,(yy*16)-camy,getmapinfo(xx,yy),16); + drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy); + setclip(0,0,getWidth,getHeight); + end; else + if getmap(xx,yy)=122 then + begin + drawimage(tex[getBlockTex(getmap(xx,yy))+getmapinfo(xx,yy)],(xx*16)-camx,(yy*16)-camy); + end; else + if getmap(xx,yy)<>0 then + drawimage(tex[getBlockTex(getmap(xx,yy))],(xx*16)-camx,(yy*16)-camy); + end; + + procedure drawItem(item, sum, x, y:integer; indicator:boolean;); + var + pa_xo,ugol:integer; + begin + if sum>0 then + begin + if getItemTexType(item)=0 then + drawimage(tex[getBlockTex(item)], x, y); + else + if getItemTexType(item)=1 then + drawimage(vars.item[getItemTex(item)], x, y); + + if item=216 then + begin + drawimage(compas, x, y); + setcolor(255,0,0); + setclip(x+2, y+2, 12, 10); + if pl_world=0 then + drawline(get_spawn_x*16-camx, get_spawn_y*16-camy, x+8, y+7); + else + if pl_world=1 then + drawline(random(getWidth), random(getHeight), x+8, y+7); + setclip(0, 0, getWidth, getheight); + end; + else + if item=215 then + begin + drawimage(clock[clock_stage], x, y); + end; + end; + + if (sum>1) and indicator then + begin + if getItemIndLine(item) then + begin + pa_xo:=10000*16/getItemMax(item)*sum/10000; + if pa_xo<=3 then + setcolor(255,0,0); + else + setcolor(0,255,0); + drawline(x, y+14, x+pa_xo, y+14); + end; + + if getItemIndNum(item) then + drawfonttext(''+sum, x, y+8); + end; + end; + + +//Загрузка шрифта из файла под именем s +procedure LoadDrawFont(s:string); + var + ix:integer; + im:image; + begin + im:=ld_tex('default_font.png', s, ''); + for ix:=0 to FONT_MAX_SYM do + font[ix]:=rotate_image_from_image(im, ix*FONT_SYM_SIZE, 0, FONT_SYM_SIZE, FONT_SYM_SIZE, 0); + end; + +//Рисование текста графическим шрифтом +procedure DrawFontTextSpec(str:string; x, y, color:integer; spec:boolean;); + const + FONT_UNKNOWN_SYM=$3F; + FONT_SPEC_SYM=$FFA7;//UTF8 + var + ch, i, spec_c:integer; + tch:char; + begin + for i:=0 to length(str)-1 do + begin + ch:=ord(getChar(str, i)); + + if (spec) and (ch=FONT_SPEC_SYM) then + begin + + i:=i+1; + if i<=length(str)-2 then + begin + ch:=ord(getChar(str, i+1)); + tch:=getChar(UpCase(str), i); + if tch='0' then + color:=$FF000000; + else + if tch='1' then + color:=$FF0000AA; + else + if tch='2' then + color:=$FF00AA00; + else + if tch='3' then + color:=$FF00AAAA; + else + if tch='4' then + color:=$FFAA0000; + else + if tch='5' then + color:=$FFAA00AA; + else + if tch='6' then + color:=$FFAA5500; + else + if tch='7' then + color:=$FFAAAAAA; + else + if tch='8' then + color:=$FF555555; + else + if tch='9' then + color:=$FF5555FF; + else + if tch='A' then + color:=$FF55FF55; + else + if tch='B' then + color:=$FF55FFFF; + else + if tch='C' then + color:=$FFFF5555; + else + if tch='D' then + color:=$FFFF55FF; + else + if tch='E' then + color:=$FFFFFF55; + else + if tch='F' then + color:=$FFFFFFFF; + else + begin + i:=i-2; + ch:=ord(getChar(str, i)); + spec_c:=spec_c-2; + end; + + i:=i+1; + spec_c:=spec_c+2; + end; + end; + + if ch>FONT_MAX_SYM then + ch:=FONT_UNKNOWN_SYM; + + if color=FONT_STD_COLOR then + DrawImage(font[ch],x+((i-spec_c)*FONT_SYM_SIZE),y); + else + DrawImage(ReplaceImgColor(font[ch], FONT_STD_COLOR, color), x+((i-spec_c)*FONT_SYM_SIZE), y); + end; + end; + +//Рисование текста графическим шрифтом со стандартным цветом +procedure DrawFontText(str:string; x, y:integer); + begin + DrawFontTextSpec(str, x, y, FONT_STD_COLOR, true); + end; + + +end. diff --git a/src/furnace.mpsrc b/src/furnace.mpsrc new file mode 100644 index 0000000..7f568df --- /dev/null +++ b/src/furnace.mpsrc @@ -0,0 +1,369 @@ +unit furnace; + +interface + const + MAX_FURNACE=31; + MAX_FURNACE_CELLS=2; + + ITEM_IN_FIRE=10000; + + FURNACE_IN=0; + FURNACE_FUEL=1; + FURNACE_OUT=2; + + FURNACE_ERROR=-1; + + procedure setMaxFuel(i:integer); + procedure setMaxRecipes(i:integer); + procedure initFuel(id, item, time:integer); + procedure initRecipe(id, in_item, out_item:integer); + + function getTime:integer; + function startFuelTime(furid:integer):integer; + function endFuelTime(furid:integer):integer; + function startProgTime(furid:integer):integer; + function endProgTime(furid:integer):integer; + function FuelTime(i:integer):integer; + function ProgTime(i:integer):integer; + + function GetFurItem(cell, furid:integer;):integer; + procedure SetFurItem(val, cell, furid:integer;); + function GetFurSum(cell, furid:integer;):integer; + procedure SetFurSum(val, cell, furid:integer;); + + function CreateFurnace(x, y:integer;):integer; + procedure DestroyFurnace(x, y:integer); + procedure UpdateFurnaces; + + function furnaceBurn(i:integer):boolean; + function itemBurn(i:integer):boolean; + +implementation + uses maps, drop, items_store, items; + var + furnace_b: array [0..MAX_FURNACE] of boolean; + furnace_item, furnace_sum: array [0..MAX_FURNACE, 0..MAX_FURNACE_CELLS] of integer; + furnace_fstart, furnace_ftime, furnace_prstart: array [0..MAX_FURNACE] of integer; + + time:integer; + maxFuel, maxRecipe:integer; + fuel_item, fuel_time: array [0..0] of integer; + recept_in, recept_out: array [0..0] of integer; + + function getTime:integer; + begin + getTime:=time; + end; + + procedure UpdateTime; + begin + time:=getRelativeTimeMs; + end; + + function startFuelTime(i:integer):integer; + begin + startFuelTime:=furnace_fstart[i]; + end; + + function endFuelTime(i:integer):integer; + begin + endFuelTime:=furnace_fstart[i]+furnace_ftime[i]; + end; + + function FuelTime(i:integer):integer; + begin + FuelTime:=furnace_ftime[i]; + end; + + procedure updateFuelTime(fueltime, i:integer); + begin + furnace_fstart[i]:=getTime; + furnace_ftime[i]:=fueltime; + end; + + function startProgTime(i:integer):integer; + begin + startProgTime:=furnace_prstart[i]; + end; + + function endProgTime(i:integer):integer; + begin + endProgTime:=furnace_prstart[i]+ITEM_IN_FIRE; + end; + + function ProgTime(i:integer):integer; + begin + ProgTime:=ITEM_IN_FIRE; + end; + + procedure setMaxFuel(i:integer;); + begin + maxFuel:=i; + i:=i+1; + bytecode + iload 0; + newarray 10; + putstatic field 'furnace', 'fuel_item', '[I'; + end; + bytecode + iload 0; + newarray 10; + putstatic field 'furnace', 'fuel_time', '[I'; + end; + end; + + procedure setMaxRecipes(i:integer); + begin + maxRecipe:=i; + i:=i+1; + bytecode + iload 0; + newarray 10; + putstatic field 'furnace', 'recept_in', '[I'; + end; + bytecode + iload 0; + newarray 10; + putstatic field 'furnace', 'recept_out', '[I'; + end; + end; + + procedure initFuel(id, item, time:integer); + begin + fuel_item[id]:=item; + fuel_time[id]:=time; + end; + + procedure initRecipe(id, in_item, out_item:integer); + begin + recept_in[id]:=in_item; + recept_out[id]:=out_item; + end; + + procedure ResetProgress(furid:integer); + begin + furnace_prstart[furid]:=getTime; + end; + + function GetFurItem(cell, furid:integer;):integer; + begin + GetFurItem:=furnace_item[furid, cell]; + end; + + procedure SetFurItem(val, cell, furid:integer;); + begin + furnace_item[furid, cell]:=val; + end; + + function GetFurSum(cell, furid:integer;):integer; + begin + GetFurSum:=furnace_sum[furid, cell]; + end; + + procedure SetFurSum(val, cell, furid:integer;); + begin + furnace_sum[furid, cell]:=val; + end; + + function FurCellIsNull(cell, furid:integer;):boolean; + begin + if (GetFurItem(cell, furid)<1) or (GetFurSum(cell, furid)<1) then + FurCellIsNull:=true; + end; + + procedure fixNull(cell, furid:integer;); + begin + if FurCellIsNull(cell, furid) then + begin + SetFurItem(0, cell, furid); + SetFurSum(0, cell, furid); + end; + end; + + function CreateFurnace(x, y:integer;):integer; + var + i, j:integer; + begin + for i:=0 to MAX_FURNACE do + if furnace_b[i]=false then + begin + furnace_b[i]:=true; + for j:=0 to MAX_FURNACE_CELLS do + begin + furnace_item[i, j]:=0; + furnace_sum[i, j]:=0; + end; + furnace_fstart[i]:=getTime; + furnace_ftime[i]:=0; + furnace_prstart[i]:=getTime; + setMapInfo(i, x, y); + CreateFurnace:=i; + exit; + end; + CreateFurnace:=FURNACE_ERROR; + end; + + function FindFuel(furid:integer):integer; + var + i:integer; + begin + if FurCellIsNull(FURNACE_FUEL, furid)=false then + for i:=0 to maxFuel do + if GetFurItem(FURNACE_FUEL, furid)=fuel_item[i] then + begin + FindFuel:=i; + exit; + end; + FindFuel:=FURNACE_ERROR; + end; + + procedure DestroyFurnace(x, y:integer); + var + i, j:integer; + begin + i:=getMapInfo(x, y); + furnace_b[i]:=false; + for j:=0 to MAX_FURNACE_CELLS do + begin + if FurCellIsNull(j, i)=false then + drop.create(furnace_item[i, j], furnace_sum[i, j], x*16+4, y*16+4) + furnace_item[i, j]:=0; + furnace_sum[i, j]:=0; + end; + furnace_fstart[i]:=getTime; + furnace_ftime[i]:=0; + furnace_prstart[i]:=getTime; + end; + + function GetReceptOut(in_item:integer;):integer; + var + i:integer; + begin + for i:=0 to maxRecipe do + if in_item=recept_in[i] then + begin + GetReceptOut:=recept_out[i]; + exit; + end; + GetReceptOut:=FURNACE_ERROR; + end; + + function canUpdate(i:integer):boolean; + var + itemIN, itemOUT, sumOUT, recipeOUT:integer; + begin + fixNull(FURNACE_IN, i); + fixNull(FURNACE_OUT, i); + + itemIN:=GetFurItem(FURNACE_IN, i); + itemOUT:=GetFurItem(FURNACE_OUT, i); + sumOUT:=GetFurSum(FURNACE_OUT, i); + recipeOUT:=GetReceptOut(itemIN); + + if (itemIN<>0) and (recipeOUT<>FURNACE_ERROR) then + if (itemOUT=0) or ((itemOUT=recipeOUT) and (sumOUT=startFuelTime(i)) and (getTime<=endFuelTime(i)) then + furnaceBurn:=true; + end; + + function itemBurn(i:integer):boolean; + begin + if FurCellIsNull(FURNACE_IN, i)=false then + if (getTime>=startProgTime(i)) and (getTime<=endProgTime(i)) then + itemBurn:=true; + end; + + procedure useFuel(i:integer;); + var + fuelid, item, sum:integer; + begin + fuelid:=FindFuel(i); + item:=GetFurItem(FURNACE_FUEL, i); + sum:=GetFurSum(FURNACE_FUEL, i); + + if getItemDiv(item) then + begin + sum:=sum-1; + if sum<0 then + item:=0; + end; + else + begin + item:=0; + sum:=0; + end; + + updateFuelTime(fuel_time[fuelid], i); + + SetFurItem(item, FURNACE_FUEL, i); + SetFurSum(sum, FURNACE_FUEL, i); + end; + + procedure createOutItem(i:integer); + var + itemIN, sumIN, itemOUT, sumOUT, recipeOUT:integer; + begin + itemIN:=GetFurItem(FURNACE_IN, i); + sumIN:=GetFurSum(FURNACE_IN, i); + itemOUT:=GetFurItem(FURNACE_OUT, i); + sumOUT:=GetFurSum(FURNACE_OUT, i); + recipeOUT:=GetReceptOut(itemIN); + + if getItemDiv(itemIN) then + begin + sumIN:=sumIN-1; + if sumIN<0 then + itemIN:=0; + end; + else + begin + itemIN:=0; + sumIN:=0; + end; + + itemOUT:=recipeOUT; + sumOUT:=sumOUT+1; + + SetFurItem(itemIN, FURNACE_IN, i); + SetFurSum(sumIN, FURNACE_IN, i); + SetFurItem(itemOUT, FURNACE_OUT, i); + SetFurSum(sumOUT, FURNACE_OUT, i); + end; + + procedure UpdateFurnaces; + var + i, fuelid:integer; + begin + for i:=0 to MAX_FURNACE do + if furnace_b[i] then + if canUpdate(i) then + begin + if furnaceBurn(i) then + begin + if itemBurn(i)=false then + begin + createOutItem(i); + ResetProgress(i); + end; + end; + else + begin + fuelid:=FindFuel(i); + if fuelid=FURNACE_ERROR then + ResetProgress(i); + else + useFuel(i); + end; + end; + else + ResetProgress(i); + + UpdateTime; + end; + +end. diff --git a/src/gameui.mpsrc b/src/gameui.mpsrc new file mode 100644 index 0000000..8d705cf --- /dev/null +++ b/src/gameui.mpsrc @@ -0,0 +1,99 @@ +unit gameui; + +interface + const + UI_MAX_STACK=2;//3 + UI_MAX_ELEMENTS=62;//63 + + UI_TYPE_NULL=0; + + UI_ERROR=-1; + + procedure NewUILayer; + procedure DelUILayer; + function addUIElement(el_type, x, y:integer):integer; + procedure delUIElement(i:integer); + procedure clearUIElements; + function getUIx(i:integer):integer; + function getUIy(i:integer):integer; + function getUIw(i:integer):integer; + function getUIh(i:integer):integer; + +implementation +//Main UI functions and vars + var + layer:integer; + ui_type: array [0..UI_MAX_STACK, 0..UI_MAX_ELEMENTS] of integer; + ui_x: array [0..UI_MAX_STACK, 0..UI_MAX_ELEMENTS] of integer; + ui_y: array [0..UI_MAX_STACK, 0..UI_MAX_ELEMENTS] of integer; + + procedure NewUILayer; + begin + layer:=layer+1; + //Test + ui_type[layer, 0]:=ui_type[layer, 0]; + end; + + procedure DelUILayer; + begin + layer:=layer-1; + //Test + ui_type[layer, 0]:=ui_type[layer, 0]; + end; + + //Return id added element or UI_ERROR + function addUIElement(el_type, x, y:integer):integer; + var + i:integer; + begin + for i:=0 to UI_MAX_ELEMENTS do + if ui_type[layer, i]=UI_TYPE_NULL then + begin + ui_type[layer, i]:=el_type; + ui_x[layer, i]:=x; + ui_y[layer, i]:=y; + addUIElement:=i; + exit; + end; + + addUIElement:=UI_ERROR; + end; + + procedure delUIElement(i:integer); + begin + ui_type[layer, i]:=UI_TYPE_NULL; + ui_x[layer, i]:=0; + ui_y[layer, i]:=0; + end; + + procedure clearUIElements; + var + i:integer; + begin + for i:=0 to UI_MAX_ELEMENTS do + delUIElement(i); + end; + + function getUIx(i:integer):integer; + begin + getUIx:=ui_x[layer, i]; + end; + + function getUIy(i:integer):integer; + begin + getUIy:=ui_y[layer, i]; + end; + + function getUIw(i:integer):integer; + begin + getUIw:=0; + end; + + function getUIh(i:integer):integer; + begin + getUIh:=0; + end; + +initialization + +end. diff --git a/src/inv.mpsrc b/src/inv.mpsrc new file mode 100644 index 0000000..76ba270 --- /dev/null +++ b/src/inv.mpsrc @@ -0,0 +1,148 @@ +unit inv; + +interface + const + INV_SIZE=35; + + + function getItem(i:integer):integer; + function getSum(i:integer):integer; + procedure setItem(val, i:integer); + procedure setSum(val, i:integer); + function isNull(i:integer):boolean; + procedure fixNull(i:integer); + + function giveItem(ityp, isum:integer):integer; + + procedure resetData; + procedure saveData; + procedure loadData; + +implementation + uses items_store, vars, jsr75i, items, func; + var + inv_item: array [0..INV_SIZE] of integer; + inv_sum: array [0..INV_SIZE] of integer; + + function getItem(i:integer):integer; + begin + getItem:=inv_item[i]; + end; + + function getSum(i:integer):integer; + begin + getSum:=inv_sum[i]; + end; + + procedure setItem(val, i:integer); + begin + inv_item[i]:=val; + end; + + procedure setSum(val, i:integer); + begin + inv_sum[i]:=val; + end; + + function isNull(i:integer):boolean; + begin + if (getItem(i)<1) or (getSum(i)<1) then + isNull:=true; + end; + + procedure fixNull(i:integer); + begin + if isNull(i) then + begin + setItem(0, i); + setSum(0, i); + end; + end; + + //Добавить предмет в инвентарь, возващает количество не полученых предметов. +function giveItem(ityp, isum:integer):integer; + var + i, item, sum:integer; + begin + //Ищем такой же предмет только если он имеет возможность делиться + if getItemDiv(ityp) then + for i:=0 to INV_SIZE do + begin + item:=getItem(i); + sum:=getSum(i); + + if (item=ityp) and (isNull(i)=false) then + if isumgetItemMax(ityp) then + begin + isum:=sum-getItemMax(ityp); + sum:=sum-isum; + end; + + setSum(sum, i); + + if isum<1 then + exit; + end; + end; + + for i:=0 to INV_SIZE do + if isNull(i) then + begin + sum:=isum; + isum:=0; + + if sum>getItemMax(ityp) then + begin + isum:=sum-getItemMax(ityp); + sum:=sum-isum; + end; + + setItem(ityp, i); + setSum(sum, i); + + if isum<1 then + exit; + end; + + giveItem:=isum; + end; + + procedure resetData; + var + i:integer; + begin + for i:=0 to INV_SIZE do + begin + setItem(0, i); + setSum(0, i); + end; + end; + + procedure saveData; + var + i:integer; + begin + for i:=0 to INV_SIZE do + begin + write_byte(getItem(i)); + WriteInt(getSum(i)); + end; + end; + + procedure loadData; + var + i:integer; + begin + for i:=0 to INV_SIZE do + begin + setItem(read_byte, i); + setSum(ReadInt, i); + end; + end; + +end. diff --git a/src/invui.mpsrc b/src/invui.mpsrc new file mode 100644 index 0000000..3b642f5 --- /dev/null +++ b/src/invui.mpsrc @@ -0,0 +1,859 @@ +unit invui; + +interface + procedure OpenFurnaceWindow(furid:integer); + procedure OpenFastCraftWindow(mode:integer); + procedure OpenChestWindow(n:integer;); + procedure OpenCreativeWindow; + procedure OpenPlayerInventory; + procedure DrawWindows; + function WindowKeyHanler:boolean; + +implementation + uses vars, CellUI, console, Canvas, items, utils, craft, furnace, func, items_store, player, keyboard; + const + WINDOW_PLAYER_INV=1; + WINDOW_DIV_ITEMS=2; + WINDOW_CEATIVE_INV=3; + WINDOW_CHEST_INV=4; + WINDOW_FASTCRAFT=5; + WINDOW_FURNACE=6; + + INV_MODE_SELECT1=0; + INV_MODE_SELECT2=1; + INV_MODE_SELECT2_DIV=2; + + MAX_CREATIVE_OFFSET=248;//32*8-8 + MAX_FASTCRAFT_OFFSET=232;//24*10-8 + + WINDOW_INFO_INVMODE=0; + WINDOW_INFO_DIVRES=1; + WINDOW_INFO_FUR_ID=2; + + WINDOW_INFO_DIV_ITEM=0; + WINDOW_INFO_DIV_SUM1=1; + WINDOW_INFO_DIV_SUM2=2; + + WINDOW_INFO_FC_MODE=0; + + var + InvWindowImg:image; + DivWindowImg, DivScrollImg:image; + CrWindowImg, CrScrollImg:image; + ChestWindowImg:image; + fcWindowImg, fcScrollImg, fcCanCraftImg:image; + furWindowImg, furFireImg, furProgressImg:image; + + function calcScrollBar(scrollSize, buttonSize, maxEl, currentEl:integer):integer; + const + DivAccuracy=100000; + begin + if (currentEl=0) or (maxEl=0) then + calcScrollBar:=0; + else + if (currentEl<>maxEl) then + calcScrollBar:=DivAccuracy*(scrollSize-buttonSize)/maxEl*currentEl/DivAccuracy; + else + calcScrollBar:=scrollSize-buttonSize; + end; + + procedure OpenFurnaceWindow(furid:integer); + var + i, j, id:integer; + begin + NewLayer; + SetWindowType(WINDOW_FURNACE); + SetCurActive(true, CUR_SELECT1); + + SetWindowInfo(furid, WINDOW_INFO_FUR_ID); + + if FindCurrentWindowsType=false then + begin + furWindowImg:=ld_tex('furnace.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/'); + furFireImg:=rotate_image_from_image(furWindowImg, 0, 166, 14, 14, 0); + furProgressImg:=rotate_image_from_image(furWindowImg, 14, 166, 24, 17, 0); + furWindowImg:=rotate_image_from_image(furWindowImg, 0, 0, 176, 166, 0); + end; + + for j:=0 to 8 do + begin + initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18, true); + id:=id+1; + end; + + for i:=1 to 3 do + for j:=0 to 8 do + begin + initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18+4, true); + id:=id+1; + end; + + initCell(CELL_TYPE_FURNACE, FURNACE_IN, 0, furid, 56, 97, true); + initCell(CELL_TYPE_FURNACE, FURNACE_FUEL, 0, furid, 56, 133, true); + initCell(CELL_TYPE_FURNACE, FURNACE_OUT, 0, furid, 116, 115, true); + end; + + procedure DrawFurnaceWindow(x, y:integer); + var + furid, i, time:integer; + begin + furid:=GetWindowInfo(WINDOW_INFO_FUR_ID); + + DrawImage(furWindowImg, x, y); + + time:=furnace.getTime; + if furnaceBurn(furid) then + begin + i:=calcScrollBar(14, 0, furnace.FuelTime(furid), furnace.endFuelTime(furid)-time); + debug('i: '+i+'; time: '+time+'; fueltime:'+furnace.FuelTime(furid)+'; c: '+(furnace.endFuelTime(furid)-time)); + SetClip(x+56, y+130-i, 18, i); + DrawImage(furFireImg, x+56, y+116); + + if itemBurn(furid) then + begin + i:=calcScrollBar(24, 0, furnace.ProgTime(furid), furnace.endProgTime(furid)-time); + + SetClip(x+79, y+114, 24-i, 17); + DrawImage(furProgressImg, x+79, y+114); + end; + + SetClip(0, 0, getWidth, getHeight); + end; + + end; + + procedure CloseFurnaceWindow; + var + nullimg:image; + begin + if FindCurrentWindowsType=false then + begin + furWindowImg:=nullimg; + furFireImg:=nullimg; + furProgressImg:=nullimg; + end; + DelLayer; + end; + + procedure OpenFastCraftWindow(mode:integer); + var + i, j, id:integer; + begin + NewLayer; + SetWindowType(WINDOW_FASTCRAFT); + SetCurActive(true, CUR_SELECT1); + + SetWindowInfo(mode, WINDOW_INFO_FC_MODE); + + if FindCurrentWindowsType=false then + begin + fcWindowImg:=ld_tex('fastcraft.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/'); + fcScrollImg:=rotate_image_from_image(fcWindowImg, 0, 126, 12, 15, 0); + fcCanCraftImg:=rotate_image_from_image(fcWindowImg, 12, 126, 20, 18, 0); + fcWindowImg:=rotate_image_from_image(fcWindowImg, 0, 0, 176, 126, 0); + end; + + for i:=0 to 2 do + for j:=0 to 7 do + begin + initCell(CELL_TYPE_FASTCRAFT, id, 0, -1, 8+j*18, 66+i*18, false); + id:=id+1; + end; + end; + + procedure DrawFastCraftWindow(x, y:integer); + var + mode, craftid:integer; + i, j, id:integer; + begin + mode:=GetWindowInfo(WINDOW_INFO_FC_MODE); + craftid:=getCellID(GetCurIndex(GetCur))+GetOffset(0);//FIX IT! Indexes + + DrawImage(fcWindowImg, x, y); + if canCreateCraft(craftid, mode) then + DrawImage(fcCanCraftImg, x+87, y+26); + + for i:=0 to 1 do + for j:=0 to 1 do + begin + drawItem(getCraftInItem(craftid, id), getCraftInSum(craftid, id), x+52+j*18, y+17+i*18, true); + id:=id+1; + end; + + drawItem(getCraftOutItem(craftid), getCraftOutSum(craftid), x+108, y+27, true); + + i:=calcScrollBar(52, getImageHeight(fcScrollImg), MAX_FASTCRAFT_OFFSET, getOffset(0)); + drawimage(fcScrollImg, x+156, y+66+i); + end; + + procedure CloseFastCraftWindow; + var + nullimg:image; + begin + if FindCurrentWindowsType=false then + begin + fcWindowImg:=nullimg; + fcScrollImg:=nullimg; + fcCanCraftImg:=nullimg; + end; + DelLayer; + end; + + procedure FindFastCraftUD(n:integer;); + var + old_cur, offset:integer; + begin + old_cur:=GetCurIndex(GetCur); + offset:=getOffset(0); + + if n<0 then + ShiftCurrentCur(FIND_CELL_UP); + if n>0 then + ShiftCurrentCur(FIND_CELL_DOWN); + + if old_cur=GetCurIndex(GetCur) then + begin + if n<0 then + begin + offset:=offset-8; + if offset<0 then + offset:=0; + end; + else + if n>0 then + begin + offset:=offset+8; + if offset>MAX_FASTCRAFT_OFFSET then + offset:=MAX_FASTCRAFT_OFFSET; + end; + end; + + SetOffset(offset, 0); + end; + + procedure OpenChestWindow(n:integer;); + var + i, j, id:integer; + begin + NewLayer; + SetWindowType(WINDOW_CHEST_INV); + SetCurActive(true, CUR_SELECT1); + + if FindCurrentWindowsType=false then + begin + ChestWindowImg:=ld_tex('container.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/'); + end; + + for j:=0 to 8 do + begin + initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18, true); + id:=id+1; + end; + + for i:=1 to 3 do + for j:=0 to 8 do + begin + initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18+4, true); + id:=id+1; + end; + + id:=0; + for i:=0 to 2 do + for j:=0 to 8 do + begin + initCell(CELL_TYPE_CHEST, id, 0, n, 8+j*18, 88+i*18, true); + id:=id+1; + end; + end; + + procedure CloseChestWindow; + var + nullimg:image; + begin + if FindCurrentWindowsType=false then + begin + ChestWindowImg:=nullimg; + end; + DelLayer; + end; + + procedure OpenCreativeWindow; + var + i, j, id:integer; + begin + NewLayer; + SetWindowType(WINDOW_CEATIVE_INV); + SetCurActive(true, CUR_SELECT1); + + if FindCurrentWindowsType=false then + begin + CrWindowImg:=ld_tex('creative.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/'); + CrScrollImg:=rotate_image_from_image(CrWindowImg, 0, 108, 12, 15, 0); + CrWindowImg:=rotate_image_from_image(CrWindowImg, 0, 0, 176, 108, 0); + end; + + for j:=0 to 8 do + begin + initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18, true); + id:=id+1; + end; + + id:=0; + for i:=0 to 3 do + for j:=0 to 7 do + begin + initCell(CELL_TYPE_CREWATIVE_INV, id, 1, -1, 8+j*18, 30+i*18, false); + id:=id+1; + end; + end; + + procedure DrawCreativeWindow(x, y:integer;); + var + scroll, i:integer; + begin + DrawImage(CrWindowImg, x, y); + scroll:=getOffset(1); + i:=calcScrollBar(70, getImageHeight(CrScrollImg), MAX_CREATIVE_OFFSET, scroll); + drawimage(CrScrollImg, x+156, y+30+i); + end; + + procedure FindCeativeUD(n:integer;); + var + old_cur, offset:integer; + begin + old_cur:=GetCurIndex(GetCur); + offset:=getOffset(1); + + if n<0 then + ShiftCurrentCur(FIND_CELL_UP); + if n>0 then + ShiftCurrentCur(FIND_CELL_DOWN); + + if old_cur=GetCurIndex(GetCur) then + begin + if n<0 then + begin + offset:=offset-8; + if offset<0 then + offset:=0; + end; + else + if n>0 then + begin + offset:=offset+8; + if offset>MAX_CREATIVE_OFFSET then + offset:=MAX_CREATIVE_OFFSET; + end; + end; + + SetOffset(offset, 1); + end; + + procedure CloseCreativeWindow; + var + nullimg:image; + begin + if FindCurrentWindowsType=false then + begin + CrWindowImg:=nullimg; + CrScrollImg:=nullimg; + end; + DelLayer; + end; + + procedure OpenDivWindow; + var + item, sum:integer; + begin + debug('Open Div Window'); + item:=getItem(GetCurIndex(GetCur)); + sum:=getSum(GetCurIndex(GetCur)); + + NewLayer; + SetWindowType(WINDOW_DIV_ITEMS); + + if FindCurrentWindowsType=false then + begin + DivWindowImg:=ld_tex('partition.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/'); + DivScrollImg:=rotate_image_from_image(DivWindowImg, 0, 50, 15, 12, 0); + DivWindowImg:=rotate_image_from_image(DivWindowImg, 0, 0, 88, 50, 0); + end; + + SetWindowInfo(item, WINDOW_INFO_DIV_ITEM); + SetWindowInfo(sum, WINDOW_INFO_DIV_SUM1); + end; + + procedure DivScroll(pp:integer); + var + sum1, sum2:integer; + begin + sum1:=GetWindowInfo(WINDOW_INFO_DIV_SUM1); + sum2:=GetWindowInfo(WINDOW_INFO_DIV_SUM2); + + sum2:=sum2+pp; + if sum2<0 then + sum2:=0; + if sum2>sum1 then + sum2:=sum1; + + SetWindowInfo(sum2, WINDOW_INFO_DIV_SUM2); + end; + + procedure DrawDivWindow(x, y:integer); + var + i, item, sum1, sum2:integer; + begin + DrawImage(DivWindowImg, x, y); + + item:=GetWindowInfo(WINDOW_INFO_DIV_ITEM); + sum1:=GetWindowInfo(WINDOW_INFO_DIV_SUM1); + sum2:=GetWindowInfo(WINDOW_INFO_DIV_SUM2); + + drawItem(item, (sum1-sum2), x+8, y+8, true); + drawItem(item, sum2, x+64, y+8, true); + + i:=calcScrollBar(72, getImageWidth(DivScrollImg), sum1, sum2); + + drawimage(DivScrollImg, x+8+i, y+30); + end; + + procedure CloseDivWindow(return_val:boolean); + var + res:integer; + nullimg:image; + begin + debug('Close Div Window'); + res:=GetWindowInfo(WINDOW_INFO_DIV_SUM2); + //Если таких окон нет, то чистим память + if FindCurrentWindowsType=false then + begin + DivWindowImg:=nullimg; + DivScrollImg:=nullimg; + end; + DelLayer; + SetWindowInfo(res, WINDOW_INFO_DIVRES); + + if return_val then + begin + SetCur(CUR_SELECT2); + SetCurActive(true, CUR_SELECT2); + SetCurIndex(GetCurIndex(CUR_SELECT1), CUR_SELECT2); + SetWindowInfo(INV_MODE_SELECT2_DIV, WINDOW_INFO_INVMODE); + end; + end; + + procedure OpenPlayerInventory; + var + i, j, id:integer; + begin + NewLayer; + SetWindowType(WINDOW_PLAYER_INV); + SetCurActive(true, CUR_SELECT1); + + //Если таких окон нет, то загружаем графику + if FindCurrentWindowsType=false then + begin + InvWindowImg:=ld_tex('inventory.png','/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/','gui/'); + end; + + for j:=0 to 8 do + begin + initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18, true); + id:=id+1; + end; + + for i:=1 to 3 do + for j:=0 to 8 do + begin + initCell(CELL_TYPE_PLAYER_INV, id, 0, -1, 8+j*18, 8+i*18+4, true); + id:=id+1; + end; + end; + + procedure ClosePlayerInventory; + var + nullimg:image; + begin + debug('Close Player Inventory'); + //Если таких окон нет, то чистим память + if FindCurrentWindowsType=false then + begin + InvWindowImg:=nullimg; + end; + DelLayer; + end; + + procedure DrawWindows; + var + max:integer; + i, wtype, x, y:integer; + begin + max:=CellLayer; + for i:=0 to max do + begin + setCellLayer(i); + wtype:=GetWindowType; + if wtype=WINDOW_PLAYER_INV then + begin + x:=getWidth/2-getImageWidth(InvWindowImg)/2; + y:=getHeight/2-getImageHeight(InvWindowImg)/2; + DrawImage(InvWindowImg, x, y); + end; + else + if wtype=WINDOW_DIV_ITEMS then + begin + x:=getWidth/2-getImageWidth(DivWindowImg)/2; + y:=getHeight/2-getImageHeight(DivWindowImg)/2; + DrawDivWindow(x, y); + end; + else + if wtype=WINDOW_CEATIVE_INV then + begin + x:=getWidth/2-getImageWidth(CrWindowImg)/2; + y:=getHeight/2-getImageHeight(CrWindowImg)/2; + DrawCreativeWindow(x, y); + end; + else + if wtype=WINDOW_CHEST_INV then + begin + x:=getWidth/2-getImageWidth(ChestWindowImg)/2; + y:=getHeight/2-getImageHeight(ChestWindowImg)/2; + DrawImage(ChestWindowImg, x, y); + end; + else + if wtype=WINDOW_FASTCRAFT then + begin + x:=getWidth/2-getImageWidth(fcWindowImg)/2; + y:=getHeight/2-getImageHeight(fcWindowImg)/2; + DrawFastCraftWindow(x, y); + end; + else + if wtype=WINDOW_FURNACE then + begin + x:=getWidth/2-getImageWidth(furWindowImg)/2; + y:=getHeight/2-getImageHeight(furWindowImg)/2; + DrawFurnaceWindow(x, y); + end; + DrawCellLayer(i, x, y); + DrawCursors(i, x, y); + end; + end; + + procedure OpSwapItems(Idx1, Idx2:integer); + var + tmp_item, tmp_sum:integer; + begin + tmp_item:=getItem(Idx1); + tmp_sum:=getSum(Idx1); + + setItem(getItem(Idx2), Idx1); + setSum(getSum(Idx2), Idx1); + + setItem(tmp_item, Idx2); + setSum(tmp_sum, Idx2); + end; + + function OpAddItems(Idx1, Idx2:integer):boolean; + var + tmp_item1, tmp_sum1:integer; + tmp_item2, tmp_sum2:integer; + fresult:boolean; + begin + tmp_item1:=GetItem(Idx1); + tmp_sum1:=GetSum(Idx1); + tmp_item2:=GetItem(Idx2); + tmp_sum2:=GetSum(Idx2); + fresult:=true; + + if (tmp_item1=tmp_item2) and (Idx1<>Idx2) then + if tmp_sum2getItemMax(tmp_item2) then + begin + tmp_sum1:=tmp_sum2-getItemMax(tmp_item2); + tmp_sum2:=tmp_sum2-tmp_sum1; + end; + + if tmp_sum1<=0 then + tmp_item1:=0; + + fresult:=false; + end; + + SetItem(tmp_item1, Idx1); + SetSum(tmp_sum1, Idx1); + SetItem(tmp_item2, Idx2); + SetSum(tmp_sum2, Idx2); + OpAddItems:=fresult; + end; + + procedure SetActiveCursor(n:integer;); + var + n2:integer; + begin + if n=CUR_SELECT1 then + n2:=CUR_SELECT2; + else + n2:=CUR_SELECT1; + + SetCur(n); + SetCurActive(true, n); + SetCurIndex(GetCurIndex(n2), n); + end; + + procedure decItem(curidx:integer); + begin + SetSum(GetSum(curidx)-1, curidx); + fixNullCell(curidx); + end; + + procedure HandlerSelect2Div; + var + idx1, idx2:integer; + begin + idx1:=GetCurIndex(CUR_SELECT1); + idx2:=GetCurIndex(CUR_SELECT2); + + if GetItem(idx2)=0 then + begin + SetItem(GetItem(idx1), idx2); + SetSum(GetWindowInfo(WINDOW_INFO_DIVRES), idx2); + + SetSum(GetSum(idx1)-GetSum(idx2), idx1); + fixNullCell(idx1); + end; + end; + + procedure Select; + var + mode:integer; + begin + mode:=GetWindowInfo(WINDOW_INFO_INVMODE); + + //Нажали кнопку - выбрали первый элемент + if mode=INV_MODE_SELECT1 then + begin + //Активируем второй курсор и ставим его над первым курсором + SetActiveCursor(CUR_SELECT2); + SetWindowInfo(INV_MODE_SELECT2, WINDOW_INFO_INVMODE); + end; + else + //Нажали кнопку - выбрали второй элемент, произвели сложение и переходим к режиму выбора первого элемента. + if mode=INV_MODE_SELECT2 then + begin + //Складывваем предметы курсора 1 и курсора 2 + if OpAddItems(GetCurIndex(CUR_SELECT1), GetCurIndex(CUR_SELECT2)) then + OpSwapItems(GetCurIndex(CUR_SELECT1), GetCurIndex(CUR_SELECT2)); + //Передаём управление первому курсору + SetActiveCursor(CUR_SELECT1); + SetCurActive(false, CUR_SELECT2); + SetWindowInfo(INV_MODE_SELECT1, WINDOW_INFO_INVMODE); + end; + else + if mode=INV_MODE_SELECT2_DIV then + begin + HandlerSelect2Div; + SetActiveCursor(CUR_SELECT1); + SetCurActive(false, CUR_SELECT2); + SetWindowInfo(INV_MODE_SELECT1, WINDOW_INFO_INVMODE); + end; + end; + + function CanDivItem:boolean; + begin + if getItemDiv(getItem(GetCurIndex(GetCur))) then + if (GetCur=CUR_SELECT1) and (getSum(GetCurIndex(GetCur))>0) then + CanDivItem:=true; + end; + + procedure StdCellKeyHandler; + begin + if clickedKey(KEY_WIN_SELECT) then + SetTimer(1000, T_KEY_DIVITEM); + + if pressedKey(KEY_WIN_SELECT) then + begin + if GetTimer(T_KEY_DIVITEM)=TIMER_OK then + begin + if CanDivItem then + OpenDivWindow; + ResetTimer(T_KEY_DIVITEM); + end; + end; + else + begin + if GetTimer(T_KEY_DIVITEM)>TIMER_OK then + begin + Select; + ResetTimer(T_KEY_DIVITEM); + end; + end; + end; + + procedure keyDrop; + var + item, curidx:integer; + begin + curidx:=GetCurIndex(GetCur); + item:=getItem(curidx); + + if clickedKey(KEY_WIN_DROP) then + SetTimer(1000, T_KEY_DROPITEM); + + if pressedKey(KEY_WIN_DROP) then + begin + if GetTimer(T_KEY_DROPITEM)=TIMER_OK then + begin + player.dropItem(item, GetSum(curidx)); + SetItem(0, curidx); + SetSum(0, curidx); + ResetTimer(T_KEY_DROPITEM); + end; + end; + else + begin + if GetTimer(T_KEY_DROPITEM)>TIMER_OK then + begin + if getItemDiv(item) then + begin + player.dropItem(item, 1); + decItem(curidx); + end; + ResetTimer(T_KEY_DROPITEM); + end; + end; + end; + + function WindowKeyHanler:boolean; + var + WinType:integer; + craftid, mode:integer; + begin + WinType:=GetWindowType; + if WinType=WINDOW_PLAYER_INV then + begin + if clickedKey(KEY_WIN_UP) then + ShiftCurrentCur(FIND_CELL_UP); + if clickedKey(KEY_WIN_DOWN) then + ShiftCurrentCur(FIND_CELL_DOWN); + if clickedKey(KEY_WIN_LEFT) then + ShiftCurrentCur(FIND_CELL_LEFT); + if clickedKey(KEY_WIN_RIGHT) then + ShiftCurrentCur(FIND_CELL_RIGHT); + + StdCellKeyHandler; + keyDrop; + + if clickedKey(KEY_WIN_EXIT) then + ClosePlayerInventory; + + if clickedKey(KEY_WIN_ALT) then + begin + ClosePlayerInventory; + OpenFastCraftWindow(0); + end; + end; + else + if WinType=WINDOW_DIV_ITEMS then + begin + if clickedKey(KEY_WIN_LEFT) then + DivScroll(-1); + if clickedKey(KEY_WIN_RIGHT) then + DivScroll(1); + + if clickedKey(KEY_WIN_SELECT) then + CloseDivWindow(true); + + if clickedKey(KEY_WIN_EXIT) then + CloseDivWindow(false); + end; + else + if WinType=WINDOW_CEATIVE_INV then + begin + if clickedKey(KEY_WIN_UP) then + FindCeativeUD(-1); + if clickedKey(KEY_WIN_DOWN) then + FindCeativeUD(1); + if clickedKey(KEY_WIN_LEFT) then + ShiftCurrentCur(FIND_CELL_LEFT); + if clickedKey(KEY_WIN_RIGHT) then + ShiftCurrentCur(FIND_CELL_RIGHT); + + StdCellKeyHandler; + keyDrop; + + if clickedKey(KEY_WIN_EXIT) then + CloseCreativeWindow; + end; + else + if WinType=WINDOW_CHEST_INV then + begin + if clickedKey(KEY_WIN_UP) then + ShiftCurrentCur(FIND_CELL_UP); + if clickedKey(KEY_WIN_DOWN) then + ShiftCurrentCur(FIND_CELL_DOWN); + if clickedKey(KEY_WIN_LEFT) then + ShiftCurrentCur(FIND_CELL_LEFT); + if clickedKey(KEY_WIN_RIGHT) then + ShiftCurrentCur(FIND_CELL_RIGHT); + + StdCellKeyHandler; + keyDrop; + + if clickedKey(KEY_WIN_EXIT) then + CloseChestWindow; + end; + else + if WinType=WINDOW_FASTCRAFT then + begin + if clickedKey(KEY_WIN_UP) then + FindFastCraftUD(-1); + if clickedKey(KEY_WIN_DOWN) then + FindFastCraftUD(1); + if clickedKey(KEY_WIN_LEFT) then + ShiftCurrentCur(FIND_CELL_LEFT); + if clickedKey(KEY_WIN_RIGHT) then + ShiftCurrentCur(FIND_CELL_RIGHT); + + if clickedKey(KEY_WIN_SELECT) then + begin + mode:=GetWindowInfo(WINDOW_INFO_FC_MODE); + craftid:=getCellID(GetCurIndex(GetCur))+GetOffset(0); + createCraft(craftid, mode); + end; + + if clickedKey(KEY_WIN_ALT) then + begin + CloseChestWindow; + OpenPlayerInventory; + end; + + if clickedKey(KEY_WIN_EXIT) then + CloseChestWindow; + end; + else + if WinType=WINDOW_FURNACE then + begin + if clickedKey(KEY_WIN_UP) then + ShiftCurrentCur(FIND_CELL_UP); + if clickedKey(KEY_WIN_DOWN) then + ShiftCurrentCur(FIND_CELL_DOWN); + if clickedKey(KEY_WIN_LEFT) then + ShiftCurrentCur(FIND_CELL_LEFT); + if clickedKey(KEY_WIN_RIGHT) then + ShiftCurrentCur(FIND_CELL_RIGHT); + + StdCellKeyHandler; + keyDrop; + + if clickedKey(KEY_WIN_EXIT) then + CloseFurnaceWindow; + end; + else + WindowKeyHanler:=true; + end; + +end. diff --git a/src/items.mpsrc b/src/items.mpsrc new file mode 100644 index 0000000..3c84b8d --- /dev/null +++ b/src/items.mpsrc @@ -0,0 +1,98 @@ +unit items; + +interface + const + ITEM_TYPE_BLOCK=0; + ITEM_TYPE_TOOL=1; + + ITEM_FLAG_IND1=1; + ITEM_FLAG_IND2=2; + ITEM_FLAG_DIV=4; + ITEM_FLAG_TEX=8; + var + compas:image; + clock:array[0..7] of image; + none0:image; + clock_stage:integer; + + function getBlockTrans(id:integer;):boolean; + function getBlockFore(id:integer;):boolean; + function getBlockSet(id:integer;):boolean; + + function getItemIndNum(id:integer):boolean; + function getItemIndLine(id:integer):boolean; + function getItemDiv(id:integer):boolean; + function getItemTexType(id:integer):integer; + + procedure setMaxItemList(i:integer); + procedure setItemList(item, i:integer); + function getItemList(i:integer):integer; + +implementation + uses items_store; + const + BLOCK_FLAG_Trans=1; + BLOCK_FLAG_FORE=2; + BLOCK_FLAG_SET=4; + + var + itemListSize:integer; + itemList: array [0..0] of integer; + + function getBlockTrans(id:integer;):boolean; + begin + getBlockTrans:=(getBlockFlags(id) and BLOCK_FLAG_Trans)>0; + end; + + function getBlockFore(id:integer;):boolean; + begin + getBlockFore:=(getBlockFlags(id) and BLOCK_FLAG_FORE)>0; + end; + + function getBlockSet(id:integer;):boolean; + begin + getBlockSet:=(getBlockFlags(id) and BLOCK_FLAG_SET)>0; + end; + + function getItemIndNum(id:integer):boolean; + begin + getItemIndNum:=(getItemFlags(id) and ITEM_FLAG_IND1)>0; + end; + + function getItemIndLine(id:integer):boolean; + begin + getItemIndLine:=(getItemFlags(id) and ITEM_FLAG_IND2)>0; + end; + + function getItemDiv(id:integer):boolean; + begin + getItemDiv:=(getItemFlags(id) and ITEM_FLAG_DIV)>0; + end; + + function getItemTexType(id:integer):integer; + begin + getItemTexType:=(getItemFlags(id) and ITEM_FLAG_TEX)>>3; + end; + + procedure setMaxItemList(i:integer); + begin + itemListSize:=i; + i:=i+1; + bytecode + iload 0; + newarray 10; + putstatic field 'items', 'itemlist', '[I'; + end; + end; + + procedure setItemList(i, item:integer); + begin + itemList[i]:=item; + end; + + function getItemList(i:integer):integer; + begin + if (i>=0) and (i<=itemListSize) then + getItemList:=itemList[i]; + end; +end. diff --git a/src/items_logic.mpsrc b/src/items_logic.mpsrc new file mode 100644 index 0000000..d490072 --- /dev/null +++ b/src/items_logic.mpsrc @@ -0,0 +1,1432 @@ +unit items_logic; + +interface + function set_block_code(it,xx,yy:integer):boolean;//Выполнение кода при установке блока + procedure destroy_block_cr(id,xx,yy:integer);//Выполнение кода при разрушении блока в креативе + procedure destroy_block_0(id,xx,yy:integer);//Выполнение кода при разрушении блока не "тем" инструментом + procedure destroy_block_1(id,xx,yy:integer);//Выполнение кода при разрушении блока "нужным" инструментом + + function useBlock(invcur, x, y:integer):boolean; + function useItem(invcur, x, y:integer):boolean; + + procedure updateBlock(x, y:integer); + +implementation + uses invui, maps, drop, console, furnace, png3, func, jpeg, mob, vars, bmp, items, chest, inv, player, items_store, particles, worldgen, phy, sign; + +procedure usebonemeal(block:integer); + var + ix,iy,rnd_set:integer; + begin + if block=2 then + begin + for ix:=curx-4 to curx+4 do + for iy:=cury-4 to cury+4 do + begin + if (getmap(ix,iy+1)=2) and (getmap(ix,iy)=0) then + begin + rnd_set:=random(3); + if rnd_set=0 then setmap(22,ix,iy); else + if rnd_set=1 then setmap(23,ix,iy); else + if rnd_set=2 then setmap(57,ix,iy); else + end; + end; + inv.setSum(inv.getSum(invslot)-1, invslot); + inv.fixNull(invslot); + end; else + if block=122 then + begin + setmapinfo(3,curx,cury); + inv.setSum(inv.getSum(invslot)-1, invslot); + inv.fixNull(invslot); + end; + else + if (block=123) or (block=124) then + begin + setmapinfo(8,curx,cury); + inv.setSum(inv.getSum(invslot)-1, invslot); + inv.fixNull(invslot); + end; + else + if block=52 then + begin + genwood1(curx, cury); + inv.setSum(inv.getSum(invslot)-1, invslot); + inv.fixNull(invslot); + end; + else + if block=114 then + begin + genwood2(curx, cury); + inv.setSum(inv.getSum(invslot)-1, invslot); + inv.fixNull(invslot); + end; + else + if block=115 then + begin + genwood3(curx, cury); + inv.setSum(inv.getSum(invslot)-1, invslot); + inv.fixNull(invslot); + end; + end; + +function searchportal(ix,iy:integer):boolean; + begin + 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 + searchportal:=true; else + searchportal:=false; + end; + +procedure create_screenshot_png; + var + screen:image; + date:string; + i,time:integer; + begin + time:=getCurrentTime; + screen:=ImageFromCanvas(0,0,getWidth,getHeight); + date:=''+getWeekDay(time)+'-'+getMonth(time)+'-'+getDay(time)+'_'+getHour(time)+'.'+getMinute(time)+'.'+getSecond(time); + i:=save_png(screen,sd+'/cavecraft/screenshots/'+date+'.png'); + addToLog('Screenshot saved!'); + end; + +procedure create_screenshot_jpeg; + var + screen:image; + date:string; + time:integer; + begin + time:=getCurrentTime; + screen:=ImageFromCanvas(0,0,getWidth,getHeight); + date:=''+getWeekDay(time)+'-'+getMonth(time)+'-'+getDay(time)+'_'+getHour(time)+'.'+getMinute(time)+'.'+getSecond(time); + jpeg.saveimagetofile(screen,s_jpeg_quality,'/'+sd+'/cavecraft/screenshots/'+date+'.jpg'); + addToLog('Screenshot saved!'); + end; + +procedure create_screenshot_bmp; + var + screen:image; + date:string; + time:integer; + begin + time:=getCurrentTime; + screen:=ImageFromCanvas(0,0,getWidth,getHeight); + date:=''+getWeekDay(time)+'-'+getMonth(time)+'-'+getDay(time)+'_'+getHour(time)+'.'+getMinute(time)+'.'+getSecond(time); + savebmp(screen,'/'+sd+'/cavecraft/screenshots/'+date+'.bmp'); + addToLog('Screenshot saved!'); + end; + +procedure boom(rr,mm,xx,yy:integer); + var + ix,iy,iz,ir,imob,erru,minhp:integer; + rays:array [0..359] of integer; + mobs_minhp:array[0..31] of integer; + begin + {setmap(0,xx,yy); + setmapinfo(0,xx,yy); + for iz:=0 to 359 do + rays[iz]:=mm; + + for ir:=1 to rr do + for iz:=0 to 359 do + if rays[iz]>0 then + begin + if (iz>=0) and (iz<=180) and (ir=1) then erru:=-1; else erru:=0; + if (iz>=180) and (iz<=360) and (ir=1) then erru:=1; else erru:=0; + ix:=xx+trunc(cos(iz)*ir)+erru; + iy:=yy+trunc(sin(iz)*ir)+erru; + rays[iz]:=rays[iz]-getBlockHp(getmap(ix,iy)); + if rays[iz]<0 then rays[iz]:=0; + if coll_boom(ix,iy)=true then minhp:=minhp+(rays[iz]*2); + for imob:=0 to 31 do + if mob[imob].m_hp>0 then + begin + 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; + end; + if getmap(ix,iy)=27 then boom(4,100,ix,iy); + if getBlockHp(getmap(ix,iy))<=mm then + begin + if 30<=random(100) then destroy_block_1(getmap(ix,iy),ix,iy); + setmap(0,ix,iy); + create_particle(7,(ix*16)+8-16,(iy*16)+8-16); + end; + end; + minhp:=minhp/360; + hp:=hp-minhp; + for imob:=0 to 31 do + begin + mobs_minhp[imob]:=mobs_minhp[imob]/360; + mob[imob].m_hp:=mob[imob].m_hp-mobs_minhp[imob]; + end;} + end; + +procedure destroy_block_cr(id, xx, yy:integer); + begin + if id=27 then + begin + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; else + if id=28 then + begin + setmap(0,xx,yy); + chest.destroy(false, xx, yy); + end; else + if id=62 then + begin + setmap(50,xx,yy); + end; else + if id=62 then + begin + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; else + if id=66 then + begin + setmap(0,xx,yy); + setmapinfo(8,xx+1,yy); + end; else + if id=73 then + begin + setmap(0,xx,yy); + setmapinfo(8,xx+1,yy); + end; else + if id=77 then + begin + setmap(0,xx,yy); + setmap(0,xx+1,yy); + end; else + if id=78 then + begin + setmap(0,xx,yy); + setmap(0,xx-1,yy); + end; else + if id=79 then + begin + setmap(0,xx,yy); + setmap(0,xx,yy+1); + end; else + if id=80 then + begin + setmap(0,xx,yy); + setmap(0,xx,yy-1); + end; else + if id=81 then + begin + setmap(0,xx,yy); + setmap(0,xx,yy-1); + end; else + if id=82 then + begin + setmap(0,xx,yy); + setmap(0,xx,yy-1); + end; else + if id=102 then + begin + setmap(0,xx,yy); + chest.destroy(false, xx, yy); + end; else + if id=104 then + begin + setmap(0,xx,yy); + destsign(getmapinfo(xx,yy)); + end; else + if id=106 then + begin + setmap(0,xx,yy); + DestroyFurnace(xx, yy); + end; else + if id=121 then + begin + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; else + if id=122 then + begin + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; else + begin + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; + end; + + function set_block_code(it,xx,yy:integer):boolean;//Если false тогда блок устанавливается + begin + if it=28 then + begin + if chest.create(xx,yy)=-1 then set_block_code:=true; + end; else + if it=102 then + begin + if chest.create(xx,yy)=-1 then set_block_code:=true; + end; + if it=104 then + begin + if createsign(xx,yy)=-1 then set_block_code:=true; + end; else + if it=106 then + begin + if CreateFurnace(xx, yy)=FURNACE_ERROR then + set_block_code:=true; + end; else + if it=121 then + begin + setmapinfo(16,xx,yy); + set_block_code:=false; + end; else + set_block_code:=false; + end; + + procedure destroy_block_0(id,xx,yy:integer); + begin + if id=27 then + begin + setmapinfo(0,xx,yy); + end; else + if id=21 then + begin + if random(8)=random(8) then drop.create(201,1,xx*16+4,yy*16+4); else + if random(5)=random(5) then drop.create(52,1,xx*16+4,yy*16+4); + end; else + if id=28 then + begin + chest.destroy(false, xx, yy); + end; else + if id=57 then + begin + if random(4)=random(4) then drop.create(217,1,xx*16+4,yy*16+4); + end; else + if id=62 then + begin + setmap(50,xx,yy); + end; else + if id=62 then + begin + setmapinfo(0,xx,yy); + end; else + if id=77 then + begin + setmap(0,xx+1,yy); + end; else + if id=78 then + begin + setmap(0,xx-1,yy); + end; else + if id=79 then + begin + setmap(0,xx,yy+1); + end; else + if id=80 then + begin + setmap(0,xx,yy-1); + end; else + if id=81 then + begin + setmap(0,xx,yy+1); + end; else + if id=82 then + begin + setmap(0,xx,yy-1); + end; else + if id=102 then + begin + chest.destroy(true, xx, yy); + end; else + if id=104 then + begin + destsign(getmapinfo(xx,yy)); + end; else + if id=106 then + begin + DestroyFurnace(xx, yy); + end; else + if id=112 then + begin + if random(8)=random(8) then drop.create(201,1,xx*16+4,yy*16+4); else + if random(5)=random(5) then drop.create(114,1,xx*16+4,yy*16+4); + end; else + if id=87 then + begin + if random(10)=random(10) then drop.create(115,1,xx*16+4,yy*16+4); + end; else + if id=121 then + begin + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; else + if id=122 then + begin + if getmapinfo(xx,yy)<3 then drop.create(217,random(4),xx*16+4,yy*16+4); else + 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; + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; + if (id=123) or (id=124) then + begin + drop.create(221+(id-123),random(4),xx*16+4,yy*16+4); + end; + //setmap(0,xx,yy); + //setmapinfo(0,xx,yy); + end; + + procedure destroy_block_1(id,xx,yy:integer); + begin + if id=27 then + begin + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; else + if id=2 then + begin + drop.create(1,1,xx*16+4,yy*16+4); + end; else + if id=3 then + begin + drop.create(5,1,xx*16+4,yy*16+4); + end; else + if id=8 then + begin + if random(10)=random(10) then drop.create(207,1,xx*16+4,yy*16+4); else + drop.create(8,1,xx*16+4,yy*16+4); + end; else + if id=11 then + begin + drop.create(170,3,xx*16+4,yy*16+4); + end; else + if id=18 then + begin + drop.create(160,1,xx*16+4,yy*16+4); + end; else + if id=19 then + begin + drop.create(162,1,xx*16+4,yy*16+4); + end; else + if id=20 then + begin + drop.create(161,4+random(2),xx*16+4,yy*16+4); + end; else + if id=28 then + begin + chest.destroy(true, xx, yy); + drop.create(28,1,xx*16+4,yy*16+4); + end; else + if id=48 then + begin + drop.create(1,1,xx*16+4,yy*16+4); + end; else + if id=50 then + begin + drop.create(0,0,xx*16+4,yy*16+4); + end; else + if id=51 then + begin + drop.create(0,0,xx*16+4,yy*16+4); + end; else + if id=54 then + begin + drop.create(166,4+random(4),xx*16+4,yy*16+4); + end; else + if id=59 then + begin + drop.create(167,1,xx*16+4,yy*16+4); + end; else + if id=61 then + begin + drop.create(168,4+random(2),xx*16+4,yy*16+4); + end; else + if id=62 then + begin + setmap(0,xx,yy); + end; else + if id=63 then + begin + drop.create(168,1,xx*16+4,yy*16+4); + end; else + if id=64 then + begin + drop.create(169,4,xx*16+4,yy*16+4); + end; else + if id=66 then + begin + setmapinfo(8,xx+1,yy); + drop.create(66,1,xx*16+4,yy*16+4); + end; else + if id=73 then + begin + drop.create(176,3+random(4),xx*16+4,yy*16+4); + setmapinfo(8,xx+1,yy); + end; else + if id=74 then + begin + drop.create(1,1,xx*16+4,yy*16+4); + end; else + if id=75 then + begin + drop.create(9,1,xx*16+4,yy*16+4); + end; else + if id=76 then + begin + setmapinfo(0,xx,yy); + end; else + if id=77 then + begin + drop.create(179,1,xx*16+4,yy*16+4); + setmap(0,xx+1,yy); + end; else + if id=78 then + begin + drop.create(179,1,xx*16+4,yy*16+4); + setmap(0,xx-1,yy); + end; else + if id=79 then + begin + drop.create(178,1,xx*16+4,yy*16+4); + setmap(0,xx,yy+1); + end; else + if id=80 then + begin + drop.create(178,1,xx*16+4,yy*16+4); + setmap(0,xx,yy-1); + end; else + if id=81 then + begin + drop.create(178,1,xx*16+4,yy*16+4); + setmap(0,xx,yy+1); + end; else + if id=82 then + begin + drop.create(178,1,xx*16+4,yy*16+4); + setmap(0,xx,yy-1); + end; else + if id=84 then + begin + drop.create(83,1,xx*16+4,yy*16+4); + end; else + if id=86 then + begin + drop.create(85,1,xx*16+4,yy*16+4); + end; else + if id=88 then + begin + drop.create(24,random(3)-1,xx*16+4,yy*16+4); + end; else + if id=89 then + begin + drop.create(24,random(3)-1,xx*16+4,yy*16+4); + end; else + if id=90 then + begin + drop.create(25,random(3)-1,xx*16+4,yy*16+4); + end; else + if id=91 then + begin + drop.create(25,random(3)-1,xx*16+4,yy*16+4); + end; else + if id=93 then + begin + drop.create(92,1,xx*16+4,yy*16+4); + end; else + if id=94 then + begin + drop.create(4,1,xx*16+4,yy*16+4); + end; else + if id=95 then + begin + drop.create(187,1,xx*16+4,yy*16+4); + end; else + if id=95 then + begin + drop.create(187,1,xx*16+4,yy*16+4); + end; else + if id=95 then + begin + drop.create(187,1,xx*16+4,yy*16+4); + end; else + if id=96 then + begin + drop.create(187,1,xx*16+4,yy*16+4); + end; else + if id=97 then + begin + drop.create(187,1,xx*16+4,yy*16+4); + end; else + if id=98 then + begin + drop.create(187,1,xx*16+4,yy*16+4); + end; else + if id=99 then + begin + drop.create(187,1,xx*16+4,yy*16+4); + end; else + if id=100 then + begin + drop.create(187,1,xx*16+4,yy*16+4); + end; else + if id=101 then + begin + drop.create(187,1,xx*16+4,yy*16+4); + end; else + if id=102 then + begin + chest.destroy(true, xx, yy); + drop.create(28,1,xx*16+4,yy*16+4); + end; else + if id=104 then + begin + destsign(getmapinfo(xx,yy)); + drop.create(104,1,xx*16+4,yy*16+4); + end; else + if id=106 then + begin + setmap(0,xx,yy); + DestroyFurnace(xx, yy); + end; else + if id=107 then + begin + drop.create(108,1,xx*16+4,yy*16+4); + end; else + if id=111 then + begin + drop.create(214,random(4)+1,xx*16+4,yy*16+4); + end; else + if id=117 then + begin + drop.create(116,1,xx*16+4,yy*16+4); + end; else + if id=118 then + begin + drop.create(10,1,xx*16+4,yy*16+4); + end; else + if id=120 then + begin + drop.create(1,1,xx*16+4,yy*16+4); + end; else + if id=121 then + begin + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; else + if id=122 then + begin + if getmapinfo(xx,yy)<3 then drop.create(217,random(2),xx*16+4,yy*16+4); else + 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; + setmap(0,xx,yy); + setmapinfo(0,xx,yy); + end; else + if (id=123) or (id=124) then + begin + drop.create(221+(id-123),random(4),xx*16+4,yy*16+4); + end; else + begin + setmapinfo(0,xx,yy); + drop.create(id,1,xx*16+4,yy*16+4); + end; + end; + + procedure decItem(invcur:integer); + begin + if gamemode<>1 then + begin + inv.setSum(inv.getSum(invcur)-1, invcur); + inv.fixNull(invcur); + end; + end; + + //Возвращает true если блок небыл использован. + function useBlock(invcur, x, y:integer):boolean; + var + item, sum, block, info:integer; + begin + item:=inv.getItem(invcur); + sum:=inv.getSum(invcur); + block:=getMap(x, y); + info:=getMapInfo(x, y); + + if (block=28) or (block=102) then + begin + if info<=MAX_CHEST then + OpenChestWindow(info); + end; + else + if block=29 then + OpenFastCraftWindow(1); + else + if block=79 then + begin + setMap(81, x, y); + setMap(82, x, y+1); + end; + else + if block=80 then + begin + setMap(81, x, y-1); + setMap(82, x, y); + end; + else + if block=81 then + begin + setMap(79, x, y); + setMap(80, x, y+1); + end; + else + if block=82 then + begin + setMap(79, x, y-1); + setMap(80, x, y); + end; + /*else + if block=104 then + keymode:=5;*/ + else + if block=106 then + OpenFurnaceWindow(info); + else + if block=107 then + setMap(108, x, y); + else + if block=108 then + setMap(107, x, y); + else + if block=116 then + setMap(117, x, y); + else + if block=117 then + setMap(116, x, y); + else + if block=121 then + begin + if hunger<20 then + begin + hunger:=hunger+2; + info:=info-2; + if (info=14) or (info=2) then + info:=info-2; + if info<1 then + setMap(0, x, y); + else + setMapInfo(info, x, y); + end; + end; + else + useBlock:=true; + + /* + + + if (getmap(curx,cury)=1) or (getmap(curx,cury)=2) or (getmap(curx,cury)=48) or (getmap(curx,cury)=74) then + begin + if (get_item(0, item)=1) and (get_tool(0, item)=6) and (sum>0) and (getmap(curx,cury-1)=0) then + begin + setmap(120,curx,cury); + inv.setSum(inv.getSum(invslot)-1, invslot); + inv.fixNull(invslot); + end; + end; + else + if (getmap(curx,cury)=77) or (getmap(curx,cury)=78) then + begin + if pl_world=0 then + sleep; + else + boom(4,100,curx,cury); + end;*/ + end; + + function useItem(invcur, x, y:integer):boolean; + var + item, sum, block, info:integer; + begin + if inv.isNull(invcur) then + useItem:=true; + + item:=inv.getItem(invcur); + sum:=inv.getSum(invcur); + block:=getMap(x, y); + info:=getMapInfo(x, y); + + if item=171 then + begin + if block=50 then + begin + inv.setItem(172, invcur); + setMap(0, x, y); + end; + else + if block=51 then + begin + inv.setItem(173, invcur); + setMap(0, x, y); + end; + end; + else + if item=220 then + usebonemeal(block); + else + if item=217 then + begin + if (block=120) and (getMap(x, y-1)=0) then + begin + setMap(122, x, y-1); + decItem(invcur); + end; + end; + else + if item=221 then + begin + if (block=120) and (getMap(x, y-1)=0) then + begin + setMap(123, x, y-1); + setMapInfo(1, x, y-1); + decItem(invcur); + end; + end; + else + if item=222 then + begin + if (block=120) and (getMap(x, y-1)=0) then + begin + setMap(124, x, y-1); + setMapInfo(1, x, y-1); + decItem(invcur); + end; + end; + else + if item=172 then + begin + if (block=0) then + begin + inv.setItem(171, invcur); + setMap(50, x, y); + end; + end; + else + if item=173 then + begin + if (block=0) then + begin + inv.setItem(171, invcur); + setMap(51, x, y); + end; + end; + else + if item=176 then + begin + if hunger<20 then + begin + hunger:=hunger+2; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=177 then + begin + {if random(10)=random(10) then + create_mob(4, x*16, y*16);} + decItem(invcur); + end; + else + if item=178 then + begin + if (block=0) and (getMap(x, y-1)=0) then + begin + setMap(81, x, y-1); + setMap(82, x, y); + decItem(invcur); + end; + end; + else + if item=179 then + begin + if (block=0) and (getMap(x+1, y)=0) then + begin + setMap(77, x, y); + setMap(78, x+1, y); + decItem(invcur); + end; + end; + else + if item=180 then + begin + if getBlockColl(block)=0 then + begin + mob.create(M_ZOMBY, x*16, y*16); + decItem(invcur); + end; + end; + else + if item=181 then + begin + if getBlockColl(block)=0 then + begin + //create_mob(2, x*16, y*16); + decItem(invcur); + end; + end; + else + if item=182 then + begin + if getBlockColl(block)=0 then + begin + //create_mob(3, x*16, y*16); + decItem(invcur); + end; + end; + else + if item=185 then + begin + if hunger<20 then + begin + inv.setItem(184, invslot); + hunger:=hunger+6; + if hunger>20 then + hunger:=20; + end; + end; + else + if item=187 then + begin + if block=0 then + begin + setMap(95+random(7), x, y); + decItem(invcur); + end; + end; + else + if item=188 then + begin + if hunger<20 then + begin + hunger:=hunger+3; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=189 then + begin + if hunger<20 then + begin + hunger:=hunger+8; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=190 then + begin + if hunger<20 then + begin + hunger:=hunger+4; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=191 then + create_screenshot_png; + else + if item=192 then + create_screenshot_jpeg; + else + if item=193 then + create_screenshot_bmp; + else + if item=196 then + begin + if hunger<20 then + begin + hp:=hp-4; + hunger:=hunger+2; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=199 then + begin + if hunger<20 then + begin + hunger:=hunger+3; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=200 then + begin + if hunger<20 then + begin + hunger:=hunger+8; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=201 then + begin + if hunger<20 then + begin + hunger:=hunger+4; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=202 then + begin + if hp<20 then + begin + hp:=20; + decItem(invcur); + end; + end; + else + if item=203 then + begin + if hunger<20 then + begin + hunger:=hunger+2; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=204 then + begin + if hunger<20 then + begin + hunger:=hunger+6; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=205 then + begin + if getBlockColl(block)=0 then + begin + //create_mob(4, x*16, y*16); + decItem(invcur); + end; + end; + else + if item=206 then + begin + if getBlockColl(block)=0 then + begin + //create_mob(5, x*16, y*16); + decItem(invcur); + end; + end; + else + if item=208 then + begin + if getBlockColl(block)=0 then + begin + //create_mob(6, x*16, y*16); + decItem(invcur); + end; + end; + else + if item=209 then + begin + if getBlockColl(block)=0 then + begin + //create_mob(7, x*16, y*16); + decItem(invcur); + end; + end; + else + if item=213 then + begin + if getBlockColl(block)=0 then + begin + //create_mob(8, x*16, y*16); + decItem(invcur); + end; + end; + else + if item=212 then + begin + if getBlockColl(block)=0 then + begin + //create_mob(10, x*16, y*16); + decItem(invcur); + end; + end; + else + if item=210 then + begin + if hunger<20 then + begin + hunger:=hunger+2; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=211 then + begin + if hunger<20 then + begin + hunger:=hunger+5; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=219 then + begin + if hunger<20 then + begin + hunger:=hunger+5; + if hunger>20 then + hunger:=20; + decItem(invcur); + end; + end; + else + if item=153 then + begin + if block=10 then + begin + if searchportal(x , y)=true then + begin + genportal(x-1, y-4); + decItem(invcur); + end; + else + if searchportal(x-1, y)=true then + begin + genportal(x-2, y-4); + decItem(invcur); + end; + end; + else + if block=27 then + begin + setmapinfo(getrelativetimems/1000-(getrelativetimems/1000 div 100*100),curx,cury); + decItem(invcur); + end; + end; + else + if item=152 then + begin + if block=50 then + begin + fish:=true; + fish_time:=getrelativetimems; + fx:=curx; + fy:=cury; + end; + end; + else + useItem:=true; + end; + +procedure fluidLogic(x, y, ifbx, thenbx, ifby, thenby:integer); + var + block, blockXm1, blockXp1, blockYp1:integer; + begin + block:=getMap(x, y); + blockXm1:=getMap(x-1, y); + blockXp1:=getMap(x+1, y); + blockYp1:=getMap(x, y+1); + + //Если внизу условный блок, то заменяем. + if blockYp1=ifby then + setMap(thenby, x, y+1); + else + //Если нижний блок можно уничтожить, то ставим туда копию + if getBlockSet(blockYp1) then + begin + destroy_block_0(blockYp1, x, y+1); + setMap(block, x, y+1); + end; + //Если ничего не можем, то пытаемся течь по сторонам + else + begin + if blockXm1=ifbx then + setMap(thenbx, x-1, y); + else + if getBlockSet(blockXm1) then + begin + destroy_block_1(blockXm1, x-1, y); + setMap(block, x-1, y); + end; + + if blockXp1=ifbx then + setMap(thenbx, x+1, y); + else + if getBlockSet(blockXp1) then + begin + destroy_block_1(blockXp1, x+1, y); + setMap(block, x+1, y); + end; + end; + end; + +procedure updateBlock(x, y:integer); + const + GRASS_RND=128; + TORCH_RND=128; + SPAWN_RND=128; + SPAWN_RAD=128; + GENWOOD_RND=1024; + LIAN_RND=32; + CORN_RND=512; + var + plx, ply, block, light, info:integer; + begin + plx:=player.getX; + ply:=player.getY; + block:=getMap(x, y); + light:=getMapLight(x, y); + info:=getMapInfo(x, y); + + if block=2 then + begin + //Трава разрастается при условии что освещение выше чем 3 + if (getBlockSet(getMap(x, y-1))=false) or (light=0) then + setMap(1, x, y); + else + if light>3 then + begin + if (getMap(x-1, y)=1) and (getMap(x-1, y-1)=0) then + if random(GRASS_RND)=random(GRASS_RND) then + setMap(2, x-1, y); + + if (getMap(x+1, y)=1) and (getMap(x+1, y-1)=0) then + if random(GRASS_RND)=random(GRASS_RND) then + setMap(2, x+1, y); + end; + end; + else + if block=7 then + begin + if getBlockSet(getMap(x, y+1)) then + begin + setMap(0, x, y); + setMap(7, x, y+1); + end; + end; + else + if block=8 then + begin + if getBlockSet(getMap(x, y+1)) then + begin + setMap(0, x, y); + setMap(8, x, y+1); + end; + end; + else + if block=26 then + begin + if random(TORCH_RND)=random(TORCH_RND) then + create_particle(2, x*16+4, y*16+4); + end; + else + if block=50 then + begin + fluidLogic(x, y, 51, 10, 51, 10); + end; + else + if block=51 then + begin + fluidLogic(x, y, 50, 5, 50, 3); + end; + else + if block=63 then + begin + if (light>7) or (getMap(x, y+1)=0) then + setmap(0, x, y); + end; + else + if block=74 then + begin + if getBlockSet(getMap(x, y-1))=false then + setMap(1, x, y); + else + if light>3 then + begin + if (getMap(x-1, y)=1) and (getMap(x-1, y-1)=0) then + if random(GRASS_RND)=random(GRASS_RND) then + setMap(74, x-1, y); + + if (getMap(x+1, y)=1) and (getMap(x+1, y-1)=0) then + if random(GRASS_RND)=random(GRASS_RND) then + setMap(74, x+1, y); + end; + end; + else + if block=77 then + begin + if getmap(x+1, y)<>78 then + setMap(0, x, y); + end; + else + if block=78 then + begin + if getmap(x-1, y)<>77 then + setMap(0, x, y); + end; + else + if block=79 then + begin + if getmap( x, y+1)<>80 then + setMap(0, x, y); + end; + else + if block=80 then + begin + if getmap(x, y-1)<>79 then + setMap(0, x, y); + end; + else + if block=81 then + begin + if getmap(x, y+1)<>82 then + setMap(0, x, y); + end; else + if block=82 then + begin + if getmap(x, y-1)<>81 then + setmap(0, x, y); + end; else + if block=76 then + begin + {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 + if random(SPAWN_RND)=random(SPAWN_RND) then + create_mob(getMapInfo(x, y), x*16,(y-2)*16);} + end; + else + if block=52 then + begin + if random(GENWOOD_RND)=random(GENWOOD_RND) then + genwood1(x, y); + end; + else + if block=114 then + begin + if random(GENWOOD_RND)=random(GENWOOD_RND) then + genwood2(x, y); + end; + else + if block=115 then + begin + if random(GENWOOD_RND)=random(GENWOOD_RND) then + genwood3(x, y); + end; + else + if block=103 then + begin + if (getmap(x, y-1)=0) then + setmap(0, x, y); + else + if (getmap(x, y+1)=0) and (random(LIAN_RND)=random(LIAN_RND)) then + setmap(103, x, y+1); + end; + else + if block=105 then + begin + if random(TORCH_RND)=random(TORCH_RND) then + create_particle(4, x*16+4, y*16+4); + end; + else + if block=110 then + begin + 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 + setmap(0, x, y); + end; + else + if block=30 then + begin + if (random(GENWOOD_RND)=random(GENWOOD_RND)) and (getMap(x, y+2)<>30) then + setMap(30, x, y-1); + if (getMap(x, y+1)<>7) or (getMap(x, y+1)<>30) then + begin + setMap(0, x, y); + destroy_block_1(block, x, y); + end; + end; else + if block=65 then + begin + if (random(GENWOOD_RND)=random(GENWOOD_RND)) and (getMap(x, y+2)<>65) then + setMap(65, x, y-1); + if (getMap(x, y+1)=0) then + begin + setMap(0, x, y); + destroy_block_1(block, x, y); + end; + end; + else + if block=122 then + begin + if random(CORN_RND)=random(CORN_RND) then + info:=info+1; + if info>3 then + info:=3; + if getmap(x, y+1)<>120 then + setMap(0, x, y); + setMapInfo(info, x, y); + end; else + if block=123 then + begin + if random(CORN_RND)=random(CORN_RND) then + info:=info+1; + if info>9 then + info:=9; + if getmap(x, y+1)<>120 then + setMap(0, x, y); + + if (info=0) and (getMap(x-1, y)=0) and (getBlockColl(getMap(x-1, y+1))>0) then + setmap(73, x-1, y); + + if (getMap(x-1, y)=73) and (getMapinfo(x, y)<>9) then + info:=9; + + setMapInfo(info, x, y); + end; + else + if block=124 then + begin + if random(CORN_RND)=random(CORN_RND) then + info:=info+1; + if info>9 then + info:=9; + if getmap(x, y+1)<>120 then + setMap(0, x, y); + + if (info=0) and (getMap(x-1, y)=0) and (getBlockColl(getMap(x-1, y+1))>0) then + setmap(66, x-1, y); + + if (getMap(x-1, y)=66) and (getMapinfo(x, y)<>9) then + info:=9; + + setMapInfo(info, x, y); + end; + else + if block=27 then + begin + if info<>0 then + if getrelativetimems/1000-(getrelativetimems/1000 div 100*100)-info>3 then + boom(4, 100, x, y); + end; + end; + +end. diff --git a/src/keyboard.mpsrc b/src/keyboard.mpsrc new file mode 100644 index 0000000..9a64044 --- /dev/null +++ b/src/keyboard.mpsrc @@ -0,0 +1,227 @@ +unit keyboard; + +interface + const + MAX_KEY_TYPES=27; + MAX_KEY_BIND=3; + + KEY_FM_UP=0; + KEY_FM_DOWN=1; + KEY_FM_SELECT=2; + + KEY_MENU_UP=3; + KEY_MENU_DOWN=4; + KEY_MENU_LEFT=5; + KEY_MENU_RIGHT=6; + KEY_MENU_SELECT=7; + + KEY_FASTINV_PREV=8; + KEY_FASTINV_NEXT=9; + + KEY_CHAT=10; + + KEY_PLR_OPENINV=11; + KEY_PLR_EDITMODE=12; + KEY_PLR_USE=13; + KEY_PLR_ATTACK=14; + + KEY_PLR_UP=15; + KEY_PLR_DOWN=16; + KEY_PLR_LEFT=17; + KEY_PLR_RIGHT=18; + + KEY_MENU=19; + + KEY_WIN_UP=20; + KEY_WIN_DOWN=21; + KEY_WIN_LEFT=22; + KEY_WIN_RIGHT=23; + KEY_WIN_SELECT=24; + KEY_WIN_ALT=25; + KEY_WIN_DROP=26; + KEY_WIN_EXIT=27; + + + var + s_cl:boolean; + load_key_tex:integer; + scrMulX, scrMulY:integer; + + function touchscreen:boolean; + procedure init_touch; + function senClicked(ix,iy,xx,yy:integer):boolean; + function senPressed(ix,iy,xx,yy:integer):boolean; + //function get_key_clicked:integer; + //function get_key_pressed:integer; + procedure draw_virtual_keys; + + procedure bindKey(keytype, id, keycode:integer); + function clickedKey(keytype:integer):boolean; + function pressedKey(keytype:integer):boolean; + procedure updateKeys; + + procedure resetVirtualKeyboard(i:integer); + procedure bindVKey(i, keycode, x, y:integer); + procedure setVkeyImg(img:image; i:integer); + +implementation +uses sensor,vars,canvas, func; + var + key_bind: array [0..MAX_KEY_BIND, 0..MAX_KEY_TYPES] of integer; + clicked_key, pressed_key:integer; + + v_keycode: array [0..0] of integer; + v_keyx: array [0..0] of integer; + v_keyy: array [0..0] of integer; + v_keyimg: array [0..0] of image; + v_max:integer; + + procedure resetVirtualKeyboard(i:integer); + var + nullimg:image; + v:integer; + begin + v_max:=i; + i:=i+1; + + bytecode + iload 0; + newarray 10; + putstatic field 'keyboard', 'v_keycode', '[I'; + end; + bytecode + iload 0; + newarray 10; + putstatic field 'keyboard', 'v_keyx', '[I'; + end; + bytecode + iload 0; + newarray 10; + putstatic field 'keyboard', 'v_keyy', '[I'; + end; + bytecode + iload 0; + multianewarray class '[Ljavax/microedition/lcdui/Image;', 1; + putstatic field 'keyboard', 'v_keyimg', '[Ljavax/microedition/lcdui/Image;'; + end; + for v:=0 to v_max do + v_keyimg[v]:=nullimg; + end; + + procedure setVkeyImg(img:image; i:integer); + begin + v_keyimg[i]:=img; + end; + + procedure bindVKey(i, keycode, x, y:integer;); + begin + v_keycode[i]:=keycode; + v_keyx[i]:=x; + v_keyy[i]:=y; + end; + + procedure bindKey(keytype, id, keycode:integer); + begin + key_bind[id, keytype]:=keycode; + end; + + function clickedKey(keytype:integer):boolean; + var + i:integer; + begin + for i:=0 to MAX_KEY_BIND do + if (key_bind[i, keytype]=clicked_key) and (key_bind[i, keytype]<>0) then + begin + clickedKey:=true; + exit; + end; + end; + + function pressedKey(keytype:integer):boolean; + var + i:integer; + begin + for i:=0 to MAX_KEY_BIND do + if (key_bind[i, keytype]=pressed_key) and (key_bind[i, keytype]<>0) then + begin + pressedKey:=true; + exit; + end; + end; + +function touchscreen:boolean; + begin + setcolor(0, 0, 0); + fillrect(0, 0, getWidth, getHeight); + drawfonttext('Press 5', getWidth/2-(length('Press 5')*8)/2, getHeight-16); + drawfonttext('or touch the screen.', getWidth/2-(length('or touch the screen.')*8)/2, getHeight-8); + repaint; + delay(1); + repeat + updateKeys; + if clickedKey(KEY_MENU_SELECT) then + begin + touchscreen:=false; + exit; + end; + if pointer_state=1 then + begin + touchscreen:=true; + exit; + end; + forever; + end; + +procedure init_touch; + begin + sensor.init; + end; + +function senClicked(ix,iy,xx,yy:integer):boolean; + begin + if (pointer_state=1) and (s_cl=false) then + 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 + begin + s_cl:=true; + senClicked:=true; + end; + end; + +function senPressed(ix,iy,xx,yy:integer):boolean; + begin + if (pointer_state=1) then + 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 + senPressed:=true; + end; + + procedure updateKeys; + var + i:integer; + begin + clicked_key:=getKeyClicked; + pressed_key:=getKeyPressed; + + if pointer_state=0 then + s_cl:=false; + + for i:=0 to v_max do + begin + if senClicked(v_keyx[i], v_keyy[i], getImageWidth(v_keyimg[i]), getImageHeight(v_keyimg[i])) then + clicked_key:=v_keycode[i]; + if senPressed(v_keyx[i], v_keyy[i], getImageWidth(v_keyimg[i]), getImageHeight(v_keyimg[i])) then + pressed_key:=v_keycode[i]; + end; + end; + +procedure draw_virtual_keys; + var + i:integer; + begin + if load_key_tex=1 then + for i:=0 to v_max do + drawImage(v_keyimg[i], v_keyx[i], v_keyy[i]); + end; + +initialization + v_max:=-1; +end. diff --git a/src/mobs.pas b/src/mobs.pas new file mode 100644 index 0000000..95815db --- /dev/null +++ b/src/mobs.pas @@ -0,0 +1,577 @@ +unit mob; + +interface + const + M_NONE=0; + M_ZOMBY=1; + + MOB_TYPES=1; + + procedure create(_type, x, y:integer);//Создать моба + function findAndHit(value, x, y, w, h, addvx, addvy:integer):integer; + + procedure update;//Обновление логики + procedure updatePhy;//Обновление физики + procedure draw(camx, camy:integer);//Отрисовка + + procedure saveData;//Сохранение всех данных + procedure loadData;//Загрузка всех данных + procedure resetData;//Сброс всех данных + + procedure loadSkin(path:string);//Загрузка текстур + procedure freeSkin;//Выгрузка текстур + +implementation + uses phy, player, canvas, func; + const + MAX_MOBS=31; + MAX_ANIMREG=3; + + AI_NONE=0; + AI_ZLOY=1; + var + mob_type, mob_x, mob_y, mob_vx, mob_vy, mob_posi, mob_hp:array [0..MAX_MOBS] of integer; + mob_jmp:array [0..MAX_MOBS] of boolean; + mob_anim:array [0..MAX_MOBS, 0..MAX_ANIMREG] of integer; + tab_w, tab_h, tab_hp, tab_speedx, tab_jumph, tab_ai:array [0..MOB_TYPES] of integer; + + texture_left, texture_right:array [0..MOB_TYPES, 0..0] of image; + tex_x, tex_y, tex_w, tex_h:array [0..1, 0..MOB_TYPES, 0..0] of integer; + + part_max: array [0..MOB_TYPES] of integer; + part_tex, part_x, part_y, part_anim: array [0..MOB_TYPES, 0..0] of integer; + + function getType(i:integer):integer; + begin + getType:=mob_type[i]; + end; + + function getX(i:integer):integer; + begin + getX:=mob_x[i]; + end; + + function getY(i:integer):integer; + begin + getY:=mob_y[i]; + end; + + function getVX(i:integer):integer; + begin + getVX:=mob_vx[i]; + end; + + function getVY(i:integer):integer; + begin + getVY:=mob_vy[i]; + end; + + function getPosi(i:integer):integer; + begin + getPosi:=mob_posi[i]; + end; + + function getHp(i:integer):integer; + begin + getHp:=mob_hp[i]; + end; + + function getW(i:integer):integer; + begin + getW:=tab_w[mob_type[i]]; + end; + + function getH(i:integer):integer; + begin + getH:=tab_h[mob_type[i]]; + end; + + function getSpeedX(i:integer):integer; + begin + getSpeedX:=tab_speedx[mob_type[i]]; + end; + + function getJumpH(i:integer):integer; + begin + getJumpH:=tab_jumph[mob_type[i]]; + end; + + function getJmp(i:integer):boolean; + begin + getJmp:=mob_jmp[i]; + end; + + procedure setType(value, i:integer); + begin + mob_type[i]:=value; + end; + + procedure setX(value, i:integer); + begin + mob_x[i]:=value; + end; + + procedure setY(value, i:integer); + begin + mob_y[i]:=value; + end; + + procedure setVX(value, i:integer); + begin + mob_vx[i]:=value; + end; + + procedure setVY(value, i:integer); + begin + mob_vy[i]:=value; + end; + + procedure setPosi(value, i:integer); + begin + mob_posi[i]:=value; + end; + + procedure setHp(value, i:integer); + begin + mob_hp[i]:=value; + end; + + procedure setJmp(value:boolean; i:integer); + begin + mob_jmp[i]:=value; + end; + + procedure initTab(_type, w, h, hp, speedx, jumph, ai:integer); + begin + tab_w[_type]:=w; + tab_h[_type]:=h; + tab_hp[_type]:=hp; + tab_speedx[_type]:=speedx; + tab_jumph[_type]:=jumph; + tab_ai[_type]:=ai; + end; + + procedure initTexture(img:image; mobtype, texid, posi, centerx, centery:integer); + begin + tex_w[posi, mobtype, texid]:=getImageWidth(img); + tex_h[posi, mobtype, texid]:=getImageHeight(img); + if posi=0 then + texture_left[mobtype, texid]:=img; + else + texture_right[mobtype, texid]:=img; + tex_x[posi, mobtype, texid]:=centerx; + tex_y[posi, mobtype, texid]:=centery; + end; + + procedure setMaxTextures(mobtype, max:integer); + var + i:integer; + begin + max:=max+1; + debug('setMaxTextures(mobtype, max:integer);'); + bytecode + getstatic field 'mob', 'texture_left', '[[Ljavax/microedition/lcdui/Image;'; + iload 0; + iload 1; + multianewarray class '[Ljavax/microedition/lcdui/Image;', 1; + aastore; + + getstatic field 'mob', 'texture_right', '[[Ljavax/microedition/lcdui/Image;'; + iload 0; + iload 1; + multianewarray class '[Ljavax/microedition/lcdui/Image;', 1; + aastore; + end; + + for i:=0 to 1 do + bytecode + //tex_x[i][mobtype]=new int[max]; + getstatic field 'mob', 'tex_x', '[[[I'; + iload_2; + aaload; + iload_0; + iload_1; + multianewarray class '[I', 1; + aastore; + + getstatic field 'mob', 'tex_y', '[[[I'; + iload_2; + aaload; + iload_0; + iload_1; + multianewarray class '[I', 1; + aastore; + + getstatic field 'mob', 'tex_w', '[[[I'; + iload_2; + aaload; + iload_0; + iload_1; + multianewarray class '[I', 1; + aastore; + + getstatic field 'mob', 'tex_h', '[[[I'; + iload_2; + aaload; + iload_0; + iload_1; + multianewarray class '[I', 1; + aastore; + end; + end; + + procedure setMaxParts(mobtype, max:integer); + begin + part_max[mobtype]:=max; + max:=max+1; + + bytecode + getstatic field 'mob', 'part_tex', '[[I'; + iload_0; + iload_1; + multianewarray class '[I', 1; + aastore; + + getstatic field 'mob', 'part_x', '[[I'; + iload_0; + iload_1; + multianewarray class '[I', 1; + aastore; + + getstatic field 'mob', 'part_y', '[[I'; + iload_0; + iload_1; + multianewarray class '[I', 1; + aastore; + + getstatic field 'mob', 'part_anim', '[[I'; + iload_0; + iload_1; + multianewarray class '[I', 1; + aastore; + end; + end; + + procedure initPart(mobtype, partid, tex, x, y, animreg:integer); + begin + part_tex[mobtype, partid]:=tex; + part_x[mobtype, partid]:=x; + part_y[mobtype, partid]:=y; + part_anim[mobtype, partid]:=animreg; + end; + +procedure loadPhy(i:integer); + begin + 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]); + end; + +procedure storePhy(i:integer); + begin + mob_x[i]:=phy.getX; + mob_y[i]:=phy.getY; + mob_vx[i]:=phy.getVelX; + mob_vy[i]:=phy.getVelY; + mob_jmp[i]:=phy.getJmp; + end; + +{===== =====} + + procedure create(_type, x, y:integer);//Создать моба + var + i, j:integer; + begin + debug('Create mob '+_type+' @ '+x+'x'+y); + for i:=0 to MAX_MOBS do + if mob_type[i]=M_NONE then + begin + mob_type[i]:=_type; + mob_x[i]:=x; + mob_y[i]:=y; + mob_vx[i]:=0; + mob_vy[i]:=0; + mob_posi[i]:=0; + mob_hp[i]:=tab_hp[_type]; + mob_jmp[i]:=false; + for j:=0 to MAX_ANIMREG do + mob_anim[i, j]:=0; + + debug('Created mob is '+i); + exit; + end; + end; + + procedure die(i:integer);//Убить + begin + mob_type[i]:=M_NONE; + end; + + procedure hit(value, i:integer);//Нанести урон + var + hp:integer; + begin + hp:=getHp(i)-value; + if hp>0 then + setHp(hp, i); + else + die(i); + end; + + function findAndHit(value, x, y, w, h, addvx, addvy:integer):integer; + var + i:integer; + begin + for i:=0 to MAX_MOBS do + if getType(i)<>M_NONE then + if CollTwoObj(x, y, w, h, getX(i), getY(i), getW(i), getH(i)) then + begin + setVX(getVX(i)+addvx, i); + setVX(getVY(i)+addvy, i); + hit(value, i); + findAndHit:=i; + exit; + end; + + findAndHit:=-1; + end; + + procedure goUp(i:integer); + begin + loadPhy(i); + phy.jumpObj(getJumpH(i)); + storePhy(i); + end; + + procedure goDown(i:integer); + begin + + end; + + procedure goLeft(i:integer); + begin + setVX(-getSpeedX(i), i); + setPosi(0, i); + end; + + procedure goRight(i:integer); + begin + setVX(getSpeedX(i), i); + setPosi(1, i); + end; + + function testSolid(i, vector:integer):boolean; + var + x, y:integer; + begin + y:=((getY(i)+getH(i)))/16-1; + + if vector<0 then + begin + x:=(getX(i)/16)-1; + end; + else + if vector>0 then + begin + x:=((getX(i)+getW(i))/16){+1}; + end; + else + x:=((getX(i)+getW(i)/2)/16); + + testSolid:=phy.isSolid(x, y, getVX(i), getVY(i)); + end; + + procedure updateZloyAiAnim(i:integer); + const + DEL=1; + var + a_a, a_d, a_f:integer; + begin + a_a:=mob_anim[i, 1]; + a_d:=mob_anim[i, 2]; + a_f:=mob_anim[i, 3]; + + a_d:=a_d+1; + if a_d>DEL then + begin + a_d:=0; + a_a:=a_a+1; + if a_f=1 then + begin + a_a:=0; + a_f:=0; + end; + else + if a_a=3 then + begin + a_a:=1; + a_f:=1; + end; + end; + + mob_anim[i, 1]:=a_a; + mob_anim[i, 2]:=a_d; + mob_anim[i, 3]:=a_f; + end; + + procedure updateZloyAi(i:integer); + begin + if player.getXgetX(i) then + begin + goRight(i); + updateZloyAiAnim(i); + if testSolid(i, 1) then + goUp(i); + end; + end; + + procedure update;//Обновление логики + var + i, _type, ai:integer; + begin + for i:=0 to MAX_MOBS do + begin + _type:=getType(i); + + if _type<>M_NONE then + begin + ai:=tab_ai[_type]; + if ai=AI_ZLOY then + updateZloyAi(i); + end; + end; + end; + + procedure updatePhy;//Обновление физики + var + i:integer; + begin + for i:=0 to MAX_MOBS do + begin + loadPhy(i); + phy.calc(true); + storePhy(i); + end; + end; + + procedure drawPart(mobtype, texid, posi, anim, x, y, camx, camy:integer); + begin + x:=x-tex_x[posi, mobtype, texid]-camx; + y:=y-tex_y[posi, mobtype, texid]-camy; + + if CollTwoObj(x, y, tex_w[posi, mobtype, texid], tex_h[posi, mobtype, texid], 0, 0, getWidth, getHeight) then + if posi=0 then + drawImage(texture_left[mobtype, texid+anim], x, y); + else + drawImage(texture_right[mobtype, texid+anim], x, y); + end; + + procedure draw(camx, camy:integer);//Отрисовка + var + i, j, _type:integer; + begin + for i:=0 to MAX_MOBS do + begin + _type:=mob_type[i]; + if _type<>M_NONE then + begin + for j:=0 to part_max[_type] do + 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); + end; + end; + end; + + procedure loadSkin(path:string);//Загрузка текстур + var + im:image; + begin + setMaxTextures(M_ZOMBY, 5); + im:=ld_tex('zombie_ani.png', path, 'mobs/'); + // IMG, TYPE, ID, POSI, X, Y + initTexture(rotate_image_from_image(im, 6, 2, 8, 8, 0), M_ZOMBY, 0, 0, 4, 8);//head[left] + initTexture(rotate_image_from_image(im, 8, 10, 4, 12, 0), M_ZOMBY, 1, 0, 2, 0);//body[left] + initTexture(rotate_image_from_image(im, 0, 10, 12, 4, 0), M_ZOMBY, 2, 0, 10, 2);//hands[left] + initTexture(rotate_image_from_image(im, 0, 52, 12, 12, 0), M_ZOMBY, 3, 0, 6, 0);//legs[left] + initTexture(rotate_image_from_image(im, 13, 52, 12, 12, 0), M_ZOMBY, 4, 0, 6, 0); + initTexture(rotate_image_from_image(im, 26, 52, 12, 12, 0), M_ZOMBY, 5, 0, 6, 0); + + initTexture(rotate_image_from_image(im, 27, 2, 8, 8, 0), M_ZOMBY, 0, 1, 4, 8);//head[right] + initTexture(rotate_image_from_image(im, 29, 10, 4, 12, 0), M_ZOMBY, 1, 1, 2, 0);//body[right] + initTexture(rotate_image_from_image(im, 29, 10, 12, 4, 0), M_ZOMBY, 2, 1, 2, 2);//hands[right] + initTexture(rotate_image_from_image(im, 39, 52, 12, 12, 0), M_ZOMBY, 3, 1, 6, 0);//legs[right] + initTexture(rotate_image_from_image(im, 52, 52, 12, 12, 0), M_ZOMBY, 4, 1, 6, 0); + initTexture(rotate_image_from_image(im, 65, 52, 12, 12, 0), M_ZOMBY, 5, 1, 6, 0); + end; + + procedure freeSkin;//Выгрузка текстур + var + i, j, len:integer; + nullimg:image; + begin + for i:=0 to MOB_TYPES do + begin + bytecode + getstatic field 'mob', 'texture_left', '[[Ljavax/microedition/lcdui/Image;'; + iload_0;//i + aaload; + arraylength; + iconst_1; + isub; + istore_2;//len + end; + for j:=0 to len do + begin + texture_left[i, j]:=nullimg; + texture_right[i, j]:=nullimg; + end; + end; + end; + + procedure saveData;//Сохранение всех данных + begin + + end; + + procedure loadData;//Загрузка всех данных + begin + + end; + + procedure resetData;//Сброс всех данных + var + i, j:integer; + begin + for i:=0 to MAX_MOBS do + begin + mob_type[i]:=M_NONE; + mob_x[i]:=0; + mob_y[i]:=0; + mob_vx[i]:=0; + mob_vy[i]:=0; + mob_posi[i]:=0; + mob_hp[i]:=0; + mob_jmp[i]:=false; + for j:=0 to MAX_ANIMREG do + mob_anim[i, j]:=0; + end; + end; + +initialization + // TYPE W H HP SX JH, AI_TYPE + initTab(M_NONE, 0, 0, 0, 0, 0, AI_NONE); + setMaxParts(M_NONE, -1); + + initTab(M_ZOMBY, 8, 32, 10, 1, 7, AI_ZLOY); + setMaxParts(M_ZOMBY, 3); + // TYPE PART, TEX, X, Y ANIM + initPart(M_ZOMBY, 0, 0, 4, 8, 0);//Head + initPart(M_ZOMBY, 1, 1, 4, 8, 0);//Body + initPart(M_ZOMBY, 2, 2, 4, 10, 0);//Hands + initPart(M_ZOMBY, 3, 3, 4, 20, 1);//Legs +end. diff --git a/src/particles.mpsrc b/src/particles.mpsrc new file mode 100644 index 0000000..ba3c7c4 --- /dev/null +++ b/src/particles.mpsrc @@ -0,0 +1,139 @@ +unit particles; + +interface + var + bubble:image; + pr_1:array [0..7] of image; + none1:image; + pr_2:array [0..7] of image; + none2:image; + pr_3:array [0..7] of image; + none3:image; + pr_4:array [0..7] of image; + none4:image; + pr_5:array [0..7] of image; + none5:image; + pr_boom:array [0..15] of image; + none6:image; + + max_particles:integer; + s_particles:boolean; + gb_up_pa:integer; + + procedure create_particle(tp,ix,iy:integer); + procedure update_particle; + procedure draw_particle; + +implementation + uses vars,maps,particles_store; + +procedure create_particle(tp,ix,iy:integer); + var + i:integer; + begin + if s_particles=true then + for i:=0 to max_particles do + if get_particle_type(i)=0 then + begin + set_particle(i,tp,0,ix,iy); + exit; + end; + end; + +procedure null_particle(i:integer); + begin + set_particle(i,0,0,0,0); + end; + +procedure pr_ai_1(i,maxani:integer); + begin + set_particle_y(i,get_particle_y(i)-1); + set_particle_ani(i,get_particle_ani(i)+1); + if get_particle_ani(i)>maxani then null_particle(i); + end; + +procedure pr_ai_bubble(i:integer); + var + xx,yy:integer; + begin + set_particle_y(i,get_particle_y(i)-1); + xx:=get_particle_x(i) div 16; + yy:=get_particle_y(i) div 16; + if getmap(xx,yy)<>50 then null_particle(i); + end; + +procedure pr_ai_boom(i:integer); + begin + set_particle_ani(i,get_particle_ani(i)+1); + if get_particle_ani(i)>15 then null_particle(i); + end; + +procedure update_particle; + var + i:integer; + begin + if s_particles=true then + begin + for i:=0 to max_particles do + if get_particle_type(i)>0 then + begin + if get_particle_type(i)=1 then pr_ai_1(i,5); else + if get_particle_type(i)=2 then pr_ai_1(i,5); else + if get_particle_type(i)=3 then pr_ai_1(i,5); else + if get_particle_type(i)=4 then pr_ai_1(i,5); else + if get_particle_type(i)=5 then pr_ai_1(i,5); else + if get_particle_type(i)=6 then pr_ai_bubble(i); else + if get_particle_type(i)=7 then pr_ai_boom(i); else + null_particle(i); + end; + gb_up_pa:=gb_up_pa+1; + if gb_up_pa>=2 then gb_up_pa:=0; + end; + end; + +procedure draw_particle; + var + i:integer; + begin + for i:=0 to max_particles do + if get_particle_type(i)>0 then + begin + if get_particle_type(i)=1 then + begin + if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx-8) and (get_particle_y(i)-camy-8) and (get_particle_x(i)-camx-8) and (get_particle_y(i)-camy-8) and (get_particle_x(i)-camx-8) and (get_particle_y(i)-camy-8) and (get_particle_x(i)-camx-8) and (get_particle_y(i)-camy-8) and (get_particle_x(i)-camx-8) and (get_particle_y(i)-camy-8) and (get_particle_x(i)-camx-8) and (get_particle_y(i)-camy-32) and (get_particle_x(i)-camx-32) and (get_particle_y(i)-camyx2) and (x1y2) and (y10 then + isSolid:=true; + end; + + function mapColl(x, y, w, h, velx, vely:integer):boolean; + var + i, j:integer; + minx, miny, maxx, maxy:integer; + begin + minx:=x div TILE_SIZE; + miny:=y div TILE_SIZE; + maxx:=(x+w-1) div TILE_SIZE; + maxy:=(y+h-1) div TILE_SIZE; + for i:=minx to maxx do + for j:=miny to maxy do + begin + if isSolid(i, j, velx, vely) then + begin + mapColl:=true; + exit; + end; + end; + end; + + function canSeeObj(x1, y1, x2, y2:integer):boolean; + var + deltax, deltay:integer; + signx, signy:integer; + error, error2:integer; + begin + x1:=x1/TILE_SIZE; + y1:=y1/TILE_SIZE; + x2:=x2/TILE_SIZE; + y2:=y2/TILE_SIZE; + + deltax:=abs(x2-x1); + deltay:=abs(y2-y1); + + if x1x2) or (y1<>y2)) do + begin + if isSolid(x1, y1, 0, 0) then + exit; + + error2:=error<<1; + if error2>-deltaY then + begin + error:=error-deltaY; + x1:=x1+signX; + end; + + if error2MAX_VELY then + vely:=MAX_VELY; + + jmp:=false; + + if vely>0 then + for i:=1 to vely do + begin + y:=y+1; + if mapColl(x, y, w, h, velx, vely) then + begin + y:=y-1; + vely:=0; + jmp:=true; + break; + end; + end; + else + for i:=1 to abs(vely) do + begin + y:=y-1; + if mapColl(x, y, w, h, velx, vely) then + begin + y:=y+1; + vely:=0; + jmp:=false; + break; + end; + end; + end; + + function fixVYup:boolean; + begin + if (vely>-5) and + (mapCollType(49, x, y, w, h) or + mapCollType(103, x, y, w, h) or + mapCollType(108, x, y, w, h)) then + vely:=vely-2; + else + if (vely>-4) and + (mapCollType(50, x, y, w, h) or + mapCollType(51, x, y, w, h)) then + vely:=vely-2; + else + fixVYup:=true; + end; + + procedure fixVYdown; + begin + if (vely>5) and + (mapCollType(49, x, y, w, h) or + mapCollType(103, x, y, w, h)) then + vely:=5; + else + if (vely>4) and + (mapCollType(50, x, y, w, h) or + mapCollType(51, x, y, w, h)) then + vely:=4; + end; + + procedure jumpObj(vel:integer); + begin + if fixVYup then + if jmp then + begin + vely:=-vel; + jmp:=false; + end; + end; + + procedure calcX; + var + i:integer; + begin + if velx>0 then + for i:=1 to velx do + begin + x:=x+1; + if mapColl(x, y, w, h, velx, vely) then + begin + x:=x-1; + velx:=0; + break; + end; + end; + else + if velx<0 then + for i:=1 to abs(velx) do //there for-downto-do have a bug! + begin + x:=x-1; + if mapColl(x, y, w, h, velx, vely) then + begin + x:=x+1; + velx:=0; + break; + end; + end; + + if velx>0 then + velx:=velx-1; + else + if velx<0 then + velx:=velx+1; + end; + + procedure calcY; + var + i:integer; + begin + if vely>0 then + for i:=1 to vely do + begin + y:=y+1; + if mapColl(x, y, w, h, velx, vely) then + begin + y:=y-1; + vely:=0; + break; + end; + end; + else + if vely<0 then + for i:=1 to abs(vely) do //there for-downto-do have a bug! + begin + y:=y-1; + if mapColl(x, y, w, h, velx, vely) then + begin + y:=y+1; + velx:=0; + break; + end; + end; + + if vely>0 then + vely:=vely-1; + else + if vely<0 then + vely:=vely+1; + end; + + function getX:integer; + begin + getX:=x; + end; + + function getY:integer; + begin + getY:=y; + end; + + function getVelX:integer; + begin + getVelX:=velx; + end; + + function getVelY:integer; + begin + getVelY:=vely; + end; + + function getJmp:boolean; + begin + getJmp:=jmp; + end; + + procedure calc(gravity:boolean); + begin + calcX; + + if gravity then + begin + calcGravity; + fixVYdown; + end; + else + calcY; + end; + +end. diff --git a/src/player.mpsrc b/src/player.mpsrc new file mode 100644 index 0000000..3e9f361 --- /dev/null +++ b/src/player.mpsrc @@ -0,0 +1,363 @@ +unit player; + +interface + const + ANIM_HAND=0; + ANIM_LEGS=1; + + var + fly:boolean; + hp, hunger, air:integer; + posi:integer;//Сторона в которую повёрнут игрок + velx,vely:integer;//Переменные для физики игрока + jmp, an_pr:boolean; + s_get_drp:boolean; + invslot:integer; + + procedure setX(val:integer); + procedure setY(val:integer); + function getX:integer; + function getY:integer; + function getW:integer; + function getH:integer; + + procedure loadSkin(str, path:string); + procedure freeSkin; + procedure draw(camx, camy:integer); + procedure playAnim(anim:integer); + procedure cancelAnim(anim:integer); + + procedure dropItem(item, sum:integer); + + procedure calcPhysics; + + procedure gotoUP; + procedure gotoDOWN; + procedure gotoLEFT; + procedure gotoRIGHT; + + procedure getDrop; + +implementation + uses func, phy, vars, Canvas, drop, items, jsr75i, inv; + const + PLAYER_W=8; + PLAYER_H=32; + PLAYER_SPEED=2; + + POSI_LEFT=0; + POSI_RIGHT=1; + PLAYER_ANIM_DEL=1; + var + plx, ply:integer; + + //Skin + PlayerBody: array [0..1] of image; + PlayerHand: array [0..1, 0..3] of image; + PlayerLegs: array [0..1, 0..2] of image; + animHand, animLegs, animDelay:integer; + + procedure setX(val:integer); + begin + plx:=val; + end; + + procedure setY(val:integer); + begin + ply:=val; + end; + + function getX:integer; + begin + getX:=plx; + end; + + function getY:integer; + begin + getY:=ply; + end; + + function getW:integer; + begin + getW:=PLAYER_W; + end; + + function getH:integer; + begin + getH:=PLAYER_H; + end; + + procedure setVelX(val:integer); + begin + velx:=val; + end; + + procedure setVelY(val:integer); + begin + vely:=val; + end; + + function getVelX:integer; + begin + getVelX:=velx; + end; + + function getVelY:integer; + begin + getVelY:=vely; + end; + + procedure setJmp(val:boolean); + begin + jmp:=val; + end; + + function getJmp:boolean; + begin + getJmp:=jmp; + end; + + procedure dropItem(item, sum:integer); + begin + if posi=POSI_LEFT then + drop.create(item, sum, getX-8, getY); + else + drop.create(item, sum, getX+getW, getY); + end; + + procedure loadSkin(str, path:string); + var + im:image; + i:integer; + begin + im:=ld_tex(str, path, 'mobs/'); + + PlayerBody[POSI_LEFT]:=rotate_image_from_image(im, 0, 0, 8, 20, 0); + PlayerBody[POSI_RIGHT]:=rotate_image_from_image(im, 8, 0, 8, 20, 0); + + PlayerHand[POSI_LEFT, 0]:=rotate_image_from_image(im, 40, 0, 4, 12, 0); + PlayerHand[POSI_RIGHT, 0]:=rotate_image_from_image(im, 44, 0, 4, 12, 0); + + for i:=1 to 3 do + begin + PlayerHand[POSI_LEFT, i]:=rotate_image_from_image(im, 16, (i-1)*6, 12, 6, 0); + PlayerHand[POSI_RIGHT, i]:=rotate_image_from_image(im, 28, (i-1)*6, 12, 6, 0); + end; + + for i:=0 to 2 do + begin + PlayerLegs[POSI_LEFT, i]:=rotate_image_from_image(im, i*12, 20, 12, 12, 0); + PlayerLegs[POSI_RIGHT, i]:=rotate_image_from_image(im, 36+i*12, 20, 12, 12, 0); + end; + end; + + procedure freeSkin; + var + i, j:integer; + nullimg:image; + begin + for i:=0 to 1 do + begin + PlayerBody[i]:=nullimg; + for j:=0 to 3 do + PlayerHand[i, j]:=nullimg; + for j:=0 to 2 do + PlayerLegs[i, j]:=nullimg; + end; + end; + + procedure playAnim(anim:integer); + begin + if anim=ANIM_HAND then + begin + animHand:=animHand+1; + if animHand>3 then + animHand:=1; + end; + else + if anim=ANIM_LEGS then + begin + if animDelay=0 then + begin + animLegs:=animLegs+1; + if animLegs>2 then + animLegs:=0; + end; + + animDelay:=animDelay+1; + if animDelay>PLAYER_ANIM_DEL then + animDelay:=0; + end; + end; + + procedure cancelAnim(anim:integer); + begin + if anim=ANIM_HAND then + begin + animHand:=0; + end; + else + if anim=ANIM_LEGS then + begin + animLegs:=0; + end; + end; + + procedure draw(camx, camy:integer); + var + x, y:integer; + begin + x:=getX; + y:=getY; + + DrawImage(PlayerBody[posi], x-camx, y-camy); + DrawImage(PlayerLegs[posi, animLegs], x-2-camx, y+20-camy); + + if animHand=0 then + drawSmallItem(inv.getItem(invslot), x-camx, y+14-camy); + else + if posi=POSI_RIGHT then + drawSmallItem(inv.getItem(invslot), x+10-camx, y+5-camy+animHand); + else + if posi=POSI_LEFT then + drawSmallItem(inv.getItem(invslot), x-10-camx, y+5-camy+animHand); + + if (animHand=0) or (posi=POSI_RIGHT) then + DrawImage(PlayerHand[posi, animHand], x+2-camx, y+8-camy); + else + DrawImage(PlayerHand[posi, animHand], x-6-camx, y+8-camy); + end; + +procedure loadPhy; + begin + phy.loadObject(getX, getY, getW, getH, getVelX, getVelY, getJmp); + end; + +procedure storePhy; + begin + setX(phy.getX); + setY(phy.getY); + setVelX(phy.getVelX); + setVelY(phy.getVelY); + setJmp(phy.getJmp); + end; + + //Player collision. +{function coll:boolean; + begin + coll:=CollObj(getX, getY, getW, getH); + end; + +//Player collision by block id. +function coll_bl(id:integer):boolean; + begin + coll_bl:=CollObjBlock(getX, getY, getW, getH, id); + end; + +//Player collision by XY. +function coll_xy(xx,yy:integer):boolean; + begin + coll_xy:=CollObjXY(getX, getY, getW, getH, xx, yy); + end; + +//Controll jump velocity +procedure jmp_ctrl; + begin + if (coll_bl(49)) or (coll_bl(103)) or (coll_bl(108)) then + vely:=5; + if (coll_bl(50)) or (coll_bl(51)) then + vely:=4; + if (coll_bl(0)) and (coll_bl(50) or coll_bl(51)) then + vely:=7; + end; + +//Controll fall velocity + procedure phy_ctrl; + begin + if (coll_bl(49)) or (coll_bl(103)) then + vely:=-5; + if (coll_bl(50)) or (coll_bl(51)) then + if vely<-4 then + vely:=-4; + end;} + + procedure calcPhysics; + var + old_vely:integer; + cl:boolean; + begin + loadPhy; + phy.calc(not fly); + storePhy; + + {if fly=false then + begin + old_vely:=vely; + calcGravY(getX, getY, getW, getH, CONST_PHY_ACC, vely, CONST_PHY_MAXVEL, jmp); + setY(PhyGetY); + vely:=PhyGetVelY; + jmp:=PhyGetJump; + cl:=PhyGetColl; + + if cl then + if old_vely<-10 then + hp:=(hp-(abs(old_vely)-10)); + end;} + end; + + procedure gotoUP; + begin + if fly then + setVelY(-PLAYER_SPEED); + else + begin + loadPhy; + jumpObj(7); + storePhy; + end; + end; + + procedure gotoDOWN; + begin + if fly then + setVelY(PLAYER_SPEED); + end; + + procedure gotoLEFT; + begin + setVelX(-PLAYER_SPEED); + + posi:=POSI_LEFT; + + if fly=false then + playAnim(ANIM_LEGS); + end; + + procedure gotoRIGHT; + begin + setVelX(PLAYER_SPEED); + + posi:=POSI_RIGHT; + + if fly=false then + playAnim(ANIM_LEGS); + end; + + procedure getDrop; + var + i, maxd, sum:integer; + begin + maxd:=drop.max; + for i:=0 to maxd do + if drop.isNull(i)=false then + if CollTwoObj(getX, getY, getW, getH, drop.getX(i), drop.getY(i), drop.getW, drop.getH) then + begin + sum:=inv.giveItem(drop.getItem(i), drop.getSum(i)); + drop.setSum(sum, i); + drop.fixNull(i); + end; + end; + +initialization + +end. diff --git a/src/randoms.mpsrc b/src/randoms.mpsrc new file mode 100644 index 0000000..4720898 --- /dev/null +++ b/src/randoms.mpsrc @@ -0,0 +1,37 @@ +unit randoms; + +interface + procedure srand(s:integer);//Устанавливает зерно для ГПСЧ + function rand:integer;//Возвращает случайное число + function rnd(max:integer):integer;//Возвращает число от 0 до max + function rnd_pr(pr,p1,p2:integer):integer; + +implementation + var + next:integer; + + function rand:integer; + begin + next:=next xor (next << 13); + next:=next xor (next >>> 17); + next:=next xor (next << 5); + rand:=abs(next); + end; + + procedure srand(s:integer); + begin + //Debug('srand('+s+')'); + next:=s; + end; + + function rnd(max:integer):integer; + begin + rnd:=rand mod max; + end; + + function rnd_pr(pr,p1,p2:integer):integer; + begin + if pr>=rnd(101) then rnd_pr:=p1; else rnd_pr:=p2; + end; + +end. \ No newline at end of file diff --git a/src/sign.pas b/src/sign.pas new file mode 100644 index 0000000..01552cb --- /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 new file mode 100644 index 0000000..6f69a9a --- /dev/null +++ b/src/utils.mpsrc @@ -0,0 +1,63 @@ +unit utils; + +interface +const + MaxTimers=2; + TIMER_ERROR=-1; + TIMER_OK=0; + + T_CONSOLE=0;//Timer for call console + T_KEY_DIVITEM=1; + T_KEY_DROPITEM=2; + +procedure SetTimer(t,i:integer); +function GetTimer(i:integer):integer; +procedure ResetTimer(i:integer); +procedure ResetAllTimers; + +implementation + var + Timer_value:array [0..MaxTimers] of integer; + Timer_time:array [0..MaxTimers] of integer; + +procedure SetTimer(t,i:integer); + begin + Timer_value[i]:=t; + Timer_time[i]:=getrelativetimems; + end; + +function GetTimer(i:integer):integer; + var + dt:integer; + begin + if Timer_value[i]>-1 then + begin + dt:=Timer_time[i]-getrelativetimems; + Timer_value[i]:=Timer_value[i]+dt; + if Timer_value[i]<0 then Timer_value[i]:=0; + Timer_time[i]:=getrelativetimems; + GetTimer:=Timer_value[i]; + end; + else GetTimer:=-1; + end; + +procedure ResetTimer(i:integer); + begin + Timer_value[i]:=-1; + Timer_time[i]:=-1; + end; + +procedure ResetAllTimers; + var + i:integer; + begin + for i:=0 to MaxTimers do + begin + Timer_value[i]:=-1; + Timer_time[i]:=-1; + end; + end; + +initialization + ResetAllTimers; +end. diff --git a/src/vars.mpsrc b/src/vars.mpsrc new file mode 100644 index 0000000..5ac6cb8 --- /dev/null +++ b/src/vars.mpsrc @@ -0,0 +1,90 @@ +unit vars; + +interface + const + max_sounds=13; + + FONT_STD_COLOR=$FFFFFFFF; + FONT_YELLOW_COLOR=$FFFFFF00; + FONT_MAX_SYM=127; + FONT_SYM_SIZE=8; + + MAP_W=256; + MAP_H=128; + + TILE_SIZE=16; + + var + pl_world:integer;//мир в котором находится игрок (0 - обычный мир, 1 - нижний мир) + fps:integer;//Текущий фпс, можно использовать для синхронизации + camx,camy:integer;//Координаты камеры + curx,cury:integer;//Координаты курсора игрока + game_time:integer;//Игровое время + gamemode:integer;//Режим игры + bon_chest:boolean;//Генерировать бонусный сундук? + //invslot:integer;//номер слота на "поясе" + + + tex_pack:string; + bl_ani5:integer; + + bl_ani5_v,bl_ani5_d:boolean; + + fish:boolean; + + + fish_time:integer; + hung_time,hp_time,air_time,portal_time:integer; + fx,fy:integer; + + maxBlockTex, maxItemTex:integer; + + tex:array [0..0] of image; + none0:image; + tex8:array [0..0] of image; + none1:image; + item:array [0..0] of image; + none2:image; + item8:array [0..0] of image; + none3:image; + font:array [0..127] of image; + none4:image; + + procedure initBlockTex(i:integer); + procedure initItemTex(i:integer); + +implementation + + procedure initBlockTex(i:integer); + begin + maxblocktex:=i; + i:=i+1; + bytecode + iload 0; + multianewarray class '[Ljavax/microedition/lcdui/Image;', 1; + putstatic field 'vars', 'tex', '[Ljavax/microedition/lcdui/Image;'; + end; + bytecode + iload 0; + multianewarray class '[Ljavax/microedition/lcdui/Image;', 1; + putstatic field 'vars', 'tex8', '[Ljavax/microedition/lcdui/Image;'; + end; + end; + + procedure initItemTex(i:integer); + begin + maxItemTex:=i; + i:=i+1; + bytecode + iload 0; + multianewarray class '[Ljavax/microedition/lcdui/Image;', 1; + putstatic field 'vars', 'item', '[Ljavax/microedition/lcdui/Image;'; + end; + bytecode + iload 0; + multianewarray class '[Ljavax/microedition/lcdui/Image;', 1; + putstatic field 'vars', 'item8', '[Ljavax/microedition/lcdui/Image;'; + end; + end; + +end. diff --git a/src/video.pas b/src/video.pas new file mode 100644 index 0000000..98cef80 --- /dev/null +++ b/src/video.pas @@ -0,0 +1,66 @@ +unit video; + +interface + procedure initVideo(scrW, scrH:integer; canScale:boolean;); + procedure drawVideo; + +implementation + uses scri, keyboard; + var + useRes:boolean; + + procedure initVideo(scrW, scrH:integer; canScale:boolean;); + var + tmp:integer; + begin + keyboard.scrMulX:=1; + keyboard.scrMulY:=1; + useRes:=false; + if (getWidth>getHeight) and (scrWscrW) and (getHeight>scrH)) or ((getHeight>scrW) and (getWidth>scrH)) then + begin + debug('Scaling: '+getWidth+'x'+getHeight+' -> '+scrW+'x'+scrH); + if getWidth '+scrW+'x'+scrH); + + ScriCreate(scrW, scrH); + if canScale then + begin + keyboard.scrMulX:=getWidth/scrW; + keyboard.scrMulY:=getHeight/scrH; + ScriScale(getWidth/scrW, getHeight/scrH); + ScriPosition(0, 0); + ScriSwap; + useRes:=true; + end; + end; + end; + + procedure drawVideo; + begin + draw_virtual_keys; + if useRes then + begin + ScriSwap; + ScriDraw; + Repaint; + ScriSwap; + end; + else + Repaint; + end; + +end. diff --git a/src/worldgen.mpsrc b/src/worldgen.mpsrc new file mode 100644 index 0000000..ca52210 --- /dev/null +++ b/src/worldgen.mpsrc @@ -0,0 +1,963 @@ +//Thanks: +//ZeroNoWing +//Andrey59 + +unit worldgen; + +interface + procedure genworld;//Вызывается из главного модуля для начала генерации мира + procedure gennether; + procedure genflat; + procedure genportal(xx,yy:integer); + function get_up(Xi:integer):integer; + + procedure genwood1(xx,yy:integer);//дуб + procedure genwood2(xx,yy:integer);//берёза + procedure genwood3(xx,yy:integer);//ель + + +implementation +uses maps,randoms,vars,items,func, player, chest, items_store; + + function rnd_min:integer; + begin + rnd_min:=rnd(3)-1; + end; + +procedure create_bonus_chest(chx,chy:integer); + var + ix,l,id,time:integer; + begin + time:=getcurrenttime; + if ((getmonth(time)=0) and (getday(time)<3)) or ((getmonth(time)=11) and (getday(time)>29)) then + setmap(102,chx,chy); + else + setmap(28,chx,chy); + setmap(26,chx-1,chy); + setmap(26,chx+1,chy); + setmapinfo(31,chx,chy); + id:=chest.create(chx,chy); + debug('Bonus Chest'); + for ix:=1 to rnd(10)+1 do + begin + l:=rnd(26); + if rnd(2)=rnd(2) then + begin + chest.setItem(127 ,l, id); + chest.setSum(rnd(6)+1, l, id); + end; else + if rnd(2)=rnd(2) then + begin + chest.setItem(9 ,l, id); + chest.setSum(rnd(4)+1, l, id); + end; else + if rnd(2)=rnd(2) then + begin + chest.setItem(4 ,l, id); + chest.setSum(rnd(4)+1, l, id); + end; else + if rnd(2)=rnd(2) then + begin + chest.setItem(131 ,l, id); + chest.setSum(60, l, id); + end; else + if rnd(2)=rnd(2) then + begin + chest.setItem(132 ,l, id); + chest.setSum(132, l, id); + end; + if rnd(2)=rnd(2) then + begin + chest.setItem(141 ,l, id); + chest.setSum(60, l, id); + end; else + if rnd(2)=rnd(2) then + begin + chest.setItem(142 ,l, id); + chest.setSum(132, l, id); + end; + if rnd(2)=rnd(2) then + begin + chest.setItem(147 ,l, id); + chest.setSum(60, l, id); + end; else + if rnd(2)=rnd(2) then + begin + chest.setItem(201 ,l, id); + chest.setSum(rnd(16), l, id); + end; + end; + end; + + procedure genflat; + var + ix,iy:integer; + begin + for ix:=0 to 255 do + begin + setmap(2,ix,121); + setmap(1,ix,122); + setmap(1,ix,123); + setmap(3,ix,124); + setmap(3,ix,125); + setmap(3,ix,126); + setmap(6,ix,127); + + setBackMap(121, ix); + setBiomMap(0, ix); + end; + if bon_chest then create_bonus_chest(get_spawn_x,get_spawn_y+1); + delay(200); + end; + + procedure drawmap; + var + ix,iy:integer; + begin + for ix:=0 to 255 do + for iy:=0 to 127 do + begin + if getmap(ix,iy)<>0 then setcolor(0,0,0); else setcolor(255,255,255); + plot(ix,iy); + end; + repaint; + delay(1); + end; + + procedure gencave(xx,yy:integer); + var + ix,iy:integer; + mask:array [0..63,0..63] of boolean; + begin + for ix:=0 to 63 do + for iy:=0 to 63 do + mask[ix,iy]:=true; + ix:=(63+1)/2-1; + iy:=(63+1)/2-1; + while (ix>=0) and (ix<=63) and (iy>=0) and (iy<=63) do + begin + ix:=ix+rnd_min; + iy:=iy+rnd_min; + if (ix>=0) and (ix<=63) and (iy>=0) and (iy<=63) then mask[ix,iy]:=false; + end; + for ix:=1 to 62 do + for iy:=1 to 62 do + begin + if mask[ix,iy]=true then + if mask[ix-1,iy]=false then + if mask[ix+1,iy]=false then + mask[ix,iy]:=false; + end; + + for ix:=0 to 63 do + for iy:=0 to 63 do + begin + if mask[ix,iy]=false then setmap(0,xx+ix,yy+iy); + end; + end; + + procedure genportal(xx,yy:integer); + begin + setmap(10,xx+1,yy); + setmap(10,xx+2,yy); + setmap(118,xx,yy+1); + setmap(118,xx+3,yy+1); + setmap(118,xx,yy+2); + setmap(118,xx+3,yy+2); + setmap(118,xx,yy+3); + setmap(118,xx+3,yy+3); + setmap(10,xx+1,yy+4); + setmap(10,xx+2,yy+4); + setmap(110,xx+1,yy+1); + setmap(110,xx+2,yy+1); + setmap(110,xx+1,yy+2); + setmap(110,xx+2,yy+2); + setmap(110,xx+1,yy+3); + setmap(110,xx+2,yy+3); + end; + + procedure genportal_big(xx,yy:integer); + begin + setmap(10,xx,yy); + setmap(10,xx+1,yy); + setmap(10,xx+2,yy); + setmap(10,xx+3,yy); + setmap(118,xx,yy+1); + setmap(118,xx+3,yy+1); + setmap(118,xx,yy+2); + setmap(118,xx+3,yy+2); + setmap(118,xx,yy+3); + setmap(118,xx+3,yy+3); + setmap(10,xx,yy+4); + setmap(10,xx+1,yy+4); + setmap(10,xx+2,yy+4); + setmap(10,xx+3,yy+4); + setmap(110,xx+1,yy+1); + setmap(110,xx+2,yy+1); + setmap(110,xx+1,yy+2); + setmap(110,xx+2,yy+2); + setmap(110,xx+1,yy+3); + setmap(110,xx+2,yy+3); + end; + + procedure surprisechest(x,y:integer); + var + ix,l,id:integer; + begin + id:=chest.create(x, y); + debug('Surprise!'); + setmap(102,x,y); + for ix:=1 to rnd(8) do + begin + l:=rnd(26); + if rnd(22)=1 then + begin + chest.setItem(162 ,l, id); + chest.setSum(rnd(5), l, id); + end; else + if rnd(11)=1 then + begin + chest.setItem(165 ,l, id); + chest.setSum(rnd(6), l, id); + end; else + if rnd(11)=1 then + begin + chest.setItem(181 ,l, id); + chest.setSum(rnd(2), l, id); + end; else + if rnd(11)=1 then + begin + chest.setItem(182 ,l, id); + chest.setSum(rnd(2), l, id); + end; else + if rnd(11)=1 then + begin + chest.setItem(176 ,l, id); + chest.setSum(rnd(32), l, id); + end; else + if rnd(11)=1 then + begin + chest.setItem(183 ,l, id); + chest.setSum(rnd(10)+1, l, id); + end; else + if rnd(11)=1 then + begin + chest.setItem(186 ,l, id); + chest.setSum(1, l, id); + end; + end; + end; + + procedure genwood1(xx,yy:integer);//дуб + begin + setmap(75,xx,yy); + setmap(75,xx,yy-1); + setmap(75,xx,yy-2); + setmap(21,xx,yy-3); + setmap(21,xx,yy-4); + setmap(21,xx,yy-5); + setmap(21,xx-1,yy-3); + setmap(21,xx-1,yy-4); + setmap(21,xx+1,yy-3); + setmap(21,xx+1,yy-4); + end; + + procedure genwood2(xx,yy:integer);//берёза + begin + setmap(84,xx,yy); + setmap(84,xx,yy-1); + setmap(84,xx,yy-2); + setmap(112,xx,yy-3); + setmap(112,xx,yy-4); + setmap(112,xx,yy-5); + setmap(112,xx-1,yy-3); + setmap(112,xx-1,yy-4); + setmap(112,xx+1,yy-3); + setmap(112,xx+1,yy-4); + end; + + procedure genwood3(xx,yy:integer);//ель + var + time:integer; + begin + setmap(87,xx,yy-5); + setmap(87,xx-1,yy-4); setmap(87,xx,yy-4); setmap(87,xx+1,yy-4); + setmap(86,xx,yy-3); + setmap(87,xx-1,yy-2); setmap(86,xx,yy-2); setmap(87,xx+1,yy-2); + 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); + setmap(86,xx,yy); + time:=getcurrenttime; + if ((getmonth(time)=0) and (getday(time)<3)) or ((getmonth(time)=11) and (getday(time)>29)) then + begin + if rnd(3)=1 then surprisechest(xx-1,yy); + if rnd(3)=1 then surprisechest(xx+1,yy); + end; + end; + + procedure genfungus1(xx,yy:integer);//красный гриб + begin + setmap(88,xx-1,yy-4); setmap(88,xx,yy-4); setmap(88,xx+1,yy-4); + 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); + 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); + setmap(89,xx,yy-1); + setmap(89,xx,yy); + end; + + procedure genfungus2(xx,yy:integer);//коричневый гриб + begin + 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); + setmap(91,xx,yy-3); + setmap(91,xx,yy-2); + setmap(91,xx,yy-1); + setmap(91,xx,yy); + end; + + procedure gencactus(xx,yy:integer); + begin + setmap(30,xx,yy); + setmap(30,xx,yy-1); + setmap(30,xx,yy-2); + end; + + procedure gencane(xx,yy:integer); + begin + setmap(65,xx,yy); + setmap(65,xx,yy-1); + setmap(65,xx,yy-2); + end; + + procedure treasurechest(x,y:integer); + var + ix,l,id:integer; + begin + id:=chest.create(x, y); + debug('Treasure Chest'); + setmap(28,x,y); + for ix:=1 to rnd(8) do + begin + l:=rnd(26); + if rnd(22)=rnd(22) then + begin + chest.setItem(161 ,l, id); + chest.setSum(rnd(4)+1, l, id); + end; else + if rnd(11)=rnd(11) then + begin + chest.setItem(164 ,l, id); + chest.setSum(rnd(4)+1, l, id); + end; else + if rnd(11)=rnd(11) then + begin + chest.setItem(183 ,l, id); + chest.setSum(rnd(4)+1, l, id); + end; else + if rnd(11)=rnd(11) then + begin + chest.setItem(167 ,l, id); + chest.setSum(rnd(4)+1, l, id); + end; else + if rnd(11)=rnd(11) then + begin + chest.setItem(171 ,l, id); + chest.setSum(1, l, id); + end; else + if rnd(4)=rnd(4) then + begin + chest.setItem(220 ,l, id); + chest.setSum(rnd(8)+8, l, id); + end; + end; + end; + + procedure genteasures(xx,yy:integer); + var + ix,iy:integer; + begin + for ix:=0 to 6 do + for iy:=0 to 6 do + begin + setmap(0,xx+ix,yy+iy); + end; + for ix:=0 to 6 do + begin + setmap(12,xx+ix,yy); + setmap(12,xx+ix,yy+6); + setmap(12,xx,yy+ix); + setmap(12,xx+6,yy+ix); + end; + + setmap(76,xx+3,yy+5); + setmapinfo(1,xx+3,yy+5); + + if rnd(2)=1 then + treasurechest(xx+1,yy+5); + + if rnd(2)=1 then + treasurechest(xx+5,yy+5); + end; + + procedure genrude(t,r,xx,yy,xxx,yyy:integer); + var + ix,iy:integer; + begin + for ix:=0 to xxx do + for iy:=0 to yyy do + begin + if getmap(xx+ix,yy+iy)=3 then if rnd(r+1)-1=0 then setmap(t,xx+ix,yy+iy); + end; + end; + + procedure genallrudes; + var + ix,iy,iu,iv:integer; + begin + //алмазы + for ix:=0 to 255 do + for iy:=111 to 127 do + if (rnd_pr(1,1,0)=1) then + begin + for iu:=0 to 2 do + for iv:=0 to 2 do + if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(10,19,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); + ix:=ix+3; + end; + + //золото + for ix:=0 to 255 do + for iy:=95 to 127 do + if (rnd_pr(3,1,0)=1) then + begin + for iu:=0 to 2 do + for iv:=0 to 2 do + if (ix+iu<255) and (iy+iv<126) then + if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(20,16,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); + ix:=ix+3; + end; + + //лазурит + for ix:=0 to 255 do + for iy:=107 to 127 do + if (rnd_pr(2,1,0)=1) then + begin + for iu:=0 to 2 do + for iv:=0 to 2 do + if (ix+iu<255) and (iy+iv<126) then + if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(40,54,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); + ix:=ix+3; + end; + + //редстоун + for ix:=0 to 255 do + for iy:=107 to 127 do + if (rnd_pr(2,1,0)=1) then + begin + for iu:=0 to 2 do + for iv:=0 to 2 do + if (ix+iu<255) and (iy+iv<126) then + if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(40,20,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); + ix:=ix+3; + end; + + //железо + for ix:=0 to 255 do + for iy:=63 to 127 do + if (rnd_pr(4,1,0)=1) then + begin + for iu:=0 to 2 do + for iv:=0 to 2 do + if (ix+iu<255) and (iy+iv<126) then + if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(40,17,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); + ix:=ix+3; + end; + + //уголь + for ix:=0 to 255 do + for iy:=0 to 127 do + if (rnd_pr(6,1,0)=1) then + begin + for iu:=0 to 2 do + for iv:=0 to 2 do + if (ix+iu<255) and (iy+iv<126) then + if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(50,18,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); + ix:=ix+3; + end; + + //гравий + for ix:=0 to 255 do + for iy:=63 to 126 do + if (rnd_pr(2,1,0)=1) then + begin + for iu:=0 to rnd(5) do + for iv:=0 to rnd(5) do + if (ix+iu<255) and (iy+iv<126) then + if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(90,8,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); + ix:=ix+3; + end; + + //земля на камне + for ix:=0 to 255 do + for iy:=63 to 127 do + if (rnd_pr(1,1,0)=1) then + begin + for iu:=0 to rnd(5) do + for iv:=0 to rnd(5) do + if (ix+iu<255) and (iy+iv<126) then + if getmap(ix+iu,iy+iv)=3 then setmap(rnd_pr(90,1,getmap(ix+iu,iy+iv)),ix+iu,iy+iv); + ix:=ix+3; + end; + end; + + procedure dec_0(ix,iy:integer); + var + t:integer; + begin + t:=rnd(30); + if t=0 then setmap(22,ix,iy); else + if t=1 then setmap(23,ix,iy); else + if t=2 then setmap(24,ix,iy); else + if t=3 then setmap(25,ix,iy); else + if (t>3) and (t<8) then setmap(57,ix,iy); else + if t=8 then genwood1(ix,iy); else + if t=9 then genwood2(ix,iy); else + if t=10 then setmap(66,ix,iy); else + if t=11 then setmap(73,ix,iy); else + 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 + exit; + end; + + procedure dec_1(ix,iy:integer); + var + t:integer; + begin + t:=rnd(25); + if t=0 then setmap(58,ix,iy); else + if t=1 then gencactus(ix,iy); else + 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 + exit; + end; + + procedure dec_2(ix,iy:integer); + var + t:integer; + begin + t:=rnd(30); + if t=0 then setmap(22,ix,iy); else + if t=1 then setmap(23,ix,iy); else + if t=2 then genwood1(ix,iy); else + if t=3 then genwood2(ix,iy); else + if t=4 then genwood3(ix,iy); else + if t=5 then setmap(66,ix,iy); else + exit; + end; + + procedure dec_3(ix,iy:integer); + var + t:integer; + begin + t:=rnd(20); + if t=1 then setmap(24,ix,iy); else + if t=2 then setmap(25,ix,iy); else + if t=3 then genfungus1(ix,iy); else + if t=4 then genfungus2(ix,iy); else + exit; + end; + + procedure decorator; + var + ix,iy,t:integer; + begin + for ix:=0 to 255 do + for iy:=0 to 127 do + if getmap(ix,iy)<>0 then + begin + if (getBiomMap(ix)=0) then + begin + iy:=iy-1; + if (getmap(ix,iy+1)=2) and (getmap(ix,iy)=0) then dec_0(ix,iy); + break; + end; else + if (getBiomMap(ix)=1) then + begin + iy:=iy-1; + if (getmap(ix,iy+1)=7) and (getmap(ix,iy)=0) then dec_1(ix,iy); + break; + end; else + if (getBiomMap(ix)=2) then + begin + iy:=iy-1; + if (getmap(ix,iy+1)=48) and (getmap(ix,iy)=0) then dec_2(ix,iy); + break; + end; else + if (getBiomMap(ix)=3) then + begin + iy:=iy-1; + if (getmap(ix,iy+1)=74) and (getmap(ix,iy)=0) then dec_3(ix,iy); + break; + end; else + break; + end; + end; + + procedure genwater; + var + ix,iy,i:integer; + g:boolean; + begin + for ix:=0 to 255 do + for iy:=0 to 127 do + begin + if rnd(5)=rnd(6) then g:=not g; + if iy>63 then + if (getmap(ix,iy)=2) or (getmap(ix,iy)=48) or (getmap(ix,iy)=74) then + begin + if g then + for i:=0 to rnd(4) do setmap(64,ix,iy+i); + else setmap(1,ix,iy); + break; + end; else + if (getmap(ix,iy)=7) then + begin + if g then + for i:=0 to rnd(4) do setmap(64,ix,iy+i); + break; + end; + if getmap(ix,iy)<>0 then break; + if iy>=63 then if getmap(ix,iy)=0 then setmap(50,ix,iy); + end; + end; + + procedure minechest(x,y:integer); + var + ix,l,id:integer; + begin + id:=chest.create(x,y); + setmap(28,x,y); + for ix:=1 to rnd(6)+4 do + begin + l:=rnd(26); + if rnd(75)=rnd(75) then + begin + chest.setItem(133 ,l, id); + chest.setSum(getItemMax(133), l, id); + end; else + if rnd(25)=rnd(25) then + begin + chest.setItem(162 ,l, id); + chest.setSum(rnd(2)+1, l, id); + end; else + if rnd(15)=rnd(15) then + begin + chest.setItem(165 ,l, id); + chest.setSum(rnd(3)+1, l, id); + end; else + if rnd(15)=rnd(15) then + begin + chest.setItem(166 ,l, id); + chest.setSum(rnd(6)+4, l, id); + end; else + if rnd(15)=rnd(15) then + begin + chest.setItem(161 ,l, id); + chest.setSum(rnd(6)+4, l, id); + end; else + if rnd(15)=rnd(15) then + begin + chest.setItem(160 ,l, id); + chest.setSum(rnd(6)+3, l, id); + end; else + if rnd(15)=rnd(15) then + begin + chest.setItem(164 ,l, id); + chest.setSum(rnd(5)+1, l, id); + end; else + if rnd(4)=rnd(4) then + begin + chest.setItem(220 ,l, id); + chest.setSum(rnd(8)+8, l, id); + end; + end; + end; + + procedure minestruc0(x,y:integer); + var + ix,iy:integer; + begin + for ix:=0 to 3 do + for iy:=0 to 2 do + setmap(0,x+ix,y+iy); + + if rnd(8)=0 then setmap(26,x+1,y+1); + + for ix:=0 to 3 do + if getmap(x+ix,y+3)=0 then setmap(4,x+ix,y+3); + end; + + procedure minestruc1(x,y:integer); + var + ix,iy:integer; + begin + for ix:=0 to 2 do + for iy:=0 to 2 do + setmap(0,x+ix,y+iy); + + if rnd(8)=0 then setmap(59,x,y); + if rnd(8)=0 then setmap(59,x+2,y); + setmap(4,x+1,y); + setmap(93,x+1,y+1); + setmap(93,x+1,y+2); + for ix:=0 to 2 do + if getmap(x+ix,y+3)=0 then setmap(4,x+ix,y+3); + end; + + procedure minestruc2(x,y:integer); + var + ix,iy:integer; + begin + for ix:=0 to 2 do + for iy:=0 to 2 do + setmap(0,x+ix,y+iy); + + if rnd(8)=0 then setmap(59,x+1,y); + + for iy:=0 to 2 do + begin + setmap(94,x,y+iy); + setmap(94,x+2,y+iy); + end; + for ix:=0 to 2 do + if getmap(x+ix,y+3)=0 then setmap(4,x+ix,y+3); + end; + + procedure minestruc3(x,y:integer); + var + ix,iy,id,l:integer; + begin + for ix:=0 to 2 do + for iy:=0 to 2 do + setmap(0,x+ix,y+iy); + + minechest(x+1,y+2); + + for ix:=0 to 2 do + if getmap(x+ix,y+3)=0 then setmap(4,x+ix,y+3); + end; + + procedure genmines(x,y:integer); + var + mask:array[0..15,0..15] of integer; + ix,iy,by:integer; + begin + for iy:=0 to 15 do + for ix:=0 to 15 do + mask[ix,iy]:=-1; + + for iy:=rnd(8)+8 downto rnd(8) do + for ix:=rnd(8) to rnd(8)+8 do + begin + if ix-1>=0 then + begin + if mask[ix-1,iy]=-1 then mask[ix,iy]:=rnd(3); else + if mask[ix-1,iy]=0 then if rnd(16)=5 then mask[ix,iy]:=2; else mask[ix,iy]:=1; else + if mask[ix-1,iy]=1 then mask[ix,iy]:=0; else + if mask[ix-1,iy]=2 then mask[ix,iy]:=rnd(3); else + if mask[ix-1,iy]=3 then mask[ix,iy]:=rnd(3); + end; + + if mask[ix,iy]=0 then + begin + if rnd(16)=0 then mask[ix,iy]:=3; + end; + end; + + for iy:=15 downto 0 do + for ix:=0 to 15 do + begin + if rnd(16)=0 then by:=rnd_min;; + if mask[ix,iy]=0 then minestruc0(x+(3*ix),y+(4*iy+by)); else + if mask[ix,iy]=1 then minestruc1(x+(3*ix),y+(4*iy+by)); else + if mask[ix,iy]=2 then minestruc2(x+(3*ix),y+(4*iy+by)); else + if mask[ix,iy]=3 then minestruc3(x+(3*ix),y+(4*iy+by)); + end; + end; + + function get_up(Xi:integer):integer; + var + iy:integer; + begin + for iy:=127 downto 0 do + if getmap(xi,iy)=0 then begin get_up:=iy; break; end; + end; + + function get_down(Xi:integer):integer; + var + iy:integer; + begin + for iy:=2 to 127 do + if getmap(xi,iy)=0 then begin get_down:=iy; break; end; + end; + + procedure gensoulsand(gx,gy:integer;); + var + ix2,iy2:integer; + begin + for ix2:=gx-2-rnd(3) to gx+2+rnd(3) do + for iy2:=gy-1-rnd(2) to gy+1+rnd(2) do + setmap(rnd_pr(80,113,getmap(ix2,iy2)),ix2,iy2); + end; + + procedure genglowstone(gx,gy:integer;); + var + ix2,iy2:integer; + begin + for ix2:=gx-1-rnd(2) to gx+1+rnd(2) do + for iy2:=gy-1-rnd(2) to gy+rnd(2) do + setmap(rnd_pr(85,111,getmap(ix2,iy2)),ix2,iy2); + end; + + procedure gennether; + var + ix,iy,h,wtd,ty,ga,tmp:integer; + begin + for ix:=0 to 255 do + for iy:=1 to 126 do + begin + if (getmap(ix,iy)<>10) or (getmap(ix,iy)<>110) then + setmap(109,ix,iy); + end; + h:=63; + ty:=4; + for ix:=0 to 255 do + begin + wtd:=rnd(100); + if (wtd>0) and (wtd<30) then h:=h+1; + if (wtd>29) and (wtd<60) then h:=h-1; + if wtd=0 then h:=h+(2+rnd(3)); + if wtd=99 then h:=h-(2+rnd(3)); + if h<30 then h:=31; + if h>70 then h:=69; + setBiomMap(ty, ix); + setBackMap(0, ix); + for iy:=h-10-(1-rnd(3)) to h+rnd(2) do + begin + setmap(0,ix,iy); + end; + end; + + for ix:=0 to 255 do + for iy:=65 to 127 do + begin + if getmap(ix,iy)=0 then setmap(51,ix,iy); + end; + + for ix:=1 to rnd(3)+3 do begin iy:=rnd(256); debug('SoulSand'); gensoulsand(iy,get_up(iy)); end; + for ix:=1 to rnd(4)+7 do begin iy:=rnd(256); debug('GlowStone - '+iy); genglowstone(iy,get_down(iy)); end; + + for ix:=0 to 255 do + begin + setmap(6,ix,127); + setmap(6,ix,0); + end; + player.setX(get_spawn_x*16+4); + player.setY((get_up(get_spawn_x)-1)*16); + setmap(109,get_spawn_x,get_up(get_spawn_x)+1); + setmap(0,get_spawn_x,get_up(get_spawn_x)); + setmap(0,get_spawn_x,get_up(get_spawn_x)-1); + genportal_big(get_spawn_x-2,(get_up(get_spawn_x)-1)-2); + end; + + procedure genworld; + var + ix,iy,h,wtd,ty,ga,tmp:integer; + begin + pl_world:=0; + for ix:=0 to 255 do + for iy:=0 to 127 do + setmap(0,ix,iy); + h:=63; + ty:=rnd(4); + for ix:=0 to 255 do + begin + wtd:=rnd(100); + if (wtd>0) and (wtd<30) then h:=h+1; + if (wtd>29) and (wtd<60) then h:=h-1; + if wtd=0 then h:=h+(2+rnd(3)); + if wtd=99 then h:=h-(2+rnd(3)); + if h<0 then h:=0; + if h>80 then h:=80; + if wtd=rnd(100) then begin ty:=rnd(4); debug('Biome:'+ty); end; + setBiomMap(ty, ix); + setBackMap(h, ix); + if getBackMap(ix)>63 then + setBackMap(63, ix); + for iy:=h to 127 do + begin + if ty=0 then + begin + if iy=h then setmap(2,ix,iy); + if (iy>h) and (iyh+3 then setmap(3,ix,iy); + end; else + if ty=1 then + begin + if (iy>=h) and (iy<=h+1) then setmap(7,ix,iy); + if iy=h+2 then setmap(rnd_pr(50,56,7),ix,iy); + if iy=h+3 then setmap(56,ix,iy); + if iy>h+3 then setmap(3,ix,iy); + end; else + if ty=2 then + begin + if iy=h then setmap(48,ix,iy); + if (iy>h) and (iyh+3 then setmap(3,ix,iy); + end; else + if ty=3 then + begin + if iy=h then setmap(74,ix,iy); + if (iy>h) and (iyh+3 then setmap(3,ix,iy); + end; + end; + end; + + genallrudes; + + for ix:=1 to rnd(4)+1 do begin debug('Cave'); gencave(rnd(256),64-rnd(10)); end; + + for ix:=1 to rnd(3) do begin debug('Mine'); genmines(rnd(256),rnd(64)+64); end; + + for ix:=1 to rnd(4) do begin debug('Treasure'); genteasures(rnd(256),rnd(64)+64); end; + + genwater; + + for ix:=0 to 255 do + for iy:=117 to 127 do + begin + if getmap(ix,iy)=0 then setmap(51,ix,iy); + end; + + decorator; + + for ix:=0 to 255 do + begin + if getBiomMap(ix)=2 then + for iy:=0 to 127 do + if getmap(ix,iy)<>0 then + begin + if getmap(ix,iy)=50 then setmap(62,ix,iy); else + if (getmap(ix,iy)<>22) and (getmap(ix,iy)<>23) then setmap(63,ix,iy-1); + break; + end; + end; + + for ix:=0 to 255 do setmap(6,ix,127); + + if bon_chest then create_bonus_chest(get_spawn_x,get_spawn_y+1); + + //drawmap; + delay(200); + debug('World Generated!'); + end; + +initialization + +end.