Skip to content

Commit

Permalink
Levels of erosion on an object can affect its price.
Browse files Browse the repository at this point in the history
Depending on the level of erosion on an object will effect its price,
both buying from and selling to a shopkeeper. If the object is 'fixed',
that will affect the price also. The breakdown:

* one level of erosion, price is decreased by 1.5x the base value
* two levels of erosion, price is decreased by 2x the base value
* three levels of erosion, price is decreased by 3x the base value
* 'fixed' objects, price is increased by 2x the base value

There are two types of erosion - oeroded and oeroded2. These can stack,
so if you have an object that is both rusty and corroded, it's value
will decrease significantly.

'Fixed' refers to objects that are purposely made erodeproof. Objects
made of materials that are already inherently erodeproof are not
considered 'fixed'.
  • Loading branch information
k21971 committed Jul 16, 2024
1 parent 241c763 commit 47d3518
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/evilhack-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3549,4 +3549,5 @@ The following changes to date are:
- Fix: potential crash with dark elven objects falling down to the level below
- Fix: various player monster attacks not damaging other monsters
- Additional feedback when damaging monsters vulnerable to elemental damage
- Levels of erosion on an object can affect its price

39 changes: 35 additions & 4 deletions src/shk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3695,12 +3695,43 @@ boolean shk_buying;
if (shk_buying)
tmp /= 4;
} else if (obj->oprops) {
int i, factor = 50, next = 2;
for (i = 0; i < MAX_ITEM_PROPS; i++)
int i, factor = 50L, next = 2L;

for (i = 0; i < MAX_ITEM_PROPS; i++) {
if (obj->oprops & (1 << i))
factor *= next, next = (next == 2) ? 5 : 2;
factor *= next, next = (next == 2L)
? 5L : 2L;
}
tmp += factor;
}

/* object price is affected by its level of erosion,
or if made erodeproof. oeroded and eroded2 can stack,
so having an object that is rusted and corroded can
greatly decrease its value, both buying from and
selling to a shopkeeper */

if (obj->oerodeproof)
tmp *= 2L;

if (obj->oeroded) {
if (obj->oeroded == 3)
tmp /= 3L;
else if (obj->oeroded == 2)
tmp /= 2L;
else if (obj->oeroded == 1)
tmp -= (3L / 2L) + 1L;
}

if (obj->oeroded2) {
if (obj->oeroded2 == 3)
tmp /= 3L;
else if (obj->oeroded2 == 2)
tmp /= 2L;
else if (obj->oeroded2 == 1)
tmp -= (3L / 2L) + 1L;
}

switch (obj->oclass) {
case FOOD_CLASS:
/* simpler hunger check, (2-4)*cost */
Expand All @@ -3719,7 +3750,7 @@ boolean shk_buying;
break;
case ARMOR_CLASS:
if (Is_dragon_scaled_armor(obj))
tmp += ((3 * objects[obj->dragonscales].oc_cost) / 2L);
tmp += ((3L * objects[obj->dragonscales].oc_cost) / 2L);
/* FALLTHRU */
case WEAPON_CLASS:
if (obj->spe > 0)
Expand Down

0 comments on commit 47d3518

Please sign in to comment.