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,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * 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 |
9 | * the terms of the Affero GNU General Public License as published by the |
… | |
… | |
443 | } |
443 | } |
444 | |
444 | |
445 | for (tmp = op->inv; tmp; tmp = tmp->below) |
445 | for (tmp = op->inv; tmp; tmp = tmp->below) |
446 | if (tmp->type == MONEY) |
446 | if (tmp->type == MONEY) |
447 | total += tmp->nrof * (sint64)tmp->value; |
447 | total += tmp->nrof * (sint64)tmp->value; |
448 | else if (tmp->type == CONTAINER && tmp->flag [FLAG_APPLIED] && (!tmp->race || tmp->race.contains ("gold"))) |
448 | else if (tmp->type == CONTAINER && tmp->flag [FLAG_APPLIED] && (!tmp->race || tmp->race.contains (shstr_gold))) |
449 | total += query_money (tmp); |
449 | total += query_money (tmp); |
450 | |
450 | |
451 | return total; |
451 | return total; |
452 | } |
452 | } |
453 | |
453 | |
… | |
… | |
468 | return 0; |
468 | return 0; |
469 | |
469 | |
470 | pay_from_container (pl, pl, to_pay); |
470 | pay_from_container (pl, pl, to_pay); |
471 | |
471 | |
472 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
472 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
473 | if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && (!pouch->race || pouch->race.contains ("gold"))) |
473 | if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && (!pouch->race || pouch->race.contains (shstr_gold))) |
474 | pay_from_container (pl, pouch, to_pay); |
474 | pay_from_container (pl, pouch, to_pay); |
475 | |
475 | |
476 | pl->update_stats (); |
476 | pl->update_stats (); |
477 | return 1; |
477 | return 1; |
478 | } |
478 | } |
… | |
… | |
505 | change_exp (pl, saved_money, shstr_bargaining, SK_EXP_NONE); |
505 | change_exp (pl, saved_money, shstr_bargaining, SK_EXP_NONE); |
506 | |
506 | |
507 | pay_from_container (pl, pl, to_pay); |
507 | pay_from_container (pl, pl, to_pay); |
508 | |
508 | |
509 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
509 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
510 | if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && (!pouch->race || pouch->race.contains ("gold"))) |
510 | if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && (!pouch->race || pouch->race.contains (shstr_gold))) |
511 | pay_from_container (pl, pouch, to_pay); |
511 | pay_from_container (pl, pouch, to_pay); |
512 | |
512 | |
513 | pl->update_stats (); |
513 | pl->update_stats (); |
514 | |
514 | |
515 | return 1; |
515 | return 1; |
… | |
… | |
732 | LOG (llevError, "Could not find %s archetype\n", coins[count]); |
732 | LOG (llevError, "Could not find %s archetype\n", coins[count]); |
733 | else if ((amount / at->value) > 0) |
733 | else if ((amount / at->value) > 0) |
734 | { |
734 | { |
735 | for (pouch = pl->inv; pouch; pouch = pouch->below) |
735 | for (pouch = pl->inv; pouch; pouch = pouch->below) |
736 | { |
736 | { |
737 | if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && pouch->race.contains ("gold")) |
737 | if (pouch->type == CONTAINER && pouch->flag [FLAG_APPLIED] && pouch->race.contains (shstr_gold)) |
738 | { |
738 | { |
739 | int w = at->weight * (100 - pouch->stats.Str) / 100; |
739 | int w = at->weight * (100 - pouch->stats.Str) / 100; |
740 | int n = amount / at->value; |
740 | int n = amount / at->value; |
741 | |
741 | |
742 | if (w == 0) |
742 | if (w == 0) |
… | |
… | |
855 | return 0; |
855 | return 0; |
856 | } |
856 | } |
857 | |
857 | |
858 | if (!item->type) |
858 | if (!item->type) |
859 | { |
859 | { |
860 | LOG (llevError, "shop_specialisation_ratio: passed an item with an invalid type\n"); |
860 | LOG (llevError, "shop_specialisation_ratio: passed an item with an invalid type: %s\n", item->debug_desc ()); |
861 | /* |
861 | /* |
862 | * I'm not really sure what the /right/ thing to do here is, these types of |
862 | * I'm not really sure what the /right/ thing to do here is, these types of |
863 | * item shouldn't exist anyway, but returning the ratio is probably the best bet.." |
863 | * item shouldn't exist anyway, but returning the ratio is probably the best bet.." |
864 | */ |
864 | */ |
865 | return SPECIALISATION_EFFECT; |
865 | return SPECIALISATION_EFFECT; |
… | |
… | |
870 | if (items[i].typenum == item->type || (!items[i].typenum && !likedness)) |
870 | if (items[i].typenum == item->type || (!items[i].typenum && !likedness)) |
871 | likedness = items[i].strength; |
871 | likedness = items[i].strength; |
872 | |
872 | |
873 | if (likedness > 100) |
873 | if (likedness > 100) |
874 | { /* someone has been rather silly with the map headers. */ |
874 | { /* someone has been rather silly with the map headers. */ |
875 | LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is above 100%%\n", item->type, &map->path); |
875 | LOG (llevDebug, "shop_specialisation ratio: item %s on map %s is above 100%%\n", item->debug_desc (), &map->path); |
876 | likedness = 100; |
876 | likedness = 100; |
877 | } |
877 | } |
878 | |
878 | |
879 | if (likedness < -100) |
879 | if (likedness < -100) |
880 | { |
880 | { |
881 | LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is below -100%%\n", item->type, &map->path); |
881 | LOG (llevDebug, "shop_specialisation ratio: item %s on map %s is below -100%%\n", item->debug_desc (), &map->path); |
882 | likedness = -100; |
882 | likedness = -100; |
883 | } |
883 | } |
884 | |
884 | |
885 | return lerp (double (likedness), -100., 100., SPECIALISATION_EFFECT, 1.); |
885 | return lerp (double (likedness), -100., 100., SPECIALISATION_EFFECT, 1.); |
886 | } |
886 | } |
… | |
… | |
1112 | |
1112 | |
1113 | void |
1113 | void |
1114 | shop_listing (object *sign, object *op) |
1114 | shop_listing (object *sign, object *op) |
1115 | { |
1115 | { |
1116 | int i, j, x1, x2, y1, y2; |
1116 | int i, j, x1, x2, y1, y2; |
1117 | const char *shop_coords = sign->kv (shstr_shop_coords); |
1117 | const char *shop_coords = sign->kv [shstr_shop_coords]; |
1118 | object *stack; |
1118 | object *stack; |
1119 | shopinv *items; |
1119 | shopinv *items; |
1120 | |
1120 | |
1121 | /* Should never happen, but just in case a monster does apply a sign */ |
1121 | /* Should never happen, but just in case a monster does apply a sign */ |
1122 | if (!op->is_player ()) |
1122 | if (!op->is_player ()) |