From: Christian Heller Date: Sun, 15 Feb 2015 04:37:03 +0000 (+0100) Subject: Server: Add regeneration of lifepoints on positive satiation values. X-Git-Tag: tce~535 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/balance?a=commitdiff_plain;h=f86e20aec4f9c6f07322954569a72221d7dc11e9;p=plomrogue Server: Add regeneration of lifepoints on positive satiation values. --- diff --git a/SERVER_COMMANDS b/SERVER_COMMANDS index 3036c04..90877ba 100644 --- a/SERVER_COMMANDS +++ b/SERVER_COMMANDS @@ -166,7 +166,10 @@ T_LIFEPOINTS [0 to 255] 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 @@ -203,8 +206,8 @@ Set selected thing type's initial lifepoints value to argument. Things of 0 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.) diff --git a/src/server/run.c b/src/server/run.c index 212a37e..11735d0 100644 --- a/src/server/run.c +++ b/src/server/run.c @@ -30,7 +30,7 @@ #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() */ @@ -335,6 +335,7 @@ static void turn_over() } ai(thing); } + try_healing(thing); thing->progress++; struct ThingAction * ta = get_thing_action(thing->command); if (thing->progress == ta->effort) diff --git a/src/server/thing_actions.c b/src/server/thing_actions.c index dea2332..2a682c2 100644 --- a/src/server/thing_actions.c +++ b/src/server/thing_actions.c @@ -330,6 +330,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) diff --git a/src/server/thing_actions.h b/src/server/thing_actions.h index ebdd871..97ab3cc 100644 --- a/src/server/thing_actions.h +++ b/src/server/thing_actions.h @@ -38,6 +38,12 @@ extern void actor_pick(struct Thing * t); */ 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. */