Imported from trollstream "ContentDB"
commit
8d6077fe0c
|
@ -0,0 +1,24 @@
|
|||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
|
@ -0,0 +1,102 @@
|
|||
minetest.register_craftitem("snowball:ball", {
|
||||
description = "Throwable Snowball",
|
||||
range = 0,
|
||||
stack_max= 16,
|
||||
inventory_image = "snowball.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if not minetest.setting_getbool("creative_mode") then itemstack:take_item()
|
||||
end
|
||||
if pointed_thing.type ~= "nothing" then
|
||||
local pointed = minetest.get_pointed_thing_position(pointed_thing)
|
||||
if vector.distance(user:getpos(), pointed) < 8 then
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
local pos = user:getpos()
|
||||
local dir = user:get_look_dir()
|
||||
local yaw = user:get_look_yaw()
|
||||
if pos and dir then
|
||||
pos.y = pos.y + 1.5
|
||||
local obj = minetest.add_entity(pos, "snowball:snow")
|
||||
if obj then
|
||||
obj:setvelocity({x=dir.x * 35, y=dir.y * 35, z=dir.z * 35})
|
||||
obj:setacceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
|
||||
obj:setyaw(yaw + math.pi)
|
||||
local ent = obj:get_luaentity()
|
||||
if ent then
|
||||
ent.player = ent.player or user
|
||||
end
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
local SNOWBALL = {
|
||||
physical = false,
|
||||
timer = 0,
|
||||
visual = "cube",
|
||||
visual_size = {x=0.5, y=0.0,},
|
||||
textures = {'snowball.png','snowball.png','snowball.png','snowball.png','snowball.png','snowball.png'},
|
||||
lastpos= {},
|
||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||
}
|
||||
SNOWBALL.on_step = function(self, dtime)
|
||||
self.timer = self.timer + dtime
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
if self.timer > 0.07 then
|
||||
local objs = minetest.get_objects_inside_radius({x = pos.x, y = pos.y, z = pos.z}, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "snowball:snow" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local damage = 6
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups= {fleshy = damage},
|
||||
}, nil)
|
||||
minetest.sound_play("default_dig_cracky", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
else
|
||||
local damage = 6
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups= {fleshy = damage},
|
||||
}, nil)
|
||||
minetest.sound_play("default_dig_cracky", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x ~= nil then
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
minetest.add_item(self.lastpos, "")
|
||||
end
|
||||
minetest.sound_play("default_dig_cracky", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
self.lastpos= {x = pos.x, y = pos.y, z = pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("snowball:snow", SNOWBALL)
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = 'snowball:ball',
|
||||
recipe = 'default:snow',
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'snowball:ball 3',
|
||||
recipe = {
|
||||
{'default:snow', '', ''},
|
||||
{'', '', ''},
|
||||
{'', '', ''},
|
||||
}
|
||||
})
|
|
@ -0,0 +1,5 @@
|
|||
description = Adds throwable snowballs to your inventory
|
||||
author = ComputeGraphics
|
||||
title = throwable_snoballs
|
||||
release = 1
|
||||
name = snowball
|
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
Loading…
Reference in New Issue