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.61 by root, Tue May 1 05:48:20 2007 UTC vs.
Revision 1.77 by root, Thu Oct 4 23:59:07 2007 UTC

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
684 if (QUERY_FLAG (*target, FLAG_FREED) || QUERY_FLAG (*hitter, FLAG_FREED)) 689 if (QUERY_FLAG (*target, FLAG_FREED) || QUERY_FLAG (*hitter, FLAG_FREED))
685 { 690 {
686 LOG (llevError, "BUG: get_attack_mode(): freed object\n"); 691 LOG (llevError, "BUG: get_attack_mode(): freed object\n");
687 return 1; 692 return 1;
688 } 693 }
694
689 if ((*target)->head) 695 if ((*target)->head)
690 *target = (*target)->head; 696 *target = (*target)->head;
697
691 if ((*hitter)->head) 698 if ((*hitter)->head)
692 *hitter = (*hitter)->head; 699 *hitter = (*hitter)->head;
700
693 if ((*hitter)->env != NULL || (*target)->env != NULL) 701 if ((*hitter)->env != NULL || (*target)->env != NULL)
694 { 702 {
695 *simple_attack = 1; 703 *simple_attack = 1;
696 return 0; 704 return 0;
697 } 705 }
706
698 if (QUERY_FLAG (*target, FLAG_REMOVED) 707 if (QUERY_FLAG (*target, FLAG_REMOVED)
699 || QUERY_FLAG (*hitter, FLAG_REMOVED) || (*hitter)->map == NULL || !on_same_map ((*hitter), (*target))) 708 || QUERY_FLAG (*hitter, FLAG_REMOVED) || (*hitter)->map == NULL || !on_same_map ((*hitter), (*target)))
700 { 709 {
701 LOG (llevError, "BUG: hitter (arch %s, name %s) with no relation to " "target\n", &(*hitter)->arch->name, &(*hitter)->name); 710 LOG (llevError | logBacktrace, "BUG: hitter (%s) with no relation to target (%s)\n",
711 (*hitter)->debug_desc (), (*target)->debug_desc ());
702 return 1; 712 return 1;
703 } 713 }
714
704 *simple_attack = 0; 715 *simple_attack = 0;
705 return 0; 716 return 0;
706} 717}
707 718
708static int 719static int
744 755
745 /* 756 /*
746 * A little check to make it more difficult to dance forward and back 757 * A little check to make it more difficult to dance forward and back
747 * to avoid ever being hit by monsters. 758 * to avoid ever being hit by monsters.
748 */ 759 */
749 if (!simple_attack && QUERY_FLAG (op, FLAG_MONSTER) && op->speed_left > -(FABS (op->speed)) * 0.3) 760 if (!simple_attack && QUERY_FLAG (op, FLAG_MONSTER) && op->speed_left > abs (op->speed) * -0.3f)
750 { 761 {
751 /* Decrease speed BEFORE calling process_object. Otherwise, an 762 /* Decrease speed BEFORE calling process_object. Otherwise, an
752 * infinite loop occurs, with process_object calling move_monster, 763 * infinite loop occurs, with process_object calling move_monster,
753 * which then gets here again. By decreasing the speed before 764 * which then gets here again. By decreasing the speed before
754 * we call process_object, the 'if' statement above will fail. 765 * we call process_object, the 'if' statement above will fail.
755 */ 766 */
756 op->speed_left--; 767 --op->speed_left;
757 process_object (op); 768 process_object (op);
758 769
759 if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack)) 770 if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack))
760 goto error; 771 goto error;
761 } 772 }
770 781
771 /* See if we hit the creature */ 782 /* See if we hit the creature */
772 if (roll == 20 || op->stats.ac >= base_wc - roll) 783 if (roll == 20 || op->stats.ac >= base_wc - roll)
773 { 784 {
774 int hitdam = base_dam; 785 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 786
795 if (!simple_attack) 787 if (!simple_attack)
796 { 788 {
797 /* If you hit something, the victim should *always* wake up. 789 /* If you hit something, the victim should *always* wake up.
798 * Before, invisible hitters could avoid doing this. 790 * Before, invisible hitters could avoid doing this.
1099 return dam; 1091 return dam;
1100 1092
1101 if (hitter->slaying) 1093 if (hitter->slaying)
1102 { 1094 {
1103 if ((op->race && strstr (hitter->slaying, op->race)) 1095 if ((op->race && strstr (hitter->slaying, op->race))
1104 || (op->arch && op->arch->name && strstr (op->arch->name, hitter->slaying))) 1096 || (op->arch && op->arch->archname && strstr (op->arch->archname, hitter->slaying)))
1105 { 1097 {
1106 doesnt_slay = 0; 1098 doesnt_slay = 0;
1107 dam *= 3; 1099 dam *= 3;
1108 } 1100 }
1109 } 1101 }
1273 * exp, but the wiz would still lose exp! If drainee is a wiz, 1265 * exp, but the wiz would still lose exp! If drainee is a wiz,
1274 * nothing happens. 1266 * nothing happens.
1275 * Try to credit the owner. We try to display player -> player drain 1267 * Try to credit the owner. We try to display player -> player drain
1276 * attacks, hence all the != PLAYER checks. 1268 * attacks, hence all the != PLAYER checks.
1277 */ 1269 */
1278 if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) 1270 if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WIZ))
1279 { 1271 {
1280 object *owner = hitter->owner; 1272 object *owner = hitter->owner;
1281 1273
1282 if (owner && owner != hitter) 1274 if (owner && owner != hitter)
1283 { 1275 {
1308 object *god = find_god (determine_god (owner)); 1300 object *god = find_god (determine_god (owner));
1309 int div = 1; 1301 int div = 1;
1310 1302
1311 /* if undead are not an enemy of your god, you turn them 1303 /* if undead are not an enemy of your god, you turn them
1312 * at half strength */ 1304 * at half strength */
1313 if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL) 1305 if (!god || !god->slaying || strstr (god->slaying, shstr_undead) == NULL)
1314 div = 2; 1306 div = 2;
1315 1307
1316 /* Give a bonus if you resist turn undead */ 1308 /* 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))) 1309 if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100)))
1318 scare_creature (op, owner); 1310 scare_creature (op, owner);
1433 if (QUERY_FLAG (op, FLAG_BLOCKSVIEW)) 1425 if (QUERY_FLAG (op, FLAG_BLOCKSVIEW))
1434 update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */ 1426 update_all_los (op->map, op->x, op->y); /* makes sure los will be recalculated */
1435 1427
1436 if (op->type == DOOR) 1428 if (op->type == DOOR)
1437 { 1429 {
1438 op->set_speed (0.1); 1430 op->set_speed (0.1f);
1439 op->speed_left = -0.05; 1431 op->speed_left = -0.05f;
1440 return maxdam; 1432 return maxdam;
1441 } 1433 }
1442 1434
1443 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) 1435 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER)
1444 { 1436 {
1493 else 1485 else
1494 new_draw_info_format (NDI_BLACK, 0, owner, "You killed %s.", query_name (op)); 1486 new_draw_info_format (NDI_BLACK, 0, owner, "You killed %s.", query_name (op));
1495 1487
1496 /* Only play sounds for melee kills */ 1488 /* Only play sounds for melee kills */
1497 if (hitter->type == PLAYER) 1489 if (hitter->type == PLAYER)
1498 play_sound_map (owner->map, owner->x, owner->y, SOUND_PLAYER_KILLS); 1490 owner->play_sound (sound_find ("player_kills"));
1499 } 1491 }
1500 1492
1501 /* If a player kills another player, not on 1493 /* If a player kills another player, not on
1502 * battleground, the "killer" looses 1 luck. Since this is 1494 * battleground, the "killer" looses 1 luck. Since this is
1503 * not reversible, it's actually quite a pain IMHO. -AV 1495 * not reversible, it's actually quite a pain IMHO. -AV
1562 skill = skop->skill; 1554 skill = skop->skill;
1563 1555
1564 new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf); 1556 new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf);
1565 1557
1566 /* If you didn't kill yourself, and your not the wizard */ 1558 /* If you didn't kill yourself, and your not the wizard */
1567 if (owner != op && !QUERY_FLAG (op, FLAG_WAS_WIZ)) 1559 if (owner != op && !QUERY_FLAG (op, FLAG_WIZ))
1568 { 1560 {
1569 int exp; 1561 int exp;
1570 1562
1571 /* Really don't give much experience for killing other players */ 1563 /* Really don't give much experience for killing other players */
1572 // schmorp: temporarily? reduce the amount of exp gained for pking enourmously 1564 // schmorp: temporarily? reduce the amount of exp gained for pking enourmously
1639 { 1631 {
1640 object *owner1 = op->owner; 1632 object *owner1 = op->owner;
1641 1633
1642 if (owner1 && owner1->type == PLAYER) 1634 if (owner1 && owner1->type == PLAYER)
1643 { 1635 {
1644 play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); 1636 owner1->contr->play_sound (sound_find ("pet_is_killed"));
1645 /* Maybe we should include the owner that killed this, maybe not */ 1637 /* 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); 1638 new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name);
1647 } 1639 }
1648 1640
1649 remove_friendly_object (op); 1641 remove_friendly_object (op);
1695 } 1687 }
1696 1688
1697 if (hitter->type == SPELL || hitter->type == POISONING || hitter->type == DISEASE || hitter->type == RUNE) 1689 if (hitter->type == SPELL || hitter->type == POISONING || hitter->type == DISEASE || hitter->type == RUNE)
1698 friendlyfire = 0; 1690 friendlyfire = 0;
1699 } 1691 }
1692
1700 return friendlyfire; 1693 return friendlyfire;
1701} 1694}
1702
1703 1695
1704/* This isn't used just for players, but in fact most objects. 1696/* This isn't used just for players, but in fact most objects.
1705 * op is the object to be hit, dam is the amount of damage, hitter 1697 * op is the object to be hit, dam is the amount of damage, hitter
1706 * is what is hitting the object, type is the attacktype, and 1698 * is what is hitting the object, type is the attacktype, and
1707 * full_hit is set if monster area does not matter. 1699 * full_hit is set if monster area does not matter.
1725 1717
1726 /* very simple: if our target has no_damage 1 set or is wiz, we can't hurt him */ 1718 /* very simple: if our target has no_damage 1 set or is wiz, we can't hurt him */
1727 if (QUERY_FLAG (op, FLAG_WIZ) || QUERY_FLAG (op, FLAG_NO_DAMAGE)) 1719 if (QUERY_FLAG (op, FLAG_WIZ) || QUERY_FLAG (op, FLAG_NO_DAMAGE))
1728 return 0; 1720 return 0;
1729 1721
1730#ifdef PROHIBIT_PLAYERKILL 1722 // only allow pk for hostile players
1731 if (op->type == PLAYER) 1723 if (op->type == PLAYER)
1732 { 1724 {
1733 object *owner = hitter->owner; 1725 object *owner = hitter->owner;
1734 1726
1735 if (!owner) 1727 if (!owner)
1739 && (!op_on_battleground (op, 0, 0) 1731 && (!op_on_battleground (op, 0, 0)
1740 && (op->contr->peaceful || owner->contr->peaceful)) 1732 && (op->contr->peaceful || owner->contr->peaceful))
1741 && op != owner) 1733 && op != owner)
1742 return 0; 1734 return 0;
1743 } 1735 }
1744#endif
1745 1736
1746 if (body_attack) 1737 if (body_attack)
1747 { 1738 {
1748 /* slow and paralyze must hit the head. But we don't want to just 1739 /* slow and paralyze must hit the head. But we don't want to just
1749 * return - we still need to process other attacks the spell still 1740 * return - we still need to process other attacks the spell still
1828 if ((!hitter->slaying || 1819 if ((!hitter->slaying ||
1829 (!(op->race && strstr (hitter->slaying, op->race)) && 1820 (!(op->race && strstr (hitter->slaying, op->race)) &&
1830 !(op->name && strstr (hitter->slaying, op->name)))) && 1821 !(op->name && strstr (hitter->slaying, op->name)))) &&
1831 (!QUERY_FLAG (op, FLAG_UNDEAD) || 1822 (!QUERY_FLAG (op, FLAG_UNDEAD) ||
1832 (hitter->title != NULL 1823 (hitter->title != NULL
1833 && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, undead_name) != NULL))) 1824 && (god = find_god (determine_god (hitter))) != NULL && god->race != NULL && strstr (god->race, shstr_undead) != NULL)))
1834 return 0; 1825 return 0;
1835 } 1826 }
1836 1827
1837 maxattacktype = type; /* initialise this to something */ 1828 maxattacktype = type; /* initialise this to something */
1838 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum) 1829 for (attacknum = 0; attacknum < NROFATTACKS; attacknum++, attacktype = 1 << attacknum)
1870 */ 1861 */
1871 friendlyfire = friendly_fire (op, hitter); 1862 friendlyfire = friendly_fire (op, hitter);
1872 if (friendlyfire && maxdam) 1863 if (friendlyfire && maxdam)
1873 { 1864 {
1874 maxdam = ((dam * settings.set_friendly_fire) / 100); 1865 maxdam = ((dam * settings.set_friendly_fire) / 100);
1875#ifndef COZY_SERVER
1876 maxdam++;
1877#endif
1878 1866
1879#ifdef ATTACK_DEBUG 1867#ifdef ATTACK_DEBUG
1880 LOG (llevDebug, "Friendly fire (type:%d setting: %d%) did %d damage dropped to %d\n", 1868 LOG (llevDebug, "Friendly fire (type:%d setting: %d%) did %d damage dropped to %d\n",
1881 friendlyfire, settings.set_friendly_fire, dam, maxdam); 1869 friendlyfire, settings.set_friendly_fire, dam, maxdam);
1882#endif 1870#endif
1883 } 1871 }
1884 1872
1885 if (!full_hit) 1873 if (!full_hit)
1886 { 1874 {
1887 archetype *at;
1888 int area; 1875 int area;
1889 int remainder; 1876 int remainder;
1890 1877
1891 area = 0; 1878 area = 0;
1892 for (at = op->arch; at != NULL; at = at->more) 1879
1880 for (archetype *at = op->arch; at; at = (archetype *)at->more)
1893 area++; 1881 area++;
1882
1894 assert (area > 0); 1883 assert (area > 0);
1895 1884
1896 /* basically: maxdam /= area; we try to "simulate" a float 1885 /* basically: maxdam /= area; we try to "simulate" a float
1897 value-effect */ 1886 value-effect */
1898 remainder = 100 * (maxdam % area) / area; 1887 remainder = 100 * (maxdam % area) / area;
1975 return maxdam; 1964 return maxdam;
1976 } 1965 }
1977 1966
1978 op->remove (); 1967 op->remove ();
1979 1968
1980 for (i = 0; i < NROFNEWOBJS (op); i++) 1969 for (i = 0; i < op->stats.food; i++)
1981 { /* This doesn't handle op->more yet */ 1970 { /* This doesn't handle op->more yet */
1982 object *tmp = arch_to_object (op->other_arch); 1971 object *tmp = arch_to_object (op->other_arch);
1983 int j; 1972 int j;
1984 1973
1985 tmp->stats.hp = op->stats.hp; 1974 tmp->stats.hp = op->stats.hp;
2012 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) 2001 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10)
2013 hitter->destroy (); 2002 hitter->destroy ();
2014 2003
2015 return maxdam; 2004 return maxdam;
2016} 2005}
2017
2018 2006
2019void 2007void
2020poison_player (object *op, object *hitter, int dam) 2008poison_player (object *op, object *hitter, int dam)
2021{ 2009{
2022 archetype *at = archetype::find ("poisoning"); 2010 archetype *at = archetype::find ("poisoning");
2058 tmp->stats.Dex = MAX (-(dam / 6 + 1), -10); 2046 tmp->stats.Dex = MAX (-(dam / 6 + 1), -10);
2059 tmp->stats.Int = MAX (-dam / 7, -10); 2047 tmp->stats.Int = MAX (-dam / 7, -10);
2060 SET_FLAG (tmp, FLAG_APPLIED); 2048 SET_FLAG (tmp, FLAG_APPLIED);
2061 op->update_stats (); 2049 op->update_stats ();
2062 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); 2050 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill.");
2051 op->play_sound (tmp->sound);
2063 } 2052 }
2053
2064 if (hitter->type == PLAYER) 2054 if (hitter->type == PLAYER)
2065 new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); 2055 new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name);
2066 else if (hitter->owner != NULL && hitter->owner->type == PLAYER) 2056 else if (hitter->owner != NULL && hitter->owner->type == PLAYER)
2067 new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); 2057 new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name);
2068 } 2058 }
2059
2069 tmp->speed_left = 0; 2060 tmp->speed_left = 0;
2070 } 2061 }
2071 else 2062 else
2072 tmp->stats.food++; 2063 tmp->stats.food++;
2073} 2064}
2077{ 2068{
2078 archetype *at = archetype::find ("slowness"); 2069 archetype *at = archetype::find ("slowness");
2079 object *tmp; 2070 object *tmp;
2080 2071
2081 if (at == NULL) 2072 if (at == NULL)
2082 {
2083 LOG (llevError, "Can't find slowness archetype.\n"); 2073 LOG (llevError, "Can't find slowness archetype.\n");
2084 } 2074
2085 if ((tmp = present_arch_in_ob (at, op)) == NULL) 2075 if ((tmp = present_arch_in_ob (at, op)) == NULL)
2086 { 2076 {
2087 tmp = arch_to_object (at); 2077 tmp = arch_to_object (at);
2088 tmp = insert_ob_in_ob (tmp, op); 2078 tmp = insert_ob_in_ob (tmp, op);
2089 new_draw_info (NDI_UNIQUE, 0, op, "The world suddenly moves very fast!"); 2079 new_draw_info (NDI_UNIQUE, 0, op, "The world suddenly moves very fast!");
2090 } 2080 }
2091 else 2081 else
2092 tmp->stats.food++; 2082 tmp->stats.food++;
2083
2093 SET_FLAG (tmp, FLAG_APPLIED); 2084 SET_FLAG (tmp, FLAG_APPLIED);
2094 tmp->speed_left = 0; 2085 tmp->speed_left = 0;
2095 op->update_stats (); 2086 op->update_stats ();
2096} 2087}
2097 2088
2114 tmp->speed = 0.05; 2105 tmp->speed = 0.05;
2115 tmp->subtype = FORCE_CONFUSION; 2106 tmp->subtype = FORCE_CONFUSION;
2116 tmp->duration = 8 + MAX (1, 5 * (100 - op->resist[ATNR_CONFUSION]) / 100); 2107 tmp->duration = 8 + MAX (1, 5 * (100 - op->resist[ATNR_CONFUSION]) / 100);
2117 tmp->name = "confusion"; 2108 tmp->name = "confusion";
2118 maxduration = MAX (2, 30 * (100 - op->resist[ATNR_CONFUSION]) / 100); 2109 maxduration = MAX (2, 30 * (100 - op->resist[ATNR_CONFUSION]) / 100);
2110
2119 if (tmp->duration > maxduration) 2111 if (tmp->duration > maxduration)
2120 tmp->duration = maxduration; 2112 tmp->duration = maxduration;
2121 2113
2122 if (op->type == PLAYER && !QUERY_FLAG (op, FLAG_CONFUSED)) 2114 if (op->type == PLAYER && !QUERY_FLAG (op, FLAG_CONFUSED))
2123 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very confused!"); 2115 new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very confused!");
2116
2124 SET_FLAG (op, FLAG_CONFUSED); 2117 SET_FLAG (op, FLAG_CONFUSED);
2125} 2118}
2126 2119
2127void 2120void
2128blind_player (object *op, object *hitter, int dam) 2121blind_player (object *op, object *hitter, int dam)
2211 ** field of the deathstriking object */ 2204 ** field of the deathstriking object */
2212 2205
2213 int atk_lev, def_lev, kill_lev; 2206 int atk_lev, def_lev, kill_lev;
2214 2207
2215 if (hitter->slaying) 2208 if (hitter->slaying)
2216 if (!((QUERY_FLAG (op, FLAG_UNDEAD) && strstr (hitter->slaying, undead_name)) || (op->race && strstr (hitter->slaying, op->race)))) 2209 if (!((QUERY_FLAG (op, FLAG_UNDEAD) && strstr (hitter->slaying, shstr_undead)) || (op->race && strstr (hitter->slaying, op->race))))
2217 return; 2210 return;
2218 2211
2219 def_lev = op->level; 2212 def_lev = op->level;
2220 if (def_lev < 1) 2213 if (def_lev < 1)
2221 { 2214 {
2222 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name); 2215 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->archname, &op->name);
2223 def_lev = 1; 2216 def_lev = 1;
2224 } 2217 }
2225 2218
2226 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; 2219 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2;
2227 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", 2220 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n",
2284 } 2277 }
2285 } 2278 }
2286} 2279}
2287 2280
2288/* adj_attackroll() - adjustments to attacks by various conditions */ 2281/* adj_attackroll() - adjustments to attacks by various conditions */
2289
2290int 2282int
2291adj_attackroll (object *hitter, object *target) 2283adj_attackroll (object *hitter, object *target)
2292{ 2284{
2293 object *attacker = hitter; 2285 object *attacker = hitter;
2294 int adjust = 0; 2286 int adjust = 0;
2368 2360
2369 /* I broke what used to be one big if into a few nested 2361 /* I broke what used to be one big if into a few nested
2370 * ones so that figuring out the logic is at least possible. 2362 * ones so that figuring out the logic is at least possible.
2371 */ 2363 */
2372 if (op && (op->move_type & MOVE_FLYING)) 2364 if (op && (op->move_type & MOVE_FLYING))
2373 {
2374 if (op->type == ARROW || op->type == THROWN_OBJ) 2365 if (op->type == ARROW || op->type == THROWN_OBJ)
2375 return 1; 2366 return 1;
2376 else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION)) 2367 else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION))
2377 return 1; 2368 return 1;
2378 }
2379 2369
2380 return 0; 2370 return 0;
2381} 2371}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines