X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=src%2Fserver%2Fthing_actions.c;h=6a8803d162483a6a3ac06c2fe46dfc05420be31d;hb=ad665ff6f22943c1f1982d13e1dbea1cedc97a65;hp=dea23323bcf6b7a9f2b43974b5af180720d55faa;hpb=93d0d862f86d99062a59ab8bdca21f2ffeaf838a;p=plomrogue
diff --git a/src/server/thing_actions.c b/src/server/thing_actions.c
index dea2332..6a8803d 100644
--- a/src/server/thing_actions.c
+++ b/src/server/thing_actions.c
@@ -270,11 +270,16 @@ extern void actor_pick(struct Thing * t)
{
struct Thing * picked = NULL;
struct Thing * t_i;
+ uint8_t highest_id = 0;
for (t_i = world.things; t_i; t_i = t_i->next)
{
if (t_i != t && t_i->pos.y == t->pos.y && t_i->pos.x == t->pos.x)
{
- picked = t_i;
+ if (t_i->id >= highest_id) /* With several Things to pick, */
+ { /* pick the one with the highest ID. */
+ highest_id = t_i->id;
+ picked = t_i;
+ }
}
}
if (picked)
@@ -319,7 +324,6 @@ extern void actor_use(struct Thing * t)
}
t->satiation = t->satiation + tt->consumable > INT16_MAX ?
INT16_MAX : t->satiation + tt->consumable;
- t->lifepoints = t->lifepoints + tt->consumable;
}
}
if (t == get_player())
@@ -330,6 +334,34 @@ extern void actor_use(struct Thing * t)
+extern void try_healing(struct Thing * t)
+{
+ struct ThingType * tt = get_thing_type(t->type);
+ if ( t->satiation > 0 && t->lifepoints < tt->lifepoints
+ && 0 == (rrand() % 31)
+ && get_thing_action_id_by_name(s[S_CMD_WAIT]) == t->command)
+ {
+ t->lifepoints++;
+ t->satiation = t->satiation - 32;
+ if (get_player() == t)
+ {
+ update_log("You heal.");
+ }
+ else
+ {
+ char * msg_part = " heals.";
+ uint8_t len = strlen(tt->name) + strlen(msg_part) + 1;
+ char * msg = try_malloc(len, __func__);
+ int test = sprintf(msg, "%s%s", tt->name, msg_part);
+ exit_trouble(test < 0, __func__, s[S_FCN_SPRINTF]);
+ update_log(msg);
+ free(msg);
+ }
+ }
+}
+
+
+
extern void hunger(struct Thing * t)
{
if (t->satiation > INT16_MIN)