Page 8 of 8

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Sun May 27, 2018 17:19
by azekill_DIABLO
Stix wrote:I thought this might help?: https://github.com/PilzAdam/mobs/wiki/API
It was already one of my references. BTW, I think I know how to implement halos, it will be simple.
*EDIT: i think it would be cool if you merged burlis pathfinder with this mod, it would make mobs more dangerous as they can find paths to you: viewtopic.php?f=9&t=17406
I tried to use the minetest built-in pathfinder it didn't gave anything cuz' I really suck at that. I'm not sure about this one.

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Thu Jun 21, 2018 22:04
by csirolli
Are there any known mods that use this api?

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Thu Jun 21, 2018 22:08
by Stix
csirolli wrote:Are there any known mods that use this api?
This one does: viewtopic.php?f=9&t=18200

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Fri Jun 29, 2018 13:25
by azekill_DIABLO
^ What my friend said.

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Fri Jul 06, 2018 13:54
by azekill_DIABLO
M.I.L.A. upcoming functionnality : Auras
Image
Enjoy!

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Fri Jul 06, 2018 19:25
by Stix
azekill_DIABLO wrote:M.I.L.A. upcoming functionnality : Auras
Image
Enjoy!
Amazing, just what i always wanted <o/ !

Well that and animations.

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Fri Jul 06, 2018 20:04
by Andrey01
azekill_DIABLO, can you please add a chance mobs to turn their heads? For example, they would can turn the head if they have seen something and somebody. This would be very nice as this would be quite new feature in mobs mods!

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Sat Jul 07, 2018 12:07
by azekill_DIABLO
I don't know how to use animations. And the models aren't capable of doing this. I'm as frustrated as you. But i'll see if I can do something.

@Stix: i'm glad you like them!

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Wed Jul 11, 2018 18:04
by Stix
So hows progress on the new particles? :3
Also what about spawning and de-spawning particles...

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Wed Jul 11, 2018 23:32
by Stix
Another user is making mobs that work with M.I.L.A.! viewtopic.php?f=9&p=325078#p325078

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Sat Jul 14, 2018 10:51
by azekill_DIABLO
Yay! I've checked it, it's a nice start!

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Sat Jul 14, 2018 20:02
by Hamlet
I've tried to add animations' support to your API, eventually I've managed to make a working function. I've tried it with the wolves and it seems to work acceptably. \o/

First of all, to use an animation you must know which are its first and last frames. Quick method: fetch them from an existing mob's definition; Other method: open (import) the mob's model using Blender, at the window's bottom will be displayed a meter showing the animation frames, with markers named "walk start", "walk end", and alike - those markers will tell you the frame's number.

Secondarily, the animation function itself isn't very useful if the API does not specify when the function has to be called; e.g. you can call the function to load the "moving fast" animation when the mob is moving toward its targed, but it should also be called when the mob is standing still, or simply walking, or digging, etc.
Usage example: apply_animation(self, "moving")

Last but not least: this is my very first attempt to do such a thing, thus don't expect this code to be "bug-proof", elegant or performant; it's just a first step. :)

Now, the code.
The function must be added to your api.lua, while the animations definition must be added to the mob that you want to use it.

I'm releasing this code under the GPLv3 license, which basically means "credit me please, share alike (freely you have been given, freely you shall give), don't use it for closed source software (else your soul will be doomed to <insert unpleasant things here>)".

api.lua

Code: Select all

function apply_animation(self, action)
	if (self.animations ~= nil) then
	-- For backward compatibility: if the existing entities have been
	-- spawned without the "animations" specification in the entity
	-- definition, the game will not crash.
	-- If (self.animations == nil) then it will trigger line #78

		local animations_table = self.animations
		-- fetch the "animations" specification from the entity's definition

		local standing = animations_table["standing"]
		-- fetch the values for the "standing" animation
		-- i.e. the mob stands still

		local moving = animations_table["moving"]
		-- fetch the values for the "moving" animation
		-- i.e. the mob walks, swims or flies

		local moving_fast = animations_table["moving_fast"]
		-- fetch the values for the "moving_fast" animation
		-- same as the previous, but for running or similar

		local attacking = animations_table["attacking"]
		-- fetch the values for the "attacking" animation
		-- i.e. the mob bites, punches, digs, etc.

		if (action ~= nil) then
		-- When calling the function you must specify which action
		-- is being done, else the function will abort.
		-- It triggers line #80

			if (action == "standing") then
				self.object:set_animation(
					standing[1],
					-- i.e. {x = N1, y = N2}
					-- N1 = first animation's frame
					-- N2 = last animation's frame

					standing["frame_speed"],
					-- usually a number like 30, or 60, etc.

					standing["frame_blend"],
					-- a number, 0 to disable, I guess it makes animations smoother

					standing["frame_loop"]
					-- whether if the animation must be repeated when the last frame
					-- has been reached
				)

			elseif (action == "moving") then
				self.object:set_animation(
					moving[1],
					moving["frame_speed"],
					moving["frame_blend"],
					moving["frame_loop"]
				)

			elseif (action == "moving_fast") then
				self.object:set_animation(
					moving_fast[1],
					moving_fast["frame_speed"],
					moving_fast["frame_blend"],
					moving_fast["frame_loop"]
				)

			elseif (action == "attacking") then
				self.object:set_animation(
					attacking[1],
					attacking["frame_speed"],
					attacking["frame_blend"],
					attacking["frame_loop"]
				)

			else
				print("M.I.L.A " ..mila.version..": action \"" .. action ..
					"\" not supported or typed wrong.")
			end

		else
			print("M.I.L.A " ..mila.version..": action's value is nil.")
		end
	end
end
mob definition (frames' values are from the "Mobs Wolf" mob)

Code: Select all

animations = { -- ../minetest/doc/lua_api.txt at line 3278
	standing = { -- the mob stands still
		{x = 1, y = 60}, -- x: animation start, y: animation end
		frame_speed = 30, -- animation's speed
		frame_blend = 0, -- should make the animation smoother
		frame_loop = true -- if false then  the animation runs just once
	},

	moving = { -- the mob walks, swims or flies
		{x = 61, y = 120}, -- x: animation start, y: animation end
		frame_speed = 65, -- animation's speed
		frame_blend = 0, -- should make the animation smoother
		frame_loop = true -- if false then  the animation runs just once
	},

	moving_fast = { -- the mob runs, swims or flies faster
		{x = 61, y = 120}, -- x: animation start, y: animation end
		frame_speed = 70, -- animation's speed
		frame_blend = 0, -- should make the animation smoother
		frame_loop = true -- if false then  the animation runs just once
	},

	attacking = { -- the mob bites, punches, etc.
		{x = 1, y = 60}, -- x: animation start, y: animation end
		frame_speed = 60, -- animation's speed
		frame_blend = 0, -- should make the animation smoother
		frame_loop = true -- if false then  the animation runs just once
	},
}
EDIT--
Happy 14 July, froggy. ;)

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Sun Jul 15, 2018 10:53
by azekill_DIABLO
Wow, you deserve a price of kindness ;D
I must admit one thing: I'll probably don't work on minetest anymore. So feel free to fork my mod and make it live.

I love frogs btw.

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Sun Jul 15, 2018 11:23
by Hamlet
azekill_DIABLO wrote:I must admit one thing: I'll probably don't work on minetest anymore. So feel free to fork my mod and make it live.
Ah this is bad news, however if you decide so, then I wish you all the best for your current/future projects about real life and your other interests. :)

I will fork your mod and try my best to keep it alive.

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Sun Jul 15, 2018 12:43
by azekill_DIABLO
Thank you so much. PM me if you need help, I'll still be here from time to time.

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Tue Aug 21, 2018 21:46
by Hamlet
Hello azekillDIABLO,
during the past month I've been working on a mob API, and I've used M.I.L.A.'s source code to learn how to register a mob, register a mob spawner, etc.

M.I.L.A.'s license requires to release modified versions under the same license (LGPL v3.0), but I have chosen the European Union Public License v1.2 ("EUPL") for my code; basically it is GPL v3.0 compatible but it is legal in 23 languages (while the GPL is legal only in English).

Info site (license in 23 languages): https://joinup.ec.europa.eu/collection/ ... text-11-12
European Union's offical legal site: https://eur-lex.europa.eu/legal-content ... 32017D0863

So, given that my source code is based on your work (and contributors' work) I am asking you if I can change M.I.L.A.'s license from LGPL v3 to EUPL v1.2 - granted that this change would apply only to M.I.L.A. v.1.4 and later, not to v1.3 and earlier versions.

Re: [mod][api][github]M.I.L.A. 1.3[mila]

Posted: Wed Aug 22, 2018 07:59
by azekill_DIABLO
If you wish to change you can; But remember i'll probably be back one day. :D Thanks Hamlet.