home · contact · privacy
7DRL: Extend EMPATHY display with actors' current actions.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 14 Mar 2015 00:26:10 +0000 (01:26 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 14 Mar 2015 00:26:10 +0000 (01:26 +0100)
roguelike-server
src/client/draw_wins.c
src/client/io.c
src/client/world.h

index b61265795b6f0158548fb15dd6cc98409580f242..311a62b994857374134684a413f6fc2947e30850 100755 (executable)
@@ -360,7 +360,7 @@ def try_worldstate_update():
              mem[(mt[1] * length) + mt[2]] = ord(c)
         string = write_map(string, mem)
 
-        stacksmap = bytearray(b'0' * (length ** 2))  # #
+        metamapA = bytearray(b'0' * (length ** 2))  # #
         for id in [id for id in world_db["Things"]  # #
                       if not world_db["Things"][id]["carried"]  # #
                       if world_db["Things"][id]["T_LIFEPOINTS"]  # #
@@ -379,15 +379,33 @@ def try_worldstate_update():
                      add = 2  # #
                 elif hp > third_of_hp:  # #
                     add = 1  # #
-                stacksmap[pos] = ord('a') + add # #
+                metamapA[pos] = ord('a') + add # #
             else:  # #
-                stacksmap[pos] = ord('X')  # #
+                metamapA[pos] = ord('X')  # #
         for mt in world_db["Things"][0]["T_MEMTHING"]:  # #
             pos = mt[1] * length + mt[2]  # #
-            if stacksmap[pos] < ord('2'):  # #
-                stacksmap[pos] += 1  # #
-        string = write_map(string, stacksmap)  # #
+            if metamapA[pos] < ord('2'):  # #
+                metamapA[pos] += 1  # #
+        string = write_map(string, metamapA)  # #
         
+        metamapB = bytearray(b' ' * (length ** 2))  # #
+        for id in [id for id in world_db["Things"]  # #
+                      if not world_db["Things"][id]["carried"]  # #
+                      if world_db["Things"][id]["T_LIFEPOINTS"]  # #
+                      if world_db["Things"][0]["fovmap"][  # #
+                           world_db["Things"][id]["T_POSY"] * length  # #
+                           + world_db["Things"][id]["T_POSX"]] == ord_v]:  # #
+            pos = (world_db["Things"][id]["T_POSY"] * length  # #
+                  + world_db["Things"][id]["T_POSX"])  # #
+            if id == 0 or world_db["EMPATHY"]:  # #
+                action = world_db["Things"][id]["T_COMMAND"]  # #
+                if 0 != action:  # #
+                    name = world_db["ThingActions"][action]["TA_NAME"]  # #
+                else:  # #
+                    name = " "  # #
+                metamapB[pos] = ord(name[0]) # #
+        string = write_map(string, metamapB)  # #
+
         atomic_write(io_db["path_worldstate"], string, delete=False)
         strong_write(io_db["file_out"], "WORLD_UPDATED\n")
         io_db["worldstate_updateable"] = False
index 4725e806b6ebe56391de9b2ee3423780d7e292c8..4117e5f36e38e35f685741f4cdd0a810bdb930a1 100644 (file)
@@ -387,10 +387,10 @@ extern void draw_win_map(struct Win * win)
     init_pair(2, COLOR_BLUE, COLOR_WHITE); //
     init_pair(3, COLOR_RED, COLOR_WHITE); //
     init_pair(4, COLOR_WHITE, COLOR_BLUE); //
-    init_pair(5, COLOR_WHITE, COLOR_RED); //
+    init_pair(5, COLOR_BLUE, COLOR_RED); //
     init_pair(6, COLOR_BLACK, COLOR_RED); //
-    init_pair(7, COLOR_WHITE, COLOR_GREEN); //
-    init_pair(8, COLOR_WHITE, COLOR_YELLOW); //
+    init_pair(7, COLOR_BLUE, COLOR_GREEN); //
+    init_pair(8, COLOR_BLUE, COLOR_YELLOW); //
     init_pair(9, COLOR_BLACK, COLOR_MAGENTA); //
     init_pair(18, COLOR_WHITE, COLOR_CYAN); //
     init_pair(10, COLOR_BLACK, COLOR_CYAN); //
@@ -430,7 +430,7 @@ extern void draw_win_map(struct Win * win)
             char c = world.mem_map[y*world.map.length + x];
             set_ch_on_yx(win, y, x * 2 + (y % 2),     c   | a);
             chtype depth = ' ' | a;  //
-            if (world.stacks_map[y * world.map.length + x] == '2')  //
+            if (world.meta_map_0[y * world.map.length + x] == '2')  //
             {  //
                 depth = '+' | col_mem; //
             }  //
@@ -503,25 +503,29 @@ extern void draw_win_map(struct Win * win)
                 } //
                 // char c = world.map.cells[y*world.map.length + x];
                 set_ch_on_yx(win, y, x * 2 + (y % 2),     c | a); //
-                chtype depth = ' ' | a;  //
-                char stacksmapval = world.stacks_map[y*world.map.length+x]; //
-                if (stacksmapval == '2')  //
+                chtype meta = ' ' | a;  //
+                char metamap0val = world.meta_map_0[y*world.map.length+x]; //
+                if (metamap0val == '2')  //
                 {  //
-                    depth = '+' | col_stack;  //
+                    meta = '+' | col_stack;  //
                 }  //
-                else if (stacksmapval == 'a') //
+                else if (metamap0val != '0' && metamap0val != '1') //
                 { //
-                    depth = ' ' | col_health_bad; //
+                    char c = world.meta_map_1[y*world.map.length+x];
+                    if (metamap0val == 'a') //
+                    { //
+                        meta = c | col_health_bad; //
+                    } //
+                    else if (metamap0val == 'b') //
+                    { //
+                        meta = c | col_health_middle; //
+                    } //
+                    else if (metamap0val == 'c') //
+                    { //
+                        meta = c | col_health_good; //
+                    } //
                 } //
-                else if (stacksmapval == 'b') //
-                { //
-                    depth = ' ' | col_health_middle; //
-                } //
-                else if (stacksmapval == 'c') //
-                { //
-                    depth = ' ' | col_health_good; //
-                } //
-                set_ch_on_yx(win, y, x * 2 + (y % 2) + 1, depth); //
+                set_ch_on_yx(win, y, x * 2 + (y % 2) + 1, meta); //
                 // set_ch_on_yx(win, y, x * 2 + (y % 2),     c);
                 // set_ch_on_yx(win, y, x * 2 + (y % 2) + 1, ' ');
             }
index df90c17f2be29be49451b35c866bcd44387b422c..d7d145065d918f1fe6c6fb8826af8077700344a7 100644 (file)
@@ -197,7 +197,8 @@ static uint8_t read_worldstate()
     world.map.length = (uint16_t) read_value_from_line(read_buf, linemax, file);
     read_map_cells(file, &world.map.cells);
     read_map_cells(file, &world.mem_map);
-    read_map_cells(file, &world.stacks_map);  //
+    read_map_cells(file, &world.meta_map_0);  //
+    read_map_cells(file, &world.meta_map_1);  //
     free(read_buf);
     try_fclose(file, __func__);
     return 1;
index 9d47e92ffab8031e1b5dffd41b824dbab8c752a7..5c80143a2b70b1ae255ccfceaf94ae57af87ad7b 100644 (file)
@@ -38,7 +38,8 @@ struct World
     char * path_commands; /* path of commands config file */
     char * player_inventory; /* one-item-per-line string list of owned items */
     char * mem_map; /* map cells of player's map memory */
-    char * stacks_map; /* map of depths of thing stacks on world map */ // 7DRL
+    char * meta_map_0; /* map cells metadata  */ // 7DRL
+    char * meta_map_1; /* map cells metadata  */ // 7DRL
     char * queue; /* stores un-processed messages read from the input file */
     struct yx_uint8 player_pos; /* coordinates of player on map */
     struct yx_uint8 look_pos; /* coordinates of look cursor */