… | |
… | |
986 | } |
986 | } |
987 | |
987 | |
988 | /* The find_traps skill (aka, search). Checks for traps |
988 | /* The find_traps skill (aka, search). Checks for traps |
989 | * on the spaces or in certain objects |
989 | * on the spaces or in certain objects |
990 | */ |
990 | */ |
991 | |
|
|
992 | int |
991 | int |
993 | find_traps (object *pl, object *skill) |
992 | find_traps (object *pl, object *skill) |
994 | { |
993 | { |
995 | object *tmp, *tmp2; |
994 | object *tmp, *tmp2; |
996 | int i, expsum = 0, mflags; |
995 | int i, expsum = 0, mflags; |
… | |
… | |
998 | maptile *m; |
997 | maptile *m; |
999 | |
998 | |
1000 | /* First we search all around us for runes and traps, which are |
999 | /* First we search all around us for runes and traps, which are |
1001 | * all type RUNE |
1000 | * all type RUNE |
1002 | */ |
1001 | */ |
1003 | |
|
|
1004 | for (i = 0; i < 9; i++) |
1002 | for (i = 0; i < 9; i++) |
1005 | { |
1003 | { |
1006 | x = pl->x + freearr_x[i]; |
1004 | x = pl->x + freearr_x[i]; |
1007 | y = pl->y + freearr_y[i]; |
1005 | y = pl->y + freearr_y[i]; |
1008 | m = pl->map; |
1006 | m = pl->map; |
… | |
… | |
1010 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1008 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1011 | if (mflags & P_OUT_OF_MAP) |
1009 | if (mflags & P_OUT_OF_MAP) |
1012 | continue; |
1010 | continue; |
1013 | |
1011 | |
1014 | /* Check everything in the square for trapness */ |
1012 | /* Check everything in the square for trapness */ |
1015 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1013 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1016 | { |
1014 | { |
1017 | |
|
|
1018 | /* And now we'd better do an inventory traversal of each |
1015 | /* And now we'd better do an inventory traversal of each |
1019 | * of these objects' inventory |
1016 | * of these objects' inventory |
1020 | * We can narrow this down a bit - no reason to search through |
1017 | * We can narrow this down a bit - no reason to search through |
1021 | * the players inventory or monsters for that matter. |
1018 | * the players inventory or monsters for that matter. |
1022 | */ |
1019 | */ |
1023 | if (tmp->type != PLAYER && !QUERY_FLAG (tmp, FLAG_MONSTER)) |
1020 | if (tmp->type != PLAYER && !QUERY_FLAG (tmp, FLAG_MONSTER)) |
1024 | { |
|
|
1025 | for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) |
1021 | for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) |
1026 | if (tmp2->type == RUNE || tmp2->type == TRAP) |
1022 | if (tmp2->type == RUNE || tmp2->type == TRAP) |
1027 | if (trap_see (pl, tmp2)) |
1023 | if (trap_see (pl, tmp2)) |
1028 | { |
1024 | { |
1029 | trap_show (tmp2, tmp); |
1025 | trap_show (tmp2, tmp); |
1030 | if (tmp2->stats.Cha > 1) |
1026 | if (tmp2->stats.Cha > 1) |
1031 | { |
1027 | { |
1032 | if (!tmp2->owner || tmp2->owner->type != PLAYER) |
1028 | if (!tmp2->owner || tmp2->owner->type != PLAYER) |
1033 | expsum += calc_skill_exp (pl, tmp2, skill); |
1029 | expsum += calc_skill_exp (pl, tmp2, skill); |
1034 | |
1030 | |
1035 | tmp2->stats.Cha = 1; /* unhide the trap */ |
1031 | tmp2->stats.Cha = 1; /* unhide the trap */ |
1036 | } |
1032 | } |
1037 | } |
1033 | } |
1038 | } |
1034 | |
1039 | if ((tmp->type == RUNE || tmp->type == TRAP) && trap_see (pl, tmp)) |
1035 | if ((tmp->type == RUNE || tmp->type == TRAP) && trap_see (pl, tmp)) |
1040 | { |
1036 | { |
1041 | trap_show (tmp, tmp); |
1037 | trap_show (tmp, tmp); |
1042 | if (tmp->stats.Cha > 1) |
1038 | if (tmp->stats.Cha > 1) |
1043 | { |
1039 | { |
… | |
… | |
1046 | tmp->stats.Cha = 1; /* unhide the trap */ |
1042 | tmp->stats.Cha = 1; /* unhide the trap */ |
1047 | } |
1043 | } |
1048 | } |
1044 | } |
1049 | } |
1045 | } |
1050 | } |
1046 | } |
|
|
1047 | |
1051 | new_draw_info (NDI_BLACK, 0, pl, "You search the area."); |
1048 | new_draw_info (NDI_BLACK, 0, pl, "You search the area."); |
1052 | return expsum; |
1049 | return expsum; |
1053 | } |
1050 | } |
1054 | |
1051 | |
1055 | /* remove_trap() - This skill will disarm any previously discovered trap |
1052 | /* remove_trap() - This skill will disarm any previously discovered trap |