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

Post Reply
User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

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

by azekill_DIABLO » Post

Mobs Intelligence : Lightweight Api > see also Website :

Image
+ Spoiler
Template mobs are disgusting, I know. Create your own mobs easely! Check mob.lua to learn how!

Links and Download :

[On Github] the API.
[Download] from github.


┬┴┬┴┤ ͜ʖ ͡°) ├┬┴┬┴ Have fun!
Attachments
screenshot_20170420_205048.jpg
(627.12 KiB) Not downloaded yet
screenshot_20170420_205035.jpg
(332.44 KiB) Not downloaded yet
screenshot_20170420_205018.jpg
(521.17 KiB) Not downloaded yet
Last edited by azekill_DIABLO on Sun May 13, 2018 12:52, edited 51 times in total.

User avatar
pithy
Member
Posts: 251
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: M.I.L.A.

by pithy » Post

I bet it will have bugs.

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: M.I.L.A.

by azekill_DIABLO » Post

e'
Last edited by azekill_DIABLO on Thu Oct 13, 2016 19:39, edited 1 time in total.

User avatar
pithy
Member
Posts: 251
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: M.I.L.A.

by pithy » Post

sorry thought it be an ok thing to say because your signature says "i'm an exelent bug-maker(yeah...i know...i have a bad reputation)",

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: M.I.L.A.

by azekill_DIABLO » Post

Yeah. i already know that :)
i'm encountering some problems but i will find a solution :D

Sokomine
Member
Posts: 4186
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: M.I.L.A.

by Sokomine » Post

azekill_DIABLO wrote:
pithy wrote: I bet it will have bugs.
Hey, please don't say things like that. If you think it will have bugs before the project is really started, you think it's funny?
Might as well see that comment in a positive way :-) Any reasonably large (not trivial) programming porject *will* have bugs. They're hard to avoid. Some very few exceptional projects manage to get by with very few bugs, but those are extremly rare projects. TeX comes to mind. And then..er...there might be similar ones, but they're few and sparse.
A list of my mods can be found here.

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: M.I.L.A.

by azekill_DIABLO » Post

you're true.

User avatar
taikedz
Member
Posts: 695
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: M.I.L.A.

by taikedz » Post

I quite like mobs_redo... but am intrigued!

Post github and collab? You should set out aims rules and target design so people know what you are likely to accept.

Je fais traducs si tu veux :-P

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

Re: M.I.L.A.

by octacian » Post

Why do so many people want monsters? Monsters have ruined almost every game I know of. Real life animals are just as challenging if that's what people want.
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

User avatar
taikedz
Member
Posts: 695
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: M.I.L.A.

by taikedz » Post

So you dont want mobs on your servers? Fine.

Why did you bother entering a discussion for those who do?

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: M.I.L.A.

by azekill_DIABLO » Post

A little problem is that the register entity fonction is not very well defined... What are the basics arguments i can use? like health or speed?i didn't found anything about it....

User avatar
taikedz
Member
Posts: 695
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: M.I.L.A.

by taikedz » Post

As far as I am aware, entities have no such thing as HP - that's something you define for yourself.

you can do

Code: Select all

minetest.register_entity("modname:entityname", {
type = "milamob",
hp = 40,
mp = 100,
speed = 2,
speed_on_speed = 30,
name = "Gandalf",
}
)
And the entity will carry that. It is up to your own code to then manage the HP as you want it to.

When the HP reaches zero, it is your code's responsibility to remove the lua entity from te world.

There is no such thing as a mob at minetest level. Just lua entities.

User avatar
TenPlus1
Member
Posts: 3020
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: M.I.L.A.

by TenPlus1 » Post

Entities have the 'hp_max' flag to set health and will automatically remove points for different tools used on it.

User avatar
taikedz
Member
Posts: 695
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: M.I.L.A.

by taikedz » Post

Hi azekill,

Following TenPlus1's post, yes indeed, there is an HP. Check the documentation for LuaEntitySAO. I should have too, before replying so fast :-P

http://dev.minetest.net/LuaEntitySAO

You call register_entity with the name of the entity, then a table with the default values you want your entity to have.

I will confess that I am by no means an expert on this - just I have been picking at TenPlus1's mobs_redo so as to determine how to modify mob behaviour at load-time for my game, without changing his code.... so..... take my advice with my basic level knowledge in mind :-P

Still, if you thought that Minetest engine had some built-in system for mobs so that you could make something even simpler than mobs_redo or mobf, well... go talk to the core dev team to ask them for an engine-level API :-)



There is a lot of work to be done here, and I think that rather than building a new mob framework, you should probably fork an existing mob engine and remove things that you think are surplus to a basic mob engine.

Bearing in mind the goal of MILA to be lightweight, I expect the following things need to be taken into account at minimum, and at most:
  • Prototype:

    Default data:
    * A default routine to move towards a target position
    * A default routine to seek for players
    * A default attack routine
    * A default runaway routine
    * A default routine to handle being punched
    * A default state = "idle"

    Instances:
    * Current state -- whether the mob is walking, running, or attacking, or merely idle

    Mod-provided data:
    * behaviour = one of {"hostile","friendly"}
    * Mesh -- the meshfile to use
    * Texture -- texture to use on the mesh
    * animation keyframe indices, with animation speeds
    * A right-click callback routine
Calling the library -- I suggest the following be a reference example:

Code: Select all

mila:register_mob("modpack:mobname",
{
	mesh = "meshname.x",
	textures = {"texture_1.png","texture_2.png"},
	hp_max = 30,
	animations = {
		walk = {start=0,end=20,speed=10},
		run = {start=0,end=20,speed=20},
		attack = {start=21,end=30,speed=5},
		idle = {start=31,end=35,speed = 5}
	},
	behaviour = "friendly",
})

mila:register_egg("modpack:mobname",{
	inventory_image = "texture.png"
})

mila:register_spawn("modpack:mobname",{
	min_alt = -100,
	max_alt = 31000,
	spawn_on = "default:dirt_with_grass",
	spawn_by = {"default:tree","default:water_source","group:flowers"},
})
The key areas that MILA would have to manage then will be:

  • * locating targets
    * moving the mob
    * animating the mob
    * handling the activity state
    * spawning mobs to populate the world
    * spawning from egg placement
    * removing mobs to prevent overpopulation
This should be all that is necessary for a MILA mob. Many fancy things such as spawn time and conditions, environment damage, flight, eating, reproduction etc are absent from this, to keep it light.

Any thoughts? Anything I missed? Should an effort for a lightweight framework be its own project or a pared-down fork of something else?

You're going to need a good reason to be making a new mob engine from scratch when we already have a couple of good, well-featured ones ;-)

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: M.I.L.A.

by azekill_DIABLO » Post

yeah i will have a lot of work. lol. feel dumb right now.
But thank you for your answers!

Edit: looks like mob redo with 'mila' instead of 'mobs' :D

User avatar
taikedz
Member
Posts: 695
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: M.I.L.A.

by taikedz » Post

azekill_DIABLO wrote:Edit: looks like mob redo with 'mila' instead of 'mobs' :D
Yes, because that's what I've been working with until now :-P But I feel they would be the appropriate minimum.

Also there a re a lot less options :-)

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: M.I.L.A.

by azekill_DIABLO » Post

yes. i'm working on this right now. looks not so hard to register a working entity.

Edit i say that and i will post something like : "argh keeps bugging" in 10 seconds

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: M.I.L.A.

by azekill_DIABLO » Post

god seems like it worked holy... oh a bug.

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: M.I.L.A.

by azekill_DIABLO » Post

ideas of code to make an entity move? i use setacceleration but it kinda do, nothing at all. please help! remenber it's a community project!

User avatar
taikedz
Member
Posts: 695
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: M.I.L.A.

by taikedz » Post

azekill_DIABLO wrote:ideas of code to make an entity move? i use setacceleration but it kinda do, nothing at all.
http://dev.minetest.net/LuaEntitySAO

You want setvelocity(vector)

Probably something like this:

Code: Select all

local speed = 1
local playerposition = playerobject:getpos()
local mobposition = mobobject:getpos()
local direction = vector.direction(playerposition,mobposition)
local displacement = vector.distance(playerposition,mobposition)

mobobject:setvector({x=speed*direction.x/displacement, y=speed*direction.y/displacement,z=speed*direction.z/displacement})
azekill_DIABLO wrote:please help!
Remember to search, and try to understand what already exists.

This is how mobs_redo implements walking

https://github.com/tenplus1/mobs_redo/b ... 1295-L1331 (highglighted code)
azekill_DIABLO wrote:remenber it's a community project!
Really? It looks like you are working on the code in secret.... :-P

You did not post any URL where we can see the code, so you have not yet opened it to the community ;-)

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: M.I.L.A.

by azekill_DIABLO » Post

sorry

Code: Select all

--say that Mila is running.

mila = {}

--for the entities

player= {}

--register some basic things. (here the move. needs some improvements)

local speed = 1
local playerposition = player:getpos()
local mobposition = self.object:getpos()
local direction = vector.direction(playerposition,mobposition)
local displacement = vector.distance(playerposition,mobposition)

--register the first function (add).

function mila.add_entity(name,def) 
	minetest.register_entity(name, {
		mesh = def.mesh,
		textures = def.textures,
		hp_max = def.hp_max,
		on_step = def.on_step,
		})
end

--try to register the first entity.

mila.add_entity("mila:attack", {
		hp_max = 30,
		collisionbox = {-0.5, -0.5, -0.5,  0.5, 0.5, 0.5},
		mesh = "sheep.x",
		textures = {"default_dirt.png"},
		on_step = {obj:setvector({x=speed*direction.x/displacement, y=speed*direction.y/displacement,z=speed*direction.z/displacement})},
		})
	
--then the egg. (needs some work to be a function tough)

minetest.register_craftitem("mila:sheep_egg", {
		description = "Sheep Egg",
		inventory_image = "default_dirt.png",
		wield_image = "default_dirt.png",
		wield_scale = {x = 1, y = 1, z = 0.5},
		liquids_pointable = true,
	on_place = function(itemstack, placer, pointed_thing)
		if pointed_thing.type == "node" then
			pointed_thing.under.y = pointed_thing.under.y + 1
			minetest.add_entity(pointed_thing.under, "mila:attack")
		end
	end,})
it looks like that

the problem is here

Code: Select all

local speed = 1
local playerposition = player:getpos()
local mobposition = self.object:getpos()
local direction = vector.direction(playerposition,mobposition)
local displacement = vector.distance(playerposition,mobposition)
looks like getpos is nil.

User avatar
taikedz
Member
Posts: 695
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: M.I.L.A.

by taikedz » Post

[EDIT - code has been subsequently posted!]

Don't care. If you want help, post the code.

Show your project while you develop it, and we'll believe you're serious. Bad code can be improved only if it is seen.

Hidden code is not worth a community's time. Not in Minetest, not in Apache, not in Firefox, not anywhere.
Last edited by taikedz on Thu Aug 25, 2016 11:50, edited 1 time in total.

User avatar
azekill_DIABLO
Member
Posts: 7502
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [help needed]M.I.L.A. [community][mod][api]

by azekill_DIABLO » Post

i've pasted it in my last post. and in my 1st post too

User avatar
taikedz
Member
Posts: 695
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [help needed]M.I.L.A. [community][mod][api]

by taikedz » Post

\o/

:D

Will take a look!

User avatar
taikedz
Member
Posts: 695
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [help needed]M.I.L.A. [community][mod][api]

by taikedz » Post

[EDIT corrected the step routine]
azekill_DIABLO wrote:i've pasted it in my last post. and in my 1st post too
Thanks :)

So here's an improved version and some notes in the comments. Try following the logic there.

First adjustment: everything defined for mila should be a function associated with the mila object

Second adjustment: you need to pass the functions to the lua entity after it is created

Third adjustment: do not require the mod creator who uses mila to make their own walking algorithms. We need to define that.

This is what the code should look like. There are probably still some bugs, but they should be fewer.

Code: Select all

--define a global mila table

mila = {}

--register some basic things. (here the move. needs some improvements)


function mila:mila_step(self,dtime) -- we define a general stepping function that we will give to all mobs that get registered
	--find a player
	playerlist = minetest.get_objects_inside_radius(s, self.view_range)
	if not playerlist then return end -- no players in range, stand still.

	-- if player found, choose one
	local playerobj = playerlist[math.random(1,#playerlist)] -- number between 1 and number of items in playerlist
	-- move towards player

	local playerposition = playerobject:getpos()
	local mobposition = self:getpos() -- .... it should be self I think. else try self.ref:getpos()
	local direction = vector.direction(playerposition,mobposition)
	local displacement = vector.distance(playerposition,mobposition)
	self:setvector({x=self.speed*direction.x/displacement, y=self.speed*direction.y/displacement,z=self.speed*direction.z/displacement})
end

--register the first function (add).

function mila:add_entity(name,def) -- define and access functions on Lua tables using the ":" operator
	local luae = minetest.register_entity(name, {
		mesh = def.mesh,
		textures = def.textures,
		hp_max = def.hp_max,
		speed = def.speed, -- register speed per entity, not globally
		view_range = def.view_range,
		-- on_step = def.on_step, -- don't require the modder to define this function.
	})
	luae.on_step = mila.mila_step -- add moving function ourselves, use '.' notation to access the variables' references, don't call them
end

--try to register the first entity.

--mila.add_entity("mila:attack", { -- you meant mila:sheep, right?
mila:add_entity("mila:sheep", { -- define and access functions on Lua tables using the ":" operator
	hp_max = 30,
	collisionbox = {-0.5, -0.5, -0.5,  0.5, 0.5, 0.5},
	mesh = "sheep.x",
	textures = {"default_dirt.png"},
	speed = 1,
	view_range = 5,

	--entites should not need to define their own walking algorithms - this is what the framework should be doing !
	--on_step = {obj:setvector({x=speed*direction.x/displacement, y=speed*direction.y/displacement,z=speed*direction.z/displacement})},
})
	
--then the egg. (needs some work to be a function tough)

minetest.register_craftitem("mila:sheep_egg", {
	description = "Sheep Egg",
	inventory_image = "default_dirt.png",
	wield_image = "default_dirt.png",
	wield_scale = {x = 1, y = 1, z = 0.5},
	liquids_pointable = true, -- oh le pauvre! :-P
	on_place = function(itemstack, placer, pointed_thing)
		if pointed_thing.type == "node" then
			pointed_thing.under.y = pointed_thing.under.y + 1
			local mobe = minetest.add_entity(pointed_thing.under, "mila:sheep") -- sheep!
			mobe.hp = math.ceil(math.random(mobe.hp_max*0.8,mobe.hp_max) ) -- set a random actual HP between 80-100% of mob's max_hp
		end
	end,
})
Last edited by taikedz on Thu Aug 25, 2016 18:50, edited 2 times in total.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests