|
From: <cro...@li...> - 2005-03-22 21:45:09
|
Module Name: crossfire
Committed By: akirschbaum
Date: Tue Mar 22 21:44:44 UTC 2005
Modified Files:
crossfire: ChangeLog
crossfire/common: living.c
Log Message:
common/living.c: Allow luck to drop back to zero. Limit bad luck object to
+/-100 to prevent overflows.
Start of context diffs
Index: crossfire/ChangeLog
diff -c crossfire/ChangeLog:1.264 crossfire/ChangeLog:1.265
*** crossfire/ChangeLog:1.264 Sun Mar 20 08:32:55 2005
--- crossfire/ChangeLog Tue Mar 22 13:44:36 2005
***************
*** 17,22 ****
--- 17,26 ----
------------------------------------------------------------------------------
Changes for CVS:
+ common/living.c: Allow luck to drop back to zero. Limit bad luck object to
+ +/-100 to prevent overflows.
+ Andreas Kirschbaum 2005-03-22
+
common/living.c: When randomly adjusting luck, change both op->stats.luck and
the applied bad_luck object.
server/attack.c: Do not decrease luck if a player kills himself with a spell
Index: crossfire/common/living.c
diff -c crossfire/common/living.c:1.66 crossfire/common/living.c:1.67
*** crossfire/common/living.c:1.66 Sun Mar 20 08:32:55 2005
--- crossfire/common/living.c Tue Mar 22 13:44:43 2005
***************
*** 1,6 ****
/*
* static char *rcsid_living_c =
! * "$Id: living.c,v 1.66 2005/03/20 16:32:55 akirschbaum Exp $";
*/
/*
--- 1,6 ----
/*
* static char *rcsid_living_c =
! * "$Id: living.c,v 1.67 2005/03/22 21:44:43 akirschbaum Exp $";
*/
/*
***************
*** 676,681 ****
--- 676,683 ----
void change_luck(object *op, int value) {
object *tmp;
archetype *at;
+ int new_luck;
+
at = find_archetype("luck");
if (!at)
LOG(llevError, "Couldn't find archetype luck.\n");
***************
*** 689,710 ****
SET_FLAG(tmp,FLAG_APPLIED);
}
if (value) {
op->stats.luck+=value;
! tmp->stats.luck+=value;
} else {
if (!tmp->stats.luck) {
- LOG(llevDebug, "Internal error in change_luck().\n");
return;
}
/* Randomly change the players luck. Basically, we move it
* back neutral (if greater>0, subtract, otherwise add)
- * I believe this is supposed to be > and not >= - this means
- * if your luck is -1/1, it won't get adjusted - only when your
- * luck is worse can you hope for improvment.
- * note that if we adjusted it with it is -1/1, that check above
- * for 0 luck will happen, resulting in error.
*/
! if (RANDOM()%(FABS(tmp->stats.luck)) > RANDOM()%30) {
int diff = tmp->stats.luck>0?-1:1;
op->stats.luck += diff;
tmp->stats.luck += diff;
--- 691,713 ----
SET_FLAG(tmp,FLAG_APPLIED);
}
if (value) {
+ /* Limit the luck value of the bad luck object to +/-100. This
+ * (arbitrary) value prevents overflows (both in the bad luck object and
+ * in op itself).
+ */
+ new_luck = tmp->stats.luck+value;
+ if (new_luck >= -100 && new_luck <= 100) {
op->stats.luck+=value;
! tmp->stats.luck = new_luck;
! }
} else {
if (!tmp->stats.luck) {
return;
}
/* Randomly change the players luck. Basically, we move it
* back neutral (if greater>0, subtract, otherwise add)
*/
! if (RANDOM()%(FABS(tmp->stats.luck)) >= RANDOM()%30) {
int diff = tmp->stats.luck>0?-1:1;
op->stats.luck += diff;
tmp->stats.luck += diff;
|