diff --git a/JotunnModStub/Aswid/AswidConfig.cs b/JotunnModStub/Aswid/AswidConfig.cs index 093706a..8723800 100644 --- a/JotunnModStub/Aswid/AswidConfig.cs +++ b/JotunnModStub/Aswid/AswidConfig.cs @@ -70,6 +70,12 @@ namespace RacesOfValheim // ─── Devour ──────────────────────────────────────────────────────────── public static ConfigEntry DevourCooldown; + // What a devoured creature feeds - see AswidRace.ApplyFoodBalance. + public static ConfigEntry DevourHealthMultiplier; + public static ConfigEntry DevourStaminaShare; + public static ConfigEntry EarlyStaminaShare; + public static ConfigEntry FoodCapBase; + public static ConfigEntry FoodCapPerBiome; // ─── Domination (tier 6+ ability, native Interact key) ─────────────────── public static ConfigEntry EnslaveCooldown; @@ -189,6 +195,23 @@ namespace RacesOfValheim const string devour = "Aswid - Devour"; DevourCooldown = config.Bind(devour, "Consume Cooldown", 5f, new ConfigDescription("How long one body stays drunk-dry, in seconds. A single death is reported to the devour more than once - by two damage patches, by the aura's execute, by a thrall's kill - and this is the window that keeps those from feeding you twice off the same corpse. It is per body, not per player: killing a whole pack at once devours every one of them. One second is used as the floor, so no corpse feeds you twice even at 0.", new AcceptableValueRange(0f, 60f))); + DevourHealthMultiplier = config.Bind(devour, "Health Multiplier", 0.9f, + new ConfigDescription("Scales the health every devoured creature feeds you. 1 is the old amount.", new AcceptableValueRange(0f, 2f))); + DevourStaminaShare = config.Bind(devour, "Stamina Share", 0.10f, + new ConfigDescription("Fraction of that health turned into stamina instead, for creatures past the Black Forest. 0.1 = 10%.", new AcceptableValueRange(0f, 1f))); + EarlyStaminaShare = config.Bind(devour, "Early Creature Stamina Share", 0.60f, + new ConfigDescription("The same, for Meadows and Black Forest creatures. Above 0.5 they feed more stamina than health. Set it equal to the one above to treat every creature alike.", new AcceptableValueRange(0f, 1f))); + FoodCapBase = config.Bind(devour, "Food Health Cap Base", 15f, + new ConfigDescription("Creatures with no hand-set meal feed half their health. That is capped at this plus the per-biome value times the biome's number (Meadows 1 ... Deep North 8). With the defaults: Black Forest 45, Mountains 75, Plains 90.", new AcceptableValueRange(0f, 150f))); + FoodCapPerBiome = config.Bind(devour, "Food Health Cap Per Biome", 15f, + new ConfigDescription("See the base cap above.", new AcceptableValueRange(0f, 50f))); + + // Jotunn's server sync assigns Value, which fires SettingChanged, so the server's + // numbers reach the foods the same way a local drag does. + foreach (var entry in new[] { DevourHealthMultiplier, DevourStaminaShare, EarlyStaminaShare, FoodCapBase, FoodCapPerBiome }) + { + entry.SettingChanged += (_, __) => AswidRace.ApplyAllFoodBalance(); + } const string domination = "Aswid - Domination"; EnslaveCooldown = config.Bind(domination, "Enslave Cooldown", 900f, diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 26bc9be..2304b4a 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -191,6 +191,11 @@ namespace RacesOfValheim if (c != null) { float foodHp = Mathf.Min(c.m_health / 2f, 150f); + // The formula alone only knows how big a creature is, not where it + // lives - a Black Forest troll came out at 150. Only these get the + // per-biome cap in ApplyFoodBalance; the hand-set values below are + // choices, not formula output, and keep theirs. + bool fromFormula = true; // Capped at 50 minutes: a tough creature like the Barka would otherwise // feed for over an hour. float burnTime = Mathf.Min(c.m_health * 2f, 3000f); @@ -201,24 +206,38 @@ namespace RacesOfValheim { burnTime = 1200f; // 20 minutes } - else if (mobName == "JotunWitch") { foodHp = 120f; burnTime = 3600f; } // 60 minutes - else if (mobName == "ElakingMole") { foodHp = 100f; burnTime = 1800f; } // 30 minutes - else if (mobName.StartsWith("Dverger") && mobName != "DvergerDeepNorth") { foodHp = 90f; burnTime = 1500f; } // 25 minutes - else if (mobName == "DvergerDeepNorth") { foodHp = 100f; burnTime = 1800f; } // 30 minutes - else if (mobName == "Greyling") { foodHp = 20f; burnTime = 1200f; } - else if (mobName == "Greydwarf") { foodHp = 25f; burnTime = 1200f; } - else if (mobName == "Greydwarf_Shaman") { foodHp = 30f; burnTime = 1200f; } - else if (mobName == "Greydwarf_Elite") { foodHp = 60f; burnTime = 1800f; } + else if (mobName == "JotunWitch") { foodHp = 120f; burnTime = 3600f; fromFormula = false; } // 60 minutes + else if (mobName == "ElakingMole") { foodHp = 100f; burnTime = 1800f; fromFormula = false; } // 30 minutes + else if (mobName.StartsWith("Dverger") && mobName != "DvergerDeepNorth") { foodHp = 90f; burnTime = 1500f; fromFormula = false; } // 25 minutes + else if (mobName == "DvergerDeepNorth") { foodHp = 100f; burnTime = 1800f; fromFormula = false; } // 30 minutes + else if (mobName == "Greyling") { foodHp = 20f; burnTime = 1200f; fromFormula = false; } + else if (mobName == "Greydwarf") { foodHp = 25f; burnTime = 1200f; fromFormula = false; } + else if (mobName == "Greydwarf_Shaman") { foodHp = 30f; burnTime = 1200f; fromFormula = false; } + else if (mobName == "Greydwarf_Elite") { foodHp = 60f; burnTime = 1800f; fromFormula = false; } customItem.ItemDrop.m_itemData.m_shared.m_food = foodHp; customItem.ItemDrop.m_itemData.m_shared.m_foodStamina = 0f; customItem.ItemDrop.m_itemData.m_shared.m_foodEitr = 0f; customItem.ItemDrop.m_itemData.m_shared.m_foodBurnTime = burnTime; customItem.ItemDrop.m_itemData.m_shared.m_foodRegen = Mathf.Max(1f, foodHp / 15f); + if (fromFormula) formulaFoods.Add(foodName); } } } + // What the item gives before any balance setting, kept so ApplyFoodBalance can be + // rerun from scratch whenever a setting changes or the server's values arrive. + var shared = customItem.ItemDrop.m_itemData.m_shared; + baseFoods[foodName] = new BaseFood + { + Mob = mobName, + Health = shared.m_food, + Stamina = shared.m_foodStamina, + Regen = shared.m_foodRegen, + Shared = shared + }; + ApplyFoodBalance(foodName); + GameObject trophyPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab(trophyName); if (trophyPrefab != null) { @@ -234,6 +253,81 @@ namespace RacesOfValheim } } + private class BaseFood + { + public string Mob; + public float Health; + public float Stamina; + public float Regen; + public ItemDrop.ItemData.SharedData Shared; + } + + private static readonly Dictionary baseFoods = new Dictionary(); + private static readonly HashSet formulaFoods = new HashSet(); + + /// + /// The biome each edible creature lives in, as a number from 1 (Meadows) to 8 (Deep North). + /// It decides two things: the cap on formula-made foods, and which creatures count as early + /// game (1 and 2) for the larger stamina share. A creature missing here counts as tier 8, + /// which means uncapped in practice and never early. + /// + private static readonly Dictionary mobBiomeTier = new Dictionary + { + { "Boar", 1 }, { "Neck", 1 }, { "Deer", 1 }, { "Greyling", 1 }, + { "Greydwarf", 2 }, { "Greydwarf_Elite", 2 }, { "Greydwarf_Shaman", 2 }, { "Troll", 2 }, + { "Leech", 3 }, + { "Wolf", 4 }, { "Fenring", 4 }, { "Fenring_Cultist", 4 }, { "Ulv", 4 }, { "Hatchling", 4 }, + { "Lox", 5 }, { "Goblin", 5 }, { "GoblinArcher", 5 }, { "GoblinShaman", 5 }, { "GoblinBrute", 5 }, { "Deathsquito", 5 }, + { "Hare", 6 }, { "Seeker", 6 }, { "SeekerBrood", 6 }, { "SeekerBrute", 6 }, { "Gjall", 6 }, { "Tick", 6 }, + { "Dverger", 6 }, { "DvergerMage", 6 }, { "DvergerMageFire", 6 }, { "DvergerMageIce", 6 }, { "DvergerMageSupport", 6 }, + { "Asksvin", 7 }, { "Volture", 7 }, { "DvergerAshlands", 7 }, + }; + + public const int EarlyBiomeTier = 2; + + private static int GetBiomeTier(string mob) => mobBiomeTier.TryGetValue(mob, out int tier) ? tier : 8; + + /// + /// Rewrites one devour food from its unbalanced base and the current settings. The Discord + /// reports said even weak kills fed too much health; Dissolution asked for about 10% less, + /// and for early creatures to feed stamina more than health. So: health is scaled first, + /// then a share of it moves over to stamina. Vanilla meals the food was cloned from keep + /// the stamina they already had, the share goes on top. + /// + /// Writing the shared data is enough to reach every copy: eaten foods, the extra slot and + /// the tooltip all read the same SharedData through their ItemData. + /// + private static void ApplyFoodBalance(string foodName) + { + if (!baseFoods.TryGetValue(foodName, out BaseFood food) || food.Shared == null) return; + + int tier = GetBiomeTier(food.Mob); + float health = food.Health; + if (formulaFoods.Contains(foodName)) + { + health = Mathf.Min(health, AswidConfig.FoodCapBase.Value + AswidConfig.FoodCapPerBiome.Value * tier); + } + + float healthMultiplier = AswidConfig.DevourHealthMultiplier.Value; + health *= healthMultiplier; + + float share = tier <= EarlyBiomeTier ? AswidConfig.EarlyStaminaShare.Value : AswidConfig.DevourStaminaShare.Value; + float moved = health * share; + + food.Shared.m_food = health - moved; + food.Shared.m_foodStamina = food.Stamina + moved; + // Regen follows the health the food ends up giving, cap included, so a troll capped + // to 40 health does not keep the 10 per tick its old 150 earned. + float healthRatio = food.Health > 0f ? food.Shared.m_food / food.Health : 0f; + food.Shared.m_foodRegen = Mathf.Max(1f, food.Regen * healthRatio); + } + + /// Hooked to the balance settings, which also fire when the server's values arrive. + public static void ApplyAllFoodBalance() + { + foreach (string foodName in baseFoods.Keys) ApplyFoodBalance(foodName); + } + private float m_tintCheckTimer = 0f; private float sensesCheckTimer = 0f; diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 9b84f96..a8688cf 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -471,6 +471,10 @@ namespace RacesOfValheim Mathf.RoundToInt(AswidRace.GetStaminaBonus(state)), Mathf.RoundToInt(AswidConfig.StaminaBonusPerState.Value), Mathf.RoundToInt(AswidConfig.StaminaCostMultiplier.Value * 100f))); + sb.AppendLine(ModText.Get("rov_compendium_aswid_devour_diet", + Mathf.RoundToInt(AswidConfig.DevourHealthMultiplier.Value * 100f), + Mathf.RoundToInt(AswidConfig.EarlyStaminaShare.Value * 100f), + Mathf.RoundToInt(AswidConfig.DevourStaminaShare.Value * 100f))); sb.AppendLine(ModText.Get("rov_compendium_aswid_vampiric_aura_passive_toggle")); sb.AppendLine(ModText.Get("rov_compendium_aswid_always_active_every_form_with", auraRadiusDay, auraRadiusNight, auraExecute)); diff --git a/JotunnModStub/Translations/English/compendium.json b/JotunnModStub/Translations/English/compendium.json index 295b8e7..aad0c9e 100644 --- a/JotunnModStub/Translations/English/compendium.json +++ b/JotunnModStub/Translations/English/compendium.json @@ -40,6 +40,7 @@ "rov_compendium_aswid_superhuman_senses_passive": "[Moder Unlock] Superhuman Senses (Passive):", "rov_compendium_aswid_take_no_fall_damage_physical": "You take no fall damage, and physical kills automatically devour edible enemies (Vae Victis) for Blood Magic XP. Your physical stats scale with every boss you defeat: +$1 Armor, +$2 Damage, +$3% Speed and Jump, and +$4% Lifesteal on physical hits. All of these bonuses double during the night. You can cast Blood Magic items with infinite Eitr, and your Blood Magic skill rises $5x as fast.\n", "rov_compendium_aswid_undead_vigor": "Undead Vigor: your endurance is unholy but not endless. You carry +$1 Maximum Stamina at your present standing (+$2 for every boss), on top of what your food gives, and every stamina cost lands at $3% of the normal price.\n", + "rov_compendium_aswid_devour_diet": "Blood is all you eat, and what it gives depends on whose it was. A devoured creature feeds $1% of the health it once did. Of that, Meadows and Black Forest prey turn $2% into stamina instead, anything from further afield $3%. Creatures without a meal of their own feed no more than their homeland allows: a troll is still Black Forest prey.\n", "rov_compendium_aswid_tame_u_key_asksvin_join": "[Fader Unlock] Tame ('U' Key): Asksvin join the huntable list.\n", "rov_compendium_aswid_tame_u_key_lox_join": "[Yagluth Unlock] Tame ('U' Key): Lox join the huntable list.\n", "rov_compendium_aswid_tame_u_key_tame_boar": "[Eikthyr Unlock] Tame ('U' Key): Tame a boar under your cursor.\n", diff --git a/JotunnModStub/Translations/Italian/compendium.json b/JotunnModStub/Translations/Italian/compendium.json index f1093dd..d0ffc39 100644 --- a/JotunnModStub/Translations/Italian/compendium.json +++ b/JotunnModStub/Translations/Italian/compendium.json @@ -40,6 +40,7 @@ "rov_compendium_aswid_superhuman_senses_passive": "[Sblocco Moder] Sensi sovrumani (passiva):", "rov_compendium_aswid_take_no_fall_damage_physical": "Non subisci danni da caduta, e le uccisioni fisiche divorano automaticamente i nemici commestibili (Vae Victis) dandoti esperienza di Magia del sangue. Le tue statistiche fisiche crescono con ogni boss sconfitto: +$1 armatura, +$2 danni, +$3% velocità e salto, +$4% furto di vita sui colpi fisici. Di notte tutti questi bonus raddoppiano. Puoi usare gli oggetti di Magia del sangue con eitr infinito, e la tua abilità di Magia del sangue sale $5 volte più in fretta.\n", "rov_compendium_aswid_undead_vigor": "Vigore non morto: la tua resistenza è empia, ma non infinita. Al tuo livello attuale hai +$1 stamina massima (+$2 per ogni boss), oltre a quella che ti dà il cibo, e ogni costo di stamina ti pesa il $3% del normale.\n", + "rov_compendium_aswid_devour_diet": "Ti nutri solo di sangue, e quello che ti dà dipende da chi lo versa. Una creatura divorata ti dà il $1% della salute di prima. Di questa, le prede di Prati e Foresta Nera ne trasformano il $2% in stamina, quelle delle terre più lontane il $3%. Le creature senza un pasto proprio non danno più di quanto concede la loro terra: un troll resta una preda della Foresta Nera.\n", "rov_compendium_aswid_tame_u_key_asksvin_join": "[Sblocco Fader] Addomesticare (tasto 'U'): gli asksvin si aggiungono alle prede.\n", "rov_compendium_aswid_tame_u_key_lox_join": "[Sblocco Yagluth] Addomesticare (tasto 'U'): i lox si aggiungono alle prede.\n", "rov_compendium_aswid_tame_u_key_tame_boar": "[Sblocco Eikthyr] Addomesticare (tasto 'U'): addomestica il cinghiale sotto il cursore.\n", diff --git a/JotunnModStub/Translations/Russian/compendium.json b/JotunnModStub/Translations/Russian/compendium.json index 95ee341..26a60a6 100644 --- a/JotunnModStub/Translations/Russian/compendium.json +++ b/JotunnModStub/Translations/Russian/compendium.json @@ -40,6 +40,7 @@ "rov_compendium_aswid_superhuman_senses_passive": "[Награда: Матерь] Сверхчеловеческие чувства (Пассивное):", "rov_compendium_aswid_take_no_fall_damage_physical": "Вы не получаете урона от падения, а убийства в ближнем бою автоматически пожирают съедобных врагов (Vae Victis), принося опыт магии крови. Ваши физические характеристики растут с каждым убитым боссом: +$1 к броне, +$2 к урону, +$3% к скорости и прыжку, и +$4% вампиризма при физ. атаках. Все эти бонусы удваиваются ночью. Вы можете использовать предметы магии крови с бесконечным эйтром, а навык «Магия крови» растет в $5 раз быстрее.\n", "rov_compendium_aswid_undead_vigor": "Неживая стойкость: ваша выносливость нечестива, но не бесконечна. На текущем этапе у вас +$1 к максимальной выносливости (+$2 за каждого босса) сверх той, что дает еда, а любые траты выносливости составляют $3% от обычных.\n", + "rov_compendium_aswid_devour_diet": "Вы питаетесь только кровью, и ее сила зависит от того, чья она. Пожранное существо дает $1% прежнего здоровья. Из него добыча Лугов и Черного леса превращает $2% в выносливость, существа из дальних земель — $3%. Существа без собственного блюда дают не больше, чем позволяет их родной край: тролль остается добычей Черного леса.\n", "rov_compendium_aswid_tame_u_key_asksvin_join": "[Награда: Прародитель] Приручение (клавиша «U»): Пеплозавры добавляются в список доступных для приручения.\n", "rov_compendium_aswid_tame_u_key_lox_join": "[Награда: Яглут] Приручение (клавиша «U»): Быкоящеры добавляются в список доступных для приручения.\n", "rov_compendium_aswid_tame_u_key_tame_boar": "[Награда: Эйктюр] Приручение (клавиша «U»): Мгновенно приручает кабана под прицелом.\n",