Cuberite Forum

Full Version: Mobs attacking Players
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there anyway (in Lua) to make a mob attack a player besides having a player take damage from the mob?

I'd like to be able to make skeletons attack players and miss on occasion, or zombies strike players and not do any damage too. Part of the fun is the animation. Wink

Any direction on this?
I'm afraid this is not possible yet. It would require some form of collaboration with the AI (set the target player to attack / follow), which is missing at this point.
Missing the attack on occasion should be doable - simply have the OnTakeDamage hook lower the damage, or for skeletons, when an arrow is spawned, modify its speed a bit.
(02-09-2015, 08:36 AM)xoft Wrote: [ -> ]I'm afraid this is not possible yet. It would require some form of collaboration with the AI (set the target player to attack / follow), which is missing at this point.
Missing the attack on occasion should be doable - simply have the OnTakeDamage hook lower the damage, or for skeletons, when an arrow is spawned, modify its speed a bit.

How would you propose doing this?

The AI could easily send a cMonster:FollowPlayer(cPlayer) to have it move towards the player.

Depending on ranged/melee attacks a cMonster:AttackPlayer(cPlayer, int) where the int would be the percentage of success (0-100) or something like that.
Is this still unsupported by the API? I couldn't readily find reference to it in the API doc.
It is still unsupported, but a major AI rewrite is in progress, and that may change.