warvulture

This commit is contained in:
Ferdinando 2026-08-17 07:56:07 +02:00
commit 70bb263609
4 changed files with 100 additions and 38 deletions

View file

@ -15,7 +15,7 @@ namespace RacesOfValheim
{
public const string PluginGUID = "com.nandor.racesofvalheim";
public const string PluginName = "Races Of Valheim";
public const string PluginVersion = "1.4.3";
public const string PluginVersion = "1.4.4";
private readonly Harmony harmony = new Harmony(PluginGUID);
@ -80,6 +80,8 @@ namespace RacesOfValheim
Player player = Player.m_localPlayer;
if (player == null) return;
RemovePermanentRaceEquipment(player);
player.m_customData.Remove("Race");
player.m_customData.Remove("FenrirCurse_Active");
@ -118,6 +120,30 @@ namespace RacesOfValheim
}
}
/// <summary>
/// Strips whatever body-part weapon the outgoing race grew. The Aswid/Fenrir claws
/// (RaceClawSet) and the Sverm's Chitin Claws (SvermClawSlot) are quest items a player can
/// neither drop nor sell, so a race change has to take them off the same way it takes the
/// stats away - otherwise they sit in the inventory forever as leftovers from a race that
/// no longer applies. Checked by item identity rather than by the race being left, so it
/// also mops up anything a previous, already-abandoned race left behind.
/// </summary>
private static void RemovePermanentRaceEquipment(Player player)
{
Inventory inventory = player.GetInventory();
if (inventory == null) return;
// Copied out first: removing items while GetAllItems()'s own list is still being
// walked corrupts the enumeration.
foreach (ItemDrop.ItemData item in inventory.GetAllItems().ToArray())
{
if (RaceClawSet.SetOwning(item) == null && !SvermClawSlot.IsClaws(item)) continue;
if (player.IsItemEquiped(item)) player.UnequipItem(item, false);
inventory.RemoveItem(item);
}
}
private void CreateAllModAssets() {
PrefabManager.OnVanillaPrefabsAvailable -= CreateAllModAssets;
RaceMenuWard.Register();