Mobs Spawn (and probably despawn and Tick)
#1
Hello,

Despite the default of communication on my side on the subject, I wanted you to know I'm still implementing the Mob Spawn.

It went far from starting point, as I had some trouble finding "baby steps".

What I will release (and ask you to validate), is a partial implementation of this algorithm that include a world.ini configuration :
http://www.minecraftwiki.net/wiki/Spawning#Mob_spawning

It's my first job using chunks, so I tried to make it clean (using ChunkMap lock, and mutualising randoms, f.i.) but I'm pretty sure I didn't get it all.

Job almost done, you'll have a patch this week.
Reply
Thanks given by:
#2
Ok, I'm really looking forward to this. I guess I must've made your life terrible yesterday, committing across so many files, possibly generating conflicts...
Reply
Thanks given by:
#3
Hello.

As mobs are suppose to spawn on Opaque block (i.e. non-transparent), I figured out that water was not inside g_BlockTransparent.
For now I hacked this with something like :
Code:
if (g_BlockTransparent(a_BlockType) || a_BlockType == E_BLOCK_TYPE_WATER)
As i didn't want to add sides effects.

Do you think I can put water and lava inside g_BlockTransparent ?
Reply
Thanks given by:
#4
Renember that squids spawn on water.
Reply
Thanks given by:
#5
The transparency / solidity arrays are not updated as often as they should, if you find anything missing, feel free to change them.
Also, to check for water, use IsBlockWater() function instead, because there are two water blocks (normal and stationary). Same with lava.
Reply
Thanks given by:
#6
This is almost done (still have to settle the Random business, that didn't convinced me + finalize my style-checks, as you guys seems to be careful on spaces and case).

For now, I got problems with the Tick method of the monsters, as i relocated it in the global cWorld::TickMobs(...) method.
The reason why i did that is because we don't want to move mobs that are far away from any players.

But now I've got spawning and ticking I got alot of "mob is inside wall" warnings.
I'm not pretty sure this is a side effect that i should correct, or another feature.

I looked the Monster::Tick() method, that use speed instead of position (basically : you move in direction of your target and if you are heading to a wall, you add jumping), and I'm pretty sure this is not a viable option.
I saw that there is some tickets associated to mobs jumping.

Would you agree that I commit my patch without handling this behavior (that is now problematic as there is a lot of mobs everywhere), and start to work on this problem after that ?

About the IA : A long time ago, I used to be IA main-coder on another game (that was commercially released by ea games, but didn't sell a lot). What I think is that we do not need complex IA here (like emerging comportment). Just some easy "scripted" rules. Mobs are not supposed to be smart, plus we lack the calculation power to make it work fine. I assume this was your idea anyway.
Reply
Thanks given by:
#7
How did you move the mob ticking into cWorld? The mobs are owned by the chunk that they belong to, I have rewritten it to be so for various reasons, so ticking the mobs makes sense only in the chunk's tick method. The distance to players could simply be made a less "stringent": for example, precalculated and stored within the mob's datastructure and updated only once every N ticks (or when a player joins / leaves), since it is not required to be perfectly exact.

The "inside a block" warning is due to us not having a proper collision detection implemented yet, it should be safe to ignore it for now and commit your work without handling it.

IA: is that supposed to be artificial intelligence? Usually that's abbreviated to AI; I don't know anything that would be called IA in this context. Our AI is terrible, really, and any attempts to improve on it have only led to people becoming fed up with the project and leaving. The last such victim is Keyboard, he said he'd try to make something out of it, but we haven't heard from him for some time now.

As for the random - what are you using in the end? I still think that using the cNoise class with a counter would have been the best option here, it's both thread-safe enough and performant enough.
Reply
Thanks given by:
#8
Plus the Monster::tick algorithm make all squids keep "jumping", because it defines "going in the wall" as going below Chunk::HeightMap.
And HeightMap defines height as the first non-air cube.
Reply
Thanks given by:
#9
some weeks ago I asked keyboard (on a PM) if he was still working on physics and he said he was adding some dificult things
Reply
Thanks given by:
#10
(07-11-2013, 12:12 AM)xoft Wrote: How did you move the mob ticking into cWorld? The mobs are owned by the chunk that they belong to, I have rewritten it to be so for various reasons, so ticking the mobs makes sense only in the chunk's tick method.
You'll see what i propose. I'm not revolutioning things.

(07-11-2013, 12:12 AM)xoft Wrote: The "inside a block" warning is due to us not having a proper collision detection implemented yet
Not sure it's only that.
A monster facing a small step should not try to jump diagonally, but jump vertically, then go horizontally.
   
A monster facing a tree should not try to jump over it.
A good collision algorithm will only transform ghost-mobs (mobs that go through walls) into dumb mobs (mobs that try to go through wall but doesn't succeed)

(07-11-2013, 12:12 AM)xoft Wrote: it should be safe to ignore it for now and commit your work without handling it.
Ok, that's what i wanted to be sure. Thanks.

(07-11-2013, 12:12 AM)xoft Wrote: IA: is that supposed to be artificial intelligence? Usually that's abbreviated to AI
Yeah, French people tend to use reverse order. Sorry for that.

(07-11-2013, 12:12 AM)xoft Wrote: Our AI is terrible, really, and any attempts to improve on it have only led to people becoming fed up with the project and leaving. The last such victim is Keyboard, he said he'd try to make something out of it, but we haven't heard from him for some time now.
Sorry to read that.

(07-11-2013, 12:12 AM)xoft Wrote: As for the random - what are you using in the end?
For now : nothing.

(07-11-2013, 12:12 AM)xoft Wrote: I still think that using the cNoise class with a counter would have been the best option here, it's both thread-safe enough and performant enough.
cNoise is good enough for me, but I think I'll a a coder-friendly method that return an integer in the specified range. As I didn't succeed to find one (the existing one need me to do the math at each call).

Thanks
Reply
Thanks given by:




Users browsing this thread: 19 Guest(s)