1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
133 | { |
133 | { |
134 | new_draw_info (NDI_UNIQUE, 0, pl, "Usage: ready_skill <skill name>"); |
134 | new_draw_info (NDI_UNIQUE, 0, pl, "Usage: ready_skill <skill name>"); |
135 | return 0; |
135 | return 0; |
136 | } |
136 | } |
137 | |
137 | |
138 | skill = find_skill_by_name (pl, params); |
138 | skill = find_skill_by_name_fuzzy (pl, params); |
139 | |
139 | |
140 | if (!skill) |
140 | if (!skill) |
141 | { |
141 | { |
142 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You have no knowledge of the skill %s", params); |
142 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You have no knowledge of the skill %s", params); |
143 | return 0; |
143 | return 0; |
144 | } |
144 | } |
145 | |
145 | |
146 | pl->change_skill (0); |
146 | pl->change_skill (0); |
147 | apply_special (pl, skill, AP_APPLY); |
147 | apply_special (pl, skill, AP_APPLY); |
148 | return 1; |
148 | return 1; |
149 | } |
|
|
150 | |
|
|
151 | /* These functions (command_search, command_disarm) are really just wrappers for |
|
|
152 | * things like 'use_skill ...'). In fact, they should really be obsoleted |
|
|
153 | * and replaced with those. |
|
|
154 | */ |
|
|
155 | int |
|
|
156 | command_search (object *op, char *params) |
|
|
157 | { |
|
|
158 | return use_skill (op, skill_names[SK_FIND_TRAPS]); |
|
|
159 | } |
|
|
160 | |
|
|
161 | int |
|
|
162 | command_disarm (object *op, char *params) |
|
|
163 | { |
|
|
164 | return use_skill (op, skill_names[SK_DISARM_TRAPS]); |
|
|
165 | } |
149 | } |
166 | |
150 | |
167 | /* A little special because we do want to pass the full params along |
151 | /* A little special because we do want to pass the full params along |
168 | * as it includes the object to throw. |
152 | * as it includes the object to throw. |
169 | */ |
153 | */ |
… | |
… | |
1072 | } |
1056 | } |
1073 | |
1057 | |
1074 | std::string |
1058 | std::string |
1075 | object::long_desc (object *who) |
1059 | object::long_desc (object *who) |
1076 | { |
1060 | { |
1077 | std::string buf (query_name (this)); |
1061 | std::string buf (query_name ()); |
1078 | |
1062 | |
1079 | switch (type) |
1063 | switch (type) |
1080 | { |
1064 | { |
1081 | case RING: |
1065 | case RING: |
1082 | case SKILL: |
1066 | case SKILL: |
… | |
… | |
1094 | case CLOAK: |
1078 | case CLOAK: |
1095 | case FOOD: |
1079 | case FOOD: |
1096 | case DRINK: |
1080 | case DRINK: |
1097 | case FLESH: |
1081 | case FLESH: |
1098 | case SKILL_TOOL: |
1082 | case SKILL_TOOL: |
|
|
1083 | case LAMP: |
1099 | case POWER_CRYSTAL: |
1084 | case POWER_CRYSTAL: |
1100 | { |
1085 | { |
1101 | const char *cp = ::describe_item (this, who); |
1086 | const char *cp = ::describe_item (this, who); |
1102 | |
1087 | |
1103 | if (*cp) |
1088 | if (*cp) |
… | |
… | |
1222 | static void |
1207 | static void |
1223 | display_new_pickup (object *op) |
1208 | display_new_pickup (object *op) |
1224 | { |
1209 | { |
1225 | int i = op->contr->mode; |
1210 | int i = op->contr->mode; |
1226 | |
1211 | |
1227 | if (!(i & PU_NEWMODE)) |
|
|
1228 | return; |
|
|
1229 | |
|
|
1230 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d NEWMODE", i & PU_NEWMODE ? 1 : 0); |
|
|
1231 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d DEBUG", i & PU_DEBUG ? 1 : 0); |
1212 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d DEBUG", i & PU_DEBUG ? 1 : 0); |
1232 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d INHIBIT", i & PU_INHIBIT ? 1 : 0); |
1213 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d INHIBIT", i & PU_INHIBIT ? 1 : 0); |
1233 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d STOP", i & PU_STOP ? 1 : 0); |
1214 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d STOP", i & PU_STOP ? 1 : 0); |
1234 | |
1215 | |
1235 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d <= x pickup weight/value RATIO (0==off)", (i & PU_RATIO) * 5); |
1216 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d <= x pickup weight/value RATIO (0==off)", (i & PU_RATIO) * 5); |
… | |
… | |
1286 | }; |
1267 | }; |
1287 | |
1268 | |
1288 | if (!params) |
1269 | if (!params) |
1289 | { |
1270 | { |
1290 | /* if the new mode is used, just print the settings */ |
1271 | /* if the new mode is used, just print the settings */ |
1291 | if (op->contr->mode & PU_NEWMODE) |
|
|
1292 | { |
|
|
1293 | display_new_pickup (op); |
1272 | display_new_pickup (op); |
1294 | return 1; |
|
|
1295 | } |
|
|
1296 | if (1) |
|
|
1297 | LOG (llevDebug, "command_pickup: !params\n"); |
|
|
1298 | set_pickup_mode (op, (op->contr->mode > 6) ? 0 : op->contr->mode + 1); |
|
|
1299 | return 0; |
1273 | return 0; |
1300 | } |
1274 | } |
1301 | |
1275 | |
1302 | while (*params == ' ' && *params) |
1276 | while (*params == ' ' && *params) |
1303 | params++; |
1277 | params++; |
… | |
… | |
1309 | for (mode = 0; names[mode]; mode++) |
1283 | for (mode = 0; names[mode]; mode++) |
1310 | { |
1284 | { |
1311 | if (!strcmp (names[mode], params + 1)) |
1285 | if (!strcmp (names[mode], params + 1)) |
1312 | { |
1286 | { |
1313 | i = op->contr->mode; |
1287 | i = op->contr->mode; |
1314 | if (!(i & PU_NEWMODE)) |
1288 | |
1315 | i = PU_NEWMODE; |
|
|
1316 | if (*params == '+') |
1289 | if (*params == '+') |
1317 | i = i | modes[mode]; |
1290 | i = i | modes[mode]; |
1318 | else |
1291 | else |
1319 | i = i & ~modes[mode]; |
1292 | i = i & ~modes[mode]; |
|
|
1293 | |
1320 | op->contr->mode = i; |
1294 | op->contr->mode = i; |
1321 | display_new_pickup (op); |
1295 | display_new_pickup (op); |
1322 | return 1; |
1296 | return 1; |
1323 | } |
1297 | } |
1324 | } |
1298 | } |
… | |
… | |
1326 | return 1; |
1300 | return 1; |
1327 | } |
1301 | } |
1328 | |
1302 | |
1329 | if (sscanf (params, "%u", &i) != 1) |
1303 | if (sscanf (params, "%u", &i) != 1) |
1330 | { |
1304 | { |
1331 | if (1) |
|
|
1332 | LOG (llevDebug, "command_pickup: params==NULL\n"); |
|
|
1333 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: pickup <0-7> or <value_density> ."); |
1305 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: pickup <value_density> or [+-]type."); |
1334 | return 1; |
1306 | return 1; |
1335 | } |
1307 | } |
1336 | set_pickup_mode (op, i); |
1308 | |
|
|
1309 | if (i <= PU_RATIO) |
|
|
1310 | i |= op->contr->mode & ~PU_RATIO; |
|
|
1311 | |
|
|
1312 | op->contr->mode = i; |
1337 | |
1313 | |
1338 | return 1; |
1314 | return 1; |
1339 | } |
|
|
1340 | |
|
|
1341 | void |
|
|
1342 | set_pickup_mode (object *op, int i) |
|
|
1343 | { |
|
|
1344 | switch (op->contr->mode = i) |
|
|
1345 | { |
|
|
1346 | case 0: |
|
|
1347 | new_draw_info (NDI_UNIQUE, 0, op, "Mode: Don't pick up."); |
|
|
1348 | break; |
|
|
1349 | case 1: |
|
|
1350 | new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up one item."); |
|
|
1351 | break; |
|
|
1352 | case 2: |
|
|
1353 | new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up one item and stop."); |
|
|
1354 | break; |
|
|
1355 | case 3: |
|
|
1356 | new_draw_info (NDI_UNIQUE, 0, op, "Mode: Stop before picking up."); |
|
|
1357 | break; |
|
|
1358 | case 4: |
|
|
1359 | new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up all items."); |
|
|
1360 | break; |
|
|
1361 | case 5: |
|
|
1362 | new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up all items and stop."); |
|
|
1363 | break; |
|
|
1364 | case 6: |
|
|
1365 | new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up all magic items."); |
|
|
1366 | break; |
|
|
1367 | case 7: |
|
|
1368 | new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up all coins and gems"); |
|
|
1369 | break; |
|
|
1370 | } |
|
|
1371 | } |
1315 | } |
1372 | |
1316 | |
1373 | int |
1317 | int |
1374 | command_search_items (object *op, char *params) |
1318 | command_search_items (object *op, char *params) |
1375 | { |
1319 | { |
1376 | char buf[MAX_BUF]; |
1320 | char buf[MAX_BUF]; |
1377 | |
1321 | |
1378 | if (settings.search_items == FALSE) |
|
|
1379 | return 1; |
|
|
1380 | |
|
|
1381 | if (params == NULL) |
1322 | if (params == NULL) |
1382 | { |
1323 | { |
1383 | if (op->contr->search_str[0] == '\0') |
1324 | if (op->contr->search_str[0] == '\0') |
1384 | { |
1325 | { |
1385 | new_draw_info (NDI_UNIQUE, 0, op, "Example: search magic+1"); |
1326 | new_draw_info (NDI_UNIQUE, 0, op, "Example: search-items magic+1"); |
1386 | new_draw_info (NDI_UNIQUE, 0, op, "Would automatically pick up all"); |
1327 | new_draw_info (NDI_UNIQUE, 0, op, "Would automatically pick up all"); |
1387 | new_draw_info (NDI_UNIQUE, 0, op, "items containing the word 'magic+1'."); |
1328 | new_draw_info (NDI_UNIQUE, 0, op, "items containing the word 'magic+1'."); |
1388 | return 1; |
1329 | return 1; |
1389 | } |
1330 | } |
1390 | |
1331 | |
… | |
… | |
1392 | new_draw_info (NDI_UNIQUE, 0, op, "Search mode turned off."); |
1333 | new_draw_info (NDI_UNIQUE, 0, op, "Search mode turned off."); |
1393 | op->update_stats (); |
1334 | op->update_stats (); |
1394 | return 1; |
1335 | return 1; |
1395 | } |
1336 | } |
1396 | |
1337 | |
1397 | if ((int) strlen (params) >= MAX_BUF) |
1338 | if (strlen (params) >= MAX_BUF) |
1398 | { |
1339 | { |
1399 | new_draw_info (NDI_UNIQUE, 0, op, "Search string too long."); |
1340 | new_draw_info (NDI_UNIQUE, 0, op, "Search string too long."); |
1400 | return 1; |
1341 | return 1; |
1401 | } |
1342 | } |
1402 | |
1343 | |
1403 | strcpy (op->contr->search_str, params); |
1344 | strcpy (op->contr->search_str, params); |
1404 | sprintf (buf, "Searching for '%s'.", op->contr->search_str); |
1345 | sprintf (buf, "Now searching for '%s'.", op->contr->search_str); |
1405 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1346 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1406 | op->update_stats (); |
1347 | op->update_stats (); |
|
|
1348 | |
1407 | return 1; |
1349 | return 1; |
1408 | } |
1350 | } |
1409 | |
1351 | |