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.84 by root, Fri May 2 20:24:48 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;
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/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines