diff --git a/harrytest/init.lua b/harrytest/init.lua index bc7ef90..5efb4cc 100644 --- a/harrytest/init.lua +++ b/harrytest/init.lua @@ -152,7 +152,7 @@ end local on_mdoor_punched = function( pos, node, puncher ) local tool = puncher:get_wielded_item():get_name() - if tool and tool == "htspells:alohomora" then + if tool and tool == "unlockcharm:alohomora" then if string.find( node.name, 'harrytest:mdoor_wood' ) == nil then return end local upos = { x = pos.x, y = pos.y - 1, z = pos.z } diff --git a/harrytest/textures/door_wood.png b/harrytest/textures/door_wood.png deleted file mode 100644 index 120fc98..0000000 Binary files a/harrytest/textures/door_wood.png and /dev/null differ diff --git a/harrytest/textures/door_wood_a.png b/harrytest/textures/door_wood_a.png deleted file mode 100644 index 1617b65..0000000 Binary files a/harrytest/textures/door_wood_a.png and /dev/null differ diff --git a/harrytest/textures/door_wood_a_r.png b/harrytest/textures/door_wood_a_r.png deleted file mode 100644 index 9315b75..0000000 Binary files a/harrytest/textures/door_wood_a_r.png and /dev/null differ diff --git a/harrytest/textures/door_wood_b.png b/harrytest/textures/door_wood_b.png deleted file mode 100644 index 80d4315..0000000 Binary files a/harrytest/textures/door_wood_b.png and /dev/null differ diff --git a/harrytest/textures/door_wood_b_r.png b/harrytest/textures/door_wood_b_r.png deleted file mode 100644 index 9c53aa4..0000000 Binary files a/harrytest/textures/door_wood_b_r.png and /dev/null differ diff --git a/htspells/build_spell.lua b/htspells/build_spell.lua new file mode 100644 index 0000000..bf01be0 --- /dev/null +++ b/htspells/build_spell.lua @@ -0,0 +1,85 @@ +minetest.register_craftitem("htspells:arrow_build", { + description = "Build Arrow", + inventory_image = "htspells_arrow_build.png", +}) + +minetest.register_node("htspells:arrow_build_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"htspells_arrow_build.png", "htspells_arrow_build.png", "htspells_arrow_build_back.png", "htspells_arrow_build_front.png", "htspells_arrow_build_2.png", "htspells_arrow_build.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"htspells:arrow_build_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + node = "", +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.env:get_node(pos) + + if self.timer>0.2 then + local objs = minetest.env: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 ~= "htspells:arrow_build_entity" and obj:get_luaentity().name ~= "__builtin:item" then + if self.node ~= "" then + minetest.env:set_node(self.lastpos, {name=self.node}) + end + self.object:remove() + end + else + if self.node ~= "" then + minetest.env:set_node(self.lastpos, {name=self.node}) + end + self.object:remove() + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + if self.node ~= "" then + minetest.env:set_node(self.lastpos, {name=self.node}) + end + self.object:remove() + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("htspells:arrow_build_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'htspells:arrow_build', + recipe = { + {'default:stick', 'default:stick', 'default:shovel_steel'}, + } +}) diff --git a/htspells/depends.txt b/htspells/depends.txt index 562cf63..6a36d03 100644 --- a/htspells/depends.txt +++ b/htspells/depends.txt @@ -1 +1,3 @@ -default +default +bucket +fire diff --git a/htspells/dig_spell.lua b/htspells/dig_spell.lua new file mode 100644 index 0000000..06ae096 --- /dev/null +++ b/htspells/dig_spell.lua @@ -0,0 +1,81 @@ +minetest.register_craftitem("htspells:arrow_dig", { + description = "Dig Arrow", + inventory_image = "htspells_arrow_dig.png", +}) + +minetest.register_node("htspells:arrow_dig_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"htspells_arrow_dig.png", "htspells_arrow_dig.png", "htspells_arrow_dig_back.png", "htspells_arrow_dig_front.png", "htspells_arrow_dig_2.png", "htspells_arrow_dig.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"htspells:arrow_dig_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.env:get_node(pos) + + if self.timer>0.2 then + local objs = minetest.env: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 ~= "htspells:arrow_dig_entity" and obj:get_luaentity().name ~= "__builtin:item" then + minetest.env:add_item(pos, 'htspells:arrow_dig') + minetest.env:remove_node(pos) + self.object:remove() + end + else + minetest.env:add_item(pos, 'htspells:arrow_dig') + minetest.env:remove_node(pos) + self.object:remove() + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + minetest.env:add_item(self.lastpos, 'htspells:arrow_dig') + minetest.env:remove_node(pos) + self.object:remove() + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("htspells:arrow_dig_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'htspells:arrow_dig', + recipe = { + {'default:stick', 'default:stick', 'default:pick_steel'}, + } +}) diff --git a/htspells/fire_spell.lua b/htspells/fire_spell.lua new file mode 100644 index 0000000..1f08d21 --- /dev/null +++ b/htspells/fire_spell.lua @@ -0,0 +1,125 @@ +minetest.register_craftitem("htspells:spell_fire", { + description = "Incendio", + inventory_image = "htspells_spell_fire.png", +}) + +minetest.register_node("htspells:spell_fire_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"htspells_spell_fire.png", "htspells_spell_fire.png", "htspells_spell_fire_back.png", "htspells_spell_fire_front.png", "htspells_spell_fire_2.png", "htspells_spell_fire.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local HTSPELLS_SPELL_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"htspells:spell_fire_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +HTSPELLS_SPELL_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.env:get_node(pos) + + if self.timer>0.2 then + local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "htspells:spell_fire_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local damage = 5 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + groupcaps={ + fleshy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}}, + snappy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}}, + } + }, nil) + self.object:remove() + end + else + local damage = 5 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + groupcaps={ + fleshy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}}, + snappy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}}, + } + }, nil) + self.object:remove() + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" and node.name ~= "htspells:light" then + minetest.env:set_node(self.lastpos, {name="fire:basic_flame"}) + self.object:remove() + end + if math.floor(self.lastpos.x+0.5) ~= math.floor(pos.x+0.5) or math.floor(self.lastpos.y+0.5) ~= math.floor(pos.y+0.5) or math.floor(self.lastpos.z+0.5) ~= math.floor(pos.z+0.5) then + if minetest.env:get_node(self.lastpos).name == "htspells:light" then + minetest.env:remove_node(self.lastpos) + end + if minetest.env:get_node(pos).name == "air" then + minetest.env:set_node(pos, {name="htspells:light"}) + end + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("htspells:spell_fire_entity", HTSPELLS_SPELL_ENTITY) + +minetest.register_craft({ + output = 'htspells:spell_fire 4', + recipe = { + {'default:stick', 'default:stick', 'bucket:bucket_lava'}, + }, + replacements = { + {"bucket:bucket_lava", "bucket:bucket_empty"} + } +}) + +minetest.register_node("htspells:light", { + drawtype = "glasslike", + tiles = {"htspells_empty.png"}, + light_source = LIGHT_MAX-4, + selection_box = { + type = "fixed", + fixed = { + {0,0,0,0,0,0} + } + }, + groups = {not_in_creative_inventory=1} +}) + +minetest.register_abm({ + nodenames = {"htspells:light"}, + interval = 10, + chance = 1, + action = function(pos, node) + minetest.env:remove_node(pos) + end +}) diff --git a/htspells/init.lua b/htspells/init.lua index 9702cd3..f878243 100644 --- a/htspells/init.lua +++ b/htspells/init.lua @@ -1,124 +1,99 @@ ---[ ---PotterTest Mod Made by LandMine ---This subfolder of the mod contains all spells ---Licence: WTFPL ---] - ----Functions - - --- Spells - - -----1. Aguamenti - Sends out water - -minetest.register_tool("htspells:aguamenti", { - description = "Aguamenti Spell", - inventory_image = "aqua.png", - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=1, - groupcaps={ - fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2}, - snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1}, - choppy={times={[3]=0.70}, uses=40, maxlevel=0} - } - }, - on_use = function(itemstack, user, pointed_thing) - minetest.env:set_node(pointed_thing.above, {name="default:water_source"}) - end -}) - -----2. Incendio - Sends out fire - -minetest.register_tool("htspells:incendio", { - description = "Inendio Spell", - inventory_image = "flame.png", - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=1, - groupcaps={ - fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2}, - snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1}, - choppy={times={[3]=0.70}, uses=40, maxlevel=0} - } - }, - on_use = function(itemstack, user, pointed_thing) - minetest.env:set_node(pointed_thing.above, {name="fire:basic_flame"}) - end -}) - -----3. Alohomora - Unlocks doors -minetest.register_tool("htspells:alohomora", { - description = "Alohomora Spell", - inventory_image = "key.png", - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=1, - groupcaps={ - fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2}, - snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1}, - choppy={times={[3]=0.70}, uses=40, maxlevel=0} - } - } -}) - -----4. Lumos - Illuminates the tip of the caster's wand. -minetest.register_tool("htspells:lumos", { - description = "Lumos Spell", - inventory_image = "lumos.png", - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=1, - groupcaps={ - fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2}, - snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1}, - choppy={times={[3]=0.70}, uses=40, maxlevel=0} - } - }, - on_use = function(itemstack, user, pointed_thing) - minetest.env:set_node(pointed_thing.above, {name="default:torch"}) - end -}) - - -----5. Bombarda - Provokes a small explosion. - -minetest.register_tool("htspells:bombarda", { - description = "Bombarda Spell", - inventory_image = "flame.png", - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=1, - groupcaps={ - fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2}, - snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1}, - choppy={times={[3]=0.70}, uses=40, maxlevel=0} - } - }, - on_use = function(itemstack, user, pointed_thing) - boom(pos) - end -}) - -minetest.register_entity("htspells:smoke", { - physical = true, - visual = "sprite", - textures = {"smoke.png"}, - collisionbox = {0,0,0,0,0,0}, - - timer = 0, - time = 5, - - on_activate = function(self, staticdata) - self.object:setacceleration({x=math.random(0,10)/10-0.5, y=5, z=math.random(0,10)/10-0.5}) - self.time = math.random(1, 10)/10 - end, - - on_step = function(self, dtime) - self.timer = self.timer+dtime - if self.timer > self.time then - self.object:remove() - end - end, -}) \ No newline at end of file +spells = { + {"htspells:spell", "htspells:spell_entity"}, + {"htspells:spell_fire", "htspells:spell_fire_entity"}, + {"htspells:spell_teleport", "htspells:spell_teleport_entity"}, + {"htspells:spell_dig", "htspells:spell_dig_entity"}, + {"htspells:spell_build", "htspells:spell_build_entity"} +} + +local htspells_shoot_spell = function(itemstack, player) + for _,stack in ipairs(player:get_inventory():get_list("main")) do + for _,spell in ipairs(spells) do + if stack:get_name() == spell[1] then + player:get_inventory():remove_item("main", spell[1]) + local playerpos = player:getpos() + local obj = minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spell[2]) + local dir = player:get_look_dir() + obj:setvelocity({x=dir.x*19, y=dir.y*19, z=dir.z*19}) + obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3}) + obj:setyaw(player:get_look_yaw()+math.pi) + minetest.sound_play("throwing_sound", {pos=playerpos}) + if obj:get_luaentity().player == "" then + obj:get_luaentity().player = player + end + obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name() + return true + end + end + end + return false +end + +minetest.register_tool("htspells:wand_basic", { + description = "Basic Wand", + inventory_image = "wand2.png", + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + if htspells_shoot_spell(itemstack, user, pointed_thing) then + itemstack:add_wear(65535/50) + end + return itemstack + end, +}) + +minetest.register_craft({ + output = 'htspells:wand_basic', + recipe = { + {'', '', ''}, + {'', 'default:stick', ''}, + {'default:stick', 'default:stick', 'default:stick'}, + } +}) + +minetest.register_tool("htspells:wand_normal", { + description = "Wand", + inventory_image = "wand3.png", + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + if htspells_shoot_spell(item, user, pointed_thing) then + itemstack:add_wear(65535/100) + end + return itemstack + end, +}) + +minetest.register_craft({ + output = 'htspells:wand_normal', + recipe = { + {'', '', ''}, + {'default:stick', 'default:stick', 'default:stick'}, + {'default:stick', 'default:stick', 'default:stick'}, + } +}) + +minetest.register_tool("htspells:wand_advanced", { + description = "Advanced Wand", + inventory_image = "wand4.png", + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + if htspells_shoot_spell(item, user, pointed_thing) then + itemstack:add_wear(65535/200) + end + return itemstack + end, +}) + +minetest.register_craft({ + output = 'htspells:wand_advanced', + recipe = { + {'', '', ''}, + {'default:stick', 'default:stick', ''}, + {'default:stick', 'default:stick', 'default:stick'}, + } +}) + +dofile(minetest.get_modpath("htspells").."/spell.lua") +dofile(minetest.get_modpath("htspells").."/fire_spell.lua") +dofile(minetest.get_modpath("htspells").."/teleport_spell.lua") +dofile(minetest.get_modpath("htspells").."/dig_spell.lua") +dofile(minetest.get_modpath("htspells").."/build_spell.lua") \ No newline at end of file diff --git a/htspells/sounds/throwing_sound.ogg b/htspells/sounds/throwing_sound.ogg new file mode 100644 index 0000000..c8911e5 Binary files /dev/null and b/htspells/sounds/throwing_sound.ogg differ diff --git a/htspells/spell.lua b/htspells/spell.lua new file mode 100644 index 0000000..416489d --- /dev/null +++ b/htspells/spell.lua @@ -0,0 +1,92 @@ +minetest.register_craftitem("htspells:spell", { + description = "Spell", + inventory_image = "htspells_spell.png", +}) + +minetest.register_node("htspells:spell_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"htspells_spell.png", "htspells_spell.png", "htspells_spell_back.png", "htspells_spell_front.png", "htspells_spell_2.png", "htspells_spell.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local HTSPELLS_SPELL_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"htspells:spell_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +HTSPELLS_SPELL_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.env:get_node(pos) + + if self.timer>0.2 then + local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "htspells:spell_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local damage = 3 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + groupcaps={ + fleshy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}}, + snappy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}}, + } + }, nil) + self.object:remove() + end + else + local damage = 3 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + groupcaps={ + fleshy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}}, + snappy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}}, + } + }, nil) + self.object:remove() + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + minetest.env:add_item(self.lastpos, 'htspells:spell') + self.object:remove() + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("htspells:spell_entity", HTSPELLS_SPELL_ENTITY) + +minetest.register_craft({ + output = 'htspells:spell 16', + recipe = { + {'default:stick', 'default:stick', 'default:steel_ingot'}, + } +}) diff --git a/htspells/teleport_spell.lua b/htspells/teleport_spell.lua new file mode 100644 index 0000000..6c94490 --- /dev/null +++ b/htspells/teleport_spell.lua @@ -0,0 +1,88 @@ +minetest.register_craftitem("htspells:arrow_teleport", { + description = "Teleport Arrow", + inventory_image = "htspells_arrow_teleport.png", +}) + +minetest.register_node("htspells:arrow_teleport_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"htspells_arrow_teleport.png", "htspells_arrow_teleport.png", "htspells_arrow_teleport_back.png", "htspells_arrow_teleport_front.png", "htspells_arrow_teleport_2.png", "htspells_arrow_teleport.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"htspells:arrow_teleport_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + player = "", +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.env:get_node(pos) + + if self.timer>0.2 then + local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "htspells:arrow_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then + if self.player ~= "" then + self.player:setpos(pos) + self.player:get_inventory():add_item("main", ItemStack("htspells:arrow_teleport")) + end + self.object:remove() + end + else + if self.player ~= "" then + self.player:setpos(pos) + self.player:get_inventory():add_item("main", ItemStack("htspells:arrow_teleport")) + end + self.object:remove() + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + if self.player ~= "" then + self.player:setpos(self.lastpos) + self.player:get_inventory():add_item("main", ItemStack("htspells:arrow_teleport")) + end + self.object:remove() + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("htspells:arrow_teleport_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'htspells:arrow_teleport', + recipe = { + {'default:stick', 'default:stick', 'default:mese'}, + } +}) diff --git a/htspells/textures/aqua.png b/htspells/textures/aqua.png deleted file mode 100644 index 88b15a0..0000000 Binary files a/htspells/textures/aqua.png and /dev/null differ diff --git a/htspells/textures/boom.png b/htspells/textures/boom.png deleted file mode 100644 index 5588723..0000000 Binary files a/htspells/textures/boom.png and /dev/null differ diff --git a/htspells/textures/flame.png b/htspells/textures/flame.png deleted file mode 100644 index 905a977..0000000 Binary files a/htspells/textures/flame.png and /dev/null differ diff --git a/htspells/textures/htspells_empty.png b/htspells/textures/htspells_empty.png new file mode 100644 index 0000000..6bbd554 Binary files /dev/null and b/htspells/textures/htspells_empty.png differ diff --git a/htspells/textures/htspells_spell.png b/htspells/textures/htspells_spell.png new file mode 100644 index 0000000..9cf98b2 Binary files /dev/null and b/htspells/textures/htspells_spell.png differ diff --git a/htspells/textures/htspells_spell_2.png b/htspells/textures/htspells_spell_2.png new file mode 100644 index 0000000..058075d Binary files /dev/null and b/htspells/textures/htspells_spell_2.png differ diff --git a/htspells/textures/htspells_spell_back.png b/htspells/textures/htspells_spell_back.png new file mode 100644 index 0000000..0f8dd5d Binary files /dev/null and b/htspells/textures/htspells_spell_back.png differ diff --git a/htspells/textures/htspells_spell_fire.png b/htspells/textures/htspells_spell_fire.png new file mode 100644 index 0000000..871843c Binary files /dev/null and b/htspells/textures/htspells_spell_fire.png differ diff --git a/htspells/textures/htspells_spell_fire_2.png b/htspells/textures/htspells_spell_fire_2.png new file mode 100644 index 0000000..0617b3e Binary files /dev/null and b/htspells/textures/htspells_spell_fire_2.png differ diff --git a/htspells/textures/htspells_spell_fire_back.png b/htspells/textures/htspells_spell_fire_back.png new file mode 100644 index 0000000..0caee6a Binary files /dev/null and b/htspells/textures/htspells_spell_fire_back.png differ diff --git a/htspells/textures/htspells_spell_fire_front.png b/htspells/textures/htspells_spell_fire_front.png new file mode 100644 index 0000000..7492c3a Binary files /dev/null and b/htspells/textures/htspells_spell_fire_front.png differ diff --git a/htspells/textures/htspells_spell_front.png b/htspells/textures/htspells_spell_front.png new file mode 100644 index 0000000..8cf670e Binary files /dev/null and b/htspells/textures/htspells_spell_front.png differ diff --git a/htspells/textures/lumos.png b/htspells/textures/lumos.png deleted file mode 100644 index 4513fd1..0000000 Binary files a/htspells/textures/lumos.png and /dev/null differ diff --git a/htspells/textures/smoke.png b/htspells/textures/smoke.png deleted file mode 100644 index 6c07c30..0000000 Binary files a/htspells/textures/smoke.png and /dev/null differ diff --git a/htspells/textures/throwing_arrow_build.png b/htspells/textures/throwing_arrow_build.png new file mode 100644 index 0000000..02653e1 Binary files /dev/null and b/htspells/textures/throwing_arrow_build.png differ diff --git a/htspells/textures/throwing_arrow_build_2.png b/htspells/textures/throwing_arrow_build_2.png new file mode 100644 index 0000000..fd576d4 Binary files /dev/null and b/htspells/textures/throwing_arrow_build_2.png differ diff --git a/htspells/textures/throwing_arrow_build_back.png b/htspells/textures/throwing_arrow_build_back.png new file mode 100644 index 0000000..18c2f02 Binary files /dev/null and b/htspells/textures/throwing_arrow_build_back.png differ diff --git a/htspells/textures/throwing_arrow_build_front.png b/htspells/textures/throwing_arrow_build_front.png new file mode 100644 index 0000000..b6b6967 Binary files /dev/null and b/htspells/textures/throwing_arrow_build_front.png differ diff --git a/htspells/textures/throwing_arrow_dig.png b/htspells/textures/throwing_arrow_dig.png new file mode 100644 index 0000000..02f6a00 Binary files /dev/null and b/htspells/textures/throwing_arrow_dig.png differ diff --git a/htspells/textures/throwing_arrow_dig_2.png b/htspells/textures/throwing_arrow_dig_2.png new file mode 100644 index 0000000..b514b5d Binary files /dev/null and b/htspells/textures/throwing_arrow_dig_2.png differ diff --git a/htspells/textures/throwing_arrow_dig_back.png b/htspells/textures/throwing_arrow_dig_back.png new file mode 100644 index 0000000..9742257 Binary files /dev/null and b/htspells/textures/throwing_arrow_dig_back.png differ diff --git a/htspells/textures/throwing_arrow_dig_front.png b/htspells/textures/throwing_arrow_dig_front.png new file mode 100644 index 0000000..6681c99 Binary files /dev/null and b/htspells/textures/throwing_arrow_dig_front.png differ diff --git a/htspells/textures/throwing_arrow_teleport.png b/htspells/textures/throwing_arrow_teleport.png new file mode 100644 index 0000000..f95d3e8 Binary files /dev/null and b/htspells/textures/throwing_arrow_teleport.png differ diff --git a/htspells/textures/throwing_arrow_teleport_2.png b/htspells/textures/throwing_arrow_teleport_2.png new file mode 100644 index 0000000..6e8eaa9 Binary files /dev/null and b/htspells/textures/throwing_arrow_teleport_2.png differ diff --git a/htspells/textures/throwing_arrow_teleport_back.png b/htspells/textures/throwing_arrow_teleport_back.png new file mode 100644 index 0000000..e0bba02 Binary files /dev/null and b/htspells/textures/throwing_arrow_teleport_back.png differ diff --git a/htspells/textures/throwing_arrow_teleport_front.png b/htspells/textures/throwing_arrow_teleport_front.png new file mode 100644 index 0000000..80138c4 Binary files /dev/null and b/htspells/textures/throwing_arrow_teleport_front.png differ diff --git a/htspells/textures/wand.png b/htspells/textures/wand.png new file mode 100644 index 0000000..5ad7b4b Binary files /dev/null and b/htspells/textures/wand.png differ diff --git a/htspells/textures/wand2.png b/htspells/textures/wand2.png new file mode 100644 index 0000000..da78464 Binary files /dev/null and b/htspells/textures/wand2.png differ diff --git a/htspells/textures/wand3.png b/htspells/textures/wand3.png new file mode 100644 index 0000000..37c4682 Binary files /dev/null and b/htspells/textures/wand3.png differ diff --git a/htspells/textures/wand4.png b/htspells/textures/wand4.png new file mode 100644 index 0000000..329710e Binary files /dev/null and b/htspells/textures/wand4.png differ diff --git a/unlockcharm/depends.txt b/unlockcharm/depends.txt new file mode 100644 index 0000000..562cf63 --- /dev/null +++ b/unlockcharm/depends.txt @@ -0,0 +1 @@ +default diff --git a/unlockcharm/init.lua b/unlockcharm/init.lua new file mode 100644 index 0000000..9598b91 --- /dev/null +++ b/unlockcharm/init.lua @@ -0,0 +1,25 @@ +--[ +--PotterTest Mod Made by LandMine +--This subfolder of the mod contains all spells +--Licence: WTFPL +--] + +---Functions + + +-- Spells + +----3. Alohomora - Unlocks doors +minetest.register_tool("unlockcharm:alohomora", { + description = "Alohomora Spell", + inventory_image = "key.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2}, + snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1}, + choppy={times={[3]=0.70}, uses=40, maxlevel=0} + } + } +}) diff --git a/htspells/readme.txt b/unlockcharm/readme.txt similarity index 100% rename from htspells/readme.txt rename to unlockcharm/readme.txt diff --git a/htspells/textures/key.png b/unlockcharm/textures/key.png similarity index 100% rename from htspells/textures/key.png rename to unlockcharm/textures/key.png