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

Comparing deliantra/server/server/skills.C (file contents):
Revision 1.71 by root, Sat Nov 7 13:58:01 2009 UTC vs.
Revision 1.73 by root, Sun Nov 8 13:36:14 2009 UTC

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;
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
992int 991int
993find_traps (object *pl, object *skill) 992find_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
1314 1311
1315 pl->contr->play_sound (sound_find ("inscribe_success")); 1312 pl->contr->play_sound (sound_find ("inscribe_success"));
1316 1313
1317 if (!confused) 1314 if (!confused)
1318 { 1315 {
1319 newscroll->level = MAX (skill->level, chosen_spell->level); 1316 newscroll->level = max (skill->level, chosen_spell->level);
1320 newscroll->flag [FLAG_IDENTIFIED] = true; 1317 newscroll->flag [FLAG_IDENTIFIED] = true;
1321 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.");
1322 } 1319 }
1323 else 1320 else
1324 { 1321 {
1325 chosen_spell = find_random_spell_in_ob (pl, NULL); 1322 chosen_spell = find_random_spell_in_ob (pl, NULL);
1326 if (!chosen_spell) 1323 if (!chosen_spell)
1327 return 0; 1324 return 0;
1328 1325
1329 newscroll->level = MAX (skill->level, chosen_spell->level); 1326 newscroll->level = max (skill->level, chosen_spell->level);
1330 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.");
1331 } 1328 }
1332 1329
1333 object *tmp = chosen_spell->clone (); 1330 object *tmp = chosen_spell->clone ();
1334 insert_ob_in_ob (tmp, newscroll); 1331 insert_ob_in_ob (tmp, newscroll);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines