… | |
… | |
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 | |
198 | op->destroy_inv (true); // be explicit about dropping |
200 | op->destroy (); |
199 | op->destroy (true); |
201 | } |
200 | } |
202 | |
201 | |
203 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
202 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
204 | if (env) |
203 | if (env) |
205 | { |
204 | { |
… | |
… | |
212 | |
211 | |
213 | return; |
212 | return; |
214 | } |
213 | } |
215 | |
214 | |
216 | /* The value of 50 is arbitrary. */ |
215 | /* The value of 50 is arbitrary. */ |
217 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && (RANDOM () & 2)) |
216 | if (type & AT_COLD && (op->resist[ATNR_COLD] < 50) && !QUERY_FLAG (op, FLAG_NO_PICK) && rndm (2)) |
218 | { |
217 | { |
219 | archetype *at = archetype::find (shstr_icecube); |
218 | archetype *at = archetype::find (shstr_icecube); |
220 | |
219 | |
221 | if (at == NULL) |
220 | if (at == NULL) |
222 | return; |
221 | return; |
… | |
… | |
893 | /* Disassemble missile */ |
892 | /* Disassemble missile */ |
894 | if (op->inv) |
893 | if (op->inv) |
895 | { |
894 | { |
896 | container = op; |
895 | container = op; |
897 | hitter = op->inv; |
896 | hitter = op->inv; |
898 | hitter->remove (); |
897 | container->insert_at (hitter, hitter, INS_NO_MERGE | INS_NO_WALK_ON); |
899 | insert_ob_in_map (hitter, container->map, hitter, INS_NO_MERGE | INS_NO_WALK_ON); |
|
|
900 | /* Note that we now have an empty THROWN_OBJ on the map. Code that |
898 | /* 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 |
899 | * 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 |
900 | * removed at the end of this function must be able to deal with empty |
903 | * THROWN_OBJs. */ |
901 | * THROWN_OBJs. */ |
904 | } |
902 | } |
… | |
… | |
918 | * other places as well!) |
916 | * other places as well!) |
919 | */ |
917 | */ |
920 | if (hitter->destroyed () || hitter->env != NULL) |
918 | if (hitter->destroyed () || hitter->env != NULL) |
921 | { |
919 | { |
922 | if (container) |
920 | if (container) |
923 | { |
|
|
924 | container->remove (); |
|
|
925 | container->destroy (); |
921 | container->destroy (true); |
926 | } |
|
|
927 | |
922 | |
928 | return 0; |
923 | return 0; |
929 | } |
924 | } |
930 | |
925 | |
931 | /* Missile hit victim */ |
926 | /* Missile hit victim */ |
… | |
… | |
940 | hitter = fix_stopped_arrow (hitter); |
935 | hitter = fix_stopped_arrow (hitter); |
941 | if (!hitter) |
936 | if (!hitter) |
942 | return 0; |
937 | return 0; |
943 | } |
938 | } |
944 | else |
939 | else |
945 | container->destroy (); |
940 | container->destroy (true); |
946 | |
941 | |
947 | /* Try to stick arrow into victim */ |
942 | /* Try to stick arrow into victim */ |
948 | if (!victim->destroyed () && stick_arrow (hitter, victim)) |
943 | if (!victim->destroyed () && stick_arrow (hitter, victim)) |
949 | return 0; |
944 | return 0; |
950 | |
945 | |
… | |
… | |
994 | } |
989 | } |
995 | else if (!GET_ANIM_ID (op)) |
990 | else if (!GET_ANIM_ID (op)) |
996 | { |
991 | { |
997 | /* Object has been called - no animations, so remove it */ |
992 | /* Object has been called - no animations, so remove it */ |
998 | if (op->stats.hp < 0) |
993 | if (op->stats.hp < 0) |
999 | op->destroy (); |
994 | op->destroy (true); |
1000 | |
995 | |
1001 | return; /* no animations, so nothing more to do */ |
996 | return; /* no animations, so nothing more to do */ |
1002 | } |
997 | } |
1003 | |
998 | |
1004 | perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; |
999 | perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; |
… | |
… | |
1013 | |
1008 | |
1014 | if (perc == NUM_ANIMATIONS (op) - 1) |
1009 | if (perc == NUM_ANIMATIONS (op) - 1) |
1015 | { /* Reached the last animation */ |
1010 | { /* Reached the last animation */ |
1016 | if (op->face == blank_face) |
1011 | if (op->face == blank_face) |
1017 | /* If the last face is blank, remove the ob */ |
1012 | /* If the last face is blank, remove the ob */ |
1018 | op->destroy (); |
1013 | op->destroy (true); |
1019 | else |
1014 | else |
1020 | { /* The last face was not blank, leave an image */ |
1015 | { /* The last face was not blank, leave an image */ |
1021 | CLEAR_FLAG (op, FLAG_BLOCKSVIEW); |
1016 | CLEAR_FLAG (op, FLAG_BLOCKSVIEW); |
1022 | update_all_los (op->map, op->x, op->y); |
1017 | update_all_los (op->map, op->x, op->y); |
1023 | op->move_block = 0; |
1018 | op->move_block = 0; |
… | |
… | |
1383 | */ |
1378 | */ |
1384 | int |
1379 | int |
1385 | kill_object (object *op, int dam, object *hitter, int type) |
1380 | kill_object (object *op, int dam, object *hitter, int type) |
1386 | { |
1381 | { |
1387 | char buf[MAX_BUF]; |
1382 | char buf[MAX_BUF]; |
1388 | const char *skill; |
1383 | shstr skill; |
1389 | int maxdam = 0; |
1384 | int maxdam = 0; |
1390 | int battleg = 0; /* true if op standing on battleground */ |
1385 | int battleg = 0; /* true if op standing on battleground */ |
1391 | int pk = 0; /* true if op and what controls hitter are both players */ |
1386 | int pk = 0; /* true if op and what controls hitter are both players */ |
1392 | object *owner = 0; |
1387 | object *owner = 0; |
1393 | object *skop = 0; |
1388 | object *skop = 0; |
… | |
… | |
1414 | return maxdam; |
1409 | return maxdam; |
1415 | } |
1410 | } |
1416 | |
1411 | |
1417 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1412 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1418 | { |
1413 | { |
|
|
1414 | op->destroy_inv (true); // be explicit about dropping |
1419 | op->destroy (); |
1415 | op->destroy (true); |
1420 | return maxdam; |
1416 | return maxdam; |
1421 | } |
1417 | } |
1422 | |
1418 | |
1423 | /* Now lets start dealing with experience we get for killing something */ |
1419 | /* Now lets start dealing with experience we get for killing something */ |
1424 | |
1420 | |
1425 | owner = hitter->owner; |
1421 | owner = hitter->outer_owner (); |
1426 | if (!owner) |
1422 | if (!owner) |
1427 | owner = hitter; |
1423 | owner = hitter; |
1428 | |
1424 | |
1429 | /* is the victim (op) standing on battleground? */ |
1425 | /* is the victim (op) standing on battleground? */ |
1430 | if (op_on_battleground (op, NULL, NULL)) |
1426 | if (op_on_battleground (op, NULL, NULL)) |
… | |
… | |
1482 | |
1478 | |
1483 | /* This code below deals with finding the appropriate skill |
1479 | /* This code below deals with finding the appropriate skill |
1484 | * to credit exp to. This is a bit problematic - we should |
1480 | * to credit exp to. This is a bit problematic - we should |
1485 | * probably never really have to look at current_weapon->skill |
1481 | * probably never really have to look at current_weapon->skill |
1486 | */ |
1482 | */ |
1487 | skill = 0; |
|
|
1488 | |
|
|
1489 | if (hitter->skill && hitter->type != PLAYER) |
1483 | if (hitter->skill && hitter->type != PLAYER) |
1490 | skill = hitter->skill; |
1484 | skill = hitter->skill; |
1491 | else if (owner->chosen_skill) |
1485 | else if (owner->chosen_skill) |
1492 | { |
1486 | { |
1493 | skop = owner->chosen_skill; |
1487 | skop = owner->chosen_skill; |
1494 | skill = skop->skill; |
1488 | skill = skop->skill; |
1495 | } |
1489 | } |
1496 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) |
1490 | else if (QUERY_FLAG (owner, FLAG_READY_WEAPON)) |
1497 | skill = owner->current_weapon->skill; |
1491 | skill = owner->current_weapon->skill; |
1498 | else |
1492 | else |
|
|
1493 | { |
1499 | LOG (llevError, "kill_object - unable to find skill that killed monster\n"); |
1494 | LOG (llevError, "kill_object - unable to find skill that killed monster\n"); |
|
|
1495 | skill = 0; |
|
|
1496 | } |
1500 | |
1497 | |
1501 | /* We have the skill we want to credit to - now find the object this goes |
1498 | /* 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! |
1499 | * to. Make sure skop is an actual skill, and not a skill tool! |
1503 | */ |
1500 | */ |
1504 | if ((!skop || skop->type != SKILL) && skill) |
1501 | 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 */ |
1502 | } /* Was it a player that hit somethign */ |
1516 | else |
1503 | else |
1517 | skill = 0; |
1504 | skill = 0; |
1518 | |
1505 | |
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 */ |
1506 | /* These may have been set in the player code section above */ |
1529 | if (!skop) |
1507 | if (!skop) |
1530 | skop = hitter->chosen_skill; |
1508 | skop = hitter->chosen_skill; |
1531 | |
1509 | |
1532 | if (!skill && skop) |
1510 | if (!skill && skop) |
1533 | skill = skop->skill; |
1511 | skill = skop->skill; |
1534 | |
|
|
1535 | new_draw_info (NDI_ALL, op->type == PLAYER ? 1 : 10, NULL, buf); |
|
|
1536 | |
1512 | |
1537 | /* If you didn't kill yourself, and your not the wizard */ |
1513 | /* If you didn't kill yourself, and your not the wizard */ |
1538 | if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) |
1514 | if (owner != op && !QUERY_FLAG (op, FLAG_WIZ)) |
1539 | { |
1515 | { |
1540 | int exp; |
1516 | int exp; |
… | |
… | |
1612 | |
1588 | |
1613 | if (owner1 && owner1->type == PLAYER) |
1589 | if (owner1 && owner1->type == PLAYER) |
1614 | { |
1590 | { |
1615 | owner1->contr->play_sound (sound_find ("pet_is_killed")); |
1591 | owner1->contr->play_sound (sound_find ("pet_is_killed")); |
1616 | /* Maybe we should include the owner that killed this, maybe not */ |
1592 | /* 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); |
1593 | new_draw_info_format (NDI_UNIQUE, 0, owner1, "Your pet, the %s, was killed by %s.", &op->name, &hitter->name); |
1618 | } |
1594 | } |
1619 | |
1595 | |
1620 | remove_friendly_object (op); |
1596 | remove_friendly_object (op); |
1621 | } |
1597 | } |
1622 | |
1598 | |
|
|
1599 | op->destroy_inv (true); // be explicit about dropping |
1623 | op->destroy (); |
1600 | op->destroy (true); |
1624 | } |
1601 | } |
1625 | else |
1602 | else |
1626 | /* Player has been killed! */ |
1603 | /* Player has been killed! */ |
1627 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1604 | op->contr->killer = owner->type == PLAYER ? owner : hitter; |
1628 | |
1605 | |
… | |
… | |
1914 | /* See if the creature has been killed */ |
1891 | /* See if the creature has been killed */ |
1915 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1892 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1916 | if (rtn_kill != -1) |
1893 | if (rtn_kill != -1) |
1917 | return rtn_kill; |
1894 | return rtn_kill; |
1918 | |
1895 | |
1919 | |
|
|
1920 | /* Used to be ghosthit removal - we now use the ONE_HIT flag. Note |
1896 | /* 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 |
1897 | * that before if the player was immune to ghosthit, the monster |
1922 | * remained - that is no longer the case. |
1898 | * remained - that is no longer the case. |
1923 | */ |
1899 | */ |
1924 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1900 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
|
|
1901 | { |
|
|
1902 | hitter->destroy_inv (true); // be explicit about dropping |
1925 | hitter->destroy (); |
1903 | hitter->destroy (true); |
1926 | |
1904 | } |
1927 | /* Lets handle creatures that are splitting now */ |
1905 | /* Lets handle creatures that are splitting now */ |
1928 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1906 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1929 | { |
1907 | { |
1930 | int i; |
1908 | int i; |
1931 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1909 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
… | |
… | |
1960 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1938 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1961 | |
1939 | |
1962 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
1940 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
1963 | |
1941 | |
1964 | if (j == -1) /* No spot to put this monster */ |
1942 | if (j == -1) /* No spot to put this monster */ |
1965 | tmp->destroy (); |
1943 | tmp->destroy (true); |
1966 | else |
1944 | else |
1967 | { |
1945 | { |
1968 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
1946 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
1969 | insert_ob_in_map (tmp, op->map, NULL, 0); |
1947 | insert_ob_in_map (tmp, op->map, NULL, 0); |
1970 | } |
1948 | } |
1971 | } |
1949 | } |
1972 | |
1950 | |
1973 | op->destroy (); |
1951 | op->destroy (true); |
1974 | } |
1952 | } |
1975 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
1953 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
|
|
1954 | { |
|
|
1955 | hitter->destroy_inv (true); // be explicit about dropping |
1976 | hitter->destroy (); |
1956 | hitter->destroy (true); |
|
|
1957 | } |
1977 | |
1958 | |
1978 | return maxdam; |
1959 | return maxdam; |
1979 | } |
1960 | } |
1980 | |
1961 | |
1981 | void |
1962 | void |
… | |
… | |
2184 | return; |
2165 | return; |
2185 | |
2166 | |
2186 | def_lev = op->level; |
2167 | def_lev = op->level; |
2187 | if (def_lev < 1) |
2168 | if (def_lev < 1) |
2188 | { |
2169 | { |
2189 | LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->archname, &op->name); |
2170 | LOG (llevError, "BUG: arch %s with level < 1 (%s)\n", &op->arch->archname, op->debug_desc ()); |
2190 | def_lev = 1; |
2171 | def_lev = 1; |
2191 | } |
2172 | } |
2192 | |
2173 | |
2193 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2174 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2194 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |
2175 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |