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.99 by root, Fri Nov 6 12:49:19 2009 UTC vs.
Revision 1.105 by root, Sun Nov 29 17:41:07 2009 UTC

595object::drain_specific_stat (int deplete_stats) 595object::drain_specific_stat (int deplete_stats)
596{ 596{
597 object *tmp; 597 object *tmp;
598 archetype *at; 598 archetype *at;
599 599
600 at = archetype::find (ARCH_DEPLETION); 600 at = archetype::find (shstr_depletion);
601 if (!at) 601 if (!at)
602 { 602 {
603 LOG (llevError, "Couldn't find archetype depletion.\n"); 603 LOG (llevError, "Couldn't find archetype depletion.\n");
604 return; 604 return;
605 } 605 }
607 { 607 {
608 tmp = present_arch_in_ob (at, this); 608 tmp = present_arch_in_ob (at, this);
609 609
610 if (!tmp) 610 if (!tmp)
611 { 611 {
612 tmp = arch_to_object (at); 612 tmp = at->instance ();
613 tmp = insert_ob_in_ob (tmp, this); 613 tmp = insert_ob_in_ob (tmp, this);
614 SET_FLAG (tmp, FLAG_APPLIED); 614 SET_FLAG (tmp, FLAG_APPLIED);
615 } 615 }
616 } 616 }
617 617
625 * via an applied bad_luck object. 625 * via an applied bad_luck object.
626 */ 626 */
627void 627void
628object::change_luck (int value) 628object::change_luck (int value)
629{ 629{
630 archetype *at = archetype::find ("luck"); 630 archetype *at = archetype::find (shstr_luck);
631 if (!at) 631 if (!at)
632 LOG (llevError, "Couldn't find archetype luck.\n"); 632 LOG (llevError, "Couldn't find archetype luck.\n");
633 else 633 else
634 { 634 {
635 object *tmp = present_arch_in_ob (at, this); 635 object *tmp = present_arch_in_ob (at, this);
637 if (!tmp) 637 if (!tmp)
638 { 638 {
639 if (!value) 639 if (!value)
640 return; 640 return;
641 641
642 tmp = arch_to_object (at); 642 tmp = at->instance ();
643 tmp = insert_ob_in_ob (tmp, this); 643 tmp = insert_ob_in_ob (tmp, this);
644 SET_FLAG (tmp, FLAG_APPLIED); 644 SET_FLAG (tmp, FLAG_APPLIED);
645 } 645 }
646 646
647 if (value) 647 if (value)
767 int stat_sum [NUM_STATS]; 767 int stat_sum [NUM_STATS];
768 768
769 /* First task is to clear all the values back to their original values */ 769 /* First task is to clear all the values back to their original values */
770 if (type == PLAYER) 770 if (type == PLAYER)
771 { 771 {
772 contr->delayed_update = false;
773
772 for (int i = 0; i < NUM_STATS; i++) 774 for (int i = 0; i < NUM_STATS; i++)
773 stat_sum [i] = contr->orig_stats.stat (i); 775 stat_sum [i] = contr->orig_stats.stat (i);
774 776
775 if (settings.spell_encumbrance == TRUE) 777 if (settings.spell_encumbrance == TRUE)
776 contr->encumbrance = 0; 778 contr->encumbrance = 0;
909 && !tmp->flag [FLAG_CURSED] 911 && !tmp->flag [FLAG_CURSED]
910 && !tmp->flag [FLAG_DAMNED]) 912 && !tmp->flag [FLAG_DAMNED])
911 continue; 913 continue;
912 914
913 for (int i = 0; i < NUM_STATS; i++) 915 for (int i = 0; i < NUM_STATS; i++)
914 stat_sum [i] = stat_sum [i] + tmp->stats.stat (i); 916 stat_sum [i] += tmp->stats.stat (i);
915 917
916 if (digest_types [tmp->type]) 918 if (digest_types [tmp->type])
917 { 919 {
918 contr->digestion += tmp->stats.food; 920 contr->digestion += tmp->stats.food;
919 contr->gen_hp += tmp->stats.hp; 921 contr->gen_hp += tmp->stats.hp;
1172 1174
1173 if (type == PLAYER) 1175 if (type == PLAYER)
1174 { 1176 {
1175 // clamp various player stats 1177 // clamp various player stats
1176 for (int i = 0; i < NUM_STATS; ++i) 1178 for (int i = 0; i < NUM_STATS; ++i)
1177 stats.stat (i) = clamp (stat_sum [i], MIN_STAT, MAX_STAT); 1179 stats.stat (i) = stat_sum [i];
1180
1181 check_stat_bounds (&stats);
1178 1182
1179 contr->digestion = clamp (contr->digestion, MIN_DIGESTION, MAX_DIGESTION); 1183 contr->digestion = clamp (contr->digestion, MIN_DIGESTION, MAX_DIGESTION);
1180 1184
1181 /* Figure out the players sp/mana/hp totals. */ 1185 /* Figure out the players sp/mana/hp totals. */
1182 int pl_level; 1186 int pl_level;
1183 1187
1184 check_stat_bounds (&(stats));
1185 pl_level = level;
1186
1187 if (pl_level < 1)
1188 pl_level = 1; /* safety, we should always get 1 levels worth of hp! */ 1188 pl_level = max (1, level); /* safety, we should always get 1 levels worth of hp! */
1189 1189
1190 /* You basically get half a con bonus/level. But we do take into account rounding, 1190 /* You basically get half a con bonus/level. But we do take into account rounding,
1191 * so if your bonus is 7, you still get 7 worth of bonus every 2 levels. 1191 * so if your bonus is 7, you still get 7 worth of bonus every 2 levels.
1192 */ 1192 */
1193 stats.maxhp = 0; 1193 stats.maxhp = 0;
1356 speed *= speed_reduce_from_disease; 1356 speed *= speed_reduce_from_disease;
1357 1357
1358 /* Put a lower limit on speed. Note with this speed, you move once every 1358 /* Put a lower limit on speed. Note with this speed, you move once every
1359 * 25 ticks or so. This amounts to once every 3 seconds of realtime. 1359 * 25 ticks or so. This amounts to once every 3 seconds of realtime.
1360 */ 1360 */
1361 if (speed < 0.04f && type == PLAYER) 1361 max_it (speed, is_player () ? MIN_PLAYER_SPEED : MIN_ACTIVE_SPEED);
1362 speed = 0.04f;
1363 1362
1364 if (speed != old_speed) 1363 if (speed != old_speed)
1365 set_speed (speed); 1364 set_speed (speed);
1366 1365
1367 if (type == PLAYER) 1366 if (type == PLAYER)
1405 move_type &= ~MOVE_WALK; 1404 move_type &= ~MOVE_WALK;
1406 1405
1407 /* It is quite possible that a player's spell costing might have changed, 1406 /* It is quite possible that a player's spell costing might have changed,
1408 * so we will check that now. 1407 * so we will check that now.
1409 */ 1408 */
1410 if (type == PLAYER) 1409 if (is_player ())
1411 { 1410 contr->update_spells ();
1412 esrv_update_stats (contr);
1413 esrv_update_spells (contr);
1414 }
1415 1411
1416 // update the mapspace, if we are on a map 1412 // update the mapspace, if we are on a map
1417 if (!flag [FLAG_REMOVED] && map) 1413 if (!flag [FLAG_REMOVED] && map)
1418 map->at (x, y).flags_ = 0; 1414 map->at (x, y).flags_ = 0;
1419} 1415}
1652 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); 1648 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf);
1653 } 1649 }
1654 } 1650 }
1655 1651
1656 if (changed) 1652 if (changed)
1657 { 1653 who->update_stats (); // should cause esrv_update_stats and esrv_update_spells
1658 who->update_stats ();
1659 esrv_update_stats (who->contr);
1660 /* check if the spell data has changed */
1661 esrv_update_spells (who->contr);
1662 }
1663} 1654}
1664 1655
1665/* 1656/*
1666 * Returns how much experience is needed for a player to become 1657 * Returns how much experience is needed for a player to become
1667 * the given level. level should really never exceed max_level 1658 * the given level. level should really never exceed max_level
1948 1939
1949 for (object *tmp = op->inv; tmp; tmp = tmp->below) 1940 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1950 if (tmp->type == SKILL && tmp->stats.exp) 1941 if (tmp->type == SKILL && tmp->stats.exp)
1951 { 1942 {
1952 percentage_loss = tmp->stats.exp * settings.death_penalty_ratio / 100; 1943 percentage_loss = tmp->stats.exp * settings.death_penalty_ratio / 100;
1953 level_loss = tmp->stats.exp - levels[MAX (0, tmp->level - settings.death_penalty_level)]; 1944 level_loss = tmp->stats.exp - levels [max (0, tmp->level - settings.death_penalty_level)];
1954 1945
1955 /* With the revised exp system, you can get cases where 1946 /* With the revised exp system, you can get cases where
1956 * losing several levels would still require that you have more 1947 * losing several levels would still require that you have more
1957 * exp than you currently have - this is true if the levels 1948 * exp than you currently have - this is true if the levels
1958 * tables is a lot harder. 1949 * tables is a lot harder.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines