ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/living.C
(Generate patch)

Comparing deliantra/server/common/living.C (file contents):
Revision 1.34 by root, Mon Feb 5 03:01:32 2007 UTC vs.
Revision 1.37 by root, Sun Apr 29 03:44:35 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 * 7 *
818 * Updates all abilities given by applied objects in the inventory 818 * Updates all abilities given by applied objects in the inventory
819 * of the given object. Note: This function works for both monsters 819 * of the given object. Note: This function works for both monsters
820 * and players; the "player" in the name is purely an archaic inheritance. 820 * and players; the "player" in the name is purely an archaic inheritance.
821 * This functions starts from base values (archetype or player object) 821 * This functions starts from base values (archetype or player object)
822 * and then adjusts them according to what the player has equipped. 822 * and then adjusts them according to what the player has equipped.
823 */ 823 *
824
825/* July 95 - inserted stuff to handle new skills/exp system - b.t. 824 * July 95 - inserted stuff to handle new skills/exp system - b.t.
826 spell system split, grace points now added to system --peterm 825 * spell system split, grace points now added to system --peterm
827 */ 826 */
828
829void 827void
830object::update_stats () 828object::update_stats ()
831{ 829{
832 int i, j; 830 int i, j;
833 float f, max = 9, added_speed = 0, bonus_speed = 0, sp_tmp, speed_reduce_from_disease = 1; 831 float f, max = 9, added_speed = 0, bonus_speed = 0, sp_tmp, speed_reduce_from_disease = 1;
857 /* Don't clobber all the range_ values. range_golem otherwise 855 /* Don't clobber all the range_ values. range_golem otherwise
858 * gets reset for no good reason, and we don't want to reset 856 * gets reset for no good reason, and we don't want to reset
859 * range_magic (what spell is readied). These three below 857 * range_magic (what spell is readied). These three below
860 * well get filled in based on what the player has equipped. 858 * well get filled in based on what the player has equipped.
861 */ 859 */
862 contr->ranges[range_bow] = NULL; 860 contr->ranges[range_bow] = 0;
863 contr->ranges[range_misc] = NULL; 861 contr->ranges[range_misc] = 0;
864 contr->ranges[range_skill] = NULL; 862 contr->ranges[range_skill] = 0;
865 } 863 }
866 864
867 memcpy (body_used, body_info, sizeof (body_info)); 865 memcpy (body_used, body_info, sizeof (body_info));
868 866
869 slaying = 0; 867 slaying = 0;
1152 case HELMET: 1150 case HELMET:
1153 case BOOTS: 1151 case BOOTS:
1154 case GLOVES: 1152 case GLOVES:
1155 case CLOAK: 1153 case CLOAK:
1156 if (tmp->stats.wc) 1154 if (tmp->stats.wc)
1157 wc -= (tmp->stats.wc + tmp->magic); 1155 wc -= tmp->stats.wc + tmp->magic;
1158 1156
1159 if (tmp->stats.dam) 1157 if (tmp->stats.dam)
1160 stats.dam += (tmp->stats.dam + tmp->magic); 1158 stats.dam += tmp->stats.dam + tmp->magic;
1161 1159
1162 if (tmp->stats.ac) 1160 if (tmp->stats.ac)
1163 ac -= (tmp->stats.ac + tmp->magic); 1161 ac -= tmp->stats.ac + tmp->magic;
1164 1162
1165 break; 1163 break;
1166 1164
1165 case BOW:
1167 case WEAPON: 1166 case WEAPON:
1168 wc -= (tmp->stats.wc + tmp->magic); 1167 wc -= tmp->stats.wc + tmp->magic;
1169 1168
1170 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1169 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1171 ac -= tmp->stats.ac + tmp->magic; 1170 ac -= tmp->stats.ac + tmp->magic;
1172 1171
1173 stats.dam += (tmp->stats.dam + tmp->magic); 1172 stats.dam += tmp->stats.dam + tmp->magic;
1174 weapon_weight = tmp->weight; 1173 weapon_weight = tmp->weight;
1175 weapon_speed = ((int) WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; 1174 weapon_speed = ((int) WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2;
1176 1175
1177 if (weapon_speed < 0) 1176 if (weapon_speed < 0)
1178 weapon_speed = 0; 1177 weapon_speed = 0;
1388 * monster bonus the same as before. -b.t. 1387 * monster bonus the same as before. -b.t.
1389 */ 1388 */
1390 1389
1391 if (type == PLAYER && wc_obj && wc_obj->level > 1) 1390 if (type == PLAYER && wc_obj && wc_obj->level > 1)
1392 { 1391 {
1393 wc -= (wc_obj->level + thaco_bonus[stats.Str]); 1392 wc -= wc_obj->level + thaco_bonus[stats.Str];
1393
1394 for (i = 1; i < wc_obj->level; i++) 1394 for (i = 1; i < wc_obj->level; i++)
1395 { 1395 {
1396 /* addtional wc every 6 levels */ 1396 /* addtional wc every 6 levels */
1397 if (!(i % 6)) 1397 if (!(i % 6))
1398 wc--; 1398 wc--;
1399
1399 /* addtional dam every 4 levels. */ 1400 /* addtional dam every 4 levels. */
1400 if (!(i % 4) && (dam_bonus[stats.Str] >= 0)) 1401 if (!(i % 4) && dam_bonus[stats.Str] >= 0)
1401 stats.dam += (1 + (dam_bonus[stats.Str] / 5)); 1402 stats.dam += 1 + dam_bonus[stats.Str] / 5;
1402 } 1403 }
1403 } 1404 }
1404 else 1405 else
1405 wc -= (level + thaco_bonus[stats.Str]); 1406 wc -= level + thaco_bonus[stats.Str];
1406 1407
1407 stats.dam += dam_bonus[stats.Str]; 1408 stats.dam += dam_bonus[stats.Str];
1408 1409
1409 if (stats.dam < 1) 1410 if (stats.dam < 1)
1410 stats.dam = 1; 1411 stats.dam = 1;
1514 if (type == PLAYER) 1515 if (type == PLAYER)
1515 { 1516 {
1516 esrv_update_stats (contr); 1517 esrv_update_stats (contr);
1517 esrv_update_spells (contr); 1518 esrv_update_spells (contr);
1518 } 1519 }
1520
1521 // update the mapspace, if we are on a map
1522 if (!flag [FLAG_REMOVED] && map)
1523 map->at (x, y).flags_ = 0;
1519} 1524}
1520 1525
1521/* 1526/*
1522 * Returns true if the given player is a legal class. 1527 * Returns true if the given player is a legal class.
1523 * The function to add and remove class-bonuses to the stats doesn't 1528 * The function to add and remove class-bonuses to the stats doesn't
1950 del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction)); 1955 del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction));
1951 tmp->stats.exp -= del_exp; 1956 tmp->stats.exp -= del_exp;
1952 player_lvl_adj (op, tmp); 1957 player_lvl_adj (op, tmp);
1953 } 1958 }
1954 } 1959 }
1960
1955 if (flag != SK_SUBTRACT_SKILL_EXP) 1961 if (flag != SK_SUBTRACT_SKILL_EXP)
1956 { 1962 {
1957 del_exp = check_exp_loss (op, exp); 1963 del_exp = check_exp_loss (op, exp);
1958 op->stats.exp -= del_exp; 1964 op->stats.exp -= del_exp;
1959 player_lvl_adj (op, NULL); 1965 player_lvl_adj (op, NULL);
1960 } 1966 }
1961} 1967}
1962
1963
1964 1968
1965/* change_exp() - changes experience to a player/monster. This 1969/* change_exp() - changes experience to a player/monster. This
1966 * does bounds checking to make sure we don't overflow the max exp. 1970 * does bounds checking to make sure we don't overflow the max exp.
1967 * 1971 *
1968 * The exp passed is typically not modified much by this function - 1972 * The exp passed is typically not modified much by this function -
1969 * it is assumed the caller has modified the exp as needed. 1973 * it is assumed the caller has modified the exp as needed.
1970 * skill_name is the skill that should get the exp added. 1974 * skill_name is the skill that should get the exp added.
1971 * flag is what to do if player doesn't have the skill. 1975 * flag is what to do if player doesn't have the skill.
1972 * these last two values are only used for players. 1976 * these last two values are only used for players.
1973 */ 1977 */
1974
1975void 1978void
1976change_exp (object *op, sint64 exp, const char *skill_name, int flag) 1979change_exp (object *op, sint64 exp, const char *skill_name, int flag)
1977{ 1980{
1978
1979#ifdef EXP_DEBUG 1981#ifdef EXP_DEBUG
1980 LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp); 1982 LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp);
1981#endif 1983#endif
1982 1984
1983 /* safety */ 1985 /* safety */
2032 2034
2033/* Applies a death penalty experience, the size of this is defined by the 2035/* Applies a death penalty experience, the size of this is defined by the
2034 * settings death_penalty_percentage and death_penalty_levels, and by the 2036 * settings death_penalty_percentage and death_penalty_levels, and by the
2035 * amount of permenent experience, whichever gives the lowest loss. 2037 * amount of permenent experience, whichever gives the lowest loss.
2036 */ 2038 */
2037
2038void 2039void
2039apply_death_exp_penalty (object *op) 2040apply_death_exp_penalty (object *op)
2040{ 2041{
2041 object *tmp; 2042 object *tmp;
2042 sint64 loss; 2043 sint64 loss;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines