--- deliantra/server/common/living.C 2007/05/13 15:13:57 1.56 +++ deliantra/server/common/living.C 2007/07/01 05:00:17 1.68 @@ -1,25 +1,24 @@ /* - * CrossFire, A Multiplayer game + * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. * - * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team - * Copyright (C) 2002 Mark Wedel & Crossfire Development Team - * Copyright (C) 1992 Frank Tore Johansen + * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992,2007 Frank Tore Johansen * - * This program is free software; you can redistribute it and/or modify + * 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 + * 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 + * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * The authors can be reached via e-mail at + * along with this program. If not, see . + * + * The authors can be reached via e-mail to */ #include @@ -313,8 +312,8 @@ */ if (nstat < 1 && i * flag < 0) nstat = 1; - else if (nstat > 20 + op->arch->clone.stats.stat (j)) - nstat = 20 + op->arch->clone.stats.stat (j); + else if (nstat > 20 + op->arch->stats.stat (j)) + nstat = 20 + op->arch->stats.stat (j); if (nstat != ostat) { @@ -424,7 +423,7 @@ /* becoming UNDEAD... a special treatment for this flag. Only those not * originally undead may change their status */ - if (!QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) + if (!QUERY_FLAG (op->arch, FLAG_UNDEAD)) if (QUERY_FLAG (op, FLAG_UNDEAD) != QUERY_FLAG (&refop, FLAG_UNDEAD)) { success = 1; @@ -435,7 +434,7 @@ } else { - op->race = op->arch->clone.race; + op->race = op->arch->race; new_draw_info (NDI_UNIQUE, 0, op, "Your lifeforce returns!"); } } @@ -687,7 +686,7 @@ { for (int i = 0; i < NUM_STATS; ++i) { - sint8 v = arch->clone.stats.stat (i); + sint8 v = arch->stats.stat (i); stats.stat (i) -= v; contr->orig_stats.stat (i) -= v; } @@ -701,7 +700,7 @@ { for (int i = 0; i < NUM_STATS; ++i) { - sint8 v = arch->clone.stats.stat (i); + sint8 v = arch->stats.stat (i); stats.stat (i) += v; contr->orig_stats.stat (i) += v; } @@ -762,23 +761,23 @@ CLEAR_FLAG (this, FLAG_STEALTH); CLEAR_FLAG (this, FLAG_BLIND); - if (!QUERY_FLAG (&arch->clone, FLAG_REFL_SPELL )) CLEAR_FLAG (this, FLAG_REFL_SPELL); - if (!QUERY_FLAG (&arch->clone, FLAG_REFL_MISSILE)) CLEAR_FLAG (this, FLAG_REFL_MISSILE); - if (!QUERY_FLAG (&arch->clone, FLAG_UNDEAD )) CLEAR_FLAG (this, FLAG_UNDEAD); - if (!QUERY_FLAG (&arch->clone, FLAG_SEE_IN_DARK )) CLEAR_FLAG (this, FLAG_SEE_IN_DARK); - - path_attuned = arch->clone.path_attuned; - path_repelled = arch->clone.path_repelled; - path_denied = arch->clone.path_denied; - glow_radius = arch->clone.glow_radius; - move_type = arch->clone.move_type; + if (!QUERY_FLAG (arch, FLAG_REFL_SPELL )) CLEAR_FLAG (this, FLAG_REFL_SPELL); + if (!QUERY_FLAG (arch, FLAG_REFL_MISSILE)) CLEAR_FLAG (this, FLAG_REFL_MISSILE); + if (!QUERY_FLAG (arch, FLAG_UNDEAD )) CLEAR_FLAG (this, FLAG_UNDEAD); + if (!QUERY_FLAG (arch, FLAG_SEE_IN_DARK )) CLEAR_FLAG (this, FLAG_SEE_IN_DARK); + + path_attuned = arch->path_attuned; + path_repelled = arch->path_repelled; + path_denied = arch->path_denied; + glow_radius = arch->glow_radius; + move_type = arch->move_type; chosen_skill = 0; /* initializing resistances from the values in player/monster's * archetype clone */ - memcpy (&resist, &arch->clone.resist, sizeof (resist)); + memcpy (&resist, &arch->resist, sizeof (resist)); for (i = 0; i < NROFATTACKS; i++) { @@ -790,8 +789,8 @@ potion_resist[i] = 0; } - wc = arch->clone.stats.wc; - stats.dam = arch->clone.stats.dam; + wc = arch->stats.wc; + stats.dam = arch->stats.dam; /* for players which cannot use armour, they gain AC -1 per 3 levels, * plus a small amount of physical resist, those poor suckers. ;) @@ -802,26 +801,20 @@ */ if (!QUERY_FLAG (this, FLAG_USE_ARMOUR) && type == PLAYER) { - ac = MAX (-10, arch->clone.stats.ac - level / 3); + ac = MAX (-10, arch->stats.ac - level / 3); prot[ATNR_PHYSICAL] += ((100 - prot[AT_PHYSICAL]) * (80 * level / settings.max_level)) / 100; } else - ac = arch->clone.stats.ac; + ac = arch->stats.ac; - stats.luck = arch->clone.stats.luck; - speed = arch->clone.speed; + stats.luck = arch->stats.luck; + speed = arch->speed; /* OK - we've reset most all the objects attributes to sane values. * now go through and make adjustments for what the player has equipped. */ for (tmp = inv; tmp; tmp = tmp->below) { - /* See note in map.c:update_position about making this additive - * since light sources are never applied, need to put check here. - */ - if (tmp->glow_radius > glow_radius) - glow_radius = tmp->glow_radius; - /* This happens because apply_potion calls change_abil with the potion * applied so we can tell the player what changed. But change_abil * then calls this function. @@ -829,6 +822,12 @@ 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. + */ + if (tmp->glow_radius > glow_radius) + glow_radius = tmp->glow_radius; + /* For some things, we don't care what is equipped */ if (tmp->type == SKILL) { @@ -868,14 +867,17 @@ if (type == PLAYER) { if (tmp == contr->combat_ob || tmp == contr->ranged_ob) - if (tmp != current_weapon && (tmp->type != SKILL || tmp->subtype != SK_PRAYING)) + if (tmp != current_weapon + && (tmp->type != SKILL || tmp->subtype != SK_PRAYING) + && !tmp->flag [FLAG_CURSED] + && !tmp->flag [FLAG_DAMNED]) continue; for (i = 0; i < NUM_STATS; i++) change_attr_value (&stats, i, tmp->stats.stat (i)); - /* these are the items that currently can change digestion, regeneration, - * spell point recovery and mana point recovery. Seems sort of an arbitary + /* These are the items that currently can change digestion, regeneration, + * spell point recovery and mana point recovery. Seems sort of an arbitary * list, but other items store other info into stats array. */ if (tmp->type == WEAPON || tmp->type == BOW || @@ -959,7 +961,7 @@ if (QUERY_FLAG (tmp, FLAG_BLIND )) SET_FLAG (this, FLAG_BLIND); if (QUERY_FLAG (tmp, FLAG_SEE_IN_DARK )) SET_FLAG (this, FLAG_SEE_IN_DARK); - if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (&arch->clone, FLAG_UNDEAD)) + if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) SET_FLAG (this, FLAG_UNDEAD); if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) @@ -993,48 +995,50 @@ /* skills modifying the character -b.t. */ /* for all skills and skill granting objects */ case SKILL: - if (!QUERY_FLAG (tmp, FLAG_APPLIED)) - break; - - if (chosen_skill) - LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &name); - - chosen_skill = tmp; + { + if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) + break; - if (tmp->stats.dam > 0) - { /* skill is a 'weapon' */ - if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) - weapon_speed = WEAPON_SPEED (tmp); + if (chosen_skill) + { + LOG (llevDebug, "fix_player, op %s has multiple skills applied (%s and %s)\n", + &name, &chosen_skill->name, &tmp->name); - if (weapon_speed < 0) - weapon_speed = 0; + tmp->flag [FLAG_APPLIED] = false; + update_stats (); + return; + } + else + chosen_skill = tmp; - weapon_weight = tmp->weight; - stats.dam += 1 + (chosen_skill->level * tmp->stats.dam / 9); + if (tmp->stats.dam > 0) + { /* skill is a 'weapon' */ + if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) + weapon_speed = WEAPON_SPEED (tmp); - if (tmp->magic) - stats.dam += tmp->magic; - } + if (weapon_speed < 0) + weapon_speed = 0; - if (tmp->stats.wc) - wc -= tmp->stats.wc + tmp->magic; + weapon_weight = tmp->weight; + stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; - if (tmp->slaying) - slaying = tmp->slaying; + if (tmp->magic) + stats.dam += tmp->magic; + } - if (tmp->stats.ac) - ac -= tmp->stats.ac + tmp->magic; + if (tmp->stats.wc) + wc -= tmp->stats.wc + tmp->magic; - if (settings.spell_encumbrance == TRUE && type == PLAYER) - contr->encumbrance += (int) 3 *tmp->weight / 1000; + if (tmp->slaying) + slaying = tmp->slaying; - break; + if (tmp->stats.ac) + ac -= tmp->stats.ac + tmp->magic; - case SKILL_TOOL: - if (chosen_skill) - LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &name); + if (settings.spell_encumbrance == TRUE && type == PLAYER) + contr->encumbrance += (int) 3 *tmp->weight / 1000; + } - chosen_skill = tmp; break; case SHIELD: @@ -1318,7 +1322,7 @@ speed -= 1; if (attacktype == 0) - attacktype = arch->clone.attacktype; + attacktype = arch->attacktype; } /* End if player */ if (added_speed >= 0) @@ -1371,14 +1375,12 @@ if (K <= 0.01f) K = 0.01f; - float S = speed / (K * s); - - contr->weapon_sp = S; + contr->weapon_sp = K * s * .5f; //TODO: balance the .5 } /* I want to limit the power of small monsters with big weapons: */ - if (type != PLAYER && arch && stats.dam > arch->clone.stats.dam * 3) - stats.dam = arch->clone.stats.dam * 3; + if (type != PLAYER && arch && stats.dam > arch->stats.dam * 3) + stats.dam = arch->stats.dam * 3; stats.wc = clamp (wc, MIN_WC, MAX_WC); stats.ac = clamp (ac, MIN_AC, MAX_AC); @@ -1513,9 +1515,9 @@ for (tmp = who->inv; tmp; tmp = tmp->below) if (tmp->type == FORCE) - if (tmp->arch->name == dragon_ability_force) + if (tmp->arch->archname == dragon_ability_force) abil = tmp; - else if (tmp->arch->name == dragon_skin_force) + else if (tmp->arch->archname == dragon_skin_force) skin = tmp; /* if the force is missing -> bail out */ @@ -1580,11 +1582,11 @@ skill_obj->level = 1; insert_ob_in_ob (skill_obj, op); - if (op->contr) + if (player *pl = op->contr) { - op->contr->last_skill_ob [skill_obj->subtype] = skill_obj; - if (op->contr->ns) - op->contr->ns->last_skill_exp[skill_obj->subtype] = -1;//TODO: should be made superfluous + pl->last_skill_ob [skill_obj->subtype] = skill_obj; + if (pl->ns) + pl->ns->last_skill_exp[skill_obj->subtype] = -1;//TODO: should be made superfluous } return skill_obj;