… | |
… | |
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 | |
… | |
… | |
1381 | */ |
1382 | */ |
1382 | int |
1383 | int |
1383 | kill_object (object *op, int dam, object *hitter, int type) |
1384 | kill_object (object *op, int dam, object *hitter, int type) |
1384 | { |
1385 | { |
1385 | char buf[MAX_BUF]; |
1386 | char buf[MAX_BUF]; |
1386 | const char *skill; |
1387 | shstr skill; |
1387 | int maxdam = 0; |
1388 | int maxdam = 0; |
1388 | int battleg = 0; /* true if op standing on battleground */ |
1389 | int battleg = 0; /* true if op standing on battleground */ |
1389 | int pk = 0; /* true if op and what controls hitter are both players */ |
1390 | int pk = 0; /* true if op and what controls hitter are both players */ |
1390 | object *owner = 0; |
1391 | object *owner = 0; |
1391 | object *skop = 0; |
1392 | object *skop = 0; |
… | |
… | |
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 | |
1423 | owner = hitter->owner; |
1424 | owner = hitter->outer_owner (); |
1424 | if (!owner) |
1425 | if (!owner) |
1425 | owner = hitter; |
1426 | owner = hitter; |
1426 | |
1427 | |
1427 | /* is the victim (op) standing on battleground? */ |
1428 | /* is the victim (op) standing on battleground? */ |
1428 | if (op_on_battleground (op, NULL, NULL)) |
1429 | if (op_on_battleground (op, NULL, NULL)) |
… | |
… | |
1480 | |
1481 | |
1481 | /* This code below deals with finding the appropriate skill |
1482 | /* This code below deals with finding the appropriate skill |
1482 | * to credit exp to. This is a bit problematic - we should |
1483 | * to credit exp to. This is a bit problematic - we should |
1483 | * probably never really have to look at current_weapon->skill |
1484 | * probably never really have to look at current_weapon->skill |
1484 | */ |
1485 | */ |
1485 | skill = 0; |
|
|
1486 | |
|
|
1487 | if (hitter->skill && hitter->type != PLAYER) |
1486 | if (hitter->skill && hitter->type != PLAYER) |
1488 | skill = hitter->skill; |
1487 | skill = hitter->skill; |
1489 | else if (owner->chosen_skill) |
1488 | else if (owner->chosen_skill) |
1490 | { |
1489 | { |
1491 | skop = owner->chosen_skill; |
1490 | skop = owner->chosen_skill; |
1492 | skill = skop->skill; |
1491 | skill = skop->skill; |
1493 | } |
1492 | } |
1494 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) |
1493 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON) && owner->current_weapon) |
1495 | skill = owner->current_weapon->skill; |
1494 | skill = owner->current_weapon->skill; |
1496 | else |
1495 | else |
|
|
1496 | { |
1497 | 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 ()); |
|
|
1500 | skill = 0; |
|
|
1501 | } |
1498 | |
1502 | |
1499 | /* 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 |
1500 | * 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! |
1501 | */ |
1505 | */ |
1502 | if ((!skop || skop->type != SKILL) && skill) |
1506 | skop = owner->contr->find_skill (skill); |
1503 | { |
|
|
1504 | int i; |
|
|
1505 | |
|
|
1506 | for (i = 0; i < NUM_SKILLS; i++) |
|
|
1507 | if (owner->contr->last_skill_ob[i] && !strcmp (owner->contr->last_skill_ob[i]->skill, skill)) |
|
|
1508 | { |
|
|
1509 | skop = owner->contr->last_skill_ob[i]; |
|
|
1510 | break; |
|
|
1511 | } |
|
|
1512 | } |
|
|
1513 | } /* Was it a player that hit somethign */ |
1507 | } /* Was it a player that hit somethign */ |
1514 | else |
1508 | else |
1515 | skill = 0; |
1509 | skill = 0; |
1516 | |
|
|
1517 | /* Pet (or spell) killed something. */ |
|
|
1518 | if (op->type == PLAYER) |
|
|
1519 | { |
|
|
1520 | if (owner != hitter) |
|
|
1521 | sprintf (buf, "%s killed %s with %s%s%s.", &owner->name, |
|
|
1522 | query_name (op), query_name (hitter), battleg ? " (duel)" : "", pk ? " (pk)" : ""); |
|
|
1523 | else |
|
|
1524 | sprintf (buf, "%s killed %s%s%s%s.", &hitter->name, &op->name, |
|
|
1525 | (QUERY_FLAG (hitter, FLAG_MONSTER)) || hitter->type == PLAYER ? |
|
|
1526 | " in hand to hand combat" : "", battleg ? " (duel)" : "", pk ? " (pk)" : ""); |
|
|
1527 | |
|
|
1528 | new_draw_info (NDI_ALL, 0, NULL, buf); |
|
|
1529 | } |
|
|
1530 | |
1510 | |
1531 | /* These may have been set in the player code section above */ |
1511 | /* These may have been set in the player code section above */ |
1532 | if (!skop) |
1512 | if (!skop) |
1533 | skop = hitter->chosen_skill; |
1513 | skop = hitter->chosen_skill; |
1534 | |
1514 | |
… | |
… | |
1613 | |
1593 | |
1614 | if (owner1 && owner1->type == PLAYER) |
1594 | if (owner1 && owner1->type == PLAYER) |
1615 | { |
1595 | { |
1616 | owner1->contr->play_sound (sound_find ("pet_is_killed")); |
1596 | owner1->contr->play_sound (sound_find ("pet_is_killed")); |
1617 | /* Maybe we should include the owner that killed this, maybe not */ |
1597 | /* Maybe we should include the owner that killed this, maybe not */ |
1618 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name); |
1598 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, was killed by %s.", &op->name, &hitter->name); |
1619 | } |
1599 | } |
1620 | |
1600 | |
1621 | remove_friendly_object (op); |
1601 | remove_friendly_object (op); |
1622 | } |
1602 | } |
1623 | |
1603 | |
1624 | op->destroy (); |
1604 | op->drop_and_destroy (); |
1625 | } |
1605 | } |
1626 | else |
1606 | else |
1627 | /* Player has been killed! */ |
1607 | /* Player has been killed! */ |
1628 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1608 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1629 | |
1609 | |
… | |
… | |
1915 | /* See if the creature has been killed */ |
1895 | /* See if the creature has been killed */ |
1916 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1896 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1917 | if (rtn_kill != -1) |
1897 | if (rtn_kill != -1) |
1918 | return rtn_kill; |
1898 | return rtn_kill; |
1919 | |
1899 | |
1920 | |
|
|
1921 | /* 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 |
1922 | * that before if the player was immune to ghosthit, the monster |
1901 | * that before if the player was immune to ghosthit, the monster |
1923 | * remained - that is no longer the case. |
1902 | * remained - that is no longer the case. |
1924 | */ |
1903 | */ |
1925 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1904 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1926 | hitter->destroy (); |
1905 | hitter->drop_and_destroy (); |
1927 | |
|
|
1928 | /* Lets handle creatures that are splitting now */ |
1906 | /* Lets handle creatures that are splitting now */ |
1929 | 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)) |
1930 | { |
1908 | { |
1931 | int i; |
1909 | int i; |
1932 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1910 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
… | |
… | |
1972 | } |
1950 | } |
1973 | |
1951 | |
1974 | op->destroy (); |
1952 | op->destroy (); |
1975 | } |
1953 | } |
1976 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1954 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1977 | hitter->destroy (); |
1955 | hitter->drop_and_destroy (); |
1978 | |
1956 | |
1979 | return maxdam; |
1957 | return maxdam; |
1980 | } |
1958 | } |
1981 | |
1959 | |
1982 | void |
1960 | void |
… | |
… | |
2185 | return; |
2163 | return; |
2186 | |
2164 | |
2187 | def_lev = op->level; |
2165 | def_lev = op->level; |
2188 | if (def_lev < 1) |
2166 | if (def_lev < 1) |
2189 | { |
2167 | { |
2190 | LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->archname, &op->name); |
2168 | LOG (llevError, "BUG: arch %s with level < 1 (%s)\n", &op->arch->archname, op->debug_desc ()); |
2191 | def_lev = 1; |
2169 | def_lev = 1; |
2192 | } |
2170 | } |
2193 | |
2171 | |
2194 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2172 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2195 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |
2173 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |
… | |
… | |
2288 | { |
2266 | { |
2289 | /* target is unseen */ |
2267 | /* target is unseen */ |
2290 | if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) |
2268 | if (target->invisible || QUERY_FLAG (attacker, FLAG_BLIND)) |
2291 | adjust -= 10; |
2269 | adjust -= 10; |
2292 | /* 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). */ |
2293 | 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)) |
2294 | adjust -= target->map->darkness; |
2272 | adjust -= target->map->darklevel (); |
2295 | } |
2273 | } |
2296 | |
2274 | |
2297 | if (QUERY_FLAG (attacker, FLAG_SCARED)) |
2275 | if (QUERY_FLAG (attacker, FLAG_SCARED)) |
2298 | adjust -= 3; |
2276 | adjust -= 3; |
2299 | |
2277 | |