[NMS help] Increasing zombie's view range

Discussion in 'Plugin Development' started by Agentleader1, Aug 13, 2015.

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

    Agentleader1

    Great, more nms help with my other threads still needing help. I'm sorry :/

    Anyways, I can't exactly wrap my mind around zombie view range. You know in vanilla it's as simple as a data tag component. But in NMS, it's something I don't know where to start from and how to do it. I want to be able to make zombies see any entities it has an AI against from further away. How must I do that? Where do I begin? I am very unsure of this and need help. Thank you.

    PS: I don't want libs and apis, don't ask why.
     
  2. Offline

    CoolDude53

    Code:
    protected void aD() {
            super.aD();
            this.getAttributeInstance(GenericAttributes.b).setValue(40.0D); // <--- This one changes their agro distance
            this.getAttributeInstance(GenericAttributes.d).setValue(0.23000000417232513D);
            this.getAttributeInstance(GenericAttributes.e).setValue(3.0D);
            this.getAttributeMap().b(bp).setValue(this.random.nextDouble() * 0.10000000149011612D);
        }
    Also, you should not be shut off to using libs and/or apis, they can be helpful if you find one that fits your needs. People work hard on them so you don't have to.
     
  3. Offline

    Agentleader1

    @CoolDude53 Thanks for the help! However what class is this in? EntityZombie?

    Edit: Thanks for this help. I'll try it and reply back if it works.
     
    Last edited: Aug 13, 2015
  4. Offline

    CoolDude53

    Yessir.
     
  5. Offline

    Agentleader1

    @CoolDude53 Must I execute all 4 methods in EntityZombie's class to do this? I've only tried invoking the first method. When I tried it, it did not work.
     
  6. Offline

    CoolDude53

    You would only have to override that one in your extending class. Now that I think of it, I don't believe that changes the range they can agro, but how far they can track you. Here is an attribute description:

    Max Health = GenericAttributes.a
    Follow Range = GenericAttributes.b
    Knockback Resistance = GenericAttributes.c
    Movement Speed = GenericAttributes.d
    Attack Damage = GenericAttributes.e

    I will look into it more, but my best guess is that you can change it with PathfinderGoalNearestAttackableTarget.
     
  7. Offline

    Agentleader1

    @CoolDude53 The follow range is all I'm looking for, hoping it means how far they can track "enemy mobs." However, how must I overwrite a zombie I spawned in bukkit (world.spawn(loc, mob.class))? And is all I have to do is call what you said to call earlier? Sorry for these questions.
     
  8. Offline

    CoolDude53

    If you are just changing an attribute you can just use:
    Code:
    ((CraftLivingEntity) entity).getHandle().getAttributeInstance(GenericAttributes.b).setValue(100.0D); 
     
  9. Offline

    Agentleader1

    @CoolDude53 So I wouldn't cast CraftZombie, but instead CraftLivingEntity?
     
  10. Offline

    CoolDude53

    You can cast to either, CraftZombie extends CraftLivingEntity.
     
Thread Status:
Not open for further replies.

Share This Page