--- deliantra/server/common/living.C 2008/12/04 01:07:34 1.91
+++ deliantra/server/common/living.C 2009/11/09 18:47:55 1.101
@@ -5,18 +5,19 @@
* 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
*/
@@ -596,7 +597,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");
@@ -626,7 +627,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
@@ -860,10 +861,7 @@
if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION)
continue;
- /* See note in map.c:update_position about making this additive
- * since light sources are never applied, need to put check here.
- */
- glow_radius = max (glow_radius, tmp->glow_radius);
+ glow_radius += tmp->glow_radius;
/* For some things, we don't care what is equipped */
if (tmp->type == SKILL)
@@ -1139,10 +1137,10 @@
}
if (tmp->stats.wc)
- wc -= (tmp->stats.wc + tmp->magic);
+ wc -= tmp->stats.wc + tmp->magic;
if (tmp->stats.ac)
- ac -= (tmp->stats.ac + tmp->magic);
+ ac -= tmp->stats.ac + tmp->magic;
if (ARMOUR_SPEED (tmp))
max_speed = min (max_speed, ARMOUR_SPEED (tmp) / 10.f);
@@ -1151,7 +1149,8 @@
} /* switch tmp->type */
} /* item is equipped */
} /* for loop of items */
- fprintf (stderr, "gr %s %d\n", &name, glow_radius);//D
+
+ glow_radius = min (glow_radius, MAX_LIGHT_RADIUS);
/* We've gone through all the objects the player has equipped. For many things, we
* have generated intermediate values which we now need to assign.
@@ -1331,9 +1330,6 @@
if (settings.search_items && contr->search_str[0])
speed -= 1;
-
- if (attacktype == 0)
- attacktype = arch->attacktype;
} /* End if player */
if (added_speed >= 0)
@@ -1411,17 +1407,30 @@
/* 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)
map->at (x, y).flags_ = 0;
}
+void
+object::set_glow_radius (sint8 rad)
+{
+ glow_radius = rad;
+
+ if (is_on_map ())
+ update_all_los (map, x, y);
+ else if (object *env = outer_env ())
+ {
+ env->update_stats ();
+
+ if (env->is_on_map ())
+ update_all_los (env->map, env->x, env->y);
+ }
+}
+
/*
* Returns true if the given player is a legal class.
* The function to add and remove class-bonuses to the stats doesn't
@@ -1493,7 +1502,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 */
@@ -1642,12 +1651,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
}
/*
@@ -1772,28 +1776,32 @@
}
/* This function checks to make sure that object 'op' can
- * lost 'exp' experience. It returns the amount of exp
+ * lose 'exp' experience. It returns the amount of exp
* object 'op' can in fact lose - it basically makes
* adjustments based on permanent exp and the like.
* This function should always be used for losing experience -
* 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;
if (exp > op->stats.exp)
exp = op->stats.exp;
+
if (settings.permanent_exp_ratio)
{
del_exp = (sint64) ((op->stats.exp - op->perm_exp) * PERM_EXP_MAX_LOSS_RATIO);
+
if (del_exp < 0)
del_exp = 0;
+
if (exp > del_exp)
exp = del_exp;
}
+
return exp;
}
@@ -1803,7 +1811,7 @@
if (exp < 0)
return check_exp_loss (op, exp);
else
- return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp);
+ return min (exp, (sint64)MAX_EXPERIENCE - op->stats.exp);
}
/* Subtracts experience from player.
@@ -1926,17 +1934,15 @@
void
apply_death_exp_penalty (object *op)
{
- object *tmp;
sint64 loss;
sint64 percentage_loss; /* defined by the setting 'death_penalty_percent' */
sint64 level_loss; /* defined by the setting 'death_penalty_levels */
- for (tmp = op->inv; tmp; tmp = tmp->below)
+ for (object *tmp = op->inv; tmp; tmp = tmp->below)
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
@@ -1946,18 +1952,19 @@
if (level_loss < 0)
level_loss = 0;
- loss = check_exp_loss (tmp, MIN (level_loss, percentage_loss));
+ loss = check_exp_loss (tmp, min (level_loss, percentage_loss));
tmp->stats.exp -= loss;
player_lvl_adj (op, tmp);
}
percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100;
- level_loss = op->stats.exp - levels[MAX (0, op->level - settings.death_penalty_level)];
+ level_loss = op->stats.exp - levels[max (0, op->level - settings.death_penalty_level)];
if (level_loss < 0)
level_loss = 0;
- loss = check_exp_loss (op, MIN (level_loss, percentage_loss));
+
+ loss = check_exp_loss (op, min (level_loss, percentage_loss));
op->stats.exp -= loss;
player_lvl_adj (op, NULL);