Set selected thing's lifepoints to argument.
T_SATIATION [-32768 to 32767]
-Set selected thing's satiation score.
+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. For values affecting the
+thing's lifepoints negatively, see note on TT_LIFEPOINTS.
T_CARRIES [0 to 255]
Add thing of ID in argument to inventory of selected thing, if said thing is
lifepoints are considered inanimate, otherwise animate. This value also sets the
degree to which the selected type's things suffer from under- or over-satiation:
If 0, not at all. Else, it defines a stomach size value of 32767 divided by it.
-Each turn a thing of the given tpe may then suffer a lifepoint decrement to the
-change of the rounded down quotient of its satiation score's absolute value by
+Each turn a thing of the given type may then suffer a lifepoint decrement to the
+chance of the rounded down quotient of its satiation score's absolute value by
its stomach size value, then again divided by the latter. (This means that the
change is always zero when the absolute value of the satiation score is lower
than the stomach size value.)
#include "god_commands.h" /* parse_god_command_(1|2|3)arg() */
#include "hardcoded_strings.h" /* s */
#include "io.h" /* io_round(), save_world() */
-#include "thing_actions.h" /* hunger() */
+#include "thing_actions.h" /* hunger(), try_healing() */
#include "things.h" /* Thing, ThingType, ThingInMemory, get_player(),
* get_thing_action_id_by_name(), try_thing_proliferation()
*/
}
ai(thing);
}
+ try_healing(thing);
thing->progress++;
struct ThingAction * ta = get_thing_action(thing->command);
if (thing->progress == ta->effort)
+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)
*/
extern void actor_use(struct Thing * t);
+/* Increment "t"'s lifepoints to a 1/32 chance if its .satiation is positive,
+ * its lifepoints are below "t"'s type's .lifepoints, and "t"'s .command is the
+ * ID of the waiting action. On success, also decrement .satiation by by 32.
+ */
+extern void try_healing(struct Thing * t);
+
/* Decrement "t"'s satiation and trigger a chance (dependent on over-/under-
* satiation value) of lifepoint decrement.
*/