[Mod] Mobs Redo [1.61] [mobs]

untiltoday
Member
Posts: 20
Joined: Wed Aug 07, 2019 22:50
In-game: ParalyzeEntertain

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

by untiltoday » Post

davidthecreator wrote:
untiltoday wrote:Is it possible to add the ability to make saddles from something else (like plastic or whatever they are made from), to get saddles without killing mobs? Previously mentioned by Sokomine for Petz.
Why not wool?
Then some wood or plastic for the tree, and wool, plastic or leather for the other big parts?

User avatar
Hamlet
Member
Posts: 766
Joined: Sat Jul 29, 2017 21:09
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

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

by Hamlet » Post

I've been trying to fix the issue with the mobiles being stuck against obstacles, but I haven't been able to apply the following solution; I don't know where to look in your API for the correct places where to add this code.
In other words I don't know where to put my hands, else I would have tried myself.

Thus I'm posting it here, hoping that it will be useful to improve Mobs Redo.

The solution's underlying idea is simple: if the given mob is not in the "stand" state, its velocity should be > than 0; if velocity == 0 then the mob is moonwalking against something.

If you have ever seen one of those old toys that when bump against a wall turn back, you've got the general idea. It is less than optimal - not Artificial Intelligence - but it works.

Of course this requires a timer which performs the check - I have used 5secs - to prevent letting the mobile moonwalking against a wall for more than e.g. 5secs.

If the check is not passed - state ~= "standing" AND velocity == 0 - then apply a random direction "try going somewhere else" AND lower the stuck-check-timer to an half: if the newly chosen direction is blocked, it will take 2.5secs to choose a different one, and so on.

If the check is passed, it's all right. If the timer's value was set to 2.5 then reset it to 5.0.


All of the following (pseudo)code is CC0, i.e. Public Domain

Main API routine on step:

-- Check whether if the mobile is stuck.

Code: Select all

TimerStuckCheck(self, dtime)

Movement management - If Action == "moving" AND Speed == 0 then Stuck == True

Code: Select all

-- Returns TRUE if stuck, FALSE if not.
CheckIfStuck = function(self)
	if (self.state == "moving")
	or (self.state == "attacking")
	or (self.state ~= "standing")
	or etc.
	or etc.
	then

		local velocity = self.object:get_velocity()

		if (velocity.x == 0)
		and (velocity.y == 0)
		and (velocity.z == 0)
		then
			--print("I am stuck.")
			return true

		else
			-- print("I am not stuck.")
			return false

		end
	end
end

Timer management - If timer == 0 then do check, etc.

Code: Select all

-- Used to check if mobiles are stuck.
TimerStuckCheck = function(self, dtime)
	if (self.counter_stuck_check <= 0) then
		local mobile_is_stuck = CheckIfStuck(self)

		if (mobile_is_stuck ~= nil)
		and (mobile_is_stuck ~= false)
		then
			ApplyRandomDirection() -- I.e. try moving somewhere else.
			self.counter_change_direction = 2.5
		end

		-- If the mob isn't stuck apply the default value.
		self.counter_stuck_check = 5.0

	else
		-- Let the countdown work
		self.counter_stuck_check = (self.counter_stuck_check - dtime)

	end
end
I hope this somewhat helps, I've spawned a dozen of dwarves in a cave and they all ended up moonwalking against the walls while being slain by Dungeon Masters' fireballs... lol.
My repositories: Codeberg.org | My ContentDB's page

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

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

by TenPlus1 » Post

Hamlet - I've done something a little similar where if the mob is stuck against a wall, it will turn 90 degrees if it cannot jump up or move forward.

https://notabug.org/TenPlus1/mobs_redo/ ... .lua#L1064

User avatar
Hamlet
Member
Posts: 766
Joined: Sat Jul 29, 2017 21:09
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

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

by Hamlet » Post

TenPlus1 wrote:Hamlet - I've done something a little similar where if the mob is stuck against a wall, it will turn 90 degrees if it cannot jump up or move forward.

https://notabug.org/TenPlus1/mobs_redo/ ... .lua#L1064
I see, never mind then.
My repositories: Codeberg.org | My ContentDB's page

Ender3Guy
New member
Posts: 7
Joined: Fri May 31, 2019 21:32
GitHub: MisterPrintf

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

by Ender3Guy » Post

Can someone direct me to a wiki or tutorial for using Mobs redo? I've done a little magpen modding and I'd like to get into mobs if possible.

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

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

by TenPlus1 » Post

Ender3Guy: the git page has the mods itself and the readme and api.txt files for usage: https://notabug.org/tenplus1/mobs_redo

User avatar
Hamlet
Member
Posts: 766
Joined: Sat Jul 29, 2017 21:09
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

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

by Hamlet » Post

Mobs ignore fear_height if walk_speed > than 1.

Steps to reproduce:
- Build a pile of dirt 5 nodes tall.
- Spawn a test mob on it.
test_mob.zip
(4.28 KiB) Downloaded 78 times
The mob stays there until you add another node, then it jumps down even if fear_height = 3 (see code below).

Screenshots:
Image

Image

Test code used:

Code: Select all

--[[
	Test Mob - Registers a test mob.
	Licensed under the CC0, Version 1.0 or later.
	This sofware is distributed on an 'AS IS' basis,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
	implied.

--]]


--
-- Mob entity
--

mobs:register_mob('test_mob:test', {
	nametag = 'Test Mob',
	type = 	'npc',
	hp_min = 20,
	hp_max = 20,
	armor = 100,
	walk_velocity = 4,
	run_velocity = 4,
	stand_chance = 50,
	walk_chance = 50,
	jump = true,
	jump_height = 1.1,
	stepheight = 1.1,
	pushable = false,
	view_range = 14,
	damage = 1,
	knock_back = true,
	fear_height = 3,
	fall_damage = true,
	suffocation = true,
	floats = true,
	reach = 4,
	attack_monsters = true,
	group_attack = true,
	attack_type = 'dogfight',
	makes_footstep_sound = true,
	visual = 'mesh',
	visual_size = {x = 1, y = 1},
	collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
	selectionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
	textures = {'character.png'},
	mesh = 'character.b3d',
	animation = {
		stand_start = 0,
		stand_end = 79,
		stand_speed = 30,
		walk_start = 168,
		walk_end = 187,
		walk_speed = 30,
		run_start = 168,
		run_end = 187,
		run_speed = 30,
		punch_start = 189,
		punch_end = 198,
		punch_speed = 30,
		die_start = 162,
		die_end = 166,
		die_speed = 0.8
	}
})


--
-- Mobile spawner
--

mobs:spawn({
	name = 'test_mob:test',
	nodes = {
		'group:cracky',
		'group:stone',
		'group:crumbly',
		'group:sand',
		'group:snowy'
	},
	neighbors = {'air'},
	interval = 60,
	chance = 7500,
	active_object_count = 2,
	min_height = -30912,
	max_height = 31000
})


-- Spawn Egg

mobs:register_egg('test_mob:test', 'Test Mob', 'default_grass.png', 1)


--
-- Alias for '/spawnentity' command
--

mobs:alias_mob('mobs:test', 'test_mob:test')


--
-- Minetest engine debug logging
--

local log_level = minetest.settings:get('debug_log_level')

if (log_level == nil)
or (log_level == 'action')
or (log_level == 'info')
or (log_level == 'verbose')
then
	log_level = nil
	minetest.log('action', '[Mod] Test Mob [v0.1.0] loaded.')
end

Attachments
test2.png
test2.png (467.18 KiB) Viewed 946 times
test1.png
test1.png (533.17 KiB) Viewed 946 times
My repositories: Codeberg.org | My ContentDB's page

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

Update:

by TenPlus1 » Post

The mob core works on a 1 second delay so by the time it walks to the end of the placed node it hasn't checked for fear height just yet... I'll look into this and reduce the delay :) Sadly server lag also affects these checks.

- Changed fear height check to every 1/4 second instead of 1 second, should help.

User avatar
Hamlet
Member
Posts: 766
Joined: Sat Jul 29, 2017 21:09
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

Re: Update:

by Hamlet » Post

TenPlus1 wrote:The mob core works on a 1 second delay so by the time it walks to the end of the placed node it hasn't checked for fear height just yet... I'll look into this and reduce the delay :) Sadly server lag also affects these checks.

- Changed fear height check to every 1/4 second instead of 1 second, should help.
I've just tested it: passed! :)
Only a couple of issues:
- the walking animation doesn't stop, making it looking weird.
- the mob sticks where it stopped, doesn't move elsewhere - since 40 minutes and counting.

While we are at it, it could be worth adding to the drop-check also lava/water checks if the mob has those flaws.
Keeping lag and memory saving in mind, it could be Off by default - to be toggled via Settings.
This way servers would not be affected, while Local Game players could easily turn it on.

Quick (pseudo)code examples (License: CC-0 v1.0 or later.)

Lava check

Code: Select all

-- Checks if the node is lava.
local b_LavaDangerCheck = function(pos)
	local s_NodeName = minetest.get_node(pos).name
	local b_DangerousNode = false
	local t_LavaNodes = {
		'default:lava_source',
		'default:lava_flowing'
	}

	for i = 1, 2 do
		if (b_DangerousNode == false) then
			if (s_NodeName == t_LavaNodes[i]) then
				b_DangerousNode == true
			end
		end
	end

	return b_DangerousNode
end
Water check

Code: Select all

-- Checks if the node is water.
local b_WaterDangerCheck = function(pos)
	local s_NodeName = minetest.get_node(pos).name
	local b_DangerousNode = false
	local t_WaterNodes = {
		'default:water_source',
		'default:water_flowing',
		'default:river_water_source',
		'default:river_water_flowing'
	}

	for i = 1, 4 do
		if (b_DangerousNode == false) then
			if (s_NodeName == t_WaterNodes[i]) then
				b_DangerousNode == true
			end
		end
	end

	return b_DangerousNode
end
Implementation

Code: Select all

local b_CheckForDangerousNodes =  minetest.settings:get_bool("mobs_dangerous_nodes_check")
local i_WaterDamage = self.water_damage -- Fetch the value just once, outside the cycle.
local i_LavaDamage = self.lava_damage

-- To be used when scanning the surrounding nodes.
if (b_CheckForDangerousNodes == true) then
	if (i_LavaDamage ~= nil) then
		if (b_LavaDangerCheck(pos) == true) then
			<function_that_stops_the_mob>
			<function_that_tries_another_direction>
		end
	end

	if (i_WaterDamage ~= nil) then
		if (b_WaterDangerCheck(pos) == true) then
			<function_that_stops_the_mob>
			<function_that_tries_another_direction>
		end
	end
end
My repositories: Codeberg.org | My ContentDB's page

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

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

by TenPlus1 » Post

@Hamlet - The node that the mob is standing in is within the 1/4 second loop (self.standing_in) and the water/lava check is part of the walk cycle of checks and if found the mob usually turns around or if they fall in, escapes onto the closest land block.

https://notabug.org/TenPlus1/mobs_redo/ ... .lua#L2032

User avatar
Hamlet
Member
Posts: 766
Joined: Sat Jul 29, 2017 21:09
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

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

by Hamlet » Post

TenPlus1 wrote:@Hamlet - The node that the mob is standing in is within the 1/4 second loop (self.standing_in) and the water/lava check is part of the walk cycle of checks and if found the mob usually turns around or if they fall in, escapes onto the closest land block.

https://notabug.org/TenPlus1/mobs_redo/ ... .lua#L2032
Good to know, thank you.
My repositories: Codeberg.org | My ContentDB's page

User avatar
Hamlet
Member
Posts: 766
Joined: Sat Jul 29, 2017 21:09
IRC: H4mlet
In-game: Hamlet
Location: Lombardy, Italy

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

by Hamlet » Post

@TenPlus1

I'm having an issue with textures that I can't solve: mobs become full white on punch, for about 1sec.

This does not happen if the mob's

Code: Select all

textures
contains just an entry, i.e. a simple skin. - Mobs Humans-dev basic mode -

This happens when it contains a table of textures, which is my case due the fact I'm using StuJones' character model that allows displaying swords, shields, etc. i.e. 3D Armor's model. - Mobs Humans-dev dynamic mode -

Yesterday I thought that I had eventually solved the issue by explicitly setting the mob's

Code: Select all

blood_texture = 'mobs_blood.png'
, the 'full white effect' was gone. Today I'm experiencing it again.

It must be said that mobs in 'dynamic mode' change textures, that is draw/sheath swords if they are attacking or not.

The fact that explicitly setting the blood texture had temporarily solved it really baffles me.

Any hints on what could be possibly causing this? Here's the function I'm using to swap between armed/unarmed modes: link.
My repositories: Codeberg.org | My ContentDB's page

User avatar
FreeGamers
Member
Posts: 650
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

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

by FreeGamers » Post

I'm trying to make a mob float in lava.

I can do this two ways, I've tried enabling floats = 1, but this parameter seems to only apply to water. Could it be extended to lava?

Otherwise, I could try to use the "fly" and "fly_in" parameters and set what nodes it can fly in. However, I would like the mob to walk on land and other nods instead flying. But when fly_in and fly are enabled, the mob cannot walk.

Also, I had an additional question: can a set of nodes be given as "fly_in" definitions? I tried this but it crashed the api due to it being a table instead of the expected string.
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

ThorfinnS
Member
Posts: 311
Joined: Mon Feb 25, 2019 22:05
GitHub: ThorfinnS

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

by ThorfinnS » Post

Never paid much attention to them. Don't lava slimes float?

User avatar
FreeGamers
Member
Posts: 650
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

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

by FreeGamers » Post

ThorfinnS wrote:Never paid much attention to them. Don't lava slimes float?
I thought so but the ones in tmw_slimes dont seem to. I went to check.

I'll double check the lava flan too.
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

User avatar
FreeGamers
Member
Posts: 650
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

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

by FreeGamers » Post

I think the way I'll end up handling this is maybe some sort of variable change of the spawn like if its in lava, it can fly without any parameters. I did a lot of mob work this week and found some work by ElCeejo that handles mobs that can swim and walk on land by changing variables depending on what type of nodes they're in. It seems like a good workaround.

I had another questions for Mr. 10+1

I've been working on adding halloween content packs to my game. They are handled by adding mobs during certain times of the year. I am currently using a function that controls spawning that looks like this:

Code: Select all

local date = os.date("*t")
if (date.month == 10 and date.day >= 20) or (date.month == 11 and date.day <= 3) then
	--Spawn Functions
       	mobs:spawn_specific("mobs_creatures:halloween_zombie", {"group:cracky", "group:crumbly", "group:shovely", "group:pickaxey"}, {"air"}, 0, 6, 30, 10000, 6, -30912, 30912, false)
else
        return
end
This is pretty good and handles things efficently but requires the game to restart during the time frame in order to register the spawn.

I was wondering if Mr. 10+1 could think of a better way for me to handle this?

I was thinking perhaps registering the spawn function and using something in the spawn_specific

Code: Select all

    'on_spawn'            is a custom function which runs after mob has spawned
                          and gives self and pos values.
could be used to control this instead. But the only way I could think of would be to spawn mobs anyways and then run a check for the date and remove self if the date is not in the holiday date range. Its probably quite a bit less efficient to run these register these spawn functions year round, but would automate the game more and remove the need to reboot the minetest server during holiday periods.
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

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

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

by TenPlus1 » Post

You could easily create an on_spawn function either within the mob definition or the mobs:spawn() itself and check for a specific date, if found then return true to spawn the halloween zombie, failing that self.object:remove() or do something else.

User avatar
FreeGamers
Member
Posts: 650
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

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

by FreeGamers » Post

Do you think a simple if statement would work for this or do I need to use something that ticks and checks periodically to update what is registered?

In other words, this won't work right?

Code: Select all

local date = os.date("*t")
if (date.month == 10 and date.day >= 20) or (date.month == 11 and date.day <= 3) then
   --Spawn Functions
          mobs:spawn_specific("mobs_creatures:halloween_zombie", {"group:cracky", "group:crumbly", "group:shovely", "group:pickaxey"}, {"air"}, 0, 6, 30, 10000, 6, -30912, 30912, false)
else
        return
end
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

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

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

by TenPlus1 » Post

A simple IF statement should work fine inside of the on_spawn function each time the mob is spawned, keep or remove, and the mobs:spawn will be registered as normal as if it were a normal mob.

User avatar
FreeGamers
Member
Posts: 650
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

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

by FreeGamers » Post

OK, I think that is the best way to handle it. I was thinking about this yesterday while driving somewhere.

I think that was the easiest way for me handle it and write it. However, if the mob is spawned with a spawn egg by an admin, the mob will get removed by the on_spawn check.

I could try writing a separate check to see if the mob has an eggplacer.

monsters do not have an owner string set so checking that will not work. https://notabug.org/TenPlus1/mobs_redo/ ... 3825-L3829

OK, i think I will try to store the variable with something like

Code: Select all

local eggplacer = placer:get_player_name()
if eggplacer ~= nil then
keep the mob
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

oddguy117
Member
Posts: 23
Joined: Thu Nov 07, 2019 19:08

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

by oddguy117 » Post

Is there a way, that you could push the animals (sheep, cows etc.), because it sucks, that I get stuck between my farm animals when I'm as an example sheering sheep. With that I could also get to the wool more easily.

User avatar
davidthecreator
Member
Posts: 452
Joined: Mon Aug 18, 2014 19:48
GitHub: daviddoesminetest
In-game: DavidDoesMinetest
Location: Lithuania

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

by davidthecreator » Post

oddguy117 wrote:Is there a way, that you could push the animals (sheep, cows etc.), because it sucks, that I get stuck between my farm animals when I'm as an example sheering sheep. With that I could also get to the wool more easily.
Best you can do is. Slap them away... I think...

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

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

by TenPlus1 » Post

animals can be pushed, there's a setting for it.

oddguy117
Member
Posts: 23
Joined: Thu Nov 07, 2019 19:08

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

by oddguy117 » Post

Where is the setting? I can't find it in the settings menu

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

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

by TenPlus1 » Post


Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 14 guests