[Mod] Spriteguns (Image waypoint based guns) [spriteguns]

Post Reply
User avatar
sparky
Member
Posts: 154
Joined: Sun Oct 05, 2014 00:54
GitHub: Elkien3
IRC: ircSparky
In-game: sparky
Location: USA
Contact:

[Mod] Spriteguns (Image waypoint based guns) [spriteguns]

by sparky » Post

I know, another gun mod. But here we are. This one uses sprites (image waypoints) to draw the visuals.

Image

The main purpose of this mod is to allow the aimpoint to move around due to recoil. (Because setting the player's yaw/pitch dosn't work the best)
The result is you can make your players need to re-aim after every shot.

Readme.md

Code: Select all

: a mod for Minetest that adds guns using moving animated image_waypoints for visuals/aimpoints.
High Resolution Texture pack is available at https://elkien3.com/hiresguns.zip, do '/spritegunscale .2' ingame to fix scaling issue.

Using the guns:
	There are two main ways guns are loaded: through magazines or by inserting the ammunition directly into the firearm.

	Colt Army: 9mm cartridges
	Pardini: Pardini Magazine (9mm)
	Remington 870: 12 gauge shells
	Thompson: Thompson Magazine (9mm)
	Mini14: Mini14 Magazine: (7.62mm)
	CZ527: Cz527 Magazine (7.62mm)

	Loading a magazine: take the appropriate magazine for the gun you want to load, and put it in the crafting grid with the appropriate ammunition. Complete the craft and the ammunition will be loaded into the magazine. Put the magazine into the craft grid by itself and then craft to empty it.

	To load a firearm, make sure you have the appropriate ammunition or magazine in your inventory, Then press the 'zoom' button (default keybind is Z) to load.
	To unload, press the 'drop' button once. (default keybind is q)
	Pressing q while already unloading will drop the firearm.
	Empty magazines must be unloaded before a fresh magazine can be loaded.

	Bullets always go where the gun is pointed. (shocker) This is called the "aimpoint," But the aimpoint is not always in the middle of your screen.
	Right click to aim the weapon, you movement speed will be slower when aiming. Right click again to go back to hip fire.
	When you walk, the gun will move around a lot, and when standing still, it won't move as much, but will still move slightly over time.
	The idle aim drift will be faster if you are injured (medical mod), gassed (special grenade, not included), or are low on stamina.
	Aiming while hipfiring is a bit tricky, if you move your camera left, the point your gun is aiming at will move left, relative to the middle of your screen. this goes for all directions.
	When firing, the aimpoint will recoil upwards and sideways temporarily, then move back down to rest on a new position. Accurate fire will have to be aimed after every shot.
	Headshots do 50% more damage than body shots.
	Bullets will do less damage if they have to travel farther, depending on the weapon you are using.
	The Remington 870 shotgun has the lowest range, CZ527 has the highest.
	You can look at https://github.com/Elkien3/spriteguns/guns.lua for all gun stats.
	
Creating your own guns:
	It is not terribly hard to create your own guns, hardest part is making models, animating them, and rendering them.
	
	I will start with how they are registered in code, then move on to how to create the image assets for them.
	
	Registering guns:
	
		Below is a full registration for the Remington 870 shotgun. I've added description to all the settings.
		All you need to do is create a new mod, add spriteguns as a dependency, put this code in, then edit as needed.
		
		spriteguns.register_gun("spriteguns:remington870",{--The itemname of your gun for backend. Must use regular minetest itemstring conventions.
			description = "Remington 870 Shotgun",--The description for the item.
			inventory_image = "rem870_inv.png",--The image that represents the gun in your inventory
			zoomfov = 60,--The fov the player changes to when zooming/aiming. lower=more zoomed. default fov is 75
			scale = 7.5,--how big the image for the gun appears on the screen, suggested to leave this as is for 320x180 images.
			range = 100,--how far until the damage from the bullet goes to 0, at 1/2 range it will do 3/4 damage, 3/4 will do 1/2, etc.
			fire_sound = "rem870_fire",--the sound that plays when it is fired.
			fire_gain = 10,--volume of fire sound
			fire_sound_distant = "distant_hical",--the sound that carries farther than fire_sound
			size = 8,--how many bullets fit in the gun at a time. if it is a magazine fed gun you must make sure this is the same as the magazine capacity.
			magazine = false,--set to true if gun is magazine fed.
			loadtype = "manual",--"auto", "semi", and "manual". self explanatory, manual has an animation that must finish between slots.
			ammo = "spriteguns:bullet_12",--what kind of ammunition it uses. if it is a magazine fed gun, use the magazine itemstring.
			firetime = .2,--minimum time between shots.
			offsetrecoil = 120,--when firing, the gun will recoil more or less depending on this value
			targetrecoil = 80,--after firing, the aimpoint will rest closer or farther from the original location depending on this value.
			damage = 3,--how much damage each bullet/pellet does.
			maxdev = .16,--how far the gun can travel from the center before it is stopped.
			maxzoomdev = .06,--same as maxdev, but applies only when zoomed in.
			pellets = 12,--how many pellets/projectiles are sent out each time the gun is fired.
			space = 3,--if invspace is enabled, the gun will reduce your inventory slots by this amount.
			unload_amount = 1,--how many bullets are unloaded each animation cycle.
			concealed = false,--if true, gun will appear on your back and must be placed in the first hotbar slot to be used.
			spread = 35,--how far from the aimpoint the bullets will spread.
			textures = {--table containing all the names of the images for the sprite/image waypoint.
				prefix = "rem870_",--the prefix put in front of all the rest of the texture names. (eg: rem870_hipidle.png)
				hipidle = "hipidle.png",--for when gun is idle and not aimed
				hipidlenomag = "hipidle.png",--for when gun is idle, not aimed, and has no magazine in it.
				hipfire = "hipfireflash.png",--for when gun is firing but not aimed.
				hippostfire = "hipfire.png",--shows after firing but before gun can be fired again.
				aimidle = "aimidle.png",--same as hip, just when aiming with rightclick
				aimidlenomag = "aimidle.png",
				aimfire = "aimfireflash.png",
				aimpostfire = "aimfire.png",
				load = {--for manual guns: the animation that plays between shots.
					length = .75,--the time in seconds the full animation takes to play
					sounds = {nil, "rem870_rackslide"},--sounds to be played at each frame
					frames = {"hipidle.png", "load.png"},--images to be shown at each frame
					zoomframes = {"aimidle.png", "loadzoom.png"}--images to be shows when aiming
				},
				reload = {--the animation for loading bullets/magazines
					length = 1.15,
					speed = .75,
					loopstart = 2,--for repetitive loading animations: which frame to loop back to when it reaches loopend If this is not defined then gun will load fully after this animation.
					loopend = 5,--for repetitive loading animations: which frame after which to go to loopstart
					sounds = {nil, nil, "rem870_loadshell"},
					frames = {"reload1.png", "reload2.png", "reload2.png", "reload3.png", "reload3.png", "reload4.png"}
				},
				unload = {--the animation for unloading bullets/magazines
					length = .5,
					sounds = {nil, "rem870_rackslide"},
					frames = {"hipidle.png", "load.png"},
				},
			},
		})
		
	Creating image assets for your guns:
		It's fairly straightforward to make image assests for your gun.
		The method I used was importing models from magicavox to Blender and doing simple image renders.
		The exact process will differ depending on what software you are using.
		Unless you are sure of what you're doing, it's recommended to make your textures with these specifications:
			320x180 for low res (default, good for performance and dosn't take much time to send clients on a server)
			1920x1080 for high res (only recommended for higher end PCs, release as seperate texture pack, users can use "/spritegunscale .2" to fix the scaling issue.
			camera field of view for renders should be 120 degrees or 9.2mm
		If you use different size textures for your guns you will probably want to tweak the "scale" property in the gun registration until you get the desired outcome.
		For low resolution images may be blurry and require manual changes in an image editor, especially for aimidle. (It is hard to aim when your sights are blurry.)
		For continuity, you may want to use the same arms in your guns as were using in the ones already provided in the mod.
		Technically there is nothing stopping you from using images taken with a real camera, nor from creating the images entirely from an image editor, but it's just probably not as easy.
		
	If you create more guns I would love to see them! I will happily link them for people to find.
	I might allow custom fire logic in the future. (eg: to allow non-raycast projectiles) but for now I don't have that exposed in the api.
	If you have any feature requests or found some bugs please let me know.
Download https://github.com/Elkien3/spriteguns/a ... s/main.zip
Browse the Code https://github.com/Elkien3/spriteguns
High Resolution Texture Pack https://github.com/Elkien3/spriteguns/r ... esguns.zip
License various contributors, mostly CC-BY-SA 3.0, see license.txt for details https://github.com/Elkien3/spriteguns/b ... icense.txt

Please share any expansion packs you make, I'd love to try them :D
An easy way to try them out is to go to a server of mine called "Coalition Warfare" that is up currently.
Last edited by sparky on Tue Jan 31, 2023 18:57, edited 2 times in total.

User avatar
the_raven_262
Member
Posts: 343
Joined: Mon Sep 22, 2014 09:30
GitHub: theraven262
IRC: [Discord unfortunately] corvus262

Re: [Mod] Spriteguns (Image waypoint based guns) [spriteguns]

by the_raven_262 » Post

The audiovisual feedback on the guns is insane, I love it.

I can't access your website in order to download the highres sprites. So keep in mind that I've not yet seen those :P (EDIT): I got the highres guns, but I think I prefer the pixelated ones. The low resolution kinda makes the limitation of not being able to draw them in a high framerate when turning acceptable. (/EDIT)

The animations of the guns are, as I said, really good and well synced with the sound effects.
The movement of the guns when the player turns around is weird but feels like an intentional artistic choice, like a stop-motion animation. I think that the low resolution of the graphics really contributes to that effect.

I haven't yet been able to damage any entities using the guns, but since decals are left on the surfaces that I hit I'm going to say that the guns work.

Since you're using Blender, I believe that the blurriness on the low-res sprites is the result of a pixel filter being over 1.0 or so. When rendering pixelart (if you can still call it that in this context) I lower the pixel filter to lowest possible, this removes blurriness but makes the image noisier. Or sharper depending on what you're doing.
The setting is in: Render Properties>Film>Filter Size

If you're rendering with Cycles cause reasons, what I did was lower the samples to 1 and disable denoising. That makes the result look especially crispy. That approach doesn't really work with all the ray-tracing features that well though, but I guess you could find uses for it. Oh yeah, you get actual shadows. Thats what you can use it for.

If you want to keep some blurriness but not the alpha channel blurriness, you can clamp alpha in compositing. Just enable compositing nodes, and add a greater than (Math) node onto the alpha channel to clamp it.
Last edited by the_raven_262 on Thu Feb 02, 2023 21:07, edited 1 time in total.

User avatar
sparky
Member
Posts: 154
Joined: Sun Oct 05, 2014 00:54
GitHub: Elkien3
IRC: ircSparky
In-game: sparky
Location: USA
Contact:

Re: [Mod] Spriteguns (Image waypoint based guns) [spriteguns]

by sparky » Post

Glad you like it!

hmm, I probably should add a way to detect a wide variety of mobs, at the moment they are only added manually in the mod. https://github.com/Elkien3/spriteguns/b ... it.lua#L10

I think the blurriness is just due to being 320x180, though in the high res images I probably forgot/failed to fix the texture blurryness for the arms.

The movement of the gun when turning can only be as smooth as the server step, so it's kind of a technical reason. but it dosn't look terrible. there's actually a setting to make it do every other step, because some players were having issues with the update packets piling faster than their internet could handle. "/spritegunskipstep true/false"

I just used blender internal renderer because that's what I know xP

edit: I've just updated the high resolution texture pack that should work.

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests