Posted November 28, 201311 yr Hello there, So I have been screwing around with the AI lately, and noticed something. Other than spiders who don't use the standard AI, mobs tend to stick with the first target that attacks them.(Which is obviously the purpose of EntityAIHurtByTarget) Anyway, I was wondering if there is a way, or perhaps someone has a really good idea, on how to change the AI to not attack the player. I have already tried going into the isSuitableTarget method and seeing if I could get anything out of that to no avail. The main purpose of this is because I want to attack a custom hostile entity, and then have it switch to a tamed entity that might be also attacking it. Obviously with the vanilla code it will just keep attacking me instead of switching to the tamed entity. Thanks for any advice you may be able to provide.
November 28, 201311 yr having been working with hostile mobs recently, what i would do is set a variable for the current target, then hook into the method that tracks if the entity is hurt, then check if the object that hurt the entity is and instance of entityCreature. if it is, is it the same entity it is following or not? if not change the target to the new entity. I have not done this before, but it makes sence that doing this would be possible. do you have a class for the entity right now, or are you just looking into if its possible to do it to the mob externally?
November 28, 201311 yr Author Well I currently have about 90 entities All of which can either be tamed through the right methods, or become hostile if attacked. The idea is to really pit the tamed ones against the hostile ones, but the only vanilla way to do that is to make the hostile entity attack on sight, rather than after being attacked.
November 28, 201311 yr Author I mean there isn't a great deal of new code here yet. As far as the AI goes, its just the vanilla copypasta. The target tasks specifically are this.targetTasks.addTask(1, new EntityNewAIHurtByTarget(this, true)); this.targetTasks.addTask(2, new EntityNewAIOwnerHurtByTarget(this)); this.targetTasks.addTask(3, new EntityNewAIOwnerHurtTarget(this)); I was hoping that making EntityAIHurtByTarget would make it change priority after being attacked by something else, but no dice.
November 28, 201311 yr ok, i had to take some AI code and modify it to make it my own, what i suggest is you take the EntityAIHurtByTarget copy and paste it into your own class, extending it. then you can modify it how you want it to work. then instead of calling the vanilla class in your entities code, you call your class.
November 28, 201311 yr Author That is pretty much what I am doing already. The problem isn't with calling the vanilla copies. Its figuring out what I need to edit in the copies.
November 28, 201311 yr ok, post the code of the HurtByTarget class then so i can see how you have it set up.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.