ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/attack.C
(Generate patch)

Comparing deliantra/server/server/attack.C (file contents):
Revision 1.134 by root, Mon Apr 5 02:05:32 2010 UTC vs.
Revision 1.150 by root, Wed Nov 16 23:42:02 2016 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,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 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.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25#include <assert.h> 25#include <assert.h>
26#include <global.h> 26#include <global.h>
27#include <living.h> 27#include <living.h>
28#include <material.h> 28#include <material.h>
29#include <skills.h> 29#include <skills.h>
30#include <sounds.h> 30#include <sounds.h>
31#include <sproto.h> 31#include <sproto.h>
32
33typedef struct att_msg_str
34{
35 char *msg1;
36 char *msg2;
37} att_msg;
38 32
39/*#define ATTACK_DEBUG*/ 33/*#define ATTACK_DEBUG*/
40 34
41/* did_make_save_item just checks to make sure the item actually 35/* did_make_save_item just checks to make sure the item actually
42 * made its saving throw based on the tables. It does not take 36 * made its saving throw based on the tables. It does not take
101cancellation (object *op) 95cancellation (object *op)
102{ 96{
103 if (op->invisible) 97 if (op->invisible)
104 return; 98 return;
105 99
106 if (QUERY_FLAG (op, FLAG_ALIVE) || op->type == CONTAINER || op->type == THROWN_OBJ) 100 if (op->flag [FLAG_ALIVE] || op->type == CONTAINER || op->type == THROWN_OBJ)
107 { 101 {
108 /* Recurse through the inventory */ 102 /* Recurse through the inventory */
109 for (object *tmp = op->inv; tmp; tmp = tmp->below) 103 for (object *tmp = op->inv; tmp; tmp = tmp->below)
110 if (!did_make_save_item (tmp, AT_CANCELLATION, op)) 104 if (!did_make_save_item (tmp, AT_CANCELLATION, op))
111 cancellation (tmp); 105 cancellation (tmp);
114 { 108 {
115 /* Nullify this object. This code could probably be more complete */ 109 /* Nullify this object. This code could probably be more complete */
116 /* in what abilities it should cancel */ 110 /* in what abilities it should cancel */
117 op->magic = 0; 111 op->magic = 0;
118 112
119 CLEAR_FLAG (op, FLAG_DAMNED); 113 op->clr_flag (FLAG_DAMNED);
120 CLEAR_FLAG (op, FLAG_CURSED); 114 op->clr_flag (FLAG_CURSED);
121 CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); 115 op->clr_flag (FLAG_KNOWN_MAGICAL);
122 CLEAR_FLAG (op, FLAG_KNOWN_CURSED); 116 op->clr_flag (FLAG_KNOWN_CURSED);
123 117
124 if (object *pl = op->visible_to ()) 118 if (object *pl = op->visible_to ())
125 esrv_update_item (UPD_FLAGS, pl, op); 119 esrv_update_item (UPD_FLAGS, pl, op);
126 } 120 }
127} 121}
215 209
216 return; 210 return;
217 } 211 }
218 212
219 /* The value of 50 is arbitrary. */ 213 /* The value of 50 is arbitrary. */
220 if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && rndm (2)) 214 if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !op->flag [FLAG_NO_PICK] && rndm (2))
221 { 215 {
222 archetype *at = archetype::find (shstr_icecube); 216 archetype *at = archetype::find (shstr_icecube);
223 217
224 if (at == NULL) 218 if (at == NULL)
225 return; 219 return;
254 * returns 1 if it hits something, 0 otherwise. 248 * returns 1 if it hits something, 0 otherwise.
255 */ 249 */
256int 250int
257hit_map (object *op, int dir, uint32_t type, int full_hit) 251hit_map (object *op, int dir, uint32_t type, int full_hit)
258{ 252{
259 maptile *map;
260 sint16 x, y; 253 sint16 x, y;
261 int retflag = 0; /* added this flag.. will return 1 if it hits a monster */ 254 int retflag = 0; /* added this flag.. will return 1 if it hits a monster */
262 255
263 if (QUERY_FLAG (op, FLAG_FREED)) 256 if (op->flag [FLAG_FREED])
264 { 257 {
265 LOG (llevError, "BUG: hit_map(): free object\n"); 258 LOG (llevError, "BUG: hit_map(): free object\n");
266 return 0; 259 return 0;
267 } 260 }
268 261
269 if (QUERY_FLAG (op, FLAG_REMOVED) || op->env != NULL) 262 if (op->flag [FLAG_REMOVED] || op->env != NULL)
270 { 263 {
271 LOG (llevError, "BUG: hit_map(): hitter (arch %s, name %s) not on a map\n", &op->arch->archname, &op->name); 264 LOG (llevError, "BUG: hit_map(): hitter (arch %s, name %s) not on a map\n", &op->arch->archname, &op->name);
272 return 0; 265 return 0;
273 } 266 }
274 267
338 * This is one of the few cases where on_same_map should not be used. 331 * This is one of the few cases where on_same_map should not be used.
339 */ 332 */
340 if (tmp->map != pos.m || tmp->x != pos.x || tmp->y != pos.y) 333 if (tmp->map != pos.m || tmp->x != pos.x || tmp->y != pos.y)
341 continue; 334 continue;
342 335
343 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 336 if (tmp->flag [FLAG_ALIVE])
344 { 337 {
345 hit_player (tmp, op->stats.dam, op, type, full_hit); 338 hit_player (tmp, op->stats.dam, op, type, full_hit);
346 retflag |= 1; 339 retflag |= 1;
347 340
348 if (op->destroyed ()) 341 if (op->destroyed ())
364 if (op->destroyed ()) 357 if (op->destroyed ())
365 break; 358 break;
366 } 359 }
367 } 360 }
368 361
369 return 0; 362 return retflag;
370} 363}
371 364
372static void 365static void
373attack_message (int dam, int type, object *op, object *hitter) 366attack_message (int dam, int type, object *op, object *hitter)
374{ 367{
648} 641}
649 642
650static int 643static int
651get_attack_mode (object **target, object **hitter, int *simple_attack) 644get_attack_mode (object **target, object **hitter, int *simple_attack)
652{ 645{
653 if (QUERY_FLAG (*target, FLAG_FREED) || QUERY_FLAG (*hitter, FLAG_FREED)) 646 if ((*target)->flag [FLAG_FREED] || (*hitter)->flag [FLAG_FREED])
654 { 647 {
655 LOG (llevError, "BUG: get_attack_mode(): freed object\n"); 648 LOG (llevError, "BUG: get_attack_mode(): freed object\n");
656 return 1; 649 return 1;
657 } 650 }
658 651
666 { 659 {
667 *simple_attack = 1; 660 *simple_attack = 1;
668 return 0; 661 return 0;
669 } 662 }
670 663
671 if (QUERY_FLAG (*target, FLAG_REMOVED) 664 if ((*target)->flag [FLAG_REMOVED]
672 || QUERY_FLAG (*hitter, FLAG_REMOVED) 665 || (*hitter)->flag [FLAG_REMOVED]
673 || !(*hitter)->map 666 || !(*hitter)->map
674 || !on_same_map (*hitter, *target)) 667 || !on_same_map (*hitter, *target))
675 { 668 {
676 LOG (llevError | logBacktrace, "BUG: hitter (%s) with no relation to target (%s)\n", 669 LOG (llevError | logBacktrace, "BUG: hitter (%s) with no relation to target (%s)\n",
677 (*hitter)->debug_desc (), (*target)->debug_desc ()); 670 (*hitter)->debug_desc (), (*target)->debug_desc ());
690 */ 683 */
691 int new_mode; 684 int new_mode;
692 685
693 if (hitter->env == target || target->env == hitter) 686 if (hitter->env == target || target->env == hitter)
694 new_mode = 1; 687 new_mode = 1;
695 else if (QUERY_FLAG (hitter, FLAG_REMOVED) || QUERY_FLAG (target, FLAG_REMOVED) 688 else if (hitter->flag [FLAG_REMOVED] || target->flag [FLAG_REMOVED]
696 || hitter->map == NULL || !on_same_map (hitter, target)) 689 || hitter->map == NULL || !on_same_map (hitter, target))
697 return 1; 690 return 1;
698 else 691 else
699 new_mode = 0; 692 new_mode = 0;
700 693
706 * monster). 699 * monster).
707 */ 700 */
708static void 701static void
709thrown_item_effect (object *hitter, object *victim) 702thrown_item_effect (object *hitter, object *victim)
710{ 703{
711 if (!QUERY_FLAG (hitter, FLAG_ALIVE)) 704 if (!hitter->flag [FLAG_ALIVE])
712 { 705 {
713 /* May not need a switch for just 2 types, but this makes it 706 /* May not need a switch for just 2 types, but this makes it
714 * easier for expansion. 707 * easier for expansion.
715 */ 708 */
716 switch (hitter->type) 709 switch (hitter->type)
717 { 710 {
718 case POTION: 711 case POTION:
719 /* should player get a save throw instead of checking magic protection? */ 712 /* should player get a save throw instead of checking magic protection? */
720 if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_UNDEAD) && (victim->resist[ATNR_MAGIC] < 60)) 713 if (victim->flag [FLAG_ALIVE] && !victim->flag [FLAG_UNDEAD] && (victim->resist[ATNR_MAGIC] < 60))
721 apply_potion (victim, hitter); 714 apply_potion (victim, hitter);
722 break; 715 break;
723 716
724 case POISON: /* poison drinks */ 717 case POISON: /* poison drinks */
725 /* As with potions, should monster get a save? */ 718 /* As with potions, should monster get a save? */
726 if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_UNDEAD) && (victim->resist[ATNR_POISON] < 60)) 719 if (victim->flag [FLAG_ALIVE] && !victim->flag [FLAG_UNDEAD] && (victim->resist[ATNR_POISON] < 60))
727 apply_poison (victim, hitter); 720 apply_poison (victim, hitter);
728 break; 721 break;
729 722
730 /* Removed case statements that did nothing. 723 /* Removed case statements that did nothing.
731 * food may be poisonous, but monster must be willing to eat it, 724 * food may be poisonous, but monster must be willing to eat it,
771 if ((attacker = hitter->owner) == NULL) 764 if ((attacker = hitter->owner) == NULL)
772 attacker = hitter; 765 attacker = hitter;
773 /* A player who saves but hasn't quit still could have objects 766 /* A player who saves but hasn't quit still could have objects
774 * owned by him - need to handle that case to avoid crashes. 767 * owned by him - need to handle that case to avoid crashes.
775 */ 768 */
776 if (QUERY_FLAG (attacker, FLAG_REMOVED)) 769 if (attacker->flag [FLAG_REMOVED])
777 attacker = hitter; 770 attacker = hitter;
778 } 771 }
779 else if (!QUERY_FLAG (hitter, FLAG_ALIVE)) 772 else if (!hitter->flag [FLAG_ALIVE])
780 return 0; 773 return 0;
781 774
782 /* determine the condtions under which we make an attack. 775 /* determine the condtions under which we make an attack.
783 * Add more cases, as the need occurs. */ 776 * Add more cases, as the need occurs. */
784 777
785 if (!can_see_enemy (attacker, target)) 778 if (!can_see_enemy (attacker, target))
786 { 779 {
787 /* target is unseen */ 780 /* target is unseen */
788 if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) 781 if (target->invisible || attacker->flag [FLAG_BLIND])
789 adjust -= 10; 782 adjust -= 10;
790 /* dark map penalty for the hitter (lacks infravision if we got here). */ 783 /* dark map penalty for the hitter (lacks infravision if we got here). */
791 else if (!stand_in_light (target)) 784 else if (!stand_in_light (target))
792 adjust -= target->map->darklevel (); 785 adjust -= target->map->darklevel ();
793 } 786 }
794 787
795 if (QUERY_FLAG (attacker, FLAG_SCARED)) 788 if (attacker->flag [FLAG_SCARED])
796 adjust -= 3; 789 adjust -= 3;
797 790
798 if (QUERY_FLAG (target, FLAG_UNAGGRESSIVE)) 791 if (target->flag [FLAG_UNAGGRESSIVE])
799 adjust += 1; 792 adjust += 1;
800 793
801 if (QUERY_FLAG (target, FLAG_SCARED)) 794 if (target->flag [FLAG_SCARED])
802 adjust += 1; 795 adjust += 1;
803 796
804 if (QUERY_FLAG (attacker, FLAG_CONFUSED)) 797 if (attacker->flag [FLAG_CONFUSED])
805 adjust -= 3; 798 adjust -= 3;
806 799
807 /* if we attack at a different 'altitude' its harder */ 800 /* if we attack at a different 'altitude' its harder */
808 if ((attacker->move_type & target->move_type) == 0) 801 if ((attacker->move_type & target->move_type) == 0)
809 adjust -= 2; 802 adjust -= 2;
845 838
846 /* 839 /*
847 * A little check to make it more difficult to dance forward and back 840 * A little check to make it more difficult to dance forward and back
848 * to avoid ever being hit by monsters. 841 * to avoid ever being hit by monsters.
849 */ 842 */
850 if (!simple_attack && QUERY_FLAG (op, FLAG_MONSTER) && op->speed_left > op->speed * -0.3f) 843 if (!simple_attack && op->flag [FLAG_MONSTER] && op->speed_left > op->speed * -0.3f)
851 { 844 {
852 /* Decrease speed BEFORE calling process_object. Otherwise, an 845 /* Decrease speed BEFORE calling process_object. Otherwise, an
853 * infinite loop occurs, with process_object calling move_monster, 846 * infinite loop occurs, with process_object calling move_monster,
854 * which then gets here again. By decreasing the speed before 847 * which then gets here again. By decreasing the speed before
855 * we call process_object, the 'if' statement above will fail. 848 * we call process_object, the 'if' statement above will fail.
877 if (!simple_attack) 870 if (!simple_attack)
878 { 871 {
879 /* If you hit something, the victim should *always* wake up. 872 /* If you hit something, the victim should *always* wake up.
880 * Before, invisible hitters could avoid doing this. 873 * Before, invisible hitters could avoid doing this.
881 * -b.t. */ 874 * -b.t. */
882 if (QUERY_FLAG (op, FLAG_SLEEP)) 875 if (op->flag [FLAG_SLEEP])
883 CLEAR_FLAG (op, FLAG_SLEEP); 876 op->clr_flag (FLAG_SLEEP);
884 877
885 /* If the victim can't see the attacker, it may alert others 878 /* If the victim can't see the attacker, it may alert others
886 * for help. */ 879 * for help. */
887 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int)) 880 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int))
888 npc_call_help (op); 881 npc_call_help (op);
908 } 901 }
909 902
910 /* Need to do at least 1 damage, otherwise there is no point 903 /* Need to do at least 1 damage, otherwise there is no point
911 * to go further and it will cause FPE's below. 904 * to go further and it will cause FPE's below.
912 */ 905 */
913 if (hitdam <= 0) 906 max_it (hitdam, 1);
914 hitdam = 1;
915 907
916 type = hitter->attacktype; 908 type = hitter->attacktype;
917 909
918 /* Ok, because some of the brainfucks of the good *sigh* old *sigh* 910 /* Ok, because some of the brainfucks of the good *sigh* old *sigh*
919 * Crossfire we have to default the attacktype here to AT_PHYSICAL. 911 * Crossfire we have to default the attacktype here to AT_PHYSICAL.
927 */ 919 */
928 if (!type) 920 if (!type)
929 type = AT_PHYSICAL; 921 type = AT_PHYSICAL;
930 922
931 /* Handle monsters that hit back */ 923 /* Handle monsters that hit back */
932 if (!simple_attack && QUERY_FLAG (op, FLAG_HITBACK) && QUERY_FLAG (hitter, FLAG_ALIVE)) 924 if (!simple_attack && op->flag [FLAG_HITBACK] && hitter->flag [FLAG_ALIVE])
933 { 925 {
934 if (op->attacktype & AT_ACID && hitter->type == PLAYER) 926 if (op->attacktype & AT_ACID && hitter->type == PLAYER)
935 new_draw_info (NDI_UNIQUE, 0, hitter, "You are splashed by acid!\n"); 927 new_draw_info (NDI_UNIQUE, 0, hitter, "You are splashed by acid!\n");
936 928
937 hit_player (hitter, random_roll (0, (op->stats.dam), hitter, PREFER_LOW), op, op->attacktype, 1); 929 hit_player (hitter, random_roll (0, (op->stats.dam), hitter, PREFER_LOW), op, op->attacktype, 1);
963} 955}
964 956
965int 957int
966attack_ob (object *op, object *hitter) 958attack_ob (object *op, object *hitter)
967{ 959{
968 hitter = hitter->head_ ();
969
970 return attack_ob_simple (op, hitter, hitter->stats.dam, hitter->stats.wc); 960 return attack_ob_simple (op, hitter->head_ (), hitter->stats.dam, hitter->stats.wc);
971} 961}
972 962
973/* op is the arrow, tmp is what is stopping the arrow. 963/* op is the arrow, tmp is what is stopping the arrow.
974 * 964 *
975 * Returns 1 if op was inserted into tmp's inventory, 0 otherwise. 965 * Returns 1 if op was inserted into tmp's inventory, 0 otherwise.
1028 * arrow, move_apply() calls this function, arrow sticks in demon, 1018 * arrow, move_apply() calls this function, arrow sticks in demon,
1029 * attack_ob_simple() returns, and we've got an arrow that still exists 1019 * attack_ob_simple() returns, and we've got an arrow that still exists
1030 * but is no longer on the map. Ugh. (Beware: Such things can happen at 1020 * but is no longer on the map. Ugh. (Beware: Such things can happen at
1031 * other places as well!) 1021 * other places as well!)
1032 */ 1022 */
1033 if (hitter->destroyed () || hitter->env != NULL) 1023 if (hitter->destroyed () || hitter->env)
1034 { 1024 {
1035 if (container) 1025 if (container)
1036 container->destroy (); 1026 container->destroy ();
1037 1027
1038 return 0; 1028 return 0;
1039 } 1029 }
1040 1030
1041 /* Missile hit victim */ 1031 /* Missile hit victim */
1042 /* if the speed is > 10, then this is a fast moving arrow, we go straight 1032 /* if the speed is >= 10, then this is a fast moving arrow, we go straight
1043 * through the target 1033 * through the target
1044 */ 1034 */
1045 if (hit_something && op->speed <= 10.0) 1035 if (hit_something)
1036 if (op->speed < 10.0)
1046 { 1037 {
1047 /* Stop arrow */ 1038 /* Stop arrow */
1048 if (!container) 1039 if (!container)
1049 { 1040 {
1050 hitter = fix_stopped_arrow (hitter); 1041 hitter = fix_stopped_arrow (hitter);
1051 if (!hitter) 1042 if (!hitter)
1052 return 0; 1043 return 0;
1053 } 1044 }
1054 else 1045 else
1055 container->destroy (); 1046 container->destroy ();
1056 1047
1057 /* Try to stick arrow into victim */ 1048 /* Try to stick arrow into victim */
1058 if (!victim->destroyed () && stick_arrow (hitter, victim)) 1049 if (!victim->destroyed () && stick_arrow (hitter, victim))
1050 return 0;
1051
1052 /* Else try to put arrow on victim's map square
1053 * remove check for P_WALL here. If the arrow got to this
1054 * space, that is good enough - with the new movement code,
1055 * there is now the potential for lots of spaces where something
1056 * can fly over but not otherwise move over. What is the correct
1057 * way to handle those otherwise?
1058 */
1059 if (victim->x != hitter->x || victim->y != hitter->y)
1060 {
1061 if (victim->destroyed ())
1062 hitter->destroy ();
1063 else
1064 {
1065 hitter->remove ();
1066 hitter->x = victim->x;
1067 hitter->y = victim->y;
1068 insert_ob_in_map (hitter, victim->map, hitter, 0);
1069 }
1070 }
1071 else
1072 /* Else leave arrow where it is */
1073 merge_ob (hitter, NULL);
1074
1059 return 0; 1075 return 0;
1060
1061 /* Else try to put arrow on victim's map square
1062 * remove check for P_WALL here. If the arrow got to this
1063 * space, that is good enough - with the new movement code,
1064 * there is now the potential for lots of spaces where something
1065 * can fly over but not otherwise move over. What is the correct
1066 * way to handle those otherwise?
1067 */
1068 if (victim->x != hitter->x || victim->y != hitter->y)
1069 {
1070 if (victim->destroyed ())
1071 hitter->destroy ();
1072 else
1073 {
1074 hitter->remove ();
1075 hitter->x = victim->x;
1076 hitter->y = victim->y;
1077 insert_ob_in_map (hitter, victim->map, hitter, 0);
1078 }
1079 } 1076 }
1080 else 1077 else
1081 /* Else leave arrow where it is */ 1078 op->set_speed (op->speed - 1.f);
1082 merge_ob (hitter, NULL);
1083
1084 return 0;
1085 }
1086
1087 if (hit_something && op->speed >= 10.0)
1088 op->speed -= 1.0;
1089 1079
1090 /* Missile missed victim - reassemble missile */ 1080 /* Missile missed victim - reassemble missile */
1091 if (container) 1081 if (container)
1092 { 1082 {
1093 hitter->remove (); 1083 hitter->remove ();
1161 * MSW 2002-07-17 1151 * MSW 2002-07-17
1162 */ 1152 */
1163int 1153int
1164kill_object (object *op, int dam, object *hitter, int type) 1154kill_object (object *op, int dam, object *hitter, int type)
1165{ 1155{
1166 char buf[MAX_BUF];
1167 shstr skill; 1156 shstr skill;
1168 int maxdam = 0; 1157 int maxdam = 0;
1169 int battleg = 0; /* true if op standing on battleground */ 1158 int battleg = 0; /* true if op standing on battleground */
1170 int pk = 0; /* true if op and what controls hitter are both players */ 1159 int pk = 0; /* true if op and what controls hitter are both players */
1171 object *owner = 0; 1160 object *owner = 0;
1181 * this creature. The function(s) that call us have already 1170 * this creature. The function(s) that call us have already
1182 * adjusted the creatures HP total, so that is negative. 1171 * adjusted the creatures HP total, so that is negative.
1183 */ 1172 */
1184 maxdam = dam + op->stats.hp + 1; 1173 maxdam = dam + op->stats.hp + 1;
1185 1174
1186 if (QUERY_FLAG (op, FLAG_BLOCKSVIEW)) 1175 if (op->flag [FLAG_BLOCKSVIEW])
1187 update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */ 1176 update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */
1188 1177
1189 if (op->type == DOOR) 1178 if (op->type == DOOR)
1190 { 1179 {
1191 op->set_speed (0.1f); 1180 op->set_speed (0.1f);
1192 op->speed_left = -0.05f; 1181 op->speed_left = -0.05f;
1193 return maxdam; 1182 return maxdam;
1194 } 1183 }
1195 1184
1196 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) 1185 if (op->flag [FLAG_FRIENDLY] && op->type != PLAYER)
1197 { 1186 {
1198 op->drop_and_destroy (); 1187 op->drop_and_destroy ();
1199 return maxdam; 1188 return maxdam;
1200 } 1189 }
1201 1190
1268 else if (owner->chosen_skill) 1257 else if (owner->chosen_skill)
1269 { 1258 {
1270 skop = owner->chosen_skill; 1259 skop = owner->chosen_skill;
1271 skill = skop->skill; 1260 skill = skop->skill;
1272 } 1261 }
1273 else if (QUERY_FLAG (owner, FLAG_READY_WEAPON) && owner->current_weapon) 1262 else if (owner->flag [FLAG_READY_WEAPON] && owner->current_weapon)
1274 skill = owner->current_weapon->skill; 1263 skill = owner->current_weapon->skill;
1275 else 1264 else
1276 { 1265 {
1266 LOG (llevError | logBacktrace,
1277 LOG (llevError, "BUG: kill_object - unable to find skill that killed monster\n" 1267 "BUG: kill_object - unable to find skill that killed monster\n"
1278 "op: %s\n" "hitter: %s\n" "owner: %s\n", 1268 "op: %s\n" "hitter: %s\n" "op: %s\n",
1279 owner->debug_desc (), hitter->debug_desc (), op->debug_desc ()); 1269 op->debug_desc (), hitter->debug_desc (), op->debug_desc ());
1280 skill = 0; 1270 skill = 0;
1281 } 1271 }
1282 1272
1283 /* We have the skill we want to credit to - now find the object this goes 1273 /* We have the skill we want to credit to - now find the object this goes
1284 * to. Make sure skop is an actual skill, and not a skill tool! 1274 * to. Make sure skop is an actual skill, and not a skill tool!
1294 1284
1295 if (!skill && skop) 1285 if (!skill && skop)
1296 skill = skop->skill; 1286 skill = skop->skill;
1297 1287
1298 /* If you didn't kill yourself, and your not the wizard */ 1288 /* If you didn't kill yourself, and your not the wizard */
1299 if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) 1289 if (owner != op && !op->flag [FLAG_WIZ])
1300 { 1290 {
1301 int exp; 1291 int exp;
1302 1292
1303 /* Really don't give much experience for killing other players */ 1293 /* Really don't give much experience for killing other players */
1304 // schmorp: temporarily? reduce the amount of exp gained for pking enourmously 1294 // schmorp: temporarily? reduce the amount of exp gained for pking enourmously
1361 } /* else part of a party */ 1351 } /* else part of a party */
1362 } /* end if person didn't kill himself */ 1352 } /* end if person didn't kill himself */
1363 1353
1364 if (op->type != PLAYER) 1354 if (op->type != PLAYER)
1365 { 1355 {
1366 if (QUERY_FLAG (op, FLAG_FRIENDLY)) 1356 if (op->flag [FLAG_FRIENDLY])
1367 { 1357 {
1368 object *owner1 = op->owner; 1358 object *owner1 = op->owner;
1369 1359
1370 if (owner1 && owner1->type == PLAYER) 1360 if (owner1 && owner1->type == PLAYER)
1371 { 1361 {
1436int 1426int
1437hit_player (object *op, int dam, object *hitter, uint32_t type, int full_hit) 1427hit_player (object *op, int dam, object *hitter, uint32_t type, int full_hit)
1438{ 1428{
1439 int magic = type & AT_MAGIC; 1429 int magic = type & AT_MAGIC;
1440 int body_attack = op && op->head; /* Did we hit op's head? */ 1430 int body_attack = op && op->head; /* Did we hit op's head? */
1441 int maxdam = 0, ndam = 0, attacktype = 1; 1431 int maxdam = 0, ndam = 0;
1442 int maxattacktype; 1432 int maxattacktype;
1443 int simple_attack; 1433 int simple_attack;
1444 int rtn_kill = 0; 1434 int rtn_kill = 0;
1445 int friendlyfire; 1435 int friendlyfire;
1446 1436
1447 if (get_attack_mode (&op, &hitter, &simple_attack)) 1437 if (get_attack_mode (&op, &hitter, &simple_attack))
1448 return 0; 1438 return 0;
1449 1439
1450 /* very simple: if our target has no_damage 1 set or is wiz, we can't hurt him */ 1440 /* very simple: if our target has no_damage 1 set or is wiz, we can't hurt him */
1451 if (QUERY_FLAG (op, FLAG_WIZ) || QUERY_FLAG (op, FLAG_NO_DAMAGE)) 1441 if (op->flag [FLAG_WIZ] || op->flag [FLAG_NO_DAMAGE])
1452 return 0; 1442 return 0;
1453 1443
1454 // only allow pk for hostile players 1444 // only allow pk for hostile players
1455 if (op->type == PLAYER) 1445 if (op->type == PLAYER)
1456 { 1446 {
1498 1488
1499 break; 1489 break;
1500 } 1490 }
1501 } 1491 }
1502 1492
1503 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) 1493 if (!op->flag [FLAG_ALIVE] || op->stats.hp < 0)
1504 { 1494 {
1505 /* FIXME: If a player is killed by a rune in a door, the 1495 /* FIXME: If a player is killed by a rune in a door, the
1506 * destroyed() check above doesn't return, and might get here. 1496 * destroyed() check above doesn't return, and might get here.
1507 */ 1497 */
1508 1498
1549 object *god; 1539 object *god;
1550 1540
1551 if ((!hitter->slaying 1541 if ((!hitter->slaying
1552 || (!(op->race && hitter->slaying.contains (op->race)) 1542 || (!(op->race && hitter->slaying.contains (op->race))
1553 && !(op->name && hitter->slaying.contains (op->name)))) 1543 && !(op->name && hitter->slaying.contains (op->name))))
1554 && (!QUERY_FLAG (op, FLAG_UNDEAD) 1544 && (!op->flag [FLAG_UNDEAD]
1555 || (hitter->title 1545 || (hitter->title
1556 && (god = find_god (determine_god (hitter))) != NULL 1546 && (god = find_god (determine_god (hitter))) != NULL
1557 && god->race.contains (shstr_undead)))) 1547 && god->race.contains (shstr_undead))))
1558 return 0; 1548 return 0;
1559 } 1549 }
1631 // keep a refcount for a long time and I see no usefulness 1621 // keep a refcount for a long time and I see no usefulness
1632 // for an non-active objetc to know its enemy. 1622 // for an non-active objetc to know its enemy.
1633 if (op->active) 1623 if (op->active)
1634 if (hitter->owner) 1624 if (hitter->owner)
1635 op->enemy = hitter->owner; 1625 op->enemy = hitter->owner;
1636 else if (QUERY_FLAG (hitter, FLAG_ALIVE)) 1626 else if (hitter->flag [FLAG_ALIVE])
1637 op->enemy = hitter; 1627 op->enemy = hitter;
1638 1628
1639 if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) 1629 if (op->flag [FLAG_UNAGGRESSIVE] && op->type != PLAYER)
1640 { 1630 {
1641 /* The unaggressives look after themselves 8) */ 1631 /* The unaggressives look after themselves 8) */
1642 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE); 1632 op->clr_flag (FLAG_UNAGGRESSIVE);
1643 npc_call_help (op); 1633 npc_call_help (op);
1644 } 1634 }
1645 1635
1646 if (magic && did_make_save (op, op->level, 0)) 1636 if (magic && did_make_save (op, op->level, 0))
1647 maxdam = maxdam / 2; 1637 maxdam = maxdam / 2;
1650 1640
1651 op->stats.hp -= maxdam; 1641 op->stats.hp -= maxdam;
1652 1642
1653 /* Eneq(@csd.uu.se): Check to see if monster runs away. */ 1643 /* Eneq(@csd.uu.se): Check to see if monster runs away. */
1654 if (op->stats.hp >= 0 1644 if (op->stats.hp >= 0
1655 && (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) 1645 && (op->flag [FLAG_MONSTER] || op->type == PLAYER)
1656 && op->stats.hp * 100 < op->stats.maxhp * op->run_away) 1646 && op->stats.hp * 100 < op->stats.maxhp * op->run_away)
1657 { 1647 {
1658 1648
1659 if (QUERY_FLAG (op, FLAG_MONSTER)) 1649 if (op->flag [FLAG_MONSTER])
1660 SET_FLAG (op, FLAG_RUN_AWAY); 1650 op->set_flag (FLAG_RUN_AWAY);
1661 else 1651 else
1662 scare_creature (op, hitter); 1652 scare_creature (op, hitter);
1663 } 1653 }
1664 1654
1665 if (QUERY_FLAG (op, FLAG_TEAR_DOWN)) 1655 if (op->flag [FLAG_TEAR_DOWN])
1666 { 1656 {
1667 if (maxdam) 1657 if (maxdam)
1668 tear_down_wall (op); 1658 tear_down_wall (op);
1669 1659
1670 return maxdam; /* nothing more to do for wall */ 1660 return maxdam; /* nothing more to do for wall */
1677 1667
1678 /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note 1668 /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note
1679 * that before if the player was immune to ghosthit, the monster 1669 * that before if the player was immune to ghosthit, the monster
1680 * remained - that is no longer the case. 1670 * remained - that is no longer the case.
1681 */ 1671 */
1682 if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) 1672 if (hitter->flag [FLAG_ONE_HIT])
1683 hitter->drop_and_destroy (); 1673 hitter->drop_and_destroy ();
1684 /* Lets handle creatures that are splitting now */ 1674 /* Lets handle creatures that are splitting now */
1685 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) 1675 else if (type & AT_PHYSICAL && !op->flag [FLAG_FREED] && op->flag [FLAG_SPLITTING])
1686 { 1676 {
1687 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); 1677 int friendly = op->flag [FLAG_FRIENDLY];
1688 int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); 1678 int unaggressive = op->flag [FLAG_UNAGGRESSIVE];
1689 object *owner = op->owner; 1679 object *owner = op->owner;
1690 1680
1691 if (!op->other_arch) 1681 if (!op->other_arch)
1692 { 1682 {
1693 LOG (llevError, "SPLITTING without other_arch error.\n"); 1683 LOG (llevError, "SPLITTING without other_arch error.\n");
1710 if (owner) 1700 if (owner)
1711 tmp->set_owner (owner); 1701 tmp->set_owner (owner);
1712 } 1702 }
1713 1703
1714 if (unaggressive) 1704 if (unaggressive)
1715 SET_FLAG (tmp, FLAG_UNAGGRESSIVE); 1705 tmp->set_flag (FLAG_UNAGGRESSIVE);
1716 1706
1717 int j = find_first_free_spot (tmp, op->map, op->x, op->y); 1707 int j = find_first_free_spot (tmp, op->map, op->x, op->y);
1718 1708
1719 if (j == -1) /* No spot to put this monster */ 1709 if (j == -1) /* No spot to put this monster */
1720 tmp->destroy (); 1710 tmp->destroy ();
1737poison_player (object *op, object *hitter, int dam) 1727poison_player (object *op, object *hitter, int dam)
1738{ 1728{
1739 archetype *at = archetype::find (shstr_poisoning); 1729 archetype *at = archetype::find (shstr_poisoning);
1740 object *tmp = present_arch_in_ob (at, op); 1730 object *tmp = present_arch_in_ob (at, op);
1741 1731
1742 if (tmp == NULL) 1732 if (!tmp)
1743 { 1733 {
1744 tmp = insert_ob_in_ob (at->instance (), op); 1734 tmp = insert_ob_in_ob (at->instance (), op);
1745 /* peterm: give poisoning some teeth. It should 1735 /* peterm: give poisoning some teeth. It should
1746 * be able to kill things better than it does: 1736 * be able to kill things better than it does:
1747 * damage should be dependent something--I choose to 1737 * damage should be dependent something--I choose to
1748 * do this: if it's a monster, the damage from the 1738 * do this: if it's a monster, the damage from the
1749 * poisoning goes as the level of the monster/2. 1739 * poisoning goes as the level of the monster/2.
1750 * If anything else, goes as damage. 1740 * If anything else, goes as damage.
1751 */ 1741 */
1752 1742
1753 if (QUERY_FLAG (hitter, FLAG_ALIVE)) 1743 if (hitter->flag [FLAG_ALIVE])
1754 tmp->stats.dam += hitter->level / 2; 1744 tmp->stats.dam += hitter->level / 2;
1755 else 1745 else
1756 tmp->stats.dam = dam; 1746 tmp->stats.dam = dam;
1757 1747
1758 tmp->set_owner (hitter); /* so we get credit for poisoning kills */ 1748 tmp->set_owner (hitter); /* so we get credit for poisoning kills */
1766 /* player looses stats, maximum is -10 of each */ 1756 /* player looses stats, maximum is -10 of each */
1767 tmp->stats.Con = max (-(dam / 4 + 1), -10); 1757 tmp->stats.Con = max (-(dam / 4 + 1), -10);
1768 tmp->stats.Str = max (-(dam / 3 + 2), -10); 1758 tmp->stats.Str = max (-(dam / 3 + 2), -10);
1769 tmp->stats.Dex = max (-(dam / 6 + 1), -10); 1759 tmp->stats.Dex = max (-(dam / 6 + 1), -10);
1770 tmp->stats.Int = max (-(dam / 7 ), -10); 1760 tmp->stats.Int = max (-(dam / 7 ), -10);
1771 SET_FLAG (tmp, FLAG_APPLIED); 1761 tmp->set_flag (FLAG_APPLIED);
1772 op->update_stats (); 1762 op->update_stats ();
1773 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); 1763 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill.");
1774 op->play_sound (tmp->sound); 1764 op->play_sound (tmp->sound);
1775 } 1765 }
1776 1766
1789slow_player (object *op, object *hitter, int dam) 1779slow_player (object *op, object *hitter, int dam)
1790{ 1780{
1791 archetype *at = archetype::find (shstr_slowness); 1781 archetype *at = archetype::find (shstr_slowness);
1792 object *tmp; 1782 object *tmp;
1793 1783
1794 if (at == NULL) 1784 if (!at)
1795 LOG (llevError, "Can't find slowness archetype.\n"); 1785 LOG (llevError, "Can't find slowness archetype.\n");
1796 1786
1797 if ((tmp = present_arch_in_ob (at, op)) == NULL) 1787 if ((tmp = present_arch_in_ob (at, op)) == NULL)
1798 { 1788 {
1799 tmp = at->instance (); 1789 tmp = at->instance ();
1801 new_draw_info (NDI_UNIQUE, 0, op, "The world suddenly moves very fast!"); 1791 new_draw_info (NDI_UNIQUE, 0, op, "The world suddenly moves very fast!");
1802 } 1792 }
1803 else 1793 else
1804 tmp->stats.food++; 1794 tmp->stats.food++;
1805 1795
1806 SET_FLAG (tmp, FLAG_APPLIED); 1796 tmp->set_flag (FLAG_APPLIED);
1807 tmp->speed_left = 0; 1797 tmp->speed_left = 0;
1808 op->update_stats (); 1798 op->update_stats ();
1809} 1799}
1810 1800
1811void 1801void
1815 int maxduration; 1805 int maxduration;
1816 1806
1817 tmp = present_in_ob_by_name (FORCE, shstr_confusion, op); 1807 tmp = present_in_ob_by_name (FORCE, shstr_confusion, op);
1818 if (!tmp) 1808 if (!tmp)
1819 { 1809 {
1820 tmp = get_archetype (FORCE_NAME); 1810 tmp = archetype::get (FORCE_NAME);
1821 tmp = insert_ob_in_ob (tmp, op); 1811 tmp = insert_ob_in_ob (tmp, op);
1822 } 1812 }
1823 1813
1824 /* Duration added per hit and max. duration of confusion both depend 1814 /* Duration added per hit and max. duration of confusion both depend
1825 * on the player's resistance 1815 * on the player's resistance
1826 */ 1816 */
1827 tmp->speed = 0.05; 1817 tmp->set_speed (0.05);
1828 tmp->subtype = FORCE_CONFUSION; 1818 tmp->subtype = FORCE_CONFUSION;
1829 tmp->duration = 8 + max (1, 5 * (100 - op->resist[ATNR_CONFUSION]) / 100); 1819 tmp->duration = 8 + max (1, 5 * (100 - op->resist[ATNR_CONFUSION]) / 100);
1830 tmp->name = shstr_confusion; 1820 tmp->name = shstr_confusion;
1831 maxduration = max (2, 30 * (100 - op->resist[ATNR_CONFUSION]) / 100); 1821 maxduration = max (2, 30 * (100 - op->resist[ATNR_CONFUSION]) / 100);
1832 1822
1833 if (tmp->duration > maxduration) 1823 if (tmp->duration > maxduration)
1834 tmp->duration = maxduration; 1824 tmp->duration = maxduration;
1835 1825
1836 if (op->type == PLAYER && !QUERY_FLAG (op, FLAG_CONFUSED)) 1826 if (op->type == PLAYER && !op->flag [FLAG_CONFUSED])
1837 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very confused!"); 1827 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very confused!");
1838 1828
1839 SET_FLAG (op, FLAG_CONFUSED); 1829 op->set_flag (FLAG_CONFUSED);
1840} 1830}
1841 1831
1842void 1832void
1843blind_player (object *op, object *hitter, int dam) 1833blind_player (object *op, object *hitter, int dam)
1844{ 1834{
1845 object *tmp, *owner;
1846
1847 /* Save some work if we know it isn't going to affect the player */ 1835 /* Save some work if we know it isn't going to affect the player */
1848 if (op->resist[ATNR_BLIND] == 100) 1836 if (op->resist[ATNR_BLIND] == 100)
1849 return; 1837 return;
1850 1838
1851 tmp = present_in_ob (BLINDNESS, op); 1839 object *tmp = present_in_ob (BLINDNESS, op);
1852 if (!tmp) 1840 if (!tmp)
1853 { 1841 {
1854 tmp = get_archetype (shstr_blindness); 1842 tmp = archetype::get (shstr_blindness);
1855 SET_FLAG (tmp, FLAG_BLIND); 1843 tmp->set_flag (FLAG_BLIND);
1856 SET_FLAG (tmp, FLAG_APPLIED); 1844 tmp->set_flag (FLAG_APPLIED);
1857 /* use floats so we don't lose too much precision due to rounding errors. 1845 // use floats so we don't lose too much precision due to rounding errors.
1858 * speed is a float anyways. 1846 tmp->set_speed (lerp<float> (op->resist [ATNR_BLIND], 0, 100, tmp->speed, MIN_ACTIVE_SPEED));
1859 */
1860 tmp->speed = tmp->speed * (100.0 - (float) op->resist[ATNR_BLIND]) / 100;
1861 1847
1862 tmp = insert_ob_in_ob (tmp, op); 1848 tmp = insert_ob_in_ob (tmp, op);
1863 change_abil (op, tmp); /* Mostly to display any messages */ 1849 change_abil (op, tmp); /* Mostly to display any messages */
1864 op->update_stats (); /* This takes care of some other stuff */ 1850 op->update_stats (); /* This takes care of some other stuff */
1865 1851
1866 if (hitter->owner)
1867 owner = hitter->owner;
1868 else
1869 owner = hitter;
1870
1871 new_draw_info_format (NDI_UNIQUE, 0, owner, "Your attack blinds %s!", query_name (op)); 1852 new_draw_info_format (NDI_UNIQUE, 0, hitter->outer_owner (), "Your attack blinds %s!", query_name (op));
1872 } 1853 }
1854
1873 tmp->stats.food += dam; 1855 tmp->stats.food += dam;
1874 if (tmp->stats.food > 10) 1856 min_it (tmp->stats.food, 10);
1875 tmp->stats.food = 10;
1876} 1857}
1877 1858
1878void 1859void
1879paralyze_player (object *op, object *hitter, int dam) 1860paralyze_player (object *op, object *hitter, int dam)
1880{ 1861{
1919 ** field of the deathstriking object */ 1900 ** field of the deathstriking object */
1920 1901
1921 int atk_lev, def_lev, kill_lev; 1902 int atk_lev, def_lev, kill_lev;
1922 1903
1923 if (hitter->slaying) 1904 if (hitter->slaying)
1924 if (!((QUERY_FLAG (op, FLAG_UNDEAD) && hitter->slaying.contains (shstr_undead)) 1905 if (!((op->flag [FLAG_UNDEAD] && hitter->slaying.contains (shstr_undead))
1925 || (op->race && hitter->slaying.contains (op->race)))) 1906 || (op->race && hitter->slaying.contains (op->race))))
1926 return; 1907 return;
1927 1908
1928 def_lev = op->level; 1909 def_lev = op->level;
1929 if (def_lev < 1) 1910 if (def_lev < 1)
2054 * Second, just getting hit doesn't mean it always affects 2035 * Second, just getting hit doesn't mean it always affects
2055 * you. Third, you still get a saving through against the 2036 * you. Third, you still get a saving through against the
2056 * effect. 2037 * effect.
2057 */ 2038 */
2058 if (op->has_active_speed () 2039 if (op->has_active_speed ()
2059 && (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) 2040 && (op->flag [FLAG_MONSTER] || op->type == PLAYER)
2060 && !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) 2041 && !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1))
2061 && !did_make_save (op, level_diff, op->resist[attacknum] / 10)) 2042 && !did_make_save (op, level_diff, op->resist[attacknum] / 10))
2062 { 2043 {
2063 2044
2064 /* Player has been hit by something */ 2045 /* Player has been hit by something */
2074 scare_creature (op, hitter); 2055 scare_creature (op, hitter);
2075 else if (attacknum == ATNR_CANCELLATION) 2056 else if (attacknum == ATNR_CANCELLATION)
2076 cancellation (op); 2057 cancellation (op);
2077 else if (attacknum == ATNR_DEPLETE) 2058 else if (attacknum == ATNR_DEPLETE)
2078 op->drain_stat (); 2059 op->drain_stat ();
2079 else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR)) 2060 else if (attacknum == ATNR_BLIND && !op->flag [FLAG_UNDEAD] && !op->flag [FLAG_GENERATOR])
2080 blind_player (op, hitter, dam); 2061 blind_player (op, hitter, dam);
2081 } 2062 }
2082 2063
2083 dam = 0; /* These are all effects and don't do real damage */ 2064 dam = 0; /* These are all effects and don't do real damage */
2084 } 2065 }
2094 { 2075 {
2095 for (object *tmp = op->inv; tmp; tmp = tmp->below) 2076 for (object *tmp = op->inv; tmp; tmp = tmp->below)
2096 { 2077 {
2097 if (tmp->invisible) 2078 if (tmp->invisible)
2098 continue; 2079 continue;
2099 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) 2080 if (!tmp->flag [FLAG_APPLIED] || (tmp->resist[ATNR_ACID] >= 10))
2100 /* >= 10% acid res. on items will protect these */ 2081 /* >= 10% acid res. on items will protect these */
2101 continue; 2082 continue;
2102 if (!(tmp->materials & M_IRON)) 2083 if (!(tmp->materials & M_IRON))
2103 continue; 2084 continue;
2104 if (tmp->magic < -4) /* Let's stop at -5 */ 2085 if (tmp->magic < -4) /* Let's stop at -5 */
2168 * exp, but the wiz would still lose exp! If drainee is a wiz, 2149 * exp, but the wiz would still lose exp! If drainee is a wiz,
2169 * nothing happens. 2150 * nothing happens.
2170 * Try to credit the owner. We try to display player -> player drain 2151 * Try to credit the owner. We try to display player -> player drain
2171 * attacks, hence all the != PLAYER checks. 2152 * attacks, hence all the != PLAYER checks.
2172 */ 2153 */
2173 if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WIZ)) 2154 if (!op_on_battleground (hitter, NULL, NULL) && !op->flag [FLAG_WIZ])
2174 { 2155 {
2175 object *owner = hitter->owner; 2156 object *owner = hitter->owner;
2176 2157
2177 if (owner && owner != hitter) 2158 if (owner && owner != hitter)
2178 { 2159 {
2179 if (op->type != PLAYER || owner->type != PLAYER) 2160 if (op->type != PLAYER || owner->type != PLAYER)
2180 change_exp (owner, op->stats.exp / (rate * 2), 2161 change_exp (owner, op->stats.exp / (rate * 2),
2181 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL); 2162 hitter->chosen_skill ? hitter->chosen_skill->skill : shstr (), SK_EXP_TOTAL);
2182 } 2163 }
2183 else if (op->type != PLAYER || hitter->type != PLAYER) 2164 else if (op->type != PLAYER || hitter->type != PLAYER)
2184 change_exp (hitter, op->stats.exp / (rate * 2), 2165 change_exp (hitter, op->stats.exp / (rate * 2),
2185 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); 2166 hitter->chosen_skill ? hitter->chosen_skill->skill : shstr (), 0);
2186 2167
2187 change_exp (op, -op->stats.exp / rate, NULL, 0); 2168 change_exp (op, -op->stats.exp / rate, shstr (), 0);
2188 } 2169 }
2189 2170
2190 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure 2171 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure
2191 * drain attack, you won't know that you are actually sucking out EXP, 2172 * drain attack, you won't know that you are actually sucking out EXP,
2192 * as the messages will say you missed 2173 * as the messages will say you missed
2195 } 2176 }
2196 break; 2177 break;
2197 2178
2198 case ATNR_TURN_UNDEAD: 2179 case ATNR_TURN_UNDEAD:
2199 { 2180 {
2200 if (QUERY_FLAG (op, FLAG_UNDEAD)) 2181 if (op->flag [FLAG_UNDEAD])
2201 { 2182 {
2202 object *owner = hitter->owner ? (object *)hitter->owner : hitter; 2183 object *owner = hitter->owner ? (object *)hitter->owner : hitter;
2203 object *god = find_god (determine_god (owner)); 2184 object *god = find_god (determine_god (owner));
2204 int div = 1; 2185 int div = 1;
2205 2186
2260 * damage it does do to the player. Given that, 2241 * damage it does do to the player. Given that,
2261 * it only does 1/10'th normal damage (hence the divide by 2242 * it only does 1/10'th normal damage (hence the divide by
2262 * 1000). 2243 * 1000).
2263 */ 2244 */
2264 /* You can't steal life from something undead */ 2245 /* You can't steal life from something undead */
2265 if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD))) 2246 if ((op->type == GOLEM) || (op->flag [FLAG_UNDEAD]))
2266 return 0; 2247 return 0;
2267 2248
2268 /* If drain protection is higher than life stealing, use that */ 2249 /* If drain protection is higher than life stealing, use that */
2269 if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) 2250 if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING])
2270 dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; 2251 dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines