--- deliantra/server/common/living.C 2009/11/29 17:41:07 1.105 +++ deliantra/server/common/living.C 2010/03/28 16:41:45 1.112 @@ -1,9 +1,9 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * 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 + * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2002 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992 Frank Tore Johansen * * 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 @@ -264,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. */ @@ -417,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 @@ -766,6 +763,8 @@ 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) { @@ -813,7 +812,7 @@ glow_radius = arch->glow_radius; move_type = arch->move_type; - chosen_skill = 0; + object *chosen_skill = 0; /* initializing resistances from the values in player/monster's * archetype clone @@ -898,8 +897,7 @@ if ((tmp->flag [FLAG_APPLIED] && tmp->type != CONTAINER && tmp->type != CLOSE_CON) - || (tmp->type == SKILL - && tmp->subtype == SK_PRAYING)) + || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) { if (type == PLAYER) { @@ -932,39 +930,36 @@ } /* Update slots used for items */ - if (QUERY_FLAG (tmp, FLAG_APPLIED)) + if (tmp->flag [FLAG_APPLIED]) for (int i = 0; i < NUM_BODY_LOCATIONS; i++) slot[i].used += tmp->slot[i].info; if (tmp->type == SYMPTOM) - speed_reduce_from_disease = - min (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); + min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); /* Pos. and neg. protections are counted separate (-> pro/vuln). * (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. */ - if (tmp->type != POTION) - { - for (int i = 0; i < NROFATTACKS; i++) - { - /* Potential for cursed potions, in which case we just can use - * a straight MAX, as potion_resist is initialised to zero. - */ - if (tmp->type == POTION_EFFECT) - { - if (potion_resist[i]) - potion_resist[i] = max (potion_resist[i], tmp->resist[i]); - else - potion_resist[i] = tmp->resist[i]; - } - else if (tmp->resist[i] > 0) - prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; - else if (tmp->resist[i] < 0) - vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; - } - } + if (tmp->type == POTION_EFFECT) + for (int i = 0; i < NROFATTACKS; i++) + { + /* Potential for cursed potions, in which case we just can use + * a straight MAX, as potion_resist is initialised to zero. + // TODO: this is askign for a magic marker optimisation + */ + if (potion_resist[i]) + max_it (potion_resist[i], tmp->resist[i]); + else + potion_resist[i] = tmp->resist[i]; + } + else if (tmp->type != POTION) + for (int i = 0; i < NROFATTACKS; i++) + if (tmp->resist[i] > 0) + prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; + else if (tmp->resist[i] < 0) + vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; /* There may be other things that should not adjust the attacktype */ if (tmp->type != SYMPTOM) @@ -1001,15 +996,6 @@ switch (tmp->type) { -#if 0 - case WAND: - case ROD: - case HORN: - if (type != PLAYER || current_weapon == tmp) - chosen_skill = tmp; - break; -#endif - /* skills modifying the character -b.t. */ /* for all skills and skill granting objects */ case SKILL: @@ -1054,14 +1040,15 @@ ac -= tmp->stats.ac + tmp->magic; if (settings.spell_encumbrance == TRUE && type == PLAYER) - contr->encumbrance += (int) 3 *tmp->weight / 1000; + contr->encumbrance += 3 * tmp->weight / 1000; } break; case SHIELD: if (settings.spell_encumbrance == TRUE && type == PLAYER) - contr->encumbrance += (int) tmp->weight / 2000; + contr->encumbrance += tmp->weight / 2000; + //FALLTHROUGH case RING: case AMULET: case GIRDLE: @@ -1080,10 +1067,20 @@ break; + case WAND: + case ROD: + case HORN: + case SKILL_TOOL: + if (type != PLAYER) + chosen_skill = find_skill_by_name (this, tmp->skill); + break; + case BOW: case WEAPON: if (type != PLAYER || current_weapon == tmp) { + chosen_skill = find_skill_by_name (this, tmp->skill); + wc -= tmp->stats.wc + tmp->magic; if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) @@ -1152,6 +1149,9 @@ } /* item is equipped */ } /* for loop of items */ + if (type != PLAYER) + this->chosen_skill = chosen_skill; + glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); /* We've gone through all the objects the player has equipped. For many things, we @@ -1403,6 +1403,10 @@ 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. */ @@ -1607,7 +1611,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 */