Shopkeepers consider monster type for some items

Tins, eggs, and corpses will now cost different amounts
based on what intrinsics the monster type could give
This commit is contained in:
Pasi Kallinen
2023-10-25 18:45:07 +03:00
parent 48b10a1c8d
commit 7bf3888118
4 changed files with 51 additions and 2 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;