Making PigZombies attack zombies

Discussion in 'Plugin Development' started by Hex_27, Dec 31, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Hex_27

    I've tried making "Custom mobs" and "pathfinder goals" and things like that, but it's completely out of my field and it hasn't been working out. Is there another way to do this?
     
  2. Offline

    glory_fades

    try making an entity target event and then checking if the mob is a pig zombie and set its target to a zombie
     
  3. Offline

    Hex_27

    @Assist That doesn't work for anything. I may try it again, but I doubt it would work. Also...(refer to bottom explanation)
    @glory_fades I want them to attack zombies from the time they spawn. Your method would only set the target to something when it has ALREADY targeted something. Which means it won't work until a player hits it.

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 31, 2016
  4. Offline

    Hex_27

    Bump

    Maybe I can check for playermove event and set every nearby pigman to set its target to a zombie?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 31, 2016
  5. Offline

    Jaaakee224

  6. Offline

    Hex_27

    @Jaaakee224 I've tried that already. It gives some error here:
    CUSTOM_ZOMBIE("Zombie", 54, CustomZombie.class);
    And since I was basically copying it, I didn't want to ask anyone as I predicted angry comments on copy pasting.
     
  7. Offline

    AlphaRLee

    Yes, I'll post the first angry comment XD
    I too do copy-paste, but I always always always analyze the code I'm copying pasting. Otherwise, it'd be a mess trying to debug. If you don't understand your copy-paste, you're basically giving yourself trouble.

    Giving pathfinders to entities without pathfinders (originally) is tough. I gave a "pathfinder" to a spider, however, my method only allows for my spiders to attack my other custom entities. Try looking through the BiomeMeta (I think it's called "b") for information on a mob list. Using that, you should be able to iterate through the listed entities. And with that, just add a distance comparator, and you're set!

    I can help you with the distance comparator, I can help you with setting the target for the pigmen. However, if you want information on how to get the list of entities for the pig zombies to target? Weeeeell...I can try, let's put it that way.
     
  8. Offline

    Hex_27

    @AlphaRLee That's why I didn't wanna copy. I had completely no idea what I was doing. And.... just erm... what?
     
  9. Offline

    AlphaRLee

    I'm sure you figured out, this is NMS coding I'm talking about.

    Look into the biomes of MC, they carry information called biomeMeta. I believe that the information that carries the mobs is a list, found through the method #####.b() (as of 1.7.9). I can't help you more specifically here

    Iterate through each entity on that list, and check if they're an instanceof entityZombie. If they are, store them in a local variable and iterate through the next entity. Do a distance comparator, check if the next entity is closer or further than the locally stored entity. If closer, replace the local entity with the entity in the list, and repeat until you go through all entities. Return the local variable to the pigman, and set it as the target.

    If that didn't explain it, then I can try examples...
     
  10. Offline

    Hex_27

  11. Offline

    AlphaRLee

    I doubt it, since all the other mobs do it already, such as zombies and skeletons and creepers.
     
  12. Offline

    API_Tutorials

    @AlphaRLee
    Or...
    loop through all bukkit worlds...
    loop through all entities which is an instance of Zombie...
    do stuff
     
  13. Offline

    AlphaRLee

    If you start in NMS, finish in NMS. The more conversions you do, the more your head hurts. But that does work.
     
  14. Offline

    Hex_27

    @AlphaRLee so is it possible to loop through all zombies in the world, then check if there are pigmen near them, then see set the pigmen's target to the zombie? Or vice versa?
     
  15. Offline

    AlphaRLee

    Vice versa would probably be faster, as pig zombies are rarer, unless if they are spawned en-mass (that'd be a weird way to police regular zombies XD). You can follow up with a quick scan in a 16x16 (or whatever your coordinates are) box around your pigmen, detecting if there is an entity in there or not. I'm pretty sure there's a bukkit technique to find if there is an entity on the scanned tile, I haven't found a simple NMS equivalent yet...
     
  16. Offline

    unrealdesign

    Stop hating on the guy; he clearly said he didn't know advanced Java so don't force him for failing to understand NMS. He obviously is well versed in Java programming and there are plenty of alternatives to NMS. One example is CitizensAPI and another is NPCFactory. Have a look at http://bukkit.org/forums/resources.60/ it will help you a bunch if you're new to Java programming. There are a bunch of examples for everything and it has simple method names compared to NMS ;)
     
  17. Offline

    Hex_27

    @unrealdesign It's fine he isn't hating. He's making suggestions that I'll actually use. Back to the Citizens API, does it really allow me to change pigzombie behavior in a certain world?

    @AlphaRLee I'll start trying that too see
     
  18. Offline

    AlphaRLee

    @unrealdesign Ok...so apparently I'm a hater now. I'm "hating" because I'm apparently failing to communicate my end of my ideas to Hex. He already told me that he's inexperienced in NMS, whereas I focus primarily on NMS in comparison. I tell him to stick to it because it gives him a good learning opportunity and because I'm suggesting that he reduces the chances of spaghetti-code through these multiple conversions.

    I have no clue how the heck Citizens API or NPCFactory works, I much rather prefer homemade plugins from scratch. So...don't blame me for suggesting NMS code, and most definitely don't blame me for being a hater.

    Or go ahead and accuse me. And act all petty on a forum designed for helping people, not picking fights.

    @Hex_27, if you figure out the NMS, then congrats to you. If you figure out an alternative, then make sure you share that solution with others, and try to figure out how to keep your code as clean as possible. I might not have been useful, but I for sure am hoping that a little bit of my programming experience can get somebody somewhere in this blocky world.
     
  19. Offline

    ColonelHedgehog

    Let's keep our heads, here. :p

    Citizens uses NMS for sure.
     
  20. Offline

    sirrus86

    In my opinion, if you can wrap your head around it, NMS is the way to go for sure. That being said, looking at the source of an API can help you understand how they're able to create the result you're after... so long as you're not just copy/pasting.
     
  21. Offline

    Hex_27

    @sirrus86 I look at alot of sources. Trust me I have no idea what the heck its even talking about.
     
Thread Status:
Not open for further replies.

Share This Page