Jump to content

Changing ranged zombie attack range


Recommended Posts

Hey all,

I've been plodding around the xmls and have made a mini overhaul for myself and my friend group.  I'm now trying to add some custom enemy variants and I want to add a boss type zombie for blood moon that has a deadly ranged attack it uses from very far away. It's that last part that's causing me issues. It seems no matter how I change the hand item to have more range, longer damage falloff, projectile fly time, lifetime, velocity, sight range, angle, etc, I cannot get them to initiate their attack past a range of 24-30m. I've tested this extensively and the only thing I can think of is that in the AITask RangedAttackTarget's data field there might be some value that can be passed (along with item type, cooldown, etc.) that could affect their targeting range. I've tried range, maxRange, and targetRange to no avail.

If anyone knows anything on this (and anything else on modifying the AI behaviors, as there seems to be a ton of things I can't access easily) then I would be grateful because I'm at a dead end with many hours of head pounding trial and error.

Link to comment
Share on other sites

One thing i can think of is... are you testing it under a bloodmoon, or with them set to feral? An enemy wont attack something they can't see, and by default the cop's view distance is 30 blocks. So if they are beyond that distance, chances are they wont be able to see you and fire off their attack... Maybe upping that will help?

Link to comment
Share on other sites

Posted (edited)

I'm pretty sure the "RangedAttackTarget" AITask accepts "minRange" and "maxRange" values. Try putting them at the end of the "data" attribute value, e.g. "itemType=1;cooldown=4;duration=5;minRange=10;maxRange=100"

 

EDIT: here's the cop code with those values added:

<property name="AITask-2" value="RangedAttackTarget" data="itemType=1;cooldown=4;duration=5;minRange=10;maxRange=100"/>

 

Edited by khzmusik (see edit history)
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, khzmusik said:

I'm pretty sure the "RangedAttackTarget" AITask accepts "minRange" and "maxRange" values. Try putting them at the end of the "data" attribute value, e.g. "itemType=1;cooldown=4;duration=5;minRange=10;maxRange=100"

 

EDIT: here's the cop code with those values added:


<property name="AITask-2" value="RangedAttackTarget" data="itemType=1;cooldown=4;duration=5;minRange=10;maxRange=100"/>

 

You're a saint my friend, thank you. Any resources you'd recommend for decompiling and looking at the code? As I'm getting more into this I feel it's going to be necessary.

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, TheWolfssegen said:

You're a saint my friend, thank you. Any resources you'd recommend for decompiling and looking at the code? As I'm getting more into this I feel it's going to be necessary.

 

You're very welcome, always glad when I actually have enough knowledge to help.

 

Everyone seems to use dnSpy: https://github.com/dnSpy/dnSpy

 

I also use that. It does make navigating the code easier, and has a bunch of features that people like. But there are a few things I don't like about it - the lack of code folding is killing me. I've been trying to find something better but haven't found it yet.

 

But also, you can look in the code produced by other modders. I don't know if that would have helped in this case, but since this deals with entity attack code, you could look in one of the mods that adds new zombies or NPCs. Xyth's creature packs or Snufkin's zombies, for example.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...