[Mod] Mobs Redo [1.62] [mobs]

adikalon
Member
Posts: 44
Joined: Fri Jul 26, 2024 07:37

Re: [Mod] Mobs Redo [1.62] [mobs]

by adikalon » Post

@TenPlus1 - Then the monsters will stop attacking, but they are supposed to attack all the time. Maybe the attack probability can be configured somehow when they spawn? In that case, I would set it up in my spawn.lua files

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by TenPlus1 » Post

@adikalon - That part is easy, when spawning say a hog that has a chance of attacking a player, you can turn it off like so e.g.

Code: Select all

mobs:spawn({
	name = "mobs_animal:pumba",
	nodes = "default:dirt_with_grass",
	min_light = 14,
	interval = 60,
	chance = 8000,
	min_height = 0,
	max_height = 200,
	day_toggle = true,
	on_spawn = function(self, pos)
		self.attack_players = false -- Don't attack players until hit first.
	end,
})
Last edited by TenPlus1 on Fri Sep 26, 2025 17:12, edited 1 time in total.

adikalon
Member
Posts: 44
Joined: Fri Jul 26, 2024 07:37

Re: [Mod] Mobs Redo [1.62] [mobs]

by adikalon » Post

@TenPlus1 - Ooh, cool. So if I hit it first, will the mob retaliate? That's exactly the kind of behavior I'm hoping for

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Update:

by TenPlus1 » Post

- Refactor protected spawn checks for 'mobs_spawn_protected' and 'mobs_spawn_monster_protected' settings.

adikalon
Member
Posts: 44
Joined: Fri Jul 26, 2024 07:37

Re: [Mod] Mobs Redo [1.62] [mobs]

by adikalon » Post

Is there any way to make the initial spawn not wait for the interval? In other words, to make the timer start counting after the first spawn in each chunk

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by TenPlus1 » Post

@adikalon - If you mean spawning a mob outwith the spawner abm then yes, there are mobs:spawner nodes available or you can create a specific lbm or node that spawns a mob once generated on the map.

adikalon
Member
Posts: 44
Joined: Fri Jul 26, 2024 07:37

Re: [Mod] Mobs Redo [1.62] [mobs]

by adikalon » Post

@TenPlus1 - I'm specifically talking about the ABM's behavior. The problem is that the first spawn is also delayed by the interval. I want the first spawn to be instant when the conditions are met, and then the 180-second interval should apply to all subsequent spawns.

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by TenPlus1 » Post

@adikalon - Remember that abm spawns are using random chance, even if it runs straight away it may still not spawn a mob due to the chance factor alone. You would need to change the spawn settings for the mob in question or add a new spawn that generates with the world e.g.

Code: Select all

mobs:spawn({
	name = "mobs_animal:bunny",
	nodes = "default:dirt_with_grass",
	chance = 10, -- very low chance so mob will spawn
	min_height = 1, -- spawn above ground
	day_toggle = true, -- spawn during daytime
	active_object_count = 1, -- limit mob count so they dont overrun mapblock
	on_map_load = true, -- only spawn mob on generation of mapblock
})

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Update:

by TenPlus1 » Post

- Use vizlib mod to show mob repellent area when punched with empty hand (thanks SwissalpS)
Last edited by TenPlus1 on Fri Nov 07, 2025 09:31, edited 1 time in total.

adikalon
Member
Posts: 44
Joined: Fri Jul 26, 2024 07:37

Re: [Mod] Mobs Redo [1.62] [mobs]

by adikalon » Post

@TenPlus1 - Thanks for the example. I understand that method, but it only works for newly generated mapblocks.

My original question was specifically about the ABM respawn mechanic in already explored and loaded areas. I want the mob to appear immediately when a player enters an area where it's supposed to spawn (the first spawn after loading), and only then should the interval timer start for the next respawn.

Is there a way to configure the ABM itself to have no initial delay? Maybe a setting I'm missing, or a way to make the first ABM execution trigger instantly upon the chunk becoming active, before the interval loop begins?

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by TenPlus1 » Post

@adikalon - Default abm timers only begin when the world starts and execute at their own intervals, so to have something start immediately you would need a custom function, node, globaltimer, lbm or smaller abm intervals.

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Update:

by TenPlus1 » Post

- The Panda model in Mobs Animal has been fixed (thanks AspireMint).
- Penguins can eat group:fish from x_farming.
- Pandas can eat group:bamboo from everness.
- Pandas spawn in default jungle, or ethereal bamboo or everness bamboo biomes if found.

User avatar
Nininik
Member
Posts: 945
Joined: Thu Apr 06, 2023 01:55
GitHub: nininik0
IRC: nininik
In-game: nininik
Location: CA, Team thunderstrike headquarters
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by Nininik » Post

Have an issue, I'm trying to make a flying rideable mob but it keeps giving me this error, and the api isnt really documented for it. Previously I managed to get it to not crash but it would js fly up infinitely when I ride it. My code:

Code: Select all

do_custom = function(self, dtime)

		-- set needed values if not already present
		if not self.v2 then
			self.v2 = 0
			self.max_speed_forward = 11
			self.max_speed_reverse = 5
            self.speed = 27
			self.accel = 7
            self.fly_speed = 27
            fly = 27
			self.terrain_type = 3
			self.driver_attach_at = {x = 0, y = 0, z = -2}
			self.driver_eye_offset = {x = 0, y = 2, z = 0}
			self.driver_scale = {x = 0, y = 0, z = 0} -- shrink driver to fit model
		end

		-- if driver present allow control of horse
		if self.driver then

			mobs.fly(self, fly, true, dtime, can_shoot, arrow_entity, can_fly)
            can_shoot = true
            arrow_entity = "mobs_monster:arrow"
           can_fly = true
			return true -- skip rest of mob functions
		end

		return false
	end,

	on_die = function(self, pos)

		-- detach player from horse properly
		if self.driver then
			mobs.detach(self.driver, {x = 1, y = 0, z = 1})
		end

		-- drop saddle if found
		if self.saddle then
			minetest.add_item(pos, "mobs:saddle")
		end

		-- drop any horseshoes added
		if self.shoed then
			minetest.add_item(pos, self.shoed)
		end
	end,

	do_punch = function(self, hitter)

		-- don't cut the branch you're... ah, that's not about that
		if hitter ~= self.driver then
			return true
		end
	end,

	on_rightclick = function(self, clicker)

		-- make sure player is clicking
		if not clicker or not clicker:is_player() then
			return
		end

		-- feed, tame or heal horse
		if mobs:feed_tame(self, clicker, 10, true, true) then
			return
		end

		-- applying protection rune
		if mobs:protect(self, clicker) then
			return
		end

		local player_name = clicker:get_player_name()

		-- make sure tamed horse is being clicked by owner only
		if self.tamed and self.owner == player_name then

			local inv = clicker:get_inventory()
			local tool = clicker:get_wielded_item()
			local item = tool:get_name()

			-- detatch player already riding horse
			if self.driver and clicker == self.driver then

				mobs.detach(clicker, {x = 1, y = 0, z = 1})

				return
			end

			-- attach saddle to horse
			if not self.driver
			and not self.child
			and clicker:get_wielded_item():get_name() == "mobs:saddle"
			and not self.saddle then

				self.saddle = true
				self.order = "stand"
				self.object:set_properties({stepheight = 6})

				-- take saddle from inventory
				inv:remove_item("main", "mobs:saddle")

				self.texture_mods = self.texture_mods .. "^tiddem.png"

				self.object:set_texture_mod(self.texture_mods)

				return
			end

			-- apply horseshoes (not needed)
			if item:find("remoceditmw") then

				-- drop any existing shoes
				if self.shoed then
					minetest.add_item(self.object:get_pos(), self.shoed)
				end

				local speed = shoes[item][1]
				local jump = shoes[item][2]
				local reverse = shoes[item][3]
				local overlay = shoes[item][4]

				self.max_speed_forward = speed
				self.jump_height = jump
				self.max_speed_reverse = reverse
				self.accel = speed
				self.shoed = item

				-- apply horseshoe overlay to current horse texture
				if overlay then

					self.texture_mods = "^" .. overlay

					if self.saddle then
						self.texture_mods = self.texture_mods
							.. "^tiddem.png"
					end

					self.object:set_texture_mod(self.texture_mods)
				end

				-- show horse speed and jump stats with shoes fitted
				minetest.chat_send_player(player_name,
						S("Horse shoes fitted -")
						.. S(" speed: ") .. speed
						.. S(" , jump height: ") .. jump
						.. S(" , stop speed: ") .. reverse)

				tool:take_item()

				clicker:set_wielded_item(tool)

				return
			end
		end

		-- used to capture horse with magic lasso
		if mobs:capture_mob(self, clicker, nil, nil, 100, false, nil) then return end

		-- ride horse if saddled
		if self.saddle and self.owner == player_name then
			mobs.attach(self, clicker)
		end
		local item = clicker:get_wielded_item()

		-- Check if the item exists and is "default:stick"
		if item and item:get_name() == "default:stick" then
			-- Toggle between follow and stand orders
			if self.order == "follow" then
				self.order = "stand"
			else
				self.order = "follow"
			end

			-- Send feedback to the player
			minetest.chat_send_player(clicker:get_player_name(), "mob will " .. self.order .. ".")
		end
	end
})
Attachments
Screenshot_20251116-113715_Luanti.png
Screenshot_20251116-113715_Luanti.png (77.38 KiB) Viewed 243 times
Last edited by Nininik on Mon Nov 17, 2025 03:36, edited 1 time in total.
↯Glory to Team Thunderstrike!↯
↯T.T.S.↯

jara25
Member
Posts: 12
Joined: Tue Apr 29, 2025 01:45

Re: [Mod] Mobs Redo [1.62] [mobs]

by jara25 » Post

This function call in your do_custom function:

Code: Select all

mobs.fly(self, fly, true, dtime, can_shoot, arrow_entity, can_fly)
...does not match the function signature in mobs/mount.lua:

Code: Select all

function mobs.fly(entity, _, speed, shoots, arrow, moving_anim, stand_anim)
'true' is being passed as the speed, which causes the crash shortly after. That is what "attempt to perform arithmetic on local 'speed' (a boolean value)" means. It is basically trying to do something like '2 * true' which does not make sense in Lua.

On another note, the Riding Mobs section in api.txt needs corrections because it is using the colon syntax sugar when that's not the case in mount.lua itself. In other words, the text file says "mobs:fly" when the actual function should be called as "mobs.fly" since passing the mobs global table as the entity parameter almost certainly will make the game crash.
cdb_16a9468970bf

User avatar
Nininik
Member
Posts: 945
Joined: Thu Apr 06, 2023 01:55
GitHub: nininik0
IRC: nininik
In-game: nininik
Location: CA, Team thunderstrike headquarters
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by Nininik » Post

jara25 wrote:
Sun Nov 16, 2025 21:52
This function call in your do_custom function:

Code: Select all

mobs.fly(self, fly, true, dtime, can_shoot, arrow_entity, can_fly)
...does not match the function signature in mobs/mount.lua:

Code: Select all

function mobs.fly(entity, _, speed, shoots, arrow, moving_anim, stand_anim)
'true' is being passed as the speed, which causes the crash shortly after. That is what "attempt to perform arithmetic on local 'speed' (a boolean value)" means. It is basically trying to do something like '2 * true' which does not make sense in Lua.

On another note, the Riding Mobs section in api.txt needs corrections because it is using the colon syntax sugar when that's not the case in mount.lua itself. In other words, the text file says "mobs:fly" when the actual function should be called as "mobs.fly" since passing the mobs global table as the entity parameter almost certainly will make the game crash.
So that fixed the crashing i replaced true with 27 but now it js goes up when you PRESS w or UP, and it us goes up, when releasing it will go down slowly but it isn't flying back or forth
↯Glory to Team Thunderstrike!↯
↯T.T.S.↯

User avatar
Nininik
Member
Posts: 945
Joined: Thu Apr 06, 2023 01:55
GitHub: nininik0
IRC: nininik
In-game: nininik
Location: CA, Team thunderstrike headquarters
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by Nininik » Post

On another note, if i use the format you provided I get this error: (I modified the code and replaced the blanks with needed stuff): this is on the line function mobs.fly(self, 27, speed, shoots, arrow)
speed = 27
can_shoot = true,
arrow_entity = "mobs_monster:arrow"
can_fly = true
Attachments
Screenshot_20251116-201343_Luanti.png
Screenshot_20251116-201343_Luanti.png (61.5 KiB) Viewed 204 times
↯Glory to Team Thunderstrike!↯
↯T.T.S.↯

jara25
Member
Posts: 12
Joined: Tue Apr 29, 2025 01:45

Re: [Mod] Mobs Redo [1.62] [mobs]

by jara25 » Post

Nininik wrote:
Mon Nov 17, 2025 04:07
So that fixed the crashing i replaced true with 27 but now it js goes up when you PRESS w or UP, and it us goes up, when releasing it will go down slowly but it isn't flying back or forth
It might not be your fault.

I'm bad at 3D math but I took a look here and:

Code: Select all

	if ctrl.up then

		entity.object:set_velocity(
				{x = dir.x * speed, y = dir.y * speed + 2, z = dir.z * speed})

	elseif ctrl.down then

		entity.object:set_velocity(
				{x = -dir.x * speed, y =  dir.y * speed + 2, z = -dir.z * speed})
Is the +2 supposed to be there for the value of y in both cases?

Edit: sorry, didn't see your next post lol

For the function call, you probably want something like:

Code: Select all

mobs.fly(self, dtime, self.speed, true, "mobs_monster:arrow", "fly", "stand")
...and remove everything before the 'return true' line because those lines do nothing. I'm not sure if that's correct since I never made a flying mob that can be mounted, but tenplus1 or someone else can correct me if I'm wrong.

Note how that lines up with what the function expects according to the api.txt file.
cdb_16a9468970bf

User avatar
Nininik
Member
Posts: 945
Joined: Thu Apr 06, 2023 01:55
GitHub: nininik0
IRC: nininik
In-game: nininik
Location: CA, Team thunderstrike headquarters
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by Nininik » Post

jara25 wrote:
Mon Nov 17, 2025 04:33
Nininik wrote:
Mon Nov 17, 2025 04:07
So that fixed the crashing i replaced true with 27 but now it js goes up when you PRESS w or UP, and it us goes up, when releasing it will go down slowly but it isn't flying back or forth
It might not be your fault.

I'm bad at 3D math but I took a look here and:

Code: Select all

	if ctrl.up then

		entity.object:set_velocity(
				{x = dir.x * speed, y = dir.y * speed + 2, z = dir.z * speed})

	elseif ctrl.down then

		entity.object:set_velocity(
				{x = -dir.x * speed, y =  dir.y * speed + 2, z = -dir.z * speed})
Is the +2 supposed to be there for the value of y in both cases?

Edit: sorry, didn't see your next post lol

For the function call, you probably want something like:

Code: Select all

mobs.fly(self, dtime, self.speed, true, "mobs_monster:arrow", "fly", "stand")
...and remove everything before the 'return true' line because those lines do nothing. I'm not sure if that's correct since I never made a flying mob that can be mounted, but tenplus1 or someone else can correct me if I'm wrong.

Note how that lines up with what the function expects according to the api.txt file.
Hmmm now it js drives like a normal vehicle 🫩
↯Glory to Team Thunderstrike!↯
↯T.T.S.↯

jara25
Member
Posts: 12
Joined: Tue Apr 29, 2025 01:45

Re: [Mod] Mobs Redo [1.62] [mobs]

by jara25 » Post

Now that I look at the code more, the part of the API that is about riding mobs is a bit odd.

mobs.drive allows the player to use the jump and sneak buttons to change elevation if can_fly is true, but the mob will not be able to shoot anything.

mobs.fly seems to make the mob fly upwards when it is moving and slowly go downwards when it is not, but it allows the mob to shoot projectiles with sneak + left click.

Did you remove the +2 that I pointed out in your local copy? If so, that's why it's basically like a car now.

I'm assuming that calling both of them in the same server step is a terrible idea. Maybe tenplus1 can improve the API to combine the best parts of both functions.

If you do not need the mob to shoot anything, maybe mobs.drive is enough. Otherwise, you may have to experiment in your mob's do_custom function.
cdb_16a9468970bf

User avatar
Nininik
Member
Posts: 945
Joined: Thu Apr 06, 2023 01:55
GitHub: nininik0
IRC: nininik
In-game: nininik
Location: CA, Team thunderstrike headquarters
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by Nininik » Post

jara25 wrote:
Mon Nov 17, 2025 05:56
Now that I look at the code more, the part of the API that is about riding mobs is a bit odd.

mobs.drive allows the player to use the jump and sneak buttons to change elevation if can_fly is true, but the mob will not be able to shoot anything.

mobs.fly seems to make the mob fly upwards when it is moving and slowly go downwards when it is not, but it allows the mob to shoot projectiles with sneak + left click.

Did you remove the +2 that I pointed out in your local copy? If so, that's why it's basically like a car now.

I'm assuming that calling both of them in the same server step is a terrible idea. Maybe tenplus1 can improve the API to combine the best parts of both functions.

If you do not need the mob to shoot anything, maybe mobs.drive is enough. Otherwise, you may have to experiment in your mob's do_custom function.
Yeah I dont rly need it to shoot since I can js code an item that when used does that, so is it similar but with can_fly set to true?
↯Glory to Team Thunderstrike!↯
↯T.T.S.↯

jara25
Member
Posts: 12
Joined: Tue Apr 29, 2025 01:45

Re: [Mod] Mobs Redo [1.62] [mobs]

by jara25 » Post

Well, the function signature is this:

Code: Select all

mobs.drive(self, move_animation, stand_animation, can_fly, dtime)
...so I think this should work:

Code: Select all

mobs.drive(self, "fly", "stand", true, dtime)
This should replace the mobs.fly call entirely. It's untested, but let me know if it works out.
cdb_16a9468970bf

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Update:

by TenPlus1 » Post

- Add Spanish translation to Mob_Horse.
- Set animation to "stand" when dismounting.

@Nininik - If you need further examples to ride a mob check out Mob Horse.

https://codeberg.org/tenplus1/mob_horse ... r/init.lua

SFENCE
Member
Posts: 319
Joined: Sun Sep 29, 2019 07:13
GitHub: SFENCE
In-game: SFENCE

Re: [Mod] Mobs Redo [1.62] [mobs]

by SFENCE » Post

TenPlus1:

Can you please add the ability to set the dogfight timer per entity?
So, we can have, for example, mobs which does small damage but very often, or very big damage, but once in a long time.

Some per-entity multiplier used over time and timer will also be great.
It allows adding the effect of a slow reaction to an entity. For example, as some poisoning effect.

I also see no easy way for arrow to apply effects to arrow speed.
Can be arrow_override callback be moved after the velocity is set?
cdb_3P0AYqjEIn68

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.62] [mobs]

by TenPlus1 » Post

@SFENCE - So effectively randomizing the attack time, speed and damage ?

The self.arrow_override() is checked for every single arrow so that if the function inside the mob is changed, the arrows change too e.g.

https://codeberg.org/tenplus1/mobs_mons ... onster.lua

User avatar
TenPlus1
Member
Posts: 4219
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Update:

by TenPlus1 » Post

- Added 'punch_interval' setting to mob definition.
- Pass (self, mob_ent) to arrow_override function.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests