From 47d3518f3930927d679285912fa5b4bac4cb28a4 Mon Sep 17 00:00:00 2001 From: k21971 Date: Tue, 16 Jul 2024 19:51:05 +0000 Subject: [PATCH] Levels of erosion on an object can affect its price. 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'. --- doc/evilhack-changelog.md | 1 + src/shk.c | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/doc/evilhack-changelog.md b/doc/evilhack-changelog.md index 25c86d567..14f336f07 100644 --- a/doc/evilhack-changelog.md +++ b/doc/evilhack-changelog.md @@ -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 diff --git a/src/shk.c b/src/shk.c index a5972af7c..f1ea5264b 100644 --- a/src/shk.c +++ b/src/shk.c @@ -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 */ @@ -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)