Trying to figure out how to make a bat attack a player, or if it's not possible, how to make them go after the player at least. I know it's possible, just don't know how. Any help is appreciated.
OK, the question is, do you want to make your own AI, or use Minecraft's pre-built AI to your advantage?
If you selected the former, things just got alot harder. You will need a thorough amount of understanding of command blocks.
If you selected the latter, I can fit it in a forum post.
Since the bat doesn't go after anything on it's own, we will have to attach it to another hostile mob.
The two most ideal choices for this are Zombies and Skeletons, as they will stay out of the light automatically (You wouldn't want a bat in broad daylight, that would be wrong.)
The problem with Zombies are:
1. They attack Villagers too.
2. They are slow.
We can fix these problems, but it would require more scoreboard/team manipulation and commands.
So therefore, we should choose a Skeleton.
If we summon a Skeleton, it won't have a bow, so it will attempt to melee you.
We should also give it a custom name, so it won't be confused with other skeletons.
The summon command is this:
/summon Skeleton ~ ~ ~ {CustomName:"BatAI"}
The commands to make a simple AI are as follows:
/scoreboard objectives add BatAlive dummy
/scoreboard players set @e[type=Skeleton] BatAlive 0
I'm not quite sure I understand, and I'm getting what seems to be, unintentional side effects.
When I put all those commands on a fill clock, and then spawn a bat and skeleton with the commands, they both die instantly, if I spawn a bat first, it just flies up into the sky
If I spawn a skeleton at all, it immediately dies, if I put the spawn command on the clock, they spawn and die infinitely, and I get infinite drops, which lag
This should allow bats to target and move toward a random player within ~16 blocks in any direction of the bat. It works by starting at the bat and looking for a player in a rectangular prism in each different direction of the bat and it is also making sure that air is in the block it would be moving into. If all checks out then the bat will tp towards the player. For best results, connect these commands to a fill clock.
Edit: If there are multiple people within ~16 blocks of the bat, it very well might try to target both of them.
This should allow bats to target and move toward a random player within ~16 blocks in any direction of the bat. It works by starting at the bat and looking for a player in a rectangular prism in each different direction of the bat and it is also making sure that air is in the block it would be moving into. If all checks out then the bat will tp towards the player. For best results, connect these commands to a fill clock.
Edit: If there are multiple people within ~16 blocks of the bat, it very well might try to target both of them.
That's still helpful, but I would like it if the bat didn't constantly stick to the player, since I want them to take wither damage for 2 seconds when the bat touches them. I guess I just really want to know how to make my own AI for the bat using command blocks.
That's still helpful, but I would like it if the bat didn't constantly stick to the player, since I want them to take wither damage for 2 seconds when the bat touches them. I guess I just really want to know how to make my own AI for the bat using command blocks.
Sure just add a cooldown, similar to a mob's AttackTime nbt tag.
Now the bat will get within 1 block of a player, give them wither x3 for 1 second. I can't remember if wither's damage changes with each additional amplifier or not so you may need to adjust that. After the bat has "attacked" a player, the custom AI will turn off for 60 ticks, or 3 seconds, after that they will come back to attack again.
That may work, but for future purposes, I would like to know how to make custom AI, unless this is it, then I need to learn more to figure out how all this works.
This is a form of custom AI. Of course you can go much more into detail and make it much better. This is a basic AI that simply makes bats move directly towards the player, no kind of path finding at all.
ok, I played around with the variables, and I have something I like, thanks, but is there a way to make it go after me slower? and from farther away? it also flies away WAY too fast before the cool-down time is up, it is already out of range to attack again
Trying to figure out how to make a bat attack a player, or if it's not possible, how to make them go after the player at least. I know it's possible, just don't know how. Any help is appreciated.
OK, the question is, do you want to make your own AI, or use Minecraft's pre-built AI to your advantage?
If you selected the former, things just got alot harder. You will need a thorough amount of understanding of command blocks.
If you selected the latter, I can fit it in a forum post.
Since the bat doesn't go after anything on it's own, we will have to attach it to another hostile mob.
The two most ideal choices for this are Zombies and Skeletons, as they will stay out of the light automatically (You wouldn't want a bat in broad daylight, that would be wrong.)
The problem with Zombies are:
1. They attack Villagers too.
2. They are slow.
We can fix these problems, but it would require more scoreboard/team manipulation and commands.
So therefore, we should choose a Skeleton.
If we summon a Skeleton, it won't have a bow, so it will attempt to melee you.
We should also give it a custom name, so it won't be confused with other skeletons.
The summon command is this:
/summon Skeleton ~ ~ ~ {CustomName:"BatAI"}
The commands to make a simple AI are as follows:
/scoreboard objectives add BatAlive dummy
/scoreboard players set @e[type=Skeleton] BatAlive 0
/effect @e[type=Skeleton] minecraft:invisibility 1000000 255
/effect @e[type=Skeleton] minecraft:resistance 1000000 255
/execute @e[type=Bat] ~ ~ ~ tp @e[type=Bat,c=1] @e[type=Skeleton,name=BatAI,c=1]
/tp @e[type=Bat] ~ ~1 ~
/execute @e[type=Bat] ~ ~ ~ scoreboard players set @e[type=Skeleton,r=2] BatAlive 1
/kill @e[type=Skeleton,name=BatAI,score_BatAlive=0]
Attach it to a fill clock in this order.
And that's how you make a simple bat AI!
(Don't try this at home kids, your parents might get mad at you for starting a vampire bat apocolypse. Just saying...)
Hope I helped,
The_Topazian
Please check out my PvP map based around explosions and fire, FireFight!
Sometimes, I wonder why they call mapmakers mapmakers and not cartographers.
Dragons n' Stuff
Please click!
I'm not quite sure I understand, and I'm getting what seems to be, unintentional side effects.
When I put all those commands on a fill clock, and then spawn a bat and skeleton with the commands, they both die instantly, if I spawn a bat first, it just flies up into the sky
If I spawn a skeleton at all, it immediately dies, if I put the spawn command on the clock, they spawn and die infinitely, and I get infinite drops, which lag
edit:
I fixed the dying, had two command blocks for "/tp @e[type=Bat] ~ ~1 ~"
but now the bat doesn't fly around, and the skeleton is always on fire, and when I kill the bat, it drops bones and arrows?
Yeah, it's basic.
The point of the skeleton being able to catch on fire is because bats don't exactly like sunlight.
The bat not flying around is intentional. Having the bat 10 blocks in the air attacking you isn't realistic.
Please check out my PvP map based around explosions and fire, FireFight!
Sometimes, I wonder why they call mapmakers mapmakers and not cartographers.
Dragons n' Stuff
Please click!
Well, how would I make my own AI then? As cool, and useful as that is, it's not too practical. Especially for my use.
/execute @e[type=Bat] ~ ~-8 ~-4 detect ~1 ~8 ~4 minecraft:air 0 execute @r[type=Player,dx=16,dy=16,dz=8] ~ ~ ~ tp @e[type=Bat,c=1] ~0.5 ~ ~
/execute @e[type=Bat] ~-16 ~-8 ~-4 detect ~15 ~8 ~4 minecraft:air 0 execute @r[type=Player,dx=16,dy=16,dz=8] ~ ~ ~ tp @e[type=Bat,c=1] ~-0.5 ~ ~
/execute @e[type=Bat] ~-4 ~-8 ~ detect ~4 ~8 ~1 minecraft:air 0 execute @r[type=Player,dz=16,dy=16,dx=8] ~ ~ ~ tp @e[type=Bat,c=1] ~ ~ ~0.5
/execute @e[type=Bat] ~-4 ~-8 ~-16 detect ~4 ~8 ~15 minecraft:air 0 execute @r[type=Player,dz=16,dy=16,dx=8] ~ ~ ~ tp @e[type=Bat,c=1] ~ ~ ~-0.5
/execute @e[type=Bat] ~-4 ~ ~-4 detect ~4 ~1 ~4 minecraft:air 0 execute @r[type=Player,dx=8,dy=16,dz=8] ~ ~ ~ tp @e[type=Bat,c=1] ~ ~0.5 ~
/execute @e[type=Bat] ~-4 ~-16 ~-4 detect ~4 ~15 ~4 minecraft:air 0 execute @r[type=Player,dx=8,dy=16,dz=8] ~ ~ ~ tp @e[type=Bat,c=1] ~ ~-0.5 ~
This should allow bats to target and move toward a random player within ~16 blocks in any direction of the bat. It works by starting at the bat and looking for a player in a rectangular prism in each different direction of the bat and it is also making sure that air is in the block it would be moving into. If all checks out then the bat will tp towards the player. For best results, connect these commands to a fill clock.
Edit: If there are multiple people within ~16 blocks of the bat, it very well might try to target both of them.
That's still helpful, but I would like it if the bat didn't constantly stick to the player, since I want them to take wither damage for 2 seconds when the bat touches them. I guess I just really want to know how to make my own AI for the bat using command blocks.
Sure just add a cooldown, similar to a mob's AttackTime nbt tag.
/scoreboard players add @e[type=Bat] attackTime 0
/execute @e[type=Bat,score_attackTime=0] ~ ~-8 ~-4 detect ~1 ~8 ~4 minecraft:air 0 execute @r[type=Player,dx=16,dy=16,dz=8] ~ ~ ~ tp @e[type=Bat,c=1,score_attackTime=0] ~0.5 ~ ~
/execute @e[type=Bat,score_attackTime=0] ~-16 ~-8 ~-4 detect ~15 ~8 ~4 minecraft:air 0 execute @r[type=Player,dx=16,dy=16,dz=8] ~ ~ ~ tp @e[type=Bat,c=1,score_attackTime=0] ~-0.5 ~ ~
/execute @e[type=Bat,score_attackTime=0] ~-4 ~-8 ~ detect ~4 ~8 ~1 minecraft:air 0 execute @r[type=Player,dz=16,dy=16,dx=8] ~ ~ ~ tp @e[type=Bat,c=1,score_attackTime=0] ~ ~ ~0.5
/execute @e[type=Bat,score_attackTime=0] ~-4 ~-8 ~-16 detect ~4 ~8 ~15 minecraft:air 0 execute @r[type=Player,dz=16,dy=16,dx=8] ~ ~ ~ tp @e[type=Bat,c=1,score_attackTime=0] ~ ~ ~-0.5
/execute @e[type=Bat,score_attackTime=0] ~-4 ~ ~-4 detect ~4 ~1 ~4 minecraft:air 0 execute @r[type=Player,dx=8,dy=16,dz=8] ~ ~ ~ tp @e[type=Bat,c=1,score_attackTime=0] ~ ~0.5 ~
/execute @e[type=Bat,score_attackTime=0] ~-4 ~-16 ~-4 detect ~4 ~15 ~4 minecraft:air 0 execute @r[type=Player,dx=8,dy=16,dz=8] ~ ~ ~ tp @e[type=Bat,c=1,score_attackTime=0] ~ ~-0.5 ~
/execute @a ~ ~ ~ scoreboard players set @e[type=Bat,score_attackTime=0,r=1] attackTime 60
/execute @e[type=Bat,score_attackTime=60] ~ ~ ~ effect @r[r=1] minecraft:wither 1 2
/scoreboard players remove @e[type=Bat,score_attackTime_min=1] attackTime 1
Now the bat will get within 1 block of a player, give them wither x3 for 1 second. I can't remember if wither's damage changes with each additional amplifier or not so you may need to adjust that. After the bat has "attacked" a player, the custom AI will turn off for 60 ticks, or 3 seconds, after that they will come back to attack again.
That may work, but for future purposes, I would like to know how to make custom AI, unless this is it, then I need to learn more to figure out how all this works.
Yeah, that is it.
Please check out my PvP map based around explosions and fire, FireFight!
Sometimes, I wonder why they call mapmakers mapmakers and not cartographers.
Dragons n' Stuff
Please click!
This is a form of custom AI. Of course you can go much more into detail and make it much better. This is a basic AI that simply makes bats move directly towards the player, no kind of path finding at all.
ok, I played around with the variables, and I have something I like, thanks, but is there a way to make it go after me slower? and from farther away? it also flies away WAY too fast before the cool-down time is up, it is already out of range to attack again
Just decrease the amount of blocks teleported.
Please check out my PvP map based around explosions and fire, FireFight!
Sometimes, I wonder why they call mapmakers mapmakers and not cartographers.
Dragons n' Stuff
Please click!
Thank you both for the immense amount of help! I really appreciate it!
No problem!
And now I'm going to say something really weird, like "I live to serve"
Please check out my PvP map based around explosions and fire, FireFight!
Sometimes, I wonder why they call mapmakers mapmakers and not cartographers.
Dragons n' Stuff
Please click!