1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
9 | * 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 |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
22 | */ |
|
|
23 | |
24 | #include <assert.h> |
24 | #include <assert.h> |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <living.h> |
26 | #include <living.h> |
27 | #include <material.h> |
27 | #include <material.h> |
28 | #include <skills.h> |
28 | #include <skills.h> |
… | |
… | |
86 | break; |
86 | break; |
87 | } |
87 | } |
88 | else |
88 | else |
89 | mt = name_to_material (op->materialname); |
89 | mt = name_to_material (op->materialname); |
90 | |
90 | |
91 | if (mt == NULL) |
91 | if (!mt) |
92 | return TRUE; |
92 | return TRUE; |
93 | |
93 | |
94 | roll = rndm (1, 20); |
94 | roll = rndm (1, 20); |
95 | |
95 | |
96 | /* the attacktypes have no meaning for object saves |
96 | /* the attacktypes have no meaning for object saves |
… | |
… | |
161 | * function if the object doesnt contain a material that can burn. |
161 | * function if the object doesnt contain a material that can burn. |
162 | * So forget lighting magical swords on fire with this!) -b.t. |
162 | * So forget lighting magical swords on fire with this!) -b.t. |
163 | */ |
163 | */ |
164 | if (type & (AT_FIRE | AT_ELECTRICITY) && op->other_arch && QUERY_FLAG (op, FLAG_IS_LIGHTABLE)) |
164 | if (type & (AT_FIRE | AT_ELECTRICITY) && op->other_arch && QUERY_FLAG (op, FLAG_IS_LIGHTABLE)) |
165 | { |
165 | { |
166 | const char *arch = op->other_arch->name; |
166 | const char *arch = op->other_arch->archname; |
167 | |
167 | |
168 | op = decrease_ob_nr (op, 1); |
168 | op = decrease_ob_nr (op, 1); |
169 | |
169 | |
170 | if (op) |
170 | if (op) |
171 | fix_stopped_item (op, m, originator); |
171 | fix_stopped_item (op, m, originator); |
… | |
… | |
282 | return 0; |
282 | return 0; |
283 | } |
283 | } |
284 | |
284 | |
285 | if (QUERY_FLAG (op, FLAG_REMOVED) || op->env != NULL) |
285 | if (QUERY_FLAG (op, FLAG_REMOVED) || op->env != NULL) |
286 | { |
286 | { |
287 | LOG (llevError, "BUG: hit_map(): hitter (arch %s, name %s) not on a map\n", &op->arch->name, &op->name); |
287 | LOG (llevError, "BUG: hit_map(): hitter (arch %s, name %s) not on a map\n", &op->arch->archname, &op->name); |
288 | return 0; |
288 | return 0; |
289 | } |
289 | } |
290 | |
290 | |
291 | if (!op->map) |
291 | if (!op->map) |
292 | { |
292 | { |
… | |
… | |
613 | if (hitter->owner != NULL) |
613 | if (hitter->owner != NULL) |
614 | 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); |
615 | else |
615 | else |
616 | { |
616 | { |
617 | sprintf (buf, "%s%s you.", &hitter->name, buf2); |
617 | sprintf (buf, "%s%s you.", &hitter->name, buf2); |
|
|
618 | |
618 | if (dam != 0) |
619 | if (dam != 0) |
619 | { |
620 | { |
620 | if (dam < 10) |
621 | if (dam < 10) |
621 | play_sound_player_only (op->contr, SOUND_PLAYER_IS_HIT1, 0, 0); |
622 | op->contr->play_sound (sound_find ("player_is_hit1")); |
622 | else if (dam < 20) |
623 | else if (dam < 20) |
623 | play_sound_player_only (op->contr, SOUND_PLAYER_IS_HIT2, 0, 0); |
624 | op->contr->play_sound (sound_find ("player_is_hit2")); |
624 | else |
625 | else |
625 | play_sound_player_only (op->contr, SOUND_PLAYER_IS_HIT3, 0, 0); |
626 | op->contr->play_sound (sound_find ("player_is_hit3")); |
626 | } |
627 | } |
627 | } |
628 | } |
|
|
629 | |
628 | new_draw_info (NDI_BLACK, 0, op, buf); |
630 | new_draw_info (NDI_BLACK, 0, op, buf); |
629 | } /* end of player hitting player */ |
631 | } /* end of player hitting player */ |
630 | |
632 | |
631 | if (hitter->type == PLAYER) |
633 | if (hitter->type == PLAYER) |
632 | { |
634 | { |
633 | sprintf (buf, "You %s.", buf1); |
635 | sprintf (buf, "You %s.", buf1); |
|
|
636 | |
634 | if (dam != 0) |
637 | if (dam != 0) |
635 | { |
638 | { |
636 | if (dam < 10) |
639 | if (dam < 10) |
637 | play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS1, 0, 0); |
640 | op->play_sound (sound_find ("player_hits1")); |
638 | else if (dam < 20) |
641 | else if (dam < 20) |
639 | play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS2, 0, 0); |
642 | op->play_sound (sound_find ("player_hits2")); |
640 | else |
643 | else |
641 | play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS3, 0, 0); |
644 | op->play_sound (sound_find ("player_hits3")); |
642 | } |
645 | } |
|
|
646 | |
643 | new_draw_info (NDI_BLACK, 0, hitter, buf); |
647 | new_draw_info (NDI_BLACK, 0, hitter, buf); |
644 | } |
648 | } |
645 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
649 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
646 | { |
650 | { |
647 | /* look for stacked spells and start reducing the message chances */ |
651 | /* look for stacked spells and start reducing the message chances */ |
… | |
… | |
656 | if (next) |
660 | if (next) |
657 | while (next) |
661 | while (next) |
658 | { |
662 | { |
659 | if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) |
663 | if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) |
660 | i *= 3; |
664 | i *= 3; |
|
|
665 | |
661 | tmp = next; |
666 | tmp = next; |
662 | next = tmp->above; |
667 | next = tmp->above; |
663 | } |
668 | } |
664 | |
669 | |
665 | if (i < 0) |
670 | if (i < 0) |
… | |
… | |
670 | } |
675 | } |
671 | else if (rndm (0, 5) != 0) |
676 | else if (rndm (0, 5) != 0) |
672 | return; |
677 | return; |
673 | |
678 | |
674 | sprintf (buf, "Your %s%s %s.", &hitter->name, buf2, &op->name); |
679 | sprintf (buf, "Your %s%s %s.", &hitter->name, buf2, &op->name); |
675 | play_sound_map (op->map, op->x, op->y, SOUND_PLAYER_HITS4); |
680 | op->play_sound (sound_find ("player_hits4")); |
676 | new_draw_info (NDI_BLACK, 0, hitter->owner, buf); |
681 | new_draw_info (NDI_BLACK, 0, hitter->owner, buf); |
677 | } |
682 | } |
678 | } |
683 | } |
679 | |
684 | |
680 | |
685 | |
… | |
… | |
696 | return 0; |
701 | return 0; |
697 | } |
702 | } |
698 | if (QUERY_FLAG (*target, FLAG_REMOVED) |
703 | if (QUERY_FLAG (*target, FLAG_REMOVED) |
699 | || QUERY_FLAG (*hitter, FLAG_REMOVED) || (*hitter)->map == NULL || !on_same_map ((*hitter), (*target))) |
704 | || QUERY_FLAG (*hitter, FLAG_REMOVED) || (*hitter)->map == NULL || !on_same_map ((*hitter), (*target))) |
700 | { |
705 | { |
701 | LOG (llevError, "BUG: hitter (arch %s, name %s) with no relation to " "target\n", &(*hitter)->arch->name, &(*hitter)->name); |
706 | LOG (llevError, "BUG: hitter (arch %s, name %s) with no relation to " "target\n", &(*hitter)->arch->archname, &(*hitter)->name); |
702 | return 1; |
707 | return 1; |
703 | } |
708 | } |
704 | *simple_attack = 0; |
709 | *simple_attack = 0; |
705 | return 0; |
710 | return 0; |
706 | } |
711 | } |
… | |
… | |
751 | /* Decrease speed BEFORE calling process_object. Otherwise, an |
756 | /* Decrease speed BEFORE calling process_object. Otherwise, an |
752 | * infinite loop occurs, with process_object calling move_monster, |
757 | * infinite loop occurs, with process_object calling move_monster, |
753 | * which then gets here again. By decreasing the speed before |
758 | * which then gets here again. By decreasing the speed before |
754 | * we call process_object, the 'if' statement above will fail. |
759 | * we call process_object, the 'if' statement above will fail. |
755 | */ |
760 | */ |
756 | op->speed_left--; |
761 | --op->speed_left; |
757 | process_object (op); |
762 | process_object (op); |
758 | |
763 | |
759 | if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack)) |
764 | if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack)) |
760 | goto error; |
765 | goto error; |
761 | } |
766 | } |
… | |
… | |
770 | |
775 | |
771 | /* See if we hit the creature */ |
776 | /* See if we hit the creature */ |
772 | if (roll == 20 || op->stats.ac >= base_wc - roll) |
777 | if (roll == 20 || op->stats.ac >= base_wc - roll) |
773 | { |
778 | { |
774 | int hitdam = base_dam; |
779 | int hitdam = base_dam; |
775 | |
|
|
776 | if (settings.casting_time == TRUE) |
|
|
777 | { |
|
|
778 | if (hitter->type == PLAYER && hitter->casting_time > -1) |
|
|
779 | { |
|
|
780 | hitter->casting_time = -1; |
|
|
781 | new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost your spell!"); |
|
|
782 | } |
|
|
783 | |
|
|
784 | if (op->casting_time > -1 && hitdam > 0) |
|
|
785 | { |
|
|
786 | op->casting_time = -1; |
|
|
787 | if (op->type == PLAYER) |
|
|
788 | { |
|
|
789 | new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost your spell!"); |
|
|
790 | new_draw_info_format (NDI_ALL | NDI_UNIQUE, 5, NULL, "%s was hit by %s and lost a spell.", &op_name, &hitter->name); |
|
|
791 | } |
|
|
792 | } |
|
|
793 | } |
|
|
794 | |
780 | |
795 | if (!simple_attack) |
781 | if (!simple_attack) |
796 | { |
782 | { |
797 | /* If you hit something, the victim should *always* wake up. |
783 | /* If you hit something, the victim should *always* wake up. |
798 | * Before, invisible hitters could avoid doing this. |
784 | * Before, invisible hitters could avoid doing this. |
… | |
… | |
1099 | return dam; |
1085 | return dam; |
1100 | |
1086 | |
1101 | if (hitter->slaying) |
1087 | if (hitter->slaying) |
1102 | { |
1088 | { |
1103 | if ((op->race && strstr (hitter->slaying, op->race)) |
1089 | if ((op->race && strstr (hitter->slaying, op->race)) |
1104 | || (op->arch && op->arch->name && strstr (op->arch->name, hitter->slaying))) |
1090 | || (op->arch && op->arch->archname && strstr (op->arch->archname, hitter->slaying))) |
1105 | { |
1091 | { |
1106 | doesnt_slay = 0; |
1092 | doesnt_slay = 0; |
1107 | dam *= 3; |
1093 | dam *= 3; |
1108 | } |
1094 | } |
1109 | } |
1095 | } |
… | |
… | |
1273 | * exp, but the wiz would still lose exp! If drainee is a wiz, |
1259 | * exp, but the wiz would still lose exp! If drainee is a wiz, |
1274 | * nothing happens. |
1260 | * nothing happens. |
1275 | * Try to credit the owner. We try to display player -> player drain |
1261 | * Try to credit the owner. We try to display player -> player drain |
1276 | * attacks, hence all the != PLAYER checks. |
1262 | * attacks, hence all the != PLAYER checks. |
1277 | */ |
1263 | */ |
1278 | if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1264 | if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WIZ)) |
1279 | { |
1265 | { |
1280 | object *owner = hitter->owner; |
1266 | object *owner = hitter->owner; |
1281 | |
1267 | |
1282 | if (owner && owner != hitter) |
1268 | if (owner && owner != hitter) |
1283 | { |
1269 | { |
… | |
… | |
1308 | object *god = find_god (determine_god (owner)); |
1294 | object *god = find_god (determine_god (owner)); |
1309 | int div = 1; |
1295 | int div = 1; |
1310 | |
1296 | |
1311 | /* if undead are not an enemy of your god, you turn them |
1297 | /* if undead are not an enemy of your god, you turn them |
1312 | * at half strength */ |
1298 | * at half strength */ |
1313 | if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL) |
1299 | if (!god || !god->slaying || strstr (god->slaying, shstr_undead) == NULL) |
1314 | div = 2; |
1300 | div = 2; |
1315 | |
1301 | |
1316 | /* Give a bonus if you resist turn undead */ |
1302 | /* Give a bonus if you resist turn undead */ |
1317 | if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100))) |
1303 | if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100))) |
1318 | scare_creature (op, owner); |
1304 | scare_creature (op, owner); |
… | |
… | |
1493 | else |
1479 | else |
1494 | new_draw_info_format (NDI_BLACK, 0, owner, "You killed %s.", query_name (op)); |
1480 | new_draw_info_format (NDI_BLACK, 0, owner, "You killed %s.", query_name (op)); |
1495 | |
1481 | |
1496 | /* Only play sounds for melee kills */ |
1482 | /* Only play sounds for melee kills */ |
1497 | if (hitter->type == PLAYER) |
1483 | if (hitter->type == PLAYER) |
1498 | play_sound_map (owner->map, owner->x, owner->y, SOUND_PLAYER_KILLS); |
1484 | owner->play_sound (sound_find ("player_kills")); |
1499 | } |
1485 | } |
1500 | |
1486 | |
1501 | /* If a player kills another player, not on |
1487 | /* If a player kills another player, not on |
1502 | * battleground, the "killer" looses 1 luck. Since this is |
1488 | * battleground, the "killer" looses 1 luck. Since this is |
1503 | * not reversible, it's actually quite a pain IMHO. -AV |
1489 | * not reversible, it's actually quite a pain IMHO. -AV |
… | |
… | |
1562 | skill = skop->skill; |
1548 | skill = skop->skill; |
1563 | |
1549 | |
1564 | new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf); |
1550 | new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf); |
1565 | |
1551 | |
1566 | /* If you didn't kill yourself, and your not the wizard */ |
1552 | /* If you didn't kill yourself, and your not the wizard */ |
1567 | if (owner != op && !QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1553 | if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) |
1568 | { |
1554 | { |
1569 | int exp; |
1555 | int exp; |
1570 | |
1556 | |
1571 | /* Really don't give much experience for killing other players */ |
1557 | /* Really don't give much experience for killing other players */ |
1572 | // schmorp: temporarily? reduce the amount of exp gained for pking enourmously |
1558 | // schmorp: temporarily? reduce the amount of exp gained for pking enourmously |
… | |
… | |
1639 | { |
1625 | { |
1640 | object *owner1 = op->owner; |
1626 | object *owner1 = op->owner; |
1641 | |
1627 | |
1642 | if (owner1 && owner1->type == PLAYER) |
1628 | if (owner1 && owner1->type == PLAYER) |
1643 | { |
1629 | { |
1644 | play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); |
1630 | owner1->contr->play_sound (sound_find ("pet_is_killed")); |
1645 | /* Maybe we should include the owner that killed this, maybe not */ |
1631 | /* Maybe we should include the owner that killed this, maybe not */ |
1646 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name); |
1632 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name); |
1647 | } |
1633 | } |
1648 | |
1634 | |
1649 | remove_friendly_object (op); |
1635 | remove_friendly_object (op); |
… | |
… | |
1698 | friendlyfire = 0; |
1684 | friendlyfire = 0; |
1699 | } |
1685 | } |
1700 | |
1686 | |
1701 | return friendlyfire; |
1687 | return friendlyfire; |
1702 | } |
1688 | } |
1703 | |
|
|
1704 | |
1689 | |
1705 | /* This isn't used just for players, but in fact most objects. |
1690 | /* This isn't used just for players, but in fact most objects. |
1706 | * op is the object to be hit, dam is the amount of damage, hitter |
1691 | * op is the object to be hit, dam is the amount of damage, hitter |
1707 | * is what is hitting the object, type is the attacktype, and |
1692 | * is what is hitting the object, type is the attacktype, and |
1708 | * full_hit is set if monster area does not matter. |
1693 | * full_hit is set if monster area does not matter. |
… | |
… | |
1726 | |
1711 | |
1727 | /* very simple: if our target has no_damage 1 set or is wiz, we can't hurt him */ |
1712 | /* very simple: if our target has no_damage 1 set or is wiz, we can't hurt him */ |
1728 | if (QUERY_FLAG (op, FLAG_WIZ) || QUERY_FLAG (op, FLAG_NO_DAMAGE)) |
1713 | if (QUERY_FLAG (op, FLAG_WIZ) || QUERY_FLAG (op, FLAG_NO_DAMAGE)) |
1729 | return 0; |
1714 | return 0; |
1730 | |
1715 | |
1731 | #ifdef PROHIBIT_PLAYERKILL |
1716 | // only allow pk for hostile players |
1732 | if (op->type == PLAYER) |
1717 | if (op->type == PLAYER) |
1733 | { |
1718 | { |
1734 | object *owner = hitter->owner; |
1719 | object *owner = hitter->owner; |
1735 | |
1720 | |
1736 | if (!owner) |
1721 | if (!owner) |
… | |
… | |
1740 | && (!op_on_battleground (op, 0, 0) |
1725 | && (!op_on_battleground (op, 0, 0) |
1741 | && (op->contr->peaceful || owner->contr->peaceful)) |
1726 | && (op->contr->peaceful || owner->contr->peaceful)) |
1742 | && op != owner) |
1727 | && op != owner) |
1743 | return 0; |
1728 | return 0; |
1744 | } |
1729 | } |
1745 | #endif |
|
|
1746 | |
1730 | |
1747 | if (body_attack) |
1731 | if (body_attack) |
1748 | { |
1732 | { |
1749 | /* slow and paralyze must hit the head. But we don't want to just |
1733 | /* slow and paralyze must hit the head. But we don't want to just |
1750 | * return - we still need to process other attacks the spell still |
1734 | * return - we still need to process other attacks the spell still |
… | |
… | |
1829 | if ((!hitter->slaying || |
1813 | if ((!hitter->slaying || |
1830 | (!(op->race && strstr (hitter->slaying, op->race)) && |
1814 | (!(op->race && strstr (hitter->slaying, op->race)) && |
1831 | !(op->name && strstr (hitter->slaying, op->name)))) && |
1815 | !(op->name && strstr (hitter->slaying, op->name)))) && |
1832 | (!QUERY_FLAG (op, FLAG_UNDEAD) || |
1816 | (!QUERY_FLAG (op, FLAG_UNDEAD) || |
1833 | (hitter->title != NULL |
1817 | (hitter->title != NULL |
1834 | && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, undead_name) != NULL))) |
1818 | && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, shstr_undead) != NULL))) |
1835 | return 0; |
1819 | return 0; |
1836 | } |
1820 | } |
1837 | |
1821 | |
1838 | maxattacktype = type; /* initialise this to something */ |
1822 | maxattacktype = type; /* initialise this to something */ |
1839 | for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) |
1823 | for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) |
… | |
… | |
1871 | */ |
1855 | */ |
1872 | friendlyfire = friendly_fire (op, hitter); |
1856 | friendlyfire = friendly_fire (op, hitter); |
1873 | if (friendlyfire && maxdam) |
1857 | if (friendlyfire && maxdam) |
1874 | { |
1858 | { |
1875 | maxdam = ((dam * settings.set_friendly_fire) / 100); |
1859 | maxdam = ((dam * settings.set_friendly_fire) / 100); |
1876 | #ifndef COZY_SERVER |
|
|
1877 | maxdam++; |
|
|
1878 | #endif |
|
|
1879 | |
1860 | |
1880 | #ifdef ATTACK_DEBUG |
1861 | #ifdef ATTACK_DEBUG |
1881 | LOG (llevDebug, "Friendly fire (type:%d setting: %d%) did %d damage dropped to %d\n", |
1862 | LOG (llevDebug, "Friendly fire (type:%d setting: %d%) did %d damage dropped to %d\n", |
1882 | friendlyfire, settings.set_friendly_fire, dam, maxdam); |
1863 | friendlyfire, settings.set_friendly_fire, dam, maxdam); |
1883 | #endif |
1864 | #endif |
1884 | } |
1865 | } |
1885 | |
1866 | |
1886 | if (!full_hit) |
1867 | if (!full_hit) |
1887 | { |
1868 | { |
1888 | archetype *at; |
|
|
1889 | int area; |
1869 | int area; |
1890 | int remainder; |
1870 | int remainder; |
1891 | |
1871 | |
1892 | area = 0; |
1872 | area = 0; |
1893 | for (at = op->arch; at != NULL; at = at->more) |
1873 | |
|
|
1874 | for (archetype *at = op->arch; at; at = (archetype *)at->more) |
1894 | area++; |
1875 | area++; |
|
|
1876 | |
1895 | assert (area > 0); |
1877 | assert (area > 0); |
1896 | |
1878 | |
1897 | /* basically: maxdam /= area; we try to "simulate" a float |
1879 | /* basically: maxdam /= area; we try to "simulate" a float |
1898 | value-effect */ |
1880 | value-effect */ |
1899 | remainder = 100 * (maxdam % area) / area; |
1881 | remainder = 100 * (maxdam % area) / area; |
… | |
… | |
2058 | tmp->stats.Dex = MAX (-(dam / 6 + 1), -10); |
2040 | tmp->stats.Dex = MAX (-(dam / 6 + 1), -10); |
2059 | tmp->stats.Int = MAX (-dam / 7, -10); |
2041 | tmp->stats.Int = MAX (-dam / 7, -10); |
2060 | SET_FLAG (tmp, FLAG_APPLIED); |
2042 | SET_FLAG (tmp, FLAG_APPLIED); |
2061 | op->update_stats (); |
2043 | op->update_stats (); |
2062 | new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); |
2044 | new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); |
|
|
2045 | op->play_sound (tmp->sound); |
2063 | } |
2046 | } |
2064 | |
2047 | |
2065 | if (hitter->type == PLAYER) |
2048 | if (hitter->type == PLAYER) |
2066 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
2049 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
2067 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
2050 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
… | |
… | |
2215 | ** field of the deathstriking object */ |
2198 | ** field of the deathstriking object */ |
2216 | |
2199 | |
2217 | int atk_lev, def_lev, kill_lev; |
2200 | int atk_lev, def_lev, kill_lev; |
2218 | |
2201 | |
2219 | if (hitter->slaying) |
2202 | if (hitter->slaying) |
2220 | if (!((QUERY_FLAG (op, FLAG_UNDEAD) && strstr (hitter->slaying, undead_name)) || (op->race && strstr (hitter->slaying, op->race)))) |
2203 | if (!((QUERY_FLAG (op, FLAG_UNDEAD) && strstr (hitter->slaying, shstr_undead)) || (op->race && strstr (hitter->slaying, op->race)))) |
2221 | return; |
2204 | return; |
2222 | |
2205 | |
2223 | def_lev = op->level; |
2206 | def_lev = op->level; |
2224 | if (def_lev < 1) |
2207 | if (def_lev < 1) |
2225 | { |
2208 | { |
2226 | LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name); |
2209 | LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->archname, &op->name); |
2227 | def_lev = 1; |
2210 | def_lev = 1; |
2228 | } |
2211 | } |
2229 | |
2212 | |
2230 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2213 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2231 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |
2214 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |