Compare commits

...

23 Commits
0.8 ... master

Author SHA1 Message Date
Wuzzy 84bea1052e Version 1.0.4 2022-10-16 17:06:50 +02:00
Wuzzy 303d3cf45c Respawn spawner entity on punch/load 2022-10-16 17:06:03 +02:00
Wuzzy ac9a442a07 Add min_minetest_version 2022-10-16 16:26:55 +02:00
Wuzzy a17725133e Rename one of the engraving stones (Man→Human) 2022-10-16 16:24:16 +02:00
Wuzzy 041a4c5dcc Add .mailmap for Wuzzy 2022-10-16 16:20:37 +02:00
Wuzzy 36fc4d2639 Remove giant useless .gitignore 2022-10-16 16:18:45 +02:00
Wuzzy 111639b778 Remove useless .gitattributes 2022-10-16 16:18:23 +02:00
Wuzzy 3fc59c9010 Fix crash if mummy dies in fire 2022-10-16 16:17:14 +02:00
Wuzzy 61ebaab55e Version 1.0.3 2022-02-19 23:27:55 +01:00
Wuzzy 8a449ea8a8 Fix crash if on_punch was called w/ nil damage 2022-02-19 23:27:23 +01:00
Wuzzy 0abcd7960a Version 1.0.2 2020-04-06 14:59:36 +02:00
Wuzzy f5fef5118d Fix broken mummy hit texture 2020-04-06 14:59:11 +02:00
Wuzzy 0974de93e4 Fix occassional crash when mummy dies 2020-04-06 14:41:48 +02:00
Wuzzy 0629d3b6ed Version 1.0.1 2020-04-06 00:47:39 +02:00
Wuzzy 5e9cd77fdc Use TRUE ephemeral sounds 2020-04-06 00:47:00 +02:00
Wuzzy 1b3f948daa Use ephemeral sounds 2020-04-06 00:19:56 +02:00
Wuzzy 63572c5c23 Fix crash 2019-10-01 13:06:20 +02:00
Wuzzy 2538680eea Fix undeclared global warnings 2019-09-26 14:31:24 +02:00
Wuzzy 85da5073b9 Version 1.0.0 2019-09-02 20:45:11 +02:00
Wuzzy d995fd381a Spawn egg: Make node on_rightclick take precedence 2019-08-25 18:47:10 +02:00
Wuzzy 355aa1d40d Add mummy description field (CMI) 2019-08-25 18:21:12 +02:00
Wuzzy 44482f6268 Add basic CMI support (experimental) 2019-08-25 18:04:16 +02:00
Wuzzy ae4fc9135c Add _cmi_is_mob 2019-08-25 17:35:56 +02:00
12 changed files with 156 additions and 278 deletions

22
.gitattributes vendored
View File

@ -1,22 +0,0 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# 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

215
.gitignore vendored
View File

@ -1,215 +0,0 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

2
.mailmap Normal file
View File

@ -0,0 +1,2 @@
Wuzzy <Wuzzy@disroot.org> <Wuzzy2@mail.ru>
Wuzzy <Wuzzy@disroot.org> <almikes@aol.com>

View File

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

17
TODO Normal file
View File

@ -0,0 +1,17 @@
Minibugs:
- Mummy doesn't avoid lava
Features:
- More random rooms!
- Man statue
- Falling traps from above
- More variety in pyramid exterior styles
- Different entrances
- Stairs leading to entrance
- Open roof? For sun room
- Multiple entries (temple-like pyramids)
- Different pyramid sizes
- Damaged pyramids
- Missing blocks
- Trap stones
- No mummies, traps or treasures

View File

@ -345,11 +345,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
minetest.log("verbose", "[tsm_pyramids] Pyramid not placed, no suitable surface. minp="..minetest.pos_to_string(minp))
return
end
-- Select the material type by the most prominent node type
-- E.g. if desert sand is most prominent, we place a desert sandstone pyramid
if sand_cnt_max_id then
sand = sands[sand_cnt_max_id]
end
if p2.y < PYRA_MIN_Y then
minetest.log("info", "[tsm_pyramids] Pyramid not placed, too deep. p2="..minetest.pos_to_string(p2))
return

View File

@ -6,10 +6,11 @@ Desert Sandstone with Cactus Engraving=
Desert Sandstone with Scarab Engraving=
Falling Cracked Sandstone Brick=
Falling Cracked Desert Sandstone Brick=
Mummy=
Mummy Spawn Egg=
Mummy Spawner=
Sandstone with Eye Engraving=
Sandstone with Man Engraving=
Sandstone with Human Engraving=
Sandstone with Sun Engraving=
A mummy spawner causes hostile mummies to appear in its vicinity as long it exists.=
Can be used to create a hostile mummy.=

View File

@ -6,10 +6,11 @@ Desert Sandstone with Cactus Engraving=Wüstensandstein mit Kaktusgravur
Desert Sandstone with Scarab Engraving=Wüstensandstein mit Skarabäusgravur
Falling Cracked Sandstone Brick=Fallender rissiger Sandsteinziegel
Falling Cracked Desert Sandstone Brick=Fallender rissiger Wüstensandsteinziegel
Mummy=Mumie
Mummy Spawn Egg=Mumien-Spawn-Ei
Mummy Spawner=Mumien-Spawner
Sandstone with Eye Engraving=Sandstein mit Augengravur
Sandstone with Man Engraving=Sandstein mit Manngravur
Sandstone with Human Engraving=Sandstein mit Menschengravur
Sandstone with Sun Engraving=Sandstein mit Sonnengravur
A mummy spawner causes hostile mummies to appear in its vicinity as long it exists.=Ein Mumien-Spawner lässt feindliche Mumien in seiner näheren Umgebung auftauchen, solange er existiert.
Can be used to create a hostile mummy.=Kann benutzt werden, um eine feindliche Mumie zu erzeugen (auch »spawnen« genannt).

View File

@ -1,4 +1,5 @@
name = tsm_pyramids
description = Pyramids with treasures! You can find them in deserts and sandstone deserts.
depends = default
optional_depends = farming, tnt, treasurer, doc_items, awards
optional_depends = farming, tnt, treasurer, doc_items, awards, cmi
min_minetest_version = 5.0

159
mummy.lua
View File

@ -1,5 +1,7 @@
local S = minetest.get_translator("tsm_pyramids")
local mod_cmi = minetest.get_modpath("cmi") ~= nil
local mummy_walk_limit = 1
local mummy_chillaxin_speed = 1
local mummy_animation_speed = 10
@ -12,6 +14,8 @@ local mummy_texture = {"tsm_pyramids_mummy.png"}
local mummy_hp = 20
local mummy_drop = "default:papyrus"
local spawner_entity_offset = -0.28
local sound_normal = "mummy"
local sound_hit = "mummy_hurt"
local sound_dead = "mummy_death"
@ -47,15 +51,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
@ -63,7 +63,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)
@ -91,8 +90,32 @@ local MUMMY_DEF = {
envdmg_timer = 0,
attacker = "",
attacking_timer = 0,
-- CMI stuff
-- Track last cause of damage for cmi.notify_die
last_damage_cause = { type = "unknown" },
_cmi_is_mob = true,
description = S("Mummy"),
}
-- Returns true if a mummy spawner entity was found at pos.
-- If self is provided, this object does not count.
local function check_if_mummy_spawner_entity_exists(pos, self)
local ents = minetest.get_objects_inside_radius(pos, 0.5)
for e=1, #ents do
if (not self) or (ents[e] ~= ents[e]) then
local lua = ents[e]:get_luaentity()
if lua then
if lua.name == "tsm_pyramids:mummy_spawner" then
-- entity found
return true
end
end
end
end
return false
end
local spawner_DEF = {
hp_max = 1,
physical = false,
@ -107,6 +130,13 @@ local spawner_DEF = {
}
spawner_DEF.on_activate = function(self)
local pos = self.object:get_pos()
local spos = vector.new(pos.x, pos.y + spawner_entity_offset, pos.z)
if check_if_mummy_spawner_entity_exists(spos, self) then
-- Remove possible duplicate entity
self.object:remove()
return
end
mummy_update_visuals_def(self)
self.object:set_velocity({x=0, y=0, z=0})
self.object:set_acceleration({x=0, y=0, z=0})
@ -114,13 +144,18 @@ spawner_DEF.on_activate = function(self)
end
-- Regularily check if entity is still inside spawner
spawner_DEF.on_step = function(self, dtime)
self.timer = self.timer + 0.01
local n = minetest.get_node_or_nil(self.object:get_pos())
if self.timer > 1 then
self.timer = self.timer + dtime
local pos = self.object:get_pos()
pos.y = pos.y - spawner_entity_offset
local n = minetest.get_node_or_nil(pos)
if self.timer > 50 then
if n and n.name and n.name ~= "tsm_pyramids:spawner_mummy" then
self.object:remove()
return
end
self.timer = 0
end
end
@ -128,7 +163,10 @@ spawner_DEF.on_punch = function(self, hitter)
end
MUMMY_DEF.on_activate = function(self)
MUMMY_DEF.on_activate = function(self, staticdata, dtime_s)
if mod_cmi then
cmi.notify_activate(self, dtime_s)
end
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)
@ -138,12 +176,20 @@ MUMMY_DEF.on_activate = function(self)
self.object:set_armor_groups({fleshy=130})
end
MUMMY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
MUMMY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
if mod_cmi then
cmi.notify_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
end
self.attacker = puncher
if damage and damage > 0 then
self.last_damage = {
type = "punch",
puncher = puncher,
}
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}
@ -159,7 +205,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
@ -167,12 +213,15 @@ MUMMY_DEF.on_death = function(self, killer)
pos.y = pos.y + 1.0
minetest.add_item(pos, mummy_drop .. " " .. count)
end
if mod_cmi then
cmi.notify_die(self, self.last_damage)
end
end
local cnt1 = 0
local cnt2 = 0
MUMMY_DEF.on_step = function(self, dtime)
if mod_cmi then
cmi.notify_step(self, dtime)
end
self.timer = self.timer + 0.01
self.turn_timer = self.turn_timer + 0.01
self.jump_timer = self.jump_timer + 0.01
@ -186,9 +235,11 @@ MUMMY_DEF.on_step = function(self, dtime)
self.time_passed = 0
end
-- Environment damage
local def = minetest.registered_nodes[current_node.name]
local dps = def.damage_per_second
local dmg = 0
local dmg_node, dmg_pos
if dps ~= nil and dps > 0 then
dmg = dps
end
@ -208,17 +259,24 @@ MUMMY_DEF.on_step = function(self, dtime)
self.envdmg_timer = self.envdmg_timer + dtime
if dmg > 0 then
if self.envdmg_timer >= 1 then
self.envdmg_timer = 0
self.object:set_hp(self.object:get_hp()-dmg)
if self.object:get_hp() <= 0 then
local new_hp = self.object:get_hp() - dmg
if new_hp <= 0 then
if self.on_death then
self.on_death(self)
end
self.object:remove()
return
else
self.envdmg_timer = 0
self.object:set_hp(new_hp)
self.last_damage = {
type = "environment",
pos = current_pos,
node = current_node,
}
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
@ -237,7 +295,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
@ -341,11 +399,23 @@ minetest.register_craftitem("tsm_pyramids:spawn_egg", {
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.settings:get_bool("creative_mode") then itemstack:take_item() end
if pointed_thing.type ~= "node" then
return itemstack
end
-- am I clicking on something with existing on_rightclick function?
local node = minetest.get_node(pointed_thing.under)
if placer and not placer:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
minetest.add_entity(pointed_thing.above,"tsm_pyramids:mummy")
if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item()
end
return itemstack
end,
})
@ -368,6 +438,20 @@ else
spawnersounds = default.node_sound_stone_defaults()
end
local spawn_mummy_spawner_entity = function(pos)
local spos = vector.new(pos.x, pos.y+spawner_entity_offset, pos.z)
minetest.add_entity(spos, "tsm_pyramids:mummy_spawner")
end
-- Respawn mummy spawner entity at pos if none exists
local respawn_mummy_spawner_entity = function(pos)
local spos = vector.new(pos.x, pos.y + spawner_entity_offset, pos.z)
if check_if_mummy_spawner_entity_exists(spos) then
return
end
spawn_mummy_spawner_entity(pos)
end
minetest.register_node("tsm_pyramids:spawner_mummy", {
description = S("Mummy Spawner"),
_doc_items_longdesc = S("A mummy spawner causes hostile mummies to appear in its vicinity as long it exists."),
@ -378,13 +462,15 @@ minetest.register_node("tsm_pyramids:spawner_mummy", {
groups = {cracky=1,level=1},
drop = "",
on_construct = function(pos)
pos.y = pos.y - 0.28
minetest.add_entity(pos,"tsm_pyramids:mummy_spawner")
spawn_mummy_spawner_entity(pos)
end,
on_punch = function(pos)
respawn_mummy_spawner_entity(pos)
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().name == "tsm_pyramids:mummy_spawner" then
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do
if obj ~= nil and not obj:is_player() then
if obj:get_luaentity().name == "tsm_pyramids:mummy_spawner" then
obj:remove()
end
end
@ -393,6 +479,17 @@ minetest.register_node("tsm_pyramids:spawner_mummy", {
sounds = spawnersounds,
})
-- Neccessary in case the spawner entity got lost due to /clearobjects
minetest.register_lbm({
label = "Respawn mummy spawner entity",
name = "tsm_pyramids:respawn_mummy_spawner_entity",
nodenames = { "tsm_pyramids:spawner_mummy" },
run_at_every_load = true,
action = function(pos, node)
respawn_mummy_spawner_entity(pos)
end,
})
-- Attempt to spawn a mummy at a random appropriate position around pos.
-- Criteria:
-- * Must be close to pos

View File

@ -5,7 +5,7 @@ local img = {
"ankh", "scarab", "cactus"
}
local desc = {
S("Sandstone with Eye Engraving"), S("Sandstone with Man Engraving"), S("Sandstone with Sun Engraving"),
S("Sandstone with Eye Engraving"), S("Sandstone with Human Engraving"), S("Sandstone with Sun Engraving"),
S("Desert Sandstone with Ankh Engraving"), S("Desert Sandstone with Scarab Engraving"), S("Desert Sandstone with Cactus Engraving")
}

View File

@ -1116,6 +1116,7 @@ function tsm_pyramids.make_traps(pos, stype, rotations, layout_room)
-- The depth of air between trap stones and lava layer is <depth> - 4
local deep_trap = math.random(1,2) == 1
local trap_node
local depth
if deep_trap then
trap_node = " "
depth = 14