… | |
… | |
327 | #endif |
327 | #endif |
328 | return op; |
328 | return op; |
329 | } |
329 | } |
330 | |
330 | |
331 | /* I believe this can safely go to 2, 3 is questionable, 4 will likely |
331 | /* I believe this can safely go to 2, 3 is questionable, 4 will likely |
332 | * result in a monster paths backtracking. It basically determines how large a |
332 | * result in a monster paths backtracking. It basically determines how large a |
333 | * detour a monster will take from the direction path when looking |
333 | * detour a monster will take from the direction path when looking |
334 | * for a path to the player. The values are in the amount of direction |
334 | * for a path to the player. The values are in the amount of direction |
335 | * the deviation is |
335 | * the deviation is |
336 | */ |
336 | */ |
337 | #define DETOUR_AMOUNT 2 |
337 | #define DETOUR_AMOUNT 2 |
… | |
… | |
416 | } |
416 | } |
417 | else |
417 | else |
418 | { |
418 | { |
419 | /* direct path is blocked - try taking a side step to |
419 | /* direct path is blocked - try taking a side step to |
420 | * either the left or right. |
420 | * either the left or right. |
421 | * Note increase the values in the loop below to be |
421 | * Note increase the values in the loop below to be |
422 | * more than -1/1 respectively will mean the monster takes |
422 | * more than -1/1 respectively will mean the monster takes |
423 | * bigger detour. Have to be careful about these values getting |
423 | * bigger detour. Have to be careful about these values getting |
424 | * too big (3 or maybe 4 or higher) as the monster may just try |
424 | * too big (3 or maybe 4 or higher) as the monster may just try |
425 | * stepping back and forth |
425 | * stepping back and forth |
426 | */ |
426 | */ |
… | |
… | |
511 | for (object *next, *op = pl->inv; op; op = next) |
511 | for (object *next, *op = pl->inv; op; op = next) |
512 | { |
512 | { |
513 | next = op->below; |
513 | next = op->below; |
514 | |
514 | |
515 | /* Forces get applied per default, unless they have the |
515 | /* Forces get applied per default, unless they have the |
516 | * flag "neutral" set. Sorry but I can't think of a better way |
516 | * flag "neutral" set. Sorry but I can't think of a better way |
517 | */ |
517 | */ |
518 | if (op->type == FORCE && !op->flag [FLAG_NEUTRAL]) |
518 | if (op->type == FORCE && !op->flag [FLAG_NEUTRAL]) |
519 | op->set_flag (FLAG_APPLIED); |
519 | op->set_flag (FLAG_APPLIED); |
520 | |
520 | |
521 | /* we never give weapons/armour if these cannot be used |
521 | /* we never give weapons/armour if these cannot be used |
522 | * by this player due to race restrictions |
522 | * by this player due to race restrictions |
523 | */ |
523 | */ |
524 | if (pl->type == PLAYER) |
524 | if (pl->type == PLAYER) |
525 | { |
525 | { |
526 | if ((!pl->flag [FLAG_USE_ARMOUR] |
526 | if ((!pl->flag [FLAG_USE_ARMOUR] |
527 | && |
527 | && |
… | |
… | |
1149 | } |
1149 | } |
1150 | |
1150 | |
1151 | /* routine for both players and monsters. We call this when |
1151 | /* routine for both players and monsters. We call this when |
1152 | * there is a possibility for our action distrubing our hiding |
1152 | * there is a possibility for our action distrubing our hiding |
1153 | * place or invisiblity spell. Artefact invisiblity causes |
1153 | * place or invisiblity spell. Artefact invisiblity causes |
1154 | * "noise" instead. If we arent invisible to begin with, we |
1154 | * "noise" instead. If we arent invisible to begin with, we |
1155 | * return 0. |
1155 | * return 0. |
1156 | */ |
1156 | */ |
1157 | static int |
1157 | static int |
1158 | action_makes_visible (object *op) |
1158 | action_makes_visible (object *op) |
1159 | { |
1159 | { |
1160 | if (op->invisible && op->flag [FLAG_ALIVE]) |
1160 | if (op->invisible && op->flag [FLAG_ALIVE]) |
… | |
… | |
1183 | return 0; |
1183 | return 0; |
1184 | } |
1184 | } |
1185 | |
1185 | |
1186 | /* |
1186 | /* |
1187 | * Find an arrow in the inventory and after that |
1187 | * Find an arrow in the inventory and after that |
1188 | * in the right type container (quiver). Pointer to the |
1188 | * in the right type container (quiver). Pointer to the |
1189 | * found object is returned. |
1189 | * found object is returned. |
1190 | */ |
1190 | */ |
1191 | static object * |
1191 | static object * |
1192 | find_arrow (object *op, const char *type) |
1192 | find_arrow (object *op, const char *type) |
1193 | { |
1193 | { |
… | |
… | |
1346 | |
1346 | |
1347 | return find_better_arrow (op, tmp, type, &i); |
1347 | return find_better_arrow (op, tmp, type, &i); |
1348 | } |
1348 | } |
1349 | |
1349 | |
1350 | /* |
1350 | /* |
1351 | * Creature fires a bow - op can be monster or player. Returns |
1351 | * Creature fires a bow - op can be monster or player. Returns |
1352 | * 1 if bow was actually fired, 0 otherwise. |
1352 | * 1 if bow was actually fired, 0 otherwise. |
1353 | * op is the object firing the bow. |
1353 | * op is the object firing the bow. |
1354 | * part is for multipart creatures - the part firing the bow. |
1354 | * part is for multipart creatures - the part firing the bow. |
1355 | * dir is the direction of fire. |
1355 | * dir is the direction of fire. |
1356 | * wc_mod is any special modifier to give (used in special player fire modes) |
1356 | * wc_mod is any special modifier to give (used in special player fire modes) |
… | |
… | |
1704 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1704 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1705 | { |
1705 | { |
1706 | if (door->type == DOOR && tmp->type == KEY) |
1706 | if (door->type == DOOR && tmp->type == KEY) |
1707 | break; |
1707 | break; |
1708 | |
1708 | |
1709 | /* For sanity, we should really check door type, but other stuff |
1709 | /* For sanity, we should really check door type, but other stuff |
1710 | * (like containers) can be locked with special keys |
1710 | * (like containers) can be locked with special keys |
1711 | */ |
1711 | */ |
1712 | if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying) |
1712 | if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying) |
1713 | break; |
1713 | break; |
1714 | } |
1714 | } |
… | |
… | |
1768 | /* find_key |
1768 | /* find_key |
1769 | * We try to find a key for the door as passed. If we find a key |
1769 | * We try to find a key for the door as passed. If we find a key |
1770 | * and successfully use it, we return the key, otherwise NULL |
1770 | * and successfully use it, we return the key, otherwise NULL |
1771 | * This function merges both normal and locked door, since the logic |
1771 | * This function merges both normal and locked door, since the logic |
1772 | * for both is the same - just the specific key is different. |
1772 | * for both is the same - just the specific key is different. |
1773 | * pl is the player, |
1773 | * pl is the player, |
1774 | * inv is the objects inventory to searched |
1774 | * inv is the objects inventory to searched |
1775 | * door is the door we are trying to match against. |
1775 | * door is the door we are trying to match against. |
1776 | * This function can be called recursively to search containers. |
1776 | * This function can be called recursively to search containers. |
1777 | */ |
1777 | */ |
1778 | object * |
1778 | object * |
1779 | find_key (object *pl, object *container, object *door) |
1779 | find_key (object *pl, object *container, object *door) |
… | |
… | |
2597 | |
2597 | |
2598 | /* There is a maximum depletion total per level. */ |
2598 | /* There is a maximum depletion total per level. */ |
2599 | if (this_stat < -1 - op->level / BALSL_MAX_LOSS_RATIO) |
2599 | if (this_stat < -1 - op->level / BALSL_MAX_LOSS_RATIO) |
2600 | { |
2600 | { |
2601 | lose_this_stat = 0; |
2601 | lose_this_stat = 0; |
2602 | /* Take loss chance vs keep chance to see if we |
2602 | /* Take loss chance vs keep chance to see if we |
2603 | retain the stat. */ |
2603 | retain the stat. */ |
2604 | } |
2604 | } |
2605 | else |
2605 | else |
2606 | { |
2606 | { |
2607 | if (random_roll (0, loss_chance + keep_chance - 1, op, PREFER_LOW) < keep_chance) |
2607 | if (random_roll (0, loss_chance + keep_chance - 1, op, PREFER_LOW) < keep_chance) |
… | |
… | |
3007 | |
3007 | |
3008 | get_rangevector (pl, op, &rv, 0x1); |
3008 | get_rangevector (pl, op, &rv, 0x1); |
3009 | |
3009 | |
3010 | /* starting with the 'head' part, lets loop |
3010 | /* starting with the 'head' part, lets loop |
3011 | * through the object and find if it has any |
3011 | * through the object and find if it has any |
3012 | * part that is in the los array but isn't on |
3012 | * part that is in the los array but isn't on |
3013 | * a blocked los square. |
3013 | * a blocked los square. |
3014 | * we use the archetype to figure out offsets. |
3014 | * we use the archetype to figure out offsets. |
3015 | */ |
3015 | */ |
3016 | while (op) |
3016 | while (op) |
3017 | { |
3017 | { |