home · contact · privacy
7DRL: Only player may pick up non-food.(Or AI axe-blocks its inventory.)
[plomrogue] / roguelike-server
index c5b50db90d44aa18fece591748ca8435623383c2..b5468a59c3b91fa675144f63fd9f1cb374df8e8d 100755 (executable)
@@ -903,6 +903,7 @@ def actor_pick_up(t):
     Define topmostness by how low the thing's type ID is.
     """
     # 7DRL: Non-player picking up player-dropped consumable -> GOD_FAVOR gain.
+    # 7DRL: Only player picks up non-food.
     used_slots = len(t["T_CARRIES"]) # #
     if used_slots < world_db["ThingTypes"][t["T_TYPE"]]["TT_STORAGE"]: # #
         ids = [id for id in world_db["Things"] if world_db["Things"][id] != t
@@ -914,6 +915,9 @@ def actor_pick_up(t):
             for iid in ids:
                 tid = world_db["Things"][iid]["T_TYPE"] 
                 if lowest_tid == -1 or tid < lowest_tid:
+                    if (t != world_db["Things"][0] and  # #
+                        world_db["ThingTypes"][tid]["TT_TOOL"] != "food"):
+                        continue
                     id = iid
                     lowest_tid = tid
             world_db["Things"][id]["carried"] = True
@@ -1310,16 +1314,20 @@ def standing_on_food(t):
 
 
 def get_inventory_slot_to_consume(t):
-    """Return slot Id of strongest consumable in t's inventory, else -1."""
-    cmp_food = 0
+    """Return slot Id of healthiest consumable in t's inventory, else -1."""
+    cmp_food = -1
     selection = -1
     i = 0
     for id in t["T_CARRIES"]:
         type = world_db["Things"][id]["T_TYPE"]
         if world_db["ThingTypes"][type]["TT_TOOL"] == "food" \
-           and world_db["ThingTypes"][type]["TT_TOOLPOWER"] > cmp_food:
-            cmp_food = world_db["ThingTypes"][type]["TT_TOOLPOWER"]
-            selection = i
+           and world_db["ThingTypes"][type]["TT_TOOLPOWER"]:
+            nutvalue = world_db["ThingTypes"][type]["TT_TOOLPOWER"]
+            tmp_cmp = abs(t["T_SATIATION"] + nutvalue)
+            if (cmp_food < 0 and tmp_cmp < abs(t["T_SATIATION"])) \
+            or tmp_cmp < cmp_food:
+                cmp_food = tmp_cmp
+                selection = i
         i += 1
     return selection