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.51 by root, Sat May 12 18:23:51 2007 UTC vs.
Revision 1.54 by root, Sat May 12 19:30:18 2007 UTC

242change_attr_value (living *stats, int attr, sint8 value) 242change_attr_value (living *stats, int attr, sint8 value)
243{ 243{
244 stats->stat (attr) += value; 244 stats->stat (attr) += value;
245} 245}
246 246
247sint8 &
248living::stat (int index)
249{
250 switch (index)
251 {
252 case STR: return Str;
253 case DEX: return Dex;
254 case CON: return Con;
255 case INT: return Int;
256 case WIS: return Wis;
257 case POW: return Pow;
258 case CHA: return Cha;
259 }
260
261 LOG (llevError | logBacktrace, "living.stat() called with out-of-range stat index");
262 static sint8 dummy;
263 return dummy;
264}
265
266sint8
267living::stat (int index) const
268{
269 switch (index)
270 {
271 case STR: return Str;
272 case DEX: return Dex;
273 case CON: return Con;
274 case INT: return Int;
275 case WIS: return Wis;
276 case POW: return Pow;
277 case CHA: return Cha;
278 }
279
280 LOG (llevError | logBacktrace, "living.stat() called with out-of-range stat index");
281 static sint8 dummy;
282 return dummy;
283}
284
285/* 247/*
286 * Ensures that all stats (str/dex/con/wis/cha/int) are within the 248 * Ensures that all stats (str/dex/con/wis/cha/int) are within the
287 * 1-30 stat limit. 249 * 1-30 stat limit.
288 */ 250 */
289void 251void
977 vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; 939 vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100;
978 } 940 }
979 } 941 }
980 942
981 /* There may be other things that should not adjust the attacktype */ 943 /* There may be other things that should not adjust the attacktype */
982 if ((tmp->type != WEAPON && tmp->type != BOW && tmp->type != SYMPTOM) 944 if (tmp->type != SYMPTOM)
983 || current_weapon == tmp)
984 { 945 {
985 attacktype |= tmp->attacktype; 946 attacktype |= tmp->attacktype;
986 path_attuned |= tmp->path_attuned; 947 path_attuned |= tmp->path_attuned;
987 path_repelled |= tmp->path_repelled; 948 path_repelled |= tmp->path_repelled;
988 path_denied |= tmp->path_denied; 949 path_denied |= tmp->path_denied;
1050 1011
1051 if (weapon_speed < 0) 1012 if (weapon_speed < 0)
1052 weapon_speed = 0; 1013 weapon_speed = 0;
1053 1014
1054 weapon_weight = tmp->weight; 1015 weapon_weight = tmp->weight;
1055 stats.dam += tmp->stats.dam * (1 + (chosen_skill->level / 9)); 1016 stats.dam += 1 + (chosen_skill->level * tmp->stats.dam / 9);
1056 1017
1057 if (tmp->magic) 1018 if (tmp->magic)
1058 stats.dam += tmp->magic; 1019 stats.dam += tmp->magic;
1059 } 1020 }
1060 1021
1264 stats.maxsp = (sint16)sp_tmp; 1225 stats.maxsp = (sint16)sp_tmp;
1265 1226
1266 for (i = 11; i <= mana_obj->level; i++) 1227 for (i = 11; i <= mana_obj->level; i++)
1267 stats.maxsp += 2; 1228 stats.maxsp += 2;
1268 } 1229 }
1230
1269 /* Characters can get their sp supercharged via rune of transferrance */ 1231 /* Characters can get their sp supercharged via rune of transferrance */
1270 if (stats.sp > stats.maxsp * 2) 1232 if (stats.sp > stats.maxsp * 2)
1271 stats.sp = stats.maxsp * 2; 1233 stats.sp = stats.maxsp * 2;
1272 1234
1273 /* set maxgrace, notice 3-4 lines below it depends on both Wis and Pow */ 1235 /* set maxgrace, notice 3-4 lines below it depends on both Wis and Pow */
1304 1266
1305 /* two grace points per level after 11 */ 1267 /* two grace points per level after 11 */
1306 for (i = 11; i <= grace_obj->level; i++) 1268 for (i = 11; i <= grace_obj->level; i++)
1307 stats.maxgrace += 2; 1269 stats.maxgrace += 2;
1308 } 1270 }
1271
1309 /* No limit on grace vs maxgrace */ 1272 /* No limit on grace vs maxgrace */
1310 1273
1311 if (contr->braced) 1274 if (contr->braced)
1312 { 1275 {
1313 ac += 2; 1276 ac += 2;
1326 * we give the player a bonus here in wc and dam 1289 * we give the player a bonus here in wc and dam
1327 * to make up for the change. Note that I left the 1290 * to make up for the change. Note that I left the
1328 * monster bonus the same as before. -b.t. 1291 * monster bonus the same as before. -b.t.
1329 */ 1292 */
1330 1293
1331 if (type == PLAYER && wc_obj && wc_obj->level > 1) 1294 if (contr && wc_obj && wc_obj->level > 1)
1332 { 1295 {
1333 wc -= wc_obj->level + thaco_bonus[stats.Str]; 1296 wc -= wc_obj->level + thaco_bonus[stats.Str];
1334 1297
1335 for (i = 1; i < wc_obj->level; i++) 1298 for (i = 1; i < wc_obj->level; i++)
1336 { 1299 {
1337 /* addtional wc every 6 levels */ 1300 /* additional wc every 6 levels */
1338 if (!(i % 6)) 1301 if (!(i % 6))
1339 wc--; 1302 wc--;
1340 1303
1341 /* addtional dam every 4 levels. */ 1304 /* additional dam every 4 levels. */
1342 if (!(i % 4) && dam_bonus[stats.Str] >= 0) 1305 if (!(i % 4) && dam_bonus[stats.Str] >= 0)
1343 stats.dam += 1 + dam_bonus[stats.Str] / 5; 1306 stats.dam += 1 + dam_bonus[stats.Str] / 5;
1344 } 1307 }
1345 } 1308 }
1346 else 1309 else
1642 } 1605 }
1643 1606
1644 return skill_obj; 1607 return skill_obj;
1645} 1608}
1646 1609
1647
1648/* player_lvl_adj() - for the new exp system. we are concerned with 1610/* player_lvl_adj() - for the new exp system. we are concerned with
1649 * whether the player gets more hp, sp and new levels. 1611 * whether the player gets more hp, sp and new levels.
1650 * Note this this function should only be called for players. Monstes 1612 * Note this this function should only be called for players. Monstes
1651 * don't really gain levels 1613 * don't really gain levels
1652 * who is the player, op is what we are checking to gain the level 1614 * who is the player, op is what we are checking to gain the level
1662 1624
1663 if (op->level < settings.max_level && op->stats.exp >= level_exp (op->level + 1, who->expmul)) 1625 if (op->level < settings.max_level && op->stats.exp >= level_exp (op->level + 1, who->expmul))
1664 { 1626 {
1665 op->level++; 1627 op->level++;
1666 1628
1667 if (op != NULL && op == who && op->stats.exp > 1 && is_dragon_pl (who)) 1629 if (op && op == who && op->stats.exp > 1 && is_dragon_pl (who))
1668 dragon_level_gain (who); 1630 dragon_level_gain (who);
1669 1631
1670 /* Only roll these if it is the player (who) that gained the level */ 1632 /* Only roll these if it is the player (who) that gained the level */
1671 if (op == who && (who->level < 11) && who->type == PLAYER) 1633 if (op == who && (who->level < 11) && who->type == PLAYER)
1672 { 1634 {
1680 { 1642 {
1681 if (op->type != PLAYER) 1643 if (op->type != PLAYER)
1682 sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); 1644 sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name);
1683 else 1645 else
1684 sprintf (buf, "You are now level %d.", op->level); 1646 sprintf (buf, "You are now level %d.", op->level);
1647
1685 if (who) 1648 if (who)
1686 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); 1649 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf);
1687 } 1650 }
1651
1688 player_lvl_adj (who, op); /* To increase more levels */ 1652 player_lvl_adj (who, op); /* To increase more levels */
1689 } 1653 }
1690 else if (op->level > 1 && op->stats.exp < level_exp (op->level, who->expmul)) 1654 else if (op->level > 1 && op->stats.exp < level_exp (op->level, who->expmul))
1691 { 1655 {
1692 op->level--; 1656 op->level--;
1693 who->update_stats (); 1657 who->update_stats ();
1658
1694 if (op->type != PLAYER) 1659 if (op->type != PLAYER)
1695 { 1660 {
1696 sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); 1661 sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name);
1697 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); 1662 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf);
1698 } 1663 }
1664
1699 player_lvl_adj (who, op); /* To decrease more levels */ 1665 player_lvl_adj (who, op); /* To decrease more levels */
1700 } 1666 }
1701 1667
1702 /* check if the spell data has changed */ 1668 /* check if the spell data has changed */
1703 esrv_update_stats (who->contr); 1669 esrv_update_stats (who->contr);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines