From: Christian Heller Date: Tue, 8 Sep 2015 11:26:02 +0000 (+0200) Subject: Improve try_healing() chance. X-Git-Tag: tce~286 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/static/todos?a=commitdiff_plain;h=98a85951798545071ceafd9d43a18520465d21c5;p=plomrogue Improve try_healing() chance. --- diff --git a/SERVER_COMMANDS b/SERVER_COMMANDS index 0900b17..f030d29 100644 --- a/SERVER_COMMANDS +++ b/SERVER_COMMANDS @@ -170,12 +170,10 @@ T_LIFEPOINTS [0 to 255] Set selected thing's lifepoints to argument. T_SATIATION [-32768 to 32767] -Set selected thing's satiation score. If above zero, and thing's lifepoints are -below its thing type's initial lifepoints, there is a 1/32 chance each turn of -waiting action that the thing's lifepoints will rise. Each turn, there is a -chance of hitpoint loss that grows with the satiation score's absolute value. -Each turn, T_SATIATION lessens by the square root of the thing's type's start -hitpoints (see TT_LIFEPOINTS). +Set selected thing's satiation score. Each turn, there is a chance of hitpoint +loss that grows with the satiation score's absolute value, and one of hitpoint +gain that lowers with it. Each turn, T_SATIATION lessens by the square root of +the thing's type's start hitpoints (see TT_LIFEPOINTS). T_CARRIES [0 to infinity] Add thing of ID in argument to inventory of selected thing, if said thing is diff --git a/roguelike-server b/roguelike-server index 28f9078..462a342 100755 --- a/roguelike-server +++ b/roguelike-server @@ -744,22 +744,17 @@ def thingproliferation(t, prol_map): def try_healing(t): - """Grow t's HP to a 1/32 chance if < HP max, satiation > 0, and waiting. - - On success, decrease satiation score by 32. - """ - if t["T_SATIATION"] > 0 \ - and t["T_LIFEPOINTS"] < \ - world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"] \ - and 0 == (rand.next() % 31) \ - and t["T_COMMAND"] == [id for id in world_db["ThingActions"] - if world_db["ThingActions"][id]["TA_NAME"] == - "wait"][0]: - t["T_LIFEPOINTS"] += 1 - t["T_SATIATION"] -= 32 - if t == world_db["Things"][0]: - strong_write(io_db["file_out"], "LOG You heal.\n") - + """If t's HP < max, increment them if well-nourished, maybe waiting.""" + if t["T_LIFEPOINTS"] < \ + world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"]: + wait_id = [id for id in world_db["ThingActions"] + if world_db["ThingActions"][id]["TA_NAME"] == "wait"][0] + wait_divider = 8 if t["T_COMMAND"] == wait_id else 1 + testval = int(abs(t["T_SATIATION"]) / wait_divider) + if (testval <= 1 or 1 == (rand.next() % testval)): + t["T_LIFEPOINTS"] += 1 + if t == world_db["Things"][0]: + strong_write(io_db["file_out"], "LOG You heal.\n") def hunger(t): """Decrement t's satiation,dependent on it trigger lifepoint dec chance."""