--- deliantra/server/common/living.C 2009/01/12 00:17:22 1.96
+++ deliantra/server/common/living.C 2010/03/26 00:05:45 1.107
@@ -1,22 +1,23 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
- * Deliantra 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 3 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.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * 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
*/
@@ -263,7 +264,7 @@
* function since some of the values passed to new_draw_info are hardcoded.
*/
#define DIFF_MSG(flag, msg1, msg2) \
- new_draw_info(NDI_UNIQUE, 0, op, (flag>0)?msg1:msg2);
+ new_draw_info (NDI_UNIQUE, 0, op, (flag > 0) ? msg1 : msg2);
/* return 1 if we sucessfully changed a stat, 0 if nothing was changed. */
@@ -416,9 +417,6 @@
if (tmp->move_type & MOVE_SWIM)
DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming");
-
- /* Changing move status may mean you are affected by things you weren't before */
- check_move_on (op, op);
}
/* becoming UNDEAD... a special treatment for this flag. Only those not
@@ -596,7 +594,7 @@
object *tmp;
archetype *at;
- at = archetype::find (ARCH_DEPLETION);
+ at = archetype::find (shstr_depletion);
if (!at)
{
LOG (llevError, "Couldn't find archetype depletion.\n");
@@ -608,7 +606,7 @@
if (!tmp)
{
- tmp = arch_to_object (at);
+ tmp = at->instance ();
tmp = insert_ob_in_ob (tmp, this);
SET_FLAG (tmp, FLAG_APPLIED);
}
@@ -626,7 +624,7 @@
void
object::change_luck (int value)
{
- archetype *at = archetype::find ("luck");
+ archetype *at = archetype::find (shstr_luck);
if (!at)
LOG (llevError, "Couldn't find archetype luck.\n");
else
@@ -638,7 +636,7 @@
if (!value)
return;
- tmp = arch_to_object (at);
+ tmp = at->instance ();
tmp = insert_ob_in_ob (tmp, this);
SET_FLAG (tmp, FLAG_APPLIED);
}
@@ -765,9 +763,13 @@
float old_speed = speed;
int stat_sum [NUM_STATS];
+ MoveType move_type; // we use change_move_type to change it, so use a local copy
+
/* First task is to clear all the values back to their original values */
if (type == PLAYER)
{
+ contr->delayed_update = false;
+
for (int i = 0; i < NUM_STATS; i++)
stat_sum [i] = contr->orig_stats.stat (i);
@@ -910,7 +912,7 @@
continue;
for (int i = 0; i < NUM_STATS; i++)
- stat_sum [i] = stat_sum [i] + tmp->stats.stat (i);
+ stat_sum [i] += tmp->stats.stat (i);
if (digest_types [tmp->type])
{
@@ -1173,18 +1175,16 @@
{
// clamp various player stats
for (int i = 0; i < NUM_STATS; ++i)
- stats.stat (i) = clamp (stat_sum [i], MIN_STAT, MAX_STAT);
+ stats.stat (i) = stat_sum [i];
+
+ check_stat_bounds (&stats);
contr->digestion = clamp (contr->digestion, MIN_DIGESTION, MAX_DIGESTION);
/* Figure out the players sp/mana/hp totals. */
int pl_level;
- check_stat_bounds (&(stats));
- pl_level = level;
-
- if (pl_level < 1)
- pl_level = 1; /* safety, we should always get 1 levels worth of hp! */
+ pl_level = max (1, level); /* safety, we should always get 1 levels worth of hp! */
/* You basically get half a con bonus/level. But we do take into account rounding,
* so if your bonus is 7, you still get 7 worth of bonus every 2 levels.
@@ -1329,9 +1329,6 @@
if (settings.search_items && contr->search_str[0])
speed -= 1;
-
- if (attacktype == 0)
- attacktype = arch->attacktype;
} /* End if player */
if (added_speed >= 0)
@@ -1360,8 +1357,7 @@
/* Put a lower limit on speed. Note with this speed, you move once every
* 25 ticks or so. This amounts to once every 3 seconds of realtime.
*/
- if (speed < 0.04f && type == PLAYER)
- speed = 0.04f;
+ max_it (speed, is_player () ? MIN_PLAYER_SPEED : MIN_ACTIVE_SPEED);
if (speed != old_speed)
set_speed (speed);
@@ -1406,14 +1402,15 @@
else if (move_type & (MOVE_FLY_LOW | MOVE_FLY_HIGH))
move_type &= ~MOVE_WALK;
+ // now apply the new move_type
+ if (this->move_type != move_type)
+ change_move_type (move_type);
+
/* It is quite possible that a player's spell costing might have changed,
* so we will check that now.
*/
- if (type == PLAYER)
- {
- esrv_update_stats (contr);
- esrv_update_spells (contr);
- }
+ if (is_player ())
+ contr->update_spells ();
// update the mapspace, if we are on a map
if (!flag [FLAG_REMOVED] && map)
@@ -1507,7 +1504,7 @@
* an overall level. Here, the dragon might gain new abilities
* or change the ability-focus.
*/
-void
+static void
dragon_level_gain (object *who)
{
object *abil = NULL; /* pointer to dragon ability force */
@@ -1613,7 +1610,7 @@
op->level++;
- if (op && op == who && op->stats.exp > 1 && is_dragon_pl (who))
+ if (op && op == who && op->stats.exp > 1 && who->is_dragon ())
dragon_level_gain (who);
/* Only roll these if it is the player (who) that gained the level */
@@ -1656,12 +1653,7 @@
}
if (changed)
- {
- who->update_stats ();
- esrv_update_stats (who->contr);
- /* check if the spell data has changed */
- esrv_update_spells (who->contr);
- }
+ who->update_stats (); // should cause esrv_update_stats and esrv_update_spells
}
/*
@@ -1793,7 +1785,7 @@
* the 'exp' value passed should be positive - this is the
* amount that should get subtract from the player.
*/
-sint64
+static sint64
check_exp_loss (const object *op, sint64 exp)
{
sint64 del_exp;
@@ -1952,7 +1944,7 @@
if (tmp->type == SKILL && tmp->stats.exp)
{
percentage_loss = tmp->stats.exp * settings.death_penalty_ratio / 100;
- level_loss = tmp->stats.exp - levels[MAX (0, tmp->level - settings.death_penalty_level)];
+ level_loss = tmp->stats.exp - levels [max (0, tmp->level - settings.death_penalty_level)];
/* With the revised exp system, you can get cases where
* losing several levels would still require that you have more