Thread: 1 Problem left

Results 1 to 9 of 9
  1. #1 1 Problem left 
    Donator


    Join Date
    Jan 2010
    Age
    29
    Posts
    4,122
    Thanks given
    274
    Thanks received
    551
    Rep Power
    738
    Hello,

    First problem: So i was working on DKS on my server but then i noticed DKS are not aggresive (Yes i added them to the aggresive check) but they still wont attack ppl who are close

    Second plroblem: Fixed myself

    Some help would be nice
    Reply With Quote  
     

  2. #2  
    -Founder Off Returnofpk-


    Join Date
    Oct 2012
    Age
    28
    Posts
    655
    Thanks given
    97
    Thanks received
    211
    Rep Power
    303
    Quote Originally Posted by Nighel View Post
    Hello,

    First problem: So i was working on DKS on my server but then i noticed DKS are not aggresive (Yes i added them to the aggresive check) but they still wont attack ppl who are close

    Second plroblem: NPC and Player combat when you attack an npc or player with range or mage it walks to the person (Yes i tryed the fixed that where released but didnt work)

    Some help would be nice
    here is my attack npc metod

    in npchandler.java
    Code:
    /**
    				* Attacking npc
    				**/
    	
    				if (isAggressive(i) && !npcs[i].underAttack && !npcs[i].isDead && !switchesAttackers(i)) {
    					npcs[i].killerId = getCloseRandomPlayer(i);
    				} else if (isAggressive(i) && !npcs[i].underAttack && !npcs[i].isDead && switchesAttackers(i)) {
    					npcs[i].killerId = getCloseRandomPlayer(i);
    				}
    				if (System.currentTimeMillis() - npcs[i].lastDamageTaken > 5000)
    					npcs[i].underAttackBy = 0;
    				
    				if((npcs[i].killerId > 0 || npcs[i].underAttack) && !npcs[i].walkingHome && retaliates(npcs[i].npcType)) {
    					if(!npcs[i].isDead) {
    						int p = npcs[i].killerId;
    						if(PlayerHandler.players[p] != null) {
    							Client c = (Client) PlayerHandler.players[p];
    							if(FightCave.isCaveNpcs(i))
    								followInCave(i, c.playerId,true);
    							else
    								followPlayer(i, c.playerId);
    							if (npcs[i] == null) return;
    							if(npcs[i].attackTimer == 0) {
    								if(c != null) {
    									attackPlayer(c, i);
    								} else {
    									npcs[i].killerId = 0;
    									npcs[i].underAttack = false;
    									npcs[i].facePlayer(0);
    								}
    							}
    						} else {
    							npcs[i].killerId = 0;
    							npcs[i].underAttack = false;
    							npcs[i].facePlayer(0);
    						}
    					}
    				}

    and add this in npchandler.java

    Code:
    public int getClosePlayer(int i) {
    		for (int j = 0; j < PlayerHandler.players.length; j++) {
    			if (PlayerHandler.players[j] != null) {
    				if (j == npcs[i].spawnedBy)
    					return j;
    				if (goodDistance(PlayerHandler.players[j].absX, PlayerHandler.players[j].absY, npcs[i].absX, npcs[i].absY, 2 + distanceRequired(i) + followDistance(i))) {
    					if ((PlayerHandler.players[j].underAttackBy <= 0 && PlayerHandler.players[j].underAttackBy2 <= 0) || PlayerHandler.players[j].inMulti())
    						if (PlayerHandler.players[j].heightLevel == npcs[i].heightLevel)
    							return j;
    				}
    			}	
    		}
    		return 0;
    	}
    	
    	public int getCloseRandomPlayer(int i) {
    		ArrayList<Integer> players = new ArrayList<Integer>();
    		for (int j = 0; j < PlayerHandler.players.length; j++) {
    			if (PlayerHandler.players[j] != null) {
    				if (goodDistance(PlayerHandler.players[j].absX, PlayerHandler.players[j].absY, npcs[i].absX, npcs[i].absY, 2 + distanceRequired(i) + followDistance(i))) {
    					if ((PlayerHandler.players[j].underAttackBy <= 0 && PlayerHandler.players[j].underAttackBy2 <= 0) || PlayerHandler.players[j].inMulti())
    						if (PlayerHandler.players[j].heightLevel == npcs[i].heightLevel)
    							players.add(j);
    				}
    			}	
    		}
    		if (players.size() > 0)
    			return players.get(Misc.random(players.size() -1));
    		else
    			return 0;
    	}
    Hope this will help you find out whate the problem is
    Attached image
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Donator


    Join Date
    Jan 2010
    Age
    29
    Posts
    4,122
    Thanks given
    274
    Thanks received
    551
    Rep Power
    738
    Quote Originally Posted by sheepmonger View Post
    here is my attack npc metod

    in npchandler.java
    Code:
    /**
    				* Attacking npc
    				**/
    	
    				if (isAggressive(i) && !npcs[i].underAttack && !npcs[i].isDead && !switchesAttackers(i)) {
    					npcs[i].killerId = getCloseRandomPlayer(i);
    				} else if (isAggressive(i) && !npcs[i].underAttack && !npcs[i].isDead && switchesAttackers(i)) {
    					npcs[i].killerId = getCloseRandomPlayer(i);
    				}
    				if (System.currentTimeMillis() - npcs[i].lastDamageTaken > 5000)
    					npcs[i].underAttackBy = 0;
    				
    				if((npcs[i].killerId > 0 || npcs[i].underAttack) && !npcs[i].walkingHome && retaliates(npcs[i].npcType)) {
    					if(!npcs[i].isDead) {
    						int p = npcs[i].killerId;
    						if(PlayerHandler.players[p] != null) {
    							Client c = (Client) PlayerHandler.players[p];
    							if(FightCave.isCaveNpcs(i))
    								followInCave(i, c.playerId,true);
    							else
    								followPlayer(i, c.playerId);
    							if (npcs[i] == null) return;
    							if(npcs[i].attackTimer == 0) {
    								if(c != null) {
    									attackPlayer(c, i);
    								} else {
    									npcs[i].killerId = 0;
    									npcs[i].underAttack = false;
    									npcs[i].facePlayer(0);
    								}
    							}
    						} else {
    							npcs[i].killerId = 0;
    							npcs[i].underAttack = false;
    							npcs[i].facePlayer(0);
    						}
    					}
    				}

    and add this in npchandler.java

    Code:
    public int getClosePlayer(int i) {
    		for (int j = 0; j < PlayerHandler.players.length; j++) {
    			if (PlayerHandler.players[j] != null) {
    				if (j == npcs[i].spawnedBy)
    					return j;
    				if (goodDistance(PlayerHandler.players[j].absX, PlayerHandler.players[j].absY, npcs[i].absX, npcs[i].absY, 2 + distanceRequired(i) + followDistance(i))) {
    					if ((PlayerHandler.players[j].underAttackBy <= 0 && PlayerHandler.players[j].underAttackBy2 <= 0) || PlayerHandler.players[j].inMulti())
    						if (PlayerHandler.players[j].heightLevel == npcs[i].heightLevel)
    							return j;
    				}
    			}	
    		}
    		return 0;
    	}
    	
    	public int getCloseRandomPlayer(int i) {
    		ArrayList<Integer> players = new ArrayList<Integer>();
    		for (int j = 0; j < PlayerHandler.players.length; j++) {
    			if (PlayerHandler.players[j] != null) {
    				if (goodDistance(PlayerHandler.players[j].absX, PlayerHandler.players[j].absY, npcs[i].absX, npcs[i].absY, 2 + distanceRequired(i) + followDistance(i))) {
    					if ((PlayerHandler.players[j].underAttackBy <= 0 && PlayerHandler.players[j].underAttackBy2 <= 0) || PlayerHandler.players[j].inMulti())
    						if (PlayerHandler.players[j].heightLevel == npcs[i].heightLevel)
    							players.add(j);
    				}
    			}	
    		}
    		if (players.size() > 0)
    			return players.get(Misc.random(players.size() -1));
    		else
    			return 0;
    	}
    Hope this will help you find out whate the problem is
    Nop no luck
    Reply With Quote  
     

  5. #4  
    -Founder Off Returnofpk-


    Join Date
    Oct 2012
    Age
    28
    Posts
    655
    Thanks given
    97
    Thanks received
    211
    Rep Power
    303
    Quote Originally Posted by Nighel View Post
    Nop no luck
    ok anyways i tryed
    Attached image
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Donator


    Join Date
    Jan 2010
    Age
    29
    Posts
    4,122
    Thanks given
    274
    Thanks received
    551
    Rep Power
    738
    bump
    Reply With Quote  
     

  8. #6  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    The first one would require a closer look at your NCHandler, for the mage from far away, the problem is that it follows the person when you click them, in attackplayer.java, or wherever it handles attacking, just do something like if (usingMagic && goodDistance(blaaaa)) { stopMovement(); return; } For range ect as well, make sure it uses the correct good distance away for certain weapons.
    Reply With Quote  
     

  9. #7  
    Donator


    Join Date
    Jan 2010
    Age
    29
    Posts
    4,122
    Thanks given
    274
    Thanks received
    551
    Rep Power
    738
    Quote Originally Posted by Icandoit View Post
    The first one would require a closer look at your NCHandler, for the mage from far away, the problem is that it follows the person when you click them, in attackplayer.java, or wherever it handles attacking, just do something like if (usingMagic && goodDistance(blaaaa)) { stopMovement(); return; } For range ect as well, make sure it uses the correct good distance away for certain weapons.
    Second is already in my followplayer

    Fixed second problem myself
    Reply With Quote  
     

  10. #8  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    Quote Originally Posted by Nighel View Post
    Second is already in my followplayer
    You walk next to them when you attack them, and then when they move, THEN you'll have the correct distance, that's why you need to add it to attackplayer.java aswell.
    Reply With Quote  
     

  11. #9  
    Donator


    Join Date
    Jan 2010
    Age
    29
    Posts
    4,122
    Thanks given
    274
    Thanks received
    551
    Rep Power
    738
    Quote Originally Posted by Icandoit View Post
    You walk next to them when you attack them, and then when they move, THEN you'll have the correct distance, that's why you need to add it to attackplayer.java aswell.
    If already fixed it just need the aggresion of dks/and those little minions left all other aggresive monsters work fine
    Reply With Quote  
     


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. Fixing Log In\Out Problem
    By _Fear in forum Tutorials
    Replies: 11
    Last Post: 04-14-2010, 10:35 PM
  2. Yerr diciding problem (2...3 sources left)
    By Andys1841 in forum Help
    Replies: 5
    Last Post: 06-06-2009, 05:58 AM
  3. No Router, No Problem
    By Z in forum Tutorials
    Replies: 6
    Last Post: 07-24-2007, 10:29 AM
  4. Backround problem , ;dd.
    By Kevvah . in forum General
    Replies: 0
    Last Post: 07-10-2007, 11:41 AM
  5. Replies: 0
    Last Post: 06-13-2007, 08:37 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •