For today's update, I have some slightly bad news and some very good news.
The bad news is that I won't be able to add item pickpocketing like I announced. It turns out that for some reason, attached entities cannot have a bounding box, meaning you can't select worn items by looking at them. Considering this, the items module will pretty remain a visual effect to see wielded items without offering any gameplay changes, although that's still an useful and pleasant feature.
Now for the good news: During the last days, I've been hard at work implementing a realistic detection mechanism for mobs. Mobs no longer magically know where everyone around them is, just because it's within their view range. Target detection is instead based on three senses: Seeing, hearing, and touching. You can sneak up behind mobs, hide to not be noticed, and pretty much get the essential mechanics you see in most stealth games. This is the exact mechanism now used in GIT:
- Touching:A mob will first of all notice a target if it's bumping into it. We know this by calculating the bounding box of the mob and that of the target, and checking if they are closer than 0.25m.
- Hearing:An audibility mechanism was introduced. The function can be used by anything that triggers a sound connected to a player or mob, and can set them as audible by amount X and for duration Y. By default, a creature will be heard by mobs when it: Punches a node, digs a node, places a node, makes footstep sounds by walking, or makes a vocal sound (like the pain or attack sounds).
What's even cooler is that for nodes, audibility is automatically determined by the type of node you're interacting with. This is possible by fetching and using the gain value of the sounds directly from the node definition! For instance, mobs or players that walk on grass will produce less noise and be harder to hear than mobs who walk on stone, whereas digging a dirt node will draw less attention than breaking a glass node.
If you wish to sneak behind a mob without being heard, you must hold down the sneak button as you move. That way you will not get an audibility level, and mobs won't notice you if you're behind them and don't bump into anything.
- Vision:The third check if visual sight, which itself got a few additions. The most important is a field of view scanner, which makes sure that mobs only see people in their view range and not those behind them! It uses the FOV setting from minetest.conf, meaning that whatever focal length the server defaults to for players will be used by mobs as well. The formula used to calculate the virtual cone was a bit problematic, and got written with a lot of help from TeTpaAka and Nore... you can see what went on in
this thread or the IRC logs.
Detection will also depend on light level additionally. A creature standing in broad daylight will be easier to see, whereas a creature in a dark spot mode difficult. Hiding in the dark reduces the changes of being seen by an enemy mob.
Rochambeau wrote:Great mod so far!
Two wishes though:
1. could you split up creatures_races_default/init.lua into several files for each mob or race? This way it would be easier to keep track of the whole thing.
2. could you implement reproduction of mobs (by feeding them special items)?
I might consider #1 at some point. #2 probably won't happen for the default creatures, but might be possible to do by using a custom function in your creature definition... especially with how flexible scripting custom functionality without changing the core mod is now.