From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 12 Mar 2015 15:59:18 +0000 (+0100)
Subject: 7DRL: Add an "axe" tool type to chop down trees with.
X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/%7B%7Bdb.prefix%7D%7D/calendar?a=commitdiff_plain;h=e3cab0b80bfbae934a2675dc5a7430a7a47c958f;p=plomrogue

7DRL: Add an "axe" tool type to chop down trees with.
---

diff --git a/SERVER_COMMANDS b/SERVER_COMMANDS
index b8385d3..3ae0b20 100644
--- a/SERVER_COMMANDS
+++ b/SERVER_COMMANDS
@@ -248,3 +248,5 @@ SLIPPERS [0 to infinity]
 FAVOR_STAGE [0 to 65535]
 
 PLANT_0 [0 to infinity]
+
+TT_TOOLS gain the "axe" argument.
diff --git a/confserver/world b/confserver/world
index 669c088..e6c85ac 100644
--- a/confserver/world
+++ b/confserver/world
@@ -92,6 +92,13 @@ TT_NAME 'PLANT #2'
 TT_TOOLPOWER 0
 TT_PROLIFERATE 512
 
+TT_ID 9
+TT_TOOL axe
+TT_SYMBOL /
+TT_NAME AXE
+TT_TOOLPOWER 5000
+TT_START_NUMBER 1
+
 TT_ID 0
 TT_CORPSE_ID 6
 TT_ID 1
@@ -108,6 +115,10 @@ TT_ID 6
 TT_CORPSE_ID 4
 TT_ID 7
 TT_CORPSE_ID 4
+TT_ID 8
+TT_CORPSE_ID 4
+TT_ID 9
+TT_CORPSE_ID 4
 
 FAVOR_STAGE 0
 SLIPPERS 1
diff --git a/roguelike-server b/roguelike-server
index 53cd751..305c8aa 100755
--- a/roguelike-server
+++ b/roguelike-server
@@ -736,6 +736,7 @@ def actor_move(t):
     """If passable, move/collide(=attack) thing into T_ARGUMENT's direction."""
     # 7DRL: Player wounding (worse: killing) others will lower God's favor.
     # 7DRL: Player entering the altar triggers enter_altar().
+    # 7DRL: Player with axe chops down trees.
     passable = False
     move_result = mv_yx_in_dir_legal(chr(t["T_ARGUMENT"]),
                                      t["T_POSY"], t["T_POSX"])
@@ -762,6 +763,28 @@ def actor_move(t):
             if test and t == world_db["Things"][0]:  # #
                 add_gods_favor(-test)  # #
             return
+        if ord("X") == world_db["MAP"][pos]:  # #
+            carries_axe = False  # #
+            for id in t["T_CARRIES"]:  # # 
+                type = world_db["Things"][id]["T_TYPE"]  # #
+                if world_db["ThingTypes"][type]["TT_TOOL"] == "axe":  # #
+                    carries_axe = True  # #
+            if carries_axe:  # #
+                axe_name = world_db["ThingTypes"][type]["TT_NAME"]  # #
+                if t == world_db["Things"][0]:  # #
+                    strong_write(io_db["file_out"], "LOG With your "  # #
+                                                    + axe_name  # #
+                                                    + ", you chop!\n")  # #
+                    add_gods_favor(-1)  # #
+                chop_power = world_db["ThingTypes"][type]["TT_TOOLPOWER"]
+                if chop_power > 0 and 0 == int(rand.next() / chop_power):  # #
+                    if t == world_db["Things"][0]:  # #
+                        strong_write(io_db["file_out"],  # #
+                                     "LOG You chop the tree down.\n")  # #
+                    add_gods_favor(-10)  # #
+                    world_db["MAP"][pos] = ord(".")   # #
+                    build_fov_map(t)  # #
+                return   # #
         passable = ("." == chr(world_db["MAP"][pos]) or
                     ":" == chr(world_db["MAP"][pos]) or # #
                     "_" == chr(world_db["MAP"][pos])) # #
@@ -852,6 +875,12 @@ def actor_use(t):
                              + "Island God laughs.\n")  # #
             t["T_LIFEPOINTS"] = 1  # #
             decrement_lifepoints(t)  # #
+        elif (world_db["ThingTypes"][type]["TT_TOOL"] == "axe"  # #
+              and t == world_db["Things"][0]):  # #
+                strong_write(io_db["file_out"],  # #
+                             "LOG To use this item for chopping, move "  # #
+                             "towards a tree while carrying it in "  # #
+                             "your inventory.\n")  # #
         elif world_db["ThingTypes"][type]["TT_TOOL"] == "food":
             t["T_CARRIES"].remove(id)
             del world_db["Things"][id]
diff --git a/src/client/draw_wins.c b/src/client/draw_wins.c
index 822b0b7..d0b66a9 100644
--- a/src/client/draw_wins.c
+++ b/src/client/draw_wins.c
@@ -447,7 +447,7 @@ extern void draw_win_map(struct Win * win)
                 { //
                     a = COLOR_PAIR(9); //
                 } //
-                else if ('m' == c) //
+                else if ('m' == c || '/' == c) //
                 { //
                     a = COLOR_PAIR(10); //
                 } //