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,2011,2012,2013,2014,2015,2016 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. |
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> |
… | |
… | |
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 | |
32 | |
33 | typedef struct att_msg_str |
|
|
34 | { |
|
|
35 | char *msg1; |
|
|
36 | char *msg2; |
|
|
37 | } att_msg; |
|
|
38 | |
|
|
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 |
43 | * any further action (like destroying the item). |
37 | * any further action (like destroying the item). |
44 | */ |
38 | */ |
45 | static int |
39 | static int |
46 | did_make_save_item (object *op, int type, object *originator) |
40 | did_make_save_item (object *op, uint32_t type, object *originator) |
47 | { |
41 | { |
48 | int i, roll, saves = 0, attacks = 0, number; |
42 | int saves = 0, attacks = 0; |
49 | materialtype_t *mt = op->material; |
43 | materialtype_t *mt = op->material; |
50 | |
44 | |
51 | // destroying objects without material has many bad effects |
45 | // destroying objects without material has many bad effects |
52 | if (mt == MATERIAL_NULL) |
46 | if (mt == MATERIAL_NULL) |
53 | return 1; |
47 | return 1; |
54 | |
48 | |
55 | roll = rndm (1, 20); |
49 | int roll = rndm (1, 20); |
56 | |
50 | |
57 | /* the attacktypes have no meaning for object saves |
51 | /* the attacktypes have no meaning for object saves |
58 | * If the type is only magic, don't adjust type - basically, if |
52 | * If the type is only magic, don't adjust type - basically, if |
59 | * pure magic is hitting an object, it should save. However, if it |
53 | * pure magic is hitting an object, it should save. However, if it |
60 | * is magic teamed with something else, then strip out the |
54 | * is magic teamed with something else, then strip out the |
61 | * magic type, and instead let the fire, cold, or whatever component |
55 | * magic type, and instead let the fire, cold, or whatever component |
62 | * destroy the item. Otherwise, you get the case of poisoncloud |
56 | * destroy the item. Otherwise, you get the case of poisoncloud |
63 | * destroying objects because it has magic attacktype. |
57 | * destroying objects because it has magic attacktype. |
64 | */ |
58 | */ |
65 | if (type != AT_MAGIC) |
59 | if (type != AT_MAGIC) |
66 | type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW | |
60 | type &= ~(AT_CONFUSION | AT_DRAIN | AT_GHOSTHIT | AT_POISON | AT_SLOW | |
67 | AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH | |
61 | AT_PARALYZE | AT_TURN_UNDEAD | AT_FEAR | AT_DEPLETE | AT_DEATH | |
68 | AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC); |
62 | AT_COUNTERSPELL | AT_HOLYWORD | AT_BLIND | AT_LIFE_STEALING | AT_MAGIC); |
69 | |
63 | |
|
|
64 | |
70 | if (type == 0) return TRUE; |
65 | if (type == 0) return TRUE; |
71 | |
66 | |
72 | if (roll == 20) return TRUE; |
67 | if (roll == 20) return TRUE; |
73 | if (roll == 1) return FALSE; |
68 | if (roll == 1) return FALSE; |
74 | |
69 | |
75 | for (number = 0; number < NROFATTACKS; number++) |
70 | for_all_bits_sparse_32 (type, number) |
76 | { |
71 | { |
77 | i = 1 << number; |
|
|
78 | |
|
|
79 | if (!(i & type)) |
|
|
80 | continue; |
|
|
81 | |
|
|
82 | attacks++; |
72 | attacks++; |
|
|
73 | |
83 | if (op->resist[number] == 100) |
74 | if (op->resist[number] == 100) |
84 | saves++; |
75 | saves++; |
85 | else if (roll >= mt->save[number] - op->magic - op->resist[number] / 100) |
76 | else if (roll >= mt->save[number] - op->magic - op->resist[number] / 100) |
86 | saves++; |
77 | saves++; |
87 | else if ((20 - mt->save[number]) / 3 > originator->stats.dam) |
78 | else if ((20 - mt->save[number]) / 3 > originator->stats.dam) |
… | |
… | |
104 | cancellation (object *op) |
95 | cancellation (object *op) |
105 | { |
96 | { |
106 | if (op->invisible) |
97 | if (op->invisible) |
107 | return; |
98 | return; |
108 | |
99 | |
109 | 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) |
110 | { |
101 | { |
111 | /* Recurse through the inventory */ |
102 | /* Recurse through the inventory */ |
112 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
103 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
113 | if (!did_make_save_item (tmp, AT_CANCELLATION, op)) |
104 | if (!did_make_save_item (tmp, AT_CANCELLATION, op)) |
114 | cancellation (tmp); |
105 | cancellation (tmp); |
… | |
… | |
117 | { |
108 | { |
118 | /* Nullify this object. This code could probably be more complete */ |
109 | /* Nullify this object. This code could probably be more complete */ |
119 | /* in what abilities it should cancel */ |
110 | /* in what abilities it should cancel */ |
120 | op->magic = 0; |
111 | op->magic = 0; |
121 | |
112 | |
122 | CLEAR_FLAG (op, FLAG_DAMNED); |
113 | op->clr_flag (FLAG_DAMNED); |
123 | CLEAR_FLAG (op, FLAG_CURSED); |
114 | op->clr_flag (FLAG_CURSED); |
124 | CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); |
115 | op->clr_flag (FLAG_KNOWN_MAGICAL); |
125 | CLEAR_FLAG (op, FLAG_KNOWN_CURSED); |
116 | op->clr_flag (FLAG_KNOWN_CURSED); |
126 | |
117 | |
127 | if (object *pl = op->visible_to ()) |
118 | if (object *pl = op->visible_to ()) |
128 | esrv_update_item (UPD_FLAGS, pl, op); |
119 | esrv_update_item (UPD_FLAGS, pl, op); |
129 | } |
120 | } |
130 | } |
121 | } |
… | |
… | |
134 | * calling cancellation, etc.) |
125 | * calling cancellation, etc.) |
135 | */ |
126 | */ |
136 | void |
127 | void |
137 | save_throw_object (object *op, int type, object *originator) |
128 | save_throw_object (object *op, int type, object *originator) |
138 | { |
129 | { |
|
|
130 | op = op->head_ (); |
|
|
131 | |
139 | if (!did_make_save_item (op, type, originator)) |
132 | if (!did_make_save_item (op, type, originator)) |
140 | { |
133 | { |
141 | object *env = op->env; |
134 | object *env = op->env; |
142 | int x = op->x, y = op->y; |
135 | int x = op->x, y = op->y; |
143 | maptile *m = op->map; |
136 | maptile *m = op->map; |
… | |
… | |
152 | * object with +/- glow_radius and an "other_arch" to change to. |
145 | * object with +/- glow_radius and an "other_arch" to change to. |
153 | * (and please note that we cant fail our save and reach this |
146 | * (and please note that we cant fail our save and reach this |
154 | * function if the object doesnt contain a material that can burn. |
147 | * function if the object doesnt contain a material that can burn. |
155 | * So forget lighting magical swords on fire with this!) -b.t. |
148 | * So forget lighting magical swords on fire with this!) -b.t. |
156 | */ |
149 | */ |
157 | if (type & (AT_FIRE | AT_ELECTRICITY) |
150 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
158 | && (QUERY_FLAG (op, FLAG_IS_LIGHTABLE) |
|
|
159 | || op->type == LAMP |
|
|
160 | || op->type == TORCH |
|
|
161 | )) |
151 | { |
162 | { |
152 | // seems LAMPs and TORCHes are always IS_LIGHTABLE? |
163 | switch (op->type) |
153 | if (op->type == LAMP || op->type == TORCH) |
164 | { |
154 | { |
165 | case LAMP: |
|
|
166 | case TORCH: |
|
|
167 | // turn on a lamp |
|
|
168 | apply_lamp (op, true); |
155 | apply_lamp (op, true); // turn on a lamp |
169 | break; |
156 | return; |
170 | |
|
|
171 | default: |
|
|
172 | // for instance icecubes: |
|
|
173 | if (op->other_arch) |
|
|
174 | { |
|
|
175 | const char *arch = op->other_arch->archname; |
|
|
176 | |
|
|
177 | if (op->decrease ()) |
|
|
178 | fix_stopped_item (op, m, originator); |
|
|
179 | |
|
|
180 | if ((op = archetype::get (arch))) |
|
|
181 | { |
|
|
182 | if (env) |
|
|
183 | env->insert (op); |
|
|
184 | else |
|
|
185 | m->insert (op, x, y, originator); |
|
|
186 | } |
|
|
187 | } |
|
|
188 | } |
157 | } |
|
|
158 | else if (op->flag [FLAG_IS_LIGHTABLE]) |
|
|
159 | { |
|
|
160 | if (op->other_arch) |
|
|
161 | { |
|
|
162 | const char *arch = op->other_arch->archname; |
189 | |
163 | |
|
|
164 | if (op->decrease ()) |
|
|
165 | fix_stopped_item (op, m, originator); |
|
|
166 | |
|
|
167 | if ((op = archetype::get (arch))) |
|
|
168 | { |
|
|
169 | if (env) |
|
|
170 | env->insert (op); |
|
|
171 | else |
|
|
172 | m->insert (op, x, y, originator); |
|
|
173 | } |
|
|
174 | } |
|
|
175 | |
190 | return; |
176 | return; |
|
|
177 | } |
191 | } |
178 | } |
192 | |
179 | |
193 | if (type & AT_CANCELLATION) |
180 | if (type & AT_CANCELLATION) |
194 | { /* Cancellation. */ |
181 | { /* Cancellation. */ |
195 | cancellation (op); |
182 | cancellation (op); |
… | |
… | |
199 | } |
186 | } |
200 | |
187 | |
201 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
188 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
202 | if (env) |
189 | if (env) |
203 | { |
190 | { |
204 | op = archetype::get (shstr_burnout); |
191 | object *op = archetype::get (shstr_burnout); |
205 | op->x = env->x, op->y = env->y; |
192 | op->x = env->x, op->y = env->y; |
206 | env->insert (op); |
193 | env->insert (op); |
207 | } |
194 | } |
208 | else |
195 | else |
209 | replace_insert_ob_in_map (shstr_burnout, originator); |
196 | replace_insert_ob_in_map (shstr_burnout, originator); |
… | |
… | |
222 | |
209 | |
223 | return; |
210 | return; |
224 | } |
211 | } |
225 | |
212 | |
226 | /* The value of 50 is arbitrary. */ |
213 | /* The value of 50 is arbitrary. */ |
227 | 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)) |
228 | { |
215 | { |
229 | archetype *at = archetype::find (shstr_icecube); |
216 | archetype *at = archetype::find (shstr_icecube); |
230 | |
217 | |
231 | if (at == NULL) |
218 | if (at == NULL) |
232 | return; |
219 | return; |
… | |
… | |
236 | return; |
223 | return; |
237 | |
224 | |
238 | object *tmp = present_arch (at, op->map, op->x, op->y); |
225 | object *tmp = present_arch (at, op->map, op->x, op->y); |
239 | if (!tmp) |
226 | if (!tmp) |
240 | { |
227 | { |
241 | tmp = arch_to_object (at); |
228 | tmp = at->instance (); |
242 | tmp->x = op->x, tmp->y = op->y; |
229 | tmp->x = op->x, tmp->y = op->y; |
243 | /* This was in the old (pre new movement code) - |
230 | /* This was in the old (pre new movement code) - |
244 | * icecubes have slow_move set to 1 - don't want |
231 | * icecubes have slow_move set to 1 - don't want |
245 | * that for ones we create. |
232 | * that for ones we create. |
246 | */ |
233 | */ |
… | |
… | |
259 | * type is the attacktype of the object. |
246 | * type is the attacktype of the object. |
260 | * full_hit is set if monster area does not matter. |
247 | * full_hit is set if monster area does not matter. |
261 | * returns 1 if it hits something, 0 otherwise. |
248 | * returns 1 if it hits something, 0 otherwise. |
262 | */ |
249 | */ |
263 | int |
250 | int |
264 | hit_map (object *op, int dir, int type, int full_hit) |
251 | hit_map (object *op, int dir, uint32_t type, int full_hit) |
265 | { |
252 | { |
266 | maptile *map; |
|
|
267 | sint16 x, y; |
253 | sint16 x, y; |
268 | 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 */ |
269 | |
255 | |
270 | if (QUERY_FLAG (op, FLAG_FREED)) |
256 | if (op->flag [FLAG_FREED]) |
271 | { |
257 | { |
272 | LOG (llevError, "BUG: hit_map(): free object\n"); |
258 | LOG (llevError, "BUG: hit_map(): free object\n"); |
273 | return 0; |
259 | return 0; |
274 | } |
260 | } |
275 | |
261 | |
276 | if (QUERY_FLAG (op, FLAG_REMOVED) || op->env != NULL) |
262 | if (op->flag [FLAG_REMOVED] || op->env != NULL) |
277 | { |
263 | { |
278 | 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); |
279 | return 0; |
265 | return 0; |
280 | } |
266 | } |
281 | |
267 | |
… | |
… | |
345 | * 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. |
346 | */ |
332 | */ |
347 | 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) |
348 | continue; |
334 | continue; |
349 | |
335 | |
350 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
336 | if (tmp->flag [FLAG_ALIVE]) |
351 | { |
337 | { |
352 | hit_player (tmp, op->stats.dam, op, type, full_hit); |
338 | hit_player (tmp, op->stats.dam, op, type, full_hit); |
353 | retflag |= 1; |
339 | retflag |= 1; |
354 | |
340 | |
355 | if (op->destroyed ()) |
341 | if (op->destroyed ()) |
… | |
… | |
371 | if (op->destroyed ()) |
357 | if (op->destroyed ()) |
372 | break; |
358 | break; |
373 | } |
359 | } |
374 | } |
360 | } |
375 | |
361 | |
376 | return 0; |
362 | return retflag; |
377 | } |
363 | } |
378 | |
364 | |
379 | static void |
365 | static void |
380 | attack_message (int dam, int type, object *op, object *hitter) |
366 | attack_message (int dam, int type, object *op, object *hitter) |
381 | { |
367 | { |
… | |
… | |
530 | { |
516 | { |
531 | int mtype; |
517 | int mtype; |
532 | |
518 | |
533 | switch (hitter->current_weapon->weapontype) |
519 | switch (hitter->current_weapon->weapontype) |
534 | { |
520 | { |
535 | case WEAP_HIT: |
521 | case WEAP_HIT: mtype = ATM_BASIC; break; |
536 | mtype = ATM_BASIC; |
522 | case WEAP_SLASH: mtype = ATM_SLASH; break; |
537 | break; |
523 | case WEAP_PIERCE: mtype = ATM_PIERCE; break; |
538 | case WEAP_SLASH: |
524 | case WEAP_CLEAVE: mtype = ATM_CLEAVE; break; |
539 | mtype = ATM_SLASH; |
525 | case WEAP_SLICE: mtype = ATM_SLICE; break; |
540 | break; |
526 | case WEAP_STAB: mtype = ATM_STAB; break; |
541 | case WEAP_PIERCE: |
527 | case WEAP_WHIP: mtype = ATM_WHIP; break; |
542 | mtype = ATM_PIERCE; |
528 | case WEAP_CRUSH: mtype = ATM_CRUSH; break; |
543 | break; |
529 | case WEAP_BLUD: mtype = ATM_BLUD; break; |
544 | case WEAP_CLEAVE: |
530 | default: mtype = ATM_BASIC; break; |
545 | mtype = ATM_CLEAVE; |
|
|
546 | break; |
|
|
547 | case WEAP_SLICE: |
|
|
548 | mtype = ATM_SLICE; |
|
|
549 | break; |
|
|
550 | case WEAP_STAB: |
|
|
551 | mtype = ATM_STAB; |
|
|
552 | break; |
|
|
553 | case WEAP_WHIP: |
|
|
554 | mtype = ATM_WHIP; |
|
|
555 | break; |
|
|
556 | case WEAP_CRUSH: |
|
|
557 | mtype = ATM_CRUSH; |
|
|
558 | break; |
|
|
559 | case WEAP_BLUD: |
|
|
560 | mtype = ATM_BLUD; |
|
|
561 | break; |
|
|
562 | default: |
|
|
563 | mtype = ATM_BASIC; |
|
|
564 | break; |
|
|
565 | } |
531 | } |
566 | |
532 | |
567 | for (i = 0; i < MAXATTACKMESS && attack_mess[mtype][i].level != -1; i++) |
533 | for (i = 0; i < MAXATTACKMESS && attack_mess[mtype][i].level != -1; i++) |
568 | if (dam < attack_mess[mtype][i].level || attack_mess[mtype][i + 1].level == -1) |
534 | if (dam < attack_mess[mtype][i].level || attack_mess[mtype][i + 1].level == -1) |
569 | { |
535 | { |
… | |
… | |
675 | } |
641 | } |
676 | |
642 | |
677 | static int |
643 | static int |
678 | get_attack_mode (object **target, object **hitter, int *simple_attack) |
644 | get_attack_mode (object **target, object **hitter, int *simple_attack) |
679 | { |
645 | { |
680 | if (QUERY_FLAG (*target, FLAG_FREED) || QUERY_FLAG (*hitter, FLAG_FREED)) |
646 | if ((*target)->flag [FLAG_FREED] || (*hitter)->flag [FLAG_FREED]) |
681 | { |
647 | { |
682 | LOG (llevError, "BUG: get_attack_mode(): freed object\n"); |
648 | LOG (llevError, "BUG: get_attack_mode(): freed object\n"); |
683 | return 1; |
649 | return 1; |
684 | } |
650 | } |
685 | |
651 | |
… | |
… | |
693 | { |
659 | { |
694 | *simple_attack = 1; |
660 | *simple_attack = 1; |
695 | return 0; |
661 | return 0; |
696 | } |
662 | } |
697 | |
663 | |
698 | if (QUERY_FLAG (*target, FLAG_REMOVED) |
664 | if ((*target)->flag [FLAG_REMOVED] |
699 | || QUERY_FLAG (*hitter, FLAG_REMOVED) |
665 | || (*hitter)->flag [FLAG_REMOVED] |
700 | || !(*hitter)->map |
666 | || !(*hitter)->map |
701 | || !on_same_map (*hitter, *target)) |
667 | || !on_same_map (*hitter, *target)) |
702 | { |
668 | { |
703 | 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", |
704 | (*hitter)->debug_desc (), (*target)->debug_desc ()); |
670 | (*hitter)->debug_desc (), (*target)->debug_desc ()); |
… | |
… | |
717 | */ |
683 | */ |
718 | int new_mode; |
684 | int new_mode; |
719 | |
685 | |
720 | if (hitter->env == target || target->env == hitter) |
686 | if (hitter->env == target || target->env == hitter) |
721 | new_mode = 1; |
687 | new_mode = 1; |
722 | else if (QUERY_FLAG (hitter, FLAG_REMOVED) || QUERY_FLAG (target, FLAG_REMOVED) |
688 | else if (hitter->flag [FLAG_REMOVED] || target->flag [FLAG_REMOVED] |
723 | || hitter->map == NULL || !on_same_map (hitter, target)) |
689 | || hitter->map == NULL || !on_same_map (hitter, target)) |
724 | return 1; |
690 | return 1; |
725 | else |
691 | else |
726 | new_mode = 0; |
692 | new_mode = 0; |
727 | |
693 | |
… | |
… | |
733 | * monster). |
699 | * monster). |
734 | */ |
700 | */ |
735 | static void |
701 | static void |
736 | thrown_item_effect (object *hitter, object *victim) |
702 | thrown_item_effect (object *hitter, object *victim) |
737 | { |
703 | { |
738 | if (!QUERY_FLAG (hitter, FLAG_ALIVE)) |
704 | if (!hitter->flag [FLAG_ALIVE]) |
739 | { |
705 | { |
740 | /* 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 |
741 | * easier for expansion. |
707 | * easier for expansion. |
742 | */ |
708 | */ |
743 | switch (hitter->type) |
709 | switch (hitter->type) |
744 | { |
710 | { |
745 | case POTION: |
711 | case POTION: |
746 | /* should player get a save throw instead of checking magic protection? */ |
712 | /* should player get a save throw instead of checking magic protection? */ |
747 | 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)) |
748 | (void) apply_potion (victim, hitter); |
714 | apply_potion (victim, hitter); |
749 | break; |
715 | break; |
750 | |
716 | |
751 | case POISON: /* poison drinks */ |
717 | case POISON: /* poison drinks */ |
752 | /* As with potions, should monster get a save? */ |
718 | /* As with potions, should monster get a save? */ |
753 | 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)) |
754 | apply_poison (victim, hitter); |
720 | apply_poison (victim, hitter); |
755 | break; |
721 | break; |
756 | |
722 | |
757 | /* Removed case statements that did nothing. |
723 | /* Removed case statements that did nothing. |
758 | * 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, |
… | |
… | |
765 | |
731 | |
766 | /* determine if the object is an 'aimed' missile */ |
732 | /* determine if the object is an 'aimed' missile */ |
767 | static int |
733 | static int |
768 | is_aimed_missile (object *op) |
734 | is_aimed_missile (object *op) |
769 | { |
735 | { |
770 | |
|
|
771 | /* I broke what used to be one big if into a few nested |
736 | /* I broke what used to be one big if into a few nested |
772 | * ones so that figuring out the logic is at least possible. |
737 | * ones so that figuring out the logic is at least possible. |
773 | */ |
738 | */ |
774 | if (op && (op->move_type & MOVE_FLYING)) |
739 | if (op && (op->move_type & MOVE_FLYING)) |
775 | if (op->type == ARROW || op->type == THROWN_OBJ) |
740 | if (op->type == ARROW || op->type == THROWN_OBJ) |
… | |
… | |
799 | if ((attacker = hitter->owner) == NULL) |
764 | if ((attacker = hitter->owner) == NULL) |
800 | attacker = hitter; |
765 | attacker = hitter; |
801 | /* 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 |
802 | * owned by him - need to handle that case to avoid crashes. |
767 | * owned by him - need to handle that case to avoid crashes. |
803 | */ |
768 | */ |
804 | if (QUERY_FLAG (attacker, FLAG_REMOVED)) |
769 | if (attacker->flag [FLAG_REMOVED]) |
805 | attacker = hitter; |
770 | attacker = hitter; |
806 | } |
771 | } |
807 | else if (!QUERY_FLAG (hitter, FLAG_ALIVE)) |
772 | else if (!hitter->flag [FLAG_ALIVE]) |
808 | return 0; |
773 | return 0; |
809 | |
774 | |
810 | /* determine the condtions under which we make an attack. |
775 | /* determine the condtions under which we make an attack. |
811 | * Add more cases, as the need occurs. */ |
776 | * Add more cases, as the need occurs. */ |
812 | |
777 | |
813 | if (!can_see_enemy (attacker, target)) |
778 | if (!can_see_enemy (attacker, target)) |
814 | { |
779 | { |
815 | /* target is unseen */ |
780 | /* target is unseen */ |
816 | if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) |
781 | if (target->invisible || attacker->flag [FLAG_BLIND]) |
817 | adjust -= 10; |
782 | adjust -= 10; |
818 | /* 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). */ |
819 | else if (!stand_in_light (target)) |
784 | else if (!stand_in_light (target)) |
820 | adjust -= target->map->darklevel (); |
785 | adjust -= target->map->darklevel (); |
821 | } |
786 | } |
822 | |
787 | |
823 | if (QUERY_FLAG (attacker, FLAG_SCARED)) |
788 | if (attacker->flag [FLAG_SCARED]) |
824 | adjust -= 3; |
789 | adjust -= 3; |
825 | |
790 | |
826 | if (QUERY_FLAG (target, FLAG_UNAGGRESSIVE)) |
791 | if (target->flag [FLAG_UNAGGRESSIVE]) |
827 | adjust += 1; |
792 | adjust += 1; |
828 | |
793 | |
829 | if (QUERY_FLAG (target, FLAG_SCARED)) |
794 | if (target->flag [FLAG_SCARED]) |
830 | adjust += 1; |
795 | adjust += 1; |
831 | |
796 | |
832 | if (QUERY_FLAG (attacker, FLAG_CONFUSED)) |
797 | if (attacker->flag [FLAG_CONFUSED]) |
833 | adjust -= 3; |
798 | adjust -= 3; |
834 | |
799 | |
835 | /* if we attack at a different 'altitude' its harder */ |
800 | /* if we attack at a different 'altitude' its harder */ |
836 | if ((attacker->move_type & target->move_type) == 0) |
801 | if ((attacker->move_type & target->move_type) == 0) |
837 | adjust -= 2; |
802 | adjust -= 2; |
… | |
… | |
873 | |
838 | |
874 | /* |
839 | /* |
875 | * 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 |
876 | * to avoid ever being hit by monsters. |
841 | * to avoid ever being hit by monsters. |
877 | */ |
842 | */ |
878 | if (!simple_attack && QUERY_FLAG (op, FLAG_MONSTER) && op->speed_left > abs (op->speed) * -0.3f) |
843 | if (!simple_attack && op->flag [FLAG_MONSTER] && op->speed_left > op->speed * -0.3f) |
879 | { |
844 | { |
880 | /* Decrease speed BEFORE calling process_object. Otherwise, an |
845 | /* Decrease speed BEFORE calling process_object. Otherwise, an |
881 | * infinite loop occurs, with process_object calling move_monster, |
846 | * infinite loop occurs, with process_object calling move_monster, |
882 | * which then gets here again. By decreasing the speed before |
847 | * which then gets here again. By decreasing the speed before |
883 | * we call process_object, the 'if' statement above will fail. |
848 | * we call process_object, the 'if' statement above will fail. |
… | |
… | |
905 | if (!simple_attack) |
870 | if (!simple_attack) |
906 | { |
871 | { |
907 | /* If you hit something, the victim should *always* wake up. |
872 | /* If you hit something, the victim should *always* wake up. |
908 | * Before, invisible hitters could avoid doing this. |
873 | * Before, invisible hitters could avoid doing this. |
909 | * -b.t. */ |
874 | * -b.t. */ |
910 | if (QUERY_FLAG (op, FLAG_SLEEP)) |
875 | if (op->flag [FLAG_SLEEP]) |
911 | CLEAR_FLAG (op, FLAG_SLEEP); |
876 | op->clr_flag (FLAG_SLEEP); |
912 | |
877 | |
913 | /* 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 |
914 | * for help. */ |
879 | * for help. */ |
915 | 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)) |
916 | npc_call_help (op); |
881 | npc_call_help (op); |
… | |
… | |
936 | } |
901 | } |
937 | |
902 | |
938 | /* 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 |
939 | * to go further and it will cause FPE's below. |
904 | * to go further and it will cause FPE's below. |
940 | */ |
905 | */ |
941 | if (hitdam <= 0) |
906 | max_it (hitdam, 1); |
942 | hitdam = 1; |
|
|
943 | |
907 | |
944 | type = hitter->attacktype; |
908 | type = hitter->attacktype; |
945 | |
909 | |
946 | /* 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* |
947 | * Crossfire we have to default the attacktype here to AT_PHYSICAL. |
911 | * Crossfire we have to default the attacktype here to AT_PHYSICAL. |
… | |
… | |
955 | */ |
919 | */ |
956 | if (!type) |
920 | if (!type) |
957 | type = AT_PHYSICAL; |
921 | type = AT_PHYSICAL; |
958 | |
922 | |
959 | /* Handle monsters that hit back */ |
923 | /* Handle monsters that hit back */ |
960 | 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]) |
961 | { |
925 | { |
962 | if (op->attacktype & AT_ACID && hitter->type == PLAYER) |
926 | if (op->attacktype & AT_ACID && hitter->type == PLAYER) |
963 | 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"); |
964 | |
928 | |
965 | 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); |
… | |
… | |
991 | } |
955 | } |
992 | |
956 | |
993 | int |
957 | int |
994 | attack_ob (object *op, object *hitter) |
958 | attack_ob (object *op, object *hitter) |
995 | { |
959 | { |
996 | hitter = hitter->head_ (); |
|
|
997 | |
|
|
998 | 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); |
999 | } |
961 | } |
1000 | |
962 | |
1001 | /* op is the arrow, tmp is what is stopping the arrow. |
963 | /* op is the arrow, tmp is what is stopping the arrow. |
1002 | * |
964 | * |
1003 | * 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. |
… | |
… | |
1056 | * arrow, move_apply() calls this function, arrow sticks in demon, |
1018 | * arrow, move_apply() calls this function, arrow sticks in demon, |
1057 | * 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 |
1058 | * 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 |
1059 | * other places as well!) |
1021 | * other places as well!) |
1060 | */ |
1022 | */ |
1061 | if (hitter->destroyed () || hitter->env != NULL) |
1023 | if (hitter->destroyed () || hitter->env) |
1062 | { |
1024 | { |
1063 | if (container) |
1025 | if (container) |
1064 | container->destroy (); |
1026 | container->destroy (); |
1065 | |
1027 | |
1066 | return 0; |
1028 | return 0; |
1067 | } |
1029 | } |
1068 | |
1030 | |
1069 | /* Missile hit victim */ |
1031 | /* Missile hit victim */ |
1070 | /* 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 |
1071 | * through the target |
1033 | * through the target |
1072 | */ |
1034 | */ |
1073 | if (hit_something && op->speed <= 10.0) |
1035 | if (hit_something) |
|
|
1036 | if (op->speed < 10.0) |
1074 | { |
1037 | { |
1075 | /* Stop arrow */ |
1038 | /* Stop arrow */ |
1076 | if (!container) |
1039 | if (!container) |
1077 | { |
1040 | { |
1078 | hitter = fix_stopped_arrow (hitter); |
1041 | hitter = fix_stopped_arrow (hitter); |
1079 | if (!hitter) |
1042 | if (!hitter) |
1080 | return 0; |
1043 | return 0; |
1081 | } |
1044 | } |
1082 | else |
1045 | else |
1083 | container->destroy (); |
1046 | container->destroy (); |
1084 | |
1047 | |
1085 | /* Try to stick arrow into victim */ |
1048 | /* Try to stick arrow into victim */ |
1086 | 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 | |
1087 | return 0; |
1075 | return 0; |
1088 | |
|
|
1089 | /* Else try to put arrow on victim's map square |
|
|
1090 | * remove check for P_WALL here. If the arrow got to this |
|
|
1091 | * space, that is good enough - with the new movement code, |
|
|
1092 | * there is now the potential for lots of spaces where something |
|
|
1093 | * can fly over but not otherwise move over. What is the correct |
|
|
1094 | * way to handle those otherwise? |
|
|
1095 | */ |
|
|
1096 | if (victim->x != hitter->x || victim->y != hitter->y) |
|
|
1097 | { |
|
|
1098 | if (victim->destroyed ()) |
|
|
1099 | hitter->destroy (); |
|
|
1100 | else |
|
|
1101 | { |
|
|
1102 | hitter->remove (); |
|
|
1103 | hitter->x = victim->x; |
|
|
1104 | hitter->y = victim->y; |
|
|
1105 | insert_ob_in_map (hitter, victim->map, hitter, 0); |
|
|
1106 | } |
|
|
1107 | } |
1076 | } |
1108 | else |
1077 | else |
1109 | /* Else leave arrow where it is */ |
1078 | op->set_speed (op->speed - 1.f); |
1110 | merge_ob (hitter, NULL); |
|
|
1111 | |
|
|
1112 | return 0; |
|
|
1113 | } |
|
|
1114 | |
|
|
1115 | if (hit_something && op->speed >= 10.0) |
|
|
1116 | op->speed -= 1.0; |
|
|
1117 | |
1079 | |
1118 | /* Missile missed victim - reassemble missile */ |
1080 | /* Missile missed victim - reassemble missile */ |
1119 | if (container) |
1081 | if (container) |
1120 | { |
1082 | { |
1121 | hitter->remove (); |
1083 | hitter->remove (); |
… | |
… | |
1189 | * MSW 2002-07-17 |
1151 | * MSW 2002-07-17 |
1190 | */ |
1152 | */ |
1191 | int |
1153 | int |
1192 | kill_object (object *op, int dam, object *hitter, int type) |
1154 | kill_object (object *op, int dam, object *hitter, int type) |
1193 | { |
1155 | { |
1194 | char buf[MAX_BUF]; |
|
|
1195 | shstr skill; |
1156 | shstr skill; |
1196 | int maxdam = 0; |
1157 | int maxdam = 0; |
1197 | int battleg = 0; /* true if op standing on battleground */ |
1158 | int battleg = 0; /* true if op standing on battleground */ |
1198 | 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 */ |
1199 | object *owner = 0; |
1160 | object *owner = 0; |
… | |
… | |
1209 | * this creature. The function(s) that call us have already |
1170 | * this creature. The function(s) that call us have already |
1210 | * adjusted the creatures HP total, so that is negative. |
1171 | * adjusted the creatures HP total, so that is negative. |
1211 | */ |
1172 | */ |
1212 | maxdam = dam + op->stats.hp + 1; |
1173 | maxdam = dam + op->stats.hp + 1; |
1213 | |
1174 | |
1214 | if (QUERY_FLAG (op, FLAG_BLOCKSVIEW)) |
1175 | if (op->flag [FLAG_BLOCKSVIEW]) |
1215 | 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 */ |
1216 | |
1177 | |
1217 | if (op->type == DOOR) |
1178 | if (op->type == DOOR) |
1218 | { |
1179 | { |
1219 | op->set_speed (0.1f); |
1180 | op->set_speed (0.1f); |
1220 | op->speed_left = -0.05f; |
1181 | op->speed_left = -0.05f; |
1221 | return maxdam; |
1182 | return maxdam; |
1222 | } |
1183 | } |
1223 | |
1184 | |
1224 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1185 | if (op->flag [FLAG_FRIENDLY] && op->type != PLAYER) |
1225 | { |
1186 | { |
1226 | op->drop_and_destroy (); |
1187 | op->drop_and_destroy (); |
1227 | return maxdam; |
1188 | return maxdam; |
1228 | } |
1189 | } |
1229 | |
1190 | |
… | |
… | |
1296 | else if (owner->chosen_skill) |
1257 | else if (owner->chosen_skill) |
1297 | { |
1258 | { |
1298 | skop = owner->chosen_skill; |
1259 | skop = owner->chosen_skill; |
1299 | skill = skop->skill; |
1260 | skill = skop->skill; |
1300 | } |
1261 | } |
1301 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON) && owner->current_weapon) |
1262 | else if (owner->flag [FLAG_READY_WEAPON] && owner->current_weapon) |
1302 | skill = owner->current_weapon->skill; |
1263 | skill = owner->current_weapon->skill; |
1303 | else |
1264 | else |
1304 | { |
1265 | { |
|
|
1266 | LOG (llevError | logBacktrace, |
1305 | 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" |
1306 | "op: %s\n" "hitter: %s\n" "owner: %s\n", |
1268 | "op: %s\n" "hitter: %s\n" "op: %s\n", |
1307 | owner->debug_desc (), hitter->debug_desc (), op->debug_desc ()); |
1269 | op->debug_desc (), hitter->debug_desc (), op->debug_desc ()); |
1308 | skill = 0; |
1270 | skill = 0; |
1309 | } |
1271 | } |
1310 | |
1272 | |
1311 | /* 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 |
1312 | * 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! |
… | |
… | |
1322 | |
1284 | |
1323 | if (!skill && skop) |
1285 | if (!skill && skop) |
1324 | skill = skop->skill; |
1286 | skill = skop->skill; |
1325 | |
1287 | |
1326 | /* If you didn't kill yourself, and your not the wizard */ |
1288 | /* If you didn't kill yourself, and your not the wizard */ |
1327 | if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) |
1289 | if (owner != op && !op->flag [FLAG_WIZ]) |
1328 | { |
1290 | { |
1329 | int exp; |
1291 | int exp; |
1330 | |
1292 | |
1331 | /* Really don't give much experience for killing other players */ |
1293 | /* Really don't give much experience for killing other players */ |
1332 | // schmorp: temporarily? reduce the amount of exp gained for pking enourmously |
1294 | // schmorp: temporarily? reduce the amount of exp gained for pking enourmously |
… | |
… | |
1389 | } /* else part of a party */ |
1351 | } /* else part of a party */ |
1390 | } /* end if person didn't kill himself */ |
1352 | } /* end if person didn't kill himself */ |
1391 | |
1353 | |
1392 | if (op->type != PLAYER) |
1354 | if (op->type != PLAYER) |
1393 | { |
1355 | { |
1394 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
1356 | if (op->flag [FLAG_FRIENDLY]) |
1395 | { |
1357 | { |
1396 | object *owner1 = op->owner; |
1358 | object *owner1 = op->owner; |
1397 | |
1359 | |
1398 | if (owner1 && owner1->type == PLAYER) |
1360 | if (owner1 && owner1->type == PLAYER) |
1399 | { |
1361 | { |
… | |
… | |
1460 | * modify it. |
1422 | * modify it. |
1461 | */ |
1423 | */ |
1462 | /* Oct 95 - altered the following slightly for MULTIPLE_GODS hack |
1424 | /* Oct 95 - altered the following slightly for MULTIPLE_GODS hack |
1463 | * which needs new attacktype AT_HOLYWORD to work . b.t. */ |
1425 | * which needs new attacktype AT_HOLYWORD to work . b.t. */ |
1464 | int |
1426 | int |
1465 | hit_player (object *op, int dam, object *hitter, int type, int full_hit) |
1427 | hit_player (object *op, int dam, object *hitter, uint32_t type, int full_hit) |
1466 | { |
1428 | { |
1467 | int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC); |
1429 | int magic = type & AT_MAGIC; |
1468 | int maxattacktype, attacknum; |
|
|
1469 | 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? */ |
|
|
1431 | int maxdam = 0, ndam = 0; |
|
|
1432 | int maxattacktype; |
1470 | int simple_attack; |
1433 | int simple_attack; |
1471 | int rtn_kill = 0; |
1434 | int rtn_kill = 0; |
1472 | int friendlyfire; |
1435 | int friendlyfire; |
1473 | |
1436 | |
1474 | if (get_attack_mode (&op, &hitter, &simple_attack)) |
1437 | if (get_attack_mode (&op, &hitter, &simple_attack)) |
1475 | return 0; |
1438 | return 0; |
1476 | |
1439 | |
1477 | /* 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 */ |
1478 | if (QUERY_FLAG (op, FLAG_WIZ) || QUERY_FLAG (op, FLAG_NO_DAMAGE)) |
1441 | if (op->flag [FLAG_WIZ] || op->flag [FLAG_NO_DAMAGE]) |
1479 | return 0; |
1442 | return 0; |
1480 | |
1443 | |
1481 | // only allow pk for hostile players |
1444 | // only allow pk for hostile players |
1482 | if (op->type == PLAYER) |
1445 | if (op->type == PLAYER) |
1483 | { |
1446 | { |
… | |
… | |
1525 | |
1488 | |
1526 | break; |
1489 | break; |
1527 | } |
1490 | } |
1528 | } |
1491 | } |
1529 | |
1492 | |
1530 | if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) |
1493 | if (!op->flag [FLAG_ALIVE] || op->stats.hp < 0) |
1531 | { |
1494 | { |
1532 | /* 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 |
1533 | * destroyed() check above doesn't return, and might get here. |
1496 | * destroyed() check above doesn't return, and might get here. |
1534 | */ |
1497 | */ |
1535 | |
1498 | |
… | |
… | |
1576 | object *god; |
1539 | object *god; |
1577 | |
1540 | |
1578 | if ((!hitter->slaying |
1541 | if ((!hitter->slaying |
1579 | || (!(op->race && hitter->slaying.contains (op->race)) |
1542 | || (!(op->race && hitter->slaying.contains (op->race)) |
1580 | && !(op->name && hitter->slaying.contains (op->name)))) |
1543 | && !(op->name && hitter->slaying.contains (op->name)))) |
1581 | && (!QUERY_FLAG (op, FLAG_UNDEAD) |
1544 | && (!op->flag [FLAG_UNDEAD] |
1582 | || (hitter->title |
1545 | || (hitter->title |
1583 | && (god = find_god (determine_god (hitter))) != NULL |
1546 | && (god = find_god (determine_god (hitter))) != NULL |
1584 | && god->race.contains (shstr_undead)))) |
1547 | && god->race.contains (shstr_undead)))) |
1585 | return 0; |
1548 | return 0; |
1586 | } |
1549 | } |
1587 | |
1550 | |
1588 | maxattacktype = type; /* initialise this to something */ |
1551 | maxattacktype = type; /* initialise this to something */ |
1589 | for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) |
1552 | for_all_bits_sparse_32 (type, attacknum) |
1590 | { |
1553 | { |
|
|
1554 | uint32_t attacktype = 1 << attacknum; |
|
|
1555 | |
1591 | /* Magic isn't really a true attack type - it gets combined with other |
1556 | /* Magic isn't really a true attack type - it gets combined with other |
1592 | * attack types. As such, skip it over. However, if magic is |
1557 | * attack types. As such, skip it over. However, if magic is |
1593 | * the only attacktype in the group, then still attack with it |
1558 | * the only attacktype in the group, then still attack with it |
1594 | */ |
1559 | */ |
1595 | if ((attacktype == AT_MAGIC) && (type & ~AT_MAGIC)) |
1560 | if ((attacktype == AT_MAGIC) && (type & ~AT_MAGIC)) |
… | |
… | |
1598 | /* Go through and hit the player with each attacktype, one by one. |
1563 | /* Go through and hit the player with each attacktype, one by one. |
1599 | * hit_player_attacktype only figures out the damage, doesn't inflict |
1564 | * hit_player_attacktype only figures out the damage, doesn't inflict |
1600 | * it. It will do the appropriate action for attacktypes with |
1565 | * it. It will do the appropriate action for attacktypes with |
1601 | * effects (slow, paralization, etc. |
1566 | * effects (slow, paralization, etc. |
1602 | */ |
1567 | */ |
1603 | if (type & attacktype) |
|
|
1604 | { |
|
|
1605 | ndam = hit_player_attacktype (op, hitter, dam, attacknum, magic); |
1568 | ndam = hit_player_attacktype (op, hitter, dam, attacknum, magic); |
|
|
1569 | |
1606 | /* the >= causes us to prefer messages from special attacks, if |
1570 | /* the >= causes us to prefer messages from special attacks, if |
1607 | * the damage is equal. |
1571 | * the damage is equal. |
1608 | */ |
1572 | */ |
1609 | if (ndam >= maxdam) |
1573 | if (ndam >= maxdam) |
1610 | { |
1574 | { |
1611 | maxdam = ndam; |
1575 | maxdam = ndam; |
1612 | maxattacktype = 1 << attacknum; |
1576 | maxattacktype = 1 << attacknum; |
1613 | } |
|
|
1614 | } |
1577 | } |
1615 | } |
1578 | } |
1616 | |
1579 | |
1617 | /* if this is friendly fire then do a set % of damage only |
1580 | /* if this is friendly fire then do a set % of damage only |
1618 | * Note - put a check in to make sure this attack is actually |
1581 | * Note - put a check in to make sure this attack is actually |
… | |
… | |
1658 | // 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 |
1659 | // for an non-active objetc to know its enemy. |
1622 | // for an non-active objetc to know its enemy. |
1660 | if (op->active) |
1623 | if (op->active) |
1661 | if (hitter->owner) |
1624 | if (hitter->owner) |
1662 | op->enemy = hitter->owner; |
1625 | op->enemy = hitter->owner; |
1663 | else if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
1626 | else if (hitter->flag [FLAG_ALIVE]) |
1664 | op->enemy = hitter; |
1627 | op->enemy = hitter; |
1665 | |
1628 | |
1666 | if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) |
1629 | if (op->flag [FLAG_UNAGGRESSIVE] && op->type != PLAYER) |
1667 | { |
1630 | { |
1668 | /* The unaggressives look after themselves 8) */ |
1631 | /* The unaggressives look after themselves 8) */ |
1669 | CLEAR_FLAG (op, FLAG_UNAGGRESSIVE); |
1632 | op->clr_flag (FLAG_UNAGGRESSIVE); |
1670 | npc_call_help (op); |
1633 | npc_call_help (op); |
1671 | } |
1634 | } |
1672 | |
1635 | |
1673 | if (magic && did_make_save (op, op->level, 0)) |
1636 | if (magic && did_make_save (op, op->level, 0)) |
1674 | maxdam = maxdam / 2; |
1637 | maxdam = maxdam / 2; |
… | |
… | |
1676 | attack_message (maxdam, maxattacktype, op, hitter); |
1639 | attack_message (maxdam, maxattacktype, op, hitter); |
1677 | |
1640 | |
1678 | op->stats.hp -= maxdam; |
1641 | op->stats.hp -= maxdam; |
1679 | |
1642 | |
1680 | /* Eneq(@csd.uu.se): Check to see if monster runs away. */ |
1643 | /* Eneq(@csd.uu.se): Check to see if monster runs away. */ |
1681 | if ((op->stats.hp >= 0) && |
1644 | if (op->stats.hp >= 0 |
1682 | (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) && |
1645 | && (op->flag [FLAG_MONSTER] || op->type == PLAYER) |
1683 | op->stats.hp < (signed short) (((float) op->run_away / (float) 100) * (float) op->stats.maxhp)) |
1646 | && op->stats.hp * 100 < op->stats.maxhp * op->run_away) |
1684 | { |
1647 | { |
1685 | |
1648 | |
1686 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
1649 | if (op->flag [FLAG_MONSTER]) |
1687 | SET_FLAG (op, FLAG_RUN_AWAY); |
1650 | op->set_flag (FLAG_RUN_AWAY); |
1688 | else |
1651 | else |
1689 | scare_creature (op, hitter); |
1652 | scare_creature (op, hitter); |
1690 | } |
1653 | } |
1691 | |
1654 | |
1692 | if (QUERY_FLAG (op, FLAG_TEAR_DOWN)) |
1655 | if (op->flag [FLAG_TEAR_DOWN]) |
1693 | { |
1656 | { |
1694 | if (maxdam) |
1657 | if (maxdam) |
1695 | tear_down_wall (op); |
1658 | tear_down_wall (op); |
1696 | |
1659 | |
1697 | return maxdam; /* nothing more to do for wall */ |
1660 | return maxdam; /* nothing more to do for wall */ |
… | |
… | |
1704 | |
1667 | |
1705 | /* 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 |
1706 | * that before if the player was immune to ghosthit, the monster |
1669 | * that before if the player was immune to ghosthit, the monster |
1707 | * remained - that is no longer the case. |
1670 | * remained - that is no longer the case. |
1708 | */ |
1671 | */ |
1709 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1672 | if (hitter->flag [FLAG_ONE_HIT]) |
1710 | hitter->drop_and_destroy (); |
1673 | hitter->drop_and_destroy (); |
1711 | /* Lets handle creatures that are splitting now */ |
1674 | /* Lets handle creatures that are splitting now */ |
1712 | 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]) |
1713 | { |
1676 | { |
1714 | int i; |
|
|
1715 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1677 | int friendly = op->flag [FLAG_FRIENDLY]; |
1716 | int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); |
1678 | int unaggressive = op->flag [FLAG_UNAGGRESSIVE]; |
1717 | object *owner = op->owner; |
1679 | object *owner = op->owner; |
1718 | |
1680 | |
1719 | if (!op->other_arch) |
1681 | if (!op->other_arch) |
1720 | { |
1682 | { |
1721 | LOG (llevError, "SPLITTING without other_arch error.\n"); |
1683 | LOG (llevError, "SPLITTING without other_arch error.\n"); |
1722 | return maxdam; |
1684 | return maxdam; |
1723 | } |
1685 | } |
1724 | |
1686 | |
1725 | op->remove (); |
1687 | op->remove (); |
1726 | |
1688 | |
1727 | for (i = 0; i < op->stats.food; i++) |
1689 | for (int i = 0; i < op->stats.food; i++) |
1728 | { /* This doesn't handle op->more yet */ |
1690 | { /* This doesn't handle op->more yet */ |
1729 | object *tmp = arch_to_object (op->other_arch); |
1691 | object *tmp = op->other_arch->instance (); |
1730 | int j; |
|
|
1731 | |
1692 | |
1732 | tmp->stats.hp = op->stats.hp; |
1693 | tmp->stats.hp = op->stats.hp; |
1733 | |
1694 | |
1734 | if (friendly) |
1695 | if (friendly) |
1735 | { |
1696 | { |
… | |
… | |
1739 | if (owner) |
1700 | if (owner) |
1740 | tmp->set_owner (owner); |
1701 | tmp->set_owner (owner); |
1741 | } |
1702 | } |
1742 | |
1703 | |
1743 | if (unaggressive) |
1704 | if (unaggressive) |
1744 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1705 | tmp->set_flag (FLAG_UNAGGRESSIVE); |
1745 | |
1706 | |
1746 | 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); |
1747 | |
1708 | |
1748 | if (j == -1) /* No spot to put this monster */ |
1709 | if (j == -1) /* No spot to put this monster */ |
1749 | tmp->destroy (); |
1710 | tmp->destroy (); |
1750 | else |
1711 | else |
1751 | { |
1712 | { |
… | |
… | |
1766 | poison_player (object *op, object *hitter, int dam) |
1727 | poison_player (object *op, object *hitter, int dam) |
1767 | { |
1728 | { |
1768 | archetype *at = archetype::find (shstr_poisoning); |
1729 | archetype *at = archetype::find (shstr_poisoning); |
1769 | object *tmp = present_arch_in_ob (at, op); |
1730 | object *tmp = present_arch_in_ob (at, op); |
1770 | |
1731 | |
1771 | if (tmp == NULL) |
1732 | if (!tmp) |
1772 | { |
1733 | { |
1773 | if ((tmp = arch_to_object (at)) == NULL) |
1734 | tmp = insert_ob_in_ob (at->instance (), op); |
1774 | LOG (llevError, "Failed to clone arch poisoning.\n"); |
1735 | /* peterm: give poisoning some teeth. It should |
|
|
1736 | * be able to kill things better than it does: |
|
|
1737 | * damage should be dependent something--I choose to |
|
|
1738 | * do this: if it's a monster, the damage from the |
|
|
1739 | * poisoning goes as the level of the monster/2. |
|
|
1740 | * If anything else, goes as damage. |
|
|
1741 | */ |
|
|
1742 | |
|
|
1743 | if (hitter->flag [FLAG_ALIVE]) |
|
|
1744 | tmp->stats.dam += hitter->level / 2; |
1775 | else |
1745 | else |
1776 | { |
|
|
1777 | tmp = insert_ob_in_ob (tmp, op); |
|
|
1778 | /* peterm: give poisoning some teeth. It should |
|
|
1779 | * be able to kill things better than it does: |
|
|
1780 | * damage should be dependent something--I choose to |
|
|
1781 | * do this: if it's a monster, the damage from the |
|
|
1782 | * poisoning goes as the level of the monster/2. |
|
|
1783 | * If anything else, goes as damage. |
|
|
1784 | */ |
|
|
1785 | |
|
|
1786 | if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
|
|
1787 | tmp->stats.dam += hitter->level / 2; |
|
|
1788 | else |
|
|
1789 | tmp->stats.dam = dam; |
1746 | tmp->stats.dam = dam; |
1790 | |
1747 | |
1791 | tmp->set_owner (hitter); /* so we get credit for poisoning kills */ |
1748 | tmp->set_owner (hitter); /* so we get credit for poisoning kills */ |
1792 | if (hitter->skill && hitter->skill != tmp->skill) |
1749 | if (hitter->skill && hitter->skill != tmp->skill) |
1793 | { |
|
|
1794 | tmp->skill = hitter->skill; |
1750 | tmp->skill = hitter->skill; |
1795 | } |
|
|
1796 | |
1751 | |
1797 | tmp->stats.food += dam; /* more damage, longer poisoning */ |
1752 | tmp->stats.food += dam; /* more damage, longer poisoning */ |
1798 | |
1753 | |
1799 | if (op->type == PLAYER) |
1754 | if (op->type == PLAYER) |
1800 | { |
1755 | { |
1801 | /* player looses stats, maximum is -10 of each */ |
1756 | /* player looses stats, maximum is -10 of each */ |
1802 | tmp->stats.Con = max (-(dam / 4 + 1), -10); |
1757 | tmp->stats.Con = max (-(dam / 4 + 1), -10); |
1803 | tmp->stats.Str = max (-(dam / 3 + 2), -10); |
1758 | tmp->stats.Str = max (-(dam / 3 + 2), -10); |
1804 | tmp->stats.Dex = max (-(dam / 6 + 1), -10); |
1759 | tmp->stats.Dex = max (-(dam / 6 + 1), -10); |
1805 | tmp->stats.Int = max (-(dam / 7 ), -10); |
1760 | tmp->stats.Int = max (-(dam / 7 ), -10); |
1806 | SET_FLAG (tmp, FLAG_APPLIED); |
1761 | tmp->set_flag (FLAG_APPLIED); |
1807 | op->update_stats (); |
1762 | op->update_stats (); |
1808 | 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."); |
1809 | op->play_sound (tmp->sound); |
1764 | op->play_sound (tmp->sound); |
1810 | } |
1765 | } |
1811 | |
1766 | |
1812 | if (hitter->type == PLAYER) |
1767 | if (hitter->type == PLAYER) |
1813 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
1768 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
1814 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
1769 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
1815 | new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); |
1770 | new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); |
1816 | } |
|
|
1817 | |
1771 | |
1818 | tmp->speed_left = 0; |
1772 | tmp->speed_left = 0; |
1819 | } |
1773 | } |
1820 | else |
1774 | else |
1821 | tmp->stats.food++; |
1775 | tmp->stats.food++; |
… | |
… | |
1825 | slow_player (object *op, object *hitter, int dam) |
1779 | slow_player (object *op, object *hitter, int dam) |
1826 | { |
1780 | { |
1827 | archetype *at = archetype::find (shstr_slowness); |
1781 | archetype *at = archetype::find (shstr_slowness); |
1828 | object *tmp; |
1782 | object *tmp; |
1829 | |
1783 | |
1830 | if (at == NULL) |
1784 | if (!at) |
1831 | LOG (llevError, "Can't find slowness archetype.\n"); |
1785 | LOG (llevError, "Can't find slowness archetype.\n"); |
1832 | |
1786 | |
1833 | if ((tmp = present_arch_in_ob (at, op)) == NULL) |
1787 | if ((tmp = present_arch_in_ob (at, op)) == NULL) |
1834 | { |
1788 | { |
1835 | tmp = arch_to_object (at); |
1789 | tmp = at->instance (); |
1836 | tmp = insert_ob_in_ob (tmp, op); |
1790 | tmp = insert_ob_in_ob (tmp, op); |
1837 | 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!"); |
1838 | } |
1792 | } |
1839 | else |
1793 | else |
1840 | tmp->stats.food++; |
1794 | tmp->stats.food++; |
1841 | |
1795 | |
1842 | SET_FLAG (tmp, FLAG_APPLIED); |
1796 | tmp->set_flag (FLAG_APPLIED); |
1843 | tmp->speed_left = 0; |
1797 | tmp->speed_left = 0; |
1844 | op->update_stats (); |
1798 | op->update_stats (); |
1845 | } |
1799 | } |
1846 | |
1800 | |
1847 | void |
1801 | void |
… | |
… | |
1851 | int maxduration; |
1805 | int maxduration; |
1852 | |
1806 | |
1853 | tmp = present_in_ob_by_name (FORCE, shstr_confusion, op); |
1807 | tmp = present_in_ob_by_name (FORCE, shstr_confusion, op); |
1854 | if (!tmp) |
1808 | if (!tmp) |
1855 | { |
1809 | { |
1856 | tmp = get_archetype (FORCE_NAME); |
1810 | tmp = archetype::get (FORCE_NAME); |
1857 | tmp = insert_ob_in_ob (tmp, op); |
1811 | tmp = insert_ob_in_ob (tmp, op); |
1858 | } |
1812 | } |
1859 | |
1813 | |
1860 | /* Duration added per hit and max. duration of confusion both depend |
1814 | /* Duration added per hit and max. duration of confusion both depend |
1861 | * on the player's resistance |
1815 | * on the player's resistance |
1862 | */ |
1816 | */ |
1863 | tmp->speed = 0.05; |
1817 | tmp->set_speed (0.05); |
1864 | tmp->subtype = FORCE_CONFUSION; |
1818 | tmp->subtype = FORCE_CONFUSION; |
1865 | 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); |
1866 | tmp->name = shstr_confusion; |
1820 | tmp->name = shstr_confusion; |
1867 | maxduration = max (2, 30 * (100 - op->resist[ATNR_CONFUSION]) / 100); |
1821 | maxduration = max (2, 30 * (100 - op->resist[ATNR_CONFUSION]) / 100); |
1868 | |
1822 | |
1869 | if (tmp->duration > maxduration) |
1823 | if (tmp->duration > maxduration) |
1870 | tmp->duration = maxduration; |
1824 | tmp->duration = maxduration; |
1871 | |
1825 | |
1872 | if (op->type == PLAYER && !QUERY_FLAG (op, FLAG_CONFUSED)) |
1826 | if (op->type == PLAYER && !op->flag [FLAG_CONFUSED]) |
1873 | 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!"); |
1874 | |
1828 | |
1875 | SET_FLAG (op, FLAG_CONFUSED); |
1829 | op->set_flag (FLAG_CONFUSED); |
1876 | } |
1830 | } |
1877 | |
1831 | |
1878 | void |
1832 | void |
1879 | blind_player (object *op, object *hitter, int dam) |
1833 | blind_player (object *op, object *hitter, int dam) |
1880 | { |
1834 | { |
1881 | object *tmp, *owner; |
|
|
1882 | |
|
|
1883 | /* 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 */ |
1884 | if (op->resist[ATNR_BLIND] == 100) |
1836 | if (op->resist[ATNR_BLIND] == 100) |
1885 | return; |
1837 | return; |
1886 | |
1838 | |
1887 | tmp = present_in_ob (BLINDNESS, op); |
1839 | object *tmp = present_in_ob (BLINDNESS, op); |
1888 | if (!tmp) |
1840 | if (!tmp) |
1889 | { |
1841 | { |
1890 | tmp = get_archetype (shstr_blindness); |
1842 | tmp = archetype::get (shstr_blindness); |
1891 | SET_FLAG (tmp, FLAG_BLIND); |
1843 | tmp->set_flag (FLAG_BLIND); |
1892 | SET_FLAG (tmp, FLAG_APPLIED); |
1844 | tmp->set_flag (FLAG_APPLIED); |
1893 | /* 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. |
1894 | * speed is a float anyways. |
1846 | tmp->set_speed (lerp<float> (op->resist [ATNR_BLIND], 0, 100, tmp->speed, MIN_ACTIVE_SPEED)); |
1895 | */ |
|
|
1896 | tmp->speed = tmp->speed * (100.0 - (float) op->resist[ATNR_BLIND]) / 100; |
|
|
1897 | |
1847 | |
1898 | tmp = insert_ob_in_ob (tmp, op); |
1848 | tmp = insert_ob_in_ob (tmp, op); |
1899 | change_abil (op, tmp); /* Mostly to display any messages */ |
1849 | change_abil (op, tmp); /* Mostly to display any messages */ |
1900 | op->update_stats (); /* This takes care of some other stuff */ |
1850 | op->update_stats (); /* This takes care of some other stuff */ |
1901 | |
1851 | |
1902 | if (hitter->owner) |
|
|
1903 | owner = hitter->owner; |
|
|
1904 | else |
|
|
1905 | owner = hitter; |
|
|
1906 | |
|
|
1907 | 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)); |
1908 | } |
1853 | } |
|
|
1854 | |
1909 | tmp->stats.food += dam; |
1855 | tmp->stats.food += dam; |
1910 | if (tmp->stats.food > 10) |
1856 | min_it (tmp->stats.food, 10); |
1911 | tmp->stats.food = 10; |
|
|
1912 | } |
1857 | } |
1913 | |
1858 | |
1914 | void |
1859 | void |
1915 | paralyze_player (object *op, object *hitter, int dam) |
1860 | paralyze_player (object *op, object *hitter, int dam) |
1916 | { |
1861 | { |
… | |
… | |
1927 | */ |
1872 | */ |
1928 | |
1873 | |
1929 | /* Do this as a float - otherwise, rounding might very well reduce this to 0 */ |
1874 | /* Do this as a float - otherwise, rounding might very well reduce this to 0 */ |
1930 | float effect = dam * 3.f * (100.f - op->resist[ATNR_PARALYZE]) / 100.f; |
1875 | float effect = dam * 3.f * (100.f - op->resist[ATNR_PARALYZE]) / 100.f; |
1931 | |
1876 | |
1932 | op->speed_left -= fabs (op->speed) * effect; |
1877 | op->speed_left -= op->speed * effect; |
1933 | /* tmp->stats.food+=(signed short) effect/op->speed; */ |
1878 | /* tmp->stats.food+=(signed short) effect/op->speed; */ |
1934 | |
1879 | |
1935 | /* max number of ticks to be affected for. */ |
1880 | /* max number of ticks to be affected for. */ |
1936 | float max = (100 - op->resist[ATNR_PARALYZE]) / 2; |
1881 | float max = (100 - op->resist[ATNR_PARALYZE]) / 2; |
1937 | |
1882 | |
1938 | if (op->speed_left < -(fabs (op->speed) * max)) |
1883 | max_it (op->speed_left, -op->speed * max); |
1939 | op->speed_left = -(fabs (op->speed) * max); |
|
|
1940 | |
1884 | |
1941 | /* tmp->stats.food = (signed short) (max / fabs (op->speed)); */ |
1885 | /* tmp->stats.food = (signed short) (max / op->speed); */ |
1942 | } |
1886 | } |
1943 | |
1887 | |
1944 | /* Attempts to kill 'op'. hitter is the attack object, dam is |
1888 | /* Attempts to kill 'op'. hitter is the attack object, dam is |
1945 | * the computed damaged. |
1889 | * the computed damaged. |
1946 | */ |
1890 | */ |
… | |
… | |
1956 | ** field of the deathstriking object */ |
1900 | ** field of the deathstriking object */ |
1957 | |
1901 | |
1958 | int atk_lev, def_lev, kill_lev; |
1902 | int atk_lev, def_lev, kill_lev; |
1959 | |
1903 | |
1960 | if (hitter->slaying) |
1904 | if (hitter->slaying) |
1961 | if (!((QUERY_FLAG (op, FLAG_UNDEAD) && hitter->slaying.contains (shstr_undead)) |
1905 | if (!((op->flag [FLAG_UNDEAD] && hitter->slaying.contains (shstr_undead)) |
1962 | || (op->race && hitter->slaying.contains (op->race)))) |
1906 | || (op->race && hitter->slaying.contains (op->race)))) |
1963 | return; |
1907 | return; |
1964 | |
1908 | |
1965 | def_lev = op->level; |
1909 | def_lev = op->level; |
1966 | if (def_lev < 1) |
1910 | if (def_lev < 1) |
… | |
… | |
2091 | * Second, just getting hit doesn't mean it always affects |
2035 | * Second, just getting hit doesn't mean it always affects |
2092 | * you. Third, you still get a saving through against the |
2036 | * you. Third, you still get a saving through against the |
2093 | * effect. |
2037 | * effect. |
2094 | */ |
2038 | */ |
2095 | if (op->has_active_speed () |
2039 | if (op->has_active_speed () |
2096 | && (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) |
2040 | && (op->flag [FLAG_MONSTER] || op->type == PLAYER) |
2097 | && !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) |
2041 | && !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) |
2098 | && !did_make_save (op, level_diff, op->resist[attacknum] / 10)) |
2042 | && !did_make_save (op, level_diff, op->resist[attacknum] / 10)) |
2099 | { |
2043 | { |
2100 | |
2044 | |
2101 | /* Player has been hit by something */ |
2045 | /* Player has been hit by something */ |
… | |
… | |
2111 | scare_creature (op, hitter); |
2055 | scare_creature (op, hitter); |
2112 | else if (attacknum == ATNR_CANCELLATION) |
2056 | else if (attacknum == ATNR_CANCELLATION) |
2113 | cancellation (op); |
2057 | cancellation (op); |
2114 | else if (attacknum == ATNR_DEPLETE) |
2058 | else if (attacknum == ATNR_DEPLETE) |
2115 | op->drain_stat (); |
2059 | op->drain_stat (); |
2116 | 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]) |
2117 | blind_player (op, hitter, dam); |
2061 | blind_player (op, hitter, dam); |
2118 | } |
2062 | } |
2119 | |
2063 | |
2120 | 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 */ |
2121 | } |
2065 | } |
… | |
… | |
2131 | { |
2075 | { |
2132 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2076 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2133 | { |
2077 | { |
2134 | if (tmp->invisible) |
2078 | if (tmp->invisible) |
2135 | continue; |
2079 | continue; |
2136 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) |
2080 | if (!tmp->flag [FLAG_APPLIED] || (tmp->resist[ATNR_ACID] >= 10)) |
2137 | /* >= 10% acid res. on items will protect these */ |
2081 | /* >= 10% acid res. on items will protect these */ |
2138 | continue; |
2082 | continue; |
2139 | if (!(tmp->materials & M_IRON)) |
2083 | if (!(tmp->materials & M_IRON)) |
2140 | continue; |
2084 | continue; |
2141 | if (tmp->magic < -4) /* Let's stop at -5 */ |
2085 | if (tmp->magic < -4) /* Let's stop at -5 */ |
… | |
… | |
2186 | rate = 400 * 100 / (100 - op->resist[ATNR_DRAIN]); |
2130 | rate = 400 * 100 / (100 - op->resist[ATNR_DRAIN]); |
2187 | |
2131 | |
2188 | if (op->stats.exp <= rate) |
2132 | if (op->stats.exp <= rate) |
2189 | { |
2133 | { |
2190 | if (op->type == GOLEM) |
2134 | if (op->type == GOLEM) |
2191 | dam = 999; /* Its force is "sucked" away. 8) */ |
2135 | dam = 9998; /* Its force is "sucked" away. 8) */ |
2192 | else |
2136 | else |
2193 | /* If we can't drain, lets try to do physical damage */ |
2137 | /* If we can't drain, lets try to do physical damage */ |
2194 | dam = hit_player_attacktype (op, hitter, dam, ATNR_PHYSICAL, magic); |
2138 | dam = hit_player_attacktype (op, hitter, dam, ATNR_PHYSICAL, magic); |
2195 | } |
2139 | } |
2196 | else |
2140 | else |
… | |
… | |
2205 | * 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, |
2206 | * nothing happens. |
2150 | * nothing happens. |
2207 | * 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 |
2208 | * attacks, hence all the != PLAYER checks. |
2152 | * attacks, hence all the != PLAYER checks. |
2209 | */ |
2153 | */ |
2210 | if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WIZ)) |
2154 | if (!op_on_battleground (hitter, NULL, NULL) && !op->flag [FLAG_WIZ]) |
2211 | { |
2155 | { |
2212 | object *owner = hitter->owner; |
2156 | object *owner = hitter->owner; |
2213 | |
2157 | |
2214 | if (owner && owner != hitter) |
2158 | if (owner && owner != hitter) |
2215 | { |
2159 | { |
2216 | if (op->type != PLAYER || owner->type != PLAYER) |
2160 | if (op->type != PLAYER || owner->type != PLAYER) |
2217 | change_exp (owner, op->stats.exp / (rate * 2), |
2161 | change_exp (owner, op->stats.exp / (rate * 2), |
2218 | 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); |
2219 | } |
2163 | } |
2220 | else if (op->type != PLAYER || hitter->type != PLAYER) |
2164 | else if (op->type != PLAYER || hitter->type != PLAYER) |
2221 | change_exp (hitter, op->stats.exp / (rate * 2), |
2165 | change_exp (hitter, op->stats.exp / (rate * 2), |
2222 | hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); |
2166 | hitter->chosen_skill ? hitter->chosen_skill->skill : shstr (), 0); |
2223 | |
2167 | |
2224 | change_exp (op, -op->stats.exp / rate, NULL, 0); |
2168 | change_exp (op, -op->stats.exp / rate, shstr (), 0); |
2225 | } |
2169 | } |
2226 | |
2170 | |
2227 | 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 |
2228 | * 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, |
2229 | * as the messages will say you missed |
2173 | * as the messages will say you missed |
… | |
… | |
2232 | } |
2176 | } |
2233 | break; |
2177 | break; |
2234 | |
2178 | |
2235 | case ATNR_TURN_UNDEAD: |
2179 | case ATNR_TURN_UNDEAD: |
2236 | { |
2180 | { |
2237 | if (QUERY_FLAG (op, FLAG_UNDEAD)) |
2181 | if (op->flag [FLAG_UNDEAD]) |
2238 | { |
2182 | { |
2239 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
2183 | object *owner = hitter->owner ? (object *)hitter->owner : hitter; |
2240 | object *god = find_god (determine_god (owner)); |
2184 | object *god = find_god (determine_god (owner)); |
2241 | int div = 1; |
2185 | int div = 1; |
2242 | |
2186 | |
… | |
… | |
2297 | * damage it does do to the player. Given that, |
2241 | * damage it does do to the player. Given that, |
2298 | * 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 |
2299 | * 1000). |
2243 | * 1000). |
2300 | */ |
2244 | */ |
2301 | /* You can't steal life from something undead */ |
2245 | /* You can't steal life from something undead */ |
2302 | if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD))) |
2246 | if ((op->type == GOLEM) || (op->flag [FLAG_UNDEAD])) |
2303 | return 0; |
2247 | return 0; |
2304 | |
2248 | |
2305 | /* If drain protection is higher than life stealing, use that */ |
2249 | /* If drain protection is higher than life stealing, use that */ |
2306 | if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) |
2250 | if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) |
2307 | dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; |
2251 | dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; |