… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009 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 it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /* |
25 | /* |
… | |
… | |
586 | |
587 | |
587 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
588 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
588 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
589 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
589 | return; /* can't unapply it */ |
590 | return; /* can't unapply it */ |
590 | |
591 | |
591 | //fprintf (stderr, "ui, on space is %ld\n", op->ms ().volume ());//D |
|
|
592 | |
|
|
593 | /* We are only dropping some of the items. We split the current object |
592 | /* We are only dropping some of the items. We split the current object |
594 | * off |
593 | * off |
595 | */ |
594 | */ |
596 | if (!can_split (op, tmp, nrof)) |
595 | if (!can_split (op, tmp, nrof)) |
597 | return; |
596 | return; |
… | |
… | |
613 | * object that was dropped. |
612 | * object that was dropped. |
614 | * |
613 | * |
615 | * Make sure to check what happened with <obj> after this function returns! |
614 | * Make sure to check what happened with <obj> after this function returns! |
616 | * Otherwise you may leak this object. |
615 | * Otherwise you may leak this object. |
617 | */ |
616 | */ |
618 | |
|
|
619 | void |
617 | void |
620 | drop_object (object *dropper, object *obj) |
618 | drop_object (object *dropper, object *obj) |
621 | { |
619 | { |
622 | if (INVOKE_OBJECT (DROP, obj, ARG_OBJECT (dropper))) |
620 | if (INVOKE_OBJECT (DROP, obj, ARG_OBJECT (dropper))) |
623 | return; |
621 | return; |
… | |
… | |
706 | } |
704 | } |
707 | |
705 | |
708 | if (op->type == PLAYER && op->contr->last_used == tmp) |
706 | if (op->type == PLAYER && op->contr->last_used == tmp) |
709 | op->contr->last_used = tmp->below ? tmp->below |
707 | op->contr->last_used = tmp->below ? tmp->below |
710 | : tmp->above ? tmp->above |
708 | : tmp->above ? tmp->above |
711 | : 0; |
709 | : (object *)0; |
712 | |
710 | |
713 | if (op->container) |
711 | if (op->container) |
714 | { |
712 | { |
715 | if (op->type == PLAYER) |
713 | if (op->type == PLAYER) |
716 | put_object_in_sack (op, op->container, tmp, op->contr->count); |
714 | put_object_in_sack (op, op->container, tmp, op->contr->count); |
… | |
… | |
1103 | examine_monster (object *op, object *tmp) |
1101 | examine_monster (object *op, object *tmp) |
1104 | { |
1102 | { |
1105 | 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 ()); |
1106 | } |
1104 | } |
1107 | |
1105 | |
|
|
1106 | static void |
|
|
1107 | describe_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 | |
1108 | std::string |
1117 | std::string |
1109 | object::describe (object *who) |
1118 | object::describe (object *who) |
1110 | { |
1119 | { |
1111 | dynbuf_text buf (1024, 1024); |
1120 | dynbuf_text buf (1024, 1024); |
1112 | |
1121 | |
… | |
… | |
1145 | buf.printf ("It has %d charges left.\r", stats.food); |
1154 | buf.printf ("It has %d charges left.\r", stats.food); |
1146 | break; |
1155 | break; |
1147 | } |
1156 | } |
1148 | |
1157 | |
1149 | if (materialname && !msg) |
1158 | if (materialname && !msg) |
1150 | buf.printf ("It is made of: %s.\r", &materialname); |
1159 | buf << (nrof > 1 ? "They are made of " : "It is made of ") |
|
|
1160 | << materialname |
|
|
1161 | << '\r'; |
1151 | |
1162 | |
1152 | if (who) |
1163 | if (who) |
1153 | /* Where to wear this item */ |
1164 | /* Where to wear this item */ |
1154 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1165 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1155 | if (slot[i].info) |
1166 | if (slot[i].info) |
… | |
… | |
1186 | buf << "This is a buildable item.\r"; |
1197 | buf << "This is a buildable item.\r"; |
1187 | |
1198 | |
1188 | /* Does the object have a message? Don't show message for all object |
1199 | /* Does the object have a message? Don't show message for all object |
1189 | * types - especially if the first entry is a match |
1200 | * types - especially if the first entry is a match |
1190 | */ |
1201 | */ |
|
|
1202 | if (msg) |
|
|
1203 | { |
1191 | if (msg && type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) |
1204 | if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) |
1192 | { |
1205 | { |
|
|
1206 | buf << '\r'; |
|
|
1207 | |
1193 | /* This is just a hack so when identifying the items, we print |
1208 | /* This is just a hack so when identifying the items, we print |
1194 | * out the extra message |
1209 | * out the extra message |
1195 | */ |
1210 | */ |
1196 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
1211 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
1197 | buf << "The object has a story:\r"; |
1212 | buf << "The object has a story:\r"; |
1198 | |
1213 | |
1199 | buf << msg << '\n'; |
1214 | buf << msg << '\n'; |
|
|
1215 | } |
|
|
1216 | } |
|
|
1217 | else if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED] |
|
|
1218 | && (type == SPELLBOOK || type == ROD || type == WAND |
|
|
1219 | || type == ROD || type == POTION || type == SCROLL)) |
|
|
1220 | // for spellbooks and other stuff that contains spells, print the spell message, |
|
|
1221 | // unless the object has a custom message handled above. |
|
|
1222 | buf << '\r' << inv->msg << '\n'; |
|
|
1223 | |
|
|
1224 | // try to display the duration for some potions and scrolls |
|
|
1225 | // this includes change ability potions and group spells, |
|
|
1226 | // but does not handle protection potions |
|
|
1227 | if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED] |
|
|
1228 | && (type == POTION || type == SCROLL)) |
|
|
1229 | { |
|
|
1230 | object *spell = inv; |
|
|
1231 | |
|
|
1232 | if (spell->subtype == SP_PARTY_SPELL) |
|
|
1233 | spell = spell->other_arch; |
|
|
1234 | |
|
|
1235 | if (spell->subtype == SP_CHANGE_ABILITY) |
|
|
1236 | buf.printf ("\nH<The effect will last about %.10g seconds.>", |
|
|
1237 | TICK2TIME (change_ability_duration (spell, this))); |
|
|
1238 | } |
|
|
1239 | |
|
|
1240 | // Display a hint about inscribable items [empty books] |
|
|
1241 | // This includes the amount of text they can hold. |
|
|
1242 | if (type == INSCRIBABLE) |
|
|
1243 | { |
|
|
1244 | if (other_arch && other_arch->type == SCROLL) |
|
|
1245 | buf.printf ("\nH<You can use the inscription skill to inscribe a spell into it.>"); |
|
|
1246 | else |
|
|
1247 | buf.printf ("\nH<You can use the inscription skill to inscribe text into it. It has room for up to %d characters.>", |
|
|
1248 | weight_limit); |
1200 | } |
1249 | } |
1201 | |
1250 | |
1202 | buf << '\n'; |
1251 | buf << '\n'; |
|
|
1252 | |
|
|
1253 | // the dungeon master additionally gets a complete dump |
|
|
1254 | if (who && who->flag [FLAG_WIZLOOK]) |
|
|
1255 | { |
|
|
1256 | buf << "\nT<Object>\n"; |
|
|
1257 | describe_dump_object (buf, this); |
|
|
1258 | |
|
|
1259 | if (inv) |
|
|
1260 | { |
|
|
1261 | buf << "\nT<Top Inventory>\n"; |
|
|
1262 | describe_dump_object (buf, inv); |
|
|
1263 | } |
|
|
1264 | } |
1203 | |
1265 | |
1204 | return std::string (buf.linearise (), buf.size ()); |
1266 | return std::string (buf.linearise (), buf.size ()); |
1205 | } |
1267 | } |
1206 | |
1268 | |
1207 | static void |
1269 | static void |