Jump to content

[1.6.4][AI]Using the AI to change targets?


Cyan

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Well I currently have about 90 entities :P 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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.