Initial commit
This commit is contained in:
commit
c4a24c9fdf
142 changed files with 15491 additions and 0 deletions
101
JotunnModStub/Trol/TrolFarmingPatches.cs
Normal file
101
JotunnModStub/Trol/TrolFarmingPatches.cs
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
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 * 3f;
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue