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.83 by root, Fri May 2 20:16:24 2008 UTC vs.
Revision 1.87 by root, Tue May 6 17:31:21 2008 UTC

279 * that gives them that ability. 279 * that gives them that ability.
280 */ 280 */
281int 281int
282change_abil (object *op, object *tmp) 282change_abil (object *op, object *tmp)
283{ 283{
284 int flag = QUERY_FLAG (tmp, FLAG_APPLIED) ? 1 : -1, success = 0; 284 int flag = tmp->flag [FLAG_APPLIED] ? 1 : -1;
285 int success = 0;
285 char message[MAX_BUF]; 286 char message[MAX_BUF];
286 int potion_max = 0; 287 int potion_max = 0;
287 288
289 // keep some stats for comparison purposes
288 object::flags_t prev_flag = op->flag; 290 object::flags_t prev_flag = op->flag;
289 MoveType prev_move_type = op->move_type; 291 MoveType prev_move_type = op->move_type;
290 sint16 prev_resist [NROFATTACKS]; // clumsy 292 sint16 prev_resist [NROFATTACKS]; // clumsy
291 assert (sizeof (prev_resist) == sizeof (op->resist)); 293 assert (sizeof (prev_resist) == sizeof (op->resist));
292 memcpy (prev_resist, op->resist, sizeof (prev_resist)); 294 memcpy (prev_resist, op->resist, sizeof (prev_resist));
294 if (op->type == PLAYER) 296 if (op->type == PLAYER)
295 { 297 {
296 if (tmp->type == POTION) 298 if (tmp->type == POTION)
297 { 299 {
298 potion_max = 1; 300 potion_max = 1;
301
299 for (int j = 0; j < NUM_STATS; j++) 302 for (int j = 0; j < NUM_STATS; j++)
300 { 303 {
301 int ostat = op->contr->orig_stats.stat (j); 304 int ostat = op->contr->orig_stats.stat (j);
302 int i = tmp->stats.stat (j); 305 int i = tmp->stats.stat (j);
303 306
304 /* nstat is what the stat will be after use of the potion */ 307 /* nstat is what the stat will be after use of the potion */
305 int nstat = flag * i + ostat; 308 int nstat = flag * i + ostat;
306 309
307 /* Do some bounds checking. While I don't think any 310 /* Do some bounds checking. There is the potential for potions
308 * potions do so right now, there is the potential for potions
309 * that adjust that stat by more than one point, so we need 311 * that adjust that stat by more than one point, so we need
310 * to allow for that. 312 * to allow for that.
311 */ 313 */
312 if (nstat < 1 && i * flag < 0) 314 if (nstat < 1 && i * flag < 0)
313 nstat = 1; 315 nstat = 1;
398 /* MOVE_FLY_HIGH trumps MOVE_FLY_LOW - changing your move_fly_low 400 /* MOVE_FLY_HIGH trumps MOVE_FLY_LOW - changing your move_fly_low
399 * status doesn't make a difference if you are flying high 401 * status doesn't make a difference if you are flying high
400 */ 402 */
401 if (tmp->move_type & MOVE_FLY_LOW && !(op->move_type & MOVE_FLY_HIGH)) 403 if (tmp->move_type & MOVE_FLY_LOW && !(op->move_type & MOVE_FLY_HIGH))
402 { 404 {
403 DIFF_MSG (flag, "You start to float in the air!.", "You float down to the ground."); 405 DIFF_MSG (flag, "You start to float in the air!", "You float down to the ground.");
404 } 406 }
405 407
406 if (tmp->move_type & MOVE_FLY_HIGH) 408 if (tmp->move_type & MOVE_FLY_HIGH)
407 { 409 {
408 /* double conditional - second case covers if you have move_fly_low - 410 /* double conditional - second case covers if you have move_fly_low -
566 new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, op, message); 568 new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, op, message);
567 } 569 }
568 } 570 }
569 571
570 if (!potion_max) 572 if (!potion_max)
571 {
572 for (int j = 0; j < NUM_STATS; j++) 573 for (int j = 0; j < NUM_STATS; j++)
573 {
574 if (int i = tmp->stats.stat (j)) 574 if (int i = tmp->stats.stat (j))
575 { 575 {
576 success = 1; 576 success = 1;
577 DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]); 577 DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]);
578 } 578 }
579 }
580 }
581 579
582 return success; 580 return success;
583} 581}
584 582
585/* 583/*
863 continue; 861 continue;
864 862
865 /* See note in map.c:update_position about making this additive 863 /* See note in map.c:update_position about making this additive
866 * since light sources are never applied, need to put check here. 864 * since light sources are never applied, need to put check here.
867 */ 865 */
868 if (tmp->glow_radius > glow_radius)
869 glow_radius = tmp->glow_radius; 866 glow_radius = max (glow_radius, tmp->glow_radius);
870 867
871 /* For some things, we don't care what is equipped */ 868 /* For some things, we don't care what is equipped */
872 if (tmp->type == SKILL) 869 if (tmp->type == SKILL)
873 { 870 {
874 /* Want to take the highest skill here. */ 871 /* Want to take the highest skill here. */
887 else if (tmp->level > grace_obj->level) 884 else if (tmp->level > grace_obj->level)
888 grace_obj = tmp; 885 grace_obj = tmp;
889 } 886 }
890 } 887 }
891 888
892 /* Container objects are not meant to adjust a players, but other applied 889 /* Container objects are not meant to adjust players, but other applied
893 * objects need to make adjustments. 890 * objects need to make adjustments.
894 * This block should handle all player specific changes 891 * This block should handle all player specific changes
895 * The check for Praying is a bit of a hack - god given bonuses are put 892 * The check for Praying is a bit of a hack - god given bonuses are put
896 * in the praying skill, and the player should always get those. 893 * in the praying skill, and the player should always get those.
897 * It also means we need to put in additional checks for applied below, 894 * It also means we need to put in additional checks for applied below,
920 917
921 if (digest_types [tmp->type]) 918 if (digest_types [tmp->type])
922 { 919 {
923 contr->digestion += tmp->stats.food; 920 contr->digestion += tmp->stats.food;
924 contr->gen_hp += tmp->stats.hp; 921 contr->gen_hp += tmp->stats.hp;
922 if (tmp->type != BOW) // ugly exception for bows
925 contr->gen_sp += tmp->stats.sp; 923 contr->gen_sp += tmp->stats.sp;
926 contr->gen_grace += tmp->stats.grace; 924 contr->gen_grace += tmp->stats.grace;
927 contr->gen_sp_armour += tmp->gen_sp_armour; 925 contr->gen_sp_armour += tmp->gen_sp_armour;
928 } 926 }
929 } /* if this is a player */ 927 } /* if this is a player */
930 else 928 else
940 938
941 if (tmp->type == SYMPTOM) 939 if (tmp->type == SYMPTOM)
942 speed_reduce_from_disease = 940 speed_reduce_from_disease =
943 min (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); 941 min (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f);
944 942
945 /* Pos. and neg. protections are counted seperate (-> pro/vuln). 943 /* Pos. and neg. protections are counted separate (-> pro/vuln).
946 * (Negative protections are calculated exactly like positive.) 944 * (Negative protections are calculated exactly like positive.)
947 * Resistance from potions are treated special as well. If there's 945 * Resistance from potions are treated special as well. If there's
948 * more than one potion-effect, the bigger prot.-value is taken. 946 * more than one potion-effect, the bigger prot.-value is taken.
949 */ 947 */
950 if (tmp->type != POTION) 948 if (tmp->type != POTION)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines