Thread: Wearing an item makes NPC ignore you. PI

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1 Wearing an item makes NPC ignore you. PI 
    Registered Member
    Join Date
    Apr 2013
    Posts
    158
    Thanks given
    7
    Thanks received
    2
    Rep Power
    11
    So I'm doing a survival server with zombies, skeletons, etc. I was wondering if there was a way to make it so, if I wore, let's say, a zombie head mask, that the zombies wouldn't attack me if they were aggressive?

    This is how I want it to work:

    W/O zombie head mask: Zombies attack you aggressively.
    W/ Zombie head mask: Zombies don't attack you unless you attack them.
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    Theres probably a boolean which determines if something is aggressive (isAggressive())

    So in NPCHandler you can do something like (under the switch statement)

    Code:
    public boolean isAggressive(int i) {
    switch (i) {
    case NPCID:
    if (c.playerEquipment[c.playerHelm] == ZOMBIEMASKID)
    return false;
    else
    return true;
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Apr 2013
    Posts
    158
    Thanks given
    7
    Thanks received
    2
    Rep Power
    11
    Okay, I'm having an idiot moment right now. I forgot what makes the c.playerEquipment become an error? What do I do to fix it? I feel ashamed that I forgot.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Apr 2013
    Posts
    158
    Thanks given
    7
    Thanks received
    2
    Rep Power
    11
    bump.
    Reply With Quote  
     

  5. #5  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    NPCHandler.java > isAggressive
    Code:
    if(npcs[i].npcType == ZOMBIE_ID)
          if(c.playerEquipment[c.playerHat] == MASK_ID)
                return false;
    NPCHandler.java > attackPlayer
    Code:
    if(npcs[i].npcType == ZOMBIE_ID) {
          if(c.playerEquipment[c.playerHat] == MASK_ID) {
                npcs[i].killerId = 0;
                return;
          }
    }
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Apr 2013
    Posts
    158
    Thanks given
    7
    Thanks received
    2
    Rep Power
    11
    Quote Originally Posted by Jason View Post
    NPCHandler.java > isAggressive
    Code:
    if(npcs[i].npcType == ZOMBIE_ID)
          if(c.playerEquipment[c.playerHat] == MASK_ID)
                return false;
    NPCHandler.java > attackPlayer
    Code:
    if(npcs[i].npcType == ZOMBIE_ID) {
          if(c.playerEquipment[c.playerHat] == MASK_ID) {
                npcs[i].killerId = 0;
                return;
          }
    }

    Okay, first, Thanks! It helped for the most part, except one thing. If I wear the mask, it stops the zombie from attacking(Which is what I want!), but even if I attack it, it doesn't attack me back.

    I basically want the mask to make me invisible to the zombie until I attack it. Know how to make that work?
    Reply With Quote  
     

  7. #7  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    Quote Originally Posted by brutally View Post
    Okay, first, Thanks! It helped for the most part, except one thing. If I wear the mask, it stops the zombie from attacking(Which is what I want!), but even if I attack it, it doesn't attack me back.

    I basically want the mask to make me invisible to the zombie until I attack it. Know how to make that work?
    Because the NPCs killerId is 0, basically meaning it is trying to attack no one, just remove the second code he gave you

    All you have to do is use my code, and change
    Code:
    c.playerEquipment[c.playerHelm]
    To

    Code:
    c.playerEquipment[c.playerHat]
    Lol
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Apr 2013
    Posts
    158
    Thanks given
    7
    Thanks received
    2
    Rep Power
    11
    I tried removing his attackPlayer code and the zombie continues to attack me, even with the mask on. I've tried relogging & it still attacks me.
    Reply With Quote  
     

  9. #9  
    Registered Member BryceTheCoder's Avatar
    Join Date
    Aug 2008
    Posts
    740
    Thanks given
    21
    Thanks received
    24
    Rep Power
    27
    Well if you want the zombie to not attack you first (aggressive) then you do this:
    NPCHandler.java -> isAggressive
    Code:
    if(npcs[i].npcType == NPCID) {
      if(c.playerEquipment[c.playerHat] == MASKID) {
        return false;
      }
    }
    But if you do not want a zombie to attack you no matter what, then you do:
    NPCHandler.java -> attackPlayer
    Code:
    if(npcs[i].npcType == NPCID) {
      if(c.playerEquipment[c.playerHat] == MASKID) {
        npcs[i].killerId = 0;
        return;
      }
    }
    Hopefully you understand.

    Advertise your RSPS cheap on my website: www.BryceBux.com

    ^ PM me and I will give you a few dollars for FREE on my website for advertisements ^
    Reply With Quote  
     

  10. #10  
    Registered Member
    Join Date
    Apr 2013
    Posts
    158
    Thanks given
    7
    Thanks received
    2
    Rep Power
    11
    Quote Originally Posted by BryceTheCoder View Post
    Well if you want the zombie to not attack you first (aggressive) then you do this:
    NPCHandler.java -> isAggressive
    Code:
    if(npcs[i].npcType == NPCID) {
      if(c.playerEquipment[c.playerHat] == MASKID) {
        return false;
      }
    }
    But if you do not want a zombie to attack you no matter what, then you do:
    NPCHandler.java -> attackPlayer
    Code:
    if(npcs[i].npcType == NPCID) {
      if(c.playerEquipment[c.playerHat] == MASKID) {
        npcs[i].killerId = 0;
        return;
      }
    }
    Hopefully you understand.
    I understand what you mean by that, but whenever I add that to it, I get this error:

    Code:
    [8/30/13 8:23 AM]: java.lang.NullPointerException
    [8/30/13 8:23 AM]: A fatal exception has been thrown!
    [8/30/13 8:23 AM]: 	at server.model.npcs.NPCHandler.isAggressive(NPCHandler.java:193)
    [8/30/13 8:23 AM]: 	at server.model.npcs.NPCHandler.process(NPCHandler.java:992)
    [8/30/13 8:23 AM]: 	at server.Server.main(Server.java:151)
    Reply With Quote  
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. An item makes you invisible :O [PI]
    By Gretar in forum Help
    Replies: 1
    Last Post: 10-27-2011, 06:13 PM
  2. Replies: 4
    Last Post: 07-15-2011, 01:47 PM
  3. [508]how to make ::npc follow you?
    By jetexone in forum Requests
    Replies: 0
    Last Post: 09-30-2008, 09:15 PM
  4. Make npcs tele you when you killed them
    By Alex_NL in forum Tutorials
    Replies: 37
    Last Post: 06-17-2008, 12:20 PM
  5. player rights to wear an item "short tut"
    By Icy Whip in forum Tutorials
    Replies: 1
    Last Post: 03-11-2008, 04:38 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •