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 | |
|
|
84 | int |
82 | int |
85 | did_make_save_item (object *op, int type, object *originator) |
83 | did_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); |
100 | if (mt == NULL) |
96 | if (mt == NULL) |
101 | return TRUE; |
97 | return TRUE; |
… | |
… | |
212 | } |
208 | } |
213 | else |
209 | else |
214 | { |
210 | { |
215 | if (op->env) |
211 | if (op->env) |
216 | { |
212 | { |
217 | object *tmp = is_player_inv (op->env); |
213 | object *tmp = op->in_player (); |
218 | |
214 | |
219 | if (tmp) |
215 | if (tmp) |
220 | esrv_del_item (tmp->contr, op->count); |
216 | esrv_del_item (tmp->contr, op->count); |
221 | } |
217 | } |
222 | |
218 | |
223 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
219 | op->destroy (); |
224 | remove_ob (op); |
|
|
225 | |
|
|
226 | free_object (op); |
|
|
227 | } |
220 | } |
228 | |
221 | |
229 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
222 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
230 | if (env) |
223 | if (env) |
231 | { |
224 | { |
… | |
… | |
264 | tmp->move_slow = 0; |
257 | tmp->move_slow = 0; |
265 | insert_ob_in_map (tmp, op->map, originator, 0); |
258 | insert_ob_in_map (tmp, op->map, originator, 0); |
266 | } |
259 | } |
267 | |
260 | |
268 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
261 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
269 | remove_ob (op); |
262 | op->remove (); |
270 | |
263 | |
271 | insert_ob_in_ob (op, tmp); |
264 | insert_ob_in_ob (op, tmp); |
272 | return; |
265 | return; |
273 | } |
266 | } |
274 | } |
267 | } |
… | |
… | |
281 | */ |
274 | */ |
282 | |
275 | |
283 | int |
276 | int |
284 | hit_map (object *op, int dir, int type, int full_hit) |
277 | hit_map (object *op, int dir, int type, int full_hit) |
285 | { |
278 | { |
286 | object *tmp, *next; |
|
|
287 | maptile *map; |
279 | maptile *map; |
288 | sint16 x, y; |
280 | sint16 x, y; |
289 | int retflag = 0; /* added this flag.. will return 1 if it hits a monster */ |
281 | int retflag = 0; /* added this flag.. will return 1 if it hits a monster */ |
290 | |
282 | |
291 | if (QUERY_FLAG (op, FLAG_FREED)) |
283 | if (QUERY_FLAG (op, FLAG_FREED)) |
… | |
… | |
342 | shuffle_attack (op, 1); /*1 flag tells it to change the face */ |
334 | shuffle_attack (op, 1); /*1 flag tells it to change the face */ |
343 | update_object (op, UP_OBJ_FACE); |
335 | update_object (op, UP_OBJ_FACE); |
344 | type &= ~AT_CHAOS; |
336 | type &= ~AT_CHAOS; |
345 | } |
337 | } |
346 | |
338 | |
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 |
339 | /* 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 |
340 | * simple way to find out short of copying all object references and |
355 | * tags into a temporary array before we start processing the first |
341 | * tags into a temporary array before we start processing the first |
356 | * object. That's why we just abort. |
342 | * object. That's why we just abort on destroy. |
357 | * |
343 | * |
358 | * This happens whenever attack spells (like fire) hit a pile |
344 | * This happens whenever attack spells (like fire) hit a pile |
359 | * of objects. This is not a bug - nor an error. The errormessage |
345 | * of objects. This is not a bug - nor an error. |
360 | * below was spamming the logs for absolutely no reason. |
346 | */ |
361 | */ |
347 | for (object *next = map->at (x, y).bot; next && !next->destroyed (); ) |
362 | /* LOG (llevDebug, "hit_map(): next object destroyed\n"); */ |
348 | { |
363 | break; |
|
|
364 | } |
|
|
365 | |
|
|
366 | tmp = next; |
349 | object *tmp = next; |
367 | next = tmp->above; |
350 | next = tmp->above; |
368 | |
|
|
369 | if (tmp->destroyed ()) |
|
|
370 | { |
|
|
371 | LOG (llevError, "BUG: hit_map(): found freed object\n"); |
|
|
372 | break; |
|
|
373 | } |
|
|
374 | |
351 | |
375 | /* Something could have happened to 'tmp' while 'tmp->below' was processed. |
352 | /* Something could have happened to 'tmp' while 'tmp->below' was processed. |
376 | * For example, 'tmp' was put in an icecube. |
353 | * For example, 'tmp' was put in an icecube. |
377 | * This is one of the few cases where on_same_map should not be used. |
354 | * This is one of the few cases where on_same_map should not be used. |
378 | */ |
355 | */ |
… | |
… | |
384 | hit_player (tmp, op->stats.dam, op, type, full_hit); |
361 | hit_player (tmp, op->stats.dam, op, type, full_hit); |
385 | retflag |= 1; |
362 | retflag |= 1; |
386 | if (op->destroyed ()) |
363 | if (op->destroyed ()) |
387 | break; |
364 | break; |
388 | } |
365 | } |
389 | |
|
|
390 | /* Here we are potentially destroying an object. If the object has |
366 | /* 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 |
367 | * 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 |
368 | * that weak walls have is_alive set, which prevent objects from |
393 | * passing over/through them. We don't care what type of movement |
369 | * 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 |
370 | * the wall blocks - if it blocks any type of movement, can't be |
395 | * destroyed right now. |
371 | * destroyed right now. |
396 | */ |
372 | */ |
397 | else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block) |
373 | else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block) |
398 | { |
374 | { |
399 | save_throw_object (tmp, type, op); |
375 | save_throw_object (tmp, type, op); |
|
|
376 | |
400 | if (op->destroyed ()) |
377 | if (op->destroyed ()) |
401 | break; |
378 | break; |
402 | } |
379 | } |
403 | } |
380 | } |
404 | |
381 | |
… | |
… | |
435 | sprintf (buf1, "missed %s", &op->name); |
412 | sprintf (buf1, "missed %s", &op->name); |
436 | sprintf (buf2, " misses"); |
413 | sprintf (buf2, " misses"); |
437 | found++; |
414 | found++; |
438 | } |
415 | } |
439 | else if ((hitter->type == DISEASE || hitter->type == SYMPTOM || |
416 | else if ((hitter->type == DISEASE || hitter->type == SYMPTOM || |
440 | hitter->type == POISONING || (type & AT_POISON && IS_LIVE (op))) && !found) |
417 | hitter->type == POISONING || (type & AT_POISON && op->is_alive ())) && !found) |
441 | { |
418 | { |
442 | for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_SUFFER][i].level != -1; i++) |
419 | 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) |
420 | if (dam < attack_mess[ATM_SUFFER][i].level || attack_mess[ATM_SUFFER][i + 1].level == -1) |
444 | { |
421 | { |
445 | sprintf (buf1, "%s %s%s", attack_mess[ATM_SUFFER][i].buf1, &op->name, attack_mess[ATM_SUFFER][i].buf2); |
422 | 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); |
434 | strcpy (buf2, attack_mess[ATM_DOOR][i].buf3); |
458 | found++; |
435 | found++; |
459 | break; |
436 | break; |
460 | } |
437 | } |
461 | } |
438 | } |
462 | else if (hitter->type == PLAYER && IS_LIVE (op)) |
439 | else if (hitter->type == PLAYER && op->is_alive ()) |
463 | { |
440 | { |
464 | if (USING_SKILL (hitter, SK_KARATE)) |
441 | if (USING_SKILL (hitter, SK_KARATE)) |
465 | { |
442 | { |
466 | for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_KARATE][i].level != -1; i++) |
443 | 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) |
444 | if (dam < attack_mess[ATM_KARATE][i].level || attack_mess[ATM_KARATE][i + 1].level == -1) |
… | |
… | |
493 | found++; |
470 | found++; |
494 | break; |
471 | break; |
495 | } |
472 | } |
496 | } |
473 | } |
497 | } |
474 | } |
|
|
475 | |
498 | if (found) |
476 | if (found) |
499 | { |
477 | { |
500 | /* done */ |
478 | /* done */ |
501 | } |
479 | } |
502 | else if (IS_ARROW (hitter) && (type == AT_PHYSICAL || type == AT_MAGIC)) |
480 | else if (hitter->is_arrow () && (type == AT_PHYSICAL || type == AT_MAGIC)) |
503 | { |
481 | { |
504 | sprintf (buf1, "hit"); /* just in case */ |
482 | sprintf (buf1, "hit"); /* just in case */ |
505 | for (i = 0; i < MAXATTACKMESS; i++) |
483 | for (i = 0; i < MAXATTACKMESS; i++) |
506 | if (dam < attack_mess[ATM_ARROW][i].level || attack_mess[ATM_ARROW][i + 1].level == -1) |
484 | if (dam < attack_mess[ATM_ARROW][i].level || attack_mess[ATM_ARROW][i + 1].level == -1) |
507 | { |
485 | { |
508 | strcpy (buf2, attack_mess[ATM_ARROW][i].buf3); |
486 | strcpy (buf2, attack_mess[ATM_ARROW][i].buf3); |
509 | found++; |
487 | found++; |
510 | break; |
488 | break; |
511 | } |
489 | } |
512 | } |
490 | } |
513 | else if (type & AT_DRAIN && IS_LIVE (op)) |
491 | else if (type & AT_DRAIN && op->is_alive ()) |
514 | { |
492 | { |
515 | /* drain is first, because some items have multiple attypes */ |
493 | /* drain is first, because some items have multiple attypes */ |
516 | for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_DRAIN][i].level != -1; i++) |
494 | 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) |
495 | if (dam < attack_mess[ATM_DRAIN][i].level || attack_mess[ATM_DRAIN][i + 1].level == -1) |
518 | { |
496 | { |
… | |
… | |
520 | strcpy (buf2, attack_mess[ATM_DRAIN][i].buf3); |
498 | strcpy (buf2, attack_mess[ATM_DRAIN][i].buf3); |
521 | found++; |
499 | found++; |
522 | break; |
500 | break; |
523 | } |
501 | } |
524 | } |
502 | } |
525 | else if (type & AT_ELECTRICITY && IS_LIVE (op)) |
503 | else if (type & AT_ELECTRICITY && op->is_alive ()) |
526 | { |
504 | { |
527 | for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_ELEC][i].level != -1; i++) |
505 | 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) |
506 | if (dam < attack_mess[ATM_ELEC][i].level || attack_mess[ATM_ELEC][i + 1].level == -1) |
529 | { |
507 | { |
530 | sprintf (buf1, "%s %s%s", attack_mess[ATM_ELEC][i].buf1, &op->name, attack_mess[ATM_ELEC][i].buf2); |
508 | 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); |
509 | strcpy (buf2, attack_mess[ATM_ELEC][i].buf3); |
532 | found++; |
510 | found++; |
533 | break; |
511 | break; |
534 | } |
512 | } |
535 | } |
513 | } |
536 | else if (type & AT_COLD && IS_LIVE (op)) |
514 | else if (type & AT_COLD && op->is_alive ()) |
537 | { |
515 | { |
538 | for (i = 0; i < MAXATTACKMESS && attack_mess[ATM_COLD][i].level != -1; i++) |
516 | 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) |
517 | if (dam < attack_mess[ATM_COLD][i].level || attack_mess[ATM_COLD][i + 1].level == -1) |
540 | { |
518 | { |
541 | sprintf (buf1, "%s %s%s", attack_mess[ATM_COLD][i].buf1, &op->name, attack_mess[ATM_COLD][i].buf2); |
519 | sprintf (buf1, "%s %s%s", attack_mess[ATM_COLD][i].buf1, &op->name, attack_mess[ATM_COLD][i].buf2); |
… | |
… | |
618 | strcpy (buf1, "hit"); |
596 | strcpy (buf1, "hit"); |
619 | strcpy (buf2, " hits"); |
597 | strcpy (buf2, " hits"); |
620 | } |
598 | } |
621 | |
599 | |
622 | /* bail out if a monster is casting spells */ |
600 | /* bail out if a monster is casting spells */ |
623 | if (!(hitter->type == PLAYER || (get_owner (hitter) != NULL && hitter->owner->type == PLAYER))) |
601 | if (!(hitter->type == PLAYER || (hitter->owner != NULL && hitter->owner->type == PLAYER))) |
624 | return; |
602 | return; |
625 | |
603 | |
626 | /* scale down magic considerably. */ |
604 | /* scale down magic considerably. */ |
627 | if (type & AT_MAGIC && rndm (0, 5)) |
605 | if (type & AT_MAGIC && rndm (0, 5)) |
628 | return; |
606 | return; |
629 | |
607 | |
630 | /* Did a player hurt another player? Inform both! */ |
608 | /* Did a player hurt another player? Inform both! */ |
631 | if (op->type == PLAYER && (get_owner (hitter) == NULL ? hitter->type : hitter->owner->type) == PLAYER) |
609 | if (op->type == PLAYER && (hitter->owner == NULL ? hitter->type : hitter->owner->type) == PLAYER) |
632 | { |
610 | { |
633 | if (get_owner (hitter) != NULL) |
611 | if (hitter->owner != NULL) |
634 | sprintf (buf, "%s's %s%s you.", &hitter->owner->name, &hitter->name, buf2); |
612 | sprintf (buf, "%s's %s%s you.", &hitter->owner->name, &hitter->name, buf2); |
635 | else |
613 | else |
636 | { |
614 | { |
637 | sprintf (buf, "%s%s you.", &hitter->name, buf2); |
615 | sprintf (buf, "%s%s you.", &hitter->name, buf2); |
638 | if (dam != 0) |
616 | if (dam != 0) |
… | |
… | |
660 | else |
638 | else |
661 | play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS3, 0, 0); |
639 | play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS3, 0, 0); |
662 | } |
640 | } |
663 | new_draw_info (NDI_BLACK, 0, hitter, buf); |
641 | new_draw_info (NDI_BLACK, 0, hitter, buf); |
664 | } |
642 | } |
665 | else if (get_owner (hitter) != NULL && hitter->owner->type == PLAYER) |
643 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
666 | { |
644 | { |
667 | /* look for stacked spells and start reducing the message chances */ |
645 | /* 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)) |
646 | if (hitter->type == SPELL_EFFECT && (hitter->subtype == SP_EXPLOSION || hitter->subtype == SP_BULLET || hitter->subtype == SP_CONE)) |
669 | { |
647 | { |
670 | i = 4; |
648 | i = 4; |
671 | map = hitter->map; |
649 | map = hitter->map; |
672 | if (out_of_map (map, hitter->x, hitter->y)) |
650 | if (out_of_map (map, hitter->x, hitter->y)) |
673 | return; |
651 | return; |
674 | next = get_map_ob (map, hitter->x, hitter->y); |
652 | next = GET_MAP_OB (map, hitter->x, hitter->y); |
675 | if (next) |
653 | if (next) |
676 | while (next) |
654 | while (next) |
677 | { |
655 | { |
678 | if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) |
656 | if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) |
679 | i *= 3; |
657 | i *= 3; |
… | |
… | |
769 | * which then gets here again. By decreasing the speed before |
747 | * which then gets here again. By decreasing the speed before |
770 | * we call process_object, the 'if' statement above will fail. |
748 | * we call process_object, the 'if' statement above will fail. |
771 | */ |
749 | */ |
772 | op->speed_left--; |
750 | op->speed_left--; |
773 | process_object (op); |
751 | process_object (op); |
|
|
752 | |
774 | if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack)) |
753 | if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack)) |
775 | goto error; |
754 | goto error; |
776 | } |
755 | } |
777 | |
756 | |
778 | op_name = op->name; |
757 | op_name = op->name; |
… | |
… | |
813 | if (QUERY_FLAG (op, FLAG_SLEEP)) |
792 | if (QUERY_FLAG (op, FLAG_SLEEP)) |
814 | CLEAR_FLAG (op, FLAG_SLEEP); |
793 | CLEAR_FLAG (op, FLAG_SLEEP); |
815 | |
794 | |
816 | /* If the victim can't see the attacker, it may alert others |
795 | /* If the victim can't see the attacker, it may alert others |
817 | * for help. */ |
796 | * for help. */ |
818 | if (op->type != PLAYER && !can_see_enemy (op, hitter) && !get_owner (op) && rndm (0, op->stats.Int)) |
797 | if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int)) |
819 | npc_call_help (op); |
798 | npc_call_help (op); |
820 | |
799 | |
821 | /* if you were hidden and hit by a creature, you are discovered */ |
800 | /* if you were hidden and hit by a creature, you are discovered */ |
822 | if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) |
801 | if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) |
823 | { |
802 | { |
… | |
… | |
830 | * when they hit the victim. For things like thrown daggers, |
809 | * when they hit the victim. For things like thrown daggers, |
831 | * this sets 'hitter' to the actual dagger, and not the |
810 | * this sets 'hitter' to the actual dagger, and not the |
832 | * wrapper object. |
811 | * wrapper object. |
833 | */ |
812 | */ |
834 | thrown_item_effect (hitter, op); |
813 | thrown_item_effect (hitter, op); |
|
|
814 | |
835 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |
815 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |
836 | goto leave; |
816 | goto leave; |
837 | } |
817 | } |
838 | |
818 | |
839 | /* Need to do at least 1 damage, otherwise there is no point |
819 | /* Need to do at least 1 damage, otherwise there is no point |
… | |
… | |
906 | if (op->weight <= 5000 && tmp->stats.hp >= 0) |
886 | if (op->weight <= 5000 && tmp->stats.hp >= 0) |
907 | { |
887 | { |
908 | if (tmp->head != NULL) |
888 | if (tmp->head != NULL) |
909 | tmp = tmp->head; |
889 | tmp = tmp->head; |
910 | |
890 | |
911 | remove_ob (op); |
891 | op->remove (); |
912 | op = insert_ob_in_ob (op, tmp); |
892 | op = insert_ob_in_ob (op, tmp); |
913 | |
893 | |
914 | if (tmp->type == PLAYER) |
894 | if (tmp->type == PLAYER) |
915 | esrv_send_item (tmp, op); |
895 | esrv_send_item (tmp, op); |
916 | |
896 | |
… | |
… | |
935 | /* Disassemble missile */ |
915 | /* Disassemble missile */ |
936 | if (op->inv) |
916 | if (op->inv) |
937 | { |
917 | { |
938 | container = op; |
918 | container = op; |
939 | hitter = op->inv; |
919 | hitter = op->inv; |
940 | remove_ob (hitter); |
920 | hitter->remove (); |
941 | insert_ob_in_map (hitter, container->map, hitter, INS_NO_MERGE | INS_NO_WALK_ON); |
921 | 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 |
922 | /* 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 |
923 | * 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 |
924 | * removed at the end of this function must be able to deal with empty |
945 | * THROWN_OBJs. */ |
925 | * THROWN_OBJs. */ |
… | |
… | |
961 | */ |
941 | */ |
962 | if (hitter->destroyed () || hitter->env != NULL) |
942 | if (hitter->destroyed () || hitter->env != NULL) |
963 | { |
943 | { |
964 | if (container) |
944 | if (container) |
965 | { |
945 | { |
966 | remove_ob (container); |
946 | container->remove (); |
967 | free_object (container); |
947 | container->destroy (); |
968 | } |
948 | } |
969 | |
949 | |
970 | return 0; |
950 | return 0; |
971 | } |
951 | } |
972 | |
952 | |
… | |
… | |
982 | hitter = fix_stopped_arrow (hitter); |
962 | hitter = fix_stopped_arrow (hitter); |
983 | if (!hitter) |
963 | if (!hitter) |
984 | return 0; |
964 | return 0; |
985 | } |
965 | } |
986 | else |
966 | else |
987 | { |
967 | container->destroy (); |
988 | remove_ob (container); |
|
|
989 | free_object (container); |
|
|
990 | } |
|
|
991 | |
968 | |
992 | /* Try to stick arrow into victim */ |
969 | /* Try to stick arrow into victim */ |
993 | if (!victim->destroyed () && stick_arrow (hitter, victim)) |
970 | if (!victim->destroyed () && stick_arrow (hitter, victim)) |
994 | return 0; |
971 | return 0; |
995 | |
972 | |
… | |
… | |
1000 | * can fly over but not otherwise move over. What is the correct |
977 | * can fly over but not otherwise move over. What is the correct |
1001 | * way to handle those otherwise? |
978 | * way to handle those otherwise? |
1002 | */ |
979 | */ |
1003 | if (victim->x != hitter->x || victim->y != hitter->y) |
980 | if (victim->x != hitter->x || victim->y != hitter->y) |
1004 | { |
981 | { |
1005 | remove_ob (hitter); |
982 | hitter->remove (); |
1006 | hitter->x = victim->x; |
983 | hitter->x = victim->x; |
1007 | hitter->y = victim->y; |
984 | hitter->y = victim->y; |
1008 | insert_ob_in_map (hitter, victim->map, hitter, 0); |
985 | insert_ob_in_map (hitter, victim->map, hitter, 0); |
1009 | } |
986 | } |
1010 | else |
987 | else |
… | |
… | |
1018 | op->speed -= 1.0; |
995 | op->speed -= 1.0; |
1019 | |
996 | |
1020 | /* Missile missed victim - reassemble missile */ |
997 | /* Missile missed victim - reassemble missile */ |
1021 | if (container) |
998 | if (container) |
1022 | { |
999 | { |
1023 | remove_ob (hitter); |
1000 | hitter->remove (); |
1024 | insert_ob_in_ob (hitter, container); |
1001 | insert_ob_in_ob (hitter, container); |
1025 | } |
1002 | } |
1026 | |
1003 | |
1027 | return op; |
1004 | return op; |
1028 | } |
1005 | } |
… | |
… | |
1040 | } |
1017 | } |
1041 | else if (!GET_ANIM_ID (op)) |
1018 | else if (!GET_ANIM_ID (op)) |
1042 | { |
1019 | { |
1043 | /* Object has been called - no animations, so remove it */ |
1020 | /* Object has been called - no animations, so remove it */ |
1044 | if (op->stats.hp < 0) |
1021 | if (op->stats.hp < 0) |
|
|
1022 | op->destroy (); |
1045 | { |
1023 | |
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 */ |
1024 | return; /* no animations, so nothing more to do */ |
1052 | } |
1025 | } |
|
|
1026 | |
1053 | perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; |
1027 | perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; |
|
|
1028 | |
1054 | if (perc >= (int) NUM_ANIMATIONS (op)) |
1029 | if (perc >= (int) NUM_ANIMATIONS (op)) |
1055 | perc = NUM_ANIMATIONS (op) - 1; |
1030 | perc = NUM_ANIMATIONS (op) - 1; |
1056 | else if (perc < 1) |
1031 | else if (perc < 1) |
1057 | perc = 1; |
1032 | perc = 1; |
|
|
1033 | |
1058 | SET_ANIMATION (op, perc); |
1034 | SET_ANIMATION (op, perc); |
1059 | update_object (op, UP_OBJ_FACE); |
1035 | update_object (op, UP_OBJ_FACE); |
|
|
1036 | |
1060 | if (perc == NUM_ANIMATIONS (op) - 1) |
1037 | if (perc == NUM_ANIMATIONS (op) - 1) |
1061 | { /* Reached the last animation */ |
1038 | { /* Reached the last animation */ |
1062 | if (op->face == blank_face) |
1039 | if (op->face == blank_face) |
1063 | { |
|
|
1064 | /* If the last face is blank, remove the ob */ |
1040 | /* If the last face is blank, remove the ob */ |
1065 | remove_ob (op); /* Should update LOS */ |
1041 | 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 |
1042 | else |
1073 | { /* The last face was not blank, leave an image */ |
1043 | { /* The last face was not blank, leave an image */ |
1074 | CLEAR_FLAG (op, FLAG_BLOCKSVIEW); |
1044 | CLEAR_FLAG (op, FLAG_BLOCKSVIEW); |
1075 | update_all_los (op->map, op->x, op->y); |
1045 | update_all_los (op->map, op->x, op->y); |
1076 | op->move_block = 0; |
1046 | op->move_block = 0; |
… | |
… | |
1080 | } |
1050 | } |
1081 | |
1051 | |
1082 | void |
1052 | void |
1083 | scare_creature (object *target, object *hitter) |
1053 | scare_creature (object *target, object *hitter) |
1084 | { |
1054 | { |
1085 | object *owner = get_owner (hitter); |
1055 | object *owner = hitter->owner; |
1086 | |
1056 | |
1087 | if (!owner) |
1057 | if (!owner) |
1088 | owner = hitter; |
1058 | owner = hitter; |
1089 | |
1059 | |
1090 | SET_FLAG (target, FLAG_SCARED); |
1060 | SET_FLAG (target, FLAG_SCARED); |
… | |
… | |
1205 | else if (attacknum == ATNR_FEAR) |
1175 | else if (attacknum == ATNR_FEAR) |
1206 | scare_creature (op, hitter); |
1176 | scare_creature (op, hitter); |
1207 | else if (attacknum == ATNR_CANCELLATION) |
1177 | else if (attacknum == ATNR_CANCELLATION) |
1208 | cancellation (op); |
1178 | cancellation (op); |
1209 | else if (attacknum == ATNR_DEPLETE) |
1179 | else if (attacknum == ATNR_DEPLETE) |
1210 | drain_stat (op); |
1180 | op->drain_stat (); |
1211 | else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR)) |
1181 | else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR)) |
1212 | blind_player (op, hitter, dam); |
1182 | blind_player (op, hitter, dam); |
1213 | } |
1183 | } |
1214 | dam = 0; /* These are all effects and don't do real damage */ |
1184 | dam = 0; /* These are all effects and don't do real damage */ |
1215 | } |
1185 | } |
… | |
… | |
1254 | if (op->type == PLAYER) |
1224 | if (op->type == PLAYER) |
1255 | esrv_send_item (op, tmp); |
1225 | esrv_send_item (op, tmp); |
1256 | } |
1226 | } |
1257 | } |
1227 | } |
1258 | if (flag) |
1228 | if (flag) |
1259 | fix_player (op); /* Something was corroded */ |
1229 | op->update_stats (); /* Something was corroded */ |
1260 | } |
1230 | } |
1261 | } |
1231 | } |
1262 | break; |
1232 | break; |
1263 | case ATNR_DRAIN: |
1233 | case ATNR_DRAIN: |
1264 | { |
1234 | { |
… | |
… | |
1294 | * Try to credit the owner. We try to display player -> player drain |
1264 | * Try to credit the owner. We try to display player -> player drain |
1295 | * attacks, hence all the != PLAYER checks. |
1265 | * attacks, hence all the != PLAYER checks. |
1296 | */ |
1266 | */ |
1297 | if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1267 | if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1298 | { |
1268 | { |
1299 | object *owner = get_owner (hitter); |
1269 | object *owner = hitter->owner; |
1300 | |
1270 | |
1301 | if (owner && owner != hitter) |
1271 | if (owner && owner != hitter) |
1302 | { |
1272 | { |
1303 | if (op->type != PLAYER || owner->type != PLAYER) |
1273 | if (op->type != PLAYER || owner->type != PLAYER) |
1304 | change_exp (owner, op->stats.exp / (rate * 2), |
1274 | change_exp (owner, op->stats.exp / (rate * 2), |
… | |
… | |
1441 | if (QUERY_FLAG (op, FLAG_BLOCKSVIEW)) |
1411 | if (QUERY_FLAG (op, FLAG_BLOCKSVIEW)) |
1442 | update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */ |
1412 | update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */ |
1443 | |
1413 | |
1444 | if (op->type == DOOR) |
1414 | if (op->type == DOOR) |
1445 | { |
1415 | { |
1446 | op->speed = 0.1; |
1416 | op->set_speed (0.1); |
1447 | update_ob_speed (op); |
|
|
1448 | op->speed_left = -0.05; |
1417 | op->speed_left = -0.05; |
1449 | return maxdam; |
1418 | return maxdam; |
1450 | } |
1419 | } |
1451 | |
1420 | |
1452 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1421 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1453 | { |
1422 | { |
1454 | remove_friendly_object (op); |
1423 | remove_friendly_object (op); |
1455 | |
1424 | |
1456 | if (get_owner (op) && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op) |
1425 | if (op->owner && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op) |
1457 | op->owner->contr->ranges[range_golem] = 0; |
1426 | op->owner->contr->ranges[range_golem] = 0; |
1458 | |
1427 | |
1459 | remove_ob (op); |
1428 | op->destroy (); |
1460 | free_object (op); |
|
|
1461 | return maxdam; |
1429 | return maxdam; |
1462 | } |
1430 | } |
1463 | |
1431 | |
1464 | /* Now lets start dealing with experience we get for killing something */ |
1432 | /* Now lets start dealing with experience we get for killing something */ |
1465 | |
1433 | |
1466 | owner = get_owner (hitter); |
1434 | owner = hitter->owner; |
1467 | if (!owner) |
1435 | if (!owner) |
1468 | owner = hitter; |
1436 | owner = hitter; |
1469 | |
1437 | |
1470 | /* is the victim (op) standing on battleground? */ |
1438 | /* is the victim (op) standing on battleground? */ |
1471 | if (op_on_battleground (op, NULL, NULL)) |
1439 | if (op_on_battleground (op, NULL, NULL)) |
… | |
… | |
1492 | char buf[256]; |
1460 | char buf[256]; |
1493 | |
1461 | |
1494 | tmv = localtime (&t); |
1462 | tmv = localtime (&t); |
1495 | strftime (buf, 256, "%a %b %d %H:%M:%S %Y", tmv); |
1463 | strftime (buf, 256, "%a %b %d %H:%M:%S %Y", tmv); |
1496 | |
1464 | |
1497 | LOG (llevInfo, "%s PLAYER_KILL_PLAYER: %s (%s) killed %s\n", buf, &owner->name, owner->contr->socket.host, query_name (op)); |
1465 | LOG (llevInfo, "%s PLAYER_KILL_PLAYER: %s (%s) killed %s\n", buf, &owner->name, owner->contr->ns->host, query_name (op)); |
1498 | } |
1466 | } |
1499 | |
1467 | |
1500 | /* try to filter some things out - basically, if you are |
1468 | /* try to filter some things out - basically, if you are |
1501 | * killing a level 1 creature and your level 20, you |
1469 | * killing a level 1 creature and your level 20, you |
1502 | * probably don't want to see that. |
1470 | * probably don't want to see that. |
… | |
… | |
1520 | * player that the object belonged to - so if you killed another player |
1488 | * player that the object belonged to - so if you killed another player |
1521 | * with spells, pets, whatever, there was no penalty. |
1489 | * with spells, pets, whatever, there was no penalty. |
1522 | * Changed to make luck penalty configurable in settings. |
1490 | * Changed to make luck penalty configurable in settings. |
1523 | */ |
1491 | */ |
1524 | if (op->type == PLAYER && owner != op && !battleg) |
1492 | if (op->type == PLAYER && owner != op && !battleg) |
1525 | change_luck (owner, -settings.pk_luck_penalty); |
1493 | owner->change_luck (-settings.pk_luck_penalty); |
1526 | |
1494 | |
1527 | /* This code below deals with finding the appropriate skill |
1495 | /* This code below deals with finding the appropriate skill |
1528 | * to credit exp to. This is a bit problematic - we should |
1496 | * to credit exp to. This is a bit problematic - we should |
1529 | * probably never really have to look at current_weapon->skill |
1497 | * probably never really have to look at current_weapon->skill |
1530 | */ |
1498 | */ |
… | |
… | |
1617 | { |
1585 | { |
1618 | int shares = 0, count = 0; |
1586 | int shares = 0, count = 0; |
1619 | player *pl; |
1587 | player *pl; |
1620 | partylist *party = owner->contr->party; |
1588 | partylist *party = owner->contr->party; |
1621 | |
1589 | |
1622 | #ifdef PARTY_KILL_LOG |
|
|
1623 | add_kill_to_party (party, query_name (owner), query_name (op), exp); |
1590 | add_kill_to_party (party, query_name (owner), query_name (op), exp); |
1624 | #endif |
1591 | |
1625 | for (pl = first_player; pl != NULL; pl = pl->next) |
1592 | for_all_players (pl) |
1626 | if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner)) |
1593 | if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner)) |
1627 | { |
1594 | { |
1628 | count++; |
1595 | count++; |
1629 | shares += (pl->ob->level + 4); |
1596 | shares += (pl->ob->level + 4); |
1630 | } |
1597 | } |
… | |
… | |
1633 | change_exp (owner, exp, skill, SK_EXP_TOTAL); |
1600 | change_exp (owner, exp, skill, SK_EXP_TOTAL); |
1634 | else |
1601 | else |
1635 | { |
1602 | { |
1636 | int share = exp / shares, given = 0, nexp; |
1603 | int share = exp / shares, given = 0, nexp; |
1637 | |
1604 | |
1638 | for (pl = first_player; pl != NULL; pl = pl->next) |
1605 | for_all_players (pl) |
1639 | if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner)) |
1606 | if (party && pl->ob->contr->party == party && on_same_map (pl->ob, owner)) |
1640 | { |
1607 | { |
1641 | nexp = (pl->ob->level + 4) * share; |
1608 | nexp = (pl->ob->level + 4) * share; |
1642 | change_exp (pl->ob, nexp, skill, SK_EXP_TOTAL); |
1609 | change_exp (pl->ob, nexp, skill, SK_EXP_TOTAL); |
1643 | given += nexp; |
1610 | given += nexp; |
… | |
… | |
1652 | |
1619 | |
1653 | if (op->type != PLAYER) |
1620 | if (op->type != PLAYER) |
1654 | { |
1621 | { |
1655 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
1622 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
1656 | { |
1623 | { |
1657 | object *owner1 = get_owner (op); |
1624 | object *owner1 = op->owner; |
1658 | |
1625 | |
1659 | if (owner1 && owner1->type == PLAYER) |
1626 | if (owner1 && owner1->type == PLAYER) |
1660 | { |
1627 | { |
1661 | play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); |
1628 | play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); |
1662 | /* Maybe we should include the owner that killed this, maybe not */ |
1629 | /* Maybe we should include the owner that killed this, maybe not */ |
… | |
… | |
1664 | } |
1631 | } |
1665 | |
1632 | |
1666 | remove_friendly_object (op); |
1633 | remove_friendly_object (op); |
1667 | } |
1634 | } |
1668 | |
1635 | |
1669 | remove_ob (op); |
1636 | op->destroy (); |
1670 | free_object (op); |
|
|
1671 | } |
1637 | } |
1672 | else |
1638 | else |
1673 | { |
1639 | { |
1674 | /* Player has been killed! */ |
1640 | /* Player has been killed! */ |
1675 | if (owner->type == PLAYER) |
1641 | if (owner->type == PLAYER) |
… | |
… | |
1705 | return 0; |
1671 | return 0; |
1706 | |
1672 | |
1707 | if (hitter->type == PLAYER && hitter->contr->peaceful == 1) |
1673 | if (hitter->type == PLAYER && hitter->contr->peaceful == 1) |
1708 | return 1; |
1674 | return 1; |
1709 | |
1675 | |
1710 | if ((owner = get_owner (hitter)) != NULL) |
1676 | if ((owner = hitter->owner) != NULL) |
1711 | { |
1677 | { |
1712 | if (owner->type == PLAYER && owner->contr->peaceful == 1) |
1678 | if (owner->type == PLAYER && owner->contr->peaceful == 1) |
1713 | friendlyfire = 2; |
1679 | friendlyfire = 2; |
1714 | } |
1680 | } |
1715 | |
1681 | |
… | |
… | |
1749 | return 0; |
1715 | return 0; |
1750 | |
1716 | |
1751 | #ifdef PROHIBIT_PLAYERKILL |
1717 | #ifdef PROHIBIT_PLAYERKILL |
1752 | if (op->type == PLAYER) |
1718 | if (op->type == PLAYER) |
1753 | { |
1719 | { |
1754 | object *owner = get_owner (hitter); |
1720 | object *owner = hitter->owner; |
1755 | |
1721 | |
1756 | if (!owner) |
1722 | if (!owner) |
1757 | owner = hitter; |
1723 | owner = hitter; |
1758 | |
1724 | |
1759 | if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner) |
1725 | if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner) |
… | |
… | |
1787 | |
1753 | |
1788 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1754 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1789 | if (tmp->type == RUNE || tmp->type == TRAP) |
1755 | if (tmp->type == RUNE || tmp->type == TRAP) |
1790 | { |
1756 | { |
1791 | spring_trap (tmp, hitter); |
1757 | spring_trap (tmp, hitter); |
|
|
1758 | |
1792 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |
1759 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |
1793 | return 0; |
1760 | return 0; |
|
|
1761 | |
1794 | break; |
1762 | break; |
1795 | } |
1763 | } |
1796 | } |
1764 | } |
1797 | |
1765 | |
1798 | if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) |
1766 | if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) |
… | |
… | |
1844 | (hitter->title != NULL |
1812 | (hitter->title != NULL |
1845 | && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, undead_name) != NULL))) |
1813 | && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, undead_name) != NULL))) |
1846 | return 0; |
1814 | return 0; |
1847 | } |
1815 | } |
1848 | |
1816 | |
1849 | maxattacktype = type; /* initialize this to something */ |
1817 | maxattacktype = type; /* initialise this to something */ |
1850 | for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) |
1818 | for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) |
1851 | { |
1819 | { |
1852 | /* Magic isn't really a true attack type - it gets combined with other |
1820 | /* 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 |
1821 | * attack types. As such, skip it over. However, if magic is |
1854 | * the only attacktype in the group, then still attack with it |
1822 | * the only attacktype in the group, then still attack with it |
… | |
… | |
1915 | |
1883 | |
1916 | #ifdef ATTACK_DEBUG |
1884 | #ifdef ATTACK_DEBUG |
1917 | LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); |
1885 | LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); |
1918 | #endif |
1886 | #endif |
1919 | |
1887 | |
1920 | if (get_owner (hitter)) |
1888 | if (hitter->owner) |
1921 | op->enemy = hitter->owner; |
1889 | op->enemy = hitter->owner; |
1922 | else if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
1890 | else if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
1923 | op->enemy = hitter; |
1891 | op->enemy = hitter; |
1924 | |
1892 | |
1925 | if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) |
1893 | if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) |
… | |
… | |
1950 | |
1918 | |
1951 | if (QUERY_FLAG (op, FLAG_TEAR_DOWN)) |
1919 | if (QUERY_FLAG (op, FLAG_TEAR_DOWN)) |
1952 | { |
1920 | { |
1953 | if (maxdam) |
1921 | if (maxdam) |
1954 | tear_down_wall (op); |
1922 | tear_down_wall (op); |
|
|
1923 | |
1955 | return maxdam; /* nothing more to do for wall */ |
1924 | return maxdam; /* nothing more to do for wall */ |
1956 | } |
1925 | } |
1957 | |
1926 | |
1958 | /* See if the creature has been killed */ |
1927 | /* See if the creature has been killed */ |
1959 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1928 | rtn_kill = kill_object (op, maxdam, hitter, type); |
… | |
… | |
1967 | */ |
1936 | */ |
1968 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1937 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1969 | { |
1938 | { |
1970 | if (QUERY_FLAG (hitter, FLAG_FRIENDLY)) |
1939 | if (QUERY_FLAG (hitter, FLAG_FRIENDLY)) |
1971 | remove_friendly_object (hitter); |
1940 | remove_friendly_object (hitter); |
1972 | remove_ob (hitter); |
1941 | |
1973 | free_object (hitter); |
1942 | hitter->destroy (); |
1974 | } |
1943 | } |
1975 | /* Lets handle creatures that are splitting now */ |
1944 | /* Lets handle creatures that are splitting now */ |
1976 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1945 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1977 | { |
1946 | { |
1978 | int i; |
1947 | int i; |
1979 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1948 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1980 | int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); |
1949 | int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); |
1981 | object *owner = get_owner (op); |
1950 | object *owner = op->owner; |
1982 | |
1951 | |
1983 | if (!op->other_arch) |
1952 | if (!op->other_arch) |
1984 | { |
1953 | { |
1985 | LOG (llevError, "SPLITTING without other_arch error.\n"); |
1954 | LOG (llevError, "SPLITTING without other_arch error.\n"); |
1986 | return maxdam; |
1955 | return maxdam; |
1987 | } |
1956 | } |
|
|
1957 | |
1988 | remove_ob (op); |
1958 | op->remove (); |
|
|
1959 | |
1989 | for (i = 0; i < NROFNEWOBJS (op); i++) |
1960 | for (i = 0; i < NROFNEWOBJS (op); i++) |
1990 | { /* This doesn't handle op->more yet */ |
1961 | { /* This doesn't handle op->more yet */ |
1991 | object *tmp = arch_to_object (op->other_arch); |
1962 | object *tmp = arch_to_object (op->other_arch); |
1992 | int j; |
1963 | int j; |
1993 | |
1964 | |
1994 | tmp->stats.hp = op->stats.hp; |
1965 | tmp->stats.hp = op->stats.hp; |
|
|
1966 | |
1995 | if (friendly) |
1967 | if (friendly) |
1996 | { |
1968 | { |
1997 | SET_FLAG (tmp, FLAG_FRIENDLY); |
|
|
1998 | add_friendly_object (tmp); |
1969 | add_friendly_object (tmp); |
1999 | tmp->attack_movement = PETMOVE; |
1970 | tmp->attack_movement = PETMOVE; |
|
|
1971 | |
2000 | if (owner != NULL) |
1972 | if (owner) |
2001 | set_owner (tmp, owner); |
1973 | tmp->set_owner (owner); |
2002 | } |
1974 | } |
|
|
1975 | |
2003 | if (unaggressive) |
1976 | if (unaggressive) |
2004 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1977 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
|
|
1978 | |
2005 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
1979 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
|
|
1980 | |
2006 | if (j == -1) /* No spot to put this monster */ |
1981 | if (j == -1) /* No spot to put this monster */ |
2007 | free_object (tmp); |
1982 | tmp->destroy (); |
2008 | else |
1983 | else |
2009 | { |
1984 | { |
2010 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
1985 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
2011 | insert_ob_in_map (tmp, op->map, NULL, 0); |
1986 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2012 | } |
1987 | } |
2013 | } |
1988 | } |
2014 | if (friendly) |
1989 | |
2015 | remove_friendly_object (op); |
1990 | op->destroy (); |
2016 | free_object (op); |
|
|
2017 | } |
1991 | } |
2018 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1992 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
2019 | { |
1993 | hitter->destroy (); |
2020 | remove_ob (hitter); |
1994 | |
2021 | free_object (hitter); |
|
|
2022 | } |
|
|
2023 | return maxdam; |
1995 | return maxdam; |
2024 | } |
1996 | } |
2025 | |
1997 | |
2026 | |
1998 | |
2027 | void |
1999 | void |
… | |
… | |
2048 | if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
2020 | if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
2049 | tmp->stats.dam += hitter->level / 2; |
2021 | tmp->stats.dam += hitter->level / 2; |
2050 | else |
2022 | else |
2051 | tmp->stats.dam = dam; |
2023 | tmp->stats.dam = dam; |
2052 | |
2024 | |
2053 | copy_owner (tmp, hitter); /* so we get credit for poisoning kills */ |
2025 | tmp->set_owner (hitter); /* so we get credit for poisoning kills */ |
2054 | if (hitter->skill && hitter->skill != tmp->skill) |
2026 | if (hitter->skill && hitter->skill != tmp->skill) |
2055 | { |
2027 | { |
2056 | tmp->skill = hitter->skill; |
2028 | tmp->skill = hitter->skill; |
2057 | } |
2029 | } |
2058 | |
2030 | |
… | |
… | |
2064 | tmp->stats.Con = MAX (-(dam / 4 + 1), -10); |
2036 | tmp->stats.Con = MAX (-(dam / 4 + 1), -10); |
2065 | tmp->stats.Str = MAX (-(dam / 3 + 2), -10); |
2037 | tmp->stats.Str = MAX (-(dam / 3 + 2), -10); |
2066 | tmp->stats.Dex = MAX (-(dam / 6 + 1), -10); |
2038 | tmp->stats.Dex = MAX (-(dam / 6 + 1), -10); |
2067 | tmp->stats.Int = MAX (-dam / 7, -10); |
2039 | tmp->stats.Int = MAX (-dam / 7, -10); |
2068 | SET_FLAG (tmp, FLAG_APPLIED); |
2040 | SET_FLAG (tmp, FLAG_APPLIED); |
2069 | fix_player (op); |
2041 | op->update_stats (); |
2070 | new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); |
2042 | new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); |
2071 | } |
2043 | } |
2072 | if (hitter->type == PLAYER) |
2044 | if (hitter->type == PLAYER) |
2073 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
2045 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
2074 | else if (get_owner (hitter) != NULL && hitter->owner->type == PLAYER) |
2046 | 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); |
2047 | new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); |
2076 | } |
2048 | } |
2077 | tmp->speed_left = 0; |
2049 | tmp->speed_left = 0; |
2078 | } |
2050 | } |
2079 | else |
2051 | else |
… | |
… | |
2098 | } |
2070 | } |
2099 | else |
2071 | else |
2100 | tmp->stats.food++; |
2072 | tmp->stats.food++; |
2101 | SET_FLAG (tmp, FLAG_APPLIED); |
2073 | SET_FLAG (tmp, FLAG_APPLIED); |
2102 | tmp->speed_left = 0; |
2074 | tmp->speed_left = 0; |
2103 | fix_player (op); |
2075 | op->update_stats (); |
2104 | } |
2076 | } |
2105 | |
2077 | |
2106 | void |
2078 | void |
2107 | confuse_player (object *op, object *hitter, int dam) |
2079 | confuse_player (object *op, object *hitter, int dam) |
2108 | { |
2080 | { |
… | |
… | |
2152 | */ |
2124 | */ |
2153 | tmp->speed = tmp->speed * (100.0 - (float) op->resist[ATNR_BLIND]) / 100; |
2125 | tmp->speed = tmp->speed * (100.0 - (float) op->resist[ATNR_BLIND]) / 100; |
2154 | |
2126 | |
2155 | tmp = insert_ob_in_ob (tmp, op); |
2127 | tmp = insert_ob_in_ob (tmp, op); |
2156 | change_abil (op, tmp); /* Mostly to display any messages */ |
2128 | change_abil (op, tmp); /* Mostly to display any messages */ |
2157 | fix_player (op); /* This takes care of some other stuff */ |
2129 | op->update_stats (); /* This takes care of some other stuff */ |
2158 | |
2130 | |
2159 | if (hitter->owner) |
2131 | if (hitter->owner) |
2160 | owner = get_owner (hitter); |
2132 | owner = hitter->owner; |
2161 | else |
2133 | else |
2162 | owner = hitter; |
2134 | owner = hitter; |
2163 | |
2135 | |
2164 | new_draw_info_format (NDI_UNIQUE, 0, owner, "Your attack blinds %s!", query_name (op)); |
2136 | new_draw_info_format (NDI_UNIQUE, 0, owner, "Your attack blinds %s!", query_name (op)); |
2165 | } |
2137 | } |
… | |
… | |
2311 | } |
2283 | } |
2312 | |
2284 | |
2313 | /* aimed missiles use the owning object's sight */ |
2285 | /* aimed missiles use the owning object's sight */ |
2314 | if (is_aimed_missile (hitter)) |
2286 | if (is_aimed_missile (hitter)) |
2315 | { |
2287 | { |
2316 | if ((attacker = get_owner (hitter)) == NULL) |
2288 | if ((attacker = hitter->owner) == NULL) |
2317 | attacker = hitter; |
2289 | attacker = hitter; |
2318 | /* A player who saves but hasn't quit still could have objects |
2290 | /* A player who saves but hasn't quit still could have objects |
2319 | * owned by him - need to handle that case to avoid crashes. |
2291 | * owned by him - need to handle that case to avoid crashes. |
2320 | */ |
2292 | */ |
2321 | if (QUERY_FLAG (attacker, FLAG_REMOVED)) |
2293 | if (QUERY_FLAG (attacker, FLAG_REMOVED)) |