… | |
… | |
273 | { |
273 | { |
274 | /* Clear item stack */ |
274 | /* Clear item stack */ |
275 | free (stack_items); |
275 | free (stack_items); |
276 | } |
276 | } |
277 | |
277 | |
|
|
278 | /* |
|
|
279 | * get_player_archetype() return next player archetype from archetype |
|
|
280 | * list. Not very efficient routine, but used only creating new players. |
|
|
281 | * Note: there MUST be at least one player archetype! |
|
|
282 | */ |
|
|
283 | static archetype * |
|
|
284 | get_player_archetype (archetype *at) |
|
|
285 | { |
|
|
286 | // archetypes could have been reloaded |
|
|
287 | archetype *nat = at ? archetype::find (at->archname) : archetypes [0]; |
|
|
288 | |
|
|
289 | if (!nat) |
|
|
290 | return at; |
|
|
291 | |
|
|
292 | archvec::iterator i = archetypes.find (nat); |
|
|
293 | |
|
|
294 | for (;;) |
|
|
295 | { |
|
|
296 | if (++i == archetypes.end ()) |
|
|
297 | i = archetypes.begin (); |
|
|
298 | else if (*i == at) |
|
|
299 | cleanup ("not a single player archetype found"); |
|
|
300 | |
|
|
301 | if ((*i)->type == PLAYER) |
|
|
302 | return *i; |
|
|
303 | } |
|
|
304 | } |
|
|
305 | |
278 | /* Tries to add player on the connection passed in ns. |
306 | /* Tries to add player on the connection passed in ns. |
279 | * All we can really get in this is some settings like host and display |
307 | * All we can really get in this is some settings like host and display |
280 | * mode. |
308 | * mode. |
281 | */ |
309 | */ |
282 | player * |
310 | player * |
… | |
… | |
291 | pl->ob->run_away = 25; /* Then we panick... */ |
319 | pl->ob->run_away = 25; /* Then we panick... */ |
292 | |
320 | |
293 | set_first_map (pl->ob); |
321 | set_first_map (pl->ob); |
294 | |
322 | |
295 | return pl; |
323 | return pl; |
296 | } |
|
|
297 | |
|
|
298 | /* |
|
|
299 | * get_player_archetype() return next player archetype from archetype |
|
|
300 | * list. Not very efficient routine, but used only creating new players. |
|
|
301 | * Note: there MUST be at least one player archetype! |
|
|
302 | */ |
|
|
303 | archetype * |
|
|
304 | get_player_archetype (archetype *at) |
|
|
305 | { |
|
|
306 | // archetypes could have been reloaded |
|
|
307 | archetype *nat = at ? archetype::find (at->archname) : archetypes [0]; |
|
|
308 | |
|
|
309 | if (!nat) |
|
|
310 | return at; |
|
|
311 | |
|
|
312 | archvec::iterator i = archetypes.find (nat); |
|
|
313 | |
|
|
314 | for (;;) |
|
|
315 | { |
|
|
316 | if (++i == archetypes.end ()) |
|
|
317 | i = archetypes.begin (); |
|
|
318 | else if (*i == at) |
|
|
319 | cleanup ("not a single player archetype found"); |
|
|
320 | |
|
|
321 | if ((*i)->type == PLAYER) |
|
|
322 | return *i; |
|
|
323 | } |
|
|
324 | } |
324 | } |
325 | |
325 | |
326 | object * |
326 | object * |
327 | get_nearest_player (object *mon) |
327 | get_nearest_player (object *mon) |
328 | { |
328 | { |
… | |
… | |
744 | player::chargen_race_done () |
744 | player::chargen_race_done () |
745 | { |
745 | { |
746 | /* this must before then initial items are given */ |
746 | /* this must before then initial items are given */ |
747 | esrv_new_player (ob->contr); |
747 | esrv_new_player (ob->contr); |
748 | |
748 | |
749 | treasurelist *tl = treasurelist::find ("starting_wealth"); |
749 | treasurelist *tl = treasurelist::find (shstr_starting_wealth); |
750 | if (tl) |
750 | if (tl) |
751 | create_treasure (tl, ob, 0, 0, 0); |
751 | create_treasure (tl, ob, 0, 0, 0); |
752 | |
752 | |
753 | INVOKE_PLAYER (BIRTH, ob->contr); |
753 | INVOKE_PLAYER (BIRTH, ob->contr); |
754 | INVOKE_PLAYER (LOGIN, ob->contr); |
754 | INVOKE_PLAYER (LOGIN, ob->contr); |
… | |
… | |
807 | ob->stats.hp = ob->stats.maxhp; |
807 | ob->stats.hp = ob->stats.maxhp; |
808 | ob->stats.sp = ob->stats.maxsp; |
808 | ob->stats.sp = ob->stats.maxsp; |
809 | ob->stats.grace = 0; |
809 | ob->stats.grace = 0; |
810 | } |
810 | } |
811 | |
811 | |
812 | void |
812 | static void |
813 | flee_player (object *op) |
813 | flee_player (object *op) |
814 | { |
814 | { |
815 | int dir, diff; |
815 | int dir, diff; |
816 | rv_vector rv; |
816 | rv_vector rv; |
817 | |
817 | |
… | |
… | |
903 | if (op->contr->mode & PU_DEBUG) |
903 | if (op->contr->mode & PU_DEBUG) |
904 | { |
904 | { |
905 | /* some debugging code to figure out item information */ |
905 | /* some debugging code to figure out item information */ |
906 | const char *str = tmp->name |
906 | const char *str = tmp->name |
907 | ? format ("item name: %s item type: %d weight/value: %d", |
907 | ? format ("item name: %s item type: %d weight/value: %d", |
908 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))) |
908 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1)))) |
909 | : format ("item name: %s item type: %d weight/value: %d", |
909 | : format ("item name: %s item type: %d weight/value: %d", |
910 | &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
910 | &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1)))); |
911 | |
911 | |
912 | new_draw_info (NDI_UNIQUE, 0, op, str); |
912 | new_draw_info (NDI_UNIQUE, 0, op, str); |
913 | } |
913 | } |
914 | |
914 | |
915 | if (op->contr->mode & PU_INHIBIT) |
915 | if (op->contr->mode & PU_INHIBIT) |
… | |
… | |
1146 | fprintf (stderr, "%s", tmp->name); |
1146 | fprintf (stderr, "%s", tmp->name); |
1147 | } |
1147 | } |
1148 | else |
1148 | else |
1149 | fprintf (stderr, "%s", tmp->arch->archname); |
1149 | fprintf (stderr, "%s", tmp->arch->archname); |
1150 | fprintf (stderr, ",%d] = ", tmp->type); |
1150 | fprintf (stderr, ",%d] = ", tmp->type); |
1151 | fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1151 | fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1)))); |
1152 | #endif |
1152 | #endif |
1153 | CHK_PICK_PICKUP; |
1153 | CHK_PICK_PICKUP; |
1154 | continue; |
1154 | continue; |
1155 | } |
1155 | } |
1156 | } /* the new pickup model */ |
1156 | } /* the new pickup model */ |
1157 | } |
1157 | } |
1158 | |
1158 | |
1159 | return !stop; |
1159 | return !stop; |
1160 | } |
1160 | } |
1161 | |
1161 | |
|
|
1162 | /* routine for both players and monsters. We call this when |
|
|
1163 | * there is a possibility for our action distrubing our hiding |
|
|
1164 | * place or invisiblity spell. Artefact invisiblity causes |
|
|
1165 | * "noise" instead. If we arent invisible to begin with, we |
|
|
1166 | * return 0. |
|
|
1167 | */ |
|
|
1168 | static int |
|
|
1169 | action_makes_visible (object *op) |
|
|
1170 | { |
|
|
1171 | if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) |
|
|
1172 | { |
|
|
1173 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
|
|
1174 | { |
|
|
1175 | // artefact invisibility is permanent, but we still make noise |
|
|
1176 | // this is important for game-balance. |
|
|
1177 | if (op->contr) |
|
|
1178 | op->make_noise (); |
|
|
1179 | |
|
|
1180 | return 0; |
|
|
1181 | } |
|
|
1182 | |
|
|
1183 | if (op->contr && op->contr->tmp_invis == 0) |
|
|
1184 | return 0; |
|
|
1185 | |
|
|
1186 | /* If monsters, they should become visible */ |
|
|
1187 | if (op->flag [FLAG_HIDDEN] || !op->contr || (op->contr && op->contr->tmp_invis)) |
|
|
1188 | { |
|
|
1189 | new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->flag [FLAG_HIDDEN] ? "unhidden" : "visible"); |
|
|
1190 | return 1; |
|
|
1191 | } |
|
|
1192 | } |
|
|
1193 | |
|
|
1194 | return 0; |
|
|
1195 | } |
|
|
1196 | |
1162 | /* |
1197 | /* |
1163 | * Find an arrow in the inventory and after that |
1198 | * Find an arrow in the inventory and after that |
1164 | * in the right type container (quiver). Pointer to the |
1199 | * in the right type container (quiver). Pointer to the |
1165 | * found object is returned. |
1200 | * found object is returned. |
1166 | */ |
1201 | */ |
1167 | object * |
1202 | static object * |
1168 | find_arrow (object *op, const char *type) |
1203 | find_arrow (object *op, const char *type) |
1169 | { |
1204 | { |
1170 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1205 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1171 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
1206 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
1172 | return splay (tmp); |
1207 | return splay (tmp); |
… | |
… | |
1186 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1221 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1187 | * against the target. A full test is not performed, simply a basic test |
1222 | * against the target. A full test is not performed, simply a basic test |
1188 | * of resistances. The archer is making a quick guess at what he sees down |
1223 | * of resistances. The archer is making a quick guess at what he sees down |
1189 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1224 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1190 | */ |
1225 | */ |
1191 | object * |
1226 | static object * |
1192 | find_better_arrow (object *op, object *target, shstr_cmp type, int *better) |
1227 | find_better_arrow (object *op, object *target, shstr_cmp type, int *better) |
1193 | { |
1228 | { |
1194 | object *tmp = NULL, *arrow, *ntmp; |
1229 | object *tmp = NULL, *arrow, *ntmp; |
1195 | int attacknum, attacktype, betterby = 0, i; |
1230 | int attacknum, attacktype, betterby = 0, i; |
1196 | |
1231 | |
… | |
… | |
1265 | * find_better_arrow to find a decent arrow to use. |
1300 | * find_better_arrow to find a decent arrow to use. |
1266 | * op = the shooter |
1301 | * op = the shooter |
1267 | * type = bow->race |
1302 | * type = bow->race |
1268 | * dir = fire direction |
1303 | * dir = fire direction |
1269 | */ |
1304 | */ |
1270 | object * |
1305 | static object * |
1271 | pick_arrow_target (object *op, shstr_cmp type, int dir) |
1306 | pick_arrow_target (object *op, shstr_cmp type, int dir) |
1272 | { |
1307 | { |
1273 | object *tmp = NULL; |
1308 | object *tmp = NULL; |
1274 | maptile *m; |
1309 | maptile *m; |
1275 | int i, mflags, found, number; |
1310 | int i, mflags, found, number; |
… | |
… | |
1490 | * but monsters can't. Putting that code here |
1525 | * but monsters can't. Putting that code here |
1491 | * makes the fire_bow code much cleaner. |
1526 | * makes the fire_bow code much cleaner. |
1492 | * this function should only be called if 'op' is a player, |
1527 | * this function should only be called if 'op' is a player, |
1493 | * hence the function name. |
1528 | * hence the function name. |
1494 | */ |
1529 | */ |
1495 | int |
1530 | static int |
1496 | player_fire_bow (object *op, int dir) |
1531 | player_fire_bow (object *op, int dir) |
1497 | { |
1532 | { |
1498 | int ret; |
1533 | int ret; |
1499 | |
1534 | |
1500 | if (op->contr->bowtype == bow_bestarrow) |
1535 | if (op->contr->bowtype == bow_bestarrow) |
… | |
… | |
1528 | } |
1563 | } |
1529 | |
1564 | |
1530 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1565 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1531 | * Broken apart from 'fire' to keep it more readable. |
1566 | * Broken apart from 'fire' to keep it more readable. |
1532 | */ |
1567 | */ |
1533 | void |
1568 | static void |
1534 | fire_misc_object (object *op, int dir) |
1569 | fire_misc_object (object *op, int dir) |
1535 | { |
1570 | { |
1536 | object *item = op->contr->ranged_ob; |
1571 | object *item = op->contr->ranged_ob; |
1537 | |
1572 | |
1538 | if (!item) |
1573 | if (!item) |
… | |
… | |
1560 | return; |
1595 | return; |
1561 | } |
1596 | } |
1562 | } |
1597 | } |
1563 | else if (item->type == ROD || item->type == HORN) |
1598 | else if (item->type == ROD || item->type == HORN) |
1564 | { |
1599 | { |
1565 | sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace); |
1600 | sint16 spell_sp = max (item->inv->stats.sp, item->inv->stats.grace); |
1566 | |
1601 | |
1567 | // using the maximum of the rods charge allows at least one spell cast |
1602 | // using the maximum of the rods charge allows at least one spell cast |
1568 | // for a rod or horn, this fixes some broken rods. |
1603 | // for a rod or horn, this fixes some broken rods. |
1569 | if (item->stats.hp < MIN (spell_sp, item->stats.maxhp)) |
1604 | if (item->stats.hp < min (spell_sp, item->stats.maxhp)) |
1570 | { |
1605 | { |
1571 | op->contr->play_sound (sound_find ("wand_poof")); |
1606 | op->contr->play_sound (sound_find ("wand_poof")); |
1572 | |
1607 | |
1573 | if (item->type == ROD) |
1608 | if (item->type == ROD) |
1574 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
1609 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
… | |
… | |
1983 | } |
2018 | } |
1984 | |
2019 | |
1985 | bool |
2020 | bool |
1986 | move_player (object *op, int dir) |
2021 | move_player (object *op, int dir) |
1987 | { |
2022 | { |
1988 | int pick; |
|
|
1989 | |
|
|
1990 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2023 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
1991 | return 0; |
2024 | return 0; |
1992 | |
2025 | |
1993 | /* Sanity check: make sure dir is valid */ |
2026 | /* Sanity check: make sure dir is valid */ |
1994 | if ((dir < 0) || (dir >= 9)) |
2027 | if ((dir < 0) || (dir >= 9)) |
… | |
… | |
2005 | |
2038 | |
2006 | if (op->flag [FLAG_HIDDEN]) |
2039 | if (op->flag [FLAG_HIDDEN]) |
2007 | do_hidden_move (op); |
2040 | do_hidden_move (op); |
2008 | |
2041 | |
2009 | bool retval; |
2042 | bool retval; |
|
|
2043 | int pick = 0; |
2010 | |
2044 | |
2011 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
2045 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
2012 | retval = RESULT_INT (0); |
2046 | retval = RESULT_INT (0); |
2013 | else if (op->contr->fire_on) |
2047 | else if (op->contr->fire_on) |
2014 | retval = fire (op, dir); |
2048 | retval = fire (op, dir); |
… | |
… | |
2071 | return move_player (op, op->direction); |
2105 | return move_player (op, op->direction); |
2072 | |
2106 | |
2073 | return false; |
2107 | return false; |
2074 | } |
2108 | } |
2075 | |
2109 | |
2076 | int |
2110 | static int |
2077 | save_life (object *op) |
2111 | save_life (object *op) |
2078 | { |
2112 | { |
2079 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2113 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2080 | return 0; |
2114 | return 0; |
2081 | |
2115 | |
… | |
… | |
2128 | void |
2162 | void |
2129 | object::drop_unpaid_items () |
2163 | object::drop_unpaid_items () |
2130 | { |
2164 | { |
2131 | if (!flag [FLAG_REMOVED]) |
2165 | if (!flag [FLAG_REMOVED]) |
2132 | ::drop_unpaid_items (inv, this); |
2166 | ::drop_unpaid_items (inv, this); |
2133 | } |
|
|
2134 | |
|
|
2135 | /* |
|
|
2136 | * Returns pointer a static string containing gravestone text |
|
|
2137 | * Moved from apply.c to player.c - player.c is what |
|
|
2138 | * actually uses this function. player.c may not be quite the |
|
|
2139 | * best, a misc file for object actions is probably better, |
|
|
2140 | * but there isn't one in the server directory. |
|
|
2141 | */ |
|
|
2142 | const char * |
|
|
2143 | gravestone_text (object *op) |
|
|
2144 | { |
|
|
2145 | static dynbuf_text buf; |
|
|
2146 | |
|
|
2147 | buf << "---- R.I.P. ----\n\n" |
|
|
2148 | << op->name; |
|
|
2149 | |
|
|
2150 | if (op->type == PLAYER) |
|
|
2151 | buf << " the " << op->contr->title; |
|
|
2152 | |
|
|
2153 | buf << "\n\n"; |
|
|
2154 | |
|
|
2155 | buf << "who was level "; |
|
|
2156 | buf << (sint32)op->level << "\n\n" // OO breakdown |
|
|
2157 | << " when " << (op->contr ? "killed" : "died") << "\n\n"; |
|
|
2158 | |
|
|
2159 | if (op->type == PLAYER) |
|
|
2160 | buf << "by " << op->contr->killer_name () << ".\n\n"; |
|
|
2161 | |
|
|
2162 | { |
|
|
2163 | static char buf2[128]; |
|
|
2164 | time_t now = time (NULL); |
|
|
2165 | strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now)); |
|
|
2166 | buf << buf2; |
|
|
2167 | } |
|
|
2168 | |
|
|
2169 | return buf; |
|
|
2170 | } |
2167 | } |
2171 | |
2168 | |
2172 | void |
2169 | void |
2173 | do_some_living (object *op) |
2170 | do_some_living (object *op) |
2174 | { |
2171 | { |
… | |
… | |
2429 | return; |
2426 | return; |
2430 | |
2427 | |
2431 | dynbuf_text deathtab; |
2428 | dynbuf_text deathtab; |
2432 | |
2429 | |
2433 | /* restore player */ |
2430 | /* restore player */ |
2434 | at = archetype::find ("poisoning"); |
2431 | at = archetype::find (shstr_poisoning); |
2435 | if (object *tmp = present_arch_in_ob (at, op)) |
2432 | if (object *tmp = present_arch_in_ob (at, op)) |
2436 | { |
2433 | { |
2437 | tmp->destroy (); |
2434 | tmp->destroy (); |
2438 | deathtab << "Your body feels cleansed...\r"; |
2435 | deathtab << "Your body feels cleansed...\r"; |
2439 | } |
2436 | } |
2440 | |
2437 | |
2441 | at = archetype::find ("confusion"); |
2438 | at = archetype::find (shstr_confusion); |
2442 | if (object *tmp = present_arch_in_ob (at, op)) |
2439 | if (object *tmp = present_arch_in_ob (at, op)) |
2443 | { |
2440 | { |
2444 | tmp->destroy (); |
2441 | tmp->destroy (); |
2445 | deathtab << "Your mind feels clearer...\r"; |
2442 | deathtab << "Your mind feels clearer...\r"; |
2446 | } |
2443 | } |
… | |
… | |
2473 | if (op_on_battleground (op, &x, &y)) |
2470 | if (op_on_battleground (op, &x, &y)) |
2474 | { |
2471 | { |
2475 | deathtab << "You almost died in combat, but local medics have saved your life...\r"; |
2472 | deathtab << "You almost died in combat, but local medics have saved your life...\r"; |
2476 | |
2473 | |
2477 | /* create a bodypart-trophy to make the winner happy */ |
2474 | /* create a bodypart-trophy to make the winner happy */ |
2478 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2475 | if (object *tmp = arch_to_object (archetype::find (shstr_finger))) |
2479 | { |
2476 | { |
2480 | tmp->name = format ("%s's finger" , &op->name); |
2477 | tmp->name = format ("%s's finger" , &op->name); |
2481 | tmp->name_pl = format ("%s's fingers", &op->name); |
2478 | tmp->name_pl = format ("%s's fingers", &op->name); |
2482 | tmp->msg = format ( |
2479 | tmp->msg = format ( |
2483 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
2480 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
… | |
… | |
2558 | lost_a_stat = 1; |
2555 | lost_a_stat = 1; |
2559 | } |
2556 | } |
2560 | else |
2557 | else |
2561 | { |
2558 | { |
2562 | /* deplete a stat */ |
2559 | /* deplete a stat */ |
2563 | archetype *deparch = archetype::find ("depletion"); |
2560 | archetype *deparch = archetype::find (shstr_depletion); |
2564 | object *dep; |
2561 | object *dep; |
2565 | |
2562 | |
2566 | dep = present_arch_in_ob (deparch, op); |
2563 | dep = present_arch_in_ob (deparch, op); |
2567 | if (!dep) |
2564 | if (!dep) |
2568 | { |
2565 | { |
… | |
… | |
2640 | #endif |
2637 | #endif |
2641 | |
2638 | |
2642 | /* Put a gravestone up where the character 'almost' died. List the |
2639 | /* Put a gravestone up where the character 'almost' died. List the |
2643 | * exp loss on the stone. |
2640 | * exp loss on the stone. |
2644 | */ |
2641 | */ |
2645 | tmp = arch_to_object (archetype::find ("gravestone")); |
2642 | tmp = arch_to_object (archetype::find (shstr_gravestone)); |
2646 | tmp->name = format ("%s's gravestone", &op->name); |
2643 | tmp->name = format ("%s's gravestone", &op->name); |
2647 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2644 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2648 | tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n", |
2645 | tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n", |
2649 | &op->name, op->contr->title, op->contr->killer_name ()); |
2646 | &op->name, op->contr->title, op->contr->killer_name ()); |
2650 | tmp->x = op->x, tmp->y = op->y; |
2647 | tmp->x = op->x, tmp->y = op->y; |
… | |
… | |
2705 | } |
2702 | } |
2706 | |
2703 | |
2707 | op->contr->infobox (MSG_CHANNEL ("death"), deathtab); |
2704 | op->contr->infobox (MSG_CHANNEL ("death"), deathtab); |
2708 | } |
2705 | } |
2709 | |
2706 | |
2710 | void |
2707 | static void |
2711 | loot_object (object *op) |
2708 | loot_object (object *op) |
2712 | { /* Grab and destroy some treasure */ |
2709 | { /* Grab and destroy some treasure */ |
2713 | object *tmp, *tmp2, *next; |
2710 | object *tmp, *tmp2, *next; |
2714 | |
2711 | |
2715 | op->close_container (); /* close open sack first */ |
2712 | op->close_container (); /* close open sack first */ |
… | |
… | |
3017 | } |
3014 | } |
3018 | |
3015 | |
3019 | return 0; |
3016 | return 0; |
3020 | } |
3017 | } |
3021 | |
3018 | |
3022 | /* routine for both players and monsters. We call this when |
|
|
3023 | * there is a possibility for our action distrubing our hiding |
|
|
3024 | * place or invisiblity spell. Artefact invisiblity causes |
|
|
3025 | * "noise" instead. If we arent invisible to begin with, we |
|
|
3026 | * return 0. |
|
|
3027 | */ |
|
|
3028 | int |
|
|
3029 | action_makes_visible (object *op) |
|
|
3030 | { |
|
|
3031 | if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) |
|
|
3032 | { |
|
|
3033 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
|
|
3034 | { |
|
|
3035 | // artefact invisibility is permanent, but we still make noise |
|
|
3036 | // this is important for game-balance. |
|
|
3037 | if (op->contr) |
|
|
3038 | op->make_noise (); |
|
|
3039 | |
|
|
3040 | return 0; |
|
|
3041 | } |
|
|
3042 | |
|
|
3043 | if (op->contr && op->contr->tmp_invis == 0) |
|
|
3044 | return 0; |
|
|
3045 | |
|
|
3046 | /* If monsters, they should become visible */ |
|
|
3047 | if (op->flag [FLAG_HIDDEN] || !op->contr || (op->contr && op->contr->tmp_invis)) |
|
|
3048 | { |
|
|
3049 | new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->flag [FLAG_HIDDEN] ? "unhidden" : "visible"); |
|
|
3050 | return 1; |
|
|
3051 | } |
|
|
3052 | } |
|
|
3053 | |
|
|
3054 | return 0; |
|
|
3055 | } |
|
|
3056 | |
|
|
3057 | /* op_on_battleground - checks if the given object op (usually |
3019 | /* op_on_battleground - checks if the given object op (usually |
3058 | * a player) is standing on a valid battleground-tile, |
3020 | * a player) is standing on a valid battleground-tile, |
3059 | * function returns TRUE/FALSE. If true x, y returns the battleground |
3021 | * function returns TRUE/FALSE. If true x, y returns the battleground |
3060 | * -exit-coord. (and if x, y not NULL) |
3022 | * -exit-coord. (and if x, y not NULL) |
3061 | * 19 March 2005 - josh@woosworld.net modifed to check if the battleground also has slaying, maxhp, and maxsp set |
3023 | * 19 March 2005 - josh@woosworld.net modifed to check if the battleground also has slaying, maxhp, and maxsp set |