Merge branch 'localisation' into localisation-turkish

This commit is contained in:
kanym 2026-11-06 21:45:36 +01:00
commit 968540617a
20 changed files with 281 additions and 64 deletions

View file

@ -119,7 +119,10 @@ namespace RacesOfValheim
if (Time.time >= nextPulse)
{
nextPulse = Time.time + AlfarPowerConfig.ArchonPulseInterval.Value;
AlfarPowers.Pulse(player, AlfarPowerConfig.ArchonPulseRadius.Value, AlfarPowerConfig.ArchonPulseDamage.Value);
// The pulse fires on its own while the form lasts, so it earns what an aura does:
// a tenth of a hit per second, once per pulse that struck something.
if (AlfarPowers.Pulse(player, AlfarPowerConfig.ArchonPulseRadius.Value, AlfarPowerConfig.ArchonPulseDamage.Value))
FormMelee.RaiseSkill(Skills.SkillType.ElementalMagic, 0.1f * AlfarPowerConfig.ArchonPulseInterval.Value);
}
}

View file

@ -148,12 +148,17 @@ namespace RacesOfValheim
}
/// <summary>A pulse of lightning on every hostile creature within a radius of the Alfr.</summary>
public static void Pulse(Player player, float radius, float damage)
/// <returns>True if it struck at least one creature.</returns>
public static bool Pulse(Player player, float radius, float damage)
{
bool struck = false;
foreach (Character character in CharactersIn(player.transform.position, radius))
{
if (IsHostile(player, character)) Strike(player, character, damage, character.GetCenterPoint());
if (!IsHostile(player, character)) continue;
Strike(player, character, damage, character.GetCenterPoint());
struck = true;
}
return struck;
}
private static IEnumerable<Character> CharactersIn(Vector3 center, float radius)
@ -396,7 +401,11 @@ namespace RacesOfValheim
AlfarEitr.Spend(player, cost);
}
if (IsHostile(player, target)) Strike(player, target, AlfarPowerConfig.BeamDps.Value * tick, end);
if (IsHostile(player, target))
{
Strike(player, target, AlfarPowerConfig.BeamDps.Value * tick, end);
FormMelee.RaiseSkill(Skills.SkillType.ElementalMagic, tick); // a full hit per second on target
}
}
private static void RaiseHand(Player player)
@ -548,14 +557,19 @@ namespace RacesOfValheim
const float tick = 0.5f;
nextTick = Time.time + tick;
bool struck = false;
foreach (Collider collider in Physics.OverlapSphere(transform.position, Radius, ~0, QueryTriggerInteraction.Ignore))
{
Character character = collider.GetComponentInParent<Character>();
if (character == null || character == Owner || character.IsDead() || character.IsTamed()) continue;
if (!BaseAI.IsEnemy(Owner, character)) continue;
AlfarPowers.Strike(Owner, character, DamagePerSecond * tick, character.GetCenterPoint());
struck = true;
}
// Once per tick, not per creature: a full hit per second the storm strikes something.
if (struck && Owner == Player.m_localPlayer) FormMelee.RaiseSkill(Skills.SkillType.ElementalMagic, tick);
Vector2 offset = Random.insideUnitCircle * Radius;
AlfarFx.Spawn("fx_JotunWitch_LightningBolt_Explosion", transform.position + new Vector3(offset.x, 0f, offset.y));
}

View file

@ -931,6 +931,30 @@ namespace RacesOfValheim
}
}
/// <summary>
/// Pukeberries empty the fourth stomach too.
///
/// SE_Puke calls RemoveOneFood once a second, and vanilla only ever picks from its own three
/// slots, so the Aswid's fourth meal survived the berries. It now goes into the same random
/// draw as the other three, the way the Trol's extra slots do.
/// </summary>
[HarmonyPatch(typeof(Player), "RemoveOneFood")]
public static class Aswid_PlayerRemoveOneFood_Patch
{
public static bool Prefix(Player __instance, System.Collections.Generic.List<Player.Food> ___m_foods, ref bool __result)
{
if (__instance != Player.m_localPlayer || !AswidRace.IsAswid()) return true;
if (!AswidFoodManager.ExtraFoods.TryGetValue(__instance, out Player.Food extraFood) || extraFood == null) return true;
int vanillaCount = ___m_foods != null ? ___m_foods.Count : 0;
if (Random.Range(0, vanillaCount + 1) < vanillaCount) return true; // one of vanilla's three
AswidFoodManager.ClearFood(__instance);
__result = true;
return false;
}
}
[HarmonyPatch(typeof(Player), "ClearFood")]
public static class Aswid_Player_ClearFood_Patch
{

View file

@ -1191,6 +1191,7 @@ namespace RacesOfValheim
int layerMask = LayerMask.GetMask("character", "character_net", "character_ghost");
var colliders = Physics.OverlapSphere(center, radius, layerMask);
bool hitCreature = false;
foreach (var col in colliders)
{
@ -1241,10 +1242,16 @@ namespace RacesOfValheim
// kill). ApplyDamage() skipped all of that: it edited the local copy of a
// character we usually do not own, and the owner overwrote it on the next sync.
c.Damage(hd);
hitCreature = true;
SpawnBloodVFX(c);
}
}
// The aura scales with Blood Magic but called Damage directly, so it never paid
// the skill back. Passive and always on, so it earns what the Skadi's Frost Aura
// does: a tenth of a hit per second of draining, once per tick, not per victim.
if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.BloodMagic, 0.1f * AswidConfig.AuraTickInterval.Value);
}
catch (Exception ex)
{

View file

@ -165,6 +165,10 @@ namespace RacesOfValheim
if (!__result) return; // already not enemies, nothing to add
if (a == null || b == null) return;
// The player's own blow. Peace is the creature's choice, not a shield. See
// RaceGrudge.StrikeScope.
if (RaceGrudge.PlayerStrikes(a)) return;
if (IsThrallTruce(a, b) || IsThrallTruce(b, a))
{
__result = false;

View file

@ -59,8 +59,9 @@ namespace RacesOfValheim
"Without this the truce is absolute in both directions: MonsterAI.UpdateTarget " +
"throws away any target BaseAI.IsEnemy calls a non-enemy, so a truced mob could " +
"not fight back even after being struck - it stood still, or fled because it " +
"was hurt and had no enemy it was allowed to have. The grudge is per attacker " +
"and per creature, on whichever machine runs that creature's AI. 0 restores the " +
"was hurt and had no enemy it was allowed to have. Each creature holds one " +
"grudge, against the last player who hit it, and keeps it when another player's " +
"game takes over running that creature. 0 restores the " +
"old absolute truce.",
new AcceptableValueRange<float>(0f, 600f)));

View file

@ -774,6 +774,7 @@ namespace RacesOfValheim
Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask);
FormMelee.LogSwing(FormLabel, hits.Length);
System.Collections.Generic.HashSet<GameObject> hitObjects = new System.Collections.Generic.HashSet<GameObject>();
bool hitCreature = false;
foreach (Collider hit in hits)
{
@ -823,10 +824,13 @@ namespace RacesOfValheim
FormMelee.LogHit(FormLabel, target, totalDamage);
target.Damage(hitData);
FormMelee.GrantAdrenaline(target);
if (target is Character) hitCreature = true;
}
}
}
}
if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
}
}
@ -1067,6 +1071,7 @@ namespace RacesOfValheim
Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask);
FormMelee.LogSwing(FormLabel, hits.Length);
System.Collections.Generic.HashSet<GameObject> hitObjects = new System.Collections.Generic.HashSet<GameObject>();
bool hitCreature = false;
foreach (Collider hit in hits)
{
@ -1106,6 +1111,7 @@ namespace RacesOfValheim
FormMelee.LogHit(FormLabel, target, totalDamage);
target.Damage(hitData);
FormMelee.GrantAdrenaline(target, 0.2f); // one 0.2s tick: a full hit per second of breath
if (target is Character) hitCreature = true;
if (ZNetScene.instance != null)
{
@ -1115,6 +1121,8 @@ namespace RacesOfValheim
}
}
}
if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.ElementalMagic, 0.2f); // one 0.2s tick: a full swing's worth per second of breath
}
private IEnumerator ClawRoutine()
@ -1231,6 +1239,7 @@ namespace RacesOfValheim
Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask);
FormMelee.LogSwing(FormLabel, hits.Length);
System.Collections.Generic.HashSet<GameObject> hitObjects = new System.Collections.Generic.HashSet<GameObject>();
bool hitCreature = false;
foreach (Collider hit in hits)
{
@ -1280,10 +1289,13 @@ namespace RacesOfValheim
FormMelee.LogHit(FormLabel, target, totalDamage);
target.Damage(hitData);
FormMelee.GrantAdrenaline(target);
if (target is Character) hitCreature = true;
}
}
}
}
if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
}
}
@ -1446,6 +1458,7 @@ namespace RacesOfValheim
Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask);
FormMelee.LogSwing(FormLabel, hits.Length);
System.Collections.Generic.HashSet<GameObject> hitObjects = new System.Collections.Generic.HashSet<GameObject>();
bool hitCreature = false;
foreach (Collider hit in hits)
{
@ -1495,10 +1508,13 @@ namespace RacesOfValheim
FormMelee.LogHit(FormLabel, target, totalDamage);
target.Damage(hitData);
FormMelee.GrantAdrenaline(target);
if (target is Character) hitCreature = true;
}
}
}
}
if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
}
}
@ -1654,6 +1670,7 @@ namespace RacesOfValheim
Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask);
FormMelee.LogSwing(FormLabel, hits.Length);
System.Collections.Generic.HashSet<GameObject> hitObjects = new System.Collections.Generic.HashSet<GameObject>();
bool hitCreature = false;
foreach (Collider hit in hits)
{
@ -1703,10 +1720,13 @@ namespace RacesOfValheim
FormMelee.LogHit(FormLabel, target, totalDamage);
target.Damage(hitData);
FormMelee.GrantAdrenaline(target);
if (target is Character) hitCreature = true;
}
}
}
}
if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
}
private IEnumerator UlvJumpAttackRoutine()

View file

@ -368,6 +368,21 @@ namespace RacesOfValheim
player.AddAdrenaline(perHit * character.m_enemyAdrenalineMultiplier * scale);
}
/// <summary>
/// The skill experience vanilla gives for a weapon hit, which a hand-built hit never got.
/// Vanilla raises the skill inside Attack (once per swing that landed on a creature) and
/// inside Projectile.OnHit; Character.Damage never does, so a form that calls Damage
/// directly left its skill at whatever level the player brought in. Call it once per
/// swing or tick, after the loop, never once per target. amount lets a damage-over-time
/// tick pay a fraction of a swing.
/// </summary>
public static void RaiseSkill(Skills.SkillType skill, float amount = 1f)
{
Player player = Player.m_localPlayer;
if (player == null || amount <= 0f) return;
player.RaiseSkill(skill, amount);
}
/// <summary>
/// Charges a form attack's stamina the way vanilla charges a weapon's (Attack.GetAttackStamina):
/// the equipment modifier, status effects (meads, race passives), then up to a third off with

View file

@ -1,7 +1,7 @@
{
"name": "RacesOfValheim",
"description": "A Valheim mod that adds eleven custom playable races (Alfar, Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
"version_number": "1.6.8",
"version_number": "1.6.9",
"website_url": "",
"dependencies": [
"denikson-BepInExPack_Valheim-5.4.2333",

View file

@ -874,8 +874,8 @@ namespace RacesOfValheim
int foodDuration = Mathf.RoundToInt(TrentaConfig.FoodDurationMultiplier);
int purpleRainRadius = Mathf.RoundToInt(TrentaConfig.PurpleRainRadius);
int purpleRainHeal = Mathf.RoundToInt(TrentaConfig.PurpleRainHealAmount);
int purpleRainPoison = Mathf.RoundToInt(TrentaConfig.PurpleRainPoisonDamage);
int purpleRainHeal = Mathf.RoundToInt(TrentaConfig.PurpleRainHealFor(Player.m_localPlayer));
int purpleRainPoison = Mathf.RoundToInt(TrentaConfig.PurpleRainPoisonFor(Player.m_localPlayer));
int purpleRainCooldown = Mathf.RoundToInt(TrentaConfigManagement.PurpleRainCooldown.Value);
int purpleRainMuspellCooldown = Mathf.RoundToInt(TrentaConfigManagement.MuspellPurpleRainCooldown.Value);

View file

@ -25,11 +25,13 @@ namespace RacesOfValheim
/// which means everything downstream - acquiring, chasing, retaliating, giving up - is vanilla
/// behaviour rather than anything reimplemented here.
///
/// WHERE IT RUNS. On the client that owns the mob's AI, which is the only one whose UpdateTarget
/// matters and the only one that runs Character.ApplyDamage for it. BaseAI.OnDamaged is reached
/// through the character's damage callback on exactly that machine, so the record is made where
/// it will be read. Nothing is replicated and nothing needs to be: another client's copy of the
/// same mob is not the one deciding who it chases.
/// WHERE IT LIVES. On the creature's own ZDO: who it is angry at and until when, in network time.
/// The AI that reads it runs on whichever machine owns the creature, and that can change in the
/// middle of a fight (the owner walks off or logs out). A grudge kept in one machine's memory
/// went with it, and the new owner's copy of the creature made peace on its next UpdateTarget.
/// On the ZDO the new owner reads the same grudge. Only the owner writes it: a hit reaches the
/// owner through Character.Damage's RPC anyway, and kin owned elsewhere are told by an RPC of
/// our own (RpcName), so no client writes a ZDO it does not own.
///
/// Vanilla has its own version of this idea in BaseAI.SetAggravated, and it is not usable here:
/// it does nothing unless the prefab sets m_aggravatable, which only the dvergr and the seekers
@ -37,67 +39,96 @@ namespace RacesOfValheim
/// </summary>
public static class RaceGrudge
{
private struct Grudge
{
public ZDOID Attacker;
public float Until;
}
private const string RpcName = "RacesOfValheim_Grudge";
// One grudge per mob, against the last thing that hit it. A creature can only chase one
// target anyway, and if two players of the same race are both poking it, the one it wants
// is whoever hit it last.
private static readonly Dictionary<ZDOID, Grudge> grudges = new Dictionary<ZDOID, Grudge>();
private static float lastSweep = 0f;
// One grudge per creature, against the last player that hit it. A creature can only chase
// one target anyway, and if two players of the same race are both poking it, the one it
// wants is whoever hit it last.
private static readonly KeyValuePair<int, int> AttackerKey = ZDO.GetHashZDOID("RacesOfValheim_GrudgeAttacker");
private static readonly int UntilKey = "RacesOfValheim_GrudgeUntil".GetStableHashCode();
private static float Duration => FactionsConfig.GrudgeSeconds;
// Network time, the same on every machine, so an end time written by one owner means the
// same thing to the next. Milliseconds in a long: ZDO has no double.
private static long NowMs => ZNet.instance != null ? (long)(ZNet.instance.GetTimeSeconds() * 1000.0) : 0L;
private static ZDO ZdoOf(Character character)
{
if (character == null || ZDOMan.instance == null) return null;
ZDOID id = character.GetZDOID();
return id.IsNone() ? null : ZDOMan.instance.GetZDO(id);
}
/// <summary>
/// True while <paramref name="monster"/> is owed a hit by <paramref name="player"/>. Both
/// truce postfixes ask this first and leave IsEnemy alone when it answers yes.
/// truce postfixes ask this first and leave IsEnemy alone when it answers yes. Read on any
/// machine; it only matters on the owner's.
/// </summary>
public static bool Holds(Character monster, Character player)
{
if (monster == null || player == null) return false;
if (Duration <= 0f) return false;
if (!grudges.TryGetValue(monster.GetZDOID(), out Grudge grudge)) return false;
if (Time.time >= grudge.Until) return false;
ZDO zdo = ZdoOf(monster);
if (zdo == null) return false;
return grudge.Attacker == player.GetZDOID();
}
long until = zdo.GetLong(UntilKey, 0L);
if (until == 0L || NowMs >= until) return false;
public static void Remember(Character monster, Character attacker)
{
if (monster == null || attacker == null) return;
if (Duration <= 0f) return;
grudges[monster.GetZDOID()] = new Grudge
{
Attacker = attacker.GetZDOID(),
Until = Time.time + Duration
};
Sweep();
return zdo.GetZDOID(AttackerKey) == player.GetZDOID();
}
/// <summary>
/// Drops grudges nobody is owed any more. At most once per duration: a fight is a burst of
/// damage events and the list should not be walked on each one.
/// Writes the grudge on the creature's ZDO if this machine owns it, and otherwise asks the
/// owner to. Returns true when it was written here.
/// </summary>
private static void Sweep()
public static bool Remember(Character monster, Character attacker)
{
if (Time.time - lastSweep < Duration) return;
lastSweep = Time.time;
if (monster == null || attacker == null) return false;
if (Duration <= 0f) return false;
List<ZDOID> expired = null;
foreach (var entry in grudges)
ZNetView nview = monster.GetComponent<ZNetView>();
if (nview == null || !nview.IsValid()) return false;
if (!nview.IsOwner())
{
if (Time.time < entry.Value.Until) continue;
if (expired == null) expired = new List<ZDOID>();
expired.Add(entry.Key);
nview.InvokeRPC(RpcName, attacker.GetZDOID());
return false;
}
Write(nview.GetZDO(), attacker.GetZDOID());
return true;
}
private static void Write(ZDO zdo, ZDOID attacker)
{
zdo.Set(AttackerKey, attacker);
zdo.Set(UntilKey, NowMs + (long)(Duration * 1000f));
}
/// <summary>
/// Every creature can be told about a grudge by a machine that does not own it. ZNetView's
/// InvokeRPC routes to the owner, so the handler always runs where the ZDO may be written,
/// and the owner checks it is still the owner: ownership can move while the RPC travels.
/// </summary>
[HarmonyPatch(typeof(Character), "Awake")]
public static class Character_Awake_GrudgeRpc_Patch
{
public static void Postfix(Character __instance)
{
if (__instance.IsPlayer()) return;
ZNetView nview = __instance.GetComponent<ZNetView>();
if (nview == null || !nview.IsValid()) return;
nview.Register<ZDOID>(RpcName, (sender, attacker) =>
{
if (__instance == null || !nview.IsValid() || !nview.IsOwner()) return;
if (attacker.IsNone() || Duration <= 0f) return;
Write(nview.GetZDO(), attacker);
__instance.GetBaseAI()?.Alert();
});
}
if (expired == null) return;
foreach (ZDOID id in expired) grudges.Remove(id);
}
/// <summary>
@ -125,14 +156,62 @@ namespace RacesOfValheim
}
}
// How deep we are inside one of vanilla's hit filters (see StrikeScope). A counter rather
// than a bool because Projectile.OnHit calls DoAOE, and the inner exit must not end the
// outer scope.
private static int strikeDepth = 0;
/// <summary>
/// True while vanilla is deciding whether <paramref name="attacker"/>'s own weapon, arrow or
/// area hit lands. Both truce postfixes stand down for that question: the truce is about
/// who a creature attacks, never about whether the player is allowed to strike it.
/// </summary>
public static bool PlayerStrikes(Character attacker)
{
return strikeDepth > 0 && attacker != null && attacker.IsPlayer();
}
/// <summary>
/// THE PLAYER COULD NOT HIT THEIR OWN FACTION AT ALL. Valheim 1.0's hit filters (Attack's
/// melee and area swings, Projectile's direct hit, its AoE and its IsValidTarget, Aoe's
/// ShouldHit) ask BaseAI.IsEnemy(attacker, target) and skip the target when it answers false
/// and the attacker is a player without PvP on - vanilla's guard for tames. Our truce
/// answers false for every allied creature, so the blow passed through it, it took no
/// damage, BaseAI.OnDamaged never ran and no grudge was ever born. That is both reports at
/// once: "it will not allow me" to attack, and kin that never fight back, group grudge on or
/// off, because nobody was ever hit. With PvP on the filter let the hit through, which is
/// why it looked fine in some tests.
///
/// The scope is open only around those six methods, so everything else that asks IsEnemy
/// with the player first keeps the truce: the green health bar on allied creatures, sneaking
/// past them, the Aswid's aura leaving kin alone.
/// </summary>
[HarmonyPatch]
public static class StrikeScope
{
public static IEnumerable<System.Reflection.MethodBase> TargetMethods()
{
yield return AccessTools.Method(typeof(Attack), "DoMeleeAttack");
yield return AccessTools.Method(typeof(Attack), "DoAreaAttack");
yield return AccessTools.Method(typeof(Projectile), "DoAOE");
yield return AccessTools.Method(typeof(Projectile), "IsValidTarget");
yield return AccessTools.Method(typeof(Projectile), "OnHit");
yield return AccessTools.Method(typeof(Aoe), "ShouldHit");
}
public static void Prefix() => strikeDepth++;
// Finalizer rather than Postfix: the count has to come down even when the method
// throws, or every IsEnemy afterwards would ignore the truce.
public static void Finalizer() => strikeDepth--;
}
/// <summary>
/// Vanilla's Dvergr camp, for every faction ("Grudge spreads to kin", off by default): hit
/// a creature that is at peace with you and its kin around it take up the same grudge.
///
/// Only the creatures this machine runs the AI for are told, because a grudge is read where
/// the AI runs (see WHERE IT RUNS above). The creatures around the one that was hit are
/// nearly always simulated by the same client; one owned by another player's machine stays
/// at peace until it is hit itself.
/// Kin this machine owns are written here; kin owned by another player's machine are told
/// through RpcName, and their owner writes the grudge and alerts them.
/// </summary>
private static void SpreadToKin(Character monster, Player player)
{
@ -144,12 +223,10 @@ namespace RacesOfValheim
foreach (Character other in Character.GetAllCharacters())
{
if (other == null || other == monster || other.IsPlayer() || other.IsDead() || other.IsTamed()) continue;
if (!other.IsOwner()) continue;
if (Vector3.Distance(other.transform.position, center) > radius) continue;
if (!FactionHostilityPatch.IsAlliedMob(race, other.gameObject.name)) continue;
Remember(other, player);
other.GetBaseAI()?.Alert();
if (Remember(other, player)) other.GetBaseAI()?.Alert();
}
}
}

View file

@ -22,6 +22,9 @@ namespace RacesOfValheim
if (a == null || b == null) return;
// The player's own blow lands on kin too. See RaceGrudge.StrikeScope.
if (RaceGrudge.PlayerStrikes(a)) return;
Character playerCharacter = a.IsPlayer() ? a : (b.IsPlayer() ? b : null);
Character monster = a.IsPlayer() ? b : (b.IsPlayer() ? a : null);

View file

@ -16,7 +16,7 @@ namespace RacesOfValheim
{
public const string PluginGUID = "com.nandor.racesofvalheim";
public const string PluginName = "Races Of Valheim";
public const string PluginVersion = "1.6.8";
public const string PluginVersion = "1.6.9";
private readonly Harmony harmony = new Harmony(PluginGUID);

View file

@ -599,6 +599,7 @@ namespace RacesOfValheim
int layerMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle");
Collider[] hits = Physics.OverlapSphere(attackPoint, radius, layerMask);
System.Collections.Generic.HashSet<GameObject> hitObjects = new System.Collections.Generic.HashSet<GameObject>();
bool hitCreature = false;
foreach (Collider hit in hits)
{
@ -641,7 +642,10 @@ namespace RacesOfValheim
target.Damage(hitData);
FormMelee.GrantAdrenaline(target);
if (characterTarget != null) hitCreature = true;
}
if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
}
private void OnDestroy()

View file

@ -196,7 +196,14 @@ namespace RacesOfValheim
// The Trenta stands in its own rain and is healed by it too. It used to be left out, so
// a lone Trenta cast a heal that never touched anyone.
player.Heal(TrentaConfig.PurpleRainHealAmount, true);
float heal = TrentaConfig.PurpleRainHealFor(player);
float poison = TrentaConfig.PurpleRainPoisonFor(player);
player.Heal(heal, true);
// Blood Magic experience once per cast that reached someone besides the caster, the
// way a vanilla staff pays per cast: healing only yourself earns nothing, or the
// skill would level by casting into an empty field on cooldown.
bool reachedSomeone = false;
HashSet<Character> hit = new HashSet<Character>();
foreach (Collider collider in Physics.OverlapSphere(player.transform.position, TrentaConfig.PurpleRainRadius))
@ -209,16 +216,20 @@ namespace RacesOfValheim
if (BaseAI.IsEnemy(player, character))
{
HitData hitData = new HitData();
hitData.m_damage.m_poison = TrentaConfig.PurpleRainPoisonDamage;
hitData.m_damage.m_poison = poison;
hitData.m_skill = Skills.SkillType.BloodMagic;
hitData.SetAttacker(player);
hitData.m_dir = Vector3.zero;
character.Damage(hitData);
}
else
{
character.Heal(TrentaConfig.PurpleRainHealAmount, true);
character.Heal(heal, true);
}
reachedSomeone = true;
}
if (reachedSomeone) FormMelee.RaiseSkill(Skills.SkillType.BloodMagic);
}
/// <summary>

View file

@ -120,6 +120,16 @@ namespace RacesOfValheim
public static float PurpleRainRadius => TrentaConfigManagement.PurpleRainRadius.Value;
public static float PurpleRainHealAmount => TrentaConfigManagement.PurpleRainHealAmount.Value;
public static float PurpleRainPoisonDamage => TrentaConfigManagement.PurpleRainPoisonDamage.Value;
// The base figures plus the Blood Magic bonus, scaled linearly up to the full bonus at
// level 100 - the same shape as the Aswid's Vampiric Aura. The compendium reads these
// too, so its numbers follow the player's skill.
public static float PurpleRainHealFor(Player player) =>
PurpleRainHealAmount + BloodMagicFactor(player) * TrentaConfigManagement.PurpleRainBloodMagicHeal.Value;
public static float PurpleRainPoisonFor(Player player) =>
PurpleRainPoisonDamage + BloodMagicFactor(player) * TrentaConfigManagement.PurpleRainBloodMagicPoison.Value;
private static float BloodMagicFactor(Player player) =>
player != null ? player.GetSkillFactor(Skills.SkillType.BloodMagic) : 0f;
// A Poison-type hit; vanilla's own
// poison-on-hit handling takes over from
// there, same as SkeletonRace's fire aura

View file

@ -45,6 +45,8 @@ namespace RacesOfValheim
public static ConfigEntry<float> PurpleRainRadius;
public static ConfigEntry<float> PurpleRainHealAmount;
public static ConfigEntry<float> PurpleRainPoisonDamage;
public static ConfigEntry<float> PurpleRainBloodMagicHeal;
public static ConfigEntry<float> PurpleRainBloodMagicPoison;
// ─── Bonemass (tier 4+, passive) ──────────────────────────────────────
public static ConfigEntry<float> SwimStaminaRegen;
@ -116,6 +118,10 @@ namespace RacesOfValheim
new ConfigDescription("Flat heal applied to you and to every ally hit.", new AcceptableValueRange<float>(0f, 200f)));
PurpleRainPoisonDamage = config.Bind(purpleRain, "Enemy Poison Damage", 40f,
new ConfigDescription("Flat poison damage applied to every enemy hit.", new AcceptableValueRange<float>(0f, 200f)));
PurpleRainBloodMagicHeal = config.Bind(purpleRain, "Blood Magic Heal Bonus", 40f,
new ConfigDescription("Extra heal at 100 Blood Magic skill, added to Ally Heal Amount (scales linearly from 0).", new AcceptableValueRange<float>(0f, 200f)));
PurpleRainBloodMagicPoison = config.Bind(purpleRain, "Blood Magic Poison Bonus", 40f,
new ConfigDescription("Extra poison damage at 100 Blood Magic skill, added to Enemy Poison Damage (scales linearly from 0).", new AcceptableValueRange<float>(0f, 200f)));
const string bonemass = "Trenta - Bonemass";
SwimStaminaRegen = config.Bind(bonemass, "Swim Stamina Regen", 0.1f,

View file

@ -435,6 +435,7 @@ namespace RacesOfValheim
float totalDamage = baseDamage + unarmedSkillLevel;
HashSet<GameObject> hit = new HashSet<GameObject>();
bool hitCreature = false;
foreach (Collider collider in Physics.OverlapSphere(center, radius))
{
Character target = collider.GetComponentInParent<Character>();
@ -442,7 +443,12 @@ namespace RacesOfValheim
if (!BaseAI.IsEnemy(player, target)) continue;
DealDamage(player, target, totalDamage, HitData.DamageType.Blunt, Vector3.zero);
hitCreature = true;
}
// The spike projectile levels Unarmed through vanilla's Projectile.OnHit; the stomp
// calls Damage directly and has to raise the skill itself.
if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
}
/// <summary>