… | |
… | |
33 | * offer a range of prices around it such that the maximum price is always one |
33 | * offer a range of prices around it such that the maximum price is always one |
34 | * therefore making this number higher, makes specialisation less effective. |
34 | * therefore making this number higher, makes specialisation less effective. |
35 | * setting this value above 1 or to a negative value would have interesting, |
35 | * setting this value above 1 or to a negative value would have interesting, |
36 | * (though not useful) effects. |
36 | * (though not useful) effects. |
37 | */ |
37 | */ |
38 | #define SPECIALISATION_EFFECT 0.5 |
38 | #define SPECIALISATION_EFFECT .5 |
39 | |
39 | |
40 | /* price a shopkeeper will give someone they neither like nor dislike */ |
40 | /* price a shopkeeper will give someone they neither like nor dislike */ |
41 | #define NEUTRAL_RATIO 0.8 |
41 | #define NEUTRAL_RATIO 0.8 |
42 | |
42 | |
43 | static void pay_from_container (object *pl, object *pouch, sint64 &to_pay); |
43 | static void pay_from_container (object *pl, object *pouch, sint64 &to_pay); |
… | |
… | |
917 | } |
917 | } |
918 | |
918 | |
919 | |
919 | |
920 | /* returns a double that is the ratio of the price that a shop will offer for |
920 | /* returns a double that is the ratio of the price that a shop will offer for |
921 | * item based on the shops specialisation. Does not take account of greed, |
921 | * item based on the shops specialisation. Does not take account of greed, |
922 | * returned value is between (2*SPECIALISATION_EFFECT-1) and 1 and in any |
922 | * returned value is between SPECIALISATION_EFFECT and 1. |
923 | * event is never less than 0.1 (calling functions divide by it) |
|
|
924 | */ |
923 | */ |
925 | static double |
924 | static double |
926 | shop_specialisation_ratio (const object *item, const maptile *map) |
925 | shop_specialisation_ratio (const object *item, const maptile *map) |
927 | { |
926 | { |
928 | shopitems *items = map->shopitems; |
927 | shopitems *items = map->shopitems; |
929 | double ratio = SPECIALISATION_EFFECT, likedness = 0.001; |
928 | double likedness = 0.; |
930 | int i; |
929 | int i; |
931 | |
930 | |
932 | if (item == NULL) |
931 | if (item == NULL) |
933 | { |
932 | { |
934 | LOG (llevError, "shop_specialisation_ratio: passed a NULL item for map %s\n", &map->path); |
933 | LOG (llevError, "shop_specialisation_ratio: passed a NULL item for map %s\n", &map->path); |
… | |
… | |
940 | LOG (llevError, "shop_specialisation_ratio: passed an item with an invalid type\n"); |
939 | LOG (llevError, "shop_specialisation_ratio: passed an item with an invalid type\n"); |
941 | /* |
940 | /* |
942 | * I'm not really sure what the /right/ thing to do here is, these types of |
941 | * I'm not really sure what the /right/ thing to do here is, these types of |
943 | * item shouldn't exist anyway, but returning the ratio is probably the best bet.." |
942 | * item shouldn't exist anyway, but returning the ratio is probably the best bet.." |
944 | */ |
943 | */ |
945 | return ratio; |
944 | return SPECIALISATION_EFFECT; |
946 | } |
945 | } |
947 | |
946 | |
948 | if (map->shopitems) |
947 | if (map->shopitems) |
949 | { |
948 | { |
950 | for (i = 0; i < items[0].index; i++) |
949 | for (i = 0; i < items[0].index; i++) |
… | |
… | |
962 | { |
961 | { |
963 | LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is below -100%%\n", item->type, &map->path); |
962 | LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is below -100%%\n", item->type, &map->path); |
964 | likedness = -1.0; |
963 | likedness = -1.0; |
965 | } |
964 | } |
966 | |
965 | |
967 | ratio = ratio + (1.0 - ratio) * likedness; |
966 | return lerp (likedness, -1., 1., SPECIALISATION_EFFECT, 1.); |
968 | |
|
|
969 | if (ratio <= 0.1) |
|
|
970 | ratio = 0.1; /* if the ratio were much lower than this, we would get silly prices */ |
|
|
971 | |
|
|
972 | return ratio; |
|
|
973 | } |
967 | } |
974 | |
968 | |
975 | /*returns the greed of the shop on map, or 1 if it isn't specified. */ |
969 | /*returns the greed of the shop on map, or 1 if it isn't specified. */ |
976 | static double |
970 | static double |
977 | shop_greed (const maptile *map) |
971 | shop_greed (const maptile *map) |