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.20 by root, Tue Sep 19 10:35:22 2006 UTC vs.
Revision 1.24 by root, Sat Dec 9 16:11:09 2006 UTC

929object * 929object *
930hit_with_arrow (object *op, object *victim) 930hit_with_arrow (object *op, object *victim)
931{ 931{
932 object *container, *hitter; 932 object *container, *hitter;
933 int hit_something = 0; 933 int hit_something = 0;
934 sint16 victim_x, victim_y;
935 934
936 /* Disassemble missile */ 935 /* Disassemble missile */
937 if (op->inv) 936 if (op->inv)
938 { 937 {
939 container = op; 938 container = op;
945 * removed at the end of this function must be able to deal with empty 944 * removed at the end of this function must be able to deal with empty
946 * THROWN_OBJs. */ 945 * THROWN_OBJs. */
947 } 946 }
948 else 947 else
949 { 948 {
950 container = NULL; 949 container = 0;
951 hitter = op; 950 hitter = op;
952 } 951 }
953 952
954 /* Try to hit victim */ 953 /* Try to hit victim */
955 victim_x = victim->x;
956 victim_y = victim->y;
957
958 hit_something = attack_ob_simple (victim, hitter, op->stats.dam, op->stats.wc); 954 hit_something = attack_ob_simple (victim, hitter, op->stats.dam, op->stats.wc);
959 955
960 /* Arrow attacks door, rune of summoning is triggered, demon is put on 956 /* Arrow attacks door, rune of summoning is triggered, demon is put on
961 * arrow, move_apply() calls this function, arrow sticks in demon, 957 * arrow, move_apply() calls this function, arrow sticks in demon,
962 * attack_ob_simple() returns, and we've got an arrow that still exists 958 * attack_ob_simple() returns, and we've got an arrow that still exists
968 if (container) 964 if (container)
969 { 965 {
970 remove_ob (container); 966 remove_ob (container);
971 free_object (container); 967 free_object (container);
972 } 968 }
969
973 return NULL; 970 return 0;
974 } 971 }
975 972
976 /* Missile hit victim */ 973 /* Missile hit victim */
977 /* if the speed is > 10, then this is a fast moving arrow, we go straight 974 /* if the speed is > 10, then this is a fast moving arrow, we go straight
978 * through the target 975 * through the target
979 */ 976 */
980 if (hit_something && op->speed <= 10.0) 977 if (hit_something && op->speed <= 10.0)
981 { 978 {
982 /* Stop arrow */ 979 /* Stop arrow */
983 if (container == NULL) 980 if (!container)
984 { 981 {
985 hitter = fix_stopped_arrow (hitter); 982 hitter = fix_stopped_arrow (hitter);
986 if (hitter == NULL) 983 if (!hitter)
987 return NULL; 984 return 0;
988 } 985 }
989 else 986 else
990 { 987 {
991 remove_ob (container); 988 remove_ob (container);
992 free_object (container); 989 free_object (container);
993 } 990 }
994 991
995 /* Try to stick arrow into victim */ 992 /* Try to stick arrow into victim */
996 if (!victim->destroyed () && stick_arrow (hitter, victim)) 993 if (!victim->destroyed () && stick_arrow (hitter, victim))
997 return NULL; 994 return 0;
998 995
999 /* Else try to put arrow on victim's map square 996 /* Else try to put arrow on victim's map square
1000 * remove check for P_WALL here. If the arrow got to this 997 * remove check for P_WALL here. If the arrow got to this
1001 * space, that is good enough - with the new movement code, 998 * space, that is good enough - with the new movement code,
1002 * there is now the potential for lots of spaces where something 999 * there is now the potential for lots of spaces where something
1003 * can fly over but not otherwise move over. What is the correct 1000 * can fly over but not otherwise move over. What is the correct
1004 * way to handle those otherwise? 1001 * way to handle those otherwise?
1005 */ 1002 */
1006 if (victim_x != hitter->x || victim_y != hitter->y) 1003 if (victim->x != hitter->x || victim->y != hitter->y)
1007 { 1004 {
1008 remove_ob (hitter); 1005 remove_ob (hitter);
1009 hitter->x = victim_x; 1006 hitter->x = victim->x;
1010 hitter->y = victim_y; 1007 hitter->y = victim->y;
1011 insert_ob_in_map (hitter, victim->map, hitter, 0); 1008 insert_ob_in_map (hitter, victim->map, hitter, 0);
1012 } 1009 }
1013 else 1010 else
1014 {
1015 /* Else leave arrow where it is */ 1011 /* Else leave arrow where it is */
1016 merge_ob (hitter, NULL); 1012 merge_ob (hitter, NULL);
1017 } 1013
1018 return NULL; 1014 return 0;
1019 } 1015 }
1020 1016
1021 if (hit_something && op->speed >= 10.0) 1017 if (hit_something && op->speed >= 10.0)
1022 op->speed -= 1.0; 1018 op->speed -= 1.0;
1023 1019
1025 if (container) 1021 if (container)
1026 { 1022 {
1027 remove_ob (hitter); 1023 remove_ob (hitter);
1028 insert_ob_in_ob (hitter, container); 1024 insert_ob_in_ob (hitter, container);
1029 } 1025 }
1026
1030 return op; 1027 return op;
1031} 1028}
1032 1029
1033 1030
1034void 1031void
1453 } 1450 }
1454 1451
1455 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) 1452 if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER)
1456 { 1453 {
1457 remove_friendly_object (op); 1454 remove_friendly_object (op);
1455
1458 if (get_owner (op) && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op) 1456 if (get_owner (op) && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op)
1459 {
1460 op->owner->contr->ranges[range_golem] = 0; 1457 op->owner->contr->ranges[range_golem] = 0;
1461 op->owner->contr->golem_count = 0;
1462 }
1463 1458
1464 remove_ob (op); 1459 remove_ob (op);
1465 free_object (op); 1460 free_object (op);
1466 return maxdam; 1461 return maxdam;
1467 } 1462 }
1615 1610
1616 if (!settings.simple_exp) 1611 if (!settings.simple_exp)
1617 exp = exp / 2; 1612 exp = exp / 2;
1618 1613
1619 if (owner->type != PLAYER || owner->contr->party == NULL) 1614 if (owner->type != PLAYER || owner->contr->party == NULL)
1620 {
1621 change_exp (owner, exp, skill, 0); 1615 change_exp (owner, exp, skill, 0);
1622 }
1623 else 1616 else
1624 { 1617 {
1625 int shares = 0, count = 0; 1618 int shares = 0, count = 0;
1626 player *pl; 1619 player *pl;
1627 partylist *party = owner->contr->party; 1620 partylist *party = owner->contr->party;
1634 { 1627 {
1635 count++; 1628 count++;
1636 shares += (pl->ob->level + 4); 1629 shares += (pl->ob->level + 4);
1637 } 1630 }
1638 1631
1639 if (count == 1 || shares > exp) 1632 if (count == 1 || shares > exp || !shares)
1640 change_exp (owner, exp, skill, SK_EXP_TOTAL); 1633 change_exp (owner, exp, skill, SK_EXP_TOTAL);
1641 else 1634 else
1642 { 1635 {
1643 int share = exp / shares, given = 0, nexp; 1636 int share = exp / shares, given = 0, nexp;
1644 1637
1678 } 1671 }
1679 else 1672 else
1680 { 1673 {
1681 /* Player has been killed! */ 1674 /* Player has been killed! */
1682 if (owner->type == PLAYER) 1675 if (owner->type == PLAYER)
1683 snprintf (op->contr->killer, BIG_NAME, "%s the %s", &owner->name, owner->contr->title); 1676 snprintf (op->contr->killer, sizeof (op->contr->killer), "%s the %s", &owner->name, owner->contr->title);
1684 else 1677 else
1685 assign (op->contr->killer, hitter->name); 1678 assign (op->contr->killer, hitter->name);
1686 } 1679 }
1687 1680
1688 /* This was return -1 - that doesn't seem correct - if we return -1, process 1681 /* This was return -1 - that doesn't seem correct - if we return -1, process

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines