Jump to content

help with ai for qustom squid


cat ote

Recommended Posts

dear readers, i'm having trouble designing the ai for my custom squid. i've been trying a lot of things recently, but none have worked as i hoped. i am now stuck on this, and i am asking for your support. to put it short: i want my squid to act like normal squid, but swim towards boats, if none in the area players, and if it can't find those it will swim towards other entities. any entity it comes in contact with is dealt damage. my latest attempt led me to copy-paste the original squid ai, but that only lead to more problems. i changed the squid to my custom entity but i changed very little otherwise, and i would like to hear if you have any idea how to fix it, and otherwise another method of achieving my goals. i have put the code in this file, with all of my classes in which my entity is referenced and the original squid ai.

 

 

thanks for bothering to read this, i really thank you.

my problem(custom entity).txt

Link to comment
Share on other sites

11 hours ago, cat ote said:

i have put the code in this file, with all of my classes in which my entity is referenced and the original squid ai.

Please use a service like GitHub, GitHub Gist or Pastebin for sharing code. Also don’t share Mojang’s intellectual property (their copyrighted code) online.

 

Other than that, great question and I’ll come back to answer it once I’m on a device that can open that file.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

4 hours ago, diesieben07 said:

Don't. It's borderline unreadable.

Ouch, yeah.

For anyone else who thinks of downloading it, here it is

i tried copypasting the squid ai to my custom squid, but it gave a lot of bugs. here is my entitylist class:
<ItemList class copied from HarryTalks or similar, static initialisers for EntityTypes>
my MutantSquid class:
<Copy past of minecraft entity squid class (maybe with a couple tweaks?)>
and the vanilla squid class, for convenience:
<Copy past of minecraft entity squid class>
if you were to help me, thank you. i can't figure this one out by myself.

 

37 minutes ago, cat ote said:

Thanks, but you've set it up a couple folders too low. Here's what a properly set up GitHub repository should look like.

While we're at it, here's what a proper registration class looks like and here's what a simple entity looks like.

As you can see, the better way of doing entities is extending a vanilla class and then overriding behaviour.

16 hours ago, cat ote said:

i want my squid to act like normal squid, but swim towards boats, if none in the area players, and if it can't find those it will swim towards other entities. any entity it comes in contact with is dealt damage.

I would do this by extending the squid and adding an AI task that swims towards a "target". I would also override the update method and periodically recalculate that target. I have no experience with AIs, so I'm not sure if that's the tight approach, but that's what I would start off with. If you keep checking my example mod, I'm planning on adding an AI that charges at players to my Wild Boar as soon as I get some spare time.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

2 hours ago, Cadiboo said:

I would do this by extending the squid and adding an AI task that swims towards a "target". I would also override the update method and periodically recalculate that target. I have no experience with AIs, so I'm not sure if that's the tight approach, but that's what I would start off with. If you keep checking my example mod, I'm planning on adding an AI that charges at players to my Wild Boar as soon as I get some spare time.

Pretty much, but one important point: mobs actually have two different goal types (NB: in 1.14+, "entity AI" objects are referred to as "goals") - a main goal, and a target selection goal.  Check out MobEntity, and a subclass method such as ZombieEntity#applyEntityAI(); you'll see separate types of goals for choosing a target, and actually doing stuff in-world.

So in the case of this custom squid, one approach would be a subclass of the vanilla squid with a targeting goal to find nearby boats or players (NearestAttackableTargetGoal won't quite work here since it only works for living entities which excludes boats), and another goal to make the squid move toward its target and attack it when in melee range (should be possible to extend MeleeAttackGoal for that, but no promises...). You'll probably also want to remove the squid's FleeGoal too if this is meant to be a hostile entity.

Link to comment
Share on other sites

On 2/5/2020 at 2:08 PM, Cadiboo said:

Thanks, but you've set it up a couple folders too low. Here's what a properly set up GitHub repository should look like.

 

here's my new branch. just updated it

https://github.com/kingtorsten/endlessabyss

for some reason the link goes to the master branch so you need to slect the endlessabyss branch, i cant link it

Edited by cat ote
Link to comment
Share on other sites

On 2/5/2020 at 4:40 PM, desht said:

You'll probably also want to remove the squid's FleeGoal too if this is meant to be a hostile entity.

but how should i do that? the fleegoal is located inside the original squid ai, and i cant edit the original squid ai.

Link to comment
Share on other sites

2 hours ago, cat ote said:

but how should i do that? the fleegoal is located inside the original squid ai, and i cant edit the original squid ai.

AIs used to work off a task list and that task list used to be public. If they still work off a task list, you can just edit that list. Anyway, you’re not modifying the original squids AI, you’re modifying your squids AI. Correct me if I’m wrong but you can just instantiate your own subclass of FleeGoal and add it to your task list (after removing the original flee goal if necessary)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

On 2/7/2020 at 6:08 PM, cat ote said:

but how should i do that? the fleegoal is located inside the original squid ai, and i cant edit the original squid ai.

As Cadiboo pointed out, you're not editing the original AI - you're editing the AI in your subclass, which inherits the original AI.

 

SquidEntity.FleeGoal itself has a private constructor, so you'd need to use reflection to access it.  But if you simply want to get rid of it, the cleanest way is probably to override SquidEntity#registerGoals() to simply not add the FleeGoal in the first place. The base registration method also adds a SquidEntity.MoveRandomGoal, which you may or may not want to keep.  If you do, it's conveniently public.

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.