X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=plugins%2Fserver%2FTheCrawlingEater.py;h=867f05c0f3b7f5cb940e9fb63f06e3acdb86caaf;hb=fa6fec4689b183dc3a4c1528ced578e4fcd6348c;hp=1c7a76dace33613d51a2e1c3349de1e9ae508c14;hpb=5205756191b1305684a5005f3940e49d1b6caafa;p=plomrogue diff --git a/plugins/server/TheCrawlingEater.py b/plugins/server/TheCrawlingEater.py index 1c7a76d..867f05c 100644 --- a/plugins/server/TheCrawlingEater.py +++ b/plugins/server/TheCrawlingEater.py @@ -127,16 +127,20 @@ def actor_move(t): t["T_POSY"] = move_result[1] t["T_POSX"] = move_result[2] t["pos"] = move_result[1] * world_db["MAP_LENGTH"] + move_result[2] + if world_db["MAP"][t["pos"]] == ord("-"): + world_db["die"](t, "You FALL in a hole, and die.") + return build_fov_map(t) else: - if t["T_BOWEL"] >= 32 or chr(world_db["MAP"][pos]) == "5": + height = world_db["MAP"][pos] - ord("0") + if t["T_BOWEL"] >= 32 or height == 5: return eaten = False - if chr(world_db["MAP"][pos]) == "3" and 0 == int(rand.next() % 2): - t["T_BOWEL"] += 3 + if height == 3 and 0 == int(rand.next() % 2): + t["T_BOWEL"] += height eaten = True - elif chr(world_db["MAP"][pos]) == "4" and 0 == int(rand.next() % 5): - t["T_BOWEL"] += 4 + elif height == 4 and 0 == int(rand.next() % 5): + t["T_BOWEL"] += height eaten = True log("You EAT.") if eaten: @@ -149,15 +153,20 @@ def actor_move(t): def catch_air(t): if (world_db["wetmap"][t["pos"]] - ord("0")) \ + (world_db["MAP"][t["pos"]] - ord("0")) > 4: - t["T_LIFEPOINTS"] = 0 - if t == world_db["Things"][0]: - t["fovmap"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2)) - log("You SUFFOCATE.") + world_db["die"](t, "You SUFFOCATE") return False return True world_db["catch_air"] = catch_air +def die(t, message): + t["T_LIFEPOINTS"] = 0 + if t == world_db["Things"][0]: + t["fovmap"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2)) + log(message) +world_db["die"] = die + + def make_map(): from server.make_map import new_pos, is_neighbor from server.utils import rand @@ -197,11 +206,8 @@ def calc_effort(ta, t): t["T_POSY"], t["T_POSX"]) if 1 == move_result[0]: pos = (move_result[1] * world_db["MAP_LENGTH"]) + move_result[2] - terrain = chr(world_db["MAP"][pos]) - if terrain == "1": - return 2 - elif terrain == "2": - return 4 + narrowness = world_db["MAP"][pos] - ord("0") + return 2 ** narrowness return 1 world_db["calc_effort"] = calc_effort @@ -243,16 +249,22 @@ def turn_over(): action_db["actor_pee"](Thing) water = 0 positions_to_wet = [] - for i in range(world_db["MAP_LENGTH"] ** 2): - if world_db["MAP"][i] == ord("0") \ - and world_db["wetmap"][i] < ord("5"): - positions_to_wet += [i] + for pos in range(world_db["MAP_LENGTH"] ** 2): + if world_db["MAP"][pos] == ord("0") \ + and world_db["wetmap"][pos] < ord("5"): + positions_to_wet += [pos] i_positions_to_wet = len(positions_to_wet) for pos in range(world_db["MAP_LENGTH"] ** 2): - if 0 == rand.next() % 5 \ - and ((world_db["wetmap"][pos] > ord("0") - and not world_db["MAP"][pos] == ord("0")) - or world_db["wetmap"][pos] > ord("1")): + wetness = world_db["wetmap"][pos] - ord("0") + height = world_db["MAP"][pos] - ord("0") + if height == 0 and wetness > 0 \ + and 0 == rand.next() % ((2 ** 16) / (2 ** wetness)): + world_db["MAP"][pos] = ord("-") + if pos in positions_to_wet: + positions_to_wet.remove(pos) + i_positions_to_wet -= 1 + if ((wetness > 0 and height != 0) or wetness > 1) \ + and 0 == rand.next() % 5: world_db["wetmap"][pos] -= 1 water += 1 i_positions_to_wet -= 1 @@ -342,7 +354,7 @@ io_db["worldstate_write_order"] += [["T_BLADDER", "player_int"]] io_db["worldstate_write_order"] += [[write_wetmap, "func"]] import server.config.world_data server.config.world_data.symbols_hide = "345" -server.config.world_data.symbols_passable = "012" +server.config.world_data.symbols_passable = "012-" server.config.world_data.thing_defaults["T_BOWEL"] = 0 server.config.world_data.thing_defaults["T_BLADDER"] = 0 world_db["wetmap"] = bytearray(b"0" * world_db["MAP_LENGTH"] ** 2)