[CF-Devel] CVS update: crossfire/common
Crossfire CVS devel
mwedel at scruznet.com
Wed Aug 2 01:04:50 CDT 2000
Date: Tuesday August 1, 2000 @ 23:04
Author: cvs
Update of /home/cvs/CVS/crossfire/common
In directory boltzmann.eecs.berkeley.edu:/tmp/cvs-serv32470/common
Modified Files:
init.c living.c
Log Message:
include/config.h, include/global.h, common/init.c, common/living.c,
server/init.c, server/player.c, server/skill_util.c: Add permanent
experience and balanced stat loss features (code by Garth Denley).
Permanent experience make some experience in the skills permanent. Balance
stat loss makes stat loss less likely/costly at low level and more costly
at higher levels. These features are by default off, but can be turned
on either in the config.h file or via command line options. Code checked
in by MSW 8/1/2000
****************************************
Index: crossfire/common/init.c
diff -u crossfire/common/init.c:1.3 crossfire/common/init.c:1.4
--- crossfire/common/init.c:1.3 Sun May 21 14:41:45 2000
+++ crossfire/common/init.c Tue Aug 1 23:04:50 2000
@@ -1,11 +1,12 @@
/*
* static char *rcsid_init_c =
- * "$Id: init.c,v 1.3 2000/05/21 21:41:45 jec Exp $";
+ * "$Id: init.c,v 1.4 2000/08/02 06:04:50 cvs Exp $";
*/
/*
CrossFire, A Multiplayer game for X-windows
+ Copyright (C) 2000 Mark Wedel
Copyright (C) 1992 Frank Tore Johansen
This program is free software; you can redistribute it and/or modify
@@ -22,7 +23,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- The author can be reached via e-mail to
frankj at ifi.uio.no.
+ The author can be reached via e-mail to
mwedel at scruz.net
*/
#define EXTERN
@@ -51,6 +52,8 @@
PLAYERDIR, MAPDIR, ARCHETYPES,TREASURES,
UNIQUE_DIR, TMPDIR,
STAT_LOSS_ON_DEATH,
+USE_PERMANENT_EXPERIENCE,
+BALANCED_STAT_LOSS,
SIMPLE_EXP
};
Index: crossfire/common/living.c
diff -u crossfire/common/living.c:1.8 crossfire/common/living.c:1.9
--- crossfire/common/living.c:1.8 Mon Jun 19 05:23:11 2000
+++ crossfire/common/living.c Tue Aug 1 23:04:50 2000
@@ -1,6 +1,6 @@
/*
* static char *rcsid_living_c =
- * "$Id: living.c,v 1.8 2000/06/19 12:23:11 jec Exp $";
+ * "$Id: living.c,v 1.9 2000/08/02 06:04:50 cvs Exp $";
*/
/*
@@ -29,7 +29,6 @@
#include <global.h>
#include <funcpoint.h>
-
static int con_bonus[MAX_STAT + 1]={
-6,-5,-4,-3,-2,-1,-1,0,0,0,0,1,2,3,4,5,6,7,8,9,10,12,14,16,18,20,
22,25,30,40,50
@@ -1588,10 +1587,59 @@
/* adjust_exp() - make sure that we don't exceed max or min set on
* experience
*/
-
+
int adjust_exp(object *op, int exp) {
int max_exp = MAX_EXPERIENCE;
+ if (settings.use_permanent_experience) {
+ /* Permanent experience code. Blame me if any problems. :) */
+ /* This code _only_ affects experience objects. */
+ /* GD */
+ if (op->type == EXPERIENCE) {
+ int p_exp_min;
+ int p_exp_gain;
+ int max_loss;
+
+ /* The following fields are used: */
+ /* stats.exp: Current exp in experience object. */
+ /* last_heal: Permanent experience earnt. */
+
+ /* Ensure that our permanent experience minimum is met. */
+ p_exp_min = (int)(PERM_EXP_MINIMUM_RATIO * (float)(op->stats.exp));
+ /*LOG(llevError, "Experience minimum check: %d p-min %d p-curr %d curr.\n", p_exp_min, op->last_heal, op->stats.exp);*/
+ if (op->last_heal < p_exp_min)
+ op->last_heal = p_exp_min;
+
+ /* Experience gain: We get a ratio of the gain as permanent experience. */
+ if (exp > 0) {
+ p_exp_gain = (int)(PERM_EXP_GAIN_RATIO * exp);
+ op->last_heal += p_exp_gain;
+ /* Cap permanent experience. */
+ if (op->last_heal > MAX_EXP_IN_OBJ)
+ op->last_heal = MAX_EXP_IN_OBJ;
+ /*LOG(llevError, "Gaining %d experience results in %d permanent exp (now %d).\n", exp, p_exp_gain, op->last_heal); */
+ }
+
+ /* Experience loss: Our permanent experience affects this. */
+ if (exp < 0) {
+ /*LOG(llevError, "Experience loss of %d from %d (%d perm).\n",
+ -exp, op->stats.exp, op->last_heal); */
+ if (op->stats.exp <= op->last_heal) {
+ /* Cripes. Less experience than permanent experience.
+ No experience loss. */
+ max_loss = 0;
+ exp = 0;
+ } else {
+ /* Max loss is a ratio of temporary experience (curr-perm). */
+ max_loss = (int)(PERM_EXP_MAX_LOSS_RATIO * (float)(op->stats.exp - op->last_heal));
+ if (exp < -max_loss)
+ exp = -max_loss;
+ }
+ /* LOG(llevError, "Decided on a loss of %d.\n", -exp); */
+ }
+ }
+ }
+
op->stats.exp += exp;
if(op->stats.exp < 0) {
exp -= op->stats.exp;
More information about the crossfire
mailing list