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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
8 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the terms of the Affero GNU General Public License as published by the |
… | |
… | |
74 | }; |
75 | }; |
75 | |
76 | |
76 | /* The following is a large table of item types, the fields are: |
77 | /* The following is a large table of item types, the fields are: |
77 | * item number, item name, item name (plural), and two numbers that are the skills |
78 | * item number, item name, item name (plural), and two numbers that are the skills |
78 | * used to identify them. Anytime a new item type is added or removed, this list |
79 | * used to identify them. Anytime a new item type is added or removed, this list |
79 | * should be altered to reflect that. The defines for the numerical values are in |
80 | * should be altered to reflect that. The defines for the numerical values are in |
80 | * define.h |
81 | * define.h |
81 | */ |
82 | */ |
82 | static const typedata item_types[] = { |
83 | static const typedata item_types[] = { |
83 | {PLAYER, "player", "players", 0, 0}, |
84 | {PLAYER, "player", "players", 0, 0}, |
84 | {ROD, "rod", "rods", SK_THAUMATURGY, 0}, |
85 | {ROD, "rod", "rods", SK_THAUMATURGY, 0}, |
85 | {TREASURE, "treasure", "treasure", 0, 0}, |
86 | {TREASURE, "treasure", "treasure", 0, 0}, |
… | |
… | |
280 | enc += op->stats.stat (i); |
281 | enc += op->stats.stat (i); |
281 | |
282 | |
282 | /* This protection logic is pretty flawed. 20% fire resistance |
283 | /* This protection logic is pretty flawed. 20% fire resistance |
283 | * is much more valuable than 20% confusion, or 20% slow, or |
284 | * is much more valuable than 20% confusion, or 20% slow, or |
284 | * several others. Start at 1 - ignore physical - all that normal |
285 | * several others. Start at 1 - ignore physical - all that normal |
285 | * armour shouldn't be counted against |
286 | * armour shouldn't be counted against |
286 | */ |
287 | */ |
287 | tmp = 0; |
288 | tmp = 0; |
288 | for (i = 1; i < NROFATTACKS; i++) |
289 | for (i = 1; i < NROFATTACKS; i++) |
289 | tmp += op->resist[i]; |
290 | tmp += op->resist[i]; |
290 | |
291 | |
… | |
… | |
358 | { |
359 | { |
359 | return data [itemtype]; |
360 | return data [itemtype]; |
360 | } |
361 | } |
361 | } get_typedata_; |
362 | } get_typedata_; |
362 | |
363 | |
363 | /* returns the typedata that has a number equal to itemtype, if there |
364 | /* returns the typedata that has a number equal to itemtype, if there |
364 | * isn't one, returns NULL */ |
365 | * isn't one, returns NULL */ |
365 | const typedata * |
366 | const typedata * |
366 | get_typedata (int itemtype) |
367 | get_typedata (int itemtype) |
367 | { |
368 | { |
368 | return get_typedata_ (itemtype); |
369 | return get_typedata_ (itemtype); |
369 | } |
370 | } |
370 | |
371 | |
371 | /* returns the typedata that has a name equal to itemtype, if there |
372 | /* returns the typedata that has a name equal to itemtype, if there |
372 | * isn't one, return the plural name that matches, if there still isn't |
373 | * isn't one, return the plural name that matches, if there still isn't |
373 | * one return NULL */ |
374 | * one return NULL */ |
374 | const typedata * |
375 | const typedata * |
375 | get_typedata_by_name (const char *name) |
376 | get_typedata_by_name (const char *name) |
376 | { |
377 | { |
… | |
… | |
514 | |
515 | |
515 | return buf; |
516 | return buf; |
516 | } |
517 | } |
517 | |
518 | |
518 | /* |
519 | /* |
519 | * query_short_name(object) is similar to query_name, but doesn't |
520 | * query_short_name(object) is similar to query_name, but doesn't |
520 | * contain any information about object status (worn/cursed/etc.) |
521 | * contain any information about object status (worn/cursed/etc.) |
521 | * |
522 | * |
522 | * It is sometimes used when printing messages, so should fit well into a sentence. |
523 | * It is sometimes used when printing messages, so should fit well into a sentence. |
523 | */ |
524 | */ |
524 | const char * |
525 | const char * |
… | |
… | |
1009 | buf.printf ("(capacity %dk; it is ", op->stats.maxsp / 1000); |
1010 | buf.printf ("(capacity %dk; it is ", op->stats.maxsp / 1000); |
1010 | } |
1011 | } |
1011 | else |
1012 | else |
1012 | buf.printf ("(capacity %d; it is ", op->stats.maxsp); |
1013 | buf.printf ("(capacity %d; it is ", op->stats.maxsp); |
1013 | |
1014 | |
1014 | i = (op->stats.sp * 10) / op->stats.maxsp; |
1015 | i = op->stats.sp * 10 / max (op->stats.maxsp, 1); |
1015 | if (op->stats.sp == 0) |
1016 | |
1016 | buf << "empty"; |
1017 | if (op->stats.sp == 0) buf << "empty"; |
1017 | else if (i == 0) |
1018 | else if (i <= 0) buf << "almost empty"; |
1018 | buf << "almost empty"; |
1019 | else if (i <= 2) buf << "partially filled"; |
1019 | else if (i < 3) |
1020 | else if (i <= 5) buf << "half full"; |
1020 | buf << "partially filled"; |
1021 | else if (i <= 8) buf << "well charged"; |
1021 | else if (i < 6) |
|
|
1022 | buf << "half full"; |
|
|
1023 | else if (i < 9) |
|
|
1024 | buf << "well charged"; |
|
|
1025 | else if (op->stats.sp == op->stats.maxsp) |
1022 | else if (op->stats.sp < op->stats.maxsp) buf << "almost full"; |
1026 | buf << "fully charged"; |
1023 | else buf << "fully charged"; |
1027 | else |
|
|
1028 | buf << "almost full"; |
|
|
1029 | |
1024 | |
1030 | buf << ')'; |
1025 | buf << ')'; |
1031 | break; |
1026 | break; |
1032 | |
1027 | |
1033 | case LAMP: |
1028 | case LAMP: |
… | |
… | |
1198 | |
1193 | |
1199 | if (more_info) |
1194 | if (more_info) |
1200 | { |
1195 | { |
1201 | if (op->stats.food) buf.printf ("(sustenance%+d)", op->stats.food); |
1196 | if (op->stats.food) buf.printf ("(sustenance%+d)", op->stats.food); |
1202 | if (op->stats.grace) buf.printf ("(grace%+d)", op->stats.grace); |
1197 | if (op->stats.grace) buf.printf ("(grace%+d)", op->stats.grace); |
1203 | if (op->stats.sp) buf.printf ("(magic%+d)", op->stats.sp); |
1198 | if (op->stats.sp) buf.printf ("(magic%+d)", op->stats.sp); |
1204 | if (op->stats.hp) buf.printf ("(regeneration%+d)", op->stats.hp); |
1199 | if (op->stats.hp) buf.printf ("(regeneration%+d)", op->stats.hp); |
1205 | } |
1200 | } |
1206 | |
1201 | |
1207 | if (op->stats.luck) |
1202 | if (op->stats.luck) |
1208 | buf.printf ("(luck%+d)", op->stats.luck); |
1203 | buf.printf ("(luck%+d)", op->stats.luck); |
… | |
… | |
1417 | op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); |
1412 | op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); |
1418 | } |
1413 | } |
1419 | |
1414 | |
1420 | /* |
1415 | /* |
1421 | * inventory prints object's inventory. If inv==NULL then print player's |
1416 | * inventory prints object's inventory. If inv==NULL then print player's |
1422 | * inventory. |
1417 | * inventory. |
1423 | * [ Only items which are applied are showed. Tero.Haatanen@lut.fi ] |
1418 | * [ Only items which are applied are showed. Tero.Haatanen@lut.fi ] |
1424 | */ |
1419 | */ |
1425 | const char * |
1420 | const char * |
1426 | object::query_inventory (object *who, const char *indent) |
1421 | object::query_inventory (object *who, const char *indent) |
1427 | { |
1422 | { |