Adds TrolConfig.cs, following the established per-race pattern: one Configuration Manager section per topic (Passive Combat, Throw Rock, True Form, Log Weapon, Farming), plus the two ability keybinds (Throw Rock, True Form). Defaults match the previous hardcoded constants exactly. Fixes a real sync risk found while wiring it: True Form's scale (2.0 normal / 2.5 at tier 7+) was hardcoded independently in two places - the local transform routine in TrolRace and the remote-player sizing postfix in TrolPatches. Both now read the same TrolConfig.TrueFormScaleNormal/ TrueFormScaleAdvanced, so a retuned value can no longer make a Trol one size to themselves and another size to everyone else. Tier-gate thresholds and the small hardcoded "normal size by tier" table (1.2/1.25/1.30) stay untouched, same boundary drawn for every other race's progression data. Config sections stay bound alphabetically by race (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Trenta, Trol) in RacesOfValheim.Awake() - this is the last of the nine.
101 lines
3.6 KiB
C#
101 lines
3.6 KiB
C#
using HarmonyLib;
|
|
using UnityEngine;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
public static class TrolFarmingHelper
|
|
{
|
|
public static void ApplyTrolUnarmedToolBuff(HitData hit, bool isTree)
|
|
{
|
|
if (hit == null) return;
|
|
|
|
Character attacker = hit.GetAttacker();
|
|
if (attacker != null && attacker == Player.m_localPlayer && TrolRace.IsTrol())
|
|
{
|
|
ItemDrop.ItemData rightItem = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field<ItemDrop.ItemData>("m_rightItem").Value;
|
|
bool isHoldingLog = rightItem != null && rightItem.m_dropPrefab != null && rightItem.m_dropPrefab.name.StartsWith("TrolWeapon_");
|
|
|
|
if (isHoldingLog && isTree)
|
|
{
|
|
hit.m_toolTier = 10;
|
|
hit.m_damage.m_chop = 9999f;
|
|
return;
|
|
}
|
|
|
|
if (hit.m_skill == Skills.SkillType.Unarmed)
|
|
{
|
|
int state = BossProgressionManager.GetCurrentProgressionState();
|
|
|
|
if (state >= 8) hit.m_toolTier = 5; // Fader (Fire Metal)
|
|
else if (state >= 6) hit.m_toolTier = 4; // Yagluth (Black Metal)
|
|
else if (state >= 5) hit.m_toolTier = 3; // Moder (Silver)
|
|
else if (state >= 4) hit.m_toolTier = 2; // Bonemass (Iron)
|
|
else if (state >= 3) hit.m_toolTier = 1; // Elder (Bronze)
|
|
else if (state >= 2) hit.m_toolTier = 1; // Eikthyr (Flint/Antler)
|
|
|
|
float damageBonus = state * TrolConfig.UnarmedFarmingDamageBonusPerState.Value;
|
|
|
|
// Convert blunt damage to chop or pickaxe damage, plus progression bonus
|
|
if (isTree)
|
|
{
|
|
hit.m_damage.m_chop = hit.m_damage.m_blunt + damageBonus;
|
|
Player.m_localPlayer.RaiseSkill(Skills.SkillType.WoodCutting, 1f);
|
|
}
|
|
else
|
|
{
|
|
hit.m_damage.m_pickaxe = hit.m_damage.m_blunt + damageBonus;
|
|
Player.m_localPlayer.RaiseSkill(Skills.SkillType.Pickaxes, 1f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(TreeBase), "RPC_Damage")]
|
|
public static class Trol_TreeBase_RPC_Damage_Patch
|
|
{
|
|
public static void Prefix(HitData hit)
|
|
{
|
|
TrolFarmingHelper.ApplyTrolUnarmedToolBuff(hit, true);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(TreeLog), "RPC_Damage")]
|
|
public static class Trol_TreeLog_RPC_Damage_Patch
|
|
{
|
|
public static void Prefix(HitData hit)
|
|
{
|
|
TrolFarmingHelper.ApplyTrolUnarmedToolBuff(hit, true);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(Destructible), "RPC_Damage")]
|
|
public static class Trol_Destructible_RPC_Damage_Patch
|
|
{
|
|
public static void Prefix(HitData hit, Destructible __instance)
|
|
{
|
|
// Some destructibles are trees (stumps), some are rocks.
|
|
// We can check the destructible type.
|
|
bool isTree = __instance.m_destructibleType == DestructibleType.Tree;
|
|
TrolFarmingHelper.ApplyTrolUnarmedToolBuff(hit, isTree);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(MineRock), "RPC_Hit")]
|
|
public static class Trol_MineRock_RPC_Hit_Patch
|
|
{
|
|
public static void Prefix(HitData hit)
|
|
{
|
|
TrolFarmingHelper.ApplyTrolUnarmedToolBuff(hit, false);
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(MineRock5), "DamageArea")]
|
|
public static class Trol_MineRock5_DamageArea_Patch
|
|
{
|
|
public static void Prefix(HitData hit)
|
|
{
|
|
TrolFarmingHelper.ApplyTrolUnarmedToolBuff(hit, false);
|
|
}
|
|
}
|
|
}
|