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

Comparing deliantra/server/server/c_object.C (file contents):
Revision 1.81 by elmex, Mon Oct 6 18:26:35 2008 UTC vs.
Revision 1.89 by elmex, Mon Jan 12 00:17:23 2009 UTC

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 */
155int
156command_search (object *op, char *params)
157{
158 return use_skill (op, skill_names[SK_FIND_TRAPS]);
159}
160
161int
162command_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 */
520 504
521 return 0; 505 return 0;
522} 506}
523 507
524/* 508/*
525 * This function was part of drop, now is own function. 509 * This function was part of drop, now is own function.
526 * Player 'op' tries to put object 'tmp' into sack 'sack', 510 * Player 'op' tries to put object 'tmp' into sack 'sack',
527 * if nrof is non zero, then nrof objects is tried to put into sack. 511 * if nrof is non zero, then nrof objects is tried to put into sack.
512 *
528 * Note that the 'sack' in question can now be a transport, 513 * Note that the 'sack' in question can now be a transport,
529 * so this function isn't named very good anymore. 514 * so this function isn't named very good anymore.
530 */ 515 */
531void 516void
532put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) 517put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof)
611 if (!can_split (op, tmp, nrof)) 596 if (!can_split (op, tmp, nrof))
612 return; 597 return;
613 598
614 drop_object (op, tmp); 599 drop_object (op, tmp);
615 600
616 if (!tmp->destroyed () && !tmp->is_in_map_or_inv ()) 601 if (!tmp->destroyed () && !tmp->is_inserted ())
617 { 602 {
618 // if nothing happened with the object we give it back 603 // if nothing happened with the object we give it back
619 op->insert (tmp); 604 op->insert (tmp);
620 } 605 }
621} 606}
635drop_object (object *dropper, object *obj) 620drop_object (object *dropper, object *obj)
636{ 621{
637 if (INVOKE_OBJECT (DROP, obj, ARG_OBJECT (dropper))) 622 if (INVOKE_OBJECT (DROP, obj, ARG_OBJECT (dropper)))
638 return; 623 return;
639 624
640 // safe guard for programming errors:
641 if (obj->destroyed () || obj->is_in_map_or_inv ()) 625 if (obj->destroyed () || obj->is_inserted ())
642 {
643 LOG (llevError, "BUG: A plugin destroyed or put the object somewhere without overriding the DROP event (%s)!", obj->debug_desc ());
644 return; 626 return;
645 }
646 627
647 if (QUERY_FLAG (obj, FLAG_STARTEQUIP)) 628 if (QUERY_FLAG (obj, FLAG_STARTEQUIP))
648 { 629 {
649 dropper->statusmsg (format ("You drop the %s.", query_name (obj))); 630 dropper->statusmsg (format ("You drop the %s.", query_name (obj)));
650 dropper->statusmsg ("The god who lent it to you retrieves it."); 631 dropper->statusmsg ("The god who lent it to you retrieves it.");
658 floor; 639 floor;
659 floor = floor->above) 640 floor = floor->above)
660 if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (obj), ARG_OBJECT (dropper))) 641 if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (obj), ARG_OBJECT (dropper)))
661 return; 642 return;
662 643
663 // safe guard for programming errors:
664 if (obj->destroyed () || obj->is_in_map_or_inv ()) 644 if (obj->destroyed () || obj->is_inserted ())
665 {
666 LOG (llevError, "BUG: A plugin destroyed or put the object somewhere without overriding the DROP_ON event (%s)!", obj->debug_desc ());
667 return; 645 return;
668 }
669 646
670 if (is_in_shop (dropper) && !QUERY_FLAG (obj, FLAG_UNPAID) && obj->type != MONEY) 647 if (is_in_shop (dropper) && !QUERY_FLAG (obj, FLAG_UNPAID) && obj->type != MONEY)
671 if (!sell_item (obj, dropper)) 648 if (!sell_item (obj, dropper))
672 return; 649 return;
673 650
1079} 1056}
1080 1057
1081std::string 1058std::string
1082object::long_desc (object *who) 1059object::long_desc (object *who)
1083{ 1060{
1084 std::string buf (query_name (this)); 1061 std::string buf (query_name ());
1085 1062
1086 switch (type) 1063 switch (type)
1087 { 1064 {
1088 case RING: 1065 case RING:
1089 case SKILL: 1066 case SKILL:
1101 case CLOAK: 1078 case CLOAK:
1102 case FOOD: 1079 case FOOD:
1103 case DRINK: 1080 case DRINK:
1104 case FLESH: 1081 case FLESH:
1105 case SKILL_TOOL: 1082 case SKILL_TOOL:
1083 case LAMP:
1106 case POWER_CRYSTAL: 1084 case POWER_CRYSTAL:
1107 { 1085 {
1108 const char *cp = ::describe_item (this, who); 1086 const char *cp = ::describe_item (this, who);
1109 1087
1110 if (*cp) 1088 if (*cp)
1139 1117
1140 switch (type) 1118 switch (type)
1141 { 1119 {
1142 case SPELLBOOK: 1120 case SPELLBOOK:
1143 if (flag [FLAG_IDENTIFIED] && inv) 1121 if (flag [FLAG_IDENTIFIED] && inv)
1144 buf.printf ("%s is a %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill); 1122 buf.printf ("%s is a level %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill);
1145 break; 1123 break;
1146 1124
1147 case BOOK: 1125 case BOOK:
1148 if (msg) 1126 if (msg)
1149 buf << "Something is written in it.\r"; 1127 buf << "Something is written in it.\r";
1229static void 1207static void
1230display_new_pickup (object *op) 1208display_new_pickup (object *op)
1231{ 1209{
1232 int i = op->contr->mode; 1210 int i = op->contr->mode;
1233 1211
1234 if (!(i & PU_NEWMODE))
1235 return;
1236
1237 new_draw_info_format (NDI_UNIQUE, 0, op, "%d NEWMODE", i & PU_NEWMODE ? 1 : 0);
1238 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);
1239 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);
1240 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);
1241 1215
1242 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);
1293 }; 1267 };
1294 1268
1295 if (!params) 1269 if (!params)
1296 { 1270 {
1297 /* if the new mode is used, just print the settings */ 1271 /* if the new mode is used, just print the settings */
1298 if (op->contr->mode & PU_NEWMODE)
1299 {
1300 display_new_pickup (op); 1272 display_new_pickup (op);
1301 return 1;
1302 }
1303 if (1)
1304 LOG (llevDebug, "command_pickup: !params\n");
1305 set_pickup_mode (op, (op->contr->mode > 6) ? 0 : op->contr->mode + 1);
1306 return 0; 1273 return 0;
1307 } 1274 }
1308 1275
1309 while (*params == ' ' && *params) 1276 while (*params == ' ' && *params)
1310 params++; 1277 params++;
1316 for (mode = 0; names[mode]; mode++) 1283 for (mode = 0; names[mode]; mode++)
1317 { 1284 {
1318 if (!strcmp (names[mode], params + 1)) 1285 if (!strcmp (names[mode], params + 1))
1319 { 1286 {
1320 i = op->contr->mode; 1287 i = op->contr->mode;
1321 if (!(i & PU_NEWMODE)) 1288
1322 i = PU_NEWMODE;
1323 if (*params == '+') 1289 if (*params == '+')
1324 i = i | modes[mode]; 1290 i = i | modes[mode];
1325 else 1291 else
1326 i = i & ~modes[mode]; 1292 i = i & ~modes[mode];
1293
1327 op->contr->mode = i; 1294 op->contr->mode = i;
1328 display_new_pickup (op); 1295 display_new_pickup (op);
1329 return 1; 1296 return 1;
1330 } 1297 }
1331 } 1298 }
1333 return 1; 1300 return 1;
1334 } 1301 }
1335 1302
1336 if (sscanf (params, "%u", &i) != 1) 1303 if (sscanf (params, "%u", &i) != 1)
1337 { 1304 {
1338 if (1)
1339 LOG (llevDebug, "command_pickup: params==NULL\n");
1340 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.");
1341 return 1; 1306 return 1;
1342 } 1307 }
1343 set_pickup_mode (op, i); 1308
1309 if (i <= PU_RATIO)
1310 i |= op->contr->mode & ~PU_RATIO;
1311
1312 op->contr->mode = i;
1344 1313
1345 return 1; 1314 return 1;
1346}
1347
1348void
1349set_pickup_mode (object *op, int i)
1350{
1351 switch (op->contr->mode = i)
1352 {
1353 case 0:
1354 new_draw_info (NDI_UNIQUE, 0, op, "Mode: Don't pick up.");
1355 break;
1356 case 1:
1357 new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up one item.");
1358 break;
1359 case 2:
1360 new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up one item and stop.");
1361 break;
1362 case 3:
1363 new_draw_info (NDI_UNIQUE, 0, op, "Mode: Stop before picking up.");
1364 break;
1365 case 4:
1366 new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up all items.");
1367 break;
1368 case 5:
1369 new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up all items and stop.");
1370 break;
1371 case 6:
1372 new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up all magic items.");
1373 break;
1374 case 7:
1375 new_draw_info (NDI_UNIQUE, 0, op, "Mode: Pick up all coins and gems");
1376 break;
1377 }
1378} 1315}
1379 1316
1380int 1317int
1381command_search_items (object *op, char *params) 1318command_search_items (object *op, char *params)
1382{ 1319{
1383 char buf[MAX_BUF]; 1320 char buf[MAX_BUF];
1384 1321
1385 if (settings.search_items == FALSE)
1386 return 1;
1387
1388 if (params == NULL) 1322 if (params == NULL)
1389 { 1323 {
1390 if (op->contr->search_str[0] == '\0') 1324 if (op->contr->search_str[0] == '\0')
1391 { 1325 {
1392 new_draw_info (NDI_UNIQUE, 0, op, "Example: search magic+1"); 1326 new_draw_info (NDI_UNIQUE, 0, op, "Example: search-items magic+1");
1393 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");
1394 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'.");
1395 return 1; 1329 return 1;
1396 } 1330 }
1397 1331
1399 new_draw_info (NDI_UNIQUE, 0, op, "Search mode turned off."); 1333 new_draw_info (NDI_UNIQUE, 0, op, "Search mode turned off.");
1400 op->update_stats (); 1334 op->update_stats ();
1401 return 1; 1335 return 1;
1402 } 1336 }
1403 1337
1404 if ((int) strlen (params) >= MAX_BUF) 1338 if (strlen (params) >= MAX_BUF)
1405 { 1339 {
1406 new_draw_info (NDI_UNIQUE, 0, op, "Search string too long."); 1340 new_draw_info (NDI_UNIQUE, 0, op, "Search string too long.");
1407 return 1; 1341 return 1;
1408 } 1342 }
1409 1343
1410 strcpy (op->contr->search_str, params); 1344 strcpy (op->contr->search_str, params);
1411 sprintf (buf, "Searching for '%s'.", op->contr->search_str); 1345 sprintf (buf, "Now searching for '%s'.", op->contr->search_str);
1412 new_draw_info (NDI_UNIQUE, 0, op, buf); 1346 new_draw_info (NDI_UNIQUE, 0, op, buf);
1413 op->update_stats (); 1347 op->update_stats ();
1348
1414 return 1; 1349 return 1;
1415} 1350}
1416 1351

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines