Gunworks
A library for guns and artillery. It adds nothing by itself, other mods build their weapons on it, like Maxim Gun.Gunworks
A library for guns and artillery in Valheim. It adds nothing by itself, other mods build their weapons on it. The first one is Maxim Gun.
Install it on every player and on the server. A mod manager does it for you when you install a gun that needs it.
Every gun on it gets the same things: you build it with the hammer and pull it like a cart, rounds fly with gravity and hit what is there when they arrive, the gun heats up, burns your hands and jams, and you load ammo at a slot. A server sends its settings to every player.
A round breaks only your own buildings, or every building when you have PvP on. A server can change that in BepInEx/config/vladasz.gunworks.cfg:
BreakAllBuildings, default false. true: rounds break every building
For modders:
Reference Gunworks.dll, add [BepInDependency("vladasz.gunworks")] to your plugin and register your gun once in Awake:
IModHost host = new FolderHost("mygun", Logger, Path.GetDirectoryName(Info.Location));
Guns.Register(host, new MountedGun
{
Prefab = "mygun",
Keys = "mygun",
Name = "My gun",
Icon = "mygun",
Cost = () => "Iron:20,FineWood:10",
Build = b => { /* place the parts, set b.Barrel, b.Muzzle, b.Seat */ },
Carriage = new CarriageSpec { /* the wheels and the trail */ },
Fire = new FireSpec { RoundsPerMinute = () => 600f },
Round = new RoundSpec { Damage = () => 20f, Speed = 300f },
Heat = new HeatSpec(),
Feed = new FeedSpec { Item = new AmmoSpec { /* the ammo item */ } },
});
Your meshes, icons and sounds lie next to your dll and FolderHost finds them. A model made in Unity comes from an asset bundle with Files.Bundle, and GunBuilder.FromPrefab finds its parts by the names swivel, barrel, muzzle, seat, grips, slot and handle.
Gunworks does not need Jotunn. A Jotunn mod can still hand it a prefab.
If something does not work, tell me on Discord:
