VladasZ-Gunworks icon

Gunworks

A library for guns and artillery. It adds nothing by itself, other mods build their weapons on it, like Maxim Gun.

Last updated 14 hours ago
Total downloads 30
Total rating 0 
Categories Mods AI Generated Libraries Server-side Client-side
Dependency string VladasZ-Gunworks-0.1.0
Dependants 1 other package depends on this package

This mod requires the following mods to function

denikson-BepInExPack_Valheim-5.4.2351 icon
denikson-BepInExPack_Valheim

BepInEx pack for Valheim. Preconfigured with the correct entry point for mods and preferred defaults for the community.

Preferred version: 5.4.2351

README

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:

Discord