diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index e1eeb00f9..a9dae38aa 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1264,6 +1264,7 @@ if a temple was entered while blind, #overview could show a line of just "." when describing altars if no other interesting features on that level were known rolling boulders ignored walls and trees +shopkeepers consider the monster type when charging for tins, eggs and corpses Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index 3504d2b3f..df688821b 100644 --- a/include/extern.h +++ b/include/extern.h @@ -792,6 +792,7 @@ extern long temp_resist(int); extern void eating_conducts(struct permonst *); extern int eat_brains(struct monst *, struct monst *, boolean, int *); extern void fix_petrification(void); +extern int intrinsic_possible(int, struct permonst *); extern boolean should_givit(int, struct permonst *); extern void consume_oeaten(struct obj *, int); extern boolean maybe_finished_meal(boolean); diff --git a/src/eat.c b/src/eat.c index a3d918de5..9657ce707 100644 --- a/src/eat.c +++ b/src/eat.c @@ -19,7 +19,6 @@ static void do_reset_eat(void); static void maybe_extend_timed_resist(int); static void done_eating(boolean); static void cprefx(int); -static int intrinsic_possible(int, struct permonst *); static boolean temp_givit(int, struct permonst *); static void givit(int, struct permonst *); static void eye_of_newt_buzz(void); @@ -847,7 +846,7 @@ fix_petrification(void) */ /* intrinsic_possible() returns TRUE iff a monster can give an intrinsic. */ -static int +int intrinsic_possible(int type, struct permonst *ptr) { int res = 0; diff --git a/src/shk.c b/src/shk.c index 0ec10ccd7..e7223b8ee 100644 --- a/src/shk.c +++ b/src/shk.c @@ -48,6 +48,7 @@ static long cheapest_item(struct monst *); static int dopayobj(struct monst *, struct bill_x *, struct obj **, int, boolean); static long stolen_container(struct obj *, struct monst *, long, boolean); +static long corpsenm_price_adj(struct obj *); static long getprice(struct obj *, boolean); static void shk_names_obj(struct monst *, struct obj *, const char *, long, const char *); @@ -3612,6 +3613,51 @@ doinvbill( return 0; } +/* adjust tin, egg, or corpse price based on monster data */ +static long +corpsenm_price_adj(struct obj *obj) +{ + long val = 0L; + + if ((obj->otyp == TIN || obj->otyp == EGG || obj->otyp == CORPSE) + && obj->corpsenm >= LOW_PM) { + int i; + long tmp = 1L; + struct permonst *ptr = &mons[obj->corpsenm]; + struct { + int trinsic; + int cost; + } const icost[] = { + { FIRE_RES, 2 }, + { SLEEP_RES, 3 }, + { COLD_RES, 2 }, + { DISINT_RES, 5 }, + { SHOCK_RES, 4 }, + { POISON_RES, 2 }, + { ACID_RES, 1 }, + { STONE_RES, 3 }, + { TELEPORT, 2 }, + { TELEPORT_CONTROL, 3 }, + { TELEPAT, 5 } + }; + + for (i = 0; i < SIZE(icost); i++) + if (intrinsic_possible(icost[i].trinsic, ptr)) + tmp += icost[i].cost; + if (unique_corpstat(ptr)) + tmp += 50; + + + val = max(1, ((ptr->mlevel - 1) * 2)); + if (obj->otyp == CORPSE) + val += max(1, (ptr->cnutrit / 30)); + + val = val * tmp; + } + + return val; +} + static long getprice(register struct obj* obj, boolean shk_buying) { @@ -3624,6 +3670,8 @@ getprice(register struct obj* obj, boolean shk_buying) } switch (obj->oclass) { case FOOD_CLASS: + tmp += corpsenm_price_adj(obj); + /* simpler hunger check, (2-4)*cost */ if (u.uhs >= HUNGRY && !shk_buying) tmp *= (long) u.uhs;