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.24 by root, Sat Dec 9 16:11:09 2006 UTC vs.
Revision 1.40 by root, Sun Jan 14 22:06:05 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
72 esrv_send_item (op->env, op); 73 esrv_send_item (op->env, op);
73 } 74 }
74 } 75 }
75} 76}
76 77
77
78
79/* did_make_save_item just checks to make sure the item actually 78/* did_make_save_item just checks to make sure the item actually
80 * made its saving throw based on the tables. It does not take 79 * made its saving throw based on the tables. It does not take
81 * any further action (like destroying the item). 80 * any further action (like destroying the item).
82 */ 81 */
83
84int 82int
85did_make_save_item (object *op, int type, object *originator) 83did_make_save_item (object *op, int type, object *originator)
86{ 84{
87 int i, roll, saves = 0, attacks = 0, number; 85 int i, roll, saves = 0, attacks = 0, number;
88 materialtype_t *mt; 86 materialtype_t *mt;
89 87
90 if (op->materialname == NULL) 88 if (op->materialname == NULL)
91 { 89 {
92 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) 90 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next)
93 {
94 if (op->material & mt->material) 91 if (op->material & mt->material)
95 break; 92 break;
96 }
97 } 93 }
98 else 94 else
99 mt = name_to_material (op->materialname); 95 mt = name_to_material (op->materialname);
96
100 if (mt == NULL) 97 if (mt == NULL)
101 return TRUE; 98 return TRUE;
99
102 roll = rndm (1, 20); 100 roll = rndm (1, 20);
103 101
104 /* the attacktypes have no meaning for object saves 102 /* the attacktypes have no meaning for object saves
105 * If the type is only magic, don't adjust type - basically, if 103 * If the type is only magic, don't adjust type - basically, if
106 * pure magic is hitting an object, it should save. However, if it 104 * pure magic is hitting an object, it should save. However, if it
212 } 210 }
213 else 211 else
214 { 212 {
215 if (op->env) 213 if (op->env)
216 { 214 {
217 object *tmp = is_player_inv (op->env); 215 object *tmp = op->in_player ();
218 216
219 if (tmp) 217 if (tmp)
220 esrv_del_item (tmp->contr, op->count); 218 esrv_del_item (tmp->contr, op->count);
221 } 219 }
222 220
223 if (!QUERY_FLAG (op, FLAG_REMOVED)) 221 op->destroy ();
224 remove_ob (op);
225
226 free_object (op);
227 } 222 }
228 223
229 if (type & (AT_FIRE | AT_ELECTRICITY)) 224 if (type & (AT_FIRE | AT_ELECTRICITY))
230 if (env) 225 if (env)
231 { 226 {
264 tmp->move_slow = 0; 259 tmp->move_slow = 0;
265 insert_ob_in_map (tmp, op->map, originator, 0); 260 insert_ob_in_map (tmp, op->map, originator, 0);
266 } 261 }
267 262
268 if (!QUERY_FLAG (op, FLAG_REMOVED)) 263 if (!QUERY_FLAG (op, FLAG_REMOVED))
269 remove_ob (op); 264 op->remove ();
270 265
271 insert_ob_in_ob (op, tmp); 266 insert_ob_in_ob (op, tmp);
272 return; 267 return;
273 } 268 }
274} 269}
281 */ 276 */
282 277
283int 278int
284hit_map (object *op, int dir, int type, int full_hit) 279hit_map (object *op, int dir, int type, int full_hit)
285{ 280{
286 object *tmp, *next;
287 maptile *map; 281 maptile *map;
288 sint16 x, y; 282 sint16 x, y;
289 int retflag = 0; /* added this flag.. will return 1 if it hits a monster */ 283 int retflag = 0; /* added this flag.. will return 1 if it hits a monster */
290 284
291 if (QUERY_FLAG (op, FLAG_FREED)) 285 if (QUERY_FLAG (op, FLAG_FREED))
342 shuffle_attack (op, 1); /*1 flag tells it to change the face */ 336 shuffle_attack (op, 1); /*1 flag tells it to change the face */
343 update_object (op, UP_OBJ_FACE); 337 update_object (op, UP_OBJ_FACE);
344 type &= ~AT_CHAOS; 338 type &= ~AT_CHAOS;
345 } 339 }
346 340
347 next = get_map_ob (map, x, y);
348
349 while (next)
350 {
351 if (next->destroyed ())
352 {
353 /* There may still be objects that were above 'next', but there is no 341 /* There may still be objects that were above 'next', but there is no
354 * simple way to find out short of copying all object references and 342 * simple way to find out short of copying all object references and
355 * tags into a temporary array before we start processing the first 343 * tags into a temporary array before we start processing the first
356 * object. That's why we just abort. 344 * object. That's why we just abort on destroy.
357 * 345 *
358 * This happens whenever attack spells (like fire) hit a pile 346 * This happens whenever attack spells (like fire) hit a pile
359 * of objects. This is not a bug - nor an error. The errormessage 347 * of objects. This is not a bug - nor an error.
360 * below was spamming the logs for absolutely no reason. 348 */
361 */ 349 for (object *next = map->at (x, y).bot; next && !next->destroyed (); )
362 /* LOG (llevDebug, "hit_map(): next object destroyed\n"); */ 350 {
363 break;
364 }
365
366 tmp = next; 351 object *tmp = next;
367 next = tmp->above; 352 next = tmp->above;
368
369 if (tmp->destroyed ())
370 {
371 LOG (llevError, "BUG: hit_map(): found freed object\n");
372 break;
373 }
374 353
375 /* Something could have happened to 'tmp' while 'tmp->below' was processed. 354 /* Something could have happened to 'tmp' while 'tmp->below' was processed.
376 * For example, 'tmp' was put in an icecube. 355 * For example, 'tmp' was put in an icecube.
377 * This is one of the few cases where on_same_map should not be used. 356 * This is one of the few cases where on_same_map should not be used.
378 */ 357 */
384 hit_player (tmp, op->stats.dam, op, type, full_hit); 363 hit_player (tmp, op->stats.dam, op, type, full_hit);
385 retflag |= 1; 364 retflag |= 1;
386 if (op->destroyed ()) 365 if (op->destroyed ())
387 break; 366 break;
388 } 367 }
389
390 /* Here we are potentially destroying an object. If the object has 368 /* Here we are potentially destroying an object. If the object has
391 * NO_PASS set, it is also immune - you can't destroy walls. Note 369 * NO_PASS set, it is also immune - you can't destroy walls. Note
392 * that weak walls have is_alive set, which prevent objects from 370 * that weak walls have is_alive set, which prevent objects from
393 * passing over/through them. We don't care what type of movement 371 * passing over/through them. We don't care what type of movement
394 * the wall blocks - if it blocks any type of movement, can't be 372 * the wall blocks - if it blocks any type of movement, can't be
395 * destroyed right now. 373 * destroyed right now.
396 */ 374 */
397 else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block) 375 else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block)
398 { 376 {
399 save_throw_object (tmp, type, op); 377 save_throw_object (tmp, type, op);
378
400 if (op->destroyed ()) 379 if (op->destroyed ())
401 break; 380 break;
402 } 381 }
403 } 382 }
404 383
435 sprintf (buf1, "missed %s", &op->name); 414 sprintf (buf1, "missed %s", &op->name);
436 sprintf (buf2, " misses"); 415 sprintf (buf2, " misses");
437 found++; 416 found++;
438 } 417 }
439 else if ((hitter->type == DISEASE || hitter->type == SYMPTOM || 418 else if ((hitter->type == DISEASE || hitter->type == SYMPTOM ||
440 hitter->type == POISONING || (type & AT_POISON && IS_LIVE (op))) && !found) 419 hitter->type == POISONING || (type & AT_POISON && op->is_alive ())) && !found)
441 { 420 {
442 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_SUFFER][i].level != -1; i++) 421 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_SUFFER][i].level != -1; i++)
443 if (dam < attack_mess[ATM_SUFFER][i].level || attack_mess[ATM_SUFFER][i + 1].level == -1) 422 if (dam < attack_mess[ATM_SUFFER][i].level || attack_mess[ATM_SUFFER][i + 1].level == -1)
444 { 423 {
445 sprintf (buf1, "%s %s%s", attack_mess[ATM_SUFFER][i].buf1, &op->name, attack_mess[ATM_SUFFER][i].buf2); 424 sprintf (buf1, "%s %s%s", attack_mess[ATM_SUFFER][i].buf1, &op->name, attack_mess[ATM_SUFFER][i].buf2);
457 strcpy (buf2, attack_mess[ATM_DOOR][i].buf3); 436 strcpy (buf2, attack_mess[ATM_DOOR][i].buf3);
458 found++; 437 found++;
459 break; 438 break;
460 } 439 }
461 } 440 }
462 else if (hitter->type == PLAYER && IS_LIVE (op)) 441 else if (hitter->type == PLAYER && op->is_alive ())
463 { 442 {
464 if (USING_SKILL (hitter, SK_KARATE)) 443 if (USING_SKILL (hitter, SK_KARATE))
465 { 444 {
466 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_KARATE][i].level != -1; i++) 445 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_KARATE][i].level != -1; i++)
467 if (dam < attack_mess[ATM_KARATE][i].level || attack_mess[ATM_KARATE][i + 1].level == -1) 446 if (dam < attack_mess[ATM_KARATE][i].level || attack_mess[ATM_KARATE][i + 1].level == -1)
493 found++; 472 found++;
494 break; 473 break;
495 } 474 }
496 } 475 }
497 } 476 }
477
498 if (found) 478 if (found)
499 { 479 {
500 /* done */ 480 /* done */
501 } 481 }
502 else if (IS_ARROW (hitter) && (type == AT_PHYSICAL || type == AT_MAGIC)) 482 else if (hitter->is_arrow () && (type == AT_PHYSICAL || type == AT_MAGIC))
503 { 483 {
504 sprintf (buf1, "hit"); /* just in case */ 484 sprintf (buf1, "hit"); /* just in case */
505 for (i = 0; i < MAXATTACKMESS; i++) 485 for (i = 0; i < MAXATTACKMESS; i++)
506 if (dam < attack_mess[ATM_ARROW][i].level || attack_mess[ATM_ARROW][i + 1].level == -1) 486 if (dam < attack_mess[ATM_ARROW][i].level || attack_mess[ATM_ARROW][i + 1].level == -1)
507 { 487 {
508 strcpy (buf2, attack_mess[ATM_ARROW][i].buf3); 488 strcpy (buf2, attack_mess[ATM_ARROW][i].buf3);
509 found++; 489 found++;
510 break; 490 break;
511 } 491 }
512 } 492 }
513 else if (type & AT_DRAIN && IS_LIVE (op)) 493 else if (type & AT_DRAIN && op->is_alive ())
514 { 494 {
515 /* drain is first, because some items have multiple attypes */ 495 /* drain is first, because some items have multiple attypes */
516 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_DRAIN][i].level != -1; i++) 496 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_DRAIN][i].level != -1; i++)
517 if (dam < attack_mess[ATM_DRAIN][i].level || attack_mess[ATM_DRAIN][i + 1].level == -1) 497 if (dam < attack_mess[ATM_DRAIN][i].level || attack_mess[ATM_DRAIN][i + 1].level == -1)
518 { 498 {
520 strcpy (buf2, attack_mess[ATM_DRAIN][i].buf3); 500 strcpy (buf2, attack_mess[ATM_DRAIN][i].buf3);
521 found++; 501 found++;
522 break; 502 break;
523 } 503 }
524 } 504 }
525 else if (type & AT_ELECTRICITY && IS_LIVE (op)) 505 else if (type & AT_ELECTRICITY && op->is_alive ())
526 { 506 {
527 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_ELEC][i].level != -1; i++) 507 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_ELEC][i].level != -1; i++)
528 if (dam < attack_mess[ATM_ELEC][i].level || attack_mess[ATM_ELEC][i + 1].level == -1) 508 if (dam < attack_mess[ATM_ELEC][i].level || attack_mess[ATM_ELEC][i + 1].level == -1)
529 { 509 {
530 sprintf (buf1, "%s %s%s", attack_mess[ATM_ELEC][i].buf1, &op->name, attack_mess[ATM_ELEC][i].buf2); 510 sprintf (buf1, "%s %s%s", attack_mess[ATM_ELEC][i].buf1, &op->name, attack_mess[ATM_ELEC][i].buf2);
531 strcpy (buf2, attack_mess[ATM_ELEC][i].buf3); 511 strcpy (buf2, attack_mess[ATM_ELEC][i].buf3);
532 found++; 512 found++;
533 break; 513 break;
534 } 514 }
535 } 515 }
536 else if (type & AT_COLD && IS_LIVE (op)) 516 else if (type & AT_COLD && op->is_alive ())
537 { 517 {
538 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_COLD][i].level != -1; i++) 518 for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_COLD][i].level != -1; i++)
539 if (dam < attack_mess[ATM_COLD][i].level || attack_mess[ATM_COLD][i + 1].level == -1) 519 if (dam < attack_mess[ATM_COLD][i].level || attack_mess[ATM_COLD][i + 1].level == -1)
540 { 520 {
541 sprintf (buf1, "%s %s%s", attack_mess[ATM_COLD][i].buf1, &op->name, attack_mess[ATM_COLD][i].buf2); 521 sprintf (buf1, "%s %s%s", attack_mess[ATM_COLD][i].buf1, &op->name, attack_mess[ATM_COLD][i].buf2);
618 strcpy (buf1, "hit"); 598 strcpy (buf1, "hit");
619 strcpy (buf2, " hits"); 599 strcpy (buf2, " hits");
620 } 600 }
621 601
622 /* bail out if a monster is casting spells */ 602 /* bail out if a monster is casting spells */
623 if (!(hitter->type == PLAYER || (get_owner (hitter) != NULL && hitter->owner->type == PLAYER))) 603 if (!(hitter->type == PLAYER || (hitter->owner != NULL && hitter->owner->type == PLAYER)))
624 return; 604 return;
625 605
626 /* scale down magic considerably. */ 606 /* scale down magic considerably. */
627 if (type & AT_MAGIC && rndm (0, 5)) 607 if (type & AT_MAGIC && rndm (0, 5))
628 return; 608 return;
629 609
630 /* Did a player hurt another player? Inform both! */ 610 /* Did a player hurt another player? Inform both! */
631 if (op->type == PLAYER && (get_owner (hitter) == NULL ? hitter->type : hitter->owner->type) == PLAYER) 611 if (op->type == PLAYER && (hitter->owner == NULL ? hitter->type : hitter->owner->type) == PLAYER)
632 { 612 {
633 if (get_owner (hitter) != NULL) 613 if (hitter->owner != NULL)
634 sprintf (buf, "%s's %s%s you.", &hitter->owner->name, &hitter->name, buf2); 614 sprintf (buf, "%s's %s%s you.", &hitter->owner->name, &hitter->name, buf2);
635 else 615 else
636 { 616 {
637 sprintf (buf, "%s%s you.", &hitter->name, buf2); 617 sprintf (buf, "%s%s you.", &hitter->name, buf2);
638 if (dam != 0) 618 if (dam != 0)
660 else 640 else
661 play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS3, 0, 0); 641 play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS3, 0, 0);
662 } 642 }
663 new_draw_info (NDI_BLACK, 0, hitter, buf); 643 new_draw_info (NDI_BLACK, 0, hitter, buf);
664 } 644 }
665 else if (get_owner (hitter) != NULL && hitter->owner->type == PLAYER) 645 else if (hitter->owner != NULL && hitter->owner->type == PLAYER)
666 { 646 {
667 /* look for stacked spells and start reducing the message chances */ 647 /* look for stacked spells and start reducing the message chances */
668 if (hitter->type == SPELL_EFFECT && (hitter->subtype == SP_EXPLOSION || hitter->subtype == SP_BULLET || hitter->subtype == SP_CONE)) 648 if (hitter->type == SPELL_EFFECT && (hitter->subtype == SP_EXPLOSION || hitter->subtype == SP_BULLET || hitter->subtype == SP_CONE))
669 { 649 {
670 i = 4; 650 i = 4;
671 map = hitter->map; 651 map = hitter->map;
672 if (out_of_map (map, hitter->x, hitter->y)) 652 if (out_of_map (map, hitter->x, hitter->y))
673 return; 653 return;
674 next = get_map_ob (map, hitter->x, hitter->y); 654 next = GET_MAP_OB (map, hitter->x, hitter->y);
675 if (next) 655 if (next)
676 while (next) 656 while (next)
677 { 657 {
678 if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) 658 if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE))
679 i *= 3; 659 i *= 3;
769 * which then gets here again. By decreasing the speed before 749 * which then gets here again. By decreasing the speed before
770 * we call process_object, the 'if' statement above will fail. 750 * we call process_object, the 'if' statement above will fail.
771 */ 751 */
772 op->speed_left--; 752 op->speed_left--;
773 process_object (op); 753 process_object (op);
754
774 if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack)) 755 if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack))
775 goto error; 756 goto error;
776 } 757 }
777 758
778 op_name = op->name; 759 op_name = op->name;
791 if (settings.casting_time == TRUE) 772 if (settings.casting_time == TRUE)
792 { 773 {
793 if ((hitter->type == PLAYER) && (hitter->casting_time > -1)) 774 if ((hitter->type == PLAYER) && (hitter->casting_time > -1))
794 { 775 {
795 hitter->casting_time = -1; 776 hitter->casting_time = -1;
796 new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost " "your spell!"); 777 new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost your spell!");
797 } 778 }
798 if ((op->casting_time > -1) && (hitdam > 0)) 779 if ((op->casting_time > -1) && (hitdam > 0))
799 { 780 {
800 op->casting_time = -1; 781 op->casting_time = -1;
801 if (op->type == PLAYER) 782 if (op->type == PLAYER)
802 { 783 {
803 new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost " "your spell!"); 784 new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost your spell!");
804 new_draw_info_format (NDI_ALL | NDI_UNIQUE, 5, NULL, "%s was hit by %s and lost a spell.", &op_name, &hitter->name); 785 new_draw_info_format (NDI_ALL | NDI_UNIQUE, 5, NULL, "%s was hit by %s and lost a spell.", &op_name, &hitter->name);
805 } 786 }
806 } 787 }
807 } 788 }
808 if (!simple_attack) 789 if (!simple_attack)
813 if (QUERY_FLAG (op, FLAG_SLEEP)) 794 if (QUERY_FLAG (op, FLAG_SLEEP))
814 CLEAR_FLAG (op, FLAG_SLEEP); 795 CLEAR_FLAG (op, FLAG_SLEEP);
815 796
816 /* If the victim can't see the attacker, it may alert others 797 /* If the victim can't see the attacker, it may alert others
817 * for help. */ 798 * for help. */
818 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !get_owner (op) && rndm (0, op->stats.Int)) 799 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int))
819 npc_call_help (op); 800 npc_call_help (op);
820 801
821 /* if you were hidden and hit by a creature, you are discovered */ 802 /* if you were hidden and hit by a creature, you are discovered */
822 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) 803 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE))
823 { 804 {
830 * when they hit the victim. For things like thrown daggers, 811 * when they hit the victim. For things like thrown daggers,
831 * this sets 'hitter' to the actual dagger, and not the 812 * this sets 'hitter' to the actual dagger, and not the
832 * wrapper object. 813 * wrapper object.
833 */ 814 */
834 thrown_item_effect (hitter, op); 815 thrown_item_effect (hitter, op);
816
835 if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) 817 if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack))
836 goto leave; 818 goto leave;
837 } 819 }
838 820
839 /* Need to do at least 1 damage, otherwise there is no point 821 /* Need to do at least 1 damage, otherwise there is no point
906 if (op->weight <= 5000 && tmp->stats.hp >= 0) 888 if (op->weight <= 5000 && tmp->stats.hp >= 0)
907 { 889 {
908 if (tmp->head != NULL) 890 if (tmp->head != NULL)
909 tmp = tmp->head; 891 tmp = tmp->head;
910 892
911 remove_ob (op); 893 op->remove ();
912 op = insert_ob_in_ob (op, tmp); 894 op = insert_ob_in_ob (op, tmp);
913 895
914 if (tmp->type == PLAYER) 896 if (tmp->type == PLAYER)
915 esrv_send_item (tmp, op); 897 esrv_send_item (tmp, op);
916 898
935 /* Disassemble missile */ 917 /* Disassemble missile */
936 if (op->inv) 918 if (op->inv)
937 { 919 {
938 container = op; 920 container = op;
939 hitter = op->inv; 921 hitter = op->inv;
940 remove_ob (hitter); 922 hitter->remove ();
941 insert_ob_in_map (hitter, container->map, hitter, INS_NO_MERGE | INS_NO_WALK_ON); 923 insert_ob_in_map (hitter, container->map, hitter, INS_NO_MERGE | INS_NO_WALK_ON);
942 /* Note that we now have an empty THROWN_OBJ on the map. Code that 924 /* Note that we now have an empty THROWN_OBJ on the map. Code that
943 * might be called until this THROWN_OBJ is either reassembled or 925 * might be called until this THROWN_OBJ is either reassembled or
944 * removed at the end of this function must be able to deal with empty 926 * removed at the end of this function must be able to deal with empty
945 * THROWN_OBJs. */ 927 * THROWN_OBJs. */
961 */ 943 */
962 if (hitter->destroyed () || hitter->env != NULL) 944 if (hitter->destroyed () || hitter->env != NULL)
963 { 945 {
964 if (container) 946 if (container)
965 { 947 {
966 remove_ob (container); 948 container->remove ();
967 free_object (container); 949 container->destroy ();
968 } 950 }
969 951
970 return 0; 952 return 0;
971 } 953 }
972 954
982 hitter = fix_stopped_arrow (hitter); 964 hitter = fix_stopped_arrow (hitter);
983 if (!hitter) 965 if (!hitter)
984 return 0; 966 return 0;
985 } 967 }
986 else 968 else
987 { 969 container->destroy ();
988 remove_ob (container);
989 free_object (container);
990 }
991 970
992 /* Try to stick arrow into victim */ 971 /* Try to stick arrow into victim */
993 if (!victim->destroyed () && stick_arrow (hitter, victim)) 972 if (!victim->destroyed () && stick_arrow (hitter, victim))
994 return 0; 973 return 0;
995 974
1000 * can fly over but not otherwise move over. What is the correct 979 * can fly over but not otherwise move over. What is the correct
1001 * way to handle those otherwise? 980 * way to handle those otherwise?
1002 */ 981 */
1003 if (victim->x != hitter->x || victim->y != hitter->y) 982 if (victim->x != hitter->x || victim->y != hitter->y)
1004 { 983 {
1005 remove_ob (hitter); 984 hitter->remove ();
1006 hitter->x = victim->x; 985 hitter->x = victim->x;
1007 hitter->y = victim->y; 986 hitter->y = victim->y;
1008 insert_ob_in_map (hitter, victim->map, hitter, 0); 987 insert_ob_in_map (hitter, victim->map, hitter, 0);
1009 } 988 }
1010 else 989 else
1018 op->speed -= 1.0; 997 op->speed -= 1.0;
1019 998
1020 /* Missile missed victim - reassemble missile */ 999 /* Missile missed victim - reassemble missile */
1021 if (container) 1000 if (container)
1022 { 1001 {
1023 remove_ob (hitter); 1002 hitter->remove ();
1024 insert_ob_in_ob (hitter, container); 1003 insert_ob_in_ob (hitter, container);
1025 } 1004 }
1026 1005
1027 return op; 1006 return op;
1028} 1007}
1040 } 1019 }
1041 else if (!GET_ANIM_ID (op)) 1020 else if (!GET_ANIM_ID (op))
1042 { 1021 {
1043 /* Object has been called - no animations, so remove it */ 1022 /* Object has been called - no animations, so remove it */
1044 if (op->stats.hp < 0) 1023 if (op->stats.hp < 0)
1024 op->destroy ();
1045 { 1025
1046 remove_ob (op); /* Should update LOS */
1047 free_object (op);
1048 /* Don't know why this is here - remove_ob should do it for us */
1049 /*update_position(m, x, y); */
1050 }
1051 return; /* no animations, so nothing more to do */ 1026 return; /* no animations, so nothing more to do */
1052 } 1027 }
1028
1053 perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; 1029 perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp;
1030
1054 if (perc >= (int) NUM_ANIMATIONS (op)) 1031 if (perc >= (int) NUM_ANIMATIONS (op))
1055 perc = NUM_ANIMATIONS (op) - 1; 1032 perc = NUM_ANIMATIONS (op) - 1;
1056 else if (perc < 1) 1033 else if (perc < 1)
1057 perc = 1; 1034 perc = 1;
1035
1058 SET_ANIMATION (op, perc); 1036 SET_ANIMATION (op, perc);
1059 update_object (op, UP_OBJ_FACE); 1037 update_object (op, UP_OBJ_FACE);
1038
1060 if (perc == NUM_ANIMATIONS (op) - 1) 1039 if (perc == NUM_ANIMATIONS (op) - 1)
1061 { /* Reached the last animation */ 1040 { /* Reached the last animation */
1062 if (op->face == blank_face) 1041 if (op->face == blank_face)
1063 {
1064 /* If the last face is blank, remove the ob */ 1042 /* If the last face is blank, remove the ob */
1065 remove_ob (op); /* Should update LOS */ 1043 op->destroy ();
1066 free_object (op);
1067
1068 /* remove_ob should call update_position for us */
1069 /*update_position(m, x, y); */
1070
1071 }
1072 else 1044 else
1073 { /* The last face was not blank, leave an image */ 1045 { /* The last face was not blank, leave an image */
1074 CLEAR_FLAG (op, FLAG_BLOCKSVIEW); 1046 CLEAR_FLAG (op, FLAG_BLOCKSVIEW);
1075 update_all_los (op->map, op->x, op->y); 1047 update_all_los (op->map, op->x, op->y);
1076 op->move_block = 0; 1048 op->move_block = 0;
1080} 1052}
1081 1053
1082void 1054void
1083scare_creature (object *target, object *hitter) 1055scare_creature (object *target, object *hitter)
1084{ 1056{
1085 object *owner = get_owner (hitter); 1057 object *owner = hitter->owner;
1086 1058
1087 if (!owner) 1059 if (!owner)
1088 owner = hitter; 1060 owner = hitter;
1089 1061
1090 SET_FLAG (target, FLAG_SCARED); 1062 SET_FLAG (target, FLAG_SCARED);
1101 * the attacktype. Makes it easier for the PR code. */ 1073 * the attacktype. Makes it easier for the PR code. */
1102 1074
1103int 1075int
1104hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic) 1076hit_player_attacktype (object *op, object *hitter, int dam, uint32 attacknum, int magic)
1105{ 1077{
1106
1107 int doesnt_slay = 1; 1078 int doesnt_slay = 1;
1108 1079
1109 /* Catch anyone that may be trying to send us a bitmask instead of the number */ 1080 /* Catch anyone that may be trying to send us a bitmask instead of the number */
1110 if (attacknum >= NROFATTACKS) 1081 if (attacknum >= NROFATTACKS)
1111 { 1082 {
1156 1127
1157 /* Keep this in order - makes things easier to find */ 1128 /* Keep this in order - makes things easier to find */
1158 1129
1159 switch (attacknum) 1130 switch (attacknum)
1160 { 1131 {
1161 case ATNR_PHYSICAL: 1132 case ATNR_PHYSICAL:
1162 /* here also check for diseases */ 1133 /* here also check for diseases */
1163 check_physically_infect (op, hitter); 1134 check_physically_infect (op, hitter);
1164 break; 1135 break;
1165 1136
1166 /* Don't need to do anything for: 1137 /* Don't need to do anything for:
1167 magic, 1138 magic,
1168 fire, 1139 fire,
1169 electricity, 1140 electricity,
1170 cold */ 1141 cold */
1171 1142
1172 case ATNR_CONFUSION: 1143 case ATNR_CONFUSION:
1173 case ATNR_POISON: 1144 case ATNR_POISON:
1174 case ATNR_SLOW: 1145 case ATNR_SLOW:
1175 case ATNR_PARALYZE: 1146 case ATNR_PARALYZE:
1176 case ATNR_FEAR: 1147 case ATNR_FEAR:
1177 case ATNR_CANCELLATION: 1148 case ATNR_CANCELLATION:
1178 case ATNR_DEPLETE: 1149 case ATNR_DEPLETE:
1179 case ATNR_BLIND: 1150 case ATNR_BLIND:
1180 { 1151 {
1181 /* chance for inflicting a special attack depends on the 1152 /* chance for inflicting a special attack depends on the
1182 * difference between attacker's and defender's level 1153 * difference between attacker's and defender's level
1183 */ 1154 */
1184 int level_diff = MIN (110, MAX (0, op->level - hitter->level)); 1155 int level_diff = MIN (110, MAX (0, op->level - hitter->level));
1185 1156
1186 /* First, only creatures/players with speed can be affected. 1157 /* First, only creatures/players with speed can be affected.
1187 * Second, just getting hit doesn't mean it always affects 1158 * Second, just getting hit doesn't mean it always affects
1188 * you. Third, you still get a saving through against the 1159 * you. Third, you still get a saving through against the
1189 * effect. 1160 * effect.
1190 */ 1161 */
1191 if (op->speed && 1162 if (op->speed &&
1192 (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) && 1163 (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) &&
1193 !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) && !did_make_save (op, level_diff, op->resist[attacknum] / 10)) 1164 !(rndm (0, (attacknum == ATNR_SLOW ? 6 : 3) - 1)) && !did_make_save (op, level_diff, op->resist[attacknum] / 10))
1194 { 1165 {
1195 1166
1196 /* Player has been hit by something */ 1167 /* Player has been hit by something */
1197 if (attacknum == ATNR_CONFUSION) 1168 if (attacknum == ATNR_CONFUSION)
1198 confuse_player (op, hitter, dam); 1169 confuse_player (op, hitter, dam);
1199 else if (attacknum == ATNR_POISON) 1170 else if (attacknum == ATNR_POISON)
1200 poison_player (op, hitter, dam); 1171 poison_player (op, hitter, dam);
1201 else if (attacknum == ATNR_SLOW) 1172 else if (attacknum == ATNR_SLOW)
1202 slow_player (op, hitter, dam); 1173 slow_player (op, hitter, dam);
1203 else if (attacknum == ATNR_PARALYZE) 1174 else if (attacknum == ATNR_PARALYZE)
1204 paralyze_player (op, hitter, dam); 1175 paralyze_player (op, hitter, dam);
1205 else if (attacknum == ATNR_FEAR) 1176 else if (attacknum == ATNR_FEAR)
1206 scare_creature (op, hitter); 1177 scare_creature (op, hitter);
1207 else if (attacknum == ATNR_CANCELLATION) 1178 else if (attacknum == ATNR_CANCELLATION)
1208 cancellation (op); 1179 cancellation (op);
1209 else if (attacknum == ATNR_DEPLETE) 1180 else if (attacknum == ATNR_DEPLETE)
1210 drain_stat (op); 1181 op->drain_stat ();
1211 else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR)) 1182 else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR))
1212 blind_player (op, hitter, dam); 1183 blind_player (op, hitter, dam);
1213 } 1184 }
1214 dam = 0; /* These are all effects and don't do real damage */ 1185 dam = 0; /* These are all effects and don't do real damage */
1215 } 1186 }
1216 break; 1187 break;
1217 case ATNR_ACID: 1188 case ATNR_ACID:
1218 { 1189 {
1219 int flag = 0; 1190 int flag = 0;
1220 1191
1221 /* Items only get corroded if you're not on a battleground and 1192 /* Items only get corroded if you're not on a battleground and
1222 * if your acid resistance is below 50%. */ 1193 * if your acid resistance is below 50%. */
1223 if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50)) 1194 if (!op_on_battleground (op, NULL, NULL) && (op->resist[ATNR_ACID] < 50))
1224 { 1195 {
1225 object *tmp; 1196 object *tmp;
1226 1197
1227 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1198 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
1228 { 1199 {
1229 if (tmp->invisible) 1200 if (tmp->invisible)
1230 continue; 1201 continue;
1231 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) 1202 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10))
1232 /* >= 10% acid res. on itmes will protect these */ 1203 /* >= 10% acid res. on itmes will protect these */
1233 continue; 1204 continue;
1234 if (!(tmp->material & M_IRON)) 1205 if (!(tmp->material & M_IRON))
1235 continue; 1206 continue;
1236 if (tmp->magic < -4) /* Let's stop at -5 */ 1207 if (tmp->magic < -4) /* Let's stop at -5 */
1237 continue; 1208 continue;
1238 if (tmp->type == RING || 1209 if (tmp->type == RING ||
1239 /* removed boots and gloves from exclusion list in 1210 /* removed boots and gloves from exclusion list in
1240 PR */ 1211 PR */
1241 tmp->type == GIRDLE || tmp->type == AMULET || tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1212 tmp->type == GIRDLE || tmp->type == AMULET || tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1242 continue; /* To avoid some strange effects */ 1213 continue; /* To avoid some strange effects */
1243 1214
1244 /* High damage acid has better chance of corroding 1215 /* High damage acid has better chance of corroding
1245 objects */ 1216 objects */
1246 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic) 1217 if (rndm (0, dam + 4) > random_roll (0, 39, op, PREFER_HIGH) + 2 * tmp->magic)
1247 { 1218 {
1248 if (op->type == PLAYER) 1219 if (op->type == PLAYER)
1249 /* Make this more visible */ 1220 /* Make this more visible */
1250 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, 1221 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op,
1251 "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp)); 1222 "The %s's acid corrodes your %s!", query_name (hitter), query_name (tmp));
1252 flag = 1; 1223 flag = 1;
1253 tmp->magic--; 1224 tmp->magic--;
1254 if (op->type == PLAYER) 1225 if (op->type == PLAYER)
1255 esrv_send_item (op, tmp); 1226 esrv_send_item (op, tmp);
1256 } 1227 }
1257 } 1228 }
1258 if (flag) 1229 if (flag)
1259 fix_player (op); /* Something was corroded */ 1230 op->update_stats (); /* Something was corroded */
1260 } 1231 }
1261 } 1232 }
1262 break; 1233 break;
1263 case ATNR_DRAIN: 1234 case ATNR_DRAIN:
1264 { 1235 {
1265 /* rate is the proportion of exp drained. High rate means 1236 /* rate is the proportion of exp drained. High rate means
1266 * not much is drained, low rate means a lot is drained. 1237 * not much is drained, low rate means a lot is drained.
1267 */ 1238 */
1268 int rate; 1239 int rate;
1269 1240
1270 if (op->resist[ATNR_DRAIN] >= 0) 1241 if (op->resist[ATNR_DRAIN] >= 0)
1271 rate = 400 + op->resist[ATNR_DRAIN] * 3; 1242 rate = 400 + op->resist[ATNR_DRAIN] * 3;
1272 else 1243 else
1273 rate = 400 * 100 / (100 - op->resist[ATNR_DRAIN]); 1244 rate = 400 * 100 / (100 - op->resist[ATNR_DRAIN]);
1274 1245
1275 if (op->stats.exp <= rate) 1246 if (op->stats.exp <= rate)
1276 { 1247 {
1277 if (op->type == GOLEM) 1248 if (op->type == GOLEM)
1278 dam = 999; /* Its force is "sucked" away. 8) */ 1249 dam = 999; /* Its force is "sucked" away. 8) */
1279 else 1250 else
1280 /* If we can't drain, lets try to do physical damage */ 1251 /* If we can't drain, lets try to do physical damage */
1281 dam = hit_player_attacktype (op, hitter, dam, ATNR_PHYSICAL, magic); 1252 dam = hit_player_attacktype (op, hitter, dam, ATNR_PHYSICAL, magic);
1282 } 1253 }
1283 else 1254 else
1284 { 1255 {
1285 /* Randomly give the hitter some hp */ 1256 /* Randomly give the hitter some hp */
1286 if (hitter->stats.hp < hitter->stats.maxhp && 1257 if (hitter->stats.hp < hitter->stats.maxhp &&
1287 (op->level > hitter->level) && random_roll (0, (op->level - hitter->level + 2), hitter, PREFER_HIGH) > 3) 1258 (op->level > hitter->level) && random_roll (0, (op->level - hitter->level + 2), hitter, PREFER_HIGH) > 3)
1288 hitter->stats.hp++; 1259 hitter->stats.hp++;
1289 1260
1290 /* Can't do drains on battleground spaces. 1261 /* Can't do drains on battleground spaces.
1291 * Move the wiz check up here - before, the hitter wouldn't gain exp 1262 * Move the wiz check up here - before, the hitter wouldn't gain exp
1292 * exp, but the wiz would still lose exp! If drainee is a wiz, 1263 * exp, but the wiz would still lose exp! If drainee is a wiz,
1293 * nothing happens. 1264 * nothing happens.
1294 * Try to credit the owner. We try to display player -> player drain 1265 * Try to credit the owner. We try to display player -> player drain
1295 * attacks, hence all the != PLAYER checks. 1266 * attacks, hence all the != PLAYER checks.
1296 */ 1267 */
1297 if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) 1268 if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ))
1298 { 1269 {
1299 object *owner = get_owner (hitter); 1270 object *owner = hitter->owner;
1300 1271
1301 if (owner && owner != hitter) 1272 if (owner && owner != hitter)
1302 { 1273 {
1303 if (op->type != PLAYER || owner->type != PLAYER) 1274 if (op->type != PLAYER || owner->type != PLAYER)
1304 change_exp (owner, op->stats.exp / (rate * 2), 1275 change_exp (owner, op->stats.exp / (rate * 2),
1305 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL); 1276 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL);
1306 } 1277 }
1307 else if (op->type != PLAYER || hitter->type != PLAYER) 1278 else if (op->type != PLAYER || hitter->type != PLAYER)
1308 { 1279 {
1309 change_exp (hitter, op->stats.exp / (rate * 2), 1280 change_exp (hitter, op->stats.exp / (rate * 2),
1310 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); 1281 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0);
1311 } 1282 }
1312 change_exp (op, -op->stats.exp / rate, NULL, 0); 1283 change_exp (op, -op->stats.exp / rate, NULL, 0);
1313 } 1284 }
1314 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure 1285 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure
1315 * drain attack, you won't know that you are actually sucking out EXP, 1286 * drain attack, you won't know that you are actually sucking out EXP,
1316 * as the messages will say you missed 1287 * as the messages will say you missed
1317 */ 1288 */
1318 } 1289 }
1319 } 1290 }
1320 break; 1291 break;
1321 case ATNR_TURN_UNDEAD: 1292 case ATNR_TURN_UNDEAD:
1322 { 1293 {
1323 if (QUERY_FLAG (op, FLAG_UNDEAD)) 1294 if (QUERY_FLAG (op, FLAG_UNDEAD))
1324 { 1295 {
1325 object *owner = hitter->owner ? (object *)hitter->owner : hitter; 1296 object *owner = hitter->owner ? (object *)hitter->owner : hitter;
1326 object *god = find_god (determine_god (owner)); 1297 object *god = find_god (determine_god (owner));
1327 int div = 1; 1298 int div = 1;
1328 1299
1329 /* if undead are not an enemy of your god, you turn them 1300 /* if undead are not an enemy of your god, you turn them
1330 * at half strength */ 1301 * at half strength */
1331 if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL) 1302 if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL)
1332 div = 2; 1303 div = 2;
1333 /* Give a bonus if you resist turn undead */ 1304 /* Give a bonus if you resist turn undead */
1334 if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100))) 1305 if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100)))
1335 scare_creature (op, owner); 1306 scare_creature (op, owner);
1336 } 1307 }
1337 else 1308 else
1338 dam = 0; /* don't damage non undead - should we damage 1309 dam = 0; /* don't damage non undead - should we damage
1339 undead? */ 1310 undead? */
1340 } 1311 }
1341 break; 1312 break;
1342 case ATNR_DEATH: 1313 case ATNR_DEATH:
1343 deathstrike_player (op, hitter, &dam); 1314 deathstrike_player (op, hitter, &dam);
1344 break; 1315 break;
1345 case ATNR_CHAOS: 1316 case ATNR_CHAOS:
1346 LOG (llevError, "%s was hit by %s with non-specific chaos.\n", query_name (op), query_name (hitter)); 1317 LOG (llevError, "%s was hit by %s with non-specific chaos.\n", op->debug_desc (), hitter->debug_desc2 ());
1347 dam = 0; 1318 dam = 0;
1348 break; 1319 break;
1349 case ATNR_COUNTERSPELL: 1320 case ATNR_COUNTERSPELL:
1350 LOG (llevError, "%s was hit by %s with counterspell attack.\n", query_name (op), query_name (hitter)); 1321 LOG (llevError, "%s was hit by %s with counterspell attack.\n", op->debug_desc (), hitter->debug_desc2 ());
1351 dam = 0; 1322 dam = 0;
1352 /* This should never happen. Counterspell is handled 1323 /* This should never happen. Counterspell is handled
1353 * seperately and filtered out. If this does happen, 1324 * seperately and filtered out. If this does happen,
1354 * Counterspell has no effect on anything but spells, so it 1325 * Counterspell has no effect on anything but spells, so it
1355 * does no damage. */ 1326 * does no damage. */
1356 break; 1327 break;
1357 case ATNR_HOLYWORD: 1328 case ATNR_HOLYWORD:
1358 { 1329 {
1359 /* This has already been handled by hit_player, 1330 /* This has already been handled by hit_player,
1360 * no need to check twice -- DAMN */ 1331 * no need to check twice -- DAMN */
1361 object *owner = hitter->owner ? (object *)hitter->owner : hitter; 1332 object *owner = hitter->owner ? (object *)hitter->owner : hitter;
1362 1333
1363 /* As with turn undead above, give a bonus on the saving throw */ 1334 /* As with turn undead above, give a bonus on the saving throw */
1364 if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis]) 1335 if ((op->level + (op->resist[ATNR_HOLYWORD] / 100)) < owner->level + turn_bonus[owner->stats.Wis])
1365 scare_creature (op, owner); 1336 scare_creature (op, owner);
1366 } 1337 }
1367 break; 1338 break;
1368 case ATNR_LIFE_STEALING: 1339 case ATNR_LIFE_STEALING:
1369 { 1340 {
1370 int new_hp; 1341 int new_hp;
1371 1342
1372 /* this is replacement to drain for players, instead of taking 1343 /* this is replacement to drain for players, instead of taking
1373 * exp it takes hp. It is geared for players, probably not 1344 * exp it takes hp. It is geared for players, probably not
1374 * much use giving it to monsters 1345 * much use giving it to monsters
1375 * 1346 *
1376 * life stealing doesn't do a lot of damage, but it gives the 1347 * life stealing doesn't do a lot of damage, but it gives the
1377 * damage it does do to the player. Given that, 1348 * damage it does do to the player. Given that,
1378 * it only does 1/10'th normal damage (hence the divide by 1349 * it only does 1/10'th normal damage (hence the divide by
1379 * 1000). 1350 * 1000).
1380 */ 1351 */
1381 /* You can't steal life from something undead */ 1352 /* You can't steal life from something undead */
1382 if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD))) 1353 if ((op->type == GOLEM) || (QUERY_FLAG (op, FLAG_UNDEAD)))
1383 return 0; 1354 return 0;
1384 /* If drain protection is higher than life stealing, use that */ 1355 /* If drain protection is higher than life stealing, use that */
1385 if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING]) 1356 if (op->resist[ATNR_DRAIN] >= op->resist[ATNR_LIFE_STEALING])
1386 dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000; 1357 dam = (dam * (100 - op->resist[ATNR_DRAIN])) / 3000;
1387 else 1358 else
1388 dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000; 1359 dam = (dam * (100 - op->resist[ATNR_LIFE_STEALING])) / 3000;
1389 /* You die at -1 hp, not zero. */ 1360 /* You die at -1 hp, not zero. */
1390 if (dam > (op->stats.hp + 1)) 1361 if (dam > (op->stats.hp + 1))
1391 dam = op->stats.hp + 1; 1362 dam = op->stats.hp + 1;
1392 new_hp = hitter->stats.hp + dam; 1363 new_hp = hitter->stats.hp + dam;
1393 if (new_hp > hitter->stats.maxhp) 1364 if (new_hp > hitter->stats.maxhp)
1394 new_hp = hitter->stats.maxhp; 1365 new_hp = hitter->stats.maxhp;
1395 if (new_hp > hitter->stats.hp) 1366 if (new_hp > hitter->stats.hp)
1396 hitter->stats.hp = new_hp; 1367 hitter->stats.hp = new_hp;
1397 } 1368 }
1398 } 1369 }
1370
1399 return dam; 1371 return dam;
1400} 1372}
1401
1402 1373
1403/* GROS: This code comes from hit_player. It has been made external to 1374/* GROS: This code comes from hit_player. It has been made external to
1404 * allow script procedures to "kill" objects in a combat-like fashion. 1375 * allow script procedures to "kill" objects in a combat-like fashion.
1405 * It was initially used by (kill-object) developed for the Collector's 1376 * It was initially used by (kill-object) developed for the Collector's
1406 * Sword. Note that nothing has been changed from the original version 1377 * Sword. Note that nothing has been changed from the original version
1441 if (QUERY_FLAG (op, FLAG_BLOCKSVIEW)) 1412 if (QUERY_FLAG (op, FLAG_BLOCKSVIEW))
1442 update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */ 1413 update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */
1443 1414
1444 if (op->type == DOOR) 1415 if (op->type == DOOR)
1445 { 1416 {
1446 op->speed = 0.1; 1417 op->set_speed (0.1);
1447 update_ob_speed (op);
1448 op->speed_left = -0.05; 1418 op->speed_left = -0.05;
1449 return maxdam; 1419 return maxdam;
1450 } 1420 }
1451 1421
1452 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) 1422 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER)
1453 { 1423 {
1454 remove_friendly_object (op); 1424 remove_friendly_object (op);
1455 1425
1456 if (get_owner (op) && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op) 1426 if (op->owner && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op)
1457 op->owner->contr->ranges[range_golem] = 0; 1427 op->owner->contr->ranges[range_golem] = 0;
1458 1428
1459 remove_ob (op); 1429 op->destroy ();
1460 free_object (op);
1461 return maxdam; 1430 return maxdam;
1462 } 1431 }
1463 1432
1464 /* Now lets start dealing with experience we get for killing something */ 1433 /* Now lets start dealing with experience we get for killing something */
1465 1434
1466 owner = get_owner (hitter); 1435 owner = hitter->owner;
1467 if (!owner) 1436 if (!owner)
1468 owner = hitter; 1437 owner = hitter;
1469 1438
1470 /* is the victim (op) standing on battleground? */ 1439 /* is the victim (op) standing on battleground? */
1471 if (op_on_battleground (op, NULL, NULL)) 1440 if (op_on_battleground (op, NULL, NULL))
1492 char buf[256]; 1461 char buf[256];
1493 1462
1494 tmv = localtime (&t); 1463 tmv = localtime (&t);
1495 strftime (buf, 256, "%a %b %d %H:%M:%S %Y", tmv); 1464 strftime (buf, 256, "%a %b %d %H:%M:%S %Y", tmv);
1496 1465
1497 LOG (llevInfo, "%s PLAYER_KILL_PLAYER: %s (%s) killed %s\n", buf, &owner->name, owner->contr->socket.host, query_name (op)); 1466 LOG (llevInfo, "%s PLAYER_KILL_PLAYER: %s (%s) killed %s\n", buf, &owner->name, owner->contr->ns->host, query_name (op));
1498 } 1467 }
1499 1468
1500 /* try to filter some things out - basically, if you are 1469 /* try to filter some things out - basically, if you are
1501 * killing a level 1 creature and your level 20, you 1470 * killing a level 1 creature and your level 20, you
1502 * probably don't want to see that. 1471 * probably don't want to see that.
1520 * player that the object belonged to - so if you killed another player 1489 * player that the object belonged to - so if you killed another player
1521 * with spells, pets, whatever, there was no penalty. 1490 * with spells, pets, whatever, there was no penalty.
1522 * Changed to make luck penalty configurable in settings. 1491 * Changed to make luck penalty configurable in settings.
1523 */ 1492 */
1524 if (op->type == PLAYER && owner != op && !battleg) 1493 if (op->type == PLAYER && owner != op && !battleg)
1525 change_luck (owner, -settings.pk_luck_penalty); 1494 owner->change_luck (-settings.pk_luck_penalty);
1526 1495
1527 /* This code below deals with finding the appropriate skill 1496 /* This code below deals with finding the appropriate skill
1528 * to credit exp to. This is a bit problematic - we should 1497 * to credit exp to. This is a bit problematic - we should
1529 * probably never really have to look at current_weapon->skill 1498 * probably never really have to look at current_weapon->skill
1530 */ 1499 */
1617 { 1586 {
1618 int shares = 0, count = 0; 1587 int shares = 0, count = 0;
1619 player *pl; 1588 player *pl;
1620 partylist *party = owner->contr->party; 1589 partylist *party = owner->contr->party;
1621 1590
1622#ifdef PARTY_KILL_LOG
1623 add_kill_to_party (party, query_name (owner), query_name (op), exp); 1591 add_kill_to_party (party, query_name (owner), query_name (op), exp);
1624#endif 1592
1625 for (pl = first_player; pl != NULL; pl = pl->next) 1593 for_all_players (pl)
1626 if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner)) 1594 if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner))
1627 { 1595 {
1628 count++; 1596 count++;
1629 shares += (pl->ob->level + 4); 1597 shares += (pl->ob->level + 4);
1630 } 1598 }
1633 change_exp (owner, exp, skill, SK_EXP_TOTAL); 1601 change_exp (owner, exp, skill, SK_EXP_TOTAL);
1634 else 1602 else
1635 { 1603 {
1636 int share = exp / shares, given = 0, nexp; 1604 int share = exp / shares, given = 0, nexp;
1637 1605
1638 for (pl = first_player; pl != NULL; pl = pl->next) 1606 for_all_players (pl)
1639 if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner)) 1607 if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner))
1640 { 1608 {
1641 nexp = (pl->ob->level + 4) * share; 1609 nexp = (pl->ob->level + 4) * share;
1642 change_exp (pl->ob, nexp, skill, SK_EXP_TOTAL); 1610 change_exp (pl->ob, nexp, skill, SK_EXP_TOTAL);
1643 given += nexp; 1611 given += nexp;
1652 1620
1653 if (op->type != PLAYER) 1621 if (op->type != PLAYER)
1654 { 1622 {
1655 if (QUERY_FLAG (op, FLAG_FRIENDLY)) 1623 if (QUERY_FLAG (op, FLAG_FRIENDLY))
1656 { 1624 {
1657 object *owner1 = get_owner (op); 1625 object *owner1 = op->owner;
1658 1626
1659 if (owner1 && owner1->type == PLAYER) 1627 if (owner1 && owner1->type == PLAYER)
1660 { 1628 {
1661 play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); 1629 play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0);
1662 /* Maybe we should include the owner that killed this, maybe not */ 1630 /* Maybe we should include the owner that killed this, maybe not */
1664 } 1632 }
1665 1633
1666 remove_friendly_object (op); 1634 remove_friendly_object (op);
1667 } 1635 }
1668 1636
1669 remove_ob (op); 1637 op->destroy ();
1670 free_object (op);
1671 } 1638 }
1672 else 1639 else
1673 { 1640 {
1674 /* Player has been killed! */ 1641 /* Player has been killed! */
1675 if (owner->type == PLAYER) 1642 if (owner->type == PLAYER)
1705 return 0; 1672 return 0;
1706 1673
1707 if (hitter->type == PLAYER && hitter->contr->peaceful == 1) 1674 if (hitter->type == PLAYER && hitter->contr->peaceful == 1)
1708 return 1; 1675 return 1;
1709 1676
1710 if ((owner = get_owner (hitter)) != NULL) 1677 if ((owner = hitter->owner) != NULL)
1711 { 1678 {
1712 if (owner->type == PLAYER && owner->contr->peaceful == 1) 1679 if (owner->type == PLAYER && owner->contr->peaceful == 1)
1713 friendlyfire = 2; 1680 friendlyfire = 2;
1714 } 1681 }
1715 1682
1725 * is what is hitting the object, type is the attacktype, and 1692 * is what is hitting the object, type is the attacktype, and
1726 * full_hit is set if monster area does not matter. 1693 * full_hit is set if monster area does not matter.
1727 * dam is base damage - protections/vulnerabilities/slaying matches can 1694 * dam is base damage - protections/vulnerabilities/slaying matches can
1728 * modify it. 1695 * modify it.
1729 */ 1696 */
1730
1731 /* Oct 95 - altered the following slightly for MULTIPLE_GODS hack 1697/* Oct 95 - altered the following slightly for MULTIPLE_GODS hack
1732 * which needs new attacktype AT_HOLYWORD to work . b.t. */ 1698 * which needs new attacktype AT_HOLYWORD to work . b.t. */
1733
1734int 1699int
1735hit_player (object *op, int dam, object *hitter, int type, int full_hit) 1700hit_player (object *op, int dam, object *hitter, int type, int full_hit)
1736{ 1701{
1737 int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC); 1702 int maxdam = 0, ndam = 0, attacktype = 1, magic = (type & AT_MAGIC);
1738 int maxattacktype, attacknum; 1703 int maxattacktype, attacknum;
1749 return 0; 1714 return 0;
1750 1715
1751#ifdef PROHIBIT_PLAYERKILL 1716#ifdef PROHIBIT_PLAYERKILL
1752 if (op->type == PLAYER) 1717 if (op->type == PLAYER)
1753 { 1718 {
1754 object *owner = get_owner (hitter); 1719 object *owner = hitter->owner;
1755 1720
1756 if (!owner) 1721 if (!owner)
1757 owner = hitter; 1722 owner = hitter;
1758 1723
1759 if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner) 1724 if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner)
1787 1752
1788 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1753 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
1789 if (tmp->type == RUNE || tmp->type == TRAP) 1754 if (tmp->type == RUNE || tmp->type == TRAP)
1790 { 1755 {
1791 spring_trap (tmp, hitter); 1756 spring_trap (tmp, hitter);
1757
1792 if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) 1758 if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack))
1793 return 0; 1759 return 0;
1760
1794 break; 1761 break;
1795 } 1762 }
1796 } 1763 }
1797 1764
1798 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) 1765 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0)
1844 (hitter->title != NULL 1811 (hitter->title != NULL
1845 && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, undead_name) != NULL))) 1812 && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, undead_name) != NULL)))
1846 return 0; 1813 return 0;
1847 } 1814 }
1848 1815
1849 maxattacktype = type; /* initialize this to something */ 1816 maxattacktype = type; /* initialise this to something */
1850 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) 1817 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum)
1851 { 1818 {
1852 /* Magic isn't really a true attack type - it gets combined with other 1819 /* Magic isn't really a true attack type - it gets combined with other
1853 * attack types. As such, skip it over. However, if magic is 1820 * attack types. As such, skip it over. However, if magic is
1854 * the only attacktype in the group, then still attack with it 1821 * the only attacktype in the group, then still attack with it
1915 1882
1916#ifdef ATTACK_DEBUG 1883#ifdef ATTACK_DEBUG
1917 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); 1884 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam);
1918#endif 1885#endif
1919 1886
1920 if (get_owner (hitter)) 1887 if (hitter->owner)
1921 op->enemy = hitter->owner; 1888 op->enemy = hitter->owner;
1922 else if (QUERY_FLAG (hitter, FLAG_ALIVE)) 1889 else if (QUERY_FLAG (hitter, FLAG_ALIVE))
1923 op->enemy = hitter; 1890 op->enemy = hitter;
1924 1891
1925 if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) 1892 if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER)
1950 1917
1951 if (QUERY_FLAG (op, FLAG_TEAR_DOWN)) 1918 if (QUERY_FLAG (op, FLAG_TEAR_DOWN))
1952 { 1919 {
1953 if (maxdam) 1920 if (maxdam)
1954 tear_down_wall (op); 1921 tear_down_wall (op);
1922
1955 return maxdam; /* nothing more to do for wall */ 1923 return maxdam; /* nothing more to do for wall */
1956 } 1924 }
1957 1925
1958 /* See if the creature has been killed */ 1926 /* See if the creature has been killed */
1959 rtn_kill = kill_object (op, maxdam, hitter, type); 1927 rtn_kill = kill_object (op, maxdam, hitter, type);
1967 */ 1935 */
1968 if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) 1936 if (QUERY_FLAG (hitter, FLAG_ONE_HIT))
1969 { 1937 {
1970 if (QUERY_FLAG (hitter, FLAG_FRIENDLY)) 1938 if (QUERY_FLAG (hitter, FLAG_FRIENDLY))
1971 remove_friendly_object (hitter); 1939 remove_friendly_object (hitter);
1972 remove_ob (hitter); 1940
1973 free_object (hitter); 1941 hitter->destroy ();
1974 } 1942 }
1975 /* Lets handle creatures that are splitting now */ 1943 /* Lets handle creatures that are splitting now */
1976 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) 1944 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING))
1977 { 1945 {
1978 int i; 1946 int i;
1979 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); 1947 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY);
1980 int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); 1948 int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE);
1981 object *owner = get_owner (op); 1949 object *owner = op->owner;
1982 1950
1983 if (!op->other_arch) 1951 if (!op->other_arch)
1984 { 1952 {
1985 LOG (llevError, "SPLITTING without other_arch error.\n"); 1953 LOG (llevError, "SPLITTING without other_arch error.\n");
1986 return maxdam; 1954 return maxdam;
1987 } 1955 }
1956
1988 remove_ob (op); 1957 op->remove ();
1958
1989 for (i = 0; i < NROFNEWOBJS (op); i++) 1959 for (i = 0; i < NROFNEWOBJS (op); i++)
1990 { /* This doesn't handle op->more yet */ 1960 { /* This doesn't handle op->more yet */
1991 object *tmp = arch_to_object (op->other_arch); 1961 object *tmp = arch_to_object (op->other_arch);
1992 int j; 1962 int j;
1993 1963
1994 tmp->stats.hp = op->stats.hp; 1964 tmp->stats.hp = op->stats.hp;
1965
1995 if (friendly) 1966 if (friendly)
1996 { 1967 {
1997 SET_FLAG (tmp, FLAG_FRIENDLY);
1998 add_friendly_object (tmp); 1968 add_friendly_object (tmp);
1999 tmp->attack_movement = PETMOVE; 1969 tmp->attack_movement = PETMOVE;
1970
2000 if (owner != NULL) 1971 if (owner)
2001 set_owner (tmp, owner); 1972 tmp->set_owner (owner);
2002 } 1973 }
1974
2003 if (unaggressive) 1975 if (unaggressive)
2004 SET_FLAG (tmp, FLAG_UNAGGRESSIVE); 1976 SET_FLAG (tmp, FLAG_UNAGGRESSIVE);
1977
2005 j = find_first_free_spot (tmp, op->map, op->x, op->y); 1978 j = find_first_free_spot (tmp, op->map, op->x, op->y);
1979
2006 if (j == -1) /* No spot to put this monster */ 1980 if (j == -1) /* No spot to put this monster */
2007 free_object (tmp); 1981 tmp->destroy ();
2008 else 1982 else
2009 { 1983 {
2010 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; 1984 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j];
2011 insert_ob_in_map (tmp, op->map, NULL, 0); 1985 insert_ob_in_map (tmp, op->map, NULL, 0);
2012 } 1986 }
2013 } 1987 }
2014 if (friendly) 1988
2015 remove_friendly_object (op); 1989 op->destroy ();
2016 free_object (op);
2017 } 1990 }
2018 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) 1991 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10)
2019 { 1992 hitter->destroy ();
2020 remove_ob (hitter); 1993
2021 free_object (hitter);
2022 }
2023 return maxdam; 1994 return maxdam;
2024} 1995}
2025 1996
2026 1997
2027void 1998void
2048 if (QUERY_FLAG (hitter, FLAG_ALIVE)) 2019 if (QUERY_FLAG (hitter, FLAG_ALIVE))
2049 tmp->stats.dam += hitter->level / 2; 2020 tmp->stats.dam += hitter->level / 2;
2050 else 2021 else
2051 tmp->stats.dam = dam; 2022 tmp->stats.dam = dam;
2052 2023
2053 copy_owner (tmp, hitter); /* so we get credit for poisoning kills */ 2024 tmp->set_owner (hitter); /* so we get credit for poisoning kills */
2054 if (hitter->skill && hitter->skill != tmp->skill) 2025 if (hitter->skill && hitter->skill != tmp->skill)
2055 { 2026 {
2056 tmp->skill = hitter->skill; 2027 tmp->skill = hitter->skill;
2057 } 2028 }
2058 2029
2064 tmp->stats.Con = MAX (-(dam / 4 + 1), -10); 2035 tmp->stats.Con = MAX (-(dam / 4 + 1), -10);
2065 tmp->stats.Str = MAX (-(dam / 3 + 2), -10); 2036 tmp->stats.Str = MAX (-(dam / 3 + 2), -10);
2066 tmp->stats.Dex = MAX (-(dam / 6 + 1), -10); 2037 tmp->stats.Dex = MAX (-(dam / 6 + 1), -10);
2067 tmp->stats.Int = MAX (-dam / 7, -10); 2038 tmp->stats.Int = MAX (-dam / 7, -10);
2068 SET_FLAG (tmp, FLAG_APPLIED); 2039 SET_FLAG (tmp, FLAG_APPLIED);
2069 fix_player (op); 2040 op->update_stats ();
2070 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); 2041 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill.");
2071 } 2042 }
2072 if (hitter->type == PLAYER) 2043 if (hitter->type == PLAYER)
2073 new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); 2044 new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name);
2074 else if (get_owner (hitter) != NULL && hitter->owner->type == PLAYER) 2045 else if (hitter->owner != NULL && hitter->owner->type == PLAYER)
2075 new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); 2046 new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name);
2076 } 2047 }
2077 tmp->speed_left = 0; 2048 tmp->speed_left = 0;
2078 } 2049 }
2079 else 2050 else
2098 } 2069 }
2099 else 2070 else
2100 tmp->stats.food++; 2071 tmp->stats.food++;
2101 SET_FLAG (tmp, FLAG_APPLIED); 2072 SET_FLAG (tmp, FLAG_APPLIED);
2102 tmp->speed_left = 0; 2073 tmp->speed_left = 0;
2103 fix_player (op); 2074 op->update_stats ();
2104} 2075}
2105 2076
2106void 2077void
2107confuse_player (object *op, object *hitter, int dam) 2078confuse_player (object *op, object *hitter, int dam)
2108{ 2079{
2152 */ 2123 */
2153 tmp->speed = tmp->speed * (100.0 - (float) op->resist[ATNR_BLIND]) / 100; 2124 tmp->speed = tmp->speed * (100.0 - (float) op->resist[ATNR_BLIND]) / 100;
2154 2125
2155 tmp = insert_ob_in_ob (tmp, op); 2126 tmp = insert_ob_in_ob (tmp, op);
2156 change_abil (op, tmp); /* Mostly to display any messages */ 2127 change_abil (op, tmp); /* Mostly to display any messages */
2157 fix_player (op); /* This takes care of some other stuff */ 2128 op->update_stats (); /* This takes care of some other stuff */
2158 2129
2159 if (hitter->owner) 2130 if (hitter->owner)
2160 owner = get_owner (hitter); 2131 owner = hitter->owner;
2161 else 2132 else
2162 owner = hitter; 2133 owner = hitter;
2163 2134
2164 new_draw_info_format (NDI_UNIQUE, 0, owner, "Your attack blinds %s!", query_name (op)); 2135 new_draw_info_format (NDI_UNIQUE, 0, owner, "Your attack blinds %s!", query_name (op));
2165 } 2136 }
2311 } 2282 }
2312 2283
2313 /* aimed missiles use the owning object's sight */ 2284 /* aimed missiles use the owning object's sight */
2314 if (is_aimed_missile (hitter)) 2285 if (is_aimed_missile (hitter))
2315 { 2286 {
2316 if ((attacker = get_owner (hitter)) == NULL) 2287 if ((attacker = hitter->owner) == NULL)
2317 attacker = hitter; 2288 attacker = hitter;
2318 /* A player who saves but hasn't quit still could have objects 2289 /* A player who saves but hasn't quit still could have objects
2319 * owned by him - need to handle that case to avoid crashes. 2290 * owned by him - need to handle that case to avoid crashes.
2320 */ 2291 */
2321 if (QUERY_FLAG (attacker, FLAG_REMOVED)) 2292 if (QUERY_FLAG (attacker, FLAG_REMOVED))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines