Add on_fire knockback and a few tweaks to guns

This commit is contained in:
LoneWolfHT 2020-12-02 12:09:22 -08:00
parent f74ea4e0be
commit 748711b073
2 changed files with 15 additions and 2 deletions

View file

@ -386,6 +386,15 @@ local function fire_weapon(player, itemstack, spec, extended)
if not dir or not pos then if not dir or not pos then
return return
end end
if spec.user_knockback then
if vector.distance(player:get_velocity(), vector.new()) < 10 then
local vel = vector.multiply(minetest.yaw_to_dir(player:get_look_horizontal()), -spec.user_knockback)
vel.y = spec.user_knockback/2
player:add_player_velocity(vel)
end
end
pos.y = pos.y + player:get_properties().eye_height pos.y = pos.y + player:get_properties().eye_height
spec.origin = pos spec.origin = pos
local interval = spec.tool_caps.full_punch_interval local interval = spec.tool_caps.full_punch_interval
@ -449,6 +458,7 @@ shooter.fire_weapon = function(player, itemstack, spec)
end end
shooting[name] = true shooting[name] = true
end end
spec.user = name spec.user = name
spec.name = itemstack:get_name() spec.name = itemstack:get_name()
spec.wield_idx = player:get_wield_index() spec.wield_idx = player:get_wield_index()

View file

@ -42,6 +42,7 @@ shooter.register_weapon("shooter_guns:rifle", {
description = "Rifle", description = "Rifle",
inventory_image = "shooter_rifle.png", inventory_image = "shooter_rifle.png",
spec = { spec = {
user_knockback = 4,
rounds = 100, rounds = 100,
range = 240, range = 240,
step = 30, step = 30,
@ -64,12 +65,13 @@ shooter.register_weapon("shooter_guns:shotgun", {
description = "Shotgun", description = "Shotgun",
inventory_image = "shooter_shotgun.png", inventory_image = "shooter_shotgun.png",
spec = { spec = {
user_knockback = 12,
rounds = 12, rounds = 12,
range = 30, range = 30,
step = 15, step = 15,
shots = 15, shots = 15,
spread = 10, spread = 10,
tool_caps = {full_punch_interval=1, damage_groups={fleshy=2, ranged=1}}, tool_caps = {full_punch_interval=1.5, damage_groups={fleshy=2, ranged=1}},
groups = {snappy=3, fleshy=3, oddly_breakable_by_hand=3}, groups = {snappy=3, fleshy=3, oddly_breakable_by_hand=3},
sounds = { sounds = {
shot = "shooter_shotgun", shot = "shooter_shotgun",
@ -88,7 +90,8 @@ shooter.register_weapon("shooter_guns:machine_gun", {
inventory_image = "shooter_smgun.png", inventory_image = "shooter_smgun.png",
spec = { spec = {
automatic = true, automatic = true,
rounds = 32, user_knockback = 2,
rounds = 42,
range = 160, range = 160,
step = 20, step = 20,
tool_caps = {full_punch_interval=0.1, damage_groups={fleshy=2, ranged=1}}, tool_caps = {full_punch_interval=0.1, damage_groups={fleshy=2, ranged=1}},