Version MFF.
0
.gitattributes
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
README.txt
Normal file → Executable file
3
depends.txt
Normal file → Executable file
@ -1,3 +1,6 @@
|
|||||||
default
|
default
|
||||||
|
mobs
|
||||||
|
maptools
|
||||||
farming?
|
farming?
|
||||||
treasurer?
|
treasurer?
|
||||||
|
watershed?
|
||||||
|
42
init.lua
Normal file → Executable file
@ -1,4 +1,5 @@
|
|||||||
pyramids = {}
|
pyramids = {}
|
||||||
|
pyramids.max_time = 30*60
|
||||||
|
|
||||||
dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
||||||
dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
|
dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
|
||||||
@ -16,16 +17,21 @@ local chest_stuff = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pyramids.fill_chest(pos)
|
function pyramids.fill_chest(pos)
|
||||||
minetest.after(2, function()
|
local n = minetest.get_node_or_nil(pos)
|
||||||
local n = minetest.get_node(pos)
|
if n and n.name and n.name == "tsm_pyramids:chest" then
|
||||||
if n and n.name and n.name == "default:chest" then
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
|
inv:set_list("main",
|
||||||
|
{
|
||||||
|
[1] = "",
|
||||||
|
[32] = ""
|
||||||
|
}
|
||||||
|
)
|
||||||
if math.random(1,10) < 7 then return end
|
if math.random(1,10) < 7 then return end
|
||||||
local stacks = {}
|
local stacks = {}
|
||||||
if minetest.get_modpath("treasurer") ~= nil then
|
if minetest.get_modpath("treasurer") ~= nil then
|
||||||
stacks = treasurer.select_random_treasures(3,7,9,{"minetool", "food", "crafting_component"})
|
stacks = treasurer.select_random_treasures()
|
||||||
else
|
else
|
||||||
for i=0,2,1 do
|
for i=0,2,1 do
|
||||||
local stuff = chest_stuff[math.random(1,#chest_stuff)]
|
local stuff = chest_stuff[math.random(1,#chest_stuff)]
|
||||||
@ -38,9 +44,7 @@ function pyramids.fill_chest(pos)
|
|||||||
inv:set_stack("main", math.random(1,32), stacks[s])
|
inv:set_stack("main", math.random(1,32), stacks[s])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_spawner(pos)
|
local function add_spawner(pos)
|
||||||
@ -67,7 +71,7 @@ local function underground(pos)
|
|||||||
while can_replace(p2)==true do
|
while can_replace(p2)==true do
|
||||||
cnt = cnt+1
|
cnt = cnt+1
|
||||||
if cnt > 25 then break end
|
if cnt > 25 then break end
|
||||||
if cnt>math.random(2,4) then mat = "desert_stone"end
|
if cnt>math.random(2,4) then mat = "desert_stone" end
|
||||||
minetest.set_node(p2, {name="default:"..mat})
|
minetest.set_node(p2, {name="default:"..mat})
|
||||||
p2.y = p2.y-1
|
p2.y = p2.y-1
|
||||||
end
|
end
|
||||||
@ -79,21 +83,21 @@ local function make_entrance(pos)
|
|||||||
for iz=0,6,1 do
|
for iz=0,6,1 do
|
||||||
minetest.remove_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz})
|
minetest.remove_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz})
|
||||||
if iz >=3 and iy == 3 then
|
if iz >=3 and iy == 3 then
|
||||||
minetest.set_node({x=gang.x,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"})
|
minetest.set_node({x=gang.x,y=gang.y+iy+1,z=gang.z+iz}, {name="maptools:sandstone_brick"})
|
||||||
minetest.set_node({x=gang.x+1,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"})
|
minetest.set_node({x=gang.x+1,y=gang.y+iy+1,z=gang.z+iz}, {name="maptools:sandstone_brick"})
|
||||||
minetest.set_node({x=gang.x+2,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"})
|
minetest.set_node({x=gang.x+2,y=gang.y+iy+1,z=gang.z+iz}, {name="maptools:sandstone_brick"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function make(pos)
|
function pyramids.make(pos)
|
||||||
minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")")
|
minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")")
|
||||||
for iy=0,10,1 do
|
for iy=0,10,1 do
|
||||||
for ix=iy,22-iy,1 do
|
for ix=iy,22-iy,1 do
|
||||||
for iz=iy,22-iy,1 do
|
for iz=iy,22-iy,1 do
|
||||||
if iy <1 then underground({x=pos.x+ix,y=pos.y,z=pos.z+iz}) end
|
if iy <1 then underground({x=pos.x+ix,y=pos.y,z=pos.z+iz}) end
|
||||||
minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name="default:sandstonebrick"})
|
minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name="maptools:sandstone_brick"})
|
||||||
for yy=1,10-iy,1 do
|
for yy=1,10-iy,1 do
|
||||||
local n = minetest.get_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz})
|
local n = minetest.get_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz})
|
||||||
if n and n.name and n.name == "default:desert_stone" then minetest.set_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz},{name="default:desert_sand"}) end
|
if n and n.name and n.name == "default:desert_stone" then minetest.set_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz},{name="default:desert_sand"}) end
|
||||||
@ -118,6 +122,7 @@ local function hlp_fnct(pos, name)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ground(pos, old)
|
local function ground(pos, old)
|
||||||
local p2 = pos
|
local p2 = pos
|
||||||
while hlp_fnct(p2, "air") do
|
while hlp_fnct(p2, "air") do
|
||||||
@ -132,14 +137,16 @@ end
|
|||||||
|
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
|
minetest.after(3, function(minp, maxp, seed)
|
||||||
|
|
||||||
if maxp.y < 0 then return end
|
if maxp.y < 0 then return end
|
||||||
math.randomseed(seed)
|
math.randomseed(seed)
|
||||||
local cnt = 0
|
local cnt = 0
|
||||||
|
|
||||||
local perlin1 = minetest.env:get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
|
local perlin1 = minetest.get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
|
||||||
local noise1 = perlin1:get2d({x=minp.x,y=minp.y})--,z=minp.z})
|
local noise1 = perlin1:get2d({x=minp.x,y=minp.y})--,z=minp.z})
|
||||||
|
|
||||||
if noise1 > 0.25 or noise1 < -0.26 then
|
if noise1 > 0.25 or noise1 < -0.26 and math.random(1,100) % 2 == 0 then -- Coward attempt to divide per 2 the spawn rate
|
||||||
local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
||||||
|
|
||||||
local p2 = minetest.find_node_near(mpos, 25, {"default:desert_sand"})
|
local p2 = minetest.find_node_near(mpos, 25, {"default:desert_sand"})
|
||||||
@ -169,9 +176,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
p2.y = p2.y - 3
|
p2.y = p2.y - 3
|
||||||
if p2.y < 0 then p2.y = 0 end
|
if p2.y < 0 then p2.y = 0 end
|
||||||
if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil or minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil or minetest.find_node_near(p2, 52, {"default:sandstonebrick"}) ~= nil then return end
|
if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil
|
||||||
|
or minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil
|
||||||
|
or minetest.find_node_near(p2, 52, {"maptools:sandstone_brick"}) ~= nil then return end
|
||||||
|
|
||||||
if math.random(0,10) > 7 then return end
|
if math.random(0,10) > 7 then return end
|
||||||
minetest.after(0.8,make,p2)
|
pyramids.make(p2)
|
||||||
end
|
end
|
||||||
|
end, minp, maxp, seed)
|
||||||
end)
|
end)
|
||||||
|
BIN
models/tsm_pyramids_hit.png
Normal file → Executable file
Before Width: | Height: | Size: 214 B After Width: | Height: | Size: 175 B |
BIN
models/tsm_pyramids_mummy.png
Normal file → Executable file
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.4 KiB |
0
models/tsm_pyramids_mummy.x
Normal file → Executable file
529
mummy.lua
Normal file → Executable file
@ -1,98 +1,156 @@
|
|||||||
--pyramids = {}
|
-- Pyramid mummy
|
||||||
|
|
||||||
local mummy_walk_limit = 1
|
mobs:register_mob("tsm_pyramids:mummy", {
|
||||||
local mummy_chillaxin_speed = 1
|
-- animal, monster, npc, barbarian
|
||||||
local mummy_animation_speed = 10
|
type = "monster",
|
||||||
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
-- aggressive, deals 4 damage to player when hit
|
||||||
local mummy_animation_blend = 0
|
passive = false,
|
||||||
|
attack_type = "dogfight",
|
||||||
-- Default player appearance
|
damage = 4,
|
||||||
local mummy_mesh = "tsm_pyramids_mummy.x"
|
-- health & armor
|
||||||
local mummy_texture = {"tsm_pyramids_mummy.png"}
|
hp_min = 15, hp_max = 20, armor = 100,
|
||||||
local mummy_hp = 20
|
-- textures and model
|
||||||
local mummy_drop = "default:papyrus"
|
|
||||||
|
|
||||||
local sound_normal = "mummy"
|
|
||||||
local sound_hit = "mummy_hurt"
|
|
||||||
local sound_dead = "mummy_death"
|
|
||||||
|
|
||||||
local spawner_range = 17
|
|
||||||
local spawner_max_mobs = 6
|
|
||||||
|
|
||||||
local function get_animations()
|
|
||||||
return {
|
|
||||||
stand_START = 74,
|
|
||||||
stand_END = 74,
|
|
||||||
sit_START = 81,
|
|
||||||
sit_END = 160,
|
|
||||||
lay_START = 162,
|
|
||||||
lay_END = 166,
|
|
||||||
walk_START = 74,
|
|
||||||
walk_END = 105,
|
|
||||||
mine_START = 74,
|
|
||||||
mine_END = 105,
|
|
||||||
walk_mine_START = 74,
|
|
||||||
walk_mine_END = 105
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local npc_model = {}
|
|
||||||
local npc_anim = {}
|
|
||||||
local npc_sneak = {}
|
|
||||||
local ANIM_STAND = 1
|
|
||||||
local ANIM_SIT = 2
|
|
||||||
local ANIM_LAY = 3
|
|
||||||
local ANIM_WALK = 4
|
|
||||||
local ANIM_WALK_MINE = 5
|
|
||||||
local ANIM_MINE = 6
|
|
||||||
|
|
||||||
function hit(self)
|
|
||||||
prop = {
|
|
||||||
mesh = mummy_mesh,
|
|
||||||
textures = {"tsm_pyramids_mummy.png^tsm_pyramids_hit.png"},
|
|
||||||
}
|
|
||||||
self.object:set_properties(prop)
|
|
||||||
minetest.after(0.4, function()
|
|
||||||
prop = {textures = mummy_texture,}
|
|
||||||
self.object:set_properties(prop)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mummy_update_visuals_def(self)
|
|
||||||
--local name = get_player_name()
|
|
||||||
visual = default_model_def
|
|
||||||
npc_anim = 0 -- Animation will be set further below immediately
|
|
||||||
--npc_sneak[name] = false
|
|
||||||
prop = {
|
|
||||||
mesh = mummy_mesh,
|
|
||||||
textures = mummy_texture,
|
|
||||||
--visual_size = {x=1, y=1, z=1},
|
|
||||||
}
|
|
||||||
self.object:set_properties(prop)
|
|
||||||
end
|
|
||||||
|
|
||||||
MUMMY_DEF = {
|
|
||||||
physical = true,
|
|
||||||
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
|
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
|
mesh = "tsm_pyramids_mummy.x",
|
||||||
|
drawtype = "front",
|
||||||
|
textures = {
|
||||||
|
{"tsm_pyramids_mummy.png"},
|
||||||
|
},
|
||||||
visual_size = {x=8,y=8},
|
visual_size = {x=8,y=8},
|
||||||
mesh = mummy_mesh,
|
blood_texture = "default_sand.png",
|
||||||
textures = mummy_texture,
|
-- sounds
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
npc_anim = 0,
|
sounds = {
|
||||||
timer = 0,
|
random = "mummy",
|
||||||
turn_timer = 0,
|
},
|
||||||
vec = 0,
|
-- speed and jump, sinks in water
|
||||||
yaw = 0,
|
walk_velocity = 0.4,
|
||||||
yawwer = 0,
|
run_velocity = 0.8,
|
||||||
state = 1,
|
view_range = 16,
|
||||||
jump_timer = 0,
|
jump = false,
|
||||||
punch_timer = 0,
|
floats = 0,
|
||||||
sound_timer = 0,
|
knock_back = 0.1, --this is a test
|
||||||
attacker = "",
|
-- drops papyrus when dead
|
||||||
attacking_timer = 0,
|
drops = {
|
||||||
mob_name = "mummy"
|
{name = "default:papyrus",
|
||||||
}
|
chance = 2, min = 4, max = 6,},
|
||||||
|
{name = "maptools:silver_coin",
|
||||||
|
chance = 10, min = 1, max = 1,},
|
||||||
|
},
|
||||||
|
-- damaged by
|
||||||
|
water_damage = 0,
|
||||||
|
lava_damage = 15,
|
||||||
|
light_damage = 15,
|
||||||
|
-- model animation
|
||||||
|
animation = {
|
||||||
|
speed_normal = 15, speed_run = 15,
|
||||||
|
stand_start = 74, stand_end = 74,
|
||||||
|
walk_start = 74, walk_end = 105,
|
||||||
|
run_start = 74, run_end = 105,
|
||||||
|
punch_start = 74, punch_end = 105,
|
||||||
|
sit_start = 81, sit_end = 160,
|
||||||
|
lay_start = 162, lay_end = 166,
|
||||||
|
mine_start = 74, mine_end = 105,
|
||||||
|
walk_mine_start = 74, walk_mine_end = 105,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
--MFF ABM to replace old maptools:chest
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"tsm_pyramids:spawner_mummy"},
|
||||||
|
interval = 10.0,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
local chests = minetest.find_nodes_in_area(
|
||||||
|
{x=pos.x-4, y=pos.y-3, z=pos.z-10},
|
||||||
|
{x=pos.x+4, y=pos.y, z=pos.z},
|
||||||
|
"maptools:chest"
|
||||||
|
)
|
||||||
|
for _, cpos in ipairs(chests) do
|
||||||
|
local p2 = 0
|
||||||
|
local n = minetest.get_node_or_nil(cpos)
|
||||||
|
if n and n.param2 then
|
||||||
|
p2 = n.param2
|
||||||
|
end
|
||||||
|
minetest.set_node(cpos, {name="tsm_pyramids:chest", param2=p2})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
-- spawner (spawn in pyramids, near the spawner)
|
||||||
|
if not minetest.setting_getbool("only_peaceful_mobs") then
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"tsm_pyramids:spawner_mummy"},
|
||||||
|
interval = 10.0,
|
||||||
|
chance = 20,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
local player_near = false
|
||||||
|
local mobs = 0
|
||||||
|
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 17)) do
|
||||||
|
if obj then
|
||||||
|
if obj:is_player() then
|
||||||
|
player_near = true
|
||||||
|
else
|
||||||
|
if obj:get_luaentity() and obj:get_luaentity().mob_name == "mummy" then mobs = mobs + 1 end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if player_near then
|
||||||
|
if mobs < 6 then
|
||||||
|
pos.x = pos.x+1
|
||||||
|
local p = minetest.find_node_near(pos, 5, {"air"})
|
||||||
|
minetest.add_entity(p,"tsm_pyramids:mummy")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function pyramids.spawn_mummy (pos, number)
|
||||||
|
for i=0,number do
|
||||||
|
minetest.add_entity(pos,"tsm_pyramids:mummy")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("tsm_pyramids:spawner_mummy", {
|
||||||
|
description = "Mummy spawner",
|
||||||
|
paramtype = "light",
|
||||||
|
tiles = {"tsm_pyramids_spawner.png"},
|
||||||
|
is_ground_content = true,
|
||||||
|
drawtype = "allfaces",--_optional",
|
||||||
|
groups = {unbreakable=1},
|
||||||
|
drop = "",
|
||||||
|
on_construct = function(pos)
|
||||||
|
pos.y = pos.y - 0.28
|
||||||
|
minetest.add_entity(pos,"tsm_pyramids:mummy_spawner")
|
||||||
|
end,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||||
|
if not obj:is_player() then
|
||||||
|
if obj ~= nil and obj:get_luaentity().m_name == "dummy" then
|
||||||
|
obj:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- register spawn egg
|
||||||
|
minetest.register_craftitem("tsm_pyramids:spawn_egg", {
|
||||||
|
description = "Mummy spawn-egg",
|
||||||
|
inventory_image = "tsm_pyramids_mummy_egg.png",
|
||||||
|
liquids_pointable = false,
|
||||||
|
stack_max = 99,
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
if pointed_thing.type == "node" then
|
||||||
|
minetest.add_entity(pointed_thing.above,"tsm_pyramids:mummy")
|
||||||
|
if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Spawner entity
|
||||||
|
|
||||||
spawner_DEF = {
|
spawner_DEF = {
|
||||||
hp_max = 1,
|
hp_max = 1,
|
||||||
@ -100,8 +158,8 @@ spawner_DEF = {
|
|||||||
collisionbox = {0,0,0,0,0,0},
|
collisionbox = {0,0,0,0,0,0},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
visual_size = {x=3.3,y=3.3},
|
visual_size = {x=3.3,y=3.3},
|
||||||
mesh = mummy_mesh,
|
mesh = "tsm_pyramids_mummy.x",
|
||||||
textures = mummy_texture,
|
textures = {"tsm_pyramids_mummy.png"},
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
timer = 0,
|
timer = 0,
|
||||||
automatic_rotate = math.pi * 2.9,
|
automatic_rotate = math.pi * 2.9,
|
||||||
@ -130,282 +188,17 @@ spawner_DEF.on_punch = function(self, hitter)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
MUMMY_DEF.on_activate = function(self)
|
|
||||||
mummy_update_visuals_def(self)
|
|
||||||
self.anim = get_animations()
|
|
||||||
self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, mummy_animation_speed, mummy_animation_blend)
|
|
||||||
self.npc_anim = ANIM_STAND
|
|
||||||
self.object:setacceleration({x=0,y=-20,z=0})--20
|
|
||||||
self.state = 1
|
|
||||||
self.object:set_hp(mummy_hp)
|
|
||||||
self.object:set_armor_groups({fleshy=130})
|
|
||||||
end
|
|
||||||
|
|
||||||
MUMMY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
|
||||||
|
|
||||||
--attack as group
|
|
||||||
--[[for _,object in ipairs(minetest.env:get_objects_inside_radius(self.object:getpos(), 5)) do
|
|
||||||
if not object:is_player() then
|
|
||||||
if object:get_luaentity().name == "peaceful_npc:npc_def" then
|
|
||||||
object:get_luaentity().state = 3
|
|
||||||
object:get_luaentity().attacker = puncher:get_player_name()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end]]
|
|
||||||
|
|
||||||
--if self.state ~= 3 then
|
|
||||||
--self.state = 3
|
|
||||||
self.attacker = puncher--:get_player_name()
|
|
||||||
--end
|
|
||||||
|
|
||||||
if puncher ~= nil then
|
|
||||||
local sound = sound_hit
|
|
||||||
if self.object:get_hp() == 0 then sound = sound_dead end
|
|
||||||
minetest.sound_play(sound, {to_player = puncher:get_player_name(), loop = false, gain = 0.3})
|
|
||||||
if time_from_last_punch >= 0.45 then
|
|
||||||
hit(self)
|
|
||||||
--local dir = puncher:get_look_dir()
|
|
||||||
--self.direction = dir
|
|
||||||
self.direction = {x=self.object:getvelocity().x, y=self.object:getvelocity().y, z=self.object:getvelocity().z}
|
|
||||||
self.punch_timer = 0
|
|
||||||
self.object:setvelocity({x=dir.x*mummy_chillaxin_speed,y=5,z=dir.z*mummy_chillaxin_speed})--self.object:setvelocity({x=dir.x*4,y=5,z=dir.z*4})
|
|
||||||
if self.state == 1 then
|
|
||||||
self.state = 8
|
|
||||||
elseif self.state >= 2 then
|
|
||||||
self.state = 9
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.object:get_hp() == 0 then
|
|
||||||
local obj = minetest.env:add_item(self.object:getpos(), mummy_drop.." "..math.random(0,3))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local cnt1 = 0
|
|
||||||
local cnt2 = 0
|
|
||||||
|
|
||||||
MUMMY_DEF.on_step = function(self, dtime)
|
|
||||||
self.timer = self.timer + 0.01
|
|
||||||
self.turn_timer = self.turn_timer + 0.01
|
|
||||||
self.jump_timer = self.jump_timer + 0.01
|
|
||||||
self.punch_timer = self.punch_timer + 0.01
|
|
||||||
self.attacking_timer = self.attacking_timer + 0.01
|
|
||||||
self.sound_timer = self.sound_timer + 0.01
|
|
||||||
|
|
||||||
local current_pos = self.object:getpos()
|
|
||||||
local current_node = minetest.env:get_node(current_pos)
|
|
||||||
if self.time_passed == nil then
|
|
||||||
self.time_passed = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
--self.time_passed = self.time_passed + dtime
|
|
||||||
if self.object:get_hp() == 0 then-- self.object:remove() end
|
|
||||||
|
|
||||||
--if self.time_passed >= 5 then
|
|
||||||
minetest.sound_play(sound_dead, {pos = current_pos, max_hear_distance = 10 , gain = 0.3})
|
|
||||||
self.object:remove()
|
|
||||||
end--else
|
|
||||||
if current_node.name == "default:water_source" or current_node.name == "default:water_flowing" or current_node.name == "default:lava_source" or current_node.name == "default:lava_flowing" then
|
|
||||||
--self.time_passed = self.time_passed + dtime
|
|
||||||
self.sound_timer = self.sound_timer + dtime
|
|
||||||
if self.sound_timer >= 0.8 then
|
|
||||||
self.sound_timer = 0
|
|
||||||
self.object:set_hp(self.object:get_hp()-5)
|
|
||||||
hit(self)
|
|
||||||
minetest.sound_play(sound_hit, {pos = current_pos, max_hear_distance = 10, gain = 0.3})
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.time_passed = 0
|
|
||||||
end
|
|
||||||
--end
|
|
||||||
|
|
||||||
--update moving state every 1 or 2 seconds
|
|
||||||
if self.state < 3 then
|
|
||||||
if self.timer > math.random(1,2) then
|
|
||||||
if self.attacker == "" then
|
|
||||||
self.state = math.random(1,2)
|
|
||||||
else self.state = 1 end
|
|
||||||
self.timer = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--play sound
|
|
||||||
if self.sound_timer > math.random(5,35) then
|
|
||||||
minetest.sound_play(sound_normal, {pos = current_pos, max_hear_distance = 10, gain = 0.2})
|
|
||||||
self.sound_timer = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
--after punched
|
|
||||||
if self.state >= 8 then
|
|
||||||
if self.punch_timer > 0.15 then
|
|
||||||
--self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
|
|
||||||
if self.state == 9 then
|
|
||||||
self.object:setvelocity({x=self.direction.x*mummy_chillaxin_speed,y=-20,z=self.direction.z*mummy_chillaxin_speed})
|
|
||||||
self.state = 2
|
|
||||||
elseif self.state == 8 then
|
|
||||||
self.object:setvelocity({x=0,y=-20,z=0})
|
|
||||||
self.state = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--STANDING
|
|
||||||
if self.state == 1 then
|
|
||||||
self.yawwer = true
|
|
||||||
self.attacker = ""
|
|
||||||
for _,object in ipairs(minetest.env:get_objects_inside_radius(self.object:getpos(), 4)) do
|
|
||||||
if object:is_player() then
|
|
||||||
self.yawwer = false
|
|
||||||
NPC = self.object:getpos()
|
|
||||||
PLAYER = object:getpos()
|
|
||||||
self.vec = {x=PLAYER.x-NPC.x, y=PLAYER.y-NPC.y, z=PLAYER.z-NPC.z}
|
|
||||||
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
|
|
||||||
if PLAYER.x > NPC.x then
|
|
||||||
self.yaw = self.yaw + math.pi
|
|
||||||
end
|
|
||||||
self.yaw = self.yaw - 2
|
|
||||||
self.object:setyaw(self.yaw)
|
|
||||||
self.attacker = object--:get_player_name()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.attacker == "" and self.turn_timer > math.random(1,4) then--and yawwer == true then
|
|
||||||
self.yaw = 360 * math.random()
|
|
||||||
self.object:setyaw(self.yaw)
|
|
||||||
self.turn_timer = 0
|
|
||||||
self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
|
|
||||||
end
|
|
||||||
self.object:setvelocity({x=0,y=self.object:getvelocity().y,z=0})
|
|
||||||
if self.npc_anim ~= ANIM_STAND then
|
|
||||||
self.anim = get_animations()
|
|
||||||
self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, mummy_animation_speed, mummy_animation_blend)
|
|
||||||
self.npc_anim = ANIM_STAND
|
|
||||||
end
|
|
||||||
if self.attacker ~= "" then
|
|
||||||
self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
|
|
||||||
self.state = 2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--WALKING
|
|
||||||
if self.state == 2 then
|
|
||||||
|
|
||||||
if self.direction ~= nil then
|
|
||||||
self.object:setvelocity({x=self.direction.x*mummy_chillaxin_speed,y=self.object:getvelocity().y,z=self.direction.z*mummy_chillaxin_speed})
|
|
||||||
end
|
|
||||||
if self.turn_timer > math.random(1,4) and not self.attacker then
|
|
||||||
self.yaw = 360 * math.random()
|
|
||||||
self.object:setyaw(self.yaw)
|
|
||||||
self.turn_timer = 0
|
|
||||||
self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
|
|
||||||
--self.object:setvelocity({x=self.direction.x,y=self.object:getvelocity().y,z=direction.z})
|
|
||||||
--self.object:setacceleration(self.direction)
|
|
||||||
end
|
|
||||||
if self.npc_anim ~= ANIM_WALK then
|
|
||||||
self.anim = get_animations()
|
|
||||||
self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, mummy_animation_speed, mummy_animation_blend)
|
|
||||||
self.npc_anim = ANIM_WALK
|
|
||||||
end
|
|
||||||
--[[jump
|
|
||||||
if self.direction ~= nil then
|
|
||||||
if self.jump_timer > 0.3 then
|
|
||||||
if minetest.env:get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then
|
|
||||||
self.object:setvelocity({x=self.object:getvelocity().x,y=5,z=self.object:getvelocity().z})
|
|
||||||
self.jump_timer = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end]]
|
|
||||||
|
|
||||||
if self.attacker ~= "" and minetest.setting_getbool("enable_damage") then
|
|
||||||
local s = self.object:getpos()
|
|
||||||
local p = self.attacker:getpos()
|
|
||||||
if (s ~= nil and p ~= nil) then
|
|
||||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
|
||||||
|
|
||||||
if dist < 2 and self.attacking_timer > 0.6 then
|
|
||||||
self.attacker:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval=1.0,
|
|
||||||
damage_groups = {fleshy=1}
|
|
||||||
})
|
|
||||||
self.attacking_timer = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_entity("tsm_pyramids:mummy", MUMMY_DEF)
|
|
||||||
minetest.register_entity("tsm_pyramids:mummy_spawner", spawner_DEF)
|
minetest.register_entity("tsm_pyramids:mummy_spawner", spawner_DEF)
|
||||||
|
|
||||||
|
function mummy_update_visuals_def(self)
|
||||||
--spawn-egg/spawner
|
--local name = get_player_name()
|
||||||
|
-- visual = default_model_def
|
||||||
minetest.register_craftitem("tsm_pyramids:spawn_egg", {
|
self.npc_anim = 0 -- Animation will be set further below immediately
|
||||||
description = "Mummy spawn-egg",
|
--npc_sneak[name] = false
|
||||||
inventory_image = "tsm_pyramids_mummy_egg.png",
|
local prop = {
|
||||||
liquids_pointable = false,
|
mesh = self.mesh,
|
||||||
stack_max = 99,
|
textures = self.textures,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
--visual_size = {x=1, y=1, z=1},
|
||||||
if pointed_thing.type == "node" then
|
}
|
||||||
minetest.env:add_entity(pointed_thing.above,"tsm_pyramids:mummy")
|
self.object:set_properties(prop)
|
||||||
if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
function pyramids.spawn_mummy (pos, number)
|
|
||||||
for i=0,number do
|
|
||||||
minetest.env:add_entity(pos,"tsm_pyramids:mummy")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("tsm_pyramids:spawner_mummy", {
|
|
||||||
description = "Mummy spawner",
|
|
||||||
paramtype = "light",
|
|
||||||
tiles = {"tsm_pyramids_spawner.png"},
|
|
||||||
is_ground_content = true,
|
|
||||||
drawtype = "allfaces",--_optional",
|
|
||||||
groups = {cracky=1,level=1},
|
|
||||||
drop = "",
|
|
||||||
on_construct = function(pos)
|
|
||||||
pos.y = pos.y - 0.28
|
|
||||||
minetest.env:add_entity(pos,"tsm_pyramids:mummy_spawner")
|
|
||||||
end,
|
|
||||||
on_destruct = function(pos)
|
|
||||||
for _,obj in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
|
|
||||||
if not obj:is_player() then
|
|
||||||
if obj ~= nil and obj:get_luaentity().m_name == "dummy" then
|
|
||||||
obj:remove()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
if not minetest.setting_getbool("only_peaceful_mobs") then
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"tsm_pyramids:spawner_mummy"},
|
|
||||||
interval = 2.0,
|
|
||||||
chance = 20,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local player_near = false
|
|
||||||
local mobs = 0
|
|
||||||
for _,obj in ipairs(minetest.env:get_objects_inside_radius(pos, spawner_range)) do
|
|
||||||
if obj:is_player() then
|
|
||||||
player_near = true
|
|
||||||
else
|
|
||||||
if obj:get_luaentity().mob_name == "mummy" then mobs = mobs + 1 end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if player_near then
|
|
||||||
if mobs < spawner_max_mobs then
|
|
||||||
pos.x = pos.x+1
|
|
||||||
local p = minetest.find_node_near(pos, 5, {"air"})
|
|
||||||
minetest.env:add_entity(p,"tsm_pyramids:mummy")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
|
37
nodes.lua
Normal file → Executable file
@ -4,14 +4,14 @@ for i=1,3 do
|
|||||||
minetest.register_node("tsm_pyramids:deco_stone"..i, {
|
minetest.register_node("tsm_pyramids:deco_stone"..i, {
|
||||||
description = "Sandstone with "..img[i],
|
description = "Sandstone with "..img[i],
|
||||||
tiles = {"default_sandstone.png^tsm_pyramids_"..img[i]..".png"},
|
tiles = {"default_sandstone.png^tsm_pyramids_"..img[i]..".png"},
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
groups = {crumbly=2,cracky=3},
|
groups = {unbreakable=1},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
trap_on_timer = function (pos, elapsed)
|
local trap_on_timer = function (pos, elapsed)
|
||||||
local objs = minetest.env:get_objects_inside_radius(pos, 2)
|
local objs = minetest.get_objects_inside_radius(pos, 2)
|
||||||
for i, obj in pairs(objs) do
|
for i, obj in pairs(objs) do
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
local n = minetest.get_node(pos)
|
local n = minetest.get_node(pos)
|
||||||
@ -27,11 +27,11 @@ end
|
|||||||
minetest.register_node("tsm_pyramids:trap", {
|
minetest.register_node("tsm_pyramids:trap", {
|
||||||
description = "Cracked sandstone brick",
|
description = "Cracked sandstone brick",
|
||||||
tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png"},
|
tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png"},
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
groups = {crumbly=2,cracky=3},
|
groups = {crumbly=2,cracky=3},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
minetest.env:get_node_timer(pos):start(0.1)
|
minetest.get_node_timer(pos):start(0.1)
|
||||||
end,
|
end,
|
||||||
crack = 1,
|
crack = 1,
|
||||||
on_timer = trap_on_timer,
|
on_timer = trap_on_timer,
|
||||||
@ -41,8 +41,31 @@ minetest.register_node("tsm_pyramids:trap", {
|
|||||||
minetest.register_node("tsm_pyramids:trap_2", {
|
minetest.register_node("tsm_pyramids:trap_2", {
|
||||||
description = "trapstone",
|
description = "trapstone",
|
||||||
tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png^[transformR90"},
|
tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png^[transformR90"},
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
groups = {crumbly=2,cracky=3,falling_node=1,not_in_creative_inventory=1},
|
groups = {crumbly=2,cracky=3,falling_node=1,not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
drop = "",
|
drop = "",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local chestdef = minetest.registered_nodes["default:chest"]
|
||||||
|
minetest.register_node("tsm_pyramids:chest",{
|
||||||
|
description = "tsm_pyramids Chest auto refilled",
|
||||||
|
tiles = chestdef.tiles,
|
||||||
|
stack_max = 1000,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
on_construct = function(pos)
|
||||||
|
chestdef.on_construct(pos)
|
||||||
|
minetest.get_node_timer(pos):start(pyramids.max_time)
|
||||||
|
pyramids.fill_chest(pos)
|
||||||
|
end,
|
||||||
|
on_metadata_inventory_move = chestdef.on_metadata_inventory_move,
|
||||||
|
on_metadata_inventory_put = chestdef.on_metadata_inventory_put,
|
||||||
|
on_metadata_inventory_take = chestdef.on_metadata_inventory_take,
|
||||||
|
groups = {unbreakable = 1, not_in_creative_inventory = 1},
|
||||||
|
on_timer = function (pos, elapsed)
|
||||||
|
pyramids.fill_chest(pos)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
4
room.lua
Normal file → Executable file
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
local room = {"a","a","a","a","a","a","a","a","a",
|
local room = {"a","a","a","a","a","a","a","a","a",
|
||||||
"a","c","a","c","a","c","a","c","a",
|
"a","c","a","c","a","c","a","c","a",
|
||||||
"a","s","a","s","a","s","a","s","a",
|
"a","s","a","s","a","s","a","s","a",
|
||||||
@ -35,6 +36,8 @@ local function replace(str,iy)
|
|||||||
if iy == 0 and str == "s" then out = "tsm_pyramids:" str = "sun" end
|
if iy == 0 and str == "s" then out = "tsm_pyramids:" str = "sun" end
|
||||||
if iy == 3 and str == "s" then out = "tsm_pyramids:" str = "men" end
|
if iy == 3 and str == "s" then out = "tsm_pyramids:" str = "men" end
|
||||||
if str == "a" then out = "" end
|
if str == "a" then out = "" end
|
||||||
|
if str == "c" then out = "tsm_pyramids:" end --MFF newchest
|
||||||
|
if str == "s" or str == "b" then out = "maptools:" end
|
||||||
return out..code[str]
|
return out..code[str]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -56,7 +59,6 @@ function pyramids.make_room(pos)
|
|||||||
local p2 = 0
|
local p2 = 0
|
||||||
if n_str == "c" then
|
if n_str == "c" then
|
||||||
if ix < 3 then p2 = 1 else p2 = 3 end
|
if ix < 3 then p2 = 1 else p2 = 3 end
|
||||||
pyramids.fill_chest({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz})
|
|
||||||
end
|
end
|
||||||
minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace(n_str,iy), param2=p2})
|
minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace(n_str,iy), param2=p2})
|
||||||
end
|
end
|
||||||
|
BIN
sounds/mummy.1.ogg
Normal file → Executable file
BIN
sounds/mummy.2.ogg
Normal file → Executable file
BIN
sounds/mummy_death.1.ogg
Normal file → Executable file
BIN
sounds/mummy_hurt.1.ogg
Normal file → Executable file
0
textures/tsm_pyramids_crack.png
Normal file → Executable file
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 390 B |
BIN
textures/tsm_pyramids_eye.png
Normal file → Executable file
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 174 B |
BIN
textures/tsm_pyramids_men.png
Normal file → Executable file
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 173 B |
BIN
textures/tsm_pyramids_mummy_egg.png
Normal file → Executable file
Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 713 B |
BIN
textures/tsm_pyramids_spawner.png
Normal file → Executable file
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 320 B |
BIN
textures/tsm_pyramids_sun.png
Normal file → Executable file
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 161 B |