… | |
… | |
148 | object *env = op->env; |
148 | object *env = op->env; |
149 | int x = op->x, y = op->y; |
149 | int x = op->x, y = op->y; |
150 | maptile *m = op->map; |
150 | maptile *m = op->map; |
151 | |
151 | |
152 | op = stop_item (op); |
152 | op = stop_item (op); |
153 | if (op == NULL) |
153 | if (!op) |
154 | return; |
154 | return; |
155 | |
155 | |
156 | /* Hacked the following so that type LIGHTER will work. |
156 | /* Hacked the following so that type LIGHTER will work. |
157 | * Also, objects which are potential "lights" that are hit by |
157 | * Also, objects which are potential "lights" that are hit by |
158 | * flame/elect attacks will be set to glow. "lights" are any |
158 | * flame/elect attacks will be set to glow. "lights" are any |
… | |
… | |
192 | fix_stopped_item (op, m, originator); |
192 | fix_stopped_item (op, m, originator); |
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 | while (op->inv) |
|
|
198 | op->inv->insert_at (originator); |
197 | op->insert_at (originator); |
199 | |
|
|
200 | op->destroy (); |
198 | op->drop_and_destroy (); |
201 | } |
199 | } |
202 | |
200 | |
203 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
201 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
204 | if (env) |
202 | if (env) |
205 | { |
203 | { |
… | |
… | |
212 | |
210 | |
213 | return; |
211 | return; |
214 | } |
212 | } |
215 | |
213 | |
216 | /* The value of 50 is arbitrary. */ |
214 | /* The value of 50 is arbitrary. */ |
217 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) |
215 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && rndm (2)) |
218 | { |
216 | { |
219 | archetype *at = archetype::find (shstr_icecube); |
217 | archetype *at = archetype::find (shstr_icecube); |
220 | |
218 | |
221 | if (at == NULL) |
219 | if (at == NULL) |
222 | return; |
220 | return; |
… | |
… | |
782 | * for help. */ |
780 | * for help. */ |
783 | 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)) |
784 | npc_call_help (op); |
782 | npc_call_help (op); |
785 | |
783 | |
786 | /* 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 */ |
787 | if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) |
785 | if (op->flag [FLAG_HIDDEN] && hitter->flag [FLAG_ALIVE]) |
788 | { |
786 | { |
789 | make_visible (op); |
787 | make_visible (op); |
790 | |
788 | |
791 | if (op->type == PLAYER) |
789 | if (op->type == PLAYER) |
792 | 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!"); |
… | |
… | |
893 | /* Disassemble missile */ |
891 | /* Disassemble missile */ |
894 | if (op->inv) |
892 | if (op->inv) |
895 | { |
893 | { |
896 | container = op; |
894 | container = op; |
897 | hitter = op->inv; |
895 | hitter = op->inv; |
898 | hitter->remove (); |
|
|
899 | 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); |
900 | /* 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 |
901 | * might be called until this THROWN_OBJ is either reassembled or |
898 | * might be called until this THROWN_OBJ is either reassembled or |
902 | * 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 |
903 | * THROWN_OBJs. */ |
900 | * THROWN_OBJs. */ |
904 | } |
901 | } |
… | |
… | |
918 | * other places as well!) |
915 | * other places as well!) |
919 | */ |
916 | */ |
920 | if (hitter->destroyed () || hitter->env != NULL) |
917 | if (hitter->destroyed () || hitter->env != NULL) |
921 | { |
918 | { |
922 | if (container) |
919 | if (container) |
923 | { |
|
|
924 | container->remove (); |
|
|
925 | container->destroy (); |
920 | container->destroy (); |
926 | } |
|
|
927 | |
921 | |
928 | return 0; |
922 | return 0; |
929 | } |
923 | } |
930 | |
924 | |
931 | /* Missile hit victim */ |
925 | /* Missile hit victim */ |
… | |
… | |
955 | * 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 |
956 | * way to handle those otherwise? |
950 | * way to handle those otherwise? |
957 | */ |
951 | */ |
958 | if (victim->x != hitter->x || victim->y != hitter->y) |
952 | if (victim->x != hitter->x || victim->y != hitter->y) |
959 | { |
953 | { |
|
|
954 | if (victim->destroyed ()) |
|
|
955 | hitter->destroy (); |
|
|
956 | else |
|
|
957 | { |
960 | hitter->remove (); |
958 | hitter->remove (); |
961 | hitter->x = victim->x; |
959 | hitter->x = victim->x; |
962 | hitter->y = victim->y; |
960 | hitter->y = victim->y; |
963 | insert_ob_in_map (hitter, victim->map, hitter, 0); |
961 | insert_ob_in_map (hitter, victim->map, hitter, 0); |
|
|
962 | } |
964 | } |
963 | } |
965 | else |
964 | else |
966 | /* Else leave arrow where it is */ |
965 | /* Else leave arrow where it is */ |
967 | merge_ob (hitter, NULL); |
966 | merge_ob (hitter, NULL); |
968 | |
967 | |
… | |
… | |
1383 | */ |
1382 | */ |
1384 | int |
1383 | int |
1385 | kill_object (object *op, int dam, object *hitter, int type) |
1384 | kill_object (object *op, int dam, object *hitter, int type) |
1386 | { |
1385 | { |
1387 | char buf[MAX_BUF]; |
1386 | char buf[MAX_BUF]; |
1388 | const char *skill; |
1387 | shstr skill; |
1389 | int maxdam = 0; |
1388 | int maxdam = 0; |
1390 | int battleg = 0; /* true if op standing on battleground */ |
1389 | int battleg = 0; /* true if op standing on battleground */ |
1391 | 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 */ |
1392 | object *owner = 0; |
1391 | object *owner = 0; |
1393 | object *skop = 0; |
1392 | object *skop = 0; |
… | |
… | |
1414 | return maxdam; |
1413 | return maxdam; |
1415 | } |
1414 | } |
1416 | |
1415 | |
1417 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1416 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1418 | { |
1417 | { |
1419 | op->destroy (); |
1418 | op->drop_and_destroy (); |
1420 | return maxdam; |
1419 | return maxdam; |
1421 | } |
1420 | } |
1422 | |
1421 | |
1423 | /* Now lets start dealing with experience we get for killing something */ |
1422 | /* Now lets start dealing with experience we get for killing something */ |
1424 | |
1423 | |
1425 | owner = hitter->owner; |
1424 | owner = hitter->outer_owner (); |
1426 | if (!owner) |
1425 | if (!owner) |
1427 | owner = hitter; |
1426 | owner = hitter; |
1428 | |
1427 | |
1429 | /* is the victim (op) standing on battleground? */ |
1428 | /* is the victim (op) standing on battleground? */ |
1430 | if (op_on_battleground (op, NULL, NULL)) |
1429 | if (op_on_battleground (op, NULL, NULL)) |
… | |
… | |
1482 | |
1481 | |
1483 | /* This code below deals with finding the appropriate skill |
1482 | /* This code below deals with finding the appropriate skill |
1484 | * to credit exp to. This is a bit problematic - we should |
1483 | * to credit exp to. This is a bit problematic - we should |
1485 | * probably never really have to look at current_weapon->skill |
1484 | * probably never really have to look at current_weapon->skill |
1486 | */ |
1485 | */ |
1487 | skill = 0; |
|
|
1488 | |
|
|
1489 | if (hitter->skill && hitter->type != PLAYER) |
1486 | if (hitter->skill && hitter->type != PLAYER) |
1490 | skill = hitter->skill; |
1487 | skill = hitter->skill; |
1491 | else if (owner->chosen_skill) |
1488 | else if (owner->chosen_skill) |
1492 | { |
1489 | { |
1493 | skop = owner->chosen_skill; |
1490 | skop = owner->chosen_skill; |
1494 | skill = skop->skill; |
1491 | skill = skop->skill; |
1495 | } |
1492 | } |
1496 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) |
1493 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) |
1497 | skill = owner->current_weapon->skill; |
1494 | skill = owner->current_weapon->skill; |
1498 | else |
1495 | else |
|
|
1496 | { |
1499 | LOG (llevError, "kill_object - unable to find skill that killed monster\n"); |
1497 | LOG (llevError, "kill_object - unable to find skill that killed monster\n"); |
|
|
1498 | skill = 0; |
|
|
1499 | } |
1500 | |
1500 | |
1501 | /* We have the skill we want to credit to - now find the object this goes |
1501 | /* We have the skill we want to credit to - now find the object this goes |
1502 | * to. Make sure skop is an actual skill, and not a skill tool! |
1502 | * to. Make sure skop is an actual skill, and not a skill tool! |
1503 | */ |
1503 | */ |
1504 | if ((!skop || skop->type != SKILL) && skill) |
1504 | skop = owner->contr->find_skill (skill); |
1505 | { |
|
|
1506 | int i; |
|
|
1507 | |
|
|
1508 | for (i = 0; i < NUM_SKILLS; i++) |
|
|
1509 | if (owner->contr->last_skill_ob[i] && !strcmp (owner->contr->last_skill_ob[i]->skill, skill)) |
|
|
1510 | { |
|
|
1511 | skop = owner->contr->last_skill_ob[i]; |
|
|
1512 | break; |
|
|
1513 | } |
|
|
1514 | } |
|
|
1515 | } /* Was it a player that hit somethign */ |
1505 | } /* Was it a player that hit somethign */ |
1516 | else |
1506 | else |
1517 | skill = 0; |
1507 | skill = 0; |
1518 | |
1508 | |
1519 | /* Pet (or spell) killed something. */ |
|
|
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 | /* These may have been set in the player code section above */ |
1509 | /* These may have been set in the player code section above */ |
1529 | if (!skop) |
1510 | if (!skop) |
1530 | skop = hitter->chosen_skill; |
1511 | skop = hitter->chosen_skill; |
1531 | |
1512 | |
1532 | if (!skill && skop) |
1513 | if (!skill && skop) |
1533 | skill = skop->skill; |
1514 | skill = skop->skill; |
1534 | |
|
|
1535 | new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf); |
|
|
1536 | |
1515 | |
1537 | /* If you didn't kill yourself, and your not the wizard */ |
1516 | /* If you didn't kill yourself, and your not the wizard */ |
1538 | if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) |
1517 | if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) |
1539 | { |
1518 | { |
1540 | int exp; |
1519 | int exp; |
… | |
… | |
1612 | |
1591 | |
1613 | if (owner1 && owner1->type == PLAYER) |
1592 | if (owner1 && owner1->type == PLAYER) |
1614 | { |
1593 | { |
1615 | owner1->contr->play_sound (sound_find ("pet_is_killed")); |
1594 | owner1->contr->play_sound (sound_find ("pet_is_killed")); |
1616 | /* Maybe we should include the owner that killed this, maybe not */ |
1595 | /* Maybe we should include the owner that killed this, maybe not */ |
1617 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, is killed by %s.", &op->name, &hitter->name); |
1596 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, was killed by %s.", &op->name, &hitter->name); |
1618 | } |
1597 | } |
1619 | |
1598 | |
1620 | remove_friendly_object (op); |
1599 | remove_friendly_object (op); |
1621 | } |
1600 | } |
1622 | |
1601 | |
1623 | op->destroy (); |
1602 | op->drop_and_destroy (); |
1624 | } |
1603 | } |
1625 | else |
1604 | else |
1626 | /* Player has been killed! */ |
1605 | /* Player has been killed! */ |
1627 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1606 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1628 | |
1607 | |
… | |
… | |
1914 | /* See if the creature has been killed */ |
1893 | /* See if the creature has been killed */ |
1915 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1894 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1916 | if (rtn_kill != -1) |
1895 | if (rtn_kill != -1) |
1917 | return rtn_kill; |
1896 | return rtn_kill; |
1918 | |
1897 | |
1919 | |
|
|
1920 | /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note |
1898 | /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note |
1921 | * that before if the player was immune to ghosthit, the monster |
1899 | * that before if the player was immune to ghosthit, the monster |
1922 | * remained - that is no longer the case. |
1900 | * remained - that is no longer the case. |
1923 | */ |
1901 | */ |
1924 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1902 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1925 | hitter->destroy (); |
1903 | hitter->drop_and_destroy (); |
1926 | |
|
|
1927 | /* Lets handle creatures that are splitting now */ |
1904 | /* Lets handle creatures that are splitting now */ |
1928 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1905 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1929 | { |
1906 | { |
1930 | int i; |
1907 | int i; |
1931 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1908 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
… | |
… | |
1971 | } |
1948 | } |
1972 | |
1949 | |
1973 | op->destroy (); |
1950 | op->destroy (); |
1974 | } |
1951 | } |
1975 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1952 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1976 | hitter->destroy (); |
1953 | hitter->drop_and_destroy (); |
1977 | |
1954 | |
1978 | return maxdam; |
1955 | return maxdam; |
1979 | } |
1956 | } |
1980 | |
1957 | |
1981 | void |
1958 | void |
… | |
… | |
2184 | return; |
2161 | return; |
2185 | |
2162 | |
2186 | def_lev = op->level; |
2163 | def_lev = op->level; |
2187 | if (def_lev < 1) |
2164 | if (def_lev < 1) |
2188 | { |
2165 | { |
2189 | LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->archname, &op->name); |
2166 | LOG (llevError, "BUG: arch %s with level < 1 (%s)\n", &op->arch->archname, op->debug_desc ()); |
2190 | def_lev = 1; |
2167 | def_lev = 1; |
2191 | } |
2168 | } |
2192 | |
2169 | |
2193 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2170 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2194 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |
2171 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |