… | |
… | |
193 | } |
193 | } |
194 | else |
194 | else |
195 | { |
195 | { |
196 | // drop everything to the ground, if possible |
196 | // drop everything to the ground, if possible |
197 | op->insert_at (originator); |
197 | op->insert_at (originator); |
198 | op->destroy_inv (true); // be explicit about dropping |
|
|
199 | op->destroy (true); |
198 | op->drop_and_destroy (); |
200 | } |
199 | } |
201 | |
200 | |
202 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
201 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
203 | if (env) |
202 | if (env) |
204 | { |
203 | { |
… | |
… | |
781 | * for help. */ |
780 | * for help. */ |
782 | 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)) |
783 | npc_call_help (op); |
782 | npc_call_help (op); |
784 | |
783 | |
785 | /* 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 */ |
786 | if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) |
785 | if (op->flag [FLAG_HIDDEN] && hitter->flag [FLAG_ALIVE]) |
787 | { |
786 | { |
788 | make_visible (op); |
787 | make_visible (op); |
789 | |
788 | |
790 | if (op->type == PLAYER) |
789 | if (op->type == PLAYER) |
791 | 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!"); |
… | |
… | |
892 | /* Disassemble missile */ |
891 | /* Disassemble missile */ |
893 | if (op->inv) |
892 | if (op->inv) |
894 | { |
893 | { |
895 | container = op; |
894 | container = op; |
896 | hitter = op->inv; |
895 | hitter = op->inv; |
897 | 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); |
898 | /* 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 |
899 | * might be called until this THROWN_OBJ is either reassembled or |
898 | * might be called until this THROWN_OBJ is either reassembled or |
900 | * 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 |
901 | * THROWN_OBJs. */ |
900 | * THROWN_OBJs. */ |
902 | } |
901 | } |
… | |
… | |
916 | * other places as well!) |
915 | * other places as well!) |
917 | */ |
916 | */ |
918 | if (hitter->destroyed () || hitter->env != NULL) |
917 | if (hitter->destroyed () || hitter->env != NULL) |
919 | { |
918 | { |
920 | if (container) |
919 | if (container) |
921 | container->destroy (true); |
920 | container->destroy (); |
922 | |
921 | |
923 | return 0; |
922 | return 0; |
924 | } |
923 | } |
925 | |
924 | |
926 | /* Missile hit victim */ |
925 | /* Missile hit victim */ |
… | |
… | |
935 | hitter = fix_stopped_arrow (hitter); |
934 | hitter = fix_stopped_arrow (hitter); |
936 | if (!hitter) |
935 | if (!hitter) |
937 | return 0; |
936 | return 0; |
938 | } |
937 | } |
939 | else |
938 | else |
940 | container->destroy (true); |
939 | container->destroy (); |
941 | |
940 | |
942 | /* Try to stick arrow into victim */ |
941 | /* Try to stick arrow into victim */ |
943 | if (!victim->destroyed () && stick_arrow (hitter, victim)) |
942 | if (!victim->destroyed () && stick_arrow (hitter, victim)) |
944 | return 0; |
943 | return 0; |
945 | |
944 | |
… | |
… | |
950 | * 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 |
951 | * way to handle those otherwise? |
950 | * way to handle those otherwise? |
952 | */ |
951 | */ |
953 | if (victim->x != hitter->x || victim->y != hitter->y) |
952 | if (victim->x != hitter->x || victim->y != hitter->y) |
954 | { |
953 | { |
|
|
954 | if (victim->destroyed ()) |
|
|
955 | hitter->destroy (); |
|
|
956 | else |
|
|
957 | { |
955 | hitter->remove (); |
958 | hitter->remove (); |
956 | hitter->x = victim->x; |
959 | hitter->x = victim->x; |
957 | hitter->y = victim->y; |
960 | hitter->y = victim->y; |
958 | insert_ob_in_map (hitter, victim->map, hitter, 0); |
961 | insert_ob_in_map (hitter, victim->map, hitter, 0); |
|
|
962 | } |
959 | } |
963 | } |
960 | else |
964 | else |
961 | /* Else leave arrow where it is */ |
965 | /* Else leave arrow where it is */ |
962 | merge_ob (hitter, NULL); |
966 | merge_ob (hitter, NULL); |
963 | |
967 | |
… | |
… | |
989 | } |
993 | } |
990 | else if (!GET_ANIM_ID (op)) |
994 | else if (!GET_ANIM_ID (op)) |
991 | { |
995 | { |
992 | /* Object has been called - no animations, so remove it */ |
996 | /* Object has been called - no animations, so remove it */ |
993 | if (op->stats.hp < 0) |
997 | if (op->stats.hp < 0) |
994 | op->destroy (true); |
998 | op->destroy (); |
995 | |
999 | |
996 | return; /* no animations, so nothing more to do */ |
1000 | return; /* no animations, so nothing more to do */ |
997 | } |
1001 | } |
998 | |
1002 | |
999 | 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; |
… | |
… | |
1008 | |
1012 | |
1009 | if (perc == NUM_ANIMATIONS (op) - 1) |
1013 | if (perc == NUM_ANIMATIONS (op) - 1) |
1010 | { /* Reached the last animation */ |
1014 | { /* Reached the last animation */ |
1011 | if (op->face == blank_face) |
1015 | if (op->face == blank_face) |
1012 | /* If the last face is blank, remove the ob */ |
1016 | /* If the last face is blank, remove the ob */ |
1013 | op->destroy (true); |
1017 | op->destroy (); |
1014 | else |
1018 | else |
1015 | { /* The last face was not blank, leave an image */ |
1019 | { /* The last face was not blank, leave an image */ |
1016 | CLEAR_FLAG (op, FLAG_BLOCKSVIEW); |
1020 | CLEAR_FLAG (op, FLAG_BLOCKSVIEW); |
1017 | update_all_los (op->map, op->x, op->y); |
1021 | update_all_los (op->map, op->x, op->y); |
1018 | op->move_block = 0; |
1022 | op->move_block = 0; |
… | |
… | |
1409 | return maxdam; |
1413 | return maxdam; |
1410 | } |
1414 | } |
1411 | |
1415 | |
1412 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1416 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1413 | { |
1417 | { |
1414 | op->destroy_inv (true); // be explicit about dropping |
|
|
1415 | op->destroy (true); |
1418 | op->drop_and_destroy (); |
1416 | return maxdam; |
1419 | return maxdam; |
1417 | } |
1420 | } |
1418 | |
1421 | |
1419 | /* Now lets start dealing with experience we get for killing something */ |
1422 | /* Now lets start dealing with experience we get for killing something */ |
1420 | |
1423 | |
… | |
… | |
1485 | else if (owner->chosen_skill) |
1488 | else if (owner->chosen_skill) |
1486 | { |
1489 | { |
1487 | skop = owner->chosen_skill; |
1490 | skop = owner->chosen_skill; |
1488 | skill = skop->skill; |
1491 | skill = skop->skill; |
1489 | } |
1492 | } |
1490 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) |
1493 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON) && owner->current_weapon) |
1491 | skill = owner->current_weapon->skill; |
1494 | skill = owner->current_weapon->skill; |
1492 | else |
1495 | else |
1493 | { |
1496 | { |
1494 | 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 ()); |
1495 | skill = 0; |
1500 | skill = 0; |
1496 | } |
1501 | } |
1497 | |
1502 | |
1498 | /* 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 |
1499 | * 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! |
… | |
… | |
1594 | } |
1599 | } |
1595 | |
1600 | |
1596 | remove_friendly_object (op); |
1601 | remove_friendly_object (op); |
1597 | } |
1602 | } |
1598 | |
1603 | |
1599 | op->destroy_inv (true); // be explicit about dropping |
|
|
1600 | op->destroy (true); |
1604 | op->drop_and_destroy (); |
1601 | } |
1605 | } |
1602 | else |
1606 | else |
1603 | /* Player has been killed! */ |
1607 | /* Player has been killed! */ |
1604 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1608 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1605 | |
1609 | |
… | |
… | |
1896 | /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note |
1900 | /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note |
1897 | * that before if the player was immune to ghosthit, the monster |
1901 | * that before if the player was immune to ghosthit, the monster |
1898 | * remained - that is no longer the case. |
1902 | * remained - that is no longer the case. |
1899 | */ |
1903 | */ |
1900 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1904 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1901 | { |
|
|
1902 | hitter->destroy_inv (true); // be explicit about dropping |
|
|
1903 | hitter->destroy (true); |
1905 | hitter->drop_and_destroy (); |
1904 | } |
|
|
1905 | /* Lets handle creatures that are splitting now */ |
1906 | /* Lets handle creatures that are splitting now */ |
1906 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1907 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1907 | { |
1908 | { |
1908 | int i; |
1909 | int i; |
1909 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1910 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
… | |
… | |
1938 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1939 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1939 | |
1940 | |
1940 | 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); |
1941 | |
1942 | |
1942 | if (j == -1) /* No spot to put this monster */ |
1943 | if (j == -1) /* No spot to put this monster */ |
1943 | tmp->destroy (true); |
1944 | tmp->destroy (); |
1944 | else |
1945 | else |
1945 | { |
1946 | { |
1946 | 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]; |
1947 | insert_ob_in_map (tmp, op->map, NULL, 0); |
1948 | insert_ob_in_map (tmp, op->map, NULL, 0); |
1948 | } |
1949 | } |
1949 | } |
1950 | } |
1950 | |
1951 | |
1951 | op->destroy (true); |
1952 | op->destroy (); |
1952 | } |
1953 | } |
1953 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1954 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1954 | { |
|
|
1955 | hitter->destroy_inv (true); // be explicit about dropping |
|
|
1956 | hitter->destroy (true); |
1955 | hitter->drop_and_destroy (); |
1957 | } |
|
|
1958 | |
1956 | |
1959 | return maxdam; |
1957 | return maxdam; |
1960 | } |
1958 | } |
1961 | |
1959 | |
1962 | void |
1960 | void |
… | |
… | |
2268 | { |
2266 | { |
2269 | /* target is unseen */ |
2267 | /* target is unseen */ |
2270 | if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) |
2268 | if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) |
2271 | adjust -= 10; |
2269 | adjust -= 10; |
2272 | /* 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). */ |
2273 | 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)) |
2274 | adjust -= target->map->darkness; |
2272 | adjust -= target->map->darklevel (); |
2275 | } |
2273 | } |
2276 | |
2274 | |
2277 | if (QUERY_FLAG (attacker, FLAG_SCARED)) |
2275 | if (QUERY_FLAG (attacker, FLAG_SCARED)) |
2278 | adjust -= 3; |
2276 | adjust -= 3; |
2279 | |
2277 | |