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.102 by root, Wed Nov 11 04:45:22 2009 UTC vs.
Revision 1.108 by root, Fri Mar 26 00:59:20 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
262/* Rather than having a whole bunch of if (flag) new_draw.. else new_draw, 262/* Rather than having a whole bunch of if (flag) new_draw.. else new_draw,
263 * make this macro to clean those up. Not usuable outside change_abil 263 * make this macro to clean those up. Not usuable outside change_abil
264 * function since some of the values passed to new_draw_info are hardcoded. 264 * function since some of the values passed to new_draw_info are hardcoded.
265 */ 265 */
266#define DIFF_MSG(flag, msg1, msg2) \ 266#define DIFF_MSG(flag, msg1, msg2) \
267 new_draw_info(NDI_UNIQUE, 0, op, (flag>0)?msg1:msg2); 267 new_draw_info (NDI_UNIQUE, 0, op, (flag > 0) ? msg1 : msg2);
268 268
269/* return 1 if we sucessfully changed a stat, 0 if nothing was changed. */ 269/* return 1 if we sucessfully changed a stat, 0 if nothing was changed. */
270 270
271/* flag is set to 1 if we are applying the object, -1 if we are removing 271/* flag is set to 1 if we are applying the object, -1 if we are removing
272 * the object. 272 * the object.
415 (op->move_type & MOVE_FLY_LOW ? "You fly lower in the air" : "You float down to the ground.")); 415 (op->move_type & MOVE_FLY_LOW ? "You fly lower in the air" : "You float down to the ground."));
416 } 416 }
417 417
418 if (tmp->move_type & MOVE_SWIM) 418 if (tmp->move_type & MOVE_SWIM)
419 DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming"); 419 DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming");
420
421 /* Changing move status may mean you are affected by things you weren't before */
422 check_move_on (op, op);
423 } 420 }
424 421
425 /* becoming UNDEAD... a special treatment for this flag. Only those not 422 /* becoming UNDEAD... a special treatment for this flag. Only those not
426 * originally undead may change their status 423 * originally undead may change their status
427 */ 424 */
607 { 604 {
608 tmp = present_arch_in_ob (at, this); 605 tmp = present_arch_in_ob (at, this);
609 606
610 if (!tmp) 607 if (!tmp)
611 { 608 {
612 tmp = arch_to_object (at); 609 tmp = at->instance ();
613 tmp = insert_ob_in_ob (tmp, this); 610 tmp = insert_ob_in_ob (tmp, this);
614 SET_FLAG (tmp, FLAG_APPLIED); 611 SET_FLAG (tmp, FLAG_APPLIED);
615 } 612 }
616 } 613 }
617 614
637 if (!tmp) 634 if (!tmp)
638 { 635 {
639 if (!value) 636 if (!value)
640 return; 637 return;
641 638
642 tmp = arch_to_object (at); 639 tmp = at->instance ();
643 tmp = insert_ob_in_ob (tmp, this); 640 tmp = insert_ob_in_ob (tmp, this);
644 SET_FLAG (tmp, FLAG_APPLIED); 641 SET_FLAG (tmp, FLAG_APPLIED);
645 } 642 }
646 643
647 if (value) 644 if (value)
764 int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; 761 int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS];
765 object *grace_obj = NULL, *mana_obj = NULL, *tmp; 762 object *grace_obj = NULL, *mana_obj = NULL, *tmp;
766 float old_speed = speed; 763 float old_speed = speed;
767 int stat_sum [NUM_STATS]; 764 int stat_sum [NUM_STATS];
768 765
766 MoveType move_type; // we use change_move_type to change it, so use a local copy
767
769 /* First task is to clear all the values back to their original values */ 768 /* First task is to clear all the values back to their original values */
770 if (type == PLAYER) 769 if (type == PLAYER)
771 { 770 {
772 contr->delayed_update = false; 771 contr->delayed_update = false;
773 772
911 && !tmp->flag [FLAG_CURSED] 910 && !tmp->flag [FLAG_CURSED]
912 && !tmp->flag [FLAG_DAMNED]) 911 && !tmp->flag [FLAG_DAMNED])
913 continue; 912 continue;
914 913
915 for (int i = 0; i < NUM_STATS; i++) 914 for (int i = 0; i < NUM_STATS; i++)
916 stat_sum [i] = stat_sum [i] + tmp->stats.stat (i); 915 stat_sum [i] += tmp->stats.stat (i);
917 916
918 if (digest_types [tmp->type]) 917 if (digest_types [tmp->type])
919 { 918 {
920 contr->digestion += tmp->stats.food; 919 contr->digestion += tmp->stats.food;
921 contr->gen_hp += tmp->stats.hp; 920 contr->gen_hp += tmp->stats.hp;
1174 1173
1175 if (type == PLAYER) 1174 if (type == PLAYER)
1176 { 1175 {
1177 // clamp various player stats 1176 // clamp various player stats
1178 for (int i = 0; i < NUM_STATS; ++i) 1177 for (int i = 0; i < NUM_STATS; ++i)
1179 stats.stat (i) = clamp (stat_sum [i], MIN_STAT, MAX_STAT); 1178 stats.stat (i) = stat_sum [i];
1179
1180 check_stat_bounds (&stats);
1180 1181
1181 contr->digestion = clamp (contr->digestion, MIN_DIGESTION, MAX_DIGESTION); 1182 contr->digestion = clamp (contr->digestion, MIN_DIGESTION, MAX_DIGESTION);
1182 1183
1183 /* Figure out the players sp/mana/hp totals. */ 1184 /* Figure out the players sp/mana/hp totals. */
1184 int pl_level; 1185 int pl_level;
1185 1186
1186 check_stat_bounds (&(stats));
1187 pl_level = level;
1188
1189 if (pl_level < 1)
1190 pl_level = 1; /* safety, we should always get 1 levels worth of hp! */ 1187 pl_level = max (1, level); /* safety, we should always get 1 levels worth of hp! */
1191 1188
1192 /* You basically get half a con bonus/level. But we do take into account rounding, 1189 /* You basically get half a con bonus/level. But we do take into account rounding,
1193 * so if your bonus is 7, you still get 7 worth of bonus every 2 levels. 1190 * so if your bonus is 7, you still get 7 worth of bonus every 2 levels.
1194 */ 1191 */
1195 stats.maxhp = 0; 1192 stats.maxhp = 0;
1358 speed *= speed_reduce_from_disease; 1355 speed *= speed_reduce_from_disease;
1359 1356
1360 /* Put a lower limit on speed. Note with this speed, you move once every 1357 /* Put a lower limit on speed. Note with this speed, you move once every
1361 * 25 ticks or so. This amounts to once every 3 seconds of realtime. 1358 * 25 ticks or so. This amounts to once every 3 seconds of realtime.
1362 */ 1359 */
1363 if (speed < 0.04f && type == PLAYER) 1360 max_it (speed, is_player () ? MIN_PLAYER_SPEED : MIN_ACTIVE_SPEED);
1364 speed = 0.04f;
1365 1361
1366 if (speed != old_speed) 1362 if (speed != old_speed)
1367 set_speed (speed); 1363 set_speed (speed);
1368 1364
1369 if (type == PLAYER) 1365 if (type == PLAYER)
1404 if (move_type == 0) 1400 if (move_type == 0)
1405 move_type = MOVE_WALK; 1401 move_type = MOVE_WALK;
1406 else if (move_type & (MOVE_FLY_LOW | MOVE_FLY_HIGH)) 1402 else if (move_type & (MOVE_FLY_LOW | MOVE_FLY_HIGH))
1407 move_type &= ~MOVE_WALK; 1403 move_type &= ~MOVE_WALK;
1408 1404
1405 // now apply the new move_type
1406 if (this->move_type != move_type)
1407 change_move_type (move_type);
1408
1409 /* It is quite possible that a player's spell costing might have changed, 1409 /* It is quite possible that a player's spell costing might have changed,
1410 * so we will check that now. 1410 * so we will check that now.
1411 */ 1411 */
1412 if (is_player ()) 1412 if (is_player ())
1413 contr->update_spells (); 1413 contr->update_spells ();
1608 { 1608 {
1609 changed = true; 1609 changed = true;
1610 1610
1611 op->level++; 1611 op->level++;
1612 1612
1613 if (op && op == who && op->stats.exp > 1 && is_dragon_pl (who)) 1613 if (op && op == who && op->stats.exp > 1 && who->is_dragon ())
1614 dragon_level_gain (who); 1614 dragon_level_gain (who);
1615 1615
1616 /* Only roll these if it is the player (who) that gained the level */ 1616 /* Only roll these if it is the player (who) that gained the level */
1617 if (op == who && (who->level < 11) && who->type == PLAYER) 1617 if (op == who && (who->level < 11) && who->type == PLAYER)
1618 { 1618 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines