home · contact · privacy
7DRL: more balanced world config.
[plomrogue] / roguelike-server
index 0bb69884d40f31adbd73d16e23efe89c71e0cea4..4e46788595bc942f116ca2a913c628798ca29b1a 100755 (executable)
@@ -1167,11 +1167,13 @@ def get_dir_to_target(t, filter):
         if t["fovmap"] and "a" == filter:
             for id in world_db["Things"]:
                 if animate_in_fov(world_db["Things"][id]):
-                    return good_attack_target(world_db["Things"][id])
+                    if good_attack_target(world_db["Things"][id]):
+                        return True
         elif t["fovmap"] and "f" == filter:
             for id in world_db["Things"]:
                 if animate_in_fov(world_db["Things"][id]):
-                    return good_flee_target(world_db["Things"][id])
+                    if good_flee_target(world_db["Things"][id]):
+                        return True
         elif t["T_MEMMAP"] and "c" == filter:
             eat_cost = eat_vs_hunger_threshold(t["T_TYPE"])
             for mt in t["T_MEMTHING"]:
@@ -1346,7 +1348,7 @@ def ai(t):
     """Determine next command/argment for actor t via AI algorithms."""
     # 7DRL add: Don't pick up or search things when inventory is full.
     if t == world_db["Things"][0]:
-         log("%AI------")
+        log("%AI------")
     t["T_COMMAND"] = [id for id in world_db["ThingActions"]
                       if world_db["ThingActions"][id]["TA_NAME"] == "wait"][0]
     if get_dir_to_target(t, "f"):
@@ -1387,6 +1389,7 @@ def ai(t):
 
 def turn_over():
     """Run game world and its inhabitants until new player input expected."""
+    # 7DRL: effort of move action is TA_EFFORT / sqrt(TT_LIFEPOINTS)
     id = 0
     whilebreaker = False
     while world_db["Things"][0]["T_LIFEPOINTS"]:
@@ -1415,7 +1418,14 @@ def turn_over():
                     taid = [a for a in world_db["ThingActions"]
                               if a == Thing["T_COMMAND"]][0]
                     ThingAction = world_db["ThingActions"][taid]
-                    if Thing["T_PROGRESS"] == ThingAction["TA_EFFORT"]:
+                    #if Thing["T_PROGRESS"] == ThingAction["TA_EFFORT"]:
+                    effort = ThingAction["TA_EFFORT"]  # #
+                    if ThingAction["TA_NAME"] == "move":  # #
+                        type = Thing["T_TYPE"]  # #
+                        max_hp = (world_db["ThingTypes"][type]  # #
+                                 ["TT_LIFEPOINTS"])  # #
+                        effort = int(effort / math.sqrt(max_hp))  # #
+                    if Thing["T_PROGRESS"] == effort:  # #
                         eval("actor_" + ThingAction["TA_NAME"])(Thing)
                         Thing["T_COMMAND"] = 0
                         Thing["T_PROGRESS"] = 0