[Mod] Firearms [0.2.0] [firearms]

User avatar
LemonLake
Member
Posts: 47
Joined: Sat May 10, 2014 18:27
GitHub: Lemmmy
IRC: Lemmmy
In-game: Lemmmy
Location: United Kingdom

Re: [Mod] Firearms [0.2.0] [firearms]

by LemonLake » Post

Fixes sound 'bug' (untested but I'm 100% certain it'll work)
Spoiler

Code: Select all


--[[
  || action.lua
  || Useful actions for weapons.
  ||
  || Part of the Firearms Modpack for Minetest.
  || Copyright (C) 2013 Diego Martínez <kaeza>
  || See `LICENSE.txt' for details.
--]]

local random = math.random

--[[
  | shoot
  |
  | Shoots the current weapon, using the ammo for the currently
  | selected slot.
--]]
firearms.action.shoot = {
	description = "Shoot",
	func = function(player, player_info, weapon_info)
		local ammo_info
		if weapon_info then
			player_info.ammo = player_info.ammo_info or { }
			ammo_info = (player_info.ammo_info and
				player_info.ammo_info[player_info.current_weapon.name]
			)
		end
		-- No ammo left in magazine; must reload.
		if (not ammo_info) or (ammo_info.count == 0) then
			if weapon_info.sounds.empty then
				minetest.sound_play(weapon_info.sounds.empty)
			end
			return
		end
		if player_info.shoot_cooldown <= 0 then
			local player_pos = player:getpos()
			local player_dir = player:get_look_dir()
			if weapon_info.sounds.shoot then
				minetest.sound_play(weapon_info.sounds.shoot)
			end
			-- TODO: Calc this properly.
			local muzzle_pos = { x=player_pos.x, y=player_pos.y, z=player_pos.z, } 
			local spread = weapon_info.spread or 10
			local yaw = player:get_look_yaw()
			ammo_info.count = ammo_info.count - 1
			muzzle_pos.y = muzzle_pos.y + 1.45
			muzzle_pos.x = muzzle_pos.x + (math.sin(yaw) / 2)
			muzzle_pos.z = muzzle_pos.z - (math.cos(yaw) / 2)
			if firearms.hud then
				firearms.hud.update_ammo_count(player,
				  player_info,
				  ammo_info.count
				)
			end
			player_info.shoot_cooldown = (weapon_info.shoot_cooldown or 1)
			player_pos.y = player_pos.y + 1.625
			local pellets = (ammo_info.item_def.firearms.pellets or 1)
			local damage = (ammo_info.item_def.firearms.damage or 0)
			local player_name = player:get_player_name()
			for n = 1, pellets do
				local bullet_dir = {
					x = player_dir.x + (random(-spread, spread) / 1000),
					y = player_dir.y + (random(-spread, spread) / 1000),
					z = player_dir.z + (random(-spread, spread) / 1000),
				}
				local ent = pureluaentity.add(player_pos, "firearms:bullet")
				ent.player = player
				ent.player_name = player_name
				ent.player_info = player_info
				ent.ammo_def = ammo_info.item_def
				ent.damage = damage / pellets
				ent.object:setvelocity({
					x = bullet_dir.x * 20,
					y = bullet_dir.y * 20,
					z = bullet_dir.z * 20,
				})
				local v = random(100, 150)
				local bullet_vel = {
					x = bullet_dir.x * v,
					y = bullet_dir.y * v,
					z = bullet_dir.z * v,
				}
				ent.life = (weapon_info.range or 10) / 20
				minetest.add_particle(
					muzzle_pos,         -- pos
					bullet_vel, -- velocity
					{x=0, y=0, z=0},    -- acceleration
					0.5,                -- expirationtime
					2,                  -- size
					false,              -- collisiondetection
					"firearms_bullet.png", -- texture
					player:get_player_name()
				)
			end
		end
	end,
}

--[[
  | reload
  |
  | Reloads the current weapon, using the ammo for the currently
  | selected slot.
--]]
firearms.action.reload = {
	description = "Reload",
	func = function(player, player_info, weapon_info)
		if weapon_info then
			local ammo_info = (player_info.ammo_info
			              and player_info.ammo_info[player_info.current_weapon.name])
			-- TODO: Add support for more than one slot.
			local clipsize = (weapon_info.slots
			                  and weapon_info.slots[1]
			                  and weapon_info.slots[1].clipsize)
			if not clipsize then
				firearms.warning(("clipsize not defined for %s; cannot reload"):format(
				                  player_info.current_weapon.name
				                ))
				return
			end
			if not ammo_info then
				local item_def = firearms.ammo.registered[weapon_info.slots[1].ammo]
				if not item_def then
					firearms.warning(("bullet type %s is not registered"):format(
						weapon_info.slots[1].ammo
					))
					return
				end
				ammo_info = {
					count = 0,
					item_def = item_def,
				}
				player_info.ammo_info = player_info.ammo_info or { }
				player_info.ammo_info[player_info.current_weapon.name] = ammo_info
			end
			if ammo_info.count < clipsize then
				local inv = player:get_inventory()
				local count = firearms.count_items(inv, "main", ammo_info.item_def.name)
				if count > 0 then
					player_info.shoot_cooldown = weapon_info.reload_time or 3
					if weapon_info.sounds.reload then
						minetest.sound_play(weapon_info.sounds.reload)
					end
					local needed = math.min(clipsize - ammo_info.count, count)
					player_info.ammo_info = player_info.ammo_info or { }
					player_info.ammo_info[player_info.current_weapon.name] =
					  player_info.ammo_info[player_info.current_weapon.name] or
					  ammo_info
					ammo_info.count = ammo_info.count + needed
					local stack = ItemStack({
						name = ammo_info.item_def.name,
						count = needed,
					})
					inv:remove_item("main", stack)
					if firearms.hud then
						firearms.hud.update_ammo_count(player,
						  player_info,
						  ammo_info.count
						)
					end
				end
			end
		end
	end,
}

function set_scope(player, player_info, weapon_info, flag)
	if weapon_info and flag then
		firearms.hud.set_player_overlay(player, weapon_info.hud.overlay)
		firearms.set_player_fov(player, weapon_info.zoomed_fov or -100)
	else
		firearms.set_player_fov(player, weapon_info and weapon_info.fov or -100)
		firearms.hud.set_player_overlay(player, nil)
	end
	player_info.zoomed = flag
end

--[[
  | toggle_scope
  |
  | Toggles on or off telescopic sights, and adjusts player
  | FOV accordingly (if supported).
--]]
firearms.action.toggle_scope = {
	description = "Toggle Scope",
	func = function(player, player_info, weapon_info)
		set_scope(player, player_info, weapon_info, not player_info.zoomed)
	end,
}

firearms.event.register("weapon_change", function(player, player_info, weapon_info)
	set_scope(player, player_info, weapon_info, false)
end)

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: [Mod] Firearms [0.2.0] [firearms]

by kaeza » Post

Update:
  • Added LemonLake's patch to sound bugs.
  • Added `enable_crafting' to enable/disable crafting of weapons. Useful if you want to use vending machines or other means for players to get guns.
  • Removed outline from hands in wield textures.
  • Fixed some bugs with HUD and added a nice background that shows ammo type.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: [Mod] Firearms [0.2.0] [firearms]

by kaeza » Post

Yet another update. This time added recipes for the bullets. It supports the tnt mod (for gunpowder) or provides its own. Have fun :)
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

User avatar
stormchaser3000
Member
Posts: 422
Joined: Sun Oct 06, 2013 21:02
GitHub: stormchaser3000

Re: [Mod] Firearms [0.2.0] [firearms]

by stormchaser3000 » Post

um

Code: Select all

14:46:34: ERROR[main]: ServerError: ...er3000/.minetest/mods/firearms/firearmslib/explosion.lua:39: attempt to index local 'bulletdef' (a nil value)
14:46:34: ERROR[main]: stack traceback:
14:46:34: ERROR[main]: 	...er3000/.minetest/mods/firearms/firearmslib/explosion.lua:39: in function 'explosion'
14:46:34: ERROR[main]: 	...3000/.minetest/mods/firearms/firearmslib/firearmslib.lua:393: in function 'on_destroy'
14:46:34: ERROR[main]: 	...3000/.minetest/mods/firearms/firearmslib/firearmslib.lua:310: in function '_destroy'
14:46:34: ERROR[main]: 	...3000/.minetest/mods/firearms/firearmslib/firearmslib.lua:362: in function <...3000/.minetest/mods/firearms/firearmslib/firearmslib.lua:316>

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: [Mod] Firearms [0.2.0] [firearms]

by kaeza » Post

The old version is not supported anymore. Please update to the new version or get rid of the `firearms_destructive' mod.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

awesomess3
New member
Posts: 1
Joined: Tue Jul 08, 2014 00:05

Re: [Mod] Firearms [0.2.0] [firearms]

by awesomess3 » Post

hello!

It would be super cool if the firearms could be used against simple mobs, including sheep, rats, Dirt Monster, Stone Monster, Sand Monster, Oerkki, & Dungeon monster (viewtopic.php?f=11&t=3063 [Mod] Simple Mobs [mobs]). I don't care if they don't drop anything when shot, but that the firearms do damage and destroy them.

I would help with coding but I just don't have what it takes.

Jonybravo
New member
Posts: 1
Joined: Tue Aug 19, 2014 14:42
GitHub: Jonybravo
IRC: Jonybravo
Location: 123 street

Re: [Mod] Firearms [0.2.0] [firearms]

by Jonybravo » Post

I was playing around with the damage system and it looks like the mobs from the animal mod all die with 1 hit, however they dont drop anything.
Im not sure how much damage they do in a PvP battle, Ill test that out later.

bbmario
New member
Posts: 6
Joined: Mon Oct 27, 2014 03:12

Re: [Mod] Firearms [0.2.0] [firearms]

by bbmario » Post

How can we customize the weapon models?

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: [Mod] Firearms [0.2.0] [firearms]

by kaeza » Post

bbmario wrote:How can we customize the weapon models?
Currently, the weapon models are extruded images as generated by the engine. Edit the textures (in firearms_guns/textures/ directory). You will recognize which ones are the "wield view models" (the ones you want to edit) by the fact that they have the hand visible.

Please do note, also to other users: I'm currently working on providing proper 3D models for weapons (optional), but due to a bug/misfeature of the engine, these get "cut off". See Issue #1770 for more info, and an early preview of the models.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

User avatar
crazyginger72
Member
Posts: 69
Joined: Wed Jan 01, 2014 07:57
GitHub: crazyginger72
IRC: cg72
In-game: crazyginger72
Location: gone to lunch

Re: [Mod] Firearms [0.2.0] [firearms]

by crazyginger72 » Post

how about a fixed posistion howitzer ;)

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: [Mod] Firearms [0.2.0] [firearms]

by kaeza » Post

Update!

This is an experimental feature for those who have a fairly recent git version of Minetest:

Image

How to use:
  • ZIP file can be downloaded here.
  • Git users must pull the `meshwield` branch:

    Code: Select all

    git clone https://github.com/kaeza/mt-firearms.git
    cd mt-firearms
    git checkout -b meshwield
    git pull origin meshwield
    
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: [Mod] Firearms [0.2.0] [firearms]

by Nathan.S » Post

This is sick, in the best way possible.

Great work.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
crazyginger72
Member
Posts: 69
Joined: Wed Jan 01, 2014 07:57
GitHub: crazyginger72
IRC: cg72
In-game: crazyginger72
Location: gone to lunch

Re: [Mod] Firearms [0.2.0] [firearms]

by crazyginger72 » Post

kaeza, this is why a f__king love you <3

User avatar
philipbenr
Member
Posts: 1897
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi
Location: United States

Re: [Mod] Firearms [0.2.0] [firearms]

by philipbenr » Post

@Kaeza: does this hurt mobs? I kinda don't want to search for the answer (too tired)

Offtopic: Love your first post:
kaeza wrote:Q: This mod sucks!
A: That is not a question.

Q: <div>How do you piss a web developer?</span>
A: "like this
;) Both gave me a laugh.

User avatar
the_rouge_pilot
Member
Posts: 10
Joined: Sat May 03, 2014 13:47
In-game: vfd

Re: [Mod] Firearms [0.2.0] [firearms]

by the_rouge_pilot » Post

I have a couple of suggestions, and a question.

- Iron sights for guns. I.E. If I right click with something other than a sniper, I'm now aiming down a set of iron sights.

- A Revolver with more damage than the pistol, but lower accuracy and capacity.

- Grenades that damage people, but not land. They should be thrown as items with a 5 second fuse, and be able to be thrown back.

Also, is there a way to give a gun infinite ammunition in the magazine?
OA | >>>>----------------> | BSA My Stuff: Wakefield, Ammo Can.

User avatar
LazerRay
Member
Posts: 147
Joined: Sun Jul 27, 2014 01:32
GitHub: LazerRay

Re: [Mod] Firearms [0.2.0] [firearms]

by LazerRay » Post

Ran into two minor bugs with this mod, the NVG overlay is too bright (even in dark places) making it extremely difficult to see, and the pistol doesn't always fire when used (the other guns work every time).

Soudon
Member
Posts: 167
Joined: Wed Apr 08, 2015 17:14
In-game: Soudon

Re: [Mod] Firearms [0.2.0] [firearms]

by Soudon » Post

I'm having a hard time crafting the guns, I can craft bullets no problem, but when I try to craft the gun itself it just does not work.

fhatking
New member
Posts: 2
Joined: Sun Apr 12, 2015 13:35
GitHub: fhatking
In-game: fhatking

Re: [Mod] Firearms [0.2.0] [firearms]

by fhatking » Post

your mod is not working!! -_-

Soudon
Member
Posts: 167
Joined: Wed Apr 08, 2015 17:14
In-game: Soudon

Re: [Mod] Firearms [0.2.0] [firearms]

by Soudon » Post

Actually it was working the recipes I was using were for another mod even though they were supposed to be for this one. I found another list and those work just fine.

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: [Mod] Firearms [0.2.0] [firearms]

by kaeza » Post

First of all, sorry for taking so long to answer.
philipbenr wrote:@Kaeza: does this hurt mobs? I kinda don't want to search for the answer (too tired)
It should work, but I'm not very sure if the collision box detection is 100% reliable in all cases.
the_rouge_pilot wrote:I have a couple of suggestions, and a question.

- Iron sights for guns. I.E. If I right click with something other than a sniper, I'm now aiming down a set of iron sights.

- A Revolver with more damage than the pistol, but lower accuracy and capacity.

- Grenades that damage people, but not land. They should be thrown as items with a 5 second fuse, and be able to be thrown back.

Also, is there a way to give a gun infinite ammunition in the magazine?
Iron sights are doable using the same method that is used for the rifle scope. The revolver is a nice idea. I've already thought about adding a Colt Python lookalike.

Expect something soon.
LazerRay wrote:Ran into two minor bugs with this mod, the NVG overlay is too bright (even in dark places) making it extremely difficult to see, and the pistol doesn't always fire when used (the other guns work every time).
The NVG overlay is the best I could do that moderately makes the player able to see in completely dark places. Making it darker would remove this ability.

The weapons don't use the normal mechanisms to detect player input, so you must hold down the left mouse button, not click repeatedly. Otherwise it may miss the clicks. Not sure if this is what you mean.
fhatking wrote:your mod is not working!! -_-
If it works for (almost) everyone else, it means it is an user error. Since I can't read your mind (I tried it already with no luck), I'll have to ask: What do you mean by "not working"? Does it show an error message? The guns don't shoot? The guns don't damage players/mobs? Something else?
Soudon wrote:Actually it was working the recipes I was using were for another mod even though they were supposed to be for this one. I found another list and those work just fine.
There are two versions of this mod. Maybe you tried to use the old one. If something is confusing in the first post, on the wiki, or anywhere else, tell me and I'll try to clarify it :)

By the way, the old one is left in place because some people liked the old explosive weapons (grenade launcher and bazooka), but I dropped support for it. I'll try to add some explosives (as requested by the_rouge_pilot above) in some future version.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

dannyplaysminetest
Member
Posts: 37
Joined: Sun Jun 28, 2015 19:20
In-game: Danny

Re: [Mod] Firearms [0.2.0] [firearms]

by dannyplaysminetest » Post

Thanks this Mod goes perfectly hand in hand with the army stuff Mod ^_^

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [Mod] Firearms [0.2.0] [firearms]

by rubenwardy » Post

Attempting to run on my VPS server running capturetheflag. For some reason it runs fine on my computer - maybe I'm missing some dependency? Latest git on both.

Code: Select all

[pureluaentity] Loading DB...
[pureluaentity] Loading DB...
2015-07-14 05:28:14: ERROR[main]: ========== ERROR FROM LUA ===========
2015-07-14 05:28:14: ERROR[main]: Failed to load and run script from 
2015-07-14 05:28:14: ERROR[main]: /home/ruben/minetest/bin/../mods/mt-firearms/firearmslib/init.lua:
2015-07-14 05:28:14: ERROR[main]: bad argument #2 to '?' (string expected, got function)
2015-07-14 05:28:14: ERROR[main]: stack traceback:
2015-07-14 05:28:14: ERROR[main]: 	[C]: ?
2015-07-14 05:28:14: ERROR[main]: 	[C]: in function 'open'
2015-07-14 05:28:14: ERROR[main]: 	...in/../mods/mt-firearms/firearmslib/pureluaentity.lua:149: in function 'load'
2015-07-14 05:28:14: ERROR[main]: 	...in/../mods/mt-firearms/firearmslib/pureluaentity.lua:190: in main chunk
2015-07-14 05:28:14: ERROR[main]: 	[C]: in function 'dofile'
2015-07-14 05:28:14: ERROR[main]: 	...inetest/bin/../mods/mt-firearms/firearmslib/init.lua:21: in main chunk
2015-07-14 05:28:14: ERROR[main]: ======= END OF ERROR FROM LUA ========
2015-07-14 05:28:14: ERROR[main]: Server: Failed to load and run /home/ruben/minetest/bin/../mods/mt-firearms/firearmslib/init.lua
2015-07-14 05:28:14: ERROR[main]: ERROR: An unhandled exception occurred: ModError: Failed to load and run /home/ruben/minetest/bin/../mods/mt-firearms/firearmslib/init.lua
2015-07-14 05:28:14: ERROR[main]: Error from Lua:
2015-07-14 05:28:14: ERROR[main]: bad argument #2 to '?' (string expected, got function)
2015-07-14 05:28:14: ERROR[main]: stack traceback:
2015-07-14 05:28:14: ERROR[main]: 	[C]: ?
2015-07-14 05:28:14: ERROR[main]: 	[C]: in function 'open'
2015-07-14 05:28:14: ERROR[main]: 	...in/../mods/mt-firearms/firearmslib/pureluaentity.lua:149: in function 'load'
2015-07-14 05:28:14: ERROR[main]: 	...in/../mods/mt-firearms/firearmslib/pureluaentity.lua:190: in main chunk
2015-07-14 05:28:14: ERROR[main]: 	[C]: in function 'dofile'
2015-07-14 05:28:14: ERROR[main]: 	...inetest/bin/../mods/mt-firearms/firearmslib/init.lua:21: in main chunk
The line is:

Code: Select all

print("[pureluaentity] Loading DB...")
local f, e = io.open(DB_FILE) -- pureluaentity.lua:149
local data
where DB_FILE is:

Code: Select all

local DB_FILE = minetest.get_worldpath().."/ple.list"
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

judahman23
New member
Posts: 2
Joined: Mon Jun 15, 2015 14:20
In-game: judah judahman

Re:

by judahman23 » Post

jojoa1997 wrote:the mod works great :-)

pros:
-do good damage
-fun
-fast shooting

cons:
-i dont know which ammo goes to which gun (maybe make the ammo name be "<gun name> ammo")
-also if you are shooting at somone but are close enough to see the selection box then they are not damaged

if you want to make it destroy the surrounding area then look at jordan4ipbanez butter mod. also have the item itself take in the surrounding area. i think that explosions shouls be configurable in case you want the damage to the player but not the damage to the land
Another con is that it doesn't do damage on animals. I have animals_modpack-2.4.2 and the guns will fire but It won't hurt and/or kill.

User avatar
Samson1
Member
Posts: 95
Joined: Wed Apr 01, 2015 19:41
GitHub: MoJo4000
IRC: Samson1
In-game: Samson1

Re: [Mod] Firearms [0.2.0] [firearms]

by Samson1 » Post

Last time I used this mod it crashed every time I tried to shoot some one

User avatar
Samson1
Member
Posts: 95
Joined: Wed Apr 01, 2015 19:41
GitHub: MoJo4000
IRC: Samson1
In-game: Samson1

Re: [Mod] Firearms [0.2.0] [firearms]

by Samson1 » Post

Do you think you could make it shoot sheep, Zombies, ghosts, all sorts like that? If you could it would be so good!

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests