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.114 by root, Sat Apr 3 17:15:19 2010 UTC vs.
Revision 1.119 by root, Sat Apr 10 04:54:09 2010 UTC

189 189
190 while (*params == ' ') 190 while (*params == ' ')
191 params++; 191 params++;
192 192
193 if (object *inv = find_best_apply_object_match (op, params, aflag)) 193 if (object *inv = find_best_apply_object_match (op, params, aflag))
194 player_apply (op, inv, aflag); 194 op->apply (inv, aflag);
195 else 195 else
196 new_draw_info_format (NDI_UNIQUE, 0, op, "Could not find any match to the %s.", params); 196 op->failmsgf ("Could not find any match to the %s.", params);
197 } 197 }
198 198
199 return 0; 199 return 0;
200} 200}
201 201
556 */ 556 */
557 if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp, (nrof ? nrof : tmp->nrof))) 557 if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp, (nrof ? nrof : tmp->nrof)))
558 return; 558 return;
559 559
560 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 560 if (QUERY_FLAG (tmp, FLAG_APPLIED))
561 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 561 if (!op->apply (tmp, AP_UNAPPLY | AP_NO_MERGE))
562 return; 562 return;
563 563
564 /* we want to put some portion of the item into the container */ 564 /* we want to put some portion of the item into the container */
565 if (!can_split (op, tmp, nrof)) 565 if (!can_split (op, tmp, nrof))
566 return; 566 return;
605 return; 605 return;
606 606
607 if (obj->destroyed () || obj->is_inserted ()) 607 if (obj->destroyed () || obj->is_inserted ())
608 return; 608 return;
609 609
610 if (is_in_shop (dropper) && !QUERY_FLAG (obj, FLAG_UNPAID) && obj->type != MONEY) 610 if (dropper->is_in_shop () && !QUERY_FLAG (obj, FLAG_UNPAID) && obj->type != MONEY)
611 if (!sell_item (obj, dropper)) 611 if (!sell_item (obj, dropper))
612 return; 612 return;
613 613
614 if (!obj->can_drop_at (dropper->map, dropper->x, dropper->y, dropper)) 614 if (!obj->can_drop_at (dropper->map, dropper->x, dropper->y, dropper))
615 return; 615 return;
635{ 635{
636 if (QUERY_FLAG (tmp, FLAG_NO_DROP)) 636 if (QUERY_FLAG (tmp, FLAG_NO_DROP))
637 return; 637 return;
638 638
639 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 639 if (QUERY_FLAG (tmp, FLAG_APPLIED))
640 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 640 if (!op->apply (tmp, AP_UNAPPLY | AP_NO_MERGE))
641 return; /* can't unapply it */ 641 return; /* can't unapply it */
642 642
643 /* We are only dropping some of the items. We split the current object 643 /* We are only dropping some of the items. We split the current object
644 * off 644 * off
645 */ 645 */
1102{ 1102{
1103 new_draw_info (NDI_UNIQUE, 0, op, tmp->describe_monster (op).c_str ()); 1103 new_draw_info (NDI_UNIQUE, 0, op, tmp->describe_monster (op).c_str ());
1104} 1104}
1105 1105
1106static void 1106static void
1107describe_dump_object (dynbuf &buf, object *ob)
1108{
1109 char *txt = dump_object (ob);
1110 for (char *p = txt; *p; ++p) if (*p == '\n') *p = '\r';
1111 buf << "\n" << txt << "\n";
1112
1113 if (!ob->is_arch ())
1114 describe_dump_object (buf, ob->arch);
1115}
1116
1117std::string
1118object::describe (object *who)
1119{
1120 dynbuf_text buf (1024, 1024);
1121
1122 buf.printf ("That is: %s.\r", long_desc (who).c_str ());
1123
1124 if (custom_name)
1125 buf.printf ("You call it %s.\r", &custom_name);
1126
1127 switch (type)
1128 {
1129 case SPELLBOOK:
1130 if (flag [FLAG_IDENTIFIED] && inv)
1131 buf.printf ("%s is a level %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill);
1132 break;
1133
1134 case BOOK:
1135 if (msg)
1136 buf << "Something is written in it.\r";
1137 break;
1138
1139 case CONTAINER:
1140 if (race)
1141 {
1142 if (weight_limit && stats.Str < 100)
1143 buf.printf ("It can hold only %s and its weight limit is %.1f kg.\r",
1144 &race, weight_limit / (10.0 * (100 - stats.Str)));
1145 else
1146 buf.printf ("It can hold only %s.\r", &race);
1147 }
1148 else if (weight_limit && stats.Str < 100)
1149 buf.printf ("Its weight limit is %.1f kg.\r", weight_limit / (10.0 * (100 - stats.Str)));
1150 break;
1151
1152 case WAND:
1153 if (flag [FLAG_IDENTIFIED])
1154 buf.printf ("It has %d %s left.\r", stats.food, stats.food == 1 ? "charge" : "charges");
1155 break;
1156 }
1157
1158 if (material != MATERIAL_NULL && !msg)
1159 buf << (nrof > 1 ? "They are made of " : "It is made of ")
1160 << material->description
1161 << ".\r";
1162
1163 if (who)
1164 /* Where to wear this item */
1165 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
1166 if (slot[i].info)
1167 {
1168 buf << (who->slot[i].info ? body_locations[i].use_name : body_locations[i].nonuse_name);
1169
1170 if (slot[i].info < -1 && who->slot[i].info)
1171 buf.printf ("(%d)", -slot[i].info);
1172
1173 buf << ".\r";
1174 }
1175
1176 if (weight)
1177 buf.printf ("%s %3.3f kg.\r", nrof > 1 ? "They weigh" : "It weighs", weight * (nrof ? nrof : 1) / 1000.0);
1178
1179 if (flag [FLAG_STARTEQUIP])
1180 buf << (nrof > 1 ? "They were" : "It was")
1181 << " given by a god and will vanish when dropped.\r";
1182
1183 if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who)
1184 {
1185 buf.printf ("You reckon %s worth %s.\r", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX));
1186
1187 if (is_in_shop (who))
1188 {
1189 if (flag [FLAG_UNPAID])
1190 buf.printf ("%s would cost you %s.\r", nrof > 1 ? "They" : "It", query_cost_string (this, who, F_BUY | F_SHOP));
1191 else
1192 buf.printf ("You are offered %s for %s.\r", query_cost_string (this, who, F_SELL + F_SHOP), nrof > 1 ? "them" : "it");
1193 }
1194 }
1195
1196 if (flag [FLAG_MONSTER])
1197 buf << describe_monster (who);
1198
1199 /* Is this item buildable? */
1200 if (flag [FLAG_IS_BUILDABLE])
1201 buf << "This is a buildable item.\r";
1202
1203 /* Does the object have a message? Don't show message for all object
1204 * types - especially if the first entry is a match
1205 */
1206 if (msg)
1207 {
1208 if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ())
1209 {
1210 buf << '\r';
1211
1212 /* This is just a hack so when identifying the items, we print
1213 * out the extra message
1214 */
1215 if (need_identify (this) && flag [FLAG_IDENTIFIED])
1216 buf << "The object has a story:\r";
1217
1218 buf << msg << '\n';
1219 }
1220 }
1221 else if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED]
1222 && (type == SPELLBOOK || type == ROD || type == WAND
1223 || type == ROD || type == POTION || type == SCROLL))
1224 // for spellbooks and other stuff that contains spells, print the spell message,
1225 // unless the object has a custom message handled above.
1226 buf << '\r' << inv->msg << '\n';
1227
1228 // try to display the duration for some potions and scrolls
1229 // this includes change ability potions and group spells,
1230 // but does not handle protection potions
1231 if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED]
1232 && (type == POTION || type == SCROLL))
1233 {
1234 object *spell = inv;
1235
1236 if (spell->subtype == SP_PARTY_SPELL)
1237 spell = spell->other_arch;
1238
1239 if (spell->subtype == SP_CHANGE_ABILITY)
1240 buf.printf ("\nH<The effect will last about %.10g seconds.>",
1241 TICK2TIME (change_ability_duration (spell, this)));
1242 }
1243
1244 // Display a hint about inscribable items [empty books]
1245 // This includes the amount of text they can hold.
1246 if (type == INSCRIBABLE)
1247 {
1248 if (other_arch && other_arch->type == SCROLL)
1249 buf.printf ("\nH<You can use the inscription skill to inscribe a spell into it.>");
1250 else
1251 buf.printf ("\nH<You can use the inscription skill to inscribe text into it. It has room for up to %d characters.>",
1252 weight_limit);
1253 }
1254
1255 buf << '\n';
1256
1257 // the dungeon master additionally gets a complete dump
1258 if (who && who->flag [FLAG_WIZLOOK])
1259 {
1260 buf << "\nT<Object>\n";
1261 describe_dump_object (buf, this);
1262
1263 if (inv)
1264 {
1265 buf << "\nT<Top Inventory>\n";
1266 describe_dump_object (buf, inv);
1267 }
1268 }
1269
1270 return std::string (buf.linearise (), buf.size ());
1271}
1272
1273static void
1274display_new_pickup (object *op) 1107display_new_pickup (object *op)
1275{ 1108{
1276 int i = op->contr->mode; 1109 int i = op->contr->mode;
1277 1110
1278 new_draw_info_format (NDI_UNIQUE, 0, op, "%d DEBUG", i & PU_DEBUG ? 1 : 0); 1111 new_draw_info_format (NDI_UNIQUE, 0, op, "%d DEBUG", i & PU_DEBUG ? 1 : 0);
1470 esrv_update_item (UPD_FLAGS, op, item); 1303 esrv_update_item (UPD_FLAGS, op, item);
1471 } 1304 }
1472 1305
1473 return 0; 1306 return 0;
1474} 1307}
1308
1309/* op should be a player, params is any params.
1310 * If no params given, we print out the currently marked object.
1311 * otherwise, try to find a matching object - try best match first.
1312 */
1313int
1314command_mark (object *op, char *params)
1315{
1316 if (!params)
1317 {
1318 if (object *mark = find_marked_object (op))
1319 op->statusmsg (format ("%s is marked.", query_name (mark)));
1320 else
1321 op->failmsg ("You have no marked object.");
1322 }
1323 else
1324 {
1325 if (object *mark = find_best_object_match (op, params))
1326 {
1327 op->contr->mark = mark;
1328 op->statusmsg (format ("Marked item %s", query_name (mark)));
1329 }
1330 else
1331 op->failmsgf ("Could not find an object that matches %s", params);
1332 }
1333
1334 return 0; /*shouldnt get here */
1335}
1336

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines