From: Christian Heller Date: Mon, 7 Mar 2016 00:03:57 +0000 (+0100) Subject: TCE: Add basic crawl eating. X-Git-Tag: tce~77 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/calendar_export?a=commitdiff_plain;h=ac0bce5e77cccd797405f9c54c7b3799a2a4d252;p=plomrogue TCE: Add basic crawl eating. --- diff --git a/confserver/TheCrawlingEater b/confserver/TheCrawlingEater index a9b5e95..74ff231 100644 --- a/confserver/TheCrawlingEater +++ b/confserver/TheCrawlingEater @@ -1,9 +1,15 @@ +PLUGIN TheCrawlingEater + MAP_LENGTH 64 PLAYER_TYPE 0 TA_ID 1 TA_NAME wait +TA_ID 2 +TA_EFFORT 5 +TA_NAME move + TT_ID 0 TT_START_NUMBER 1 TT_LIFEPOINTS 30 diff --git a/plugins/server/TheCrawlingEater.py b/plugins/server/TheCrawlingEater.py new file mode 100644 index 0000000..71eb14e --- /dev/null +++ b/plugins/server/TheCrawlingEater.py @@ -0,0 +1,57 @@ +# This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3 +# or any later version. For details on its copyright, license, and warranties, +# see the file NOTICE in the root directory of the PlomRogue source package. + + +from server.config.world_data import world_db + + +def make_map(): + from server.make_map import new_pos, is_neighbor + from server.utils import rand + world_db["MAP"] = bytearray(b'X' * (world_db["MAP_LENGTH"] ** 2)) + length = world_db["MAP_LENGTH"] + add_half_width = (not (length % 2)) * int(length / 2) + world_db["MAP"][int((length ** 2) / 2) + add_half_width] = ord("#") + while (1): + y, x, pos = new_pos() + if "X" == chr(world_db["MAP"][pos]) and is_neighbor((y, x), "#"): + if y == 0 or y == (length - 1) or x == 0 or x == (length - 1): + break + world_db["MAP"][pos] = ord("#") + n_trees = int((length ** 2) / 16) + i_trees = 0 + while (i_trees <= n_trees): + single_allowed = rand.next() % 32 + y, x, pos = new_pos() + if "#" == chr(world_db["MAP"][pos]) \ + and ((not single_allowed) or is_neighbor((y, x), ".")): + world_db["MAP"][pos] = ord(".") + i_trees += 1 + + +def actor_move_attempts_hook(t, move_result, pos): + from server.utils import rand + if ord("#") == world_db["MAP"][pos] and 0 == int(rand.next() % 5): + world_db["MAP"][pos] = ord(".") + return True + return False + + +def play_move_attempt_hook(t, direction, pos): + if ord("#") == world_db["MAP"][pos]: + log("You bite.") + world_db["Things"][0]["T_ARGUMENT"] = direction + set_command("move") + return True + return False + + +import server.config.actions +server.config.actions.actor_move_attempts_hook = actor_move_attempts_hook +import server.config.commands +server.config.commands.play_move_attempt_hook = play_move_attempt_hook +import server.config.world_data +server.config.world_data.symbols_hide += "#" +import server.config.make_world_helpers +server.config.make_world_helpers.make_map = make_map