… | |
… | |
49 | return -1; |
49 | return -1; |
50 | } |
50 | } |
51 | |
51 | |
52 | /* ADJUSTMENTS */ |
52 | /* ADJUSTMENTS */ |
53 | |
53 | |
54 | /* Its harder to steal from hostile beings! */ |
54 | /* It's harder to steal from hostile beings! */ |
55 | if (!QUERY_FLAG (victim, FLAG_UNAGGRESSIVE)) |
55 | if (!QUERY_FLAG (victim, FLAG_UNAGGRESSIVE)) |
56 | roll = roll / 2; |
56 | roll = roll / 2; |
57 | |
57 | |
58 | /* Easier to steal from sleeping beings, or if the thief is |
58 | /* Easier to steal from sleeping beings, or if the thief is |
59 | * unseen */ |
59 | * unseen */ |
… | |
… | |
315 | // reduce monster experience by experience we gained, as to |
315 | // reduce monster experience by experience we gained, as to |
316 | // limit the amount of exp that can be gained by stealing from monsters |
316 | // limit the amount of exp that can be gained by stealing from monsters |
317 | // (jessies gave ~20,000,000 exp otherwise. |
317 | // (jessies gave ~20,000,000 exp otherwise. |
318 | int exp = calc_skill_exp (op, tmp, skill); |
318 | int exp = calc_skill_exp (op, tmp, skill); |
319 | |
319 | |
320 | exp = MIN (tmp->stats.exp, exp); |
320 | exp = min (tmp->stats.exp, exp); |
321 | tmp->stats.exp -= exp; |
321 | tmp->stats.exp -= exp; |
322 | return exp; |
322 | return exp; |
323 | } |
323 | } |
324 | } |
324 | } |
325 | return 0; |
325 | return 0; |
… | |
… | |
482 | static void |
482 | static void |
483 | stop_jump (object *pl, int dist, int spaces) |
483 | stop_jump (object *pl, int dist, int spaces) |
484 | { |
484 | { |
485 | pl->update_stats (); |
485 | pl->update_stats (); |
486 | pl->map->insert (pl, pl->x, pl->y, pl); |
486 | pl->map->insert (pl, pl->x, pl->y, pl); |
487 | pl->speed_left -= fabs (pl->speed * 8); |
487 | pl->speed_left -= pl->speed * 8.; |
488 | } |
488 | } |
489 | |
489 | |
490 | static int |
490 | static int |
491 | attempt_jump (object *pl, int dir, int spaces, object *skill) |
491 | attempt_jump (object *pl, int dir, int spaces, object *skill) |
492 | { |
492 | { |
… | |
… | |
659 | } |
659 | } |
660 | |
660 | |
661 | /* Helper function for do_skill_ident, so that we can loop |
661 | /* Helper function for do_skill_ident, so that we can loop |
662 | * over inventory AND objects on the ground conveniently. |
662 | * over inventory AND objects on the ground conveniently. |
663 | */ |
663 | */ |
664 | int |
664 | static int |
665 | do_skill_ident2 (object *tmp, object *pl, int obj_class, object *skill) |
665 | do_skill_ident2 (object *tmp, object *pl, int obj_class, object *skill) |
666 | { |
666 | { |
667 | int success = 0, chance; |
667 | int success = 0, chance; |
668 | int skill_value = skill->level * pl->stats.Int ? pl->stats.Int : 10; |
668 | int skill_value = skill->level * pl->stats.Int ? pl->stats.Int : 10; |
669 | |
669 | |
… | |
… | |
925 | |
925 | |
926 | if (pl->type != PLAYER) |
926 | if (pl->type != PLAYER) |
927 | return 0; /* only players use this skill */ |
927 | return 0; /* only players use this skill */ |
928 | |
928 | |
929 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You sing."); |
929 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You sing."); |
930 | for (i = 0; i < MIN (skill->level, SIZEOFFREE); i++) |
930 | for (i = 0; i < min (skill->level, SIZEOFFREE); i++) |
931 | { |
931 | { |
932 | x = pl->x + freearr_x[i]; |
932 | x = pl->x + freearr_x[i]; |
933 | y = pl->y + freearr_y[i]; |
933 | y = pl->y + freearr_y[i]; |
934 | m = pl->map; |
934 | m = pl->map; |
935 | |
935 | |
… | |
… | |
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 |
… | |
… | |
1072 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1069 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1073 | if (mflags & P_OUT_OF_MAP) |
1070 | if (mflags & P_OUT_OF_MAP) |
1074 | continue; |
1071 | continue; |
1075 | |
1072 | |
1076 | /* Check everything in the square for trapness */ |
1073 | /* Check everything in the square for trapness */ |
1077 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1074 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1078 | { |
1075 | { |
1079 | /* And now we'd better do an inventory traversal of each |
1076 | /* And now we'd better do an inventory traversal of each |
1080 | * of these objects inventory. Like above, only |
1077 | * of these objects inventory. Like above, only |
1081 | * do this for interesting objects. |
1078 | * do this for interesting objects. |
1082 | */ |
1079 | */ |
1083 | |
1080 | |
1084 | if (tmp->type != PLAYER && !QUERY_FLAG (tmp, FLAG_MONSTER)) |
1081 | if (tmp->type != PLAYER && !QUERY_FLAG (tmp, FLAG_MONSTER)) |
1085 | { |
1082 | { |
1086 | for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) |
1083 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1087 | if ((tmp2->type == RUNE || tmp2->type == TRAP) && tmp2->stats.Cha <= 1) |
1084 | if ((tmp2->type == RUNE || tmp2->type == TRAP) && tmp2->stats.Cha <= 1) |
1088 | { |
1085 | { |
1089 | trap_show (tmp2, tmp); |
1086 | trap_show (tmp2, tmp); |
|
|
1087 | |
1090 | if (trap_disarm (op, tmp2, 1, skill) && (!tmp2->owner || tmp2->owner->type != PLAYER)) |
1088 | if (trap_disarm (op, tmp2, 1, skill) && (!tmp2->owner || tmp2->owner->type != PLAYER)) |
1091 | { |
1089 | { |
1092 | tmp->stats.exp = tmp->stats.Cha * tmp->level; |
1090 | tmp->stats.exp = tmp->stats.Cha * tmp->level; |
1093 | success += calc_skill_exp (op, tmp2, skill); |
1091 | success += calc_skill_exp (op, tmp2, skill); |
1094 | } |
1092 | } |
1095 | } |
1093 | } |
1096 | } |
1094 | } |
|
|
1095 | |
1097 | if ((tmp->type == RUNE || tmp->type == TRAP) && tmp->stats.Cha <= 1) |
1096 | if ((tmp->type == RUNE || tmp->type == TRAP) && tmp->stats.Cha <= 1) |
1098 | { |
1097 | { |
1099 | trap_show (tmp, tmp); |
1098 | trap_show (tmp, tmp); |
1100 | |
1099 | |
1101 | if (trap_disarm (op, tmp, 1, skill) && (!tmp->owner || tmp->owner->type != PLAYER)) |
1100 | if (trap_disarm (op, tmp, 1, skill) && (!tmp->owner || tmp->owner->type != PLAYER)) |
… | |
… | |
1238 | |
1237 | |
1239 | STRLEN char_len = utf8_length ((U8 *)msg, (U8 *)(msg+len)); |
1238 | STRLEN char_len = utf8_length ((U8 *)msg, (U8 *)(msg+len)); |
1240 | |
1239 | |
1241 | if (char_len <= item->weight_limit) |
1240 | if (char_len <= item->weight_limit) |
1242 | { |
1241 | { |
1243 | object *newbook = arch_to_object (item->other_arch); |
1242 | object *newbook = item->other_arch->instance (); |
1244 | item->decrease (); |
1243 | item->decrease (); |
1245 | newbook->nrof = 1; |
1244 | newbook->nrof = 1; |
1246 | newbook->msg = shstr (msg); |
1245 | newbook->msg = shstr (msg); |
1247 | newbook->flag [FLAG_IDENTIFIED] = true; |
1246 | newbook->flag [FLAG_IDENTIFIED] = true; |
1248 | |
1247 | |
… | |
… | |
1304 | pl->stats.grace -= SP_level_spellpoint_cost (pl, chosen_spell, SPELL_GRACE); |
1303 | pl->stats.grace -= SP_level_spellpoint_cost (pl, chosen_spell, SPELL_GRACE); |
1305 | pl->stats.sp -= SP_level_spellpoint_cost (pl, chosen_spell, SPELL_MANA); |
1304 | pl->stats.sp -= SP_level_spellpoint_cost (pl, chosen_spell, SPELL_MANA); |
1306 | |
1305 | |
1307 | if (random_roll (0, chosen_spell->level * 4 - 1, pl, PREFER_LOW) < skill->level) |
1306 | if (random_roll (0, chosen_spell->level * 4 - 1, pl, PREFER_LOW) < skill->level) |
1308 | { |
1307 | { |
1309 | object *newscroll = arch_to_object (scroll->other_arch); |
1308 | object *newscroll = scroll->other_arch->instance (); |
1310 | scroll->decrease (); |
1309 | scroll->decrease (); |
1311 | newscroll->nrof = 1; |
1310 | newscroll->nrof = 1; |
1312 | |
1311 | |
1313 | pl->contr->play_sound (sound_find ("inscribe_success")); |
1312 | pl->contr->play_sound (sound_find ("inscribe_success")); |
1314 | |
1313 | |
1315 | if (!confused) |
1314 | if (!confused) |
1316 | { |
1315 | { |
1317 | newscroll->level = MAX (skill->level, chosen_spell->level); |
1316 | newscroll->level = max (skill->level, chosen_spell->level); |
1318 | newscroll->flag [FLAG_IDENTIFIED] = true; |
1317 | newscroll->flag [FLAG_IDENTIFIED] = true; |
1319 | new_draw_info (NDI_UNIQUE, 0, pl, "You succeed in writing the spell."); |
1318 | new_draw_info (NDI_UNIQUE, 0, pl, "You succeed in writing the spell."); |
1320 | } |
1319 | } |
1321 | else |
1320 | else |
1322 | { |
1321 | { |
1323 | chosen_spell = find_random_spell_in_ob (pl, NULL); |
1322 | chosen_spell = find_random_spell_in_ob (pl, NULL); |
1324 | if (!chosen_spell) |
1323 | if (!chosen_spell) |
1325 | return 0; |
1324 | return 0; |
1326 | |
1325 | |
1327 | newscroll->level = MAX (skill->level, chosen_spell->level); |
1326 | newscroll->level = max (skill->level, chosen_spell->level); |
1328 | new_draw_info (NDI_UNIQUE, 0, pl, "In your confused state, you write down some odd spell."); |
1327 | new_draw_info (NDI_UNIQUE, 0, pl, "In your confused state, you write down some odd spell."); |
1329 | } |
1328 | } |
1330 | |
1329 | |
1331 | object *tmp = chosen_spell->clone (); |
1330 | object *tmp = chosen_spell->clone (); |
1332 | insert_ob_in_ob (tmp, newscroll); |
1331 | insert_ob_in_ob (tmp, newscroll); |