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