Add coloured arrows
This commit is contained in:
parent
dc86ef4ecb
commit
a6f3caeaf5
5 changed files with 101 additions and 70 deletions
14
README.txt
14
README.txt
|
@ -5,7 +5,7 @@ Mod Version: 0.5.2
|
|||
|
||||
Minetest Version: 0.4.9, 0.4.10
|
||||
|
||||
Depends: default, wool, tnt
|
||||
Depends: default, dye, tnt, wool
|
||||
|
||||
An experimental first person shooter mod that uses simple vector mathematics
|
||||
to produce an accurate and server-firendly method of hit detection.
|
||||
|
@ -22,6 +22,10 @@ as the base for a 'Spades' style FPS game using the minetest engine.
|
|||
Crafting
|
||||
========
|
||||
|
||||
<color> = grey, black, red, yellow, green, cyan, blue, magenta
|
||||
|
||||
A = Arrow [shooter:arrow_white]
|
||||
C = Color Dye [dye:<color>]
|
||||
W = Wooden Stick [default:stick]
|
||||
P = Paper [default:paper]
|
||||
S = Steel Ingot [default:steel_ingot]
|
||||
|
@ -41,7 +45,7 @@ Crossbow: [shooter:crossbow]
|
|||
| W | | B |
|
||||
+---+---+---+
|
||||
|
||||
Arrow: [shooter:arrow]
|
||||
White Arrow: [shooter:arrow_white]
|
||||
|
||||
+---+---+---+
|
||||
| S | | |
|
||||
|
@ -51,6 +55,12 @@ Arrow: [shooter:arrow]
|
|||
| | P | W |
|
||||
+---+---+---+
|
||||
|
||||
Coloured Arrow: [shooter:arrow_<color>]
|
||||
|
||||
+---+---+
|
||||
| C | A |
|
||||
+---+---+
|
||||
|
||||
Pistol: [shooter:pistol]
|
||||
|
||||
+---+---+
|
||||
|
|
51
crossbow.lua
51
crossbow.lua
|
@ -2,6 +2,9 @@ SHOOTER_CROSSBOW_USES = 50
|
|||
SHOOTER_ARROW_TOOL_CAPS = {damage_groups={fleshy=2}}
|
||||
SHOOTER_ARROW_LIFETIME = 180 -- 3 minutes
|
||||
|
||||
minetest.register_alias("shooter:arrow", "shooter:arrow_white")
|
||||
minetest.register_alias("shooter:crossbow_loaded", "shooter:crossbow_loaded_white")
|
||||
|
||||
local function get_animation_frame(dir)
|
||||
local angle = math.atan(dir.y)
|
||||
local frame = 90 - math.floor(angle * 360 / math.pi)
|
||||
|
@ -52,11 +55,6 @@ local function get_texture(name, colour)
|
|||
return "shooter_"..name..".png^wool_"..colour..".png^shooter_"..name..".png^[makealpha:255,126,126"
|
||||
end
|
||||
|
||||
minetest.register_craftitem("shooter:arrow", {
|
||||
description = "Arrow",
|
||||
inventory_image = get_texture("arrow_inv", "white"),
|
||||
})
|
||||
|
||||
minetest.register_entity("shooter:arrow_entity", {
|
||||
physical = false,
|
||||
visual = "mesh",
|
||||
|
@ -65,6 +63,7 @@ minetest.register_entity("shooter:arrow_entity", {
|
|||
textures = {
|
||||
get_texture("arrow_uv", "white"),
|
||||
},
|
||||
color = "white",
|
||||
timer = 0,
|
||||
lifetime = SHOOTER_ARROW_LIFETIME,
|
||||
player = nil,
|
||||
|
@ -80,7 +79,7 @@ minetest.register_entity("shooter:arrow_entity", {
|
|||
on_punch = function(self, puncher)
|
||||
if puncher then
|
||||
if puncher:is_player() then
|
||||
local stack = "shooter:arrow"
|
||||
local stack = "shooter:arrow_"..self.color
|
||||
local inv = puncher:get_inventory()
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
|
@ -164,9 +163,14 @@ minetest.register_entity("shooter:arrow_entity", {
|
|||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("shooter:crossbow_loaded", {
|
||||
for _, color in pairs(dye.basecolors) do
|
||||
minetest.register_craftitem("shooter:arrow_"..color, {
|
||||
description = color:gsub("%a", string.upper, 1).." Arrow",
|
||||
inventory_image = get_texture("arrow_inv", color),
|
||||
})
|
||||
minetest.register_tool("shooter:crossbow_loaded_"..color, {
|
||||
description = "Crossbow",
|
||||
inventory_image = get_texture("crossbow_loaded", "white"),
|
||||
inventory_image = get_texture("crossbow_loaded", color),
|
||||
groups = {not_in_creative_inventory=1},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
minetest.sound_play("shooter_click", {object=user})
|
||||
|
@ -185,6 +189,10 @@ minetest.register_tool("shooter:crossbow_loaded", {
|
|||
ent = obj:get_luaentity()
|
||||
end
|
||||
if ent then
|
||||
ent.color = color
|
||||
obj:set_properties({
|
||||
textures = {get_texture("arrow_uv", color)}
|
||||
})
|
||||
minetest.sound_play("shooter_throw", {object=obj})
|
||||
local frame = get_animation_frame(dir)
|
||||
obj:setyaw(yaw + math.pi)
|
||||
|
@ -218,23 +226,24 @@ minetest.register_tool("shooter:crossbow_loaded", {
|
|||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_tool("shooter:crossbow", {
|
||||
description = "Crossbow",
|
||||
inventory_image = "shooter_crossbow.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local inv = user:get_inventory()
|
||||
if inv:contains_item("main", "shooter:arrow") then
|
||||
for _, color in pairs(dye.basecolors) do
|
||||
if inv:contains_item("main", "shooter:arrow_"..color) then
|
||||
minetest.sound_play("shooter_reload", {object=user})
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
inv:remove_item("main", "shooter:arrow 1")
|
||||
inv:remove_item("main", "shooter:arrow_"..color.." 1")
|
||||
end
|
||||
return "shooter:crossbow_loaded_"..color.." 1 "..itemstack:get_wear()
|
||||
end
|
||||
end
|
||||
itemstack = "shooter:crossbow_loaded 1 "..itemstack:get_wear()
|
||||
else
|
||||
minetest.sound_play("shooter_click", {object=user})
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -248,12 +257,22 @@ if SHOOTER_ENABLE_CRAFTING == true then
|
|||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "shooter:arrow",
|
||||
output = "shooter:arrow_white",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "", ""},
|
||||
{"", "default:stick", "default:paper"},
|
||||
{"", "default:paper", "default:stick"},
|
||||
},
|
||||
})
|
||||
for _, color in pairs(dye.basecolors) do
|
||||
if color ~= "white" then
|
||||
minetest.register_craft({
|
||||
output = "shooter:arrow_"..color,
|
||||
recipe = {
|
||||
{"", "dye:"..color, "shooter:arrow_white"},
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
default
|
||||
wool
|
||||
dye
|
||||
tnt
|
||||
wool
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 483 B |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
Loading…
Reference in a new issue