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.48 by root, Thu Jan 18 22:20:00 2007 UTC vs.
Revision 1.60 by root, Mon Apr 30 04:43:46 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 * 7 *
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>
29
30#ifndef __CEXTRACT__
31# include <sproto.h>
32#endif
33
34#include <sounds.h> 29#include <sounds.h>
30#include <sproto.h>
35 31
36typedef struct att_msg_str 32typedef struct att_msg_str
37{ 33{
38 char *msg1; 34 char *msg1;
39 char *msg2; 35 char *msg2;
84 materialtype_t *mt; 80 materialtype_t *mt;
85 81
86 if (op->materialname == NULL) 82 if (op->materialname == NULL)
87 { 83 {
88 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) 84 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next)
89 if (op->material & mt->material) 85 if (op->materials & mt->material)
90 break; 86 break;
91 } 87 }
92 else 88 else
93 mt = name_to_material (op->materialname); 89 mt = name_to_material (op->materialname);
94 90
271 * op is going in direction 'dir' 267 * op is going in direction 'dir'
272 * type is the attacktype of the object. 268 * type is the attacktype of the object.
273 * full_hit is set if monster area does not matter. 269 * full_hit is set if monster area does not matter.
274 * returns 1 if it hits something, 0 otherwise. 270 * returns 1 if it hits something, 0 otherwise.
275 */ 271 */
276
277int 272int
278hit_map (object *op, int dir, int type, int full_hit) 273hit_map (object *op, int dir, int type, int full_hit)
279{ 274{
280 maptile *map; 275 maptile *map;
281 sint16 x, y; 276 sint16 x, y;
314 mapspace &ms = map->at (x, y); 309 mapspace &ms = map->at (x, y);
315 310
316 if (ms.flags () & P_SAFE) 311 if (ms.flags () & P_SAFE)
317 return 0; 312 return 0;
318 313
319 /* peterm: a few special cases for special attacktypes --counterspell 314 /* peterm: a few special cases for special attacktypes --counterspell
320 * must be out here because it strikes things which are not alive 315 * must be out here because it strikes things which are not alive
321 */ 316 */
322 if (type & (AT_COUNTERSPELL | AT_CHAOS)) 317 if (type & (AT_COUNTERSPELL | AT_CHAOS))
323 { 318 {
324 if (type & AT_COUNTERSPELL) 319 if (type & AT_COUNTERSPELL)
375 * that weak walls have is_alive set, which prevent objects from 370 * that weak walls have is_alive set, which prevent objects from
376 * passing over/through them. We don't care what type of movement 371 * passing over/through them. We don't care what type of movement
377 * the wall blocks - if it blocks any type of movement, can't be 372 * the wall blocks - if it blocks any type of movement, can't be
378 * destroyed right now. 373 * destroyed right now.
379 */ 374 */
380 else if ((tmp->material || tmp->materialname) && op->stats.dam > 0 && !tmp->move_block) 375 else if (tmp->materialname && op->stats.dam > 0 && !tmp->move_block)
381 { 376 {
382 save_throw_object (tmp, type, op); 377 save_throw_object (tmp, type, op);
383 378
384 if (op->destroyed ()) 379 if (op->destroyed ())
385 break; 380 break;
654 { 649 {
655 i = 4; 650 i = 4;
656 map = hitter->map; 651 map = hitter->map;
657 if (out_of_map (map, hitter->x, hitter->y)) 652 if (out_of_map (map, hitter->x, hitter->y))
658 return; 653 return;
654
659 next = GET_MAP_OB (map, hitter->x, hitter->y); 655 next = GET_MAP_OB (map, hitter->x, hitter->y);
660 if (next) 656 if (next)
661 while (next) 657 while (next)
662 { 658 {
663 if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) 659 if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE))
664 i *= 3; 660 i *= 3;
665 tmp = next; 661 tmp = next;
666 next = tmp->above; 662 next = tmp->above;
667 } 663 }
664
668 if (i < 0) 665 if (i < 0)
669 return; 666 return;
667
670 if (rndm (0, i) != 0) 668 if (rndm (0, i) != 0)
671 return; 669 return;
672 } 670 }
673 else if (rndm (0, 5) != 0) 671 else if (rndm (0, 5) != 0)
674 return; 672 return;
673
675 sprintf (buf, "Your %s%s %s.", &hitter->name, buf2, &op->name); 674 sprintf (buf, "Your %s%s %s.", &hitter->name, buf2, &op->name);
676 play_sound_map (op->map, op->x, op->y, SOUND_PLAYER_HITS4); 675 play_sound_map (op->map, op->x, op->y, SOUND_PLAYER_HITS4);
677 new_draw_info (NDI_BLACK, 0, hitter->owner, buf); 676 new_draw_info (NDI_BLACK, 0, hitter->owner, buf);
678 } 677 }
679} 678}
774 { 773 {
775 int hitdam = base_dam; 774 int hitdam = base_dam;
776 775
777 if (settings.casting_time == TRUE) 776 if (settings.casting_time == TRUE)
778 { 777 {
779 if ((hitter->type == PLAYER) && (hitter->casting_time > -1)) 778 if (hitter->type == PLAYER && hitter->casting_time > -1)
780 { 779 {
781 hitter->casting_time = -1; 780 hitter->casting_time = -1;
782 new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost your spell!"); 781 new_draw_info (NDI_UNIQUE, 0, hitter, "You attacked and lost your spell!");
783 } 782 }
783
784 if ((op->casting_time > -1) && (hitdam > 0)) 784 if (op->casting_time > -1 && hitdam > 0)
785 { 785 {
786 op->casting_time = -1; 786 op->casting_time = -1;
787 if (op->type == PLAYER) 787 if (op->type == PLAYER)
788 { 788 {
789 new_draw_info (NDI_UNIQUE, 0, op, "You were hit and lost your spell!"); 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); 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 } 791 }
792 } 792 }
793 } 793 }
794
794 if (!simple_attack) 795 if (!simple_attack)
795 { 796 {
796 /* If you hit something, the victim should *always* wake up. 797 /* If you hit something, the victim should *always* wake up.
797 * Before, invisible hitters could avoid doing this. 798 * Before, invisible hitters could avoid doing this.
798 * -b.t. */ 799 * -b.t. */
806 807
807 /* if you were hidden and hit by a creature, you are discovered */ 808 /* if you were hidden and hit by a creature, you are discovered */
808 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) 809 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE))
809 { 810 {
810 make_visible (op); 811 make_visible (op);
812
811 if (op->type == PLAYER) 813 if (op->type == PLAYER)
812 new_draw_info (NDI_UNIQUE, 0, op, "You were hit by a wild attack. " "You are no longer hidden!"); 814 new_draw_info (NDI_UNIQUE, 0, op, "You were hit by a wild attack. " "You are no longer hidden!");
813 } 815 }
814 816
815 /* thrown items (hitter) will have various effects 817 /* thrown items (hitter) will have various effects
869} 871}
870 872
871int 873int
872attack_ob (object *op, object *hitter) 874attack_ob (object *op, object *hitter)
873{ 875{
874
875 if (hitter->head)
876 hitter = hitter->head; 876 hitter = hitter->head_ ();
877
877 return attack_ob_simple (op, hitter, hitter->stats.dam, hitter->stats.wc); 878 return attack_ob_simple (op, hitter, hitter->stats.dam, hitter->stats.wc);
878} 879}
879 880
880/* op is the arrow, tmp is what is stopping the arrow. 881/* op is the arrow, tmp is what is stopping the arrow.
881 * 882 *
890 * debate - 5000 is 5 kg, so arrows, knives, and other light weapons 891 * debate - 5000 is 5 kg, so arrows, knives, and other light weapons
891 * stick around. 892 * stick around.
892 */ 893 */
893 if (op->weight <= 5000 && tmp->stats.hp >= 0) 894 if (op->weight <= 5000 && tmp->stats.hp >= 0)
894 { 895 {
895 if (tmp->head != NULL)
896 tmp = tmp->head; 896 tmp = tmp->head_ ();
897 897
898 op->remove (); 898 op->remove ();
899 op = insert_ob_in_ob (op, tmp); 899 op = insert_ob_in_ob (op, tmp);
900 900
901 if (tmp->type == PLAYER) 901 if (tmp->type == PLAYER)
1008 insert_ob_in_ob (hitter, container); 1008 insert_ob_in_ob (hitter, container);
1009 } 1009 }
1010 1010
1011 return op; 1011 return op;
1012} 1012}
1013
1014 1013
1015void 1014void
1016tear_down_wall (object *op) 1015tear_down_wall (object *op)
1017{ 1016{
1018 int perc = 0; 1017 int perc = 0;
1067 SET_FLAG (target, FLAG_SCARED); 1066 SET_FLAG (target, FLAG_SCARED);
1068 if (!target->enemy) 1067 if (!target->enemy)
1069 target->enemy = owner; 1068 target->enemy = owner;
1070} 1069}
1071 1070
1072
1073/* This returns the amount of damage hitter does to op with the 1071/* This returns the amount of damage hitter does to op with the
1074 * appropriate attacktype. Only 1 attacktype should be set at a time. 1072 * appropriate attacktype. Only 1 attacktype should be set at a time.
1075 * This doesn't damage the player, but returns how much it should 1073 * This doesn't damage the player, but returns how much it should
1076 * take. However, it will do other effects (paralyzation, slow, etc.) 1074 * take. However, it will do other effects (paralyzation, slow, etc.)
1077 * Note - changed for PR code - we now pass the attack number and not 1075 * Note - changed for PR code - we now pass the attack number and not
1099 if (attacknum == ATNR_INTERNAL) 1097 if (attacknum == ATNR_INTERNAL)
1100 return dam; 1098 return dam;
1101 1099
1102 if (hitter->slaying) 1100 if (hitter->slaying)
1103 { 1101 {
1104 if (((op->race != NULL) && strstr (hitter->slaying, op->race)) || 1102 if ((op->race && strstr (hitter->slaying, op->race))
1105 (op->arch && (op->arch->name != NULL) && strstr (op->arch->name, hitter->slaying))) 1103 || (op->arch && op->arch->name && strstr (op->arch->name, hitter->slaying)))
1106 { 1104 {
1107 doesnt_slay = 0; 1105 doesnt_slay = 0;
1108 dam *= 3; 1106 dam *= 3;
1109 } 1107 }
1110 } 1108 }
1124 /* Special hack. By default, if immune to something, you 1122 /* Special hack. By default, if immune to something, you
1125 * shouldn't need to worry. However, acid is an exception, since 1123 * shouldn't need to worry. However, acid is an exception, since
1126 * it can still damage your items. Only include attacktypes if 1124 * it can still damage your items. Only include attacktypes if
1127 * special processing is needed */ 1125 * special processing is needed */
1128 1126
1129 if ((op->resist[attacknum] >= 100) && doesnt_slay && (attacknum != ATNR_ACID)) 1127 if (op->resist[attacknum] >= 100
1128 && doesnt_slay
1129 && attacknum != ATNR_ACID)
1130 return 0; 1130 return 0;
1131 1131
1132 /* Keep this in order - makes things easier to find */ 1132 /* Keep this in order - makes things easier to find */
1133 1133
1134 switch (attacknum) 1134 switch (attacknum)
1184 else if (attacknum == ATNR_DEPLETE) 1184 else if (attacknum == ATNR_DEPLETE)
1185 op->drain_stat (); 1185 op->drain_stat ();
1186 else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR)) 1186 else if (attacknum == ATNR_BLIND && !QUERY_FLAG (op, FLAG_UNDEAD) && !QUERY_FLAG (op, FLAG_GENERATOR))
1187 blind_player (op, hitter, dam); 1187 blind_player (op, hitter, dam);
1188 } 1188 }
1189
1189 dam = 0; /* These are all effects and don't do real damage */ 1190 dam = 0; /* These are all effects and don't do real damage */
1190 } 1191 }
1191 break; 1192 break;
1192 1193
1193 case ATNR_ACID: 1194 case ATNR_ACID:
1203 if (tmp->invisible) 1204 if (tmp->invisible)
1204 continue; 1205 continue;
1205 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10)) 1206 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || (tmp->resist[ATNR_ACID] >= 10))
1206 /* >= 10% acid res. on items will protect these */ 1207 /* >= 10% acid res. on items will protect these */
1207 continue; 1208 continue;
1208 if (!(tmp->material & M_IRON)) 1209 if (!(tmp->materials & M_IRON))
1209 continue; 1210 continue;
1210 if (tmp->magic < -4) /* Let's stop at -5 */ 1211 if (tmp->magic < -4) /* Let's stop at -5 */
1211 continue; 1212 continue;
1212 if (tmp->type == RING 1213 if (tmp->type == RING
1213 /* removed boots and gloves from exclusion list in PR */ 1214 /* removed boots and gloves from exclusion list in PR */
1282 if (op->type != PLAYER || owner->type != PLAYER) 1283 if (op->type != PLAYER || owner->type != PLAYER)
1283 change_exp (owner, op->stats.exp / (rate * 2), 1284 change_exp (owner, op->stats.exp / (rate * 2),
1284 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL); 1285 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, SK_EXP_TOTAL);
1285 } 1286 }
1286 else if (op->type != PLAYER || hitter->type != PLAYER) 1287 else if (op->type != PLAYER || hitter->type != PLAYER)
1287 {
1288 change_exp (hitter, op->stats.exp / (rate * 2), 1288 change_exp (hitter, op->stats.exp / (rate * 2),
1289 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0); 1289 hitter->chosen_skill ? hitter->chosen_skill->skill : (const char *) 0, 0);
1290 } 1290
1291 change_exp (op, -op->stats.exp / rate, NULL, 0); 1291 change_exp (op, -op->stats.exp / rate, NULL, 0);
1292 } 1292 }
1293 1293
1294 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure 1294 dam = 1; /* Drain is an effect. Still return 1 - otherwise, if you have pure
1295 * drain attack, you won't know that you are actually sucking out EXP, 1295 * drain attack, you won't know that you are actually sucking out EXP,
1309 1309
1310 /* if undead are not an enemy of your god, you turn them 1310 /* if undead are not an enemy of your god, you turn them
1311 * at half strength */ 1311 * at half strength */
1312 if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL) 1312 if (!god || !god->slaying || strstr (god->slaying, undead_name) == NULL)
1313 div = 2; 1313 div = 2;
1314
1314 /* Give a bonus if you resist turn undead */ 1315 /* Give a bonus if you resist turn undead */
1315 if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100))) 1316 if (op->level * div < (turn_bonus[owner->stats.Wis] + owner->level + (op->resist[ATNR_TURN_UNDEAD] / 100)))
1316 scare_creature (op, owner); 1317 scare_creature (op, owner);
1317 } 1318 }
1318 else 1319 else
1438 return maxdam; 1439 return maxdam;
1439 } 1440 }
1440 1441
1441 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) 1442 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER)
1442 { 1443 {
1443 remove_friendly_object (op);
1444
1445 if (op->owner && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op)
1446 op->owner->contr->ranges[range_golem] = 0;
1447
1448 op->destroy (); 1444 op->destroy ();
1449 return maxdam; 1445 return maxdam;
1450 } 1446 }
1451 1447
1452 /* Now lets start dealing with experience we get for killing something */ 1448 /* Now lets start dealing with experience we get for killing something */
1529 skill = owner->current_weapon->skill; 1525 skill = owner->current_weapon->skill;
1530 else 1526 else
1531 LOG (llevError, "kill_object - unable to find skill that killed monster\n"); 1527 LOG (llevError, "kill_object - unable to find skill that killed monster\n");
1532 1528
1533 /* We have the skill we want to credit to - now find the object this goes 1529 /* We have the skill we want to credit to - now find the object this goes
1534 * to. Make sure skop is an actual skill, and not a skill tool! 1530 * to. Make sure skop is an actual skill, and not a skill tool!
1535 */ 1531 */
1536 if ((!skop || skop->type != SKILL) && skill) 1532 if ((!skop || skop->type != SKILL) && skill)
1537 { 1533 {
1538 int i; 1534 int i;
1539 1535
1602 if (owner->type != PLAYER || owner->contr->party == NULL) 1598 if (owner->type != PLAYER || owner->contr->party == NULL)
1603 change_exp (owner, exp, skill, 0); 1599 change_exp (owner, exp, skill, 0);
1604 else 1600 else
1605 { 1601 {
1606 int shares = 0, count = 0; 1602 int shares = 0, count = 0;
1607 player *pl;
1608 partylist *party = owner->contr->party; 1603 partylist *party = owner->contr->party;
1609 1604
1610 add_kill_to_party (party, query_name (owner), query_name (op), exp); 1605 add_kill_to_party (party, query_name (owner), query_name (op), exp);
1611 1606
1612 for_all_players (pl) 1607 for_all_players (pl)
1671} 1666}
1672 1667
1673/* Find out if this is friendly fire (PVP and attacker is peaceful) or not 1668/* Find out if this is friendly fire (PVP and attacker is peaceful) or not
1674 * Returns 0 this is not friendly fire 1669 * Returns 0 this is not friendly fire
1675 */ 1670 */
1676
1677int 1671int
1678friendly_fire (object *op, object *hitter) 1672friendly_fire (object *op, object *hitter)
1679{ 1673{
1680 object *owner; 1674 object *owner;
1681 int friendlyfire; 1675 int friendlyfire;
1738 object *owner = hitter->owner; 1732 object *owner = hitter->owner;
1739 1733
1740 if (!owner) 1734 if (!owner)
1741 owner = hitter; 1735 owner = hitter;
1742 1736
1743 if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner) 1737 if (owner->type == PLAYER
1738 && (!op_on_battleground (op, 0, 0)
1739 && (op->contr->peaceful || owner->contr->peaceful))
1740 && op != owner)
1744 return 0; 1741 return 0;
1745 } 1742 }
1746#endif 1743#endif
1747 1744
1748 if (body_attack) 1745 if (body_attack)
1782 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) 1779 if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0)
1783 { 1780 {
1784 /* FIXME: If a player is killed by a rune in a door, the 1781 /* FIXME: If a player is killed by a rune in a door, the
1785 * destroyed() check above doesn't return, and might get here. 1782 * destroyed() check above doesn't return, and might get here.
1786 */ 1783 */
1784
1785 /* FIXME: This for example happens when a dead door is on a mover and
1786 gets it's speed_left raised on each mover-tick.
1787 Doors are removed in a kinda funny way by giving them speed and speed_left
1788 and waiting for that to run out.
1789 */
1787 LOG (llevDebug, "victim %s already dead in hit_player()\n", op->debug_desc ()); 1790 LOG (llevDebug, "victim %s (%d) already dead in hit_player()\n", op->debug_desc (), op->stats.hp);
1788 return 0; 1791 return 0;
1789 } 1792 }
1790 1793
1791#ifdef ATTACK_DEBUG 1794#ifdef ATTACK_DEBUG
1792 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam); 1795 LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam);
1899 1902
1900#ifdef ATTACK_DEBUG 1903#ifdef ATTACK_DEBUG
1901 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); 1904 LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam);
1902#endif 1905#endif
1903 1906
1907 // for now, only do this for active objects, otherwise they
1908 // keep a refcount for a long time and I see no usefulness
1909 // for an non-active objetc to know its enemy.
1910 if (op->active)
1904 if (hitter->owner) 1911 if (hitter->owner)
1905 op->enemy = hitter->owner; 1912 op->enemy = hitter->owner;
1906 else if (QUERY_FLAG (hitter, FLAG_ALIVE)) 1913 else if (QUERY_FLAG (hitter, FLAG_ALIVE))
1907 op->enemy = hitter; 1914 op->enemy = hitter;
1908 1915
1909 if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) 1916 if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER)
1910 { 1917 {
1911 /* The unaggressives look after themselves 8) */ 1918 /* The unaggressives look after themselves 8) */
1912 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE); 1919 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE);
1949 /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note 1956 /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note
1950 * that before if the player was immune to ghosthit, the monster 1957 * that before if the player was immune to ghosthit, the monster
1951 * remained - that is no longer the case. 1958 * remained - that is no longer the case.
1952 */ 1959 */
1953 if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) 1960 if (QUERY_FLAG (hitter, FLAG_ONE_HIT))
1954 {
1955 if (QUERY_FLAG (hitter, FLAG_FRIENDLY))
1956 remove_friendly_object (hitter);
1957
1958 hitter->destroy (); 1961 hitter->destroy ();
1959 } 1962
1960 /* Lets handle creatures that are splitting now */ 1963 /* Lets handle creatures that are splitting now */
1961 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) 1964 else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING))
1962 { 1965 {
1963 int i; 1966 int i;
1964 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); 1967 int friendly = QUERY_FLAG (op, FLAG_FRIENDLY);
2190 op->speed_left = (float) -(FABS (op->speed) * max); 2193 op->speed_left = (float) -(FABS (op->speed) * max);
2191 2194
2192/* tmp->stats.food = (signed short) (max/FABS(op->speed)); */ 2195/* tmp->stats.food = (signed short) (max/FABS(op->speed)); */
2193} 2196}
2194 2197
2195
2196/* Attempts to kill 'op'. hitter is the attack object, dam is 2198/* Attempts to kill 'op'. hitter is the attack object, dam is
2197 * the computed damaged. 2199 * the computed damaged.
2198 */ 2200 */
2199void 2201void
2200deathstrike_player (object *op, object *hitter, int *dam) 2202deathstrike_player (object *op, object *hitter, int *dam)
2217 if (def_lev < 1) 2219 if (def_lev < 1)
2218 { 2220 {
2219 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name); 2221 LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name);
2220 def_lev = 1; 2222 def_lev = 1;
2221 } 2223 }
2224
2222 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; 2225 atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2;
2223 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", 2226 /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n",
2224 atk_lev, def_lev); */ 2227 atk_lev, def_lev); */
2225 2228
2226 if (atk_lev >= def_lev) 2229 if (atk_lev >= def_lev)
2241 */ 2244 */
2242 *dam *= kill_lev / def_lev; 2245 *dam *= kill_lev / def_lev;
2243 } 2246 }
2244 } 2247 }
2245 else 2248 else
2246 {
2247 *dam = 0; /* no harm done */ 2249 *dam = 0; /* no harm done */
2248 }
2249} 2250}
2250 2251
2251/* thrown_item_effect() - handles any special effects of thrown 2252/* thrown_item_effect() - handles any special effects of thrown
2252 * items (like attacking living creatures--a potion thrown at a 2253 * items (like attacking living creatures--a potion thrown at a
2253 * monster). 2254 * monster).
2357#endif 2358#endif
2358 2359
2359 return adjust; 2360 return adjust;
2360} 2361}
2361 2362
2362
2363/* determine if the object is an 'aimed' missile */ 2363/* determine if the object is an 'aimed' missile */
2364int 2364int
2365is_aimed_missile (object *op) 2365is_aimed_missile (object *op)
2366{ 2366{
2367 2367
2373 if (op->type == ARROW || op->type == THROWN_OBJ) 2373 if (op->type == ARROW || op->type == THROWN_OBJ)
2374 return 1; 2374 return 1;
2375 else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION)) 2375 else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION))
2376 return 1; 2376 return 1;
2377 } 2377 }
2378
2378 return 0; 2379 return 0;
2379} 2380}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines