From 748711b0732e42274f582310b116e59c1493ebb4 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 2 Dec 2020 12:09:22 -0800 Subject: [PATCH] Add on_fire knockback and a few tweaks to guns --- shooter/api.lua | 10 ++++++++++ shooter_guns/init.lua | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/shooter/api.lua b/shooter/api.lua index 9b14679..34e9fc4 100644 --- a/shooter/api.lua +++ b/shooter/api.lua @@ -386,6 +386,15 @@ local function fire_weapon(player, itemstack, spec, extended) if not dir or not pos then return 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 spec.origin = pos local interval = spec.tool_caps.full_punch_interval @@ -449,6 +458,7 @@ shooter.fire_weapon = function(player, itemstack, spec) end shooting[name] = true end + spec.user = name spec.name = itemstack:get_name() spec.wield_idx = player:get_wield_index() diff --git a/shooter_guns/init.lua b/shooter_guns/init.lua index 1326bff..7ce1699 100644 --- a/shooter_guns/init.lua +++ b/shooter_guns/init.lua @@ -42,6 +42,7 @@ shooter.register_weapon("shooter_guns:rifle", { description = "Rifle", inventory_image = "shooter_rifle.png", spec = { + user_knockback = 4, rounds = 100, range = 240, step = 30, @@ -64,12 +65,13 @@ shooter.register_weapon("shooter_guns:shotgun", { description = "Shotgun", inventory_image = "shooter_shotgun.png", spec = { + user_knockback = 12, rounds = 12, range = 30, step = 15, shots = 15, 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}, sounds = { shot = "shooter_shotgun", @@ -88,7 +90,8 @@ shooter.register_weapon("shooter_guns:machine_gun", { inventory_image = "shooter_smgun.png", spec = { automatic = true, - rounds = 32, + user_knockback = 2, + rounds = 42, range = 160, step = 20, tool_caps = {full_punch_interval=0.1, damage_groups={fleshy=2, ranged=1}},