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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 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 |
… | |
… | |
20 | * |
20 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #include <funcpoint.h> |
|
|
26 | #include <living.h> |
25 | #include <living.h> |
27 | #include <spells.h> |
26 | #include <spells.h> |
28 | |
27 | |
29 | const char *const coins[NUM_COINS + 1] = { "royalty", "platinacoin", "goldcoin", "silvercoin", 0 }; |
28 | const char *const coins[NUM_COINS + 1] = { "royalty", "platinacoin", "goldcoin", "silvercoin", 0 }; |
30 | |
29 | |
… | |
… | |
300 | if (op->type == WEAPON) |
299 | if (op->type == WEAPON) |
301 | { |
300 | { |
302 | for (i = 1; i < NROFATTACKS; i++) |
301 | for (i = 1; i < NROFATTACKS; i++) |
303 | if (op->attacktype & (1 << i)) |
302 | if (op->attacktype & (1 << i)) |
304 | enc++; |
303 | enc++; |
|
|
304 | |
305 | if (op->slaying) |
305 | if (op->slaying) |
306 | enc += 2; /* What it slays is probably more relevent */ |
306 | enc += 2; /* What it slays is probably more relevent */ |
307 | } |
307 | } |
|
|
308 | |
308 | /* Items the player can equip */ |
309 | /* Items the player can equip */ |
309 | if ((op->type == WEAPON) || (op->type == ARMOUR) || (op->type == HELMET) || |
310 | if ((op->type == WEAPON) || (op->type == ARMOUR) || (op->type == HELMET) || |
310 | (op->type == SHIELD) || (op->type == RING) || |
311 | (op->type == SHIELD) || (op->type == RING) || |
311 | (op->type == BOOTS) || (op->type == GLOVES) || |
312 | (op->type == BOOTS) || (op->type == GLOVES) || |
312 | (op->type == AMULET) || (op->type == GIRDLE) || (op->type == BRACERS) || (op->type == CLOAK)) |
313 | (op->type == AMULET) || (op->type == GIRDLE) || (op->type == BRACERS) || (op->type == CLOAK)) |
… | |
… | |
315 | enc += op->stats.hp; /* hp regen */ |
316 | enc += op->stats.hp; /* hp regen */ |
316 | enc += op->stats.sp; /* mana regen */ |
317 | enc += op->stats.sp; /* mana regen */ |
317 | enc += op->stats.grace; /* grace regen */ |
318 | enc += op->stats.grace; /* grace regen */ |
318 | enc += op->stats.exp; /* speed bonus */ |
319 | enc += op->stats.exp; /* speed bonus */ |
319 | } |
320 | } |
|
|
321 | |
320 | enc += op->stats.luck; |
322 | enc += op->stats.luck; |
321 | |
323 | |
322 | /* Do spell paths now */ |
324 | /* Do spell paths now */ |
323 | for (i = 1; i < NRSPELLPATHS; i++) |
325 | for (i = 1; i < NRSPELLPATHS; i++) |
324 | { |
326 | { |
… | |
… | |
356 | int i; |
358 | int i; |
357 | |
359 | |
358 | for (i = 0; i < item_types_size; i++) |
360 | for (i = 0; i < item_types_size; i++) |
359 | if (item_types[i].number == itemtype) |
361 | if (item_types[i].number == itemtype) |
360 | return &item_types[i]; |
362 | return &item_types[i]; |
|
|
363 | |
361 | return NULL; |
364 | return NULL; |
362 | } |
365 | } |
363 | |
366 | |
364 | /* returns the typedata that has a name equal to itemtype, if there |
367 | /* returns the typedata that has a name equal to itemtype, if there |
365 | * isn't one, return the plural name that matches, if there still isn't |
368 | * isn't one, return the plural name that matches, if there still isn't |
… | |
… | |
370 | int i; |
373 | int i; |
371 | |
374 | |
372 | for (i = 0; i < item_types_size; i++) |
375 | for (i = 0; i < item_types_size; i++) |
373 | if (!strcmp (item_types[i].name, name)) |
376 | if (!strcmp (item_types[i].name, name)) |
374 | return &item_types[i]; |
377 | return &item_types[i]; |
|
|
378 | |
375 | for (i = 0; i < item_types_size; i++) |
379 | for (i = 0; i < item_types_size; i++) |
376 | if (!strcmp (item_types[i].name_pl, name)) |
380 | if (!strcmp (item_types[i].name_pl, name)) |
377 | { |
381 | { |
378 | LOG (llevInfo, |
382 | LOG (llevInfo, |
379 | "get_typedata_by_name: I have been sent the plural %s, the singular form %s is preffered\n", name, item_types[i].name); |
383 | "get_typedata_by_name: I have been sent the plural %s, the singular form %s is prefered\n", name, item_types[i].name); |
380 | return &item_types[i]; |
384 | return &item_types[i]; |
381 | } |
385 | } |
|
|
386 | |
382 | return NULL; |
387 | return NULL; |
383 | } |
388 | } |
384 | |
389 | |
385 | /* describe_resistance generates the visible naming for resistances. |
390 | /* describe_resistance generates the visible naming for resistances. |
386 | * returns a static array of the description. This can return |
391 | * returns a static array of the description. This can return |
… | |
… | |
419 | */ |
424 | */ |
420 | const char * |
425 | const char * |
421 | query_weight (const object *op) |
426 | query_weight (const object *op) |
422 | { |
427 | { |
423 | static char buf[10]; |
428 | static char buf[10]; |
424 | sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; |
429 | sint32 i = op->total_weight (); |
425 | |
430 | |
426 | if (op->weight < 0) |
431 | if (op->weight < 0) |
427 | return " "; |
432 | return " "; |
428 | |
433 | |
429 | if (i % 1000) |
434 | if (i % 1000) |
… | |
… | |
574 | break; |
579 | break; |
575 | |
580 | |
576 | case ALTAR: |
581 | case ALTAR: |
577 | case TRIGGER_ALTAR: |
582 | case TRIGGER_ALTAR: |
578 | case IDENTIFY_ALTAR: |
583 | case IDENTIFY_ALTAR: |
|
|
584 | case CONVERTER: |
579 | if (op->slaying == shstr_money) |
585 | if (op->slaying == shstr_money) |
580 | { |
586 | { |
581 | bool wrap = !!buf.size (); |
587 | bool wrap = !!buf.size (); |
582 | |
588 | |
583 | if (wrap) buf << " ["; |
589 | if (wrap) buf << " ["; |
… | |
… | |
589 | if (op->stats.food % coin->value == 0) |
595 | if (op->stats.food % coin->value == 0) |
590 | break; |
596 | break; |
591 | |
597 | |
592 | sint32 coins = op->stats.food / coin->value; |
598 | sint32 coins = op->stats.food / coin->value; |
593 | |
599 | |
594 | buf.printf ("drop %d %s", coins, coins == 1 ? &coin->name : &coin->name_pl); |
600 | buf.printf ("drop %d %s (or equivalent)", coins, coins == 1 ? &coin->name : &coin->name_pl); |
595 | |
601 | |
596 | if (wrap) buf << ']'; |
602 | if (wrap) buf << ']'; |
597 | } |
603 | } |
598 | break; |
604 | break; |
599 | |
605 | |
… | |
… | |
1193 | } |
1199 | } |
1194 | |
1200 | |
1195 | void |
1201 | void |
1196 | examine (object *op, object *tmp) |
1202 | examine (object *op, object *tmp) |
1197 | { |
1203 | { |
1198 | std::string s = tmp->describe (op); |
1204 | std::string info = tmp->describe (op); |
1199 | |
1205 | op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); |
1200 | new_draw_info (NDI_UNIQUE, 0, op, s.c_str ()); |
|
|
1201 | } |
1206 | } |
1202 | |
1207 | |
1203 | /* |
1208 | /* |
1204 | * inventory prints object's inventory. If inv==NULL then print player's |
1209 | * inventory prints object's inventory. If inv==NULL then print player's |
1205 | * inventory. |
1210 | * inventory. |
… | |
… | |
1357 | * Supposed to fix face-values as well here, but later. |
1362 | * Supposed to fix face-values as well here, but later. |
1358 | */ |
1363 | */ |
1359 | void |
1364 | void |
1360 | identify (object *op) |
1365 | identify (object *op) |
1361 | { |
1366 | { |
1362 | object *pl; |
|
|
1363 | |
|
|
1364 | SET_FLAG (op, FLAG_IDENTIFIED); |
1367 | SET_FLAG (op, FLAG_IDENTIFIED); |
1365 | CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); |
1368 | CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); |
1366 | CLEAR_FLAG (op, FLAG_NO_SKILL_IDENT); |
1369 | CLEAR_FLAG (op, FLAG_NO_SKILL_IDENT); |
1367 | |
1370 | |
1368 | /* |
1371 | /* |
… | |
… | |
1375 | { |
1378 | { |
1376 | if (op->inv && op->randomitems) |
1379 | if (op->inv && op->randomitems) |
1377 | op->title = op->inv->name; |
1380 | op->title = op->inv->name; |
1378 | else if (op->arch) |
1381 | else if (op->arch) |
1379 | { |
1382 | { |
1380 | op->name = op->arch->object::name; |
1383 | op->name = op->arch->object::name; |
1381 | op->name_pl = op->arch->object::name_pl; |
1384 | op->name_pl = op->arch->object::name_pl; |
1382 | } |
1385 | } |
1383 | } |
1386 | } |
1384 | |
1387 | |
1385 | /* If the object is on a map, make sure we update its face */ |
1388 | /* If the object is on a map, make sure we update its face */ |
1386 | if (op->map) |
1389 | if (op->map) |
1387 | update_object (op, UP_OBJ_CHANGE); |
1390 | update_object (op, UP_OBJ_CHANGE); |
1388 | else |
1391 | else if (object *pl = op->visible_to ()) |
1389 | { |
|
|
1390 | pl = op->in_player (); |
|
|
1391 | if (pl) |
|
|
1392 | /* A lot of the values can change from an update - might as well send |
1392 | /* A lot of the values can change from an update - might as well send |
1393 | * it all. |
1393 | * it all. |
1394 | */ |
1394 | */ |
1395 | esrv_send_item (pl, op); |
1395 | esrv_send_item (pl, op); |
1396 | } |
|
|
1397 | } |
1396 | } |
1398 | |
1397 | |