X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=roguelike-server;h=28f90781cc9c759cf471739d64c28bdd8c93ca15;hb=6187315aace9959a16bdc62c4585ccf0c1cf2eac;hp=09940395b36e39d222f46f17abd850016d3bc231;hpb=cc35c3b1cd47f927003b14b565fe910a56640309;p=plomrogue diff --git a/roguelike-server b/roguelike-server index 0994039..28f9078 100755 --- a/roguelike-server +++ b/roguelike-server @@ -12,6 +12,7 @@ import shlex import shutil import time import ctypes +import math class RandomnessIO: @@ -763,14 +764,15 @@ def try_healing(t): def hunger(t): """Decrement t's satiation,dependent on it trigger lifepoint dec chance.""" if t["T_SATIATION"] > -32768: - t["T_SATIATION"] -= 1 - testbase = t["T_SATIATION"] if t["T_SATIATION"] >= 0 else -t["T_SATIATION"] - if not world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"]: - raise RuntimeError("A thing that should not hunger is hungering.") - stomach = int(32767 / world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"]) - if int(int(testbase / stomach) / ((rand.next() % stomach) + 1)): + max_hp = world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"] + t["T_SATIATION"] -= int(math.sqrt(max_hp)) + if 0 != t["T_SATIATION"] and 0 == int(rand.next() / abs(t["T_SATIATION"])): if t == world_db["Things"][0]: - strong_write(io_db["file_out"], "LOG You suffer from hunger.\n") + if t["T_SATIATION"] < 0: + strong_write(io_db["file_out"], "LOG You suffer from hunger.\n") + else: + strong_write(io_db["file_out"], + "LOG You suffer from over-eating.\n") decrement_lifepoints(t)