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.21 by root, Thu Sep 21 18:58:39 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines