--- deliantra/server/common/exp.C 2007/05/28 21:21:40 1.15
+++ deliantra/server/common/exp.C 2009/11/29 09:41:27 1.25
@@ -1,25 +1,25 @@
/*
- * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
+ * This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
+ * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
- * Crossfire TRT is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * Deliantra is free software: you can redistribute it and/or modify it under
+ * the terms of the Affero GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * You should have received a copy of the Affero GNU General Public License
+ * and the GNU General Public License along with this program. If not, see
+ * .
*
- * The authors can be reached via e-mail to
+ * The authors can be reached via e-mail to
*/
#include
@@ -27,7 +27,7 @@
sint64 *levels;
-float exp_att_mult[NROFATTACKS + 2] = {
+static float exp_att_mult[NROFATTACKS + 2] = {
0.0, /* AT_PHYSICAL */
0.0, /* AT_MAGIC */
0.0, /* AT_FIRE */
@@ -50,7 +50,7 @@
0.0 /* AT_COUNTERSPELL */
};
-float exp_prot_mult[NROFATTACKS + 2] = {
+static float exp_prot_mult[NROFATTACKS + 2] = {
0.4, /* AT_PHYSICAL */
0.5, /* AT_MAGIC */
0.1, /* AT_FIRE */
@@ -74,6 +74,20 @@
};
/*
+ * Returns true if the monster specified has any innate abilities.
+ */
+static int
+has_ability (const object *ob)
+{
+ object *tmp;
+
+ for (tmp = ob->inv; tmp != NULL; tmp = tmp->below)
+ if (tmp->type == SPELL || tmp->type == SPELLBOOK)
+ return true;
+ return false;
+}
+
+/*
* new_exp() is an alternative way to calculate experience based
* on the ability of a monster.
* It's far from perfect, and doesn't consider everything which
@@ -100,6 +114,7 @@
*/
prot_mult += (exp_prot_mult[i] * 200 * ob->resist[i]) / 100.0;
}
+
spec_mult += (0.3 * (QUERY_FLAG (ob, FLAG_SEE_INVISIBLE) != 0)) +
(0.5 * (QUERY_FLAG (ob, FLAG_SPLITTING) != 0)) +
(0.3 * (QUERY_FLAG (ob, FLAG_HITBACK) != 0)) +
@@ -114,27 +129,12 @@
exp *= (QUERY_FLAG (ob, FLAG_CAST_SPELL) && has_ability (ob)) ? (40 + (ob->stats.maxsp > 80 ? 80 : ob->stats.maxsp)) / 40 : 1;
exp *= (80.0 / (70.0 + ob->stats.wc)) * (80.0 / (70.0 + ob->stats.ac)) * (50.0 + ob->stats.dam) / 50.0;
exp *= att_mult * prot_mult * spec_mult;
- exp *= 2.0 / (2.0 - ((fabs (ob->speed) < 0.95) ? fabs (ob->speed) : 0.95));
+ exp *= 2.0 / (2.0 - min (ob->speed, 0.95));
exp *= (20.0 + ob->stats.Con) / 20.0;
if (QUERY_FLAG (ob, FLAG_STAND_STILL))
exp /= 2;
- return (int) exp;
-}
-
-/*
- * Returns true if the monster specified has any innate abilities.
- */
-
-int
-has_ability (const object *ob)
-{
- object *tmp;
-
- for (tmp = ob->inv; tmp != NULL; tmp = tmp->below)
- if (tmp->type == SPELL || tmp->type == SPELLBOOK)
- return true;
- return false;
+ return exp;
}
/* This loads the experience table from the exp_table
@@ -144,14 +144,13 @@
* state.
*/
void
-init_experience (void)
+init_experience ()
{
char buf[MAX_BUF], *cp;
int lastlevel = 0, comp;
sint64 lastexp = -1, tmpexp;
FILE *fp;
-
sprintf (buf, "%s/exp_table", settings.confdir);
if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
@@ -232,18 +231,3 @@
}
}
-/* Dump the table - useful in terms of debugging to make sure the
- * format of the exp_table is correct.
- */
-
-void
-dump_experience ()
-{
- int i;
-
- for (i = 1; i <= settings.max_level; i++)
- {
- fprintf (logfile, "%4d %20lld\n", i, (long long) levels[i]);
- }
- exit (0);
-}