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.111 by root, Sun Mar 28 15:57:14 2010 UTC vs.
Revision 1.119 by root, Sat Apr 10 04:54:09 2010 UTC

136 136
137 skill = find_skill_by_name_fuzzy (pl, params); 137 skill = find_skill_by_name_fuzzy (pl, params);
138 138
139 if (!skill) 139 if (!skill)
140 { 140 {
141 new_draw_info_format (NDI_UNIQUE, 0, pl, "You have no knowledge of the skill %s", params); 141 new_draw_info_format (NDI_UNIQUE, 0, pl, "You have no knowledge of the %s skill.", params);
142 return 0; 142 return 0;
143 } 143 }
144 144
145 pl->change_skill (0); 145 pl->apply (skill);
146 apply_special (pl, skill, AP_APPLY);
147 return 1; 146 return 1;
148} 147}
149 148
150/* A little special because we do want to pass the full params along 149/* A little special because we do want to pass the full params along
151 * as it includes the object to throw. 150 * as it includes the object to throw.
154command_throw (object *op, char *params) 153command_throw (object *op, char *params)
155{ 154{
156 if (object *skop = find_skill_by_name (op, skill_names[SK_THROWING])) 155 if (object *skop = find_skill_by_name (op, skill_names[SK_THROWING]))
157 return do_skill (op, op, skop, op->facing, params); 156 return do_skill (op, op, skop, op->facing, params);
158 else 157 else
159 new_draw_info (NDI_UNIQUE, 0, op, "You have no knowledge of the skill throwing."); 158 new_draw_info (NDI_UNIQUE, 0, op, "You have no knowledge of the throwing skill.");
160 159
161 return 0; 160 return 0;
162} 161}
163 162
164int 163int
190 189
191 while (*params == ' ') 190 while (*params == ' ')
192 params++; 191 params++;
193 192
194 if (object *inv = find_best_apply_object_match (op, params, aflag)) 193 if (object *inv = find_best_apply_object_match (op, params, aflag))
195 player_apply (op, inv, aflag, 0); 194 op->apply (inv, aflag);
196 else 195 else
197 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);
198 } 197 }
199 198
200 return 0; 199 return 0;
201} 200}
202 201
557 */ 556 */
558 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)))
559 return; 558 return;
560 559
561 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 560 if (QUERY_FLAG (tmp, FLAG_APPLIED))
562 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 561 if (!op->apply (tmp, AP_UNAPPLY | AP_NO_MERGE))
563 return; 562 return;
564 563
565 /* 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 */
566 if (!can_split (op, tmp, nrof)) 565 if (!can_split (op, tmp, nrof))
567 return; 566 return;
606 return; 605 return;
607 606
608 if (obj->destroyed () || obj->is_inserted ()) 607 if (obj->destroyed () || obj->is_inserted ())
609 return; 608 return;
610 609
611 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)
612 if (!sell_item (obj, dropper)) 611 if (!sell_item (obj, dropper))
613 return; 612 return;
614 613
615 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))
616 return; 615 return;
636{ 635{
637 if (QUERY_FLAG (tmp, FLAG_NO_DROP)) 636 if (QUERY_FLAG (tmp, FLAG_NO_DROP))
638 return; 637 return;
639 638
640 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 639 if (QUERY_FLAG (tmp, FLAG_APPLIED))
641 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 640 if (!op->apply (tmp, AP_UNAPPLY | AP_NO_MERGE))
642 return; /* can't unapply it */ 641 return; /* can't unapply it */
643 642
644 /* 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
645 * off 644 * off
646 */ 645 */
1103{ 1102{
1104 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 ());
1105} 1104}
1106 1105
1107static void 1106static void
1108describe_dump_object (dynbuf &buf, object *ob)
1109{
1110 char *txt = dump_object (ob);
1111 for (char *p = txt; *p; ++p) if (*p == '\n') *p = '\r';
1112 buf << "\n" << txt << "\n";
1113
1114 if (!ob->is_arch ())
1115 describe_dump_object (buf, ob->arch);
1116}
1117
1118std::string
1119object::describe (object *who)
1120{
1121 dynbuf_text buf (1024, 1024);
1122
1123 buf.printf ("That is: %s.\r", long_desc (who).c_str ());
1124
1125 if (custom_name)
1126 buf.printf ("You call it %s.\r", &custom_name);
1127
1128 switch (type)
1129 {
1130 case SPELLBOOK:
1131 if (flag [FLAG_IDENTIFIED] && inv)
1132 buf.printf ("%s is a level %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill);
1133 break;
1134
1135 case BOOK:
1136 if (msg)
1137 buf << "Something is written in it.\r";
1138 break;
1139
1140 case CONTAINER:
1141 if (race)
1142 {
1143 if (weight_limit && stats.Str < 100)
1144 buf.printf ("It can hold only %s and its weight limit is %.1f kg.\r",
1145 &race, weight_limit / (10.0 * (100 - stats.Str)));
1146 else
1147 buf.printf ("It can hold only %s.\r", &race);
1148 }
1149 else if (weight_limit && stats.Str < 100)
1150 buf.printf ("Its weight limit is %.1f kg.\r", weight_limit / (10.0 * (100 - stats.Str)));
1151 break;
1152
1153 case WAND:
1154 if (flag [FLAG_IDENTIFIED])
1155 buf.printf ("It has %d %s left.\r", stats.food, stats.food == 1 ? "charge" : "charges");
1156 break;
1157 }
1158
1159 if (material != MATERIAL_NULL && !msg)
1160 buf << (nrof > 1 ? "They are made of " : "It is made of ")
1161 << material->description
1162 << ".\r";
1163
1164 if (who)
1165 /* Where to wear this item */
1166 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
1167 if (slot[i].info)
1168 {
1169 buf << (who->slot[i].info ? body_locations[i].use_name : body_locations[i].nonuse_name);
1170
1171 if (slot[i].info < -1 && who->slot[i].info)
1172 buf.printf ("(%d)", -slot[i].info);
1173
1174 buf << ".\r";
1175 }
1176
1177 if (weight)
1178 buf.printf ("%s %3.3f kg.\r", nrof > 1 ? "They weigh" : "It weighs", weight * (nrof ? nrof : 1) / 1000.0);
1179
1180 if (flag [FLAG_STARTEQUIP])
1181 buf << (nrof > 1 ? "They were" : "It was")
1182 << " given by a god and will vanish when dropped.\r";
1183
1184 if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who)
1185 {
1186 buf.printf ("You reckon %s worth %s.\r", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX));
1187
1188 if (is_in_shop (who))
1189 {
1190 if (flag [FLAG_UNPAID])
1191 buf.printf ("%s would cost you %s.\r", nrof > 1 ? "They" : "It", query_cost_string (this, who, F_BUY | F_SHOP));
1192 else
1193 buf.printf ("You are offered %s for %s.\r", query_cost_string (this, who, F_SELL + F_SHOP), nrof > 1 ? "them" : "it");
1194 }
1195 }
1196
1197 if (flag [FLAG_MONSTER])
1198 buf << describe_monster (who);
1199
1200 /* Is this item buildable? */
1201 if (flag [FLAG_IS_BUILDABLE])
1202 buf << "This is a buildable item.\r";
1203
1204 /* Does the object have a message? Don't show message for all object
1205 * types - especially if the first entry is a match
1206 */
1207 if (msg)
1208 {
1209 if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ())
1210 {
1211 buf << '\r';
1212
1213 /* This is just a hack so when identifying the items, we print
1214 * out the extra message
1215 */
1216 if (need_identify (this) && flag [FLAG_IDENTIFIED])
1217 buf << "The object has a story:\r";
1218
1219 buf << msg << '\n';
1220 }
1221 }
1222 else if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED]
1223 && (type == SPELLBOOK || type == ROD || type == WAND
1224 || type == ROD || type == POTION || type == SCROLL))
1225 // for spellbooks and other stuff that contains spells, print the spell message,
1226 // unless the object has a custom message handled above.
1227 buf << '\r' << inv->msg << '\n';
1228
1229 // try to display the duration for some potions and scrolls
1230 // this includes change ability potions and group spells,
1231 // but does not handle protection potions
1232 if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED]
1233 && (type == POTION || type == SCROLL))
1234 {
1235 object *spell = inv;
1236
1237 if (spell->subtype == SP_PARTY_SPELL)
1238 spell = spell->other_arch;
1239
1240 if (spell->subtype == SP_CHANGE_ABILITY)
1241 buf.printf ("\nH<The effect will last about %.10g seconds.>",
1242 TICK2TIME (change_ability_duration (spell, this)));
1243 }
1244
1245 // Display a hint about inscribable items [empty books]
1246 // This includes the amount of text they can hold.
1247 if (type == INSCRIBABLE)
1248 {
1249 if (other_arch && other_arch->type == SCROLL)
1250 buf.printf ("\nH<You can use the inscription skill to inscribe a spell into it.>");
1251 else
1252 buf.printf ("\nH<You can use the inscription skill to inscribe text into it. It has room for up to %d characters.>",
1253 weight_limit);
1254 }
1255
1256 buf << '\n';
1257
1258 // the dungeon master additionally gets a complete dump
1259 if (who && who->flag [FLAG_WIZLOOK])
1260 {
1261 buf << "\nT<Object>\n";
1262 describe_dump_object (buf, this);
1263
1264 if (inv)
1265 {
1266 buf << "\nT<Top Inventory>\n";
1267 describe_dump_object (buf, inv);
1268 }
1269 }
1270
1271 return std::string (buf.linearise (), buf.size ());
1272}
1273
1274static void
1275display_new_pickup (object *op) 1107display_new_pickup (object *op)
1276{ 1108{
1277 int i = op->contr->mode; 1109 int i = op->contr->mode;
1278 1110
1279 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);
1471 esrv_update_item (UPD_FLAGS, op, item); 1303 esrv_update_item (UPD_FLAGS, op, item);
1472 } 1304 }
1473 1305
1474 return 0; 1306 return 0;
1475} 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