--- deliantra/server/common/living.C 2007/01/03 00:21:35 1.23 +++ deliantra/server/common/living.C 2007/04/29 14:39:55 1.39 @@ -1,25 +1,26 @@ /* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 2002 Mark Wedel & Crossfire Development Team - Copyright (C) 1992 Frank Tore Johansen - - This program 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. - - 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - The authors can be reached via e-mail at -*/ + * CrossFire, A Multiplayer game + * + * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team + * Copyright (C) 2002 Mark Wedel & Crossfire Development Team + * Copyright (C) 1992 Frank Tore Johansen + * + * This program 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. + * + * 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * The authors can be reached via e-mail at + */ #include #include @@ -193,36 +194,36 @@ "You're feeling clumsy!", "You feel less healthy", "You suddenly begin to lose your memory!", - "Your face gets distorted!", "Watch out, your mind is going!", - "Your spirit feels drained!" + "Your spirit feels drained!", + "Your face gets distorted!", }; const char *const restore_msg[NUM_STATS] = { "You feel your strength return.", "You feel your agility return.", "You feel your health return.", + "You feel your memory return.", "You feel your wisdom return.", + "You feel your spirits return.", "You feel your charisma return.", - "You feel your memory return.", - "You feel your spirits return." }; const char *const gain_msg[NUM_STATS] = { "You feel stronger.", "You feel more agile.", "You feel healthy.", + "You feel smarter.", "You feel wiser.", + "You feel more potent.", "You seem to look better.", - "You feel smarter.", - "You feel more potent." }; const char *const lose_msg[NUM_STATS] = { "You feel weaker!", "You feel clumsy!", "You feel less healthy!", + "You feel stupid!", "You lose some of your memory!", + "You feel less potent!", "You look ugly!", - "You feel stupid!", - "You feel less potent!" }; const char *const statname[NUM_STATS] = { @@ -678,7 +679,7 @@ void object::drain_stat () { - drain_specific_stat (RANDOM () % NUM_STATS); + drain_specific_stat (rndm (NUM_STATS)); } void @@ -756,7 +757,7 @@ /* Randomly change the players luck. Basically, we move it * back neutral (if greater>0, subtract, otherwise add) */ - if (RANDOM () % (FABS (tmp->stats.luck)) >= RANDOM () % 30) + if (rndm (abs (tmp->stats.luck)) >= rndm (30)) { int diff = tmp->stats.luck > 0 ? -1 : 1; @@ -819,12 +820,10 @@ * and players; the "player" in the name is purely an archaic inheritance. * This functions starts from base values (archetype or player object) * and then adjusts them according to what the player has equipped. + * + * July 95 - inserted stuff to handle new skills/exp system - b.t. + * spell system split, grace points now added to system --peterm */ - -/* July 95 - inserted stuff to handle new skills/exp system - b.t. - spell system split, grace points now added to system --peterm - */ - void object::update_stats () { @@ -834,6 +833,7 @@ int best_wc = 0, best_ac = 0, wc = 0, ac = 0; int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; object *grace_obj = NULL, *mana_obj = NULL, *wc_obj = NULL, *tmp; + float old_speed = speed; /* First task is to clear all the values back to their original values */ if (type == PLAYER) @@ -845,21 +845,22 @@ contr->encumbrance = 0; attacktype = 0; - contr->digestion = 0; - contr->gen_hp = 0; - contr->gen_sp = 0; - contr->gen_grace = 0; + + contr->digestion = 0; + contr->gen_hp = 0; + contr->gen_sp = 0; + contr->gen_grace = 0; contr->gen_sp_armour = 10; - contr->item_power = 0; + contr->item_power = 0; /* Don't clobber all the range_ values. range_golem otherwise * gets reset for no good reason, and we don't want to reset * range_magic (what spell is readied). These three below * well get filled in based on what the player has equipped. */ - contr->ranges[range_bow] = NULL; - contr->ranges[range_misc] = NULL; - contr->ranges[range_skill] = NULL; + contr->ranges[range_bow] = 0; + contr->ranges[range_misc] = 0; + contr->ranges[range_skill] = 0; } memcpy (body_used, body_info, sizeof (body_info)); @@ -881,11 +882,12 @@ 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_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; + path_denied = arch->clone.path_denied; + glow_radius = arch->clone.glow_radius; + move_type = arch->clone.move_type; + chosen_skill = NULL; /* initializing resistances from the values in player/monster's @@ -926,7 +928,6 @@ /* 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 @@ -972,8 +973,11 @@ * because the skill shouldn't count against body positions being used * up, etc. */ - if ((QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type != CONTAINER && tmp->type != CLOSE_CON) || - (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) + if ((QUERY_FLAG (tmp, FLAG_APPLIED) + && tmp->type != CONTAINER + && tmp->type != CLOSE_CON) + || (tmp->type == SKILL + && tmp->subtype == SK_PRAYING)) { if (type == PLAYER) { @@ -984,13 +988,13 @@ contr->ranges[range_misc] = tmp; for (i = 0; i < NUM_STATS; i++) - change_attr_value (&(stats), i, get_attr_value (&(tmp->stats), i)); + change_attr_value (&stats, i, get_attr_value (&tmp->stats, i)); /* 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) || + if ((tmp->type == WEAPON) || (tmp->type == BOW) || (tmp->type == ARMOUR) || (tmp->type == HELMET) || (tmp->type == SHIELD) || (tmp->type == RING) || (tmp->type == BOOTS) || (tmp->type == GLOVES) || @@ -1016,12 +1020,13 @@ if (tmp->type == SYMPTOM) { speed_reduce_from_disease = tmp->last_sp / 100.0; + if (speed_reduce_from_disease == 0) speed_reduce_from_disease = 1; } /* Pos. and neg. protections are counted seperate (-> pro/vuln). - * (Negative protections are calculated extactly like positive.) + * (Negative protections are calculated exactly like positive.) * Resistance from potions are treated special as well. If there's * more than one potion-effect, the bigger prot.-value is taken. */ @@ -1040,9 +1045,9 @@ potion_resist[i] = tmp->resist[i]; } else if (tmp->resist[i] > 0) - prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; + prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; else if (tmp->resist[i] < 0) - vuln[i] += ((100 - vuln[i]) * (-tmp->resist[i])) / 100; + vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; } } @@ -1050,11 +1055,11 @@ if (tmp->type != BOW && tmp->type != SYMPTOM) attacktype |= tmp->attacktype; - path_attuned |= tmp->path_attuned; + path_attuned |= tmp->path_attuned; path_repelled |= tmp->path_repelled; - path_denied |= tmp->path_denied; - stats.luck += tmp->stats.luck; - move_type |= tmp->move_type; + path_denied |= tmp->path_denied; + move_type |= tmp->move_type; + stats.luck += tmp->stats.luck; if (QUERY_FLAG (tmp, FLAG_LIFESAVE )) SET_FLAG (this, FLAG_LIFESAVE); if (QUERY_FLAG (tmp, FLAG_REFL_SPELL )) SET_FLAG (this, FLAG_REFL_SPELL); @@ -1153,23 +1158,24 @@ case GLOVES: case CLOAK: if (tmp->stats.wc) - wc -= (tmp->stats.wc + tmp->magic); + wc -= tmp->stats.wc + tmp->magic; if (tmp->stats.dam) - stats.dam += (tmp->stats.dam + tmp->magic); + stats.dam += tmp->stats.dam + tmp->magic; if (tmp->stats.ac) - ac -= (tmp->stats.ac + tmp->magic); + ac -= tmp->stats.ac + tmp->magic; break; + case BOW: case WEAPON: - wc -= (tmp->stats.wc + tmp->magic); + wc -= tmp->stats.wc + tmp->magic; if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) ac -= tmp->stats.ac + tmp->magic; - stats.dam += (tmp->stats.dam + tmp->magic); + stats.dam += tmp->stats.dam + tmp->magic; weapon_weight = tmp->weight; weapon_speed = ((int) WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; @@ -1389,19 +1395,21 @@ if (type == PLAYER && wc_obj && wc_obj->level > 1) { - wc -= (wc_obj->level + thaco_bonus[stats.Str]); + wc -= wc_obj->level + thaco_bonus[stats.Str]; + for (i = 1; i < wc_obj->level; i++) { /* addtional wc every 6 levels */ if (!(i % 6)) wc--; + /* addtional dam every 4 levels. */ - if (!(i % 4) && (dam_bonus[stats.Str] >= 0)) - stats.dam += (1 + (dam_bonus[stats.Str] / 5)); + if (!(i % 4) && dam_bonus[stats.Str] >= 0) + stats.dam += 1 + dam_bonus[stats.Str] / 5; } } else - wc -= (level + thaco_bonus[stats.Str]); + wc -= level + thaco_bonus[stats.Str]; stats.dam += dam_bonus[stats.Str]; @@ -1504,7 +1512,8 @@ else if (move_type & (MOVE_FLY_LOW | MOVE_FLY_HIGH)) move_type &= ~MOVE_WALK; - set_speed (speed); + if (speed != old_speed) + set_speed (speed); /* It is quite possible that a player's spell costing might have changed, * so we will check that now. @@ -1514,6 +1523,10 @@ esrv_update_stats (contr); esrv_update_spells (contr); } + + // update the mapspace, if we are on a map + if (!flag [FLAG_REMOVED] && map) + map->at (x, y).flags_ = 0; } /* @@ -1608,16 +1621,16 @@ char buf[MAX_BUF]; /* tmp. string buffer */ /* now grab the 'dragon_ability'-forces from the player's inventory */ - for (tmp = who->inv; tmp != NULL; tmp = tmp->below) - { - if (tmp->type == FORCE) - { - if (strcmp (tmp->arch->name, "dragon_ability_force") == 0) - abil = tmp; - if (strcmp (tmp->arch->name, "dragon_skin_force") == 0) - skin = tmp; - } - } + shstr_cmp dragon_ability_force ("dragon_ability_force"); + shstr_cmp dragon_skin_force ("dragon_skin_force"); + + for (tmp = who->inv; tmp; tmp = tmp->below) + if (tmp->type == FORCE) + if (tmp->arch->name == dragon_ability_force) + abil = tmp; + else if (tmp->arch->name == dragon_skin_force) + skin = tmp; + /* if the force is missing -> bail out */ if (abil == NULL) return; @@ -1678,11 +1691,14 @@ skill_obj->stats.exp = 0; skill_obj->level = 1; insert_ob_in_ob (skill_obj, op); + if (op->contr) { - op->contr->last_skill_ob[skill_obj->subtype] = skill_obj; - op->contr->last_skill_exp[skill_obj->subtype] = -1; + 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 } + return skill_obj; } @@ -1947,6 +1963,7 @@ player_lvl_adj (op, tmp); } } + if (flag != SK_SUBTRACT_SKILL_EXP) { del_exp = check_exp_loss (op, exp); @@ -1955,8 +1972,6 @@ } } - - /* change_exp() - changes experience to a player/monster. This * does bounds checking to make sure we don't overflow the max exp. * @@ -1966,11 +1981,9 @@ * flag is what to do if player doesn't have the skill. * these last two values are only used for players. */ - void change_exp (object *op, sint64 exp, const char *skill_name, int flag) { - #ifdef EXP_DEBUG LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp); #endif @@ -2021,8 +2034,7 @@ * a particular skill, so we don't need to pass that * along. */ - subtract_player_exp (op, FABS (exp), skill_name, flag); - + subtract_player_exp (op, abs (exp), skill_name, flag); } } @@ -2030,7 +2042,6 @@ * settings death_penalty_percentage and death_penalty_levels, and by the * amount of permenent experience, whichever gives the lowest loss. */ - void apply_death_exp_penalty (object *op) {