by MirceaKitsune » Sat Feb 16, 2013 18:57
I have two suggestions for the mob framework. I posted them in the wrong thread, so re-writing here since I think this mod is by another author:
1 - Alert levels for mobs before attacking. The more a mob is aware of the player (has visual contact or hears them walking) the faster its alert level grows, while no longer seeing or hearing the player makes alert decrease until it goes back to 0. The higher the alert level, the more that mob will run and investigate the spot where it last sensed the player. Once alert level reaches 1, the the mob will attack the player and be fully aware of them. If during battle the player manages to lose the mob (without putting the chunk to sleep and de-spawning it) the mob's alert level will again begin to drop till it eventually goes back to 0. An alert mob will also increase the alertness of nearby mobs slowly. How fast the mob gets aware and forgets should be a per-monster settings.
For example: Lets say a mob needs to see the player for one second before realizing it should attack. If the player manages to hide behind a solid block after half a second of being seen, the mob's alert level will be 0.5. It will be pretty nervous and investigate the area. Now if it sees the player for a quarter second, its alert would increase by another 0.25 and get to 0.75, making the mob even more scared while knowing more exactly where the player is. But the player is no longer seen for 10 seconds, so alert level begins to slowly drop. In 30 seconds, the mob forgets what happened and resumes to walking around.
Although this might sound hard, it should be easy to do in LUA. Whenever the player alerts a mob, its last position is saved as a vector which is the spot that mob is alert of. Alertness level would be a float ranging from 0 to 1 and indicating how much the mob will try to run toward that spot and around it. The location accuracy and frequency of this would depend on alertness level itself.
2 - Similar to 1, but a separate idea that can be a different system. When a mob is hurt during battle, it would cry out, alerting other mobs of its kind in the area (who would normally not see the player) to come and help. They will come and attack the player too.
Let me know what you think and if any of this can be put on your list. It would be fantastic if you could consider adding such behavior to the AI, and I'd totally love to see something like that :)