More refactoring #15
@ -18,15 +18,6 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "rangedweapons:ak47",
|
|
||||||
recipe = {
|
|
||||||
{"default:diamond", "default:steel_ingot", "default:tree"},
|
|
||||||
{"default:tree", "default:mese", "default:steel_ingot"},
|
|
||||||
{"default:steel_ingot", "", "default:tree"},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "rangedweapons:awp",
|
output = "rangedweapons:awp",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -1,76 +1,81 @@
|
|||||||
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
|
local weapon = dofile(modpath.."/weapon.lua")
|
||||||
|
local auto_rifle = dofile(modpath.."/weapons".."/auto_rifle".."/auto_rifle.lua")
|
||||||
|
|
||||||
minetest.register_tool("rangedweapons:ak47_r", {
|
local weapon_type = "auto_rifle"
|
||||||
stack_max= 1,
|
local weapon_name = "ak47"
|
||||||
wield_scale = {x=1.75,y=1.75,z=1.3},
|
|
||||||
description = "",
|
|
||||||
rw_next_reload = "rangedweapons:ak47_rr",
|
|
||||||
load_sound = "rangedweapons_rifle_clip_in",
|
|
||||||
range = 0,
|
|
||||||
groups = {not_in_creative_inventory = 1},
|
|
||||||
inventory_image = "rangedweapons_ak47_rld.png",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_tool("rangedweapons:ak47_rr", {
|
local weapon_item_name = ranged_weapons.mod_name .. ":" .. weapon_name
|
||||||
stack_max= 1,
|
|
||||||
wield_scale = {x=1.75,y=1.75,z=1.3},
|
|
||||||
description = "",
|
|
||||||
rw_next_reload = "rangedweapons:ak47_rrr",
|
|
||||||
load_sound = "rangedweapons_rifle_reload_a",
|
|
||||||
range = 0,
|
|
||||||
groups = {not_in_creative_inventory = 1},
|
|
||||||
inventory_image = "rangedweapons_ak47.png",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_tool("rangedweapons:ak47_rrr", {
|
-- Attributes for the weapon
|
||||||
stack_max= 1,
|
local ak_data = {
|
||||||
wield_scale = {x=1.75,y=1.75,z=1.3},
|
name = "AK-47",
|
||||||
description = "",
|
damage = 7,
|
||||||
rw_next_reload = "rangedweapons:ak47",
|
capacity = 30,
|
||||||
load_sound = "rangedweapons_rifle_reload_b",
|
ammunition_string = "7.62x39mm Ammo",
|
||||||
range = 0,
|
texture = {
|
||||||
groups = {not_in_creative_inventory = 1},
|
icon = "rangedweapons_ak47_icon.png",
|
||||||
inventory_image = "rangedweapons_ak47.png",
|
default = "rangedweapons_ak47.png",
|
||||||
})
|
reload = "rangedweapons_ak47_rld.png",
|
||||||
|
|
||||||
|
|
||||||
minetest.register_tool("rangedweapons:ak47", {
|
|
||||||
stack_max= 1,
|
|
||||||
wield_scale = {x=1.75,y=1.75,z=1.3},
|
|
||||||
description = "" ..core.colorize("#35cdff","AK-47\n") ..core.colorize("#FFFFFF", "Gun damage: 7\n") ..core.colorize("#FFFFFF", "accuracy: 77%\n") ..core.colorize("#FFFFFF", "Gun knockback: 5\n") ..core.colorize("#FFFFFF", "Gun Critical chance: 12%\n")..core.colorize("#FFFFFF", "Critical efficiency: 2.9x\n") ..core.colorize("#FFFFFF", "Reload delay: 1.4\n") ..core.colorize("#FFFFFF", "Clip size: 30\n") ..core.colorize("#FFFFFF", "Ammunition: 7.62mm rounds\n") ..core.colorize("#FFFFFF", "Rate of fire: 0.10(full-auto)\n") ..core.colorize("#FFFFFF", "Gun type: assault rifle\n") ..core.colorize("#FFFFFF", "Block penetration: 5%\n")
|
|
||||||
..core.colorize("#FFFFFF", "Enemy penetration: 15%\n") ..core.colorize("#FFFFFF", "Bullet velocity: 40"),
|
|
||||||
range = 0,
|
|
||||||
inventory_image = "rangedweapons_ak47.png",
|
|
||||||
RW_gun_capabilities = {
|
|
||||||
automatic_gun = 1,
|
|
||||||
gun_damage = {fleshy=7,knockback=5},
|
|
||||||
gun_crit = 12,
|
|
||||||
gun_critEffc = 2.9,
|
|
||||||
suitable_ammo = {{"rangedweapons:762mm",30}},
|
|
||||||
gun_skill = {"arifle_skill",50},
|
|
||||||
gun_magazine = "rangedweapons:assaultrifle_mag",
|
|
||||||
gun_icon = "rangedweapons_ak47_icon.png",
|
|
||||||
gun_unloaded = "rangedweapons:ak47_r",
|
|
||||||
gun_velocity = 40,
|
|
||||||
gun_accuracy = 77,
|
|
||||||
gun_cooldown = 0.1,
|
|
||||||
gun_reload = 1.4/4,
|
|
||||||
gun_projectiles = 1,
|
|
||||||
has_shell = 1,
|
|
||||||
gun_gravity = 0,
|
|
||||||
gun_durability = 1200,
|
|
||||||
gun_smokeSize = 5,
|
|
||||||
gun_mob_penetration = 15,
|
|
||||||
gun_node_penetration = 5,
|
|
||||||
gun_unload_sound = "rangedweapons_rifle_clip_out",
|
|
||||||
gun_sound = "rangedweapons_ak",
|
|
||||||
},
|
},
|
||||||
|
fire_sound = "rangedweapons_ak"
|
||||||
|
}
|
||||||
|
|
||||||
|
ak_data.suitable_ammo = {{ranged_weapons.mod_name .. ":" .. "762mm", ak_data.capacity}}
|
||||||
|
|
||||||
|
-- Populate any unset values with handgun defaults
|
||||||
|
for k,v in pairs(auto_rifle) do
|
||||||
|
if ak_data[k] == nil then
|
||||||
|
ak_data[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Define the item
|
||||||
|
minetest.register_tool("rangedweapons:ak47", {
|
||||||
|
description = weapon.generate_description(ak_data),
|
||||||
|
wield_scale = ak_data.default_wield_scale,
|
||||||
|
range = 0,
|
||||||
|
inventory_image = ak_data.texture.default,
|
||||||
|
rw_gun_data = ak_data,
|
||||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||||
rangedweapons_reload_gun(itemstack, user)
|
rangedweapons_reload_gun(itemstack, user)
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
inventory_image = "rangedweapons_ak47.png",
|
rangedweapons_shoot_gun(itemstack, user)
|
||||||
|
return itemstack
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- This is a trick that animates the weapon icon in the inventory. It creates multiple in-game items for each step of the
|
||||||
|
-- reload animation, which are cycled through during the reload process.
|
||||||
|
|
||||||
|
tools = {
|
||||||
|
{name = "rangedweapons:ak47_r", next_reload = "rangedweapons:ak47_rr", load_sound = "rangedweapons_rifle_clip_in", inventory_image = "rangedweapons_ak47_rld.png"},
|
||||||
|
{name = "rangedweapons:ak47_rr", next_reload = "rangedweapons:ak47_rrr", load_sound = "rangedweapons_rifle_reload_a", inventory_image = "rangedweapons_ak47.png"},
|
||||||
|
{name = "rangedweapons:ak47_rrr", next_reload = "rangedweapons:ak47", load_sound = "rangedweapons_rifle_reload_b", inventory_image = "rangedweapons_ak47.png"}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, tool in pairs() do
|
||||||
|
minetest.register_tool(tool.name, {
|
||||||
|
stack_max = 1,
|
||||||
|
wield_scale = ak_data.wield_scale,
|
||||||
|
description = "",
|
||||||
|
rw_next_reload = tool.next_reload,
|
||||||
|
load_sound = tool.load_sound,
|
||||||
|
range = 0,
|
||||||
|
groups = {not_in_creative_inventory = 1},
|
||||||
|
inventory_image = tool.inventory_image
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Crafting recipe for the AK-47
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "rangedweapons:ak47",
|
||||||
|
recipe = {
|
||||||
|
{"default:diamond", "default:steel_ingot", "default:tree"},
|
||||||
|
{"default:tree", "default:mese", "default:steel_ingot"},
|
||||||
|
{"default:steel_ingot", "", "default:tree"},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
29
weapons/auto_rifle/auto_rifle.lua
Normal file
29
weapons/auto_rifle/auto_rifle.lua
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
-- General defaults for an automatic rifle.
|
||||||
|
|
||||||
|
local auto_rifle = {
|
||||||
|
automatic_gun=true,
|
||||||
|
damage = 6,
|
||||||
|
knock_back=5,
|
||||||
|
critical_chance = 12,
|
||||||
|
critical_efficiency = 2.9,
|
||||||
|
velocity = 40,
|
||||||
|
skill = {"arifle_skill",50},
|
||||||
|
magazine = "rangedweapons:assaultrifle_mag",
|
||||||
|
fire_rate = 0.9,
|
||||||
|
cooldown = 0.1,
|
||||||
|
reload_delay = 0.35,
|
||||||
|
projectiles = 1,
|
||||||
|
has_shell = 1,
|
||||||
|
smoke_size = 5,
|
||||||
|
unload_sound = "rangedweapons_rifle_clip_out",
|
||||||
|
accuracy = 77,
|
||||||
|
gun_projectiles = 1,
|
||||||
|
has_shell = 1,
|
||||||
|
gravity = 0,
|
||||||
|
durability = 1200,
|
||||||
|
mob_penetration = 15,
|
||||||
|
node_penetration = 5,
|
||||||
|
wield_scale = {x = 1.75, y = 1.75, z = 1.3}
|
||||||
|
}
|
||||||
|
|
||||||
|
return auto_rifle
|
Loading…
x
Reference in New Issue
Block a user