Push to github

This commit is contained in:
Mahmut Elmas 2016-02-09 03:40:40 +02:00
commit 4f9e20ec94
16 changed files with 803 additions and 0 deletions

17
.gitattributes vendored Normal file
View File

@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

47
.gitignore vendored Normal file
View File

@ -0,0 +1,47 @@
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# =========================
# Operating System Files
# =========================
# OSX
# =========================
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

15
Licence.txt Normal file
View File

@ -0,0 +1,15 @@
Copyright (C) UjEdwin 2015
Its only 2 agruments.
You are not alowed to take files from the mod and use to other things.
You have to show me (UjEdwin) as the orginal creater.
It does not mather what you is doing with the mod as long you folow this 2 agruments.
So: its ok to do stuff like: use in public servers/edit/spread/make an update of the mod / using in a video...

38
Readme.txt Normal file
View File

@ -0,0 +1,38 @@
Version: 3.3
The tool is a weapon at same time
Throw it and it will always return as long there still is velocity/power left
It can pick up stuff that is breakable by hand (like no use by tools) and mobs/drops that have 10hp or less.
Players (or mobs that have more then 10 hp) will be hurted.
+ Mese can break more stuff, more times at same throw, and can break stuff like stone / ores, makes a flash when hit something (usefull in darknes / caves)
- Wood cant pick up stuff, hurt less, it fail if it hit hard block.
Craft: Wood:
S = Stick
w = Wood
[S] [ ] [S]
[ ] [w] [ ]
[S] [ ] [S]
Craft: Steel:
S = Steel ingot
B = Steel block
[S] [ ] [S]
[ ] [B] [ ]
[S] [ ] [S]
Craft: Mese:
C = Mese crystal
B = Mese block
[C] [ ] [C]
[ ] [B] [ ]
[C] [ ] [C]

BIN
craft.JPG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

68
init.lua Normal file
View File

@ -0,0 +1,68 @@
dofile(minetest.get_modpath("chakram") .. "/wood.lua")
dofile(minetest.get_modpath("chakram") .. "/steel.lua")
dofile(minetest.get_modpath("chakram") .. "/mese.lua")
pvp=minetest.setting_getbool("enable_pvp")
chakramshot_user=""
chakramshot_user_name=""
chakram_shot_chakram={}
chakram_max_number=10
function chakram_max(add)
local c=0
for i in pairs(chakram_shot_chakram) do
c=c+1
if chakram_shot_chakram[i]:getpos()==nil then
table.remove(chakram_shot_chakram,c)
c=c-1
end
end
if c+1>chakram_max_number then return false end
if add then
table.insert(chakram_shot_chakram,add)
return true
end
return true
end
minetest.register_craft({
output = "chakram:chakram",
recipe = {
{"default:steel_ingot","","default:steel_ingot"},
{"","default:steelblock",""},
{"default:steel_ingot","","default:steel_ingot"},
}
})
minetest.register_craft({
output = "chakram:chakram_mese",
recipe = {
{"default:mese_crystal","","default:mese_crystal"},
{"","default:mese",""},
{"default:mese_crystal","","default:mese_crystal"},
}
})
minetest.register_craft({
output = "chakram:chakram_wood",
recipe = {
{"default:stick","","default:stick"},
{"","group:wood",""},
{"default:stick","","default:stick"},
}
})
function chakram_drops(name)
local d=minetest.registered_nodes[name].drop
if d=="" or d==nil then return name end
if d.items then
if d.items[1].items and d.items[2] and d.items[2].items then
return d.items[math.random(1,2)].items[1]
end
if d.items[1].items then
return d.items[1].items[1]
end
return name
end
return d
end

192
mese.lua Normal file
View File

@ -0,0 +1,192 @@
minetest.register_tool("chakram:chakram_mese", {
description = "Chakram Mese",
range = 1,
inventory_image = "chakram_chakram_m.png",
on_use=function(itemstack, user, pointed_thing)
if chakram_max()==false then
minetest.chat_send_player(user:get_player_name(), "Too many chakrams: (max " .. chakram_max_number .. ")")
return itemstack
end
local pos=user:getpos()
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 5)) do
if ob:get_luaentity() and ob:get_luaentity().name=="chakram:chakr_m" then
return itemstack
end
end
chakramshot_user=user
chakramshot_user_name=user:get_player_name()
local dir = user:get_look_dir()
local veloc=15
pos.y=pos.y+1.5
local m=minetest.env:add_entity(pos, "chakram:chakr_m")
chakram_max(m)
m:setvelocity({x=dir.x*veloc, y=dir.y*veloc, z=dir.z*veloc})
m:setyaw(user:get_look_yaw()+math.pi)
itemstack:take_item()
minetest.sound_play("chakram_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,})
return itemstack
end,
})
minetest.register_entity("chakram:chakr_m",{
hp_max = 999,
physical = false,
weight = 0,
visual="mesh",
mesh="chakram_chakram.obj",
visual_size = {x=1, y=1},
textures = {"chakram_chakram_m.png","chakram_chakram_m.png","chakram_chakram_m.png","chakram_chakram_m.png","chakram_chakram_m.png","chakram_chakram_m.png"},
colors = {},
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=1, y=1},
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = math.pi * 4,
timer = 0,
timer2 = 0,
timer3 = 0,
stuck = 0,
user={},
user_name="",
opos={x=0,y=0,z=0},
chakram_m=1,
on_activate=function(self, staticdata)
if chakramshot_user_name=="" then
minetest.add_item(self.object:getpos(), "chakram:chakram_mese")
self.object:remove()
return false
end
self.user=chakramshot_user
self.user_name=chakramshot_user_name
chakramshot_user_name=""
chakramshot_user=""
end,
on_step = function(self, dtime)
self.timer=self.timer+dtime
if self.timer<0.05 then return self end
self.timer3=self.timer3+self.timer
if self.user==nil then
self.timer3=10
self.stuck=1
end
if self.timer3>=2 then
if self.stuck==1 then
minetest.add_item(self.object:getpos(), "chakram:chakram_mese")
if self.ob then self.ob:set_detach() self.ob:setacceleration({x=0,y=-8,z=0}) end
self.object:set_hp(0)
self.object:punch(self.object, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
return
else
self.timer3=-4
self.stuck=1
end
end
self.timer=0
self.timer2=self.timer2+dtime
self.object:set_hp(999)
local pos=self.object:getpos()
local name=minetest.get_node(pos).name
if name~="air" and (minetest.get_node_group(name, "snappy")>0 or minetest.get_node_group(name, "dig_immediate")>0 or minetest.get_node_group(name, "oddly_breakable_by_hand")>0 or minetest.get_node_group(name, "cracky")>0 ) and minetest.is_protected(pos,self.user:get_player_name())==false and string.find(name,"chest",1)==nil then
minetest.add_item(pos, chakram_drops(name))
minetest.set_node(pos, {name="air"})
if name=="air" or minetest.get_node(self.opos).name=="air" then minetest.set_node(pos, {name="chakram:light"}) end
elseif minetest.registered_nodes[minetest.get_node(pos).name].walkable then
self.timer3=-4
self.stuck=1
end
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 2)) do
if ob:get_hp()<10 and (not ob:get_attach()) and ob:get_luaentity() and (not ob:get_luaentity().chakram_m) then
self.stuck=1
self.ob=ob
ob:set_attach(self.object, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
self.timer3=-4
break
end
if (not ob:get_attach()) and ((ob:get_luaentity() and (not ob:get_luaentity().itemstring) and (not ob:get_luaentity().chakram_m)) or ((not ob:get_luaentity()) and ob:get_player_name()~=self.user_name and pvp)) then
ob:set_hp(ob:get_hp()-10)
ob:punch(self.user, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
minetest.sound_play("chakram_hard_punch", {pos=ob:getpos(), gain = 1.0, max_hear_distance = 5,})
end
end
if self.stuck==1 then
if self.user==nil or self.user:getpos()==nil then
self.timer3=10
self.stuck=1
return
end
local ta=self.user:getpos()
ta.y=ta.y+1
local vec = {x = pos.x - ta.x, y = pos.y - ta.y, z = pos.z - ta.z}
local amount = (vec.x ^ 2 + vec.y ^ 2 + vec.z ^ 2) ^ 0.5
local v = -15
vec.x = vec.x * v / amount
vec.y = vec.y * v / amount
vec.z = vec.z * v / amount
self.object:setvelocity(vec)
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 2)) do
if (not ob:get_luaentity()) and ob:get_player_name()==self.user_name then
if self.object==nil or self.user==nil or self.user:getpos()==nil then
self.timer3=10
self.stuck=1
return
end
if self.ob and self.ob:get_attach() and self.ob:get_hp()~=nil and self.ob:get_hp()>0 then
self.ob:set_detach()
self.ob:set_hp(0)
self.ob:punch(self.user, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
end
if self.object:get_attach() then self.object:set_detach() return false end
if self.ob and self.ob==nil then return false end
self.user:get_inventory():add_item("main", ItemStack("chakram:chakram_mese"))
self.object:set_hp(0)
self.object:punch(self.object, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
break
end
end
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 3)) do
if ob:get_luaentity() and (not ob:get_attach()) and ob:get_luaentity().itemstring and ob:get_luaentity().itemstring~="chakram:chakram_mese" then
ob:punch(self.user, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
end
end
end
self.opos=self.object:getpos()
end,
})
minetest.register_abm({
nodenames = {"chakram:light"},
interval = 2,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name="air"})
end,
})
minetest.register_node("chakram:light", {
description = "Light",
tiles = {"chakram_light.png",},
drop="",
light_source = 10,
paramtype = "light",
alpha = 50,
walkable=false,
drawtype = "airlike",
sunlight_propagates = false,
pointable = false,
buildable_to = true,
groups = {not_in_creative_inventory=1},
can_dig = function(pos, player)
return false
end,
})

View File

@ -0,0 +1,93 @@
# Alias Wavefront OBJ File Exported from SketchUp
# with OBJexporter (c) 2010/2011 TIG
# Units = meters
mtllib hook_chakram.mtl
g hook_chakram_c_Component_1-Material1
usemtl Material1
v 3.948618 -1.249362 -4.205230
v -4.149616 -1.249362 3.954123
v -4.149616 -1.249362 -4.205230
v 3.948618 -1.249362 3.954123
v 3.948618 -1.249362 -4.205230
v 3.948618 -0.961231 3.954123
v 3.948618 -1.249362 3.954123
v 3.948618 -0.961231 -4.205230
v -4.149616 -0.961231 -4.205230
v -4.149616 -1.249362 3.954123
v -4.149616 -0.961231 3.954123
v -4.149616 -1.249362 -4.205230
v 3.948618 -0.961231 3.954123
v -4.149616 -0.961231 -4.205230
v -4.149616 -0.961231 3.954123
v 3.948618 -0.961231 -4.205230
v -4.149616 -0.961231 -4.205230
v 3.948618 -1.249362 -4.205230
v -4.149616 -1.249362 -4.205230
v 3.948618 -0.961231 -4.205230
v 3.948618 -0.961231 3.954123
v -4.149616 -1.249362 3.954123
v 3.948618 -1.249362 3.954123
v -4.149616 -0.961231 3.954123
vn 0.000000 -1.000000 -0.000000
vn 0.000000 -1.000000 -0.000000
vn 0.000000 -1.000000 -0.000000
vn 0.000000 -1.000000 -0.000000
vn 1.000000 0.000000 -0.000000
vn 1.000000 0.000000 -0.000000
vn 1.000000 0.000000 -0.000000
vn 1.000000 0.000000 -0.000000
vn -1.000000 0.000000 -0.000000
vn -1.000000 0.000000 -0.000000
vn -1.000000 0.000000 -0.000000
vn -1.000000 0.000000 -0.000000
vn 0.000000 1.000000 -0.000000
vn 0.000000 1.000000 -0.000000
vn 0.000000 1.000000 -0.000000
vn 0.000000 1.000000 -0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vt 1.021793 1.997067
vt 1.987939 1.023629
vt 1.987939 1.997067
vt 1.021793 1.023629
vt 1.997067 0.000000
vt 1.023629 0.034375
vt 1.023629 0.000000
vt 1.997067 0.034375
vt -1.997067 0.034375
vt -1.023629 0.000000
vt -1.023629 0.034375
vt -1.997067 0.000000
vt -1.021793 1.023629
vt -1.987939 1.997067
vt -1.987939 1.023629
vt -1.021793 1.997067
vt 1.987939 0.034375
vt 1.021793 0.000000
vt 1.987939 0.000000
vt 1.021793 0.034375
vt -1.021793 0.034375
vt -1.987939 0.000000
vt -1.021793 0.000000
vt -1.987939 0.034375
f 1/1/1 2/2/2 3/3/3
f 2/2/2 1/1/1 4/4/4
f 5/5/5 6/6/6 7/7/7
f 6/6/6 5/5/5 8/8/8
f 9/9/9 10/10/10 11/11/11
f 10/10/10 9/9/9 12/12/12
f 13/13/13 14/14/14 15/15/15
f 14/14/14 13/13/13 16/16/16
f 17/17/17 18/18/18 19/19/19
f 18/18/18 17/17/17 20/20/20
f 21/21/21 22/22/22 23/23/23
f 22/22/22 21/21/21 24/24/24

Binary file not shown.

BIN
sounds/chakram_throw.ogg Normal file

Binary file not shown.

186
steel.lua Normal file
View File

@ -0,0 +1,186 @@
minetest.register_tool("chakram:chakram", {
description = "Chakram",
range = 1,
inventory_image = "chakram_chakram.png",
on_use=function(itemstack, user, pointed_thing)
if chakram_max()==false then
minetest.chat_send_player(user:get_player_name(), "Too many chakrams: (max " .. chakram_max_number .. ")")
return itemstack
end
local pos=user:getpos()
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 5)) do
if ob:get_luaentity() and ob:get_luaentity().name=="chakram:chakr" then
return itemstack
end
end
chakramshot_user=user
chakramshot_user_name=user:get_player_name()
local dir = user:get_look_dir()
local veloc=15
pos.y=pos.y+1.5
local m=minetest.env:add_entity(pos, "chakram:chakr")
chakram_max(m)
m:setvelocity({x=dir.x*veloc, y=dir.y*veloc, z=dir.z*veloc})
m:setyaw(user:get_look_yaw()+math.pi)
itemstack:take_item()
minetest.sound_play("chakram_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,})
return itemstack
end,
})
minetest.register_entity("chakram:chakr",{
hp_max = 999,
physical = false,
weight = 0,
visual="mesh",
mesh="chakram_chakram.obj",
visual_size = {x=1, y=1},
textures = {"chakram_chakram.png","chakram_chakram.png","chakram_chakram.png","chakram_chakram.png","chakram_chakram.png","chakram_chakram.png"},
colors = {},
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=1, y=1},
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = math.pi * 4,
timer = 0,
timer2 = 0,
timer3 = 0,
stuck = 0,
user={},
user_name="",
chakram_s=1,
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
if puncher:get_luaentity() or (puncher:get_player_name()~=self.user_name) then
self.timer3=-2
self.stuck=1
end
end,
on_activate=function(self, staticdata)
if chakramshot_user=="" then
minetest.add_item(self.object:getpos(), "chakram:chakram")
self.object:remove()
return false
end
self.user=chakramshot_user
self.user_name=chakramshot_user_name
chakramshot_user_name=""
chakramshot_user=""
end,
on_step = function(self, dtime)
self.timer=self.timer+dtime
if self.timer<0.05 then return self end
self.timer3=self.timer3+self.timer
if self.user==nil then
self.timer3=10
self.stuck=1
end
if self.timer3>=2 then
if self.stuck==1 then
minetest.add_item(self.object:getpos(), "chakram:chakram")
if self.ob then self.ob:set_detach() self.ob:setacceleration({x=0,y=-8,z=0}) end
self.object:set_hp(0)
self.object:punch(self.object, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
return
else
self.timer3=-2
self.stuck=1
end
end
self.timer=0
self.timer2=self.timer2+dtime
self.object:set_hp(999)
local pos=self.object:getpos()
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 2)) do
if ob:get_hp()<10 and (not ob:get_attach()) and ob:get_luaentity() and (not ob:get_luaentity().chakram_s) then
self.stuck=1
self.ob=ob
ob:set_attach(self.object, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
self.timer3=-2
break
end
if self.stuck==0 then
if (ob:get_luaentity() and (not ob:get_luaentity().chakram_s) and (not ob:get_luaentity().itemstring) ) or ((not ob:get_luaentity()) and ob:get_player_name()~=self.user_name and pvp) then
ob:set_hp(ob:get_hp()-5)
ob:punch(self.user, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
minetest.sound_play("chakram_hard_punch", {pos=ob:getpos(), gain = 1.0, max_hear_distance = 5,})
end
end
end
if self.stuck==0 then
local name=minetest.get_node(pos).name
if name~="air" and (minetest.get_node_group(name, "snappy")>0 or minetest.get_node_group(name, "dig_immediate")>0 or minetest.get_node_group(name, "oddly_breakable_by_hand")>0) and minetest.is_protected(pos,self.user:get_player_name())==false and string.find(name,"chest",1)==nil then
minetest.add_item(pos, chakram_drops(name))
minetest.set_node(pos, {name="air"})
elseif minetest.registered_nodes[name].walkable then
self.timer3=-2
self.stuck=1
end
else
if self.user==nil or self.user:getpos()==nil then
self.timer3=10
self.stuck=1
return
end
local ta=self.user:getpos()
ta.y=ta.y+1
local vec = {x = pos.x - ta.x, y = pos.y - ta.y, z = pos.z - ta.z}
local amount = (vec.x ^ 2 + vec.y ^ 2 + vec.z ^ 2) ^ 0.5
local v = -15
vec.x = vec.x * v / amount
vec.y = vec.y * v / amount
vec.z = vec.z * v / amount
self.object:setvelocity(vec)
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 2)) do
if (not ob:get_attach()) and ((ob:get_luaentity() and (not ob:get_luaentity().itemstring) and (not ob:get_luaentity().chakram_s)) or ((not ob:get_luaentity()) and ob:get_player_name()~=self.user_name and pvp)) then
ob:set_hp(ob:get_hp()-15)
ob:punch(self.user, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
minetest.sound_play("chakram_hard_punch", {pos=ob:getpos(), gain = 1.0, max_hear_distance = 5,})
end
if (not ob:get_luaentity()) and ob:get_player_name()==self.user_name then
if self.user==nil or self.user:getpos()==nil then
self.timer3=10
self.stuck=1
return
end
if self.ob and self.ob:get_attach() and self.ob:get_hp()>0 then
self.ob:set_detach()
self.ob:set_hp(0)
self.ob:punch(self.user, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
end
if self.object:get_attach() then self.object:set_detach() return false end
self.user:get_inventory():add_item("main", ItemStack("chakram:chakram"))
self.object:set_hp(0)
self.object:punch(self.object, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
end
end
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 3)) do
if ob:get_luaentity() and (not ob:get_attach()) and ob:get_luaentity().itemstring and ob:get_luaentity().itemstring~="chakram:chakram" then
ob:punch(self.user, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
end
end
end
end,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

BIN
textures/chakram_light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

147
wood.lua Normal file
View File

@ -0,0 +1,147 @@
minetest.register_tool("chakram:chakram_wood", {
description = "Wooden Chakram",
range = 1,
inventory_image = "chakram_chakram_w.png",
on_use=function(itemstack, user, pointed_thing)
if chakram_max()==false then
minetest.chat_send_player(user:get_player_name(), "Too many chakrams: (max " .. chakram_max_number .. ")")
return itemstack
end
local pos=user:getpos()
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 5)) do
if ob:get_luaentity() and ob:get_luaentity().name=="chakram:chakramr_w" then
return itemstack
end
end
chakramshot_user=user
chakramshot_user_name=user:get_player_name()
local dir = user:get_look_dir()
local veloc=15
pos.y=pos.y+1.5
local m=minetest.env:add_entity(pos, "chakram:chakr_w")
chakram_max(m)
m:setvelocity({x=dir.x*veloc, y=dir.y*veloc, z=dir.z*veloc})
m:setyaw(user:get_look_yaw()+math.pi)
itemstack:take_item()
minetest.sound_play("chakram_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,})
return itemstack
end,
})
minetest.register_entity("chakram:chakr_w",{
hp_max = 999,
physical = false,
weight = 0,
visual="mesh",
mesh="chakram_chakram.obj",
visual_size = {x=1, y=1},
textures = {"chakram_chakram_w.png","chakram_chakram_w.png","chakram_chakram_w.png","chakram_chakram_w.png","chakram_chakram_w.png","chakram_chakram_w.png"},
colors = {},
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=1, y=1},
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = math.pi * 4,
timer = 0,
timer2 = 0,
timer3 = 0,
stuck = 0,
user={},
user_name="",
opos={x=0,z=0,y=0},
chakram_w=1,
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
if puncher:get_luaentity() or (puncher:get_player_name()~=self.user_name) then
minetest.add_item(self.object:getpos(), "chakram:chakram_wood")
self.object:remove()
end
end,
on_activate=function(self, staticdata)
if chakramshot_user_name=="" then
minetest.add_item(self.object:getpos(), "chakram:chakram_wood")
self.object:remove()
return false
end
self.user=chakramshot_user
self.user_name=chakramshot_user_name
chakramshot_user_name=""
chakramshot_user=""
end,
on_step = function(self, dtime)
self.timer=self.timer+dtime
if self.timer<0.05 then return self end
self.timer3=self.timer3+self.timer
if self.user==nil then
self.timer3=10
self.stuck=1
end
if self.timer3>=2 then
if self.stuck==1 then
minetest.add_item(self.object:getpos(), "chakram:chakram_wood")
self.object:remove()
return
else
self.timer3=-2
self.stuck=1
end
end
self.timer=0
self.timer2=self.timer2+dtime
self.object:set_hp(999)
local pos=self.object:getpos()
local name=minetest.get_node(pos).name
if name~="air" and (minetest.get_node_group(name, "snappy")>0 or minetest.get_node_group(name, "dig_immediate")>0) and minetest.is_protected(pos,self.user:get_player_name())==false then
minetest.add_item(pos, chakram_drops(name))
minetest.set_node(pos, {name="air"})
elseif minetest.registered_nodes[minetest.get_node(pos).name].walkable then
minetest.add_item(self.opos, "chakram:chakram_wood")
self.object:remove()
return false
end
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 2)) do
if (not ob:get_attach()) and (ob:get_luaentity() and (not ob:get_luaentity().chakram_w) and (not ob:get_luaentity().itemstring)) or ((not ob:get_luaentity()) and ob:get_player_name()~=self.user_name and pvp) then
ob:set_hp(ob:get_hp()-2)
ob:punch(self.user, {full_punch_interval=1.0,damage_groups={fleshy=10}}, "default:bronze_pick", nil)
minetest.sound_play("chakram_hard_punch", {pos=ob:getpos(), gain = 1.0, max_hear_distance = 5,})
end
end
if self.stuck==0 then
else
if self.user==nil or self.user:getpos()==nil then
self.timer3=10
self.stuck=1
return
end
local ta=self.user:getpos()
ta.y=ta.y+1
local vec = {x = pos.x - ta.x, y = pos.y - ta.y, z = pos.z - ta.z}
local amount = (vec.x ^ 2 + vec.y ^ 2 + vec.z ^ 2) ^ 0.5
local v = -15
vec.x = vec.x * v / amount
vec.y = vec.y * v / amount
vec.z = vec.z * v / amount
self.object:setvelocity(vec)
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 2)) do
if (not ob:get_luaentity()) and ob:get_player_name()==self.user_name then
if self.object==nil or self.user==nil or self.user:getpos()==nil then
self.timer3=10
self.stuck=1
return
end
if self.object:get_attach() then self.object:set_detach() return false end
self.user:get_inventory():add_item("main", ItemStack("chakram:chakram_wood"))
self.object:remove()
end
end
end
self.opos=pos
end,
})