[Mod] Ghosts [ghosts]

Post Reply
User avatar
LMD
Member
Posts: 1385
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

[Mod] Ghosts [ghosts]

by LMD » Post

Ghosts

Adds purely (audio-)visual ghosts of players you have killed that will haunt you at midnight.

About

Supports arbitrary player models and textures with a few limitations. Easter eggs included!
Depends on modlib and moblib.
All code written by Lars Müller and licensed under the MIT license.
Media (sound files) use different licenses, of which the most restrictive is CC BY 3.0: Screenshot

Image


Links
  • GitHub - sources, issue tracking, contributing
  • ContentDB - releases (cloning from GitHub is recommended)
  • Minetest Forum - (more organized) discussion
  • Discord - discussion, chatting
Limitations

There are three mechanisms to display things in Minetest:
  • Entities, significant overhead per entity, disallowed per the inspirational challenge
  • Nodes, fast but fairly limited (only one node per position)
  • HUD
  • Particles
Projecting everything onto the HUD would mean more work for the server and would look pretty bad with lag; besides, this isn't needed here, so particles are used.
Overally, Minetest imposes the following limitations:
  • Each particle gets it's own packet. Some packets might be delayed, resulting in a partially "separated" ghost.
  • Particle performance is rather poor, as each particle also gets it's own drawcall. This might affect client performance.
  • Texture pack provided skins must ideally have the same dimensions as the mod textures (or at the very least, a multiple of it) because the "sheet" modifier, which requires image dimensions, is used.
  • As multithreading isn't possible currently, ghosts have to be spawned rather fast as to not block the server step.
  • This fills up your memory.
Other limitations are specific to the implementation:
  • Only the B3D file format for models (ghosts using a different model file format won't appear) and PNG for images (otherwise, it resizes the texture to fallback dimensions, leading to even more client lag) are supported
  • If image dimensions can't be determined easily (non-PNG image or complex texture modifier), it will fall back to resizing the ghost texture to the specified fallback resolution, further hurting client performance due to cached parts not being taken advantage of.
Server-side texture packs

Server-side texture packs aren't supported, as there's no proper API for getting their paths yet. You can however use a "texture pack mod" to override textures (and other media) - all you have to do is add all mods as (optional) dependencies of that mod, ensuring it loads last. You may want to have your mod rewrite it's mod.conf to achieve that:

Code: Select all

local current_mod_name = minetest.get_current_modname()
local mod_conf = Settings(minetest.get_modpath(current_mod_name))
local mod_names = minetest.get_modnames()
for index, mod_name in pairs(mod_names) do
	if mod_name == current_mod_name then
		-- Remove the mod itself so we don't get a circular dependency
		table.remove(mod_names, index)
		break
	end
end
local depends = table.concat(modnames, ", ")
if mod_conf:get"optional_depends" ~= depends then
	mod_conf:set("optional_depends", depends)
	mod_conf:write()
	minetest.request_shutdown"Server-side resource pack mod: Updated dependencies, please restart"
end
Configuration


### `chance_reduction_per_night`Decrease in chance of ghost spawning per night
  • Type: number
  • Default: 0.5
fallback_resolution


1

Fallback resolution width
  • Type: number
  • Default: 64
2

Fallback resolution height
  • Type: number
  • Default: 64
force_fallback_resolution

Whether to always resize textures to the given fallback dimensions. Guarantees support for arbitrary resolution texture packs. If this is not set, texture packs with a resolution lower than the server texture resolution won't work at all; texture packs with a multiple of said resolution will work well, however. A resolution of 64x64 or lower is usually acceptable performance-wise.
  • Type: boolean
  • Default: false
forget_duration_nights

How many nights it takes for a ghost to forget their victim
  • Type: number
  • Default: 10
particles_per_metre

Particles per one metre (= node size)
  • Type: number
  • Default: 10
spawn_chance

Chance of a ghost spawning the first night
  • Type: number
  • Default: 1
API


ghosts.spawn_ghost(params)

Spawns a ghost. Returns success: nil if spawning the ghost failed, true if it succeeded. params is a table with the following mandatory fields:
  • expiration_time: In seconds. Time it takes for the ghost to disappear.
  • pos: Minetest vector: Ghost spawn position
  • velocity: Minetest vector.
  • implode: Number, how much the ghost particles go towards their center during expiration time. Value of 1 will collapse the ghost to a point, -10 will explode it to 10x it's size.
  • model: String. B3D model filename. Example: "character.b3d".
  • textures: List (table) of model textures (strings). Example: {"character.png"}.
Optional fields:
  • playername: String. Ghost will be visible (and audible) to all players if not given.
  • sound: No ghost sound is played if sound is falsey.
  • disperse: Number. How fast the ghost should disperse. Default is 0.
victim_player:set_hp(hp, reason)

If reason.object is set to a player (the "killer_player") and victim_player dies, killer_player will be haunted by victim_player. If you use victim_player:punch, this is already the case.
My stuff: Projects - Mods - Website

c56
Member
Posts: 307
Joined: Wed Apr 21, 2021 03:05
GitHub: tigercoding56
In-game: bm5 or bemo5 also sell_her_on55

Re: [Mod] Ghosts [ghosts]

by c56 » Post

this is a great mod ( could you maybe add support for the skins mod techage survival uses ? )
this is a signature not a place to post messages also if i could change my username i would change it to sell_her_on55

User avatar
LMD
Member
Posts: 1385
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Ghosts [ghosts]

by LMD » Post

c56 wrote:
Sun Aug 07, 2022 04:59
this is a great mod ( could you maybe add support for the skins mod techage survival uses ? )
It should support them already - this mod is texture-independent. If it doesn't work, please elaborate.
My stuff: Projects - Mods - Website

c56
Member
Posts: 307
Joined: Wed Apr 21, 2021 03:05
GitHub: tigercoding56
In-game: bm5 or bemo5 also sell_her_on55

Re: [Mod] Ghosts [ghosts]

by c56 » Post

LMD wrote:
Thu Aug 11, 2022 20:54
c56 wrote:
Sun Aug 07, 2022 04:59
this is a great mod ( could you maybe add support for the skins mod techage survival uses ? )
It should support them already - this mod is texture-independent. If it doesn't work, please elaborate.
:D
this is a signature not a place to post messages also if i could change my username i would change it to sell_her_on55

c56
Member
Posts: 307
Joined: Wed Apr 21, 2021 03:05
GitHub: tigercoding56
In-game: bm5 or bemo5 also sell_her_on55

Re: [Mod] Ghosts [ghosts]

by c56 » Post

is there a way to test this mod (in singleplayer ? )
this is a signature not a place to post messages also if i could change my username i would change it to sell_her_on55

User avatar
LMD
Member
Posts: 1385
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Ghosts [ghosts]

by LMD » Post

c56 wrote:
Fri Aug 12, 2022 06:06
is there a way to test this mod (in singleplayer ? )
*snap*
My stuff: Projects - Mods - Website

User avatar
Blockhead
Member
Posts: 1602
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: [Mod] Ghosts [ghosts]

by Blockhead » Post

c56 wrote:
Fri Aug 12, 2022 06:06
is there a way to test this mod (in singleplayer ? )
Just run multiple copies of Minetest at once where one of them launches the world with "Host server" ticked and the others connect to 127.0.0.1
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests