home · contact · privacy
TCE: Creatures may suck resources from other creatures.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 12 Mar 2016 23:13:53 +0000 (00:13 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 12 Mar 2016 23:13:53 +0000 (00:13 +0100)
confserver/TheCrawlingEater
plugins/server/TheCrawlingEater.py

index ab27c591686ac898246368dfd842c6d1ebbc3fba..eb67b739ae709580d6718da2832914296333d36f 100644 (file)
@@ -25,6 +25,7 @@ TT_ID 0
 TT_START_NUMBER 1
 TT_LIFEPOINTS 1
 TT_SYMBOL @
+TT_NAME CREATURE
 
 TT_ID 5
 TT_SYMBOL %
index 125d3f1a9ce77f7813521f22aa4e121d6031f847..fced6c8821c4d62590c559bec6318b7eedd54582 100644 (file)
@@ -84,6 +84,17 @@ def play_move(str_arg):
         move_result = mv_yx_in_dir_legal(chr(d), t["T_POSY"], t["T_POSX"])
         if 1 == move_result[0]:
             pos = (move_result[1] * world_db["MAP_LENGTH"]) + move_result[2]
+            hitted = [tid for tid in world_db["Things"]
+                      if world_db["Things"][tid]["T_POSY"] == move_result[1]
+                      if world_db["Things"][tid]["T_POSX"] == move_result[2]]
+            if len(hitted) > 0:
+                if t["T_STOMACH"] >= 32 and t["T_KIDNEY"] >= 32:
+                    if t == world_db["Things"][0]:
+                        log("You're too FULL to suck from another creature.")
+                    return
+                world_db["Things"][0]["T_ARGUMENT"] = d
+                world_db["set_command"]("eat")
+                return
             if chr(world_db["MAP"][pos]) in "34":
                 if t["T_STOMACH"] >= 32:
                     if t == world_db["Things"][0]:
@@ -107,21 +118,26 @@ def actor_eat(t):
                                      t["T_POSY"], t["T_POSX"])
     if 1 == move_result[0]:
         pos = (move_result[1] * world_db["MAP_LENGTH"]) + move_result[2]
-        #hitted = [tid for tid in world_db["Things"]
-        #          if world_db["Things"][tid] != t
-        #          if world_db["Things"][tid]["T_LIFEPOINTS"]
-        #          if world_db["Things"][tid]["T_POSY"] == move_result[1]
-        #          if world_db["Things"][tid]["T_POSX"] == move_result[2]]
-        #if len(hitted):
-        #    hit_id = hitted[0]
-        #    hitted_tid = world_db["Things"][hit_id]["T_TYPE"]
-        #    if t == world_db["Things"][0]:
-        #        hitted_name = world_db["ThingTypes"][hitted_tid]["TT_NAME"]
-        #        log("You BUMP into " + hitted_name + ".")
-        #    elif 0 == hit_id:
-        #        hitter_name = world_db["ThingTypes"][t["T_TYPE"]]["TT_NAME"]
-        #        log(hitter_name +" BUMPS into you.")
-        #    return
+        hitted = [tid for tid in world_db["Things"]
+                  if world_db["Things"][tid]["T_POSY"] == move_result[1]
+                  if world_db["Things"][tid]["T_POSX"] == move_result[2]]
+        if len(hitted):
+            hit_id = hitted[0]
+            hitted_tid = world_db["Things"][hit_id]["T_TYPE"]
+            if t == world_db["Things"][0]:
+                hitted_name = world_db["ThingTypes"][hitted_tid]["TT_NAME"]
+                log("You SUCK from " + hitted_name + ".")
+            elif 0 == hit_id:
+                hitter_name = world_db["ThingTypes"][t["T_TYPE"]]["TT_NAME"]
+                log(hitter_name +" SUCKS from you.")
+            hitted = world_db["Things"][hit_id]
+            if t["T_STOMACH"] < 32:
+                t["T_STOMACH"] = t["T_STOMACH"] + 1
+                hitted["T_STOMACH"] -= 1
+            if t["T_KIDNEY"] < 32:
+                t["T_KIDNEY"] = t["T_KIDNEY"] + 1
+                hitted["T_KIDNEY"] -= 1
+            return
         passable = chr(world_db["MAP"][pos]) in symbols_passable
     if passable and t == world_db["Things"][0]:
         log("You try to EAT, but fail.")
@@ -149,27 +165,27 @@ def actor_move(t):
                                      t["T_POSY"], t["T_POSX"])
     if 1 == move_result[0]:
         pos = (move_result[1] * world_db["MAP_LENGTH"]) + move_result[2]
-        #hitted = [tid for tid in world_db["Things"]
-        #          if world_db["Things"][tid] != t
-        #          if world_db["Things"][tid]["T_LIFEPOINTS"]
-        #          if world_db["Things"][tid]["T_POSY"] == move_result[1]
-        #          if world_db["Things"][tid]["T_POSX"] == move_result[2]]
-        #if len(hitted):
-        #    hit_id = hitted[0]
-        #    hitted_tid = world_db["Things"][hit_id]["T_TYPE"]
-        #    if t == world_db["Things"][0]:
-        #        hitted_name = world_db["ThingTypes"][hitted_tid]["TT_NAME"]
-        #        log("You BUMP into " + hitted_name + ".")
-        #    elif 0 == hit_id:
-        #        hitter_name = world_db["ThingTypes"][t["T_TYPE"]]["TT_NAME"]
-        #        log(hitter_name +" BUMPS into you.")
-        #    return
+        hitted = [tid for tid in world_db["Things"]
+                  if world_db["Things"][tid]["T_POSY"] == move_result[1]
+                  if world_db["Things"][tid]["T_POSX"] == move_result[2]]
+        if len(hitted):
+            hit_id = hitted[0]
+            hitted_tid = world_db["Things"][hit_id]["T_TYPE"]
+            if t == world_db["Things"][0]:
+                hitted_name = world_db["ThingTypes"][hitted_tid]["TT_NAME"]
+                log("You BUMP into " + hitted_name + ".")
+            elif 0 == hit_id:
+                hitter_name = world_db["ThingTypes"][t["T_TYPE"]]["TT_NAME"]
+                log(hitter_name +" BUMPS into you.")
+            return
         passable = chr(world_db["MAP"][pos]) in symbols_passable
     if passable:
         t["T_POSY"] = move_result[1]
         t["T_POSX"] = move_result[2]
         t["pos"] = move_result[1] * world_db["MAP_LENGTH"] + move_result[2]
         build_fov_map(t)
+        #if t != world_db["Things"][0]:
+        #    world_db["Things"][0]["T_MEMMAP"][t["pos"]] = ord("?")
     elif t == world_db["Things"][0]:
         log("You try to MOVE there, but fail.")