Add mob support
|
@ -4,7 +4,7 @@ function magic.register_mapgen()
|
|||
deco_type = "simple",
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 80,
|
||||
fill_ratio = 0.001,
|
||||
fill_ratio = 0.00025,
|
||||
biomes = {"rainforest", "deciduous_forest", "coniferous_forest"},
|
||||
y_min = 1,
|
||||
y_max = 31000,
|
||||
|
|
|
@ -24,6 +24,20 @@ function magic.register_spell(name, def)
|
|||
minetest.register_craftitem(name, item_def)
|
||||
end
|
||||
|
||||
-- Convert all damage to fleshy.
|
||||
function magic.damage_obj(obj, groups)
|
||||
local x = 0
|
||||
local armor = obj:get_armor_groups()
|
||||
for k,v in pairs(groups) do
|
||||
local percent = 1
|
||||
if k ~= 'fleshy' then
|
||||
percent = armor.fleshy / 100
|
||||
end
|
||||
x = x + (v / percent)
|
||||
end
|
||||
obj:punch(obj, 1.0, {full_punch_interval=1.0, damage_groups={fleshy=x}, nil})
|
||||
end
|
||||
|
||||
magic.register_spell("magic:spell_fire", {
|
||||
description = "Fire Spell",
|
||||
type = "missile",
|
||||
|
@ -47,6 +61,14 @@ magic.register_spell("magic:spell_fire", {
|
|||
end
|
||||
return false
|
||||
end,
|
||||
hit_object = function(self, pos, obj)
|
||||
magic.damage_obj(obj, {fire = 4})
|
||||
return true
|
||||
end,
|
||||
hit_player = function(self, pos, obj)
|
||||
magic.damage_obj(obj, {fire=4})
|
||||
return true
|
||||
end,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "magic:spell_fire",
|
||||
|
@ -76,7 +98,7 @@ if rawget(_G, 'tnt') and tnt.boom then
|
|||
speed = 15,
|
||||
cost = 6,
|
||||
hit_node = hit_node,
|
||||
hit_object = function(self, pos)
|
||||
hit_object = function(self, pos, obj)
|
||||
return hit_node(self, pos)
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- Throwing movement physics.
|
||||
|
||||
local safe_ents = {
|
||||
NO_HIT_ENTS = {
|
||||
["__builtin:item"] = true,
|
||||
["itemframes:item"] = true,
|
||||
["xdecor:f_item"] = true,
|
||||
|
@ -190,11 +190,11 @@ function magic.register_missile(name, texture, def, item_def)
|
|||
for k, obj in pairs(objs) do
|
||||
local bb = obj:get_properties().collisionbox
|
||||
-- If bb collides with line...
|
||||
local b1 = vector.add(obj:getpos(), {x=bb[1], y=bb[2], z=bb[3]})
|
||||
local b2 = vector.add(obj:getpos(), {x=bb[4], y=bb[5], z=bb[6]})
|
||||
local b1 = vector.add(obj:getpos(), vector.multiply({x=bb[1], y=bb[2], z=bb[3]}, 1.5))
|
||||
local b2 = vector.add(obj:getpos(), vector.multiply({x=bb[4], y=bb[5], z=bb[6]}, 1.5))
|
||||
if CheckLineBox(b1, b2, line.start, line.finish) or CheckLineNear(line, obj:getpos(), 1) then
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= name and not safe_ents[obj:get_luaentity().name] then
|
||||
if obj:get_luaentity().name ~= name and not NO_HIT_ENTS[obj:get_luaentity().name] then
|
||||
if def.hit_object(self, obj:getpos(), obj) then
|
||||
self.object:remove()
|
||||
end
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
wtfpl licenses
|
||||
2015 by Glünggi
|
|
@ -1 +0,0 @@
|
|||
default
|
125
refruit/init.lua
|
@ -1,125 +0,0 @@
|
|||
-- refruit for minetest
|
||||
-- makes fruits regrowing on the trees.
|
||||
-- images and code are WTFPL license (2015 by Glünggi)
|
||||
refruit = {}
|
||||
|
||||
--replacement
|
||||
minetest.register_node(":default:apple", {
|
||||
description = "Apple",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"default_apple.png"},
|
||||
inventory_image = "default_apple.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
|
||||
},
|
||||
groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
|
||||
on_use = minetest.item_eat(2),
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
if placer:is_player() then
|
||||
minetest.set_node(pos, {name="default:apple", param2=1})
|
||||
end
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if oldnode.name == "default:apple" then
|
||||
if oldnode.param2 ~= 0 then
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos,{name = "refruit:bud_apple"})
|
||||
else
|
||||
return
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--register nodes
|
||||
|
||||
minetest.register_node("refruit:bud_apple", {
|
||||
description = "Apple Bud",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"refruit_bud_apple.png"},
|
||||
inventory_image = "refruit_bud_apple.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.1875, -0.3125, -0.1875, 0.1875, 0.3125, 0.1875}
|
||||
},
|
||||
groups = {choppy=2,oddly_breakable_by_hand=3,flammable=2,leafdecay=3,leafdecay_drop=1,fruit=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'default:stick'},
|
||||
rarity = 99,
|
||||
},
|
||||
{
|
||||
items = {'default:stick'},
|
||||
rarity = 99
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("refruit:flower_apple", {
|
||||
description = "Apple Flower",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"refruit_flower_apple.png"},
|
||||
inventory_image = "refruit_flower_apple.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.1875, -0.3125, -0.1875, 0.1875, 0.3125, 0.1875}
|
||||
},
|
||||
groups = {choppy=2,oddly_breakable_by_hand=3,flammable=2,leafdecay=3,leafdecay_drop=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'default:stick'},
|
||||
rarity = 99,
|
||||
},
|
||||
{
|
||||
items = {'default:stick'},
|
||||
rarity = 99
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"refruit:bud_apple"},
|
||||
neighbors = {"group:leaves"},
|
||||
interval = 34,
|
||||
chance = 10,
|
||||
action = function(pos, node)
|
||||
minetest.set_node(pos, {name="refruit:flower_apple"})
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"refruit:flower_apple"},
|
||||
neighbors = {"group:leaves"},
|
||||
interval = 33,
|
||||
chance = 60,
|
||||
action = function(pos, node)
|
||||
minetest.set_node(pos, {name="default:apple"})
|
||||
end,
|
||||
})
|
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.6 KiB |
|
@ -137,12 +137,14 @@ local function entity_physics(pos, radius)
|
|||
local dist = math.max(1, vector.distance(pos, obj_pos))
|
||||
|
||||
if obj_vel ~= nil then
|
||||
obj:setvelocity(calc_velocity(pos, obj_pos,
|
||||
obj_vel, radius * 10))
|
||||
-- This causes serialization errors.
|
||||
-- obj:setvelocity(calc_velocity(pos, obj_pos,obj_vel, radius * 10))
|
||||
end
|
||||
|
||||
local damage = (4 / dist) * radius
|
||||
obj:set_hp(obj:get_hp() - damage)
|
||||
if not obj:get_luaentity() or not NO_HIT_ENTS[obj:get_luaentity().name] then
|
||||
magic.damage_obj(obj, {fleshy=damage/2, fire=damage/2})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|