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 | |
… | |
… | |
811 | path_repelled = arch->path_repelled; |
810 | path_repelled = arch->path_repelled; |
812 | path_denied = arch->path_denied; |
811 | path_denied = arch->path_denied; |
813 | glow_radius = arch->glow_radius; |
812 | glow_radius = arch->glow_radius; |
814 | move_type = arch->move_type; |
813 | move_type = arch->move_type; |
815 | |
814 | |
816 | chosen_skill = 0; |
815 | object *chosen_skill = 0; |
817 | |
816 | |
818 | /* initializing resistances from the values in player/monster's |
817 | /* initializing resistances from the values in player/monster's |
819 | * archetype clone |
818 | * archetype clone |
820 | */ |
819 | */ |
821 | memcpy (&resist, &arch->resist, sizeof (resist)); |
820 | memcpy (&resist, &arch->resist, sizeof (resist)); |
… | |
… | |
896 | * up, etc. |
895 | * up, etc. |
897 | */ |
896 | */ |
898 | if ((tmp->flag [FLAG_APPLIED] |
897 | if ((tmp->flag [FLAG_APPLIED] |
899 | && tmp->type != CONTAINER |
898 | && tmp->type != CONTAINER |
900 | && tmp->type != CLOSE_CON) |
899 | && tmp->type != CLOSE_CON) |
901 | || (tmp->type == SKILL |
|
|
902 | && tmp->subtype == SK_PRAYING)) |
900 | || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) |
903 | { |
901 | { |
904 | if (type == PLAYER) |
902 | if (type == PLAYER) |
905 | { |
903 | { |
906 | contr->item_power += tmp->item_power; |
904 | contr->item_power += tmp->item_power; |
907 | |
905 | |
… | |
… | |
999 | added_speed += tmp->stats.exp; |
997 | added_speed += tmp->stats.exp; |
1000 | } |
998 | } |
1001 | |
999 | |
1002 | switch (tmp->type) |
1000 | switch (tmp->type) |
1003 | { |
1001 | { |
1004 | #if 0 |
|
|
1005 | case WAND: |
|
|
1006 | case ROD: |
|
|
1007 | case HORN: |
|
|
1008 | if (type != PLAYER || current_weapon == tmp) |
|
|
1009 | chosen_skill = tmp; |
|
|
1010 | break; |
|
|
1011 | #endif |
|
|
1012 | |
|
|
1013 | /* skills modifying the character -b.t. */ |
1002 | /* skills modifying the character -b.t. */ |
1014 | /* for all skills and skill granting objects */ |
1003 | /* for all skills and skill granting objects */ |
1015 | case SKILL: |
1004 | case SKILL: |
1016 | { |
1005 | { |
1017 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) |
1006 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) |
… | |
… | |
1078 | if (tmp->stats.ac) |
1067 | if (tmp->stats.ac) |
1079 | ac -= tmp->stats.ac + tmp->magic; |
1068 | ac -= tmp->stats.ac + tmp->magic; |
1080 | |
1069 | |
1081 | break; |
1070 | break; |
1082 | |
1071 | |
|
|
1072 | case WAND: |
|
|
1073 | case ROD: |
|
|
1074 | case HORN: |
|
|
1075 | case SKILL_TOOL: |
|
|
1076 | if (type != PLAYER) |
|
|
1077 | chosen_skill = find_skill_by_name (this, tmp->skill); |
|
|
1078 | break; |
|
|
1079 | |
1083 | case BOW: |
1080 | case BOW: |
1084 | case WEAPON: |
1081 | case WEAPON: |
1085 | if (type != PLAYER || current_weapon == tmp) |
1082 | if (type != PLAYER || current_weapon == tmp) |
1086 | { |
1083 | { |
|
|
1084 | chosen_skill = find_skill_by_name (this, tmp->skill); |
|
|
1085 | |
1087 | wc -= tmp->stats.wc + tmp->magic; |
1086 | wc -= tmp->stats.wc + tmp->magic; |
1088 | |
1087 | |
1089 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1088 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1090 | ac -= tmp->stats.ac + tmp->magic; |
1089 | ac -= tmp->stats.ac + tmp->magic; |
1091 | |
1090 | |
… | |
… | |
1150 | break; |
1149 | break; |
1151 | } /* switch tmp->type */ |
1150 | } /* switch tmp->type */ |
1152 | } /* item is equipped */ |
1151 | } /* item is equipped */ |
1153 | } /* for loop of items */ |
1152 | } /* for loop of items */ |
1154 | |
1153 | |
|
|
1154 | if (type != PLAYER) |
|
|
1155 | this->chosen_skill = chosen_skill; |
|
|
1156 | |
1155 | glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); |
1157 | glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); |
1156 | |
1158 | |
1157 | /* We've gone through all the objects the player has equipped. For many things, we |
1159 | /* We've gone through all the objects the player has equipped. For many things, we |
1158 | * have generated intermediate values which we now need to assign. |
1160 | * have generated intermediate values which we now need to assign. |
1159 | */ |
1161 | */ |
… | |
… | |
1401 | if (move_type == 0) |
1403 | if (move_type == 0) |
1402 | move_type = MOVE_WALK; |
1404 | move_type = MOVE_WALK; |
1403 | else if (move_type & (MOVE_FLY_LOW | MOVE_FLY_HIGH)) |
1405 | else if (move_type & (MOVE_FLY_LOW | MOVE_FLY_HIGH)) |
1404 | move_type &= ~MOVE_WALK; |
1406 | move_type &= ~MOVE_WALK; |
1405 | |
1407 | |
|
|
1408 | // now apply the new move_type |
|
|
1409 | if (this->move_type != move_type) |
|
|
1410 | change_move_type (move_type); |
|
|
1411 | |
1406 | /* It is quite possible that a player's spell costing might have changed, |
1412 | /* It is quite possible that a player's spell costing might have changed, |
1407 | * so we will check that now. |
1413 | * so we will check that now. |
1408 | */ |
1414 | */ |
1409 | if (is_player ()) |
1415 | if (is_player ()) |
1410 | contr->update_spells (); |
1416 | contr->update_spells (); |
… | |
… | |
1605 | { |
1611 | { |
1606 | changed = true; |
1612 | changed = true; |
1607 | |
1613 | |
1608 | op->level++; |
1614 | op->level++; |
1609 | |
1615 | |
1610 | if (op && op == who && op->stats.exp > 1 && is_dragon_pl (who)) |
1616 | if (op && op == who && op->stats.exp > 1 && who->is_dragon ()) |
1611 | dragon_level_gain (who); |
1617 | dragon_level_gain (who); |
1612 | |
1618 | |
1613 | /* Only roll these if it is the player (who) that gained the level */ |
1619 | /* Only roll these if it is the player (who) that gained the level */ |
1614 | if (op == who && (who->level < 11) && who->type == PLAYER) |
1620 | if (op == who && (who->level < 11) && who->type == PLAYER) |
1615 | { |
1621 | { |