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.95 by root, Mon Sep 29 10:31:32 2008 UTC vs.
Revision 1.101 by root, Fri Dec 26 13:33:22 2008 UTC

780 * for help. */ 780 * for help. */
781 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int)) 781 if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int))
782 npc_call_help (op); 782 npc_call_help (op);
783 783
784 /* if you were hidden and hit by a creature, you are discovered */ 784 /* if you were hidden and hit by a creature, you are discovered */
785 if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) 785 if (op->flag [FLAG_HIDDEN] && hitter->flag [FLAG_ALIVE])
786 { 786 {
787 make_visible (op); 787 make_visible (op);
788 788
789 if (op->type == PLAYER) 789 if (op->type == PLAYER)
790 new_draw_info (NDI_UNIQUE, 0, op, "You were hit by a wild attack. " "You are no longer hidden!"); 790 new_draw_info (NDI_UNIQUE, 0, op, "You were hit by a wild attack. " "You are no longer hidden!");
891 /* Disassemble missile */ 891 /* Disassemble missile */
892 if (op->inv) 892 if (op->inv)
893 { 893 {
894 container = op; 894 container = op;
895 hitter = op->inv; 895 hitter = op->inv;
896 container->insert_at (hitter, hitter, INS_NO_MERGE | INS_NO_WALK_ON); 896 hitter->insert_at (container, hitter, INS_NO_MERGE | INS_NO_WALK_ON);
897 /* Note that we now have an empty THROWN_OBJ on the map. Code that 897 /* Note that we now have an empty THROWN_OBJ on the map. Code that
898 * might be called until this THROWN_OBJ is either reassembled or 898 * might be called until this THROWN_OBJ is either reassembled or
899 * removed at the end of this function must be able to deal with empty 899 * removed at the end of this function must be able to deal with empty
900 * THROWN_OBJs. */ 900 * THROWN_OBJs. */
901 } 901 }
915 * other places as well!) 915 * other places as well!)
916 */ 916 */
917 if (hitter->destroyed () || hitter->env != NULL) 917 if (hitter->destroyed () || hitter->env != NULL)
918 { 918 {
919 if (container) 919 if (container)
920 container->destroy (true); 920 container->destroy ();
921 921
922 return 0; 922 return 0;
923 } 923 }
924 924
925 /* Missile hit victim */ 925 /* Missile hit victim */
934 hitter = fix_stopped_arrow (hitter); 934 hitter = fix_stopped_arrow (hitter);
935 if (!hitter) 935 if (!hitter)
936 return 0; 936 return 0;
937 } 937 }
938 else 938 else
939 container->destroy (true); 939 container->destroy ();
940 940
941 /* Try to stick arrow into victim */ 941 /* Try to stick arrow into victim */
942 if (!victim->destroyed () && stick_arrow (hitter, victim)) 942 if (!victim->destroyed () && stick_arrow (hitter, victim))
943 return 0; 943 return 0;
944 944
949 * can fly over but not otherwise move over. What is the correct 949 * can fly over but not otherwise move over. What is the correct
950 * way to handle those otherwise? 950 * way to handle those otherwise?
951 */ 951 */
952 if (victim->x != hitter->x || victim->y != hitter->y) 952 if (victim->x != hitter->x || victim->y != hitter->y)
953 { 953 {
954 if (victim->destroyed ())
955 hitter->destroy ();
956 else
957 {
954 hitter->remove (); 958 hitter->remove ();
955 hitter->x = victim->x; 959 hitter->x = victim->x;
956 hitter->y = victim->y; 960 hitter->y = victim->y;
957 insert_ob_in_map (hitter, victim->map, hitter, 0); 961 insert_ob_in_map (hitter, victim->map, hitter, 0);
962 }
958 } 963 }
959 else 964 else
960 /* Else leave arrow where it is */ 965 /* Else leave arrow where it is */
961 merge_ob (hitter, NULL); 966 merge_ob (hitter, NULL);
962 967
988 } 993 }
989 else if (!GET_ANIM_ID (op)) 994 else if (!GET_ANIM_ID (op))
990 { 995 {
991 /* Object has been called - no animations, so remove it */ 996 /* Object has been called - no animations, so remove it */
992 if (op->stats.hp < 0) 997 if (op->stats.hp < 0)
993 op->destroy (true); 998 op->destroy ();
994 999
995 return; /* no animations, so nothing more to do */ 1000 return; /* no animations, so nothing more to do */
996 } 1001 }
997 1002
998 perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; 1003 perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp;
1007 1012
1008 if (perc == NUM_ANIMATIONS (op) - 1) 1013 if (perc == NUM_ANIMATIONS (op) - 1)
1009 { /* Reached the last animation */ 1014 { /* Reached the last animation */
1010 if (op->face == blank_face) 1015 if (op->face == blank_face)
1011 /* If the last face is blank, remove the ob */ 1016 /* If the last face is blank, remove the ob */
1012 op->destroy (true); 1017 op->destroy ();
1013 else 1018 else
1014 { /* The last face was not blank, leave an image */ 1019 { /* The last face was not blank, leave an image */
1015 CLEAR_FLAG (op, FLAG_BLOCKSVIEW); 1020 CLEAR_FLAG (op, FLAG_BLOCKSVIEW);
1016 update_all_los (op->map, op->x, op->y); 1021 update_all_los (op->map, op->x, op->y);
1017 op->move_block = 0; 1022 op->move_block = 0;
1483 else if (owner->chosen_skill) 1488 else if (owner->chosen_skill)
1484 { 1489 {
1485 skop = owner->chosen_skill; 1490 skop = owner->chosen_skill;
1486 skill = skop->skill; 1491 skill = skop->skill;
1487 } 1492 }
1488 else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) 1493 else if (QUERY_FLAG (owner, FLAG_READY_WEAPON) && owner->current_weapon)
1489 skill = owner->current_weapon->skill; 1494 skill = owner->current_weapon->skill;
1490 else 1495 else
1491 { 1496 {
1492 LOG (llevError, "kill_object - unable to find skill that killed monster\n"); 1497 LOG (llevError, "BUG: kill_object - unable to find skill that killed monster\n"
1498 "op: %s\n" "hitter: %s\n" "owner: %s\n",
1499 owner->debug_desc (), hitter->debug_desc (), op->debug_desc ());
1493 skill = 0; 1500 skill = 0;
1494 } 1501 }
1495 1502
1496 /* We have the skill we want to credit to - now find the object this goes 1503 /* We have the skill we want to credit to - now find the object this goes
1497 * to. Make sure skop is an actual skill, and not a skill tool! 1504 * to. Make sure skop is an actual skill, and not a skill tool!
1932 SET_FLAG (tmp, FLAG_UNAGGRESSIVE); 1939 SET_FLAG (tmp, FLAG_UNAGGRESSIVE);
1933 1940
1934 j = find_first_free_spot (tmp, op->map, op->x, op->y); 1941 j = find_first_free_spot (tmp, op->map, op->x, op->y);
1935 1942
1936 if (j == -1) /* No spot to put this monster */ 1943 if (j == -1) /* No spot to put this monster */
1937 tmp->destroy (true); 1944 tmp->destroy ();
1938 else 1945 else
1939 { 1946 {
1940 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; 1947 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j];
1941 insert_ob_in_map (tmp, op->map, NULL, 0); 1948 insert_ob_in_map (tmp, op->map, NULL, 0);
1942 } 1949 }
1943 } 1950 }
1944 1951
1945 op->destroy (true); 1952 op->destroy ();
1946 } 1953 }
1947 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) 1954 else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10)
1948 hitter->drop_and_destroy (); 1955 hitter->drop_and_destroy ();
1949 1956
1950 return maxdam; 1957 return maxdam;
2259 { 2266 {
2260 /* target is unseen */ 2267 /* target is unseen */
2261 if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) 2268 if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND))
2262 adjust -= 10; 2269 adjust -= 10;
2263 /* dark map penalty for the hitter (lacks infravision if we got here). */ 2270 /* dark map penalty for the hitter (lacks infravision if we got here). */
2264 else if (target->map && target->map->darkness > 0 && !stand_in_light (target)) 2271 else if (target->map && target->map->darklevel () > 0 && !stand_in_light (target))
2265 adjust -= target->map->darkness; 2272 adjust -= target->map->darklevel ();
2266 } 2273 }
2267 2274
2268 if (QUERY_FLAG (attacker, FLAG_SCARED)) 2275 if (QUERY_FLAG (attacker, FLAG_SCARED))
2269 adjust -= 3; 2276 adjust -= 3;
2270 2277

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines