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.15 by root, Thu Sep 14 20:46:10 2006 UTC vs.
Revision 1.45 by pippijn, Mon Jan 15 21:06:19 2007 UTC

1
2/* 1/*
3 * static char *rcsid_attack_c = 2 * CrossFire, A Multiplayer game for X-windows
4 * "$Id: attack.C,v 1.15 2006/09/14 20:46:10 root Exp $"; 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
5 */ 23 */
6
7/*
8 CrossFire, A Multiplayer game for X-windows
9
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 The authors can be reached via e-mail to crossfire-devel@real-time.com
28*/
29#include <assert.h> 24#include <assert.h>
30#include <global.h> 25#include <global.h>
31#include <living.h> 26#include <living.h>
32#include <material.h> 27#include <material.h>
33#include <skills.h> 28#include <skills.h>
50 * its magical benefits. 45 * its magical benefits.
51 */ 46 */
52void 47void
53cancellation (object *op) 48cancellation (object *op)
54{ 49{
55 object *tmp;
56
57 if (op->invisible) 50 if (op->invisible)
58 return; 51 return;
59 52
60 if (QUERY_FLAG (op, FLAG_ALIVE) || op->type == CONTAINER || op->type == THROWN_OBJ) 53 if (QUERY_FLAG (op, FLAG_ALIVE) || op->type == CONTAINER || op->type == THROWN_OBJ)
61 { 54 {
62 /* Recur through the inventory */ 55 /* Recurse through the inventory */
63 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 56 for (object *tmp = op->inv; tmp; tmp = tmp->below)
64 if (!did_make_save_item (tmp, AT_CANCELLATION, op)) 57 if (!did_make_save_item (tmp, AT_CANCELLATION, op))
65 cancellation (tmp); 58 cancellation (tmp);
66 } 59 }
67 else if (FABS (op->magic) <= (rndm (0, 5))) 60 else if (FABS (op->magic) <= rndm (0, 5))
68 { 61 {
69 /* Nullify this object. This code could probably be more complete */ 62 /* Nullify this object. This code could probably be more complete */
70 /* in what abilities it should cancel */ 63 /* in what abilities it should cancel */
71 op->magic = 0; 64 op->magic = 0;
65
72 CLEAR_FLAG (op, FLAG_DAMNED); 66 CLEAR_FLAG (op, FLAG_DAMNED);
73 CLEAR_FLAG (op, FLAG_CURSED); 67 CLEAR_FLAG (op, FLAG_CURSED);
74 CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); 68 CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL);
75 CLEAR_FLAG (op, FLAG_KNOWN_CURSED); 69 CLEAR_FLAG (op, FLAG_KNOWN_CURSED);
70
76 if (op->env && op->env->type == PLAYER) 71 if (op->env && op->env->type == PLAYER)
77 {
78 esrv_send_item (op->env, op); 72 esrv_send_item (op->env, op);
79 }
80 } 73 }
81} 74}
82
83
84 75
85/* did_make_save_item just checks to make sure the item actually 76/* did_make_save_item just checks to make sure the item actually
86 * made its saving throw based on the tables. It does not take 77 * made its saving throw based on the tables. It does not take
87 * any further action (like destroying the item). 78 * any further action (like destroying the item).
88 */ 79 */
89
90int 80int
91did_make_save_item (object *op, int type, object *originator) 81did_make_save_item (object *op, int type, object *originator)
92{ 82{
93 int i, roll, saves = 0, attacks = 0, number; 83 int i, roll, saves = 0, attacks = 0, number;
94 materialtype_t *mt; 84 materialtype_t *mt;
95 85
96 if (op->materialname == NULL) 86 if (op->materialname == NULL)
97 { 87 {
98 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) 88 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next)
99 {
100 if (op->material & mt->material) 89 if (op->material & mt->material)
101 break; 90 break;
102 }
103 } 91 }
104 else 92 else
105 mt = name_to_material (op->materialname); 93 mt = name_to_material (op->materialname);
94
106 if (mt == NULL) 95 if (mt == NULL)
107 return TRUE; 96 return TRUE;
97
108 roll = rndm (1, 20); 98 roll = rndm (1, 20);
109 99
110 /* the attacktypes have no meaning for object saves 100 /* the attacktypes have no meaning for object saves
111 * If the type is only magic, don't adjust type - basically, if 101 * If the type is only magic, don't adjust type - basically, if
112 * pure magic is hitting an object, it should save. However, if it 102 * pure magic is hitting an object, it should save. However, if it
150 140
151/* This function calls did_make_save_item. It then performs the 141/* This function calls did_make_save_item. It then performs the
152 * appropriate actions to the item (such as burning the item up, 142 * appropriate actions to the item (such as burning the item up,
153 * calling cancellation, etc.) 143 * calling cancellation, etc.)
154 */ 144 */
155
156void 145void
157save_throw_object (object *op, int type, object *originator) 146save_throw_object (object *op, int type, object *originator)
158{ 147{
159 if (!did_make_save_item (op, type, originator)) 148 if (!did_make_save_item (op, type, originator))
160 { 149 {
161 object *env = op->env; 150 object *env = op->env;
162 int x = op->x, y = op->y; 151 int x = op->x, y = op->y;
163 mapstruct *m = op->map; 152 maptile *m = op->map;
164 153
165 op = stop_item (op); 154 op = stop_item (op);
166 if (op == NULL) 155 if (op == NULL)
167 return; 156 return;
168 157
218 } 207 }
219 else 208 else
220 { 209 {
221 if (op->env) 210 if (op->env)
222 { 211 {
223 object *tmp = is_player_inv (op->env); 212 object *tmp = op->in_player ();
224 213
225 if (tmp) 214 if (tmp)
226 esrv_del_item (tmp->contr, op->count); 215 esrv_del_item (tmp->contr, op->count);
227 } 216 }
228 217
229 if (!QUERY_FLAG (op, FLAG_REMOVED)) 218 op->destroy ();
230 remove_ob (op);
231
232 free_object (op);
233 } 219 }
234 220
235 if (type & (AT_FIRE | AT_ELECTRICITY)) 221 if (type & (AT_FIRE | AT_ELECTRICITY))
236 if (env) 222 if (env)
237 { 223 {
247 233
248 /* The value of 50 is arbitrary. */ 234 /* The value of 50 is arbitrary. */
249 if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) 235 if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2))
250 { 236 {
251 object *tmp; 237 object *tmp;
252 archetype *at = find_archetype ("icecube"); 238 archetype *at = archetype::find ("icecube");
253 239
254 if (at == NULL) 240 if (at == NULL)
255 return; 241 return;
256 242
257 op = stop_item (op); 243 op = stop_item (op);
270 tmp->move_slow = 0; 256 tmp->move_slow = 0;
271 insert_ob_in_map (tmp, op->map, originator, 0); 257 insert_ob_in_map (tmp, op->map, originator, 0);
272 } 258 }
273 259
274 if (!QUERY_FLAG (op, FLAG_REMOVED)) 260 if (!QUERY_FLAG (op, FLAG_REMOVED))
275 remove_ob (op); 261 op->remove ();
276 262
277 insert_ob_in_ob (op, tmp); 263 insert_ob_in_ob (op, tmp);
278 return; 264 return;
279 } 265 }
280} 266}
287 */ 273 */
288 274
289int 275int
290hit_map (object *op, int dir, int type, int full_hit) 276hit_map (object *op, int dir, int type, int full_hit)
291{ 277{
292 object *tmp, *next;
293 mapstruct *map; 278 maptile *map;
294 sint16 x, y; 279 sint16 x, y;
295 int retflag = 0; /* added this flag.. will return 1 if it hits a monster */ 280 int retflag = 0; /* added this flag.. will return 1 if it hits a monster */
296 281
297 tag_t op_tag, next_tag = 0;
298
299 if (QUERY_FLAG (op, FLAG_FREED)) 282 if (QUERY_FLAG (op, FLAG_FREED))
300 { 283 {
301 LOG (llevError, "BUG: hit_map(): free object\n"); 284 LOG (llevError, "BUG: hit_map(): free object\n");
302 return 0; 285 return 0;
303 } 286 }
314 return 0; 297 return 0;
315 } 298 }
316 299
317 if (op->head) 300 if (op->head)
318 op = op->head; 301 op = op->head;
319
320 op_tag = op->count;
321 302
322 map = op->map; 303 map = op->map;
323 x = op->x + freearr_x[dir]; 304 x = op->x + freearr_x[dir];
324 y = op->y + freearr_y[dir]; 305 y = op->y + freearr_y[dir];
325 306
326 int mflags = get_map_flags (map, &map, x, y, &x, &y); 307 if (!xy_normalise (map, x, y))
308 return 0;
327 309
328 // elmex: a safe map tile can't be hit! 310 // elmex: a safe map tile can't be hit!
329 // this should prevent most harmful effects on items and players there. 311 // this should prevent most harmful effects on items and players there.
330 if (mflags & (P_OUT_OF_MAP | P_SAFE)) 312 mapspace &ms = map->at (x, y);
313
314 if (ms.flags () & P_SAFE)
331 return 0; 315 return 0;
332 316
333 /* peterm: a few special cases for special attacktypes --counterspell 317 /* peterm: a few special cases for special attacktypes --counterspell
334 * must be out here because it strikes things which are not alive 318 * must be out here because it strikes things which are not alive
335 */ 319 */
336 320 if (type & (AT_COUNTERSPELL | AT_CHAOS))
321 {
337 if (type & AT_COUNTERSPELL) 322 if (type & AT_COUNTERSPELL)
338 { 323 {
339 counterspell (op, dir); /* see spell_effect.c */ 324 counterspell (op, dir); /* see spell_effect.c */
340 325
341 /* If the only attacktype is counterspell or magic, don't need 326 /* If the only attacktype is counterspell or magic, don't need
342 * to do any further processing. 327 * to do any further processing.
343 */
344 if (!(type & ~(AT_COUNTERSPELL | AT_MAGIC)))
345 return 0;
346
347 type &= ~AT_COUNTERSPELL;
348 }
349
350 if (type & AT_CHAOS)
351 {
352 shuffle_attack (op, 1); /*1 flag tells it to change the face */
353 update_object (op, UP_OBJ_FACE);
354 type &= ~AT_CHAOS;
355 }
356
357 next = get_map_ob (map, x, y);
358 if (next)
359 next_tag = next->count;
360
361 while (next)
362 {
363 if (was_destroyed (next, next_tag))
364 {
365 /* There may still be objects that were above 'next', but there is no
366 * simple way to find out short of copying all object references and
367 * tags into a temporary array before we start processing the first
368 * object. That's why we just abort.
369 *
370 * This happens whenever attack spells (like fire) hit a pile
371 * of objects. This is not a bug - nor an error. The errormessage
372 * below was spamming the logs for absolutely no reason.
373 */ 328 */
374 /* LOG (llevDebug, "hit_map(): next object destroyed\n"); */ 329 if (!(type & ~(AT_COUNTERSPELL | AT_MAGIC)))
375 break; 330 return 0;
331
332 type &= ~AT_COUNTERSPELL;
333 }
334
335 if (type & AT_CHAOS)
376 } 336 {
337 shuffle_attack (op, 1); /* flag tells it to change the face */
338 update_object (op, UP_OBJ_FACE);
339 type &= ~AT_CHAOS;
340 }
341 }
377 342
343 /* There may still be objects that were above 'next', but there is no
344 * simple way to find out short of copying all object references and
345 * tags into a temporary array before we start processing the first
346 * object. That's why we just abort on destroy.
347 *
348 * This happens whenever attack spells (like fire) hit a pile
349 * of objects. This is not a bug - nor an error.
350 */
351 for (object *next = ms.bot; next && !next->destroyed (); )
352 {
378 tmp = next; 353 object *tmp = next;
379 next = tmp->above; 354 next = tmp->above;
380
381 if (next)
382 next_tag = next->count;
383
384 if (QUERY_FLAG (tmp, FLAG_FREED))
385 {
386 LOG (llevError, "BUG: hit_map(): found freed object\n");
387 break;
388 }
389 355
390 /* Something could have happened to 'tmp' while 'tmp->below' was processed. 356 /* Something could have happened to 'tmp' while 'tmp->below' was processed.
391 * For example, 'tmp' was put in an icecube. 357 * For example, 'tmp' was put in an icecube.
392 * This is one of the few cases where on_same_map should not be used. 358 * This is one of the few cases where on_same_map should not be used.
393 */ 359 */
396 362
397 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 363 if (QUERY_FLAG (tmp, FLAG_ALIVE))
398 { 364 {
399 hit_player (tmp, op->stats.dam, op, type, full_hit); 365 hit_player (tmp, op->stats.dam, op, type, full_hit);
400 retflag |= 1; 366 retflag |= 1;
367
401 if (was_destroyed (op, op_tag)) 368 if (op->destroyed ())
402 break; 369 break;
403 } 370 }
404
405 /* Here we are potentially destroying an object. If the object has 371 /* Here we are potentially destroying an object. If the object has
406 * NO_PASS set, it is also immune - you can't destroy walls. Note 372 * NO_PASS set, it is also immune - you can't destroy walls. Note
407 * that weak walls have is_alive set, which prevent objects from 373 * that weak walls have is_alive set, which prevent objects from
408 * passing over/through them. We don't care what type of movement 374 * passing over/through them. We don't care what type of movement
409 * the wall blocks - if it blocks any type of movement, can't be 375 * the wall blocks - if it blocks any type of movement, can't be
410 * destroyed right now. 376 * destroyed right now.
411 */ 377 */
412 else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block) 378 else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block)
413 { 379 {
414 save_throw_object (tmp, type, op); 380 save_throw_object (tmp, type, op);
381
415 if (was_destroyed (op, op_tag)) 382 if (op->destroyed ())
416 break; 383 break;
417 } 384 }
418 } 385 }
419 386
420 return 0; 387 return 0;
423void 390void
424attack_message (int dam, int type, object *op, object *hitter) 391attack_message (int dam, int type, object *op, object *hitter)
425{ 392{
426 char buf[MAX_BUF], buf1[MAX_BUF], buf2[MAX_BUF]; 393 char buf[MAX_BUF], buf1[MAX_BUF], buf2[MAX_BUF];
427 int i, found = 0; 394 int i, found = 0;
428 mapstruct *map; 395 maptile *map;
429 object *next, *tmp; 396 object *next, *tmp;
430 397
431 /* put in a few special messages for some of the common attacktypes 398 /* put in a few special messages for some of the common attacktypes
432 * a player might have. For example, fire, electric, cold, etc 399 * a player might have. For example, fire, electric, cold, etc
433 * [garbled 20010919] 400 * [garbled 20010919]
450 sprintf (buf1, "missed %s", &op->name); 417 sprintf (buf1, "missed %s", &op->name);
451 sprintf (buf2, " misses"); 418 sprintf (buf2, " misses");
452 found++; 419 found++;
453 } 420 }
454 else if ((hitter->type == DISEASE || hitter->type == SYMPTOM || 421 else if ((hitter->type == DISEASE || hitter->type == SYMPTOM ||
455 hitter->type == POISONING || (type & AT_POISON && IS_LIVE (op))) && !found) 422 hitter->type == POISONING || (type & AT_POISON && op->is_alive ())) && !found)
456 { 423 {
457 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_SUFFER][i].level != -1; i++) 424 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_SUFFER][i].level != -1; i++)
458 if (dam < attack_mess[ATM_SUFFER][i].level || attack_mess[ATM_SUFFER][i + 1].level == -1) 425 if (dam < attack_mess[ATM_SUFFER][i].level || attack_mess[ATM_SUFFER][i + 1].level == -1)
459 { 426 {
460 sprintf (buf1, "%s %s%s", attack_mess[ATM_SUFFER][i].buf1, &op->name, attack_mess[ATM_SUFFER][i].buf2); 427 sprintf (buf1, "%s %s%s", attack_mess[ATM_SUFFER][i].buf1, &op->name, attack_mess[ATM_SUFFER][i].buf2);
472 strcpy (buf2, attack_mess[ATM_DOOR][i].buf3); 439 strcpy (buf2, attack_mess[ATM_DOOR][i].buf3);
473 found++; 440 found++;
474 break; 441 break;
475 } 442 }
476 } 443 }
477 else if (hitter->type == PLAYER && IS_LIVE (op)) 444 else if (hitter->type == PLAYER && op->is_alive ())
478 { 445 {
479 if (USING_SKILL (hitter, SK_KARATE)) 446 if (USING_SKILL (hitter, SK_KARATE))
480 { 447 {
481 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_KARATE][i].level != -1; i++) 448 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_KARATE][i].level != -1; i++)
482 if (dam < attack_mess[ATM_KARATE][i].level || attack_mess[ATM_KARATE][i + 1].level == -1) 449 if (dam < attack_mess[ATM_KARATE][i].level || attack_mess[ATM_KARATE][i + 1].level == -1)
508 found++; 475 found++;
509 break; 476 break;
510 } 477 }
511 } 478 }
512 } 479 }
480
513 if (found) 481 if (found)
514 { 482 {
515 /* done */ 483 /* done */
516 } 484 }
517 else if (IS_ARROW (hitter) && (type == AT_PHYSICAL || type == AT_MAGIC)) 485 else if (hitter->is_arrow () && (type == AT_PHYSICAL || type == AT_MAGIC))
518 { 486 {
519 sprintf (buf1, "hit"); /* just in case */ 487 sprintf (buf1, "hit"); /* just in case */
520 for (i = 0; i < MAXATTACKMESS; i++) 488 for (i = 0; i < MAXATTACKMESS; i++)
521 if (dam < attack_mess[ATM_ARROW][i].level || attack_mess[ATM_ARROW][i + 1].level == -1) 489 if (dam < attack_mess[ATM_ARROW][i].level || attack_mess[ATM_ARROW][i + 1].level == -1)
522 { 490 {
523 strcpy (buf2, attack_mess[ATM_ARROW][i].buf3); 491 strcpy (buf2, attack_mess[ATM_ARROW][i].buf3);
524 found++; 492 found++;
525 break; 493 break;
526 } 494 }
527 } 495 }
528 else if (type & AT_DRAIN && IS_LIVE (op)) 496 else if (type & AT_DRAIN && op->is_alive ())
529 { 497 {
530 /* drain is first, because some items have multiple attypes */ 498 /* drain is first, because some items have multiple attypes */
531 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_DRAIN][i].level != -1; i++) 499 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_DRAIN][i].level != -1; i++)
532 if (dam < attack_mess[ATM_DRAIN][i].level || attack_mess[ATM_DRAIN][i + 1].level == -1) 500 if (dam < attack_mess[ATM_DRAIN][i].level || attack_mess[ATM_DRAIN][i + 1].level == -1)
533 { 501 {
535 strcpy (buf2, attack_mess[ATM_DRAIN][i].buf3); 503 strcpy (buf2, attack_mess[ATM_DRAIN][i].buf3);
536 found++; 504 found++;
537 break; 505 break;
538 } 506 }
539 } 507 }
540 else if (type & AT_ELECTRICITY && IS_LIVE (op)) 508 else if (type & AT_ELECTRICITY && op->is_alive ())
541 { 509 {
542 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_ELEC][i].level != -1; i++) 510 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_ELEC][i].level != -1; i++)
543 if (dam < attack_mess[ATM_ELEC][i].level || attack_mess[ATM_ELEC][i + 1].level == -1) 511 if (dam < attack_mess[ATM_ELEC][i].level || attack_mess[ATM_ELEC][i + 1].level == -1)
544 { 512 {
545 sprintf (buf1, "%s %s%s", attack_mess[ATM_ELEC][i].buf1, &op->name, attack_mess[ATM_ELEC][i].buf2); 513 sprintf (buf1, "%s %s%s", attack_mess[ATM_ELEC][i].buf1, &op->name, attack_mess[ATM_ELEC][i].buf2);
546 strcpy (buf2, attack_mess[ATM_ELEC][i].buf3); 514 strcpy (buf2, attack_mess[ATM_ELEC][i].buf3);
547 found++; 515 found++;
548 break; 516 break;
549 } 517 }
550 } 518 }
551 else if (type & AT_COLD && IS_LIVE (op)) 519 else if (type & AT_COLD && op->is_alive ())
552 { 520 {
553 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_COLD][i].level != -1; i++) 521 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_COLD][i].level != -1; i++)
554 if (dam < attack_mess[ATM_COLD][i].level || attack_mess[ATM_COLD][i + 1].level == -1) 522 if (dam < attack_mess[ATM_COLD][i].level || attack_mess[ATM_COLD][i + 1].level == -1)
555 { 523 {
556 sprintf (buf1, "%s %s%s", attack_mess[ATM_COLD][i].buf1, &op->name, attack_mess[ATM_COLD][i].buf2); 524 sprintf (buf1, "%s %s%s", attack_mess[ATM_COLD][i].buf1, &op->name, attack_mess[ATM_COLD][i].buf2);
633 strcpy (buf1, "hit"); 601 strcpy (buf1, "hit");
634 strcpy (buf2, " hits"); 602 strcpy (buf2, " hits");
635 } 603 }
636 604
637 /* bail out if a monster is casting spells */ 605 /* bail out if a monster is casting spells */
638 if (!(hitter->type == PLAYER || (get_owner (hitter) != NULL && hitter->owner->type == PLAYER))) 606 if (!(hitter->type == PLAYER || (hitter->owner != NULL && hitter->owner->type == PLAYER)))
639 return; 607 return;
640 608
641 /* scale down magic considerably. */ 609 /* scale down magic considerably. */
642 if (type & AT_MAGIC && rndm (0, 5)) 610 if (type & AT_MAGIC && rndm (0, 5))
643 return; 611 return;
644 612
645 /* Did a player hurt another player? Inform both! */ 613 /* Did a player hurt another player? Inform both! */
646 if (op->type == PLAYER && (get_owner (hitter) == NULL ? hitter->type : hitter->owner->type) == PLAYER) 614 if (op->type == PLAYER && (hitter->owner == NULL ? hitter->type : hitter->owner->type) == PLAYER)
647 { 615 {
648 if (get_owner (hitter) != NULL) 616 if (hitter->owner != NULL)
649 sprintf (buf, "%s's %s%s you.", &hitter->owner->name, &hitter->name, buf2); 617 sprintf (buf, "%s's %s%s you.", &hitter->owner->name, &hitter->name, buf2);
650 else 618 else
651 { 619 {
652 sprintf (buf, "%s%s you.", &hitter->name, buf2); 620 sprintf (buf, "%s%s you.", &hitter->name, buf2);
653 if (dam != 0) 621 if (dam != 0)
675 else 643 else
676 play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS3, 0, 0); 644 play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS3, 0, 0);
677 } 645 }
678 new_draw_info (NDI_BLACK, 0, hitter, buf); 646 new_draw_info (NDI_BLACK, 0, hitter, buf);
679 } 647 }
680 else if (get_owner (hitter) != NULL && hitter->owner->type == PLAYER) 648 else if (hitter->owner != NULL && hitter->owner->type == PLAYER)
681 { 649 {
682 /* look for stacked spells and start reducing the message chances */ 650 /* look for stacked spells and start reducing the message chances */
683 if (hitter->type == SPELL_EFFECT && (hitter->subtype == SP_EXPLOSION || hitter->subtype == SP_BULLET || hitter->subtype == SP_CONE)) 651 if (hitter->type == SPELL_EFFECT && (hitter->subtype == SP_EXPLOSION || hitter->subtype == SP_BULLET || hitter->subtype == SP_CONE))
684 { 652 {
685 i = 4; 653 i = 4;
686 map = hitter->map; 654 map = hitter->map;
687 if (out_of_map (map, hitter->x, hitter->y)) 655 if (out_of_map (map, hitter->x, hitter->y))
688 return; 656 return;
689 next = get_map_ob (map, hitter->x, hitter->y); 657 next = GET_MAP_OB (map, hitter->x, hitter->y);
690 if (next) 658 if (next)
691 while (next) 659 while (next)
692 { 660 {
693 if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) 661 if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE))
694 i *= 3; 662 i *= 3;
760attack_ob_simple (object *op, object *hitter, int base_dam, int base_wc) 728attack_ob_simple (object *op, object *hitter, int base_dam, int base_wc)
761{ 729{
762 int simple_attack, roll, dam = 0; 730 int simple_attack, roll, dam = 0;
763 uint32 type; 731 uint32 type;
764 shstr op_name; 732 shstr op_name;
765 tag_t op_tag, hitter_tag;
766 733
767 if (get_attack_mode (&op, &hitter, &simple_attack)) 734 if (get_attack_mode (&op, &hitter, &simple_attack))
768 goto error; 735 goto error;
769 736
770 if (hitter->current_weapon) 737 if (hitter->current_weapon)
771 if (INVOKE_OBJECT (WEAPON_ATTACK, hitter->current_weapon, ARG_OBJECT (hitter), ARG_OBJECT (op))) 738 if (INVOKE_OBJECT (WEAPON_ATTACK, hitter->current_weapon, ARG_OBJECT (hitter), ARG_OBJECT (op)))
772 return RESULT_INT (0); 739 return RESULT_INT (0);
773 740
774 if (INVOKE_OBJECT (ATTACK, op, ARG_OBJECT (hitter))) 741 if (INVOKE_OBJECT (ATTACK, op, ARG_OBJECT (hitter)))
775 return RESULT_INT (0); 742 return RESULT_INT (0);
776
777 op_tag = op->count;
778 hitter_tag = hitter->count;
779 743
780 /* 744 /*
781 * A little check to make it more difficult to dance forward and back 745 * A little check to make it more difficult to dance forward and back
782 * to avoid ever being hit by monsters. 746 * to avoid ever being hit by monsters.
783 */ 747 */
788 * which then gets here again. By decreasing the speed before 752 * which then gets here again. By decreasing the speed before
789 * we call process_object, the 'if' statement above will fail. 753 * we call process_object, the 'if' statement above will fail.
790 */ 754 */
791 op->speed_left--; 755 op->speed_left--;
792 process_object (op); 756 process_object (op);
757
793 if (was_destroyed (op, op_tag) || was_destroyed (hitter, hitter_tag) || abort_attack (op, hitter, simple_attack)) 758 if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack))
794 goto error; 759 goto error;
795 } 760 }
796 761
797 op_name = op->name; 762 op_name = op->name;
798 763
810 if (settings.casting_time == TRUE) 775 if (settings.casting_time == TRUE)
811 { 776 {
812 if ((hitter->type == PLAYER) && (hitter->casting_time > -1)) 777 if ((hitter->type == PLAYER) && (hitter->casting_time > -1))
813 { 778 {
814 hitter->casting_time = -1; 779 hitter->casting_time = -1;
815 new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost " "your spell!"); 780 new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost your spell!");
816 } 781 }
817 if ((op->casting_time > -1) && (hitdam > 0)) 782 if ((op->casting_time > -1) && (hitdam > 0))
818 { 783 {
819 op->casting_time = -1; 784 op->casting_time = -1;
820 if (op->type == PLAYER) 785 if (op->type == PLAYER)
821 { 786 {
822 new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost " "your spell!"); 787 new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost your spell!");
823 new_draw_info_format (NDI_ALL | NDI_UNIQUE, 5, NULL, "%s was hit by %s and lost a spell.", &op_name, &hitter->name); 788 new_draw_info_format (NDI_ALL | NDI_UNIQUE, 5, NULL, "%s was hit by %s and lost a spell.", &op_name, &hitter->name);
824 } 789 }
825 } 790 }
826 } 791 }
827 if (!simple_attack) 792 if (!simple_attack)
832 if (QUERY_FLAG (op, FLAG_SLEEP)) 797 if (QUERY_FLAG (op, FLAG_SLEEP))
833 CLEAR_FLAG (op, FLAG_SLEEP); 798 CLEAR_FLAG (op, FLAG_SLEEP);
834 799
835 /* If the victim can't see the attacker, it may alert others 800 /* If the victim can't see the attacker, it may alert others
836 * for help. */ 801 * for help. */
837 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !get_owner (op) && rndm (0, op->stats.Int)) 802 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int))
838 npc_call_help (op); 803 npc_call_help (op);
839 804
840 /* if you were hidden and hit by a creature, you are discovered */ 805 /* if you were hidden and hit by a creature, you are discovered */
841 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) 806 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE))
842 { 807 {
849 * when they hit the victim. For things like thrown daggers, 814 * when they hit the victim. For things like thrown daggers,
850 * this sets 'hitter' to the actual dagger, and not the 815 * this sets 'hitter' to the actual dagger, and not the
851 * wrapper object. 816 * wrapper object.
852 */ 817 */
853 thrown_item_effect (hitter, op); 818 thrown_item_effect (hitter, op);
819
854 if (was_destroyed (hitter, hitter_tag) || was_destroyed (op, op_tag) || abort_attack (op, hitter, simple_attack)) 820 if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack))
855 goto leave; 821 goto leave;
856 } 822 }
857 823
858 /* Need to do at least 1 damage, otherwise there is no point 824 /* Need to do at least 1 damage, otherwise there is no point
859 * to go further and it will cause FPE's below. 825 * to go further and it will cause FPE's below.
860 */ 826 */
861 if (hitdam <= 0) 827 if (hitdam <= 0)
862 hitdam = 1; 828 hitdam = 1;
863 829
864 type = hitter->attacktype; 830 type = hitter->attacktype;
831
865 if (!type) 832 if (!type)
866 type = AT_PHYSICAL; 833 type = AT_PHYSICAL;
834
867 /* Handle monsters that hit back */ 835 /* Handle monsters that hit back */
868 if (!simple_attack && QUERY_FLAG (op, FLAG_HITBACK) && QUERY_FLAG (hitter, FLAG_ALIVE)) 836 if (!simple_attack && QUERY_FLAG (op, FLAG_HITBACK) && QUERY_FLAG (hitter, FLAG_ALIVE))
869 { 837 {
870 if (op->attacktype & AT_ACID && hitter->type == PLAYER) 838 if (op->attacktype & AT_ACID && hitter->type == PLAYER)
871 new_draw_info (NDI_UNIQUE, 0, hitter, "You are splashed by acid!\n"); 839 new_draw_info (NDI_UNIQUE, 0, hitter, "You are splashed by acid!\n");
840
872 hit_player (hitter, random_roll (0, (op->stats.dam), hitter, PREFER_LOW), op, op->attacktype, 1); 841 hit_player (hitter, random_roll (0, (op->stats.dam), hitter, PREFER_LOW), op, op->attacktype, 1);
842
873 if (was_destroyed (op, op_tag) || was_destroyed (hitter, hitter_tag) || abort_attack (op, hitter, simple_attack)) 843 if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack))
874 goto leave; 844 goto leave;
875 } 845 }
876 846
877 /* In the new attack code, it should handle multiple attack 847 /* In the new attack code, it should handle multiple attack
878 * types in its area, so remove it from here. 848 * types in its area, so remove it from here.
879 */ 849 */
880 dam = hit_player (op, random_roll (1, hitdam, hitter, PREFER_HIGH), hitter, type, 1); 850 dam = hit_player (op, random_roll (1, hitdam, hitter, PREFER_HIGH), hitter, type, 1);
851
881 if (was_destroyed (op, op_tag) || was_destroyed (hitter, hitter_tag) || abort_attack (op, hitter, simple_attack)) 852 if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack))
882 goto leave; 853 goto leave;
883 } /* end of if hitter hit op */ 854 } /* end of if hitter hit op */
884 /* if we missed, dam=0 */ 855 /* if we missed, dam=0 */
885 856
886 /*attack_message(dam, type, op, hitter); */ 857 /*attack_message(dam, type, op, hitter); */
920 if (op->weight <= 5000 && tmp->stats.hp >= 0) 891 if (op->weight <= 5000 && tmp->stats.hp >= 0)
921 { 892 {
922 if (tmp->head != NULL) 893 if (tmp->head != NULL)
923 tmp = tmp->head; 894 tmp = tmp->head;
924 895
925 remove_ob (op); 896 op->remove ();
926 op = insert_ob_in_ob (op, tmp); 897 op = insert_ob_in_ob (op, tmp);
927 898
928 if (tmp->type == PLAYER) 899 if (tmp->type == PLAYER)
929 esrv_send_item (tmp, op); 900 esrv_send_item (tmp, op);
930 901
943object * 914object *
944hit_with_arrow (object *op, object *victim) 915hit_with_arrow (object *op, object *victim)
945{ 916{
946 object *container, *hitter; 917 object *container, *hitter;
947 int hit_something = 0; 918 int hit_something = 0;
948 tag_t victim_tag, hitter_tag;
949 sint16 victim_x, victim_y;
950 919
951 /* Disassemble missile */ 920 /* Disassemble missile */
952 if (op->inv) 921 if (op->inv)
953 { 922 {
954 container = op; 923 container = op;
955 hitter = op->inv; 924 hitter = op->inv;
956 remove_ob (hitter); 925 hitter->remove ();
957 insert_ob_in_map (hitter, container->map, hitter, INS_NO_MERGE | INS_NO_WALK_ON); 926 insert_ob_in_map (hitter, container->map, hitter, INS_NO_MERGE | INS_NO_WALK_ON);
958 /* Note that we now have an empty THROWN_OBJ on the map. Code that 927 /* Note that we now have an empty THROWN_OBJ on the map. Code that
959 * might be called until this THROWN_OBJ is either reassembled or 928 * might be called until this THROWN_OBJ is either reassembled or
960 * removed at the end of this function must be able to deal with empty 929 * removed at the end of this function must be able to deal with empty
961 * THROWN_OBJs. */ 930 * THROWN_OBJs. */
962 } 931 }
963 else 932 else
964 { 933 {
965 container = NULL; 934 container = 0;
966 hitter = op; 935 hitter = op;
967 } 936 }
968 937
969 /* Try to hit victim */ 938 /* Try to hit victim */
970 victim_x = victim->x;
971 victim_y = victim->y;
972 victim_tag = victim->count;
973 hitter_tag = hitter->count;
974
975 hit_something = attack_ob_simple (victim, hitter, op->stats.dam, op->stats.wc); 939 hit_something = attack_ob_simple (victim, hitter, op->stats.dam, op->stats.wc);
976 940
977 /* Arrow attacks door, rune of summoning is triggered, demon is put on 941 /* Arrow attacks door, rune of summoning is triggered, demon is put on
978 * arrow, move_apply() calls this function, arrow sticks in demon, 942 * arrow, move_apply() calls this function, arrow sticks in demon,
979 * attack_ob_simple() returns, and we've got an arrow that still exists 943 * attack_ob_simple() returns, and we've got an arrow that still exists
980 * but is no longer on the map. Ugh. (Beware: Such things can happen at 944 * but is no longer on the map. Ugh. (Beware: Such things can happen at
981 * other places as well!) 945 * other places as well!)
982 */ 946 */
983 if (was_destroyed (hitter, hitter_tag) || hitter->env != NULL) 947 if (hitter->destroyed () || hitter->env != NULL)
984 { 948 {
985 if (container) 949 if (container)
986 { 950 {
987 remove_ob (container); 951 container->remove ();
988 free_object (container); 952 container->destroy ();
989 } 953 }
954
990 return NULL; 955 return 0;
991 } 956 }
992 957
993 /* Missile hit victim */ 958 /* Missile hit victim */
994 /* if the speed is > 10, then this is a fast moving arrow, we go straight 959 /* if the speed is > 10, then this is a fast moving arrow, we go straight
995 * through the target 960 * through the target
996 */ 961 */
997 if (hit_something && op->speed <= 10.0) 962 if (hit_something && op->speed <= 10.0)
998 { 963 {
999 /* Stop arrow */ 964 /* Stop arrow */
1000 if (container == NULL) 965 if (!container)
1001 { 966 {
1002 hitter = fix_stopped_arrow (hitter); 967 hitter = fix_stopped_arrow (hitter);
1003 if (hitter == NULL) 968 if (!hitter)
1004 return NULL; 969 return 0;
1005 } 970 }
1006 else 971 else
1007 { 972 container->destroy ();
1008 remove_ob (container);
1009 free_object (container);
1010 }
1011 973
1012 /* Try to stick arrow into victim */ 974 /* Try to stick arrow into victim */
1013 if (!was_destroyed (victim, victim_tag) && stick_arrow (hitter, victim)) 975 if (!victim->destroyed () && stick_arrow (hitter, victim))
1014 return NULL; 976 return 0;
1015 977
1016 /* Else try to put arrow on victim's map square 978 /* Else try to put arrow on victim's map square
1017 * remove check for P_WALL here. If the arrow got to this 979 * remove check for P_WALL here. If the arrow got to this
1018 * space, that is good enough - with the new movement code, 980 * space, that is good enough - with the new movement code,
1019 * there is now the potential for lots of spaces where something 981 * there is now the potential for lots of spaces where something
1020 * can fly over but not otherwise move over. What is the correct 982 * can fly over but not otherwise move over. What is the correct
1021 * way to handle those otherwise? 983 * way to handle those otherwise?
1022 */ 984 */
1023 if (victim_x != hitter->x || victim_y != hitter->y) 985 if (victim->x != hitter->x || victim->y != hitter->y)
1024 { 986 {
1025 remove_ob (hitter); 987 hitter->remove ();
1026 hitter->x = victim_x; 988 hitter->x = victim->x;
1027 hitter->y = victim_y; 989 hitter->y = victim->y;
1028 insert_ob_in_map (hitter, victim->map, hitter, 0); 990 insert_ob_in_map (hitter, victim->map, hitter, 0);
1029 } 991 }
1030 else 992 else
1031 {
1032 /* Else leave arrow where it is */ 993 /* Else leave arrow where it is */
1033 merge_ob (hitter, NULL); 994 merge_ob (hitter, NULL);
1034 } 995
1035 return NULL; 996 return 0;
1036 } 997 }
1037 998
1038 if (hit_something && op->speed >= 10.0) 999 if (hit_something && op->speed >= 10.0)
1039 op->speed -= 1.0; 1000 op->speed -= 1.0;
1040 1001
1041 /* Missile missed victim - reassemble missile */ 1002 /* Missile missed victim - reassemble missile */
1042 if (container) 1003 if (container)
1043 { 1004 {
1044 remove_ob (hitter); 1005 hitter->remove ();
1045 insert_ob_in_ob (hitter, container); 1006 insert_ob_in_ob (hitter, container);
1046 } 1007 }
1008
1047 return op; 1009 return op;
1048} 1010}
1049 1011
1050 1012
1051void 1013void
1060 } 1022 }
1061 else if (!GET_ANIM_ID (op)) 1023 else if (!GET_ANIM_ID (op))
1062 { 1024 {
1063 /* Object has been called - no animations, so remove it */ 1025 /* Object has been called - no animations, so remove it */
1064 if (op->stats.hp < 0) 1026 if (op->stats.hp < 0)
1027 op->destroy ();
1065 { 1028
1066 remove_ob (op); /* Should update LOS */
1067 free_object (op);
1068 /* Don't know why this is here - remove_ob should do it for us */
1069 /*update_position(m, x, y); */
1070 }
1071 return; /* no animations, so nothing more to do */ 1029 return; /* no animations, so nothing more to do */
1072 } 1030 }
1031
1073 perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; 1032 perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp;
1033
1074 if (perc >= (int) NUM_ANIMATIONS (op)) 1034 if (perc >= (int) NUM_ANIMATIONS (op))
1075 perc = NUM_ANIMATIONS (op) - 1; 1035 perc = NUM_ANIMATIONS (op) - 1;
1076 else if (perc < 1) 1036 else if (perc < 1)
1077 perc = 1; 1037 perc = 1;
1038
1078 SET_ANIMATION (op, perc); 1039 SET_ANIMATION (op, perc);
1079 update_object (op, UP_OBJ_FACE); 1040 update_object (op, UP_OBJ_FACE);
1041
1080 if (perc == NUM_ANIMATIONS (op) - 1) 1042 if (perc == NUM_ANIMATIONS (op) - 1)
1081 { /* Reached the last animation */ 1043 { /* Reached the last animation */
1082 if (op->face == blank_face) 1044 if (op->face == blank_face)
1083 {
1084 /* If the last face is blank, remove the ob */ 1045 /* If the last face is blank, remove the ob */
1085 remove_ob (op); /* Should update LOS */ 1046 op->destroy ();
1086 free_object (op);
1087
1088 /* remove_ob should call update_position for us */
1089 /*update_position(m, x, y); */
1090
1091 }
1092 else 1047 else
1093 { /* The last face was not blank, leave an image */ 1048 { /* The last face was not blank, leave an image */
1094 CLEAR_FLAG (op, FLAG_BLOCKSVIEW); 1049 CLEAR_FLAG (op, FLAG_BLOCKSVIEW);
1095 update_all_los (op->map, op->x, op->y); 1050 update_all_los (op->map, op->x, op->y);
1096 op->move_block = 0; 1051 op->move_block = 0;
1100} 1055}
1101 1056
1102void 1057void
1103scare_creature (object *target, object *hitter) 1058scare_creature (object *target, object *hitter)
1104{ 1059{
1105 object *owner = get_owner (hitter); 1060 object *owner = hitter->owner;
1106 1061
1107 if (!owner) 1062 if (!owner)
1108 owner = hitter; 1063 owner = hitter;
1109 1064
1110 SET_FLAG (target, FLAG_SCARED); 1065 SET_FLAG (target, FLAG_SCARED);
1117 * appropriate attacktype. Only 1 attacktype should be set at a time. 1072 * appropriate attacktype. Only 1 attacktype should be set at a time.
1118 * This doesn't damage the player, but returns how much it should 1073 * This doesn't damage the player, but returns how much it should
1119 * take. However, it will do other effects (paralyzation, slow, etc.) 1074 * take. However, it will do other effects (paralyzation, slow, etc.)
1120 * Note - changed for PR code - we now pass the attack number and not 1075 * Note - changed for PR code - we now pass the attack number and not
1121 * the attacktype. Makes it easier for the PR code. */ 1076 * the attacktype. Makes it easier for the PR code. */
1122
1123int 1077int
1124hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic) 1078hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic)
1125{ 1079{
1126
1127 int doesnt_slay = 1; 1080 int doesnt_slay = 1;
1128 1081
1129 /* Catch anyone that may be trying to send us a bitmask instead of the number */ 1082 /* Catch anyone that may be trying to send us a bitmask instead of the number */
1130 if (attacknum >= NROFATTACKS) 1083 if (attacknum >= NROFATTACKS)
1131 { 1084 {
1176 1129
1177 /* Keep this in order - makes things easier to find */ 1130 /* Keep this in order - makes things easier to find */
1178 1131
1179 switch (attacknum) 1132 switch (attacknum)
1180 { 1133 {
1181 case ATNR_PHYSICAL: 1134 case ATNR_PHYSICAL:
1182 /* here also check for diseases */ 1135 /* here also check for diseases */
1183 check_physically_infect (op, hitter); 1136 check_physically_infect (op, hitter);
1184 break; 1137 break;
1185 1138
1186 /* Don't need to do anything for: 1139 /* Don't need to do anything for:
1187 magic, 1140 magic,
1188 fire, 1141 fire,
1189 electricity, 1142 electricity,
1190 cold */ 1143 cold */
1191 1144
1192 case ATNR_CONFUSION: 1145 case ATNR_CONFUSION:
1193 case ATNR_POISON: 1146 case ATNR_POISON:
1194 case ATNR_SLOW: 1147 case ATNR_SLOW:
1195 case ATNR_PARALYZE: 1148 case ATNR_PARALYZE:
1196 case ATNR_FEAR: 1149 case ATNR_FEAR:
1197 case ATNR_CANCELLATION: 1150 case ATNR_CANCELLATION:
1198 case ATNR_DEPLETE: 1151 case ATNR_DEPLETE:
1199 case ATNR_BLIND: 1152 case ATNR_BLIND:
1200 { 1153 {
1201 /* chance for inflicting a special attack depends on the 1154 /* chance for inflicting a special attack depends on the
1202 * difference between attacker's and defender's level 1155 * difference between attacker's and defender's level
1203 */ 1156 */
1204 int level_diff = MIN (110, MAX (0, op->level - hitter->level)); 1157 int level_diff = MIN (110, MAX (0, op->level - hitter->level));
1205 1158
1206 /* First, only creatures/players with speed can be affected. 1159 /* First, only creatures/players with speed can be affected.
1207 * Second, just getting hit doesn't mean it always affects 1160 * Second, just getting hit doesn't mean it always affects
1208 * you. Third, you still get a saving through against the 1161 * you. Third, you still get a saving through against the
1209 * effect. 1162 * effect.
1210 */ 1163 */
1211 if (op->speed && 1164 if (op->speed &&
1212 (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) && 1165 (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) &&
1213 !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) && !did_make_save (op, level_diff, op->resist[attacknum] / 10)) 1166 !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) && !did_make_save (op, level_diff, op->resist[attacknum] / 10))
1214 { 1167 {
1215 1168
1216 /* Player has been hit by something */ 1169 /* Player has been hit by something */
1217 if (attacknum == ATNR_CONFUSION) 1170 if (attacknum == ATNR_CONFUSION)
1218 confuse_player (op, hitter, dam); 1171 confuse_player (op, hitter, dam);
1219 else if (attacknum == ATNR_POISON) 1172 else if (attacknum == ATNR_POISON)
1220 poison_player (op, hitter, dam); 1173 poison_player (op, hitter, dam);
1221 else if (attacknum == ATNR_SLOW) 1174 else if (attacknum == ATNR_SLOW)
1222 slow_player (op, hitter, dam); 1175 slow_player (op, hitter, dam);
1223 else if (attacknum == ATNR_PARALYZE) 1176 else if (attacknum == ATNR_PARALYZE)
1224 paralyze_player (op, hitter, dam); 1177 paralyze_player (op, hitter, dam);
1225 else if (attacknum == ATNR_FEAR) 1178 else if (attacknum == ATNR_FEAR)
1226 scare_creature (op, hitter); 1179 scare_creature (op, hitter);
1227 else if (attacknum == ATNR_CANCELLATION) 1180 else if (attacknum == ATNR_CANCELLATION)
1228 cancellation (op); 1181 cancellation (op);
1229 else if (attacknum == ATNR_DEPLETE) 1182 else if (attacknum == ATNR_DEPLETE)
1230 drain_stat (op); 1183 op->drain_stat ();
1231 else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR)) 1184 else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR))
1232 blind_player (op, hitter, dam); 1185 blind_player (op, hitter, dam);
1233 } 1186 }
1234 dam = 0; /* These are all effects and don't do real damage */ 1187 dam = 0; /* These are all effects and don't do real damage */
1235 } 1188 }
1236 break; 1189 break;
1190
1237 case ATNR_ACID: 1191 case ATNR_ACID:
1238 { 1192 {
1239 int flag = 0; 1193 int flag = 0;
1240 1194
1241 /* Items only get corroded if you're not on a battleground and 1195 /* Items only get corroded if you're not on a battleground and
1242 * if your acid resistance is below 50%. */ 1196 * if your acid resistance is below 50%. */
1243 if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50)) 1197 if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50))
1244 { 1198 {
1245 object *tmp;
1246
1247 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1199 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1248 { 1200 {
1249 if (tmp->invisible) 1201 if (tmp->invisible)
1250 continue; 1202 continue;
1251 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) 1203 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10))
1252 /* >= 10% acid res. on itmes will protect these */ 1204 /* >= 10% acid res. on items will protect these */
1253 continue; 1205 continue;
1254 if (!(tmp->material & M_IRON)) 1206 if (!(tmp->material & M_IRON))
1255 continue; 1207 continue;
1256 if (tmp->magic < -4) /* Let's stop at -5 */ 1208 if (tmp->magic < -4) /* Let's stop at -5 */
1257 continue; 1209 continue;
1258 if (tmp->type == RING || 1210 if (tmp->type == RING
1259 /* removed boots and gloves from exclusion list in 1211 /* removed boots and gloves from exclusion list in PR */
1260 PR */ 1212 || tmp->type == GIRDLE
1261 tmp->type == GIRDLE || tmp->type == AMULET || tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1213 || tmp->type == AMULET
1214 || tmp->type == WAND
1215 || tmp->type == ROD
1216 || tmp->type == HORN)
1262 continue; /* To avoid some strange effects */ 1217 continue; /* To avoid some strange effects */
1263 1218
1264 /* High damage acid has better chance of corroding 1219 /* High damage acid has better chance of corroding
1265 objects */ 1220 objects */
1266 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) 1221 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic)
1267 { 1222 {
1268 if (op->type == PLAYER) 1223 if (op->type == PLAYER)
1269 /* Make this more visible */ 1224 /* Make this more visible */
1270 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, 1225 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op,
1271 "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp)); 1226 "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp));
1272 flag = 1; 1227 flag = 1;
1273 tmp->magic--; 1228 tmp->magic--;
1274 if (op->type == PLAYER) 1229 if (op->type == PLAYER)
1275 esrv_send_item (op, tmp); 1230 esrv_send_item (op, tmp);
1276 } 1231 }
1277 } 1232 }
1278 if (flag)
1279 fix_player (op); /* Something was corroded */
1280 } 1233
1234 if (flag)
1235 op->update_stats (); /* Something was corroded */
1281 } 1236 }
1237 }
1282 break; 1238 break;
1239
1283 case ATNR_DRAIN: 1240 case ATNR_DRAIN:
1284 { 1241 {
1285 /* rate is the proportion of exp drained. High rate means 1242 /* rate is the proportion of exp drained. High rate means
1286 * not much is drained, low rate means a lot is drained. 1243 * not much is drained, low rate means a lot is drained.
1287 */ 1244 */
1288 int rate; 1245 int rate;
1289 1246
1290 if (op->resist[ATNR_DRAIN] >= 0) 1247 if (op->resist[ATNR_DRAIN] >= 0)
1291 rate = 400 + op->resist[ATNR_DRAIN] * 3; 1248 rate = 400 + op->resist[ATNR_DRAIN] * 3;
1292 else 1249 else
1293 rate = 400 * 100 / (100 - op->resist[ATNR_DRAIN]); 1250 rate = 400 * 100 / (100 - op->resist[ATNR_DRAIN]);
1294 1251
1295 if (op->stats.exp <= rate) 1252 if (op->stats.exp <= rate)
1296 { 1253 {
1297 if (op->type == GOLEM) 1254 if (op->type == GOLEM)
1298 dam = 999; /* Its force is "sucked" away. 8) */ 1255 dam = 999; /* Its force is "sucked" away. 8) */
1299 else 1256 else
1300 /* If we can't drain, lets try to do physical damage */ 1257 /* If we can't drain, lets try to do physical damage */
1301 dam = hit_player_attacktype (op, hitter, dam, ATNR_PHYSICAL, magic); 1258 dam = hit_player_attacktype (op, hitter, dam, ATNR_PHYSICAL, magic);
1302 } 1259 }
1303 else 1260 else
1304 { 1261 {
1305 /* Randomly give the hitter some hp */ 1262 /* Randomly give the hitter some hp */
1306 if (hitter->stats.hp < hitter->stats.maxhp && 1263 if (hitter->stats.hp < hitter->stats.maxhp &&
1307 (op->level > hitter->level) && random_roll (0, (op->level - hitter->level + 2), hitter, PREFER_HIGH) > 3) 1264 (op->level > hitter->level) && random_roll (0, (op->level - hitter->level + 2), hitter, PREFER_HIGH) > 3)
1308 hitter->stats.hp++; 1265 hitter->stats.hp++;
1309 1266
1310 /* Can't do drains on battleground spaces. 1267 /* Can't do drains on battleground spaces.
1311 * Move the wiz check up here - before, the hitter wouldn't gain exp 1268 * Move the wiz check up here - before, the hitter wouldn't gain exp
1312 * exp, but the wiz would still lose exp! If drainee is a wiz, 1269 * exp, but the wiz would still lose exp! If drainee is a wiz,
1313 * nothing happens. 1270 * nothing happens.
1314 * Try to credit the owner. We try to display player -> player drain 1271 * Try to credit the owner. We try to display player -> player drain
1315 * attacks, hence all the != PLAYER checks. 1272 * attacks, hence all the != PLAYER checks.
1316 */ 1273 */
1317 if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) 1274 if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ))
1318 { 1275 {
1319 object *owner = get_owner (hitter); 1276 object *owner = hitter->owner;
1320 1277
1321 if (owner && owner != hitter) 1278 if (owner && owner != hitter)
1322 { 1279 {
1323 if (op->type != PLAYER || owner->type != PLAYER) 1280 if (op->type != PLAYER || owner->type != PLAYER)
1324 change_exp (owner, op->stats.exp / (rate * 2), 1281 change_exp (owner, op->stats.exp / (rate * 2),
1325 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL); 1282 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL);
1326 } 1283 }
1327 else if (op->type != PLAYER || hitter->type != PLAYER) 1284 else if (op->type != PLAYER || hitter->type != PLAYER)
1328 { 1285 {
1329 change_exp (hitter, op->stats.exp / (rate * 2), 1286 change_exp (hitter, op->stats.exp / (rate * 2),
1330 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); 1287 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0);
1331 } 1288 }
1332 change_exp (op, -op->stats.exp / rate, NULL, 0); 1289 change_exp (op, -op->stats.exp / rate, NULL, 0);
1333 } 1290 }
1291
1334 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure 1292 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure
1335 * drain attack, you won't know that you are actually sucking out EXP, 1293 * drain attack, you won't know that you are actually sucking out EXP,
1336 * as the messages will say you missed 1294 * as the messages will say you missed
1337 */ 1295 */
1338 } 1296 }
1339 } 1297 }
1340 break; 1298 break;
1299
1341 case ATNR_TURN_UNDEAD: 1300 case ATNR_TURN_UNDEAD:
1342 { 1301 {
1343 if (QUERY_FLAG (op, FLAG_UNDEAD)) 1302 if (QUERY_FLAG (op, FLAG_UNDEAD))
1344 { 1303 {
1345 object *owner = hitter->owner ? (object *)hitter->owner : hitter; 1304 object *owner = hitter->owner ? (object *)hitter->owner : hitter;
1346 object *god = find_god (determine_god (owner)); 1305 object *god = find_god (determine_god (owner));
1347 int div = 1; 1306 int div = 1;
1348 1307
1349 /* if undead are not an enemy of your god, you turn them 1308 /* if undead are not an enemy of your god, you turn them
1350 * at half strength */ 1309 * at half strength */
1351 if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL) 1310 if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL)
1352 div = 2; 1311 div = 2;
1353 /* Give a bonus if you resist turn undead */ 1312 /* Give a bonus if you resist turn undead */
1354 if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100))) 1313 if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100)))
1355 scare_creature (op, owner); 1314 scare_creature (op, owner);
1356 } 1315 }
1357 else 1316 else
1358 dam = 0; /* don't damage non undead - should we damage 1317 dam = 0; /* don't damage non undead - should we damage
1359 undead? */ 1318 undead? */
1360 } 1319 }
1361 break; 1320 break;
1321
1362 case ATNR_DEATH: 1322 case ATNR_DEATH:
1363 deathstrike_player (op, hitter, &dam); 1323 deathstrike_player (op, hitter, &dam);
1364 break; 1324 break;
1325
1365 case ATNR_CHAOS: 1326 case ATNR_CHAOS:
1366 LOG (llevError, "%s was hit by %s with non-specific chaos.\n", query_name (op), query_name (hitter)); 1327 LOG (llevError, "%s was hit by %s with non-specific chaos.\n", op->debug_desc (), hitter->debug_desc2 ());
1367 dam = 0; 1328 dam = 0;
1368 break; 1329 break;
1330
1369 case ATNR_COUNTERSPELL: 1331 case ATNR_COUNTERSPELL:
1370 LOG (llevError, "%s was hit by %s with counterspell attack.\n", query_name (op), query_name (hitter)); 1332 LOG (llevError, "%s was hit by %s with counterspell attack.\n", op->debug_desc (), hitter->debug_desc2 ());
1371 dam = 0; 1333 dam = 0;
1372 /* This should never happen. Counterspell is handled 1334 /* This should never happen. Counterspell is handled
1373 * seperately and filtered out. If this does happen, 1335 * seperately and filtered out. If this does happen,
1374 * Counterspell has no effect on anything but spells, so it 1336 * Counterspell has no effect on anything but spells, so it
1375 * does no damage. */ 1337 * does no damage. */
1376 break; 1338 break;
1339
1377 case ATNR_HOLYWORD: 1340 case ATNR_HOLYWORD:
1378 { 1341 {
1379 /* This has already been handled by hit_player, 1342 /* This has already been handled by hit_player,
1380 * no need to check twice -- DAMN */ 1343 * no need to check twice -- DAMN */
1381 object *owner = hitter->owner ? (object *)hitter->owner : hitter; 1344 object *owner = hitter->owner ? (object *)hitter->owner : hitter;
1382 1345
1383 /* As with turn undead above, give a bonus on the saving throw */ 1346 /* As with turn undead above, give a bonus on the saving throw */
1384 if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) 1347 if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis])
1385 scare_creature (op, owner); 1348 scare_creature (op, owner);
1386 } 1349 }
1387 break; 1350 break;
1351
1388 case ATNR_LIFE_STEALING: 1352 case ATNR_LIFE_STEALING:
1389 { 1353 {
1390 int new_hp; 1354 int new_hp;
1391 1355
1392 /* this is replacement to drain for players, instead of taking 1356 /* this is replacement to drain for players, instead of taking
1393 * exp it takes hp. It is geared for players, probably not 1357 * exp it takes hp. It is geared for players, probably not
1394 * much use giving it to monsters 1358 * much use giving it to monsters
1395 * 1359 *
1396 * life stealing doesn't do a lot of damage, but it gives the 1360 * life stealing doesn't do a lot of damage, but it gives the
1397 * damage it does do to the player. Given that, 1361 * damage it does do to the player. Given that,
1398 * it only does 1/10'th normal damage (hence the divide by 1362 * it only does 1/10'th normal damage (hence the divide by
1399 * 1000). 1363 * 1000).
1400 */ 1364 */
1401 /* You can't steal life from something undead */ 1365 /* You can't steal life from something undead */
1402 if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD))) 1366 if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD)))
1403 return 0; 1367 return 0;
1368
1404 /* If drain protection is higher than life stealing, use that */ 1369 /* If drain protection is higher than life stealing, use that */
1405 if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) 1370 if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING])
1406 dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; 1371 dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000;
1407 else 1372 else
1408 dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000; 1373 dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000;
1374
1409 /* You die at -1 hp, not zero. */ 1375 /* You die at -1 hp, not zero. */
1410 if (dam > (op->stats.hp + 1)) 1376 if (dam > (op->stats.hp + 1))
1411 dam = op->stats.hp + 1; 1377 dam = op->stats.hp + 1;
1378
1412 new_hp = hitter->stats.hp + dam; 1379 new_hp = hitter->stats.hp + dam;
1413 if (new_hp > hitter->stats.maxhp) 1380 if (new_hp > hitter->stats.maxhp)
1414 new_hp = hitter->stats.maxhp; 1381 new_hp = hitter->stats.maxhp;
1382
1415 if (new_hp > hitter->stats.hp) 1383 if (new_hp > hitter->stats.hp)
1416 hitter->stats.hp = new_hp; 1384 hitter->stats.hp = new_hp;
1417 } 1385 }
1418 } 1386 }
1387
1419 return dam; 1388 return dam;
1420} 1389}
1421
1422 1390
1423/* GROS: This code comes from hit_player. It has been made external to 1391/* GROS: This code comes from hit_player. It has been made external to
1424 * allow script procedures to "kill" objects in a combat-like fashion. 1392 * allow script procedures to "kill" objects in a combat-like fashion.
1425 * It was initially used by (kill-object) developed for the Collector's 1393 * It was initially used by (kill-object) developed for the Collector's
1426 * Sword. Note that nothing has been changed from the original version 1394 * Sword. Note that nothing has been changed from the original version
1461 if (QUERY_FLAG (op, FLAG_BLOCKSVIEW)) 1429 if (QUERY_FLAG (op, FLAG_BLOCKSVIEW))
1462 update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */ 1430 update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */
1463 1431
1464 if (op->type == DOOR) 1432 if (op->type == DOOR)
1465 { 1433 {
1466 op->speed = 0.1; 1434 op->set_speed (0.1);
1467 update_ob_speed (op);
1468 op->speed_left = -0.05; 1435 op->speed_left = -0.05;
1469 return maxdam; 1436 return maxdam;
1470 } 1437 }
1438
1471 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) 1439 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER)
1472 { 1440 {
1473 remove_friendly_object (op); 1441 remove_friendly_object (op);
1442
1474 if (get_owner (op) != NULL && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op) 1443 if (op->owner && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op)
1475 {
1476 op->owner->contr->ranges[range_golem] = NULL; 1444 op->owner->contr->ranges[range_golem] = 0;
1477 op->owner->contr->golem_count = 0;
1478 }
1479 1445
1480 remove_ob (op); 1446 op->destroy ();
1481 free_object (op);
1482 return maxdam; 1447 return maxdam;
1483 } 1448 }
1484 1449
1485 /* Now lets start dealing with experience we get for killing something */ 1450 /* Now lets start dealing with experience we get for killing something */
1486 1451
1487 owner = get_owner (hitter); 1452 owner = hitter->owner;
1488 if (owner == NULL) 1453 if (!owner)
1489 owner = hitter; 1454 owner = hitter;
1490 1455
1491 /* is the victim (op) standing on battleground? */ 1456 /* is the victim (op) standing on battleground? */
1492 if (op_on_battleground (op, NULL, NULL)) 1457 if (op_on_battleground (op, NULL, NULL))
1493 battleg = 1; 1458 battleg = 1;
1513 char buf[256]; 1478 char buf[256];
1514 1479
1515 tmv = localtime (&t); 1480 tmv = localtime (&t);
1516 strftime (buf, 256, "%a %b %d %H:%M:%S %Y", tmv); 1481 strftime (buf, 256, "%a %b %d %H:%M:%S %Y", tmv);
1517 1482
1518 LOG (llevInfo, "%s PLAYER_KILL_PLAYER: %s (%s) killed %s\n", buf, &owner->name, owner->contr->socket.host, query_name (op)); 1483 LOG (llevInfo, "%s PLAYER_KILL_PLAYER: %s (%s) killed %s\n", buf, &owner->name, owner->contr->ns->host, query_name (op));
1519 } 1484 }
1520 1485
1521 /* try to filter some things out - basically, if you are 1486 /* try to filter some things out - basically, if you are
1522 * killing a level 1 creature and your level 20, you 1487 * killing a level 1 creature and your level 20, you
1523 * probably don't want to see that. 1488 * probably don't want to see that.
1524 */ 1489 */
1525 if (owner->level < op->level * 2 || op->stats.exp > 1000) 1490 if (owner->level < op->level * 2 || op->stats.exp > 1000)
1526 { 1491 {
1527 if (owner != hitter) 1492 if (owner != hitter)
1528 {
1529 new_draw_info_format (NDI_BLACK, 0, owner, "You killed %s with %s.", query_name (op), query_name (hitter)); 1493 new_draw_info_format (NDI_BLACK, 0, owner, "You killed %s with %s.", query_name (op), query_name (hitter));
1530 }
1531 else 1494 else
1532 {
1533 new_draw_info_format (NDI_BLACK, 0, owner, "You killed %s.", query_name (op)); 1495 new_draw_info_format (NDI_BLACK, 0, owner, "You killed %s.", query_name (op));
1534 } 1496
1535 /* Only play sounds for melee kills */ 1497 /* Only play sounds for melee kills */
1536 if (hitter->type == PLAYER) 1498 if (hitter->type == PLAYER)
1537 play_sound_map (owner->map, owner->x, owner->y, SOUND_PLAYER_KILLS); 1499 play_sound_map (owner->map, owner->x, owner->y, SOUND_PLAYER_KILLS);
1538 } 1500 }
1539 1501
1544 * player that the object belonged to - so if you killed another player 1506 * player that the object belonged to - so if you killed another player
1545 * with spells, pets, whatever, there was no penalty. 1507 * with spells, pets, whatever, there was no penalty.
1546 * Changed to make luck penalty configurable in settings. 1508 * Changed to make luck penalty configurable in settings.
1547 */ 1509 */
1548 if (op->type == PLAYER && owner != op && !battleg) 1510 if (op->type == PLAYER && owner != op && !battleg)
1549 change_luck (owner, -settings.pk_luck_penalty); 1511 owner->change_luck (-settings.pk_luck_penalty);
1550 1512
1551 /* This code below deals with finding the appropriate skill 1513 /* This code below deals with finding the appropriate skill
1552 * to credit exp to. This is a bit problematic - we should 1514 * to credit exp to. This is a bit problematic - we should
1553 * probably never really have to look at current_weapon->skill 1515 * probably never really have to look at current_weapon->skill
1554 */ 1516 */
1555 skill = NULL; 1517 skill = 0;
1518
1556 if (hitter->skill && hitter->type != PLAYER) 1519 if (hitter->skill && hitter->type != PLAYER)
1557 skill = hitter->skill; 1520 skill = hitter->skill;
1558 else if (owner->chosen_skill) 1521 else if (owner->chosen_skill)
1559 { 1522 {
1560 skill = owner->chosen_skill->skill; 1523 skill = owner->chosen_skill->skill;
1579 break; 1542 break;
1580 } 1543 }
1581 } 1544 }
1582 } /* Was it a player that hit somethign */ 1545 } /* Was it a player that hit somethign */
1583 else 1546 else
1584 {
1585 skill = NULL; 1547 skill = 0;
1586 }
1587 1548
1588 /* Pet (or spell) killed something. */ 1549 /* Pet (or spell) killed something. */
1589 if (owner != hitter) 1550 if (owner != hitter)
1590 {
1591 (void) sprintf (buf, "%s killed %s with %s%s%s.", &owner->name, 1551 sprintf (buf, "%s killed %s with %s%s%s.", &owner->name,
1592 query_name (op), query_name (hitter), battleg ? " (duel)" : "", pk ? " (pk)" : ""); 1552 query_name (op), query_name (hitter), battleg ? " (duel)" : "", pk ? " (pk)" : "");
1593 }
1594 else 1553 else
1595 {
1596 (void) sprintf (buf, "%s killed %s%s%s%s.", &hitter->name, &op->name, 1554 sprintf (buf, "%s killed %s%s%s%s.", &hitter->name, &op->name,
1597 (QUERY_FLAG (hitter, FLAG_MONSTER)) || hitter->type == PLAYER ? 1555 (QUERY_FLAG (hitter, FLAG_MONSTER)) || hitter->type == PLAYER ?
1598 " in hand to hand combat" : "", battleg ? " (duel)" : "", pk ? " (pk)" : ""); 1556 " in hand to hand combat" : "", battleg ? " (duel)" : "", pk ? " (pk)" : "");
1599 } 1557
1600 /* These may have been set in the player code section above */ 1558 /* These may have been set in the player code section above */
1601 if (!skop) 1559 if (!skop)
1602 skop = hitter->chosen_skill; 1560 skop = hitter->chosen_skill;
1561
1603 if (!skill && skop) 1562 if (!skill && skop)
1604 skill = skop->skill; 1563 skill = skop->skill;
1605 1564
1606 new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf); 1565 new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf);
1607 1566
1608
1609 /* If you didn't kill yourself, and your not the wizard */ 1567 /* If you didn't kill yourself, and your not the wizard */
1610 if (owner != op && !QUERY_FLAG (op, FLAG_WAS_WIZ)) 1568 if (owner != op && !QUERY_FLAG (op, FLAG_WAS_WIZ))
1611 { 1569 {
1612 int exp; 1570 int exp;
1613 1571
1614 /* Really don't give much experience for killing other players */ 1572 /* Really don't give much experience for killing other players */
1615 // schmorp: temporary? reduce the amount of exp gained for pking enourmously 1573 // schmorp: temporarily? reduce the amount of exp gained for pking enourmously
1616 if (op->type == PLAYER) 1574 if (op->type == PLAYER)
1617 { 1575 {
1618 if (battleg) 1576 if (battleg)
1619 { 1577 {
1620 new_draw_info (NDI_UNIQUE, 0, owner, "Your foe has fallen!"); 1578 new_draw_info (NDI_UNIQUE, 0, owner, "Your foe has fallen!");
1638 1596
1639 if (!settings.simple_exp) 1597 if (!settings.simple_exp)
1640 exp = exp / 2; 1598 exp = exp / 2;
1641 1599
1642 if (owner->type != PLAYER || owner->contr->party == NULL) 1600 if (owner->type != PLAYER || owner->contr->party == NULL)
1643 {
1644 change_exp (owner, exp, skill, 0); 1601 change_exp (owner, exp, skill, 0);
1645 }
1646 else 1602 else
1647 { 1603 {
1648 int shares = 0, count = 0; 1604 int shares = 0, count = 0;
1649
1650 player *pl; 1605 player *pl;
1651
1652 partylist *party = owner->contr->party; 1606 partylist *party = owner->contr->party;
1653 1607
1654#ifdef PARTY_KILL_LOG
1655 add_kill_to_party (party, query_name (owner), query_name (op), exp); 1608 add_kill_to_party (party, query_name (owner), query_name (op), exp);
1656#endif 1609
1657 for (pl = first_player; pl != NULL; pl = pl->next) 1610 for_all_players (pl)
1658 {
1659 if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner)) 1611 if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner))
1660 { 1612 {
1661 count++; 1613 count++;
1662 shares += (pl->ob->level + 4); 1614 shares += (pl->ob->level + 4);
1663 } 1615 }
1664 } 1616
1665 if (count == 1 || shares > exp) 1617 if (count == 1 || shares > exp || !shares)
1666 change_exp (owner, exp, skill, SK_EXP_TOTAL); 1618 change_exp (owner, exp, skill, SK_EXP_TOTAL);
1667 else 1619 else
1668 { 1620 {
1669 int share = exp / shares, given = 0, nexp; 1621 int share = exp / shares, given = 0, nexp;
1670 1622
1671 for (pl = first_player; pl != NULL; pl = pl->next) 1623 for_all_players (pl)
1672 {
1673 if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner)) 1624 if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner))
1674 { 1625 {
1675 nexp = (pl->ob->level + 4) * share; 1626 nexp = (pl->ob->level + 4) * share;
1676 change_exp (pl->ob, nexp, skill, SK_EXP_TOTAL); 1627 change_exp (pl->ob, nexp, skill, SK_EXP_TOTAL);
1677 given += nexp; 1628 given += nexp;
1678 } 1629 }
1679 } 1630
1680 exp -= given; 1631 exp -= given;
1681 /* give any remainder to the player */ 1632 /* give any remainder to the player */
1682 change_exp (owner, exp, skill, SK_EXP_ADD_SKILL); 1633 change_exp (owner, exp, skill, SK_EXP_ADD_SKILL);
1683 } 1634 }
1684 } /* else part of a party */ 1635 } /* else part of a party */
1685
1686 } /* end if person didn't kill himself */ 1636 } /* end if person didn't kill himself */
1687 1637
1688 if (op->type != PLAYER) 1638 if (op->type != PLAYER)
1689 { 1639 {
1690 if (QUERY_FLAG (op, FLAG_FRIENDLY)) 1640 if (QUERY_FLAG (op, FLAG_FRIENDLY))
1691 { 1641 {
1692 object *owner1 = get_owner (op); 1642 object *owner1 = op->owner;
1693 1643
1694 if (owner1 != NULL && owner1->type == PLAYER) 1644 if (owner1 && owner1->type == PLAYER)
1695 { 1645 {
1696 play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); 1646 play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0);
1697 /* Maybe we should include the owner that killed this, maybe not */ 1647 /* Maybe we should include the owner that killed this, maybe not */
1698 new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name); 1648 new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name);
1699 } 1649 }
1700 1650
1701 remove_friendly_object (op); 1651 remove_friendly_object (op);
1702 } 1652 }
1703 1653
1704 remove_ob (op); 1654 op->destroy ();
1705 free_object (op);
1706 } 1655 }
1707 /* Player has been killed! */
1708 else 1656 else
1709 { 1657 {
1658 /* Player has been killed! */
1710 if (owner->type == PLAYER) 1659 if (owner->type == PLAYER)
1711 {
1712 snprintf (op->contr->killer, BIG_NAME, "%s the %s", &owner->name, owner->contr->title); 1660 snprintf (op->contr->killer, sizeof (op->contr->killer), "%s the %s", &owner->name, owner->contr->title);
1713 }
1714 else 1661 else
1715 assign (op->contr->killer, hitter->name); 1662 assign (op->contr->killer, hitter->name);
1716 } 1663 }
1717 1664
1718 /* This was return -1 - that doesn't seem correct - if we return -1, process 1665 /* This was return -1 - that doesn't seem correct - if we return -1, process
1742 return 0; 1689 return 0;
1743 1690
1744 if (hitter->type == PLAYER && hitter->contr->peaceful == 1) 1691 if (hitter->type == PLAYER && hitter->contr->peaceful == 1)
1745 return 1; 1692 return 1;
1746 1693
1747 if ((owner = get_owner (hitter)) != NULL) 1694 if ((owner = hitter->owner) != NULL)
1748 { 1695 {
1749 if (owner->type == PLAYER && owner->contr->peaceful == 1) 1696 if (owner->type == PLAYER && owner->contr->peaceful == 1)
1750 friendlyfire = 2; 1697 friendlyfire = 2;
1751 } 1698 }
1752 1699
1762 * is what is hitting the object, type is the attacktype, and 1709 * is what is hitting the object, type is the attacktype, and
1763 * full_hit is set if monster area does not matter. 1710 * full_hit is set if monster area does not matter.
1764 * dam is base damage - protections/vulnerabilities/slaying matches can 1711 * dam is base damage - protections/vulnerabilities/slaying matches can
1765 * modify it. 1712 * modify it.
1766 */ 1713 */
1767
1768 /* Oct 95 - altered the following slightly for MULTIPLE_GODS hack 1714/* Oct 95 - altered the following slightly for MULTIPLE_GODS hack
1769 * which needs new attacktype AT_HOLYWORD to work . b.t. */ 1715 * which needs new attacktype AT_HOLYWORD to work . b.t. */
1770
1771int 1716int
1772hit_player (object *op, int dam, object *hitter, int type, int full_hit) 1717hit_player (object *op, int dam, object *hitter, int type, int full_hit)
1773{ 1718{
1774 int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC); 1719 int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC);
1775 int maxattacktype, attacknum; 1720 int maxattacktype, attacknum;
1776 int body_attack = op && op->head; /* Did we hit op's head? */ 1721 int body_attack = op && op->head; /* Did we hit op's head? */
1777 int simple_attack; 1722 int simple_attack;
1778 tag_t op_tag, hitter_tag;
1779 int rtn_kill = 0; 1723 int rtn_kill = 0;
1780 int friendlyfire; 1724 int friendlyfire;
1781 1725
1782 if (get_attack_mode (&op, &hitter, &simple_attack)) 1726 if (get_attack_mode (&op, &hitter, &simple_attack))
1783 return 0; 1727 return 0;
1787 return 0; 1731 return 0;
1788 1732
1789#ifdef PROHIBIT_PLAYERKILL 1733#ifdef PROHIBIT_PLAYERKILL
1790 if (op->type == PLAYER) 1734 if (op->type == PLAYER)
1791 { 1735 {
1792 object *owner = get_owner (hitter); 1736 object *owner = hitter->owner;
1793 1737
1794 if (!owner) 1738 if (!owner)
1795 owner = hitter; 1739 owner = hitter;
1740
1796 if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner) 1741 if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner)
1797 {
1798 return 0; 1742 return 0;
1799 }
1800 } 1743 }
1801#endif 1744#endif
1802
1803 op_tag = op->count;
1804 hitter_tag = hitter->count;
1805 1745
1806 if (body_attack) 1746 if (body_attack)
1807 { 1747 {
1808 /* slow and paralyze must hit the head. But we don't want to just 1748 /* slow and paralyze must hit the head. But we don't want to just
1809 * return - we still need to process other attacks the spell still 1749 * return - we still need to process other attacks the spell still
1815 * attack so we don't cancel out things like magic bullet. 1755 * attack so we don't cancel out things like magic bullet.
1816 */ 1756 */
1817 if (type & (AT_PARALYZE | AT_SLOW)) 1757 if (type & (AT_PARALYZE | AT_SLOW))
1818 { 1758 {
1819 type &= ~(AT_PARALYZE | AT_SLOW); 1759 type &= ~(AT_PARALYZE | AT_SLOW);
1760
1820 if (!type || type == AT_MAGIC) 1761 if (!type || type == AT_MAGIC)
1821 return 0; 1762 return 0;
1822 } 1763 }
1823 } 1764 }
1824 1765
1825 if (!simple_attack && op->type == DOOR) 1766 if (!simple_attack && op->type == DOOR)
1826 { 1767 {
1827 object *tmp;
1828
1829 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1768 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1830 if (tmp->type == RUNE || tmp->type == TRAP) 1769 if (tmp->type == RUNE || tmp->type == TRAP)
1831 { 1770 {
1832 spring_trap (tmp, hitter); 1771 spring_trap (tmp, hitter);
1772
1833 if (was_destroyed (hitter, hitter_tag) || was_destroyed (op, op_tag) || abort_attack (op, hitter, simple_attack)) 1773 if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack))
1834 return 0; 1774 return 0;
1775
1835 break; 1776 break;
1836 } 1777 }
1837 } 1778 }
1838 1779
1839 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) 1780 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0)
1840 { 1781 {
1841 /* FIXME: If a player is killed by a rune in a door, the 1782 /* FIXME: If a player is killed by a rune in a door, the
1842 * was_destroyed() check above doesn't return, and might get here. 1783 * destroyed() check above doesn't return, and might get here.
1843 */ 1784 */
1844 LOG (llevDebug, "victim (arch %s, name %s) already dead in " "hit_player()\n", &op->arch->name, &op->name); 1785 LOG (llevDebug, "victim %s already dead in hit_player()\n", op->debug_desc ());
1845 return 0; 1786 return 0;
1846 } 1787 }
1847 1788
1848#ifdef ATTACK_DEBUG 1789#ifdef ATTACK_DEBUG
1849 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam); 1790 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam);
1885 (hitter->title != NULL 1826 (hitter->title != NULL
1886 && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, undead_name) != NULL))) 1827 && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, undead_name) != NULL)))
1887 return 0; 1828 return 0;
1888 } 1829 }
1889 1830
1890 maxattacktype = type; /* initialize this to something */ 1831 maxattacktype = type; /* initialise this to something */
1891 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) 1832 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum)
1892 { 1833 {
1893 /* Magic isn't really a true attack type - it gets combined with other 1834 /* Magic isn't really a true attack type - it gets combined with other
1894 * attack types. As such, skip it over. However, if magic is 1835 * attack types. As such, skip it over. However, if magic is
1895 * the only attacktype in the group, then still attack with it 1836 * the only attacktype in the group, then still attack with it
1956 1897
1957#ifdef ATTACK_DEBUG 1898#ifdef ATTACK_DEBUG
1958 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); 1899 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam);
1959#endif 1900#endif
1960 1901
1961 if (get_owner (hitter)) 1902 if (hitter->owner)
1962 op->enemy = hitter->owner; 1903 op->enemy = hitter->owner;
1963 else if (QUERY_FLAG (hitter, FLAG_ALIVE)) 1904 else if (QUERY_FLAG (hitter, FLAG_ALIVE))
1964 op->enemy = hitter; 1905 op->enemy = hitter;
1965 1906
1966 if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) 1907 if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER)
1991 1932
1992 if (QUERY_FLAG (op, FLAG_TEAR_DOWN)) 1933 if (QUERY_FLAG (op, FLAG_TEAR_DOWN))
1993 { 1934 {
1994 if (maxdam) 1935 if (maxdam)
1995 tear_down_wall (op); 1936 tear_down_wall (op);
1937
1996 return maxdam; /* nothing more to do for wall */ 1938 return maxdam; /* nothing more to do for wall */
1997 } 1939 }
1998 1940
1999 /* See if the creature has been killed */ 1941 /* See if the creature has been killed */
2000 rtn_kill = kill_object (op, maxdam, hitter, type); 1942 rtn_kill = kill_object (op, maxdam, hitter, type);
2008 */ 1950 */
2009 if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) 1951 if (QUERY_FLAG (hitter, FLAG_ONE_HIT))
2010 { 1952 {
2011 if (QUERY_FLAG (hitter, FLAG_FRIENDLY)) 1953 if (QUERY_FLAG (hitter, FLAG_FRIENDLY))
2012 remove_friendly_object (hitter); 1954 remove_friendly_object (hitter);
2013 remove_ob (hitter); 1955
2014 free_object (hitter); 1956 hitter->destroy ();
2015 } 1957 }
2016 /* Lets handle creatures that are splitting now */ 1958 /* Lets handle creatures that are splitting now */
2017 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) 1959 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING))
2018 { 1960 {
2019 int i; 1961 int i;
2020 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); 1962 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY);
2021 int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); 1963 int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE);
2022 object *owner = get_owner (op); 1964 object *owner = op->owner;
2023 1965
2024 if (!op->other_arch) 1966 if (!op->other_arch)
2025 { 1967 {
2026 LOG (llevError, "SPLITTING without other_arch error.\n"); 1968 LOG (llevError, "SPLITTING without other_arch error.\n");
2027 return maxdam; 1969 return maxdam;
2028 } 1970 }
1971
2029 remove_ob (op); 1972 op->remove ();
1973
2030 for (i = 0; i < NROFNEWOBJS (op); i++) 1974 for (i = 0; i < NROFNEWOBJS (op); i++)
2031 { /* This doesn't handle op->more yet */ 1975 { /* This doesn't handle op->more yet */
2032 object *tmp = arch_to_object (op->other_arch); 1976 object *tmp = arch_to_object (op->other_arch);
2033 int j; 1977 int j;
2034 1978
2035 tmp->stats.hp = op->stats.hp; 1979 tmp->stats.hp = op->stats.hp;
1980
2036 if (friendly) 1981 if (friendly)
2037 { 1982 {
2038 SET_FLAG (tmp, FLAG_FRIENDLY);
2039 add_friendly_object (tmp); 1983 add_friendly_object (tmp);
2040 tmp->attack_movement = PETMOVE; 1984 tmp->attack_movement = PETMOVE;
1985
2041 if (owner != NULL) 1986 if (owner)
2042 set_owner (tmp, owner); 1987 tmp->set_owner (owner);
2043 } 1988 }
1989
2044 if (unaggressive) 1990 if (unaggressive)
2045 SET_FLAG (tmp, FLAG_UNAGGRESSIVE); 1991 SET_FLAG (tmp, FLAG_UNAGGRESSIVE);
1992
2046 j = find_first_free_spot (tmp, op->map, op->x, op->y); 1993 j = find_first_free_spot (tmp, op->map, op->x, op->y);
1994
2047 if (j == -1) /* No spot to put this monster */ 1995 if (j == -1) /* No spot to put this monster */
2048 free_object (tmp); 1996 tmp->destroy ();
2049 else 1997 else
2050 { 1998 {
2051 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; 1999 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j];
2052 insert_ob_in_map (tmp, op->map, NULL, 0); 2000 insert_ob_in_map (tmp, op->map, NULL, 0);
2053 } 2001 }
2054 } 2002 }
2055 if (friendly) 2003
2056 remove_friendly_object (op); 2004 op->destroy ();
2057 free_object (op);
2058 } 2005 }
2059 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) 2006 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10)
2060 { 2007 hitter->destroy ();
2061 remove_ob (hitter); 2008
2062 free_object (hitter);
2063 }
2064 return maxdam; 2009 return maxdam;
2065} 2010}
2066 2011
2067 2012
2068void 2013void
2069poison_player (object *op, object *hitter, int dam) 2014poison_player (object *op, object *hitter, int dam)
2070{ 2015{
2071 archetype *at = find_archetype ("poisoning"); 2016 archetype *at = archetype::find ("poisoning");
2072 object *tmp = present_arch_in_ob (at, op); 2017 object *tmp = present_arch_in_ob (at, op);
2073 2018
2074 if (tmp == NULL) 2019 if (tmp == NULL)
2075 { 2020 {
2076 if ((tmp = arch_to_object (at)) == NULL) 2021 if ((tmp = arch_to_object (at)) == NULL)
2089 if (QUERY_FLAG (hitter, FLAG_ALIVE)) 2034 if (QUERY_FLAG (hitter, FLAG_ALIVE))
2090 tmp->stats.dam += hitter->level / 2; 2035 tmp->stats.dam += hitter->level / 2;
2091 else 2036 else
2092 tmp->stats.dam = dam; 2037 tmp->stats.dam = dam;
2093 2038
2094 copy_owner (tmp, hitter); /* so we get credit for poisoning kills */ 2039 tmp->set_owner (hitter); /* so we get credit for poisoning kills */
2095 if (hitter->skill && hitter->skill != tmp->skill) 2040 if (hitter->skill && hitter->skill != tmp->skill)
2096 { 2041 {
2097 tmp->skill = hitter->skill; 2042 tmp->skill = hitter->skill;
2098 } 2043 }
2099 2044
2105 tmp->stats.Con = MAX (-(dam / 4 + 1), -10); 2050 tmp->stats.Con = MAX (-(dam / 4 + 1), -10);
2106 tmp->stats.Str = MAX (-(dam / 3 + 2), -10); 2051 tmp->stats.Str = MAX (-(dam / 3 + 2), -10);
2107 tmp->stats.Dex = MAX (-(dam / 6 + 1), -10); 2052 tmp->stats.Dex = MAX (-(dam / 6 + 1), -10);
2108 tmp->stats.Int = MAX (-dam / 7, -10); 2053 tmp->stats.Int = MAX (-dam / 7, -10);
2109 SET_FLAG (tmp, FLAG_APPLIED); 2054 SET_FLAG (tmp, FLAG_APPLIED);
2110 fix_player (op); 2055 op->update_stats ();
2111 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); 2056 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill.");
2112 } 2057 }
2113 if (hitter->type == PLAYER) 2058 if (hitter->type == PLAYER)
2114 new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); 2059 new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name);
2115 else if (get_owner (hitter) != NULL && hitter->owner->type == PLAYER) 2060 else if (hitter->owner != NULL && hitter->owner->type == PLAYER)
2116 new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); 2061 new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name);
2117 } 2062 }
2118 tmp->speed_left = 0; 2063 tmp->speed_left = 0;
2119 } 2064 }
2120 else 2065 else
2122} 2067}
2123 2068
2124void 2069void
2125slow_player (object *op, object *hitter, int dam) 2070slow_player (object *op, object *hitter, int dam)
2126{ 2071{
2127 archetype *at = find_archetype ("slowness"); 2072 archetype *at = archetype::find ("slowness");
2128 object *tmp; 2073 object *tmp;
2129 2074
2130 if (at == NULL) 2075 if (at == NULL)
2131 { 2076 {
2132 LOG (llevError, "Can't find slowness archetype.\n"); 2077 LOG (llevError, "Can't find slowness archetype.\n");
2139 } 2084 }
2140 else 2085 else
2141 tmp->stats.food++; 2086 tmp->stats.food++;
2142 SET_FLAG (tmp, FLAG_APPLIED); 2087 SET_FLAG (tmp, FLAG_APPLIED);
2143 tmp->speed_left = 0; 2088 tmp->speed_left = 0;
2144 fix_player (op); 2089 op->update_stats ();
2145} 2090}
2146 2091
2147void 2092void
2148confuse_player (object *op, object *hitter, int dam) 2093confuse_player (object *op, object *hitter, int dam)
2149{ 2094{
2193 */ 2138 */
2194 tmp->speed = tmp->speed * (100.0 - (float) op->resist[ATNR_BLIND]) / 100; 2139 tmp->speed = tmp->speed * (100.0 - (float) op->resist[ATNR_BLIND]) / 100;
2195 2140
2196 tmp = insert_ob_in_ob (tmp, op); 2141 tmp = insert_ob_in_ob (tmp, op);
2197 change_abil (op, tmp); /* Mostly to display any messages */ 2142 change_abil (op, tmp); /* Mostly to display any messages */
2198 fix_player (op); /* This takes care of some other stuff */ 2143 op->update_stats (); /* This takes care of some other stuff */
2199 2144
2200 if (hitter->owner) 2145 if (hitter->owner)
2201 owner = get_owner (hitter); 2146 owner = hitter->owner;
2202 else 2147 else
2203 owner = hitter; 2148 owner = hitter;
2204 2149
2205 new_draw_info_format (NDI_UNIQUE, 0, owner, "Your attack blinds %s!", query_name (op)); 2150 new_draw_info_format (NDI_UNIQUE, 0, owner, "Your attack blinds %s!", query_name (op));
2206 } 2151 }
2352 } 2297 }
2353 2298
2354 /* aimed missiles use the owning object's sight */ 2299 /* aimed missiles use the owning object's sight */
2355 if (is_aimed_missile (hitter)) 2300 if (is_aimed_missile (hitter))
2356 { 2301 {
2357 if ((attacker = get_owner (hitter)) == NULL) 2302 if ((attacker = hitter->owner) == NULL)
2358 attacker = hitter; 2303 attacker = hitter;
2359 /* A player who saves but hasn't quit still could have objects 2304 /* A player who saves but hasn't quit still could have objects
2360 * owned by him - need to handle that case to avoid crashes. 2305 * owned by him - need to handle that case to avoid crashes.
2361 */ 2306 */
2362 if (QUERY_FLAG (attacker, FLAG_REMOVED)) 2307 if (QUERY_FLAG (attacker, FLAG_REMOVED))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines