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

@ -38,14 +38,41 @@ namespace RacesOfValheim
public const string JokeNonMortoZombie = "NonMortoZombie";
public const string JokeFantasma = "Fantasma";
// Every merchant in the mod buys/sells these regardless of what its own list
// carries - players kept running into benches that could not fence basic building
// mats. Folded into each ShopDefinition.Items below (WithDefaults) rather than
// handled in FactionMerchantSetup/FactionMerchantSellPanel, so both the buy and
// sell columns pick it up for free.
private static readonly List<CatalogEntry> DefaultItems = new List<CatalogEntry>
{
new CatalogEntry("Wood", 1),
new CatalogEntry("Stone", 1),
new CatalogEntry("FineWood", 5),
new CatalogEntry("Flint", 5),
new CatalogEntry("RoundLog", 10), // Core wood's internal prefab name
};
// Appends whichever DefaultItems aren't already named in items, explicit entries
// win so a shop can still special-price one of these if it ever needs to.
private static List<CatalogEntry> WithDefaults(List<CatalogEntry> items)
{
var combined = new List<CatalogEntry>(items);
foreach (CatalogEntry defaultEntry in DefaultItems)
{
if (!combined.Exists(e => e.PrefabName == defaultEntry.PrefabName))
{
combined.Add(defaultEntry);
}
}
return combined;
}
private static readonly ShopDefinition GreydwarfShop = new ShopDefinition
{
DisplayName = "Greydwarf",
JokeCategory = JokeLegnoFalegname,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("Wood", 1),
new CatalogEntry("Stone", 2),
new CatalogEntry("Resin", 5),
new CatalogEntry("GreydwarfEye", 5),
new CatalogEntry("Dandelion", 5),
@ -60,14 +87,14 @@ namespace RacesOfValheim
new CatalogEntry("TrophyGreydwarf", 20),
new CatalogEntry("TrophyGreydwarfBrute", 350),
new CatalogEntry("TrophyGreydwarfShaman", 350),
}
})
};
private static readonly ShopDefinition TrollShop = new ShopDefinition
{
DisplayName = "Troll",
JokeCategory = JokeTroll,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("TrollHide", 1),
new CatalogEntry("DeerHide", 2),
@ -79,14 +106,14 @@ namespace RacesOfValheim
new CatalogEntry("TrophyDeer", 20),
new CatalogEntry("TrophyBoar", 50),
new CatalogEntry("TrophyForestTroll", 1500),
}
})
};
private static readonly ShopDefinition FulingShop = new ShopDefinition
{
DisplayName = "Fuling",
JokeCategory = JokeGoblin,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("BlackMetalScrap", 1),
new CatalogEntry("LoxMeat", 1),
@ -114,7 +141,7 @@ namespace RacesOfValheim
new CatalogEntry("TrophyGrowth", 800), // Growth
new CatalogEntry("TrophyGoblinBrute", 1500),
new CatalogEntry("TrophySerpent", 1500),
}
})
};
// The Shaman alone stocks the Furling's crop line, so it needs a bench of its own - the four
@ -160,7 +187,7 @@ namespace RacesOfValheim
{
DisplayName = "Ulv",
JokeCategory = JokeLupoLicantropo,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("WolfFang", 5),
new CatalogEntry("WolfMeat", 5),
@ -171,52 +198,52 @@ namespace RacesOfValheim
new CatalogEntry("TrophyWolf", 350),
new CatalogEntry("TrophyUlv", 350),
new CatalogEntry("TrophyHatchling", 350), // Drake (internal id "Hatchling")
}
})
};
private static readonly ShopDefinition FenringShop = new ShopDefinition
{
DisplayName = "Fenring",
JokeCategory = JokeLupoLicantropo,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("WolfFang", 5),
new CatalogEntry("Ulvsblod", 500), // gates the Fenrir pack trough
new CatalogEntry("GreaterUlvsblod", 1500), // upgrades it: the fenrir themselves
new CatalogEntry("TrophyFenring", 350),
}
})
};
private static readonly ShopDefinition CultistShop = new ShopDefinition
{
DisplayName = "Cultist",
JokeCategory = JokeStrega,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("JuteRed", 2),
new CatalogEntry("GreaterFrostHeart", 1500), // the Skadi's bought reagent
new CatalogEntry("TrophyCultist", 1500),
}
})
};
private static readonly ShopDefinition DvergShop = new ShopDefinition
{
DisplayName = "Dverg",
JokeCategory = JokeNano,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("BlackMarble", 20),
new CatalogEntry("Softtissue", 250),
new CatalogEntry("Sap", 250), // extracted from Yggdrasil roots with Dvergr extractors
new CatalogEntry("TrophyDvergr", 1500),
}
})
};
private static readonly ShopDefinition DraugrShop = new ShopDefinition
{
DisplayName = "Draugr",
JokeCategory = JokeNonMortoZombie,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("Entrails", 2),
new CatalogEntry("Mushroom", 5),
@ -234,14 +261,14 @@ namespace RacesOfValheim
new CatalogEntry("TrophyLeech", 350), // Leech
new CatalogEntry("TrophyDraugrElite", 800),
new CatalogEntry("TrophyAbomination", 1500), // Abomination
}
})
};
private static readonly ShopDefinition SkeletonShop = new ShopDefinition
{
DisplayName = "Skeleton",
JokeCategory = JokeScheletro,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("BoneFragments", 1),
new CatalogEntry("Ooze", 2), // Blob/Oozer, folded in here: no talk-capable rig
@ -252,29 +279,29 @@ namespace RacesOfValheim
new CatalogEntry("SoulStone", 50), // binds a skeleton archer sentry
new CatalogEntry("CursedSkull", 500), // gates the Skeleton bone pile
new CatalogEntry("GreaterCursedSkull", 1500), // upgrades it: the rotten
}
})
};
private static readonly ShopDefinition GhostShop = new ShopDefinition
{
DisplayName = "Ghost",
JokeCategory = JokeFantasma,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("Ectoplasm", 2),
new CatalogEntry("TrophyGhost", 350),
}
})
};
private static readonly ShopDefinition WraithShop = new ShopDefinition
{
DisplayName = "Wraith",
JokeCategory = JokeFantasma,
Items = new List<CatalogEntry>
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("Chain", 5),
new CatalogEntry("TrophyWraith", 1500),
}
})
};
// Key = vanilla creature prefab name (internal id, not the wiki display name).

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();