… | |
… | |
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 (); |
198 | op->drop_and_destroy (); |
199 | } |
199 | } |
200 | |
200 | |
201 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
201 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
202 | if (env) |
202 | if (env) |
203 | { |
203 | { |
… | |
… | |
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 | hitter->remove (); |
|
|
897 | insert_ob_in_map (hitter, container->map, 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 | { |
|
|
922 | container->remove (); |
|
|
923 | container->destroy (); |
920 | container->destroy (); |
924 | } |
|
|
925 | |
921 | |
926 | return 0; |
922 | return 0; |
927 | } |
923 | } |
928 | |
924 | |
929 | /* Missile hit victim */ |
925 | /* Missile hit victim */ |
… | |
… | |
953 | * 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 |
954 | * way to handle those otherwise? |
950 | * way to handle those otherwise? |
955 | */ |
951 | */ |
956 | if (victim->x != hitter->x || victim->y != hitter->y) |
952 | if (victim->x != hitter->x || victim->y != hitter->y) |
957 | { |
953 | { |
|
|
954 | if (victim->destroyed ()) |
|
|
955 | hitter->destroy (); |
|
|
956 | else |
|
|
957 | { |
958 | hitter->remove (); |
958 | hitter->remove (); |
959 | hitter->x = victim->x; |
959 | hitter->x = victim->x; |
960 | hitter->y = victim->y; |
960 | hitter->y = victim->y; |
961 | insert_ob_in_map (hitter, victim->map, hitter, 0); |
961 | insert_ob_in_map (hitter, victim->map, hitter, 0); |
|
|
962 | } |
962 | } |
963 | } |
963 | else |
964 | else |
964 | /* Else leave arrow where it is */ |
965 | /* Else leave arrow where it is */ |
965 | merge_ob (hitter, NULL); |
966 | merge_ob (hitter, NULL); |
966 | |
967 | |
… | |
… | |
1412 | return maxdam; |
1413 | return maxdam; |
1413 | } |
1414 | } |
1414 | |
1415 | |
1415 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1416 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1416 | { |
1417 | { |
1417 | op->destroy (); |
1418 | op->drop_and_destroy (); |
1418 | return maxdam; |
1419 | return maxdam; |
1419 | } |
1420 | } |
1420 | |
1421 | |
1421 | /* Now lets start dealing with experience we get for killing something */ |
1422 | /* Now lets start dealing with experience we get for killing something */ |
1422 | |
1423 | |
… | |
… | |
1487 | else if (owner->chosen_skill) |
1488 | else if (owner->chosen_skill) |
1488 | { |
1489 | { |
1489 | skop = owner->chosen_skill; |
1490 | skop = owner->chosen_skill; |
1490 | skill = skop->skill; |
1491 | skill = skop->skill; |
1491 | } |
1492 | } |
1492 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) |
1493 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON) && owner->current_weapon) |
1493 | skill = owner->current_weapon->skill; |
1494 | skill = owner->current_weapon->skill; |
1494 | else |
1495 | else |
1495 | { |
1496 | { |
1496 | 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 ()); |
1497 | skill = 0; |
1500 | skill = 0; |
1498 | } |
1501 | } |
1499 | |
1502 | |
1500 | /* 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 |
1501 | * 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! |
1502 | */ |
1505 | */ |
1503 | if ((!skop || skop->type != SKILL) && skill) |
1506 | skop = owner->contr->find_skill (skill); |
1504 | for (object *tmp = owner->inv; tmp; tmp = tmp->below) |
|
|
1505 | if (tmp->skill == skill && tmp->type == SKILL) |
|
|
1506 | { |
|
|
1507 | skop = splay (tmp); |
|
|
1508 | break; |
|
|
1509 | } |
|
|
1510 | } /* Was it a player that hit somethign */ |
1507 | } /* Was it a player that hit somethign */ |
1511 | else |
1508 | else |
1512 | skill = 0; |
1509 | skill = 0; |
1513 | |
1510 | |
1514 | /* These may have been set in the player code section above */ |
1511 | /* These may have been set in the player code section above */ |
… | |
… | |
1602 | } |
1599 | } |
1603 | |
1600 | |
1604 | remove_friendly_object (op); |
1601 | remove_friendly_object (op); |
1605 | } |
1602 | } |
1606 | |
1603 | |
1607 | op->destroy (); |
1604 | op->drop_and_destroy (); |
1608 | } |
1605 | } |
1609 | else |
1606 | else |
1610 | /* Player has been killed! */ |
1607 | /* Player has been killed! */ |
1611 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1608 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1612 | |
1609 | |
… | |
… | |
1898 | /* See if the creature has been killed */ |
1895 | /* See if the creature has been killed */ |
1899 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1896 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1900 | if (rtn_kill != -1) |
1897 | if (rtn_kill != -1) |
1901 | return rtn_kill; |
1898 | return rtn_kill; |
1902 | |
1899 | |
1903 | |
|
|
1904 | /* 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 |
1905 | * that before if the player was immune to ghosthit, the monster |
1901 | * that before if the player was immune to ghosthit, the monster |
1906 | * remained - that is no longer the case. |
1902 | * remained - that is no longer the case. |
1907 | */ |
1903 | */ |
1908 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1904 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1909 | hitter->destroy (); |
1905 | hitter->drop_and_destroy (); |
1910 | |
|
|
1911 | /* Lets handle creatures that are splitting now */ |
1906 | /* Lets handle creatures that are splitting now */ |
1912 | 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)) |
1913 | { |
1908 | { |
1914 | int i; |
1909 | int i; |
1915 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1910 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
… | |
… | |
1955 | } |
1950 | } |
1956 | |
1951 | |
1957 | op->destroy (); |
1952 | op->destroy (); |
1958 | } |
1953 | } |
1959 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1954 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1960 | hitter->destroy (); |
1955 | hitter->drop_and_destroy (); |
1961 | |
1956 | |
1962 | return maxdam; |
1957 | return maxdam; |
1963 | } |
1958 | } |
1964 | |
1959 | |
1965 | void |
1960 | void |
… | |
… | |
2271 | { |
2266 | { |
2272 | /* target is unseen */ |
2267 | /* target is unseen */ |
2273 | if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) |
2268 | if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) |
2274 | adjust -= 10; |
2269 | adjust -= 10; |
2275 | /* 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). */ |
2276 | 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)) |
2277 | adjust -= target->map->darkness; |
2272 | adjust -= target->map->darklevel (); |
2278 | } |
2273 | } |
2279 | |
2274 | |
2280 | if (QUERY_FLAG (attacker, FLAG_SCARED)) |
2275 | if (QUERY_FLAG (attacker, FLAG_SCARED)) |
2281 | adjust -= 3; |
2276 | adjust -= 3; |
2282 | |
2277 | |