Compare commits

..

8 Commits

Author SHA1 Message Date
d8ece75bee Merge remote-tracking branch 'upstream/master' into nalc-1.2-dev 2020-06-12 21:51:55 +02:00
0abcd7960a Version 1.0.2 2020-04-06 14:59:36 +02:00
f5fef5118d Fix broken mummy hit texture 2020-04-06 14:59:11 +02:00
0974de93e4 Fix occassional crash when mummy dies 2020-04-06 14:41:48 +02:00
0629d3b6ed Version 1.0.1 2020-04-06 00:47:39 +02:00
5e9cd77fdc Use TRUE ephemeral sounds 2020-04-06 00:47:00 +02:00
1b3f948daa Use ephemeral sounds 2020-04-06 00:19:56 +02:00
1eb0bc363e Ajoute remplissage des coffres 30 minutes après ouverture
et modifie les items générés par ceux de nalc_trm
2019-12-27 01:22:46 +01:00
5 changed files with 58 additions and 17 deletions

View File

@ -1,6 +1,6 @@
# Pyramids (with Treasurer support) [`tsm_pyramids`]
* Version: 1.0.0
* Version: 1.0.2
## Description
This is a mod for Minetest Game which adds randomly spawned pyramids in deserts and

View File

@ -67,13 +67,16 @@ end
function tsm_pyramids.fill_chest(pos, stype, flood_sand, treasure_chance)
local sand = "default:sand"
local n = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
if not treasure_chance then
treasure_chance = 100
end
if stype == "desert_sandstone" or stype == "desert_stone" then
if meta:get_string("tsm_pyramids:stype") == "desert_sandstone" or
meta:get_string("tsm_pyramids:stype") == "desert_stone" or
stype == "desert_sandstone" or stype == "desert_stone" then
sand = "default:desert_sand"
end
local n = minetest.get_node(pos)
local treasure_added = false
if n and n.name and n.name == "default:chest" then
local meta = minetest.get_meta(pos)
@ -81,13 +84,13 @@ function tsm_pyramids.fill_chest(pos, stype, flood_sand, treasure_chance)
inv:set_size("main", 8*4)
local stacks = {}
-- Fill with sand in sand-flooded pyramids
if flood_sand then
if meta:get_int("tsm_pyramids:sanded") == 1 or flood_sand then
table.insert(stacks, {name=sand, count = math.random(1,32)})
end
-- Add treasures
if math.random(1,100) <= treasure_chance 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(3,1,5,{"armes", "armures", "precieux", "nourriture"})
else
for i=0,2,1 do
local stuff = chest_stuff.normal[math.random(1,#chest_stuff.normal)]

View File

@ -49,15 +49,11 @@ local ANIM_WALK_MINE = 5
local ANIM_MINE = 6
local function hit(self)
local prop = {
mesh = mummy_mesh,
textures = {"tsm_pyramids_mummy.png^tsm_pyramids_hit.png"},
}
self.object:set_properties(prop)
self.object:set_texture_mod("^tsm_pyramids_hit.png")
minetest.after(0.4, function(self)
local prop = {textures = mummy_texture,}
if self ~= nil and self.object ~= nil then
self.object:set_properties(prop)
self.object:set_texture_mod("")
end
end, self)
end
@ -65,7 +61,6 @@ end
local function mummy_update_visuals_def(self)
npc_anim = 0 -- Animation will be set further below immediately
local prop = {
mesh = mummy_mesh,
textures = mummy_texture,
}
self.object:set_properties(prop)
@ -128,6 +123,7 @@ spawner_DEF.on_step = function(self, dtime)
if self.timer > 1 then
if n and n.name and n.name ~= "tsm_pyramids:spawner_mummy" then
self.object:remove()
return
end
end
end
@ -162,7 +158,7 @@ MUMMY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabili
}
end
if puncher ~= nil then
minetest.sound_play(sound_hit, {pos = self.object:get_pos(), loop = false, max_hear_distance = 10, gain = 0.4})
minetest.sound_play(sound_hit, {pos = self.object:get_pos(), loop = false, max_hear_distance = 10, gain = 0.4}, true)
if time_from_last_punch >= 0.45 then
hit(self)
self.direction = {x=self.object:get_velocity().x, y=self.object:get_velocity().y, z=self.object:get_velocity().z}
@ -178,7 +174,7 @@ MUMMY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabili
end
MUMMY_DEF.on_death = function(self, killer)
minetest.sound_play(sound_dead, {pos = self.object:get_pos(), max_hear_distance = 10 , gain = 0.3})
minetest.sound_play(sound_dead, {pos = self.object:get_pos(), max_hear_distance = 10 , gain = 0.3}, true)
-- Drop item on death
local count = math.random(0,3)
if count > 0 then
@ -244,10 +240,11 @@ MUMMY_DEF.on_step = function(self, dtime)
self.on_death(self)
end
self.object:remove()
return
else
hit(self)
self.sound_timer = 0
minetest.sound_play(sound_hit, {pos = current_pos, max_hear_distance = 10, gain = 0.4})
minetest.sound_play(sound_hit, {pos = current_pos, max_hear_distance = 10, gain = 0.4}, true)
end
end
else
@ -266,7 +263,7 @@ MUMMY_DEF.on_step = function(self, dtime)
--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})
minetest.sound_play(sound_normal, {pos = current_pos, max_hear_distance = 10, gain = 0.2}, true)
self.sound_timer = 0
end

View File

@ -97,3 +97,30 @@ register_trap_stone("desert_trap",
"default_desert_sandstone_brick.png",
{ items = { { items = { "default:desert_sand" }, rarity = 1 }, { items = { "default:desert_sand" }, rarity = 2 }, } })
local chest = minetest.registered_nodes["default:chest"]
local def_on_rightclick = chest.on_rightclick
local def_on_timer = chest.on_timer
minetest.override_item(
"default:chest",
{
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if minetest.get_meta(pos):get_string("tsm_pyramids:stype") ~= "" then
local timer = minetest.get_node_timer(pos)
if not timer:is_started() then
timer:start(1800) -- remplissages des coffres toutes les 30 minutes
end
end
return def_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
end,
on_timer = function(pos, elapsed)
if minetest.get_meta(pos):get_string("tsm_pyramids:stype") ~= "" then
minetest.log("action", "[DEBUG] chest refilling")
tsm_pyramids.fill_chest(pos)
return false
else
if def_on_timer then return def_on_timer(pos, elapsed) else return false end
end
end,
})
minetest.register_alias("tsm_pyramids:chest", "default:chest")

View File

@ -960,6 +960,7 @@ function tsm_pyramids.make_room(pos, stype, room_id, rotations)
end
tries = tries + 1
end
local sanded = room.flood_sand ~= false and stype ~= "desert_stone" and math.random(1,8) == 1
local chests = {}
local column_style
if stype == "desert_stone" then
@ -1002,6 +1003,13 @@ function tsm_pyramids.make_room(pos, stype, room_id, rotations)
local nn = replace(n_str, iy, code_table, deco, column_style)
minetest.set_node(cpos, {name=nn, param2=p2})
if nn == "default:chest" then
local meta = minetest.get_meta(cpos)
meta:set_string("tsm_pyramids:stype", stype)
if sanded then
meta:set_int("tsm_pyramids:sanded", 1)
else
meta:set_int("tsm_pyramids:sanded", 0)
end
table.insert(chests, cpos)
end
end
@ -1045,6 +1053,13 @@ function tsm_pyramids.make_room(pos, stype, room_id, rotations)
local nn = code_table[n_str]
minetest.set_node(cpos, {name=nn, param2=p2})
if nn == "default:chest" then
local meta = minetest.get_meta(cpos)
meta:set_string("tsm_pyramids:stype", stype)
if sanded then
meta:set_int("tsm_pyramids:sanded", 1)
else
meta:set_int("tsm_pyramids:sanded", 0)
end
table.insert(chests, cpos)
end
end
@ -1053,7 +1068,6 @@ function tsm_pyramids.make_room(pos, stype, room_id, rotations)
else
minetest.log("error", "Invalid pyramid room style! room type ID="..r)
end
local sanded = room.flood_sand ~= false and stype ~= "desert_stone" and math.random(1,8) == 1
if #chests > 0 then
-- Make at least 8 attempts to fill chests
local filled = 0