ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.296 by root, Thu Nov 17 04:59:33 2016 UTC vs.
Revision 1.298 by root, Sun Jan 29 03:59:15 2017 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines