New mob mod

User avatar
burli
Member
 
Posts: 1637
Joined: Fri Apr 10, 2015 13:18

New mob mod

by burli » Mon Jul 11, 2016 11:18

Well, I don't want to call it API, because I think API is the wrong term

Those who follow the Post your videos thread may have seen what I'm working on. I'm unhappy with the current mobs so I decided to make my own mod with a different approach. I want to implement the steering behaviours from Craig Reynolds described in this paper

I also want to move most of the code from the "API" to the mob itself because I think the behaviour depends on the mob and if the mob can not breed for example there is no need for breeding code. So I completely removed the on_step function from the "API" like in mobs_redo and moved it to the mob itself. I want to provide lots of functions to build mobs and a mob template to start with.

The code for the wanderer from the third video is not more than this

Code: Select all
   on_step = function(self, dtime)
      self.acceleration = vector.new(0,0,0)
      self.pos = self.object:getpos()
      self.yaw = self.object:getyaw()

      mobs:apply_force(self, mobs:separate(self))
      mobs:apply_force(self, mobs:wander(self))

      local y_velocity = self.object:getvelocity().y
      
      self.velocity = vector.add(self.velocity, self.acceleration)
      self.velocity = vector.limit(self.velocity, self.walk_velocity)
      
      self.object:setvelocity({x = self.velocity.x, y = y_velocity, z = self.velocity.z})
      self.object:setyaw(vector.yaw(self.velocity))
   end,


It should be more like a construction kit with some specific configurations to make each mob individual.

I can't implement the full hierarchy of motion behaviour. This would include the calculation of each position per step. I skip this calculation and use the velocity from the previous step directly for setvelocity, which seems to work pretty well. I have tested it with over 170 sheeps and it worked without any noticeable lag, except if an new mapblock with new mobs is loaded. But I guess this is an engine issue

In the next step I will give the mobs the ability to see, hear or other "senses" and add more behaviours. My first "victim" will be the sheep
 

Robsoie
Member
 
Posts: 90
Joined: Fri Apr 29, 2016 16:22

Re: New mob mod

by Robsoie » Tue Jul 12, 2016 14:00

I just watched your videos from your post on the video thread and the less i can say is that i'm very impressed.

And getting 170 creature using your movement code without any lag, that's nothing short of amazing.
Good luck in improving your excellent work.
 

User avatar
burli
Member
 
Posts: 1637
Joined: Fri Apr 10, 2015 13:18

Re: New mob mod

by burli » Tue Jul 12, 2016 14:58

Until now there is no real magic. I just calculate some vectors and leave the rest to the engine. It will become interesting if I have to read nodes and make decisions

I will upload the video later
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: New mob mod

by Byakuren » Wed Jul 13, 2016 23:18

Are you naming your mod "mobs"?

EDIT: Also I would recommend using yaw prediction less than 1 so that the turning looks smoother.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
burli
Member
 
Posts: 1637
Joined: Fri Apr 10, 2015 13:18

Re: New mob mod

by burli » Thu Jul 14, 2016 03:13

Byakuren wrote:Are you naming your mod "mobs"?

EDIT: Also I would recommend using yaw prediction less than 1 so that the turning looks smoother.


I decided to name it s_mobs where s stands for steering, smooth or smart, whatever you prefer.

And the smoothness is limited because of the on_step call frequency
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: New mob mod

by Byakuren » Thu Jul 14, 2016 09:01

burli wrote:
Byakuren wrote:Are you naming your mod "mobs"?

EDIT: Also I would recommend using yaw prediction less than 1 so that the turning looks smoother.


I decided to name it s_mobs where s stands for steering, smooth or smart, whatever you prefer.

And the smoothness is limited because of the on_step call frequency


If you use the automatic_face_movement_dir property of an entity, it will gradually change visual yaw to match its velocity. I think the scale is 0.0 for no yaw prediction and 1.0 for immediately changing yaw to the movement direction. I think it might be worth removing manual yaw sets when you change your mob direction and instead use an automatic_face_movement_dir value somewhere between 0.9 and 0.99
Every time a mod API is left undocumented, a koala dies.
 

User avatar
burli
Member
 
Posts: 1637
Joined: Fri Apr 10, 2015 13:18

Re: New mob mod

by burli » Thu Jul 14, 2016 10:27

Doesn't work well. Can't find values for a smooth rotation. Manual rotation works better so far and doesn't cost much more CPU time
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: New mob mod

by Byakuren » Thu Jul 14, 2016 16:58

Alright.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
burli
Member
 
Posts: 1637
Joined: Fri Apr 10, 2015 13:18

Re: New mob mod

by burli » Thu Jul 14, 2016 17:16

Maybe I do it wrong, but I don't think so. And if I set yaw manually I have more control
 

User avatar
maikerumine
Member
 
Posts: 1348
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: New mob mod

by maikerumine » Thu Jul 14, 2016 17:57

I really like where you are going with this. :) Keep up the progress.
 

User avatar
burli
Member
 
Posts: 1637
Joined: Fri Apr 10, 2015 13:18

Re: New mob mod

by burli » Fri Jul 15, 2016 04:51

Thanks. I was able to limit the rotation speed. Now they don't spin around like crazy. And they can see the nodes around, jump upstairs or turn around in front of a wall

Works well, but still far away from finished
 

User avatar
burli
Member
 
Posts: 1637
Joined: Fri Apr 10, 2015 13:18

Re: New mob mod

by burli » Fri Jul 15, 2016 10:48

And I guess I have to start optimization. My routine takes more than twice the time than mobs_redo. One thing is that I do a lot of vector calculation with 3d routines, but I only need 2d vectors. So maybe I will write a 2d vector library. Than I want to optimize as much as possible.

But I think it will be impossible to get the same time like mobs_redo
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest