Thread: [Ruse]NPC Killcount System not working properly

Results 1 to 9 of 9
  1. #1 [Ruse]NPC Killcount System not working properly 
    Registered Member
    Join Date
    Jul 2014
    Posts
    22
    Thanks given
    3
    Thanks received
    0
    Rep Power
    11
    First off thank you in advance to anyone who can help me out! So I have this KCSystem.java which I will paste here

    Code:
    package com.arlania.world.content;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import com.arlania.model.definitions.NpcDefinition;
    import com.arlania.world.entity.impl.player.Player;
    
    public class KCSystem {
    
    	private Player player;
    
    	public KCSystem(Player player) {
    		this.player = player;
    	}
    
    	public enum NpcData {
    			//	OGRE_CHILD(11382, new int[][] { { 11204, 5 }}),
    	//	NISHIMAYA(11369, new int[][] { { 11382, 10 }}),
    	//	KILLING_MACHINE(11307, new int[][] { { 11369, 15 }}),
    	//	BIG_SMOKE(11202, new int[][] { { 11307, 20 }}),
    	//	SHADOWLORD(11380, new int[][] { { 11202, 25 }}),
    	//	
    	//	CHARMANDER(174, new int[][] { { 420, 5 }}),
    	//	PENGUIN(131, new int[][] { { 174, 15 }}),
    	//	CRASH(12839, new int[][] { { 17, 15 }}),
    	//	ZEUS(15, new int[][] { { 12839, 5 }}),
    	//	CHARIZARD(1982, new int[][] { { 12839, 25 }}),
    	//	JINNIS(9994, new int[][] { { 1982, 30 }}),
    	//	GODZILLA(9932, new int[][] { { 9994, 30 }}),
    	//	NARUTO(11813, new int[][] { { 9932, 50 }}),
    	//	BLOATED_INFERNALS(1999, new int[][] { { 9932, 50 }}),
    	//	HADES(16, new int[][] { { 1999, 50 }}),
    	//	DARTH_VADER(11, new int[][] { { 16, 75 }}),
    	//	DANTES_SATAN(6303, new int[][] { { 11, 100 }}),
    	//	RICK(9273, new int[][] { { 6303, 125 }}),
    	//	KINGKONG(9903, new int[][] { { 9273, 150 }}),
    	//	ASUNA(12823, new int[][] { { 9903, 150 }}),
    	//	CORPBEAST(8133, new int[][] { { 9903, 200 }}),
    	//	LUCID_DRAGONS(9247, new int[][] { { 9903, 200 }}),
    	//	HULK(8493, new int[][] { { 9247, 300 }}),
    	//	DARK_WIZARDS(9203, new int[][] { { 8493, 300 }}),
    	//	HEATED_PYROS(172, new int[][] { { 9203, 500 }}),
    	//	PURPLE_WYRM(9935, new int[][] { { 172, 500 }}),
    	//	TRINITY(170, new int[][] { { 9935, 750 }}),
    	//	CLOUD(169, new int[][] { { 170, 750 }}),
    	//	HERBAL_ROUGE(219, new int[][] { { 170, 750 }}),
    	//	EXODEN(12239, new int[][] { { 219, 1000 }}),
    	//	SUPREME_NEX(3154, new int[][] { { 12239, 1000 }}),
    	//	STORM_BREAKER(527, new int[][] { { 12239, 1000 }}),
    	//	APOLLO_RANGER(1684, new int[][] { { 527, 1000 }}),
    	//	NOXIOUS_TROLL(5957, new int[][] { { 1684, 1000 }}),
    	//	AZAZEL_BEAST(5958, new int[][] { { 5957, 1000 }}),
    	//	RAVANA(5959, new int[][] { { 5958, 1250 }}),
    	//	WARRIORS(185, new int[][] { { 5959, 1250 }}),
    	//	WARR(6311, new int[][] { { 185, 1250 }}),
    	//	RAZORSPAWN(2907, new int[][] { { 6311, 1500 }}),
    	//	DREAMFLOW(20, new int[][] { { 2907, 1500 }}),
    	//	KHIONE(259, new int[][] { { 20, 2500 }}),
    	//	SABLE_BEAST(1123, new int[][] { { 259, 3000 }}),
    	//	GLACIAL(1382, new int[][] { { 1123, 3000 }}),
    	//	APRICITY(12101, new int[][] { { 1123, 3000 }}),
    	//	MINIGAME(196, new int[][] { { 20, 2500 }}),
    	//	MINIGAME2(1683, new int[][] { { 20, 2500 }}),
    	//	MINIGAME3(282, new int[][] { { 20, 1000 }}),
    	//	MINIGAME4(158, new int[][] { { 20, 1000 }}),
    	//	MINIGAME5(181, new int[][] { { 20, 1000 }}),
    	//	MINIGAME6(202, new int[][] { { 20, 1000 }}),
    	//	MINIGAME7(6357, new int[][] { { 20, 1000 }}),
    	//	SEPHIROTH(25, new int[][] { { 8133, 50 }}),
    	//	EXPERT_BOSS(12802, new int[][] { { 185, 500 }}),
    	//	APOLLYON(12801, new int[][] { { 3154, 50 }}),
    	//	DEMOGORGON(12835, new int[][] { { 1123, 3000 }}),
    	//	YOSHI(8548, new int[][] { { 12835, 4000 }}),
    	//	RAJIN(12836, new int[][] { { 8548, 4000 }}),
    	//	SCARLETTFALCON(12805, new int[][] { { 8548, 4000 }}),
    	//	AVATAR(2264, new int[][] { { 8548, 5000 }}),
    	//	LILI(11360, new int[][] { { 2264, 7500 }}),
    	//	KUNA(11383, new int[][] { { 11360, 10000 }}),
    	//	URU(11305, new int[][] { { 11383, 12500 }}),
    	//	KUMIHO(5931, new int[][] { { 11305, 15000 }}),
    	//	MYSTERY(254, new int[][] { { 5931, 15000 }}),
    		DRUGO(299, new int[][] { { 20, 15000 }}),
    	//	GRAND_MARSHALL(307, new int[][] { { 299, 15000 }}),
    		//
    	//	SUMMER_EVENT_ROOM2(1049, new int[][] { { 4545, 10000 }}),
    	//	SUMMER_EVENT_ROOM2_NPC2(8281, new int[][] { { 1049, 5000 }}),
    	//	SUMMER_EVENT_ROOM2_NPC3(6599, new int[][] { { 8281, 7500 }});
    		NpcData(int npcId, int[][] killRequirements) {
    			this.id = npcId;
    			this.kcReqs = killRequirements;
    		}
    
    		private int id;
    		private int[][] kcReqs;
    
    	}
    
    	public int[][] getData(int id) {
    
    		for (NpcData data : NpcData.values()) {
    			if (data.id == id) {
    				return data.kcReqs;
    			}
    		}
    
    		return null;
    	}
    
    	public boolean meetsRequirements(int[][] npcData) {
    		if (npcData == null) {
    			return true;
    		}
    		Map<Integer, Integer> kcMap = new HashMap<>();
    		for (int[] data : npcData) {
    			kcMap.put(data[0], data[1]);
    		}
    		boolean meetsReqs = kcMap.entrySet().stream()
    				.allMatch(npc -> player.getNpcKillCount(npc.getKey()) >= npc.getValue());
    
            //meetsReqs = true;
    
    		if (meetsReqs) {
    			return true;
    		} else {
    			List<String> messages = new ArrayList<>();
    			for (Map.Entry<Integer, Integer> kcData : kcMap.entrySet()) {
    				String name = NpcDefinition.forId(kcData.getKey()).getName();
    				int amount = kcData.getValue();
    				int killedAmount = player.getNpcKillCount(kcData.getKey());
    				messages.add("Requirements needed: @[email protected]" + amount + " @[email protected] @[email protected]" + name + "@[email protected] - Killed: @[email protected]"
    						+ killedAmount);
    			}
    			for (String reqs : messages) {
    				player.sendMessage(reqs);
    			}
    			return true;
    		}
    
    	}
    
    }
    I have majority of the npc's commented out due to it not working, I have been testing it with drugo trying to make it work. When attacking Drugo you receive the message you need 15k kills to attack him but yet it's still letting you attack. Wondering if there was something I was missing here. Thanks again!
    Reply With Quote  
     

  2. #2  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,914
    Thanks given
    206
    Thanks received
    331
    Discord
    View profile
    Rep Power
    1242
    Check your method that handles attack a npc aswell as use magic on npc. See if there is anything that makes it go through the message.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Join Date
    Jul 2014
    Posts
    22
    Thanks given
    3
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by Arch337 View Post
    Check your method that handles attack a npc aswell as use magic on npc. See if there is anything that makes it go through the message.
    Ill check the methods now, attacking him with any of the 3 methods shows this in the chatbox but still allows you to attack him. https://prnt.sc/8rub3wnNmqWl

    Quote Originally Posted by Arch337 View Post
    Check your method that handles attack a npc aswell as use magic on npc. See if there is anything that makes it go through the message.
    I'm not quite sure why it wont work. However in the command files there is this method that checks kc overall and this does work https://prnt.sc/99GQIg6Olqyj
    I wonder if I can implement that into the teleports to certain npc's?
    Reply With Quote  
     

  5. #4  
    🧬 Rune Decay 667

    Dbcrazy's Avatar
    Join Date
    Jan 2012
    Posts
    121
    Thanks given
    18
    Thanks received
    47
    Discord
    View profile
    Rep Power
    278
    import com.arlania.model.definitions.NpcDefinition;
    Look in this file for anything that relates to the killcount and see if it's not working properly to stop you from attacking
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Donator


    Join Date
    Jan 2010
    Age
    28
    Posts
    4,169
    Thanks given
    272
    Thanks received
    545
    Discord
    View profile
    Rep Power
    735
    If you look closely to the 'meetsRequirements' method it both returns true, so in the else where it sends the message set that return to false. That should sort your issue
    Reply With Quote  
     

  8. Thankful user:


  9. #6  
    🧬 Rune Decay 667

    Dbcrazy's Avatar
    Join Date
    Jan 2012
    Posts
    121
    Thanks given
    18
    Thanks received
    47
    Discord
    View profile
    Rep Power
    278
    Quote Originally Posted by Nighel View Post
    If you look closely to the 'meetsRequirements' method it both returns true, so in the else where it sends the message set that return to false. That should sort your issue
    Yep thats gotta be it
    Reply With Quote  
     

  10. #7  
    Registered Member
    Join Date
    Jul 2014
    Posts
    22
    Thanks given
    3
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by Nighel View Post
    If you look closely to the 'meetsRequirements' method it both returns true, so in the else where it sends the message set that return to false. That should sort your issue

    You hit the nail on the head! Thank you, not sure how I looked over it 3000 times and missed it lol!
    Reply With Quote  
     

  11. #8  
    Donator


    Join Date
    Jan 2010
    Age
    28
    Posts
    4,169
    Thanks given
    272
    Thanks received
    545
    Discord
    View profile
    Rep Power
    735
    Quote Originally Posted by Exciting View Post
    You hit the nail on the head! Thank you, not sure how I looked over it 3000 times and missed it lol!
    np
    Reply With Quote  
     

  12. #9  
    Registered Member
    Join Date
    Jun 2019
    Posts
    38
    Thanks given
    11
    Thanks received
    2
    Discord
    View profile
    Rep Power
    0
    also check npcdeathtask.java that would solve ur counter issue.
    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. Replies: 0
    Last Post: 06-27-2017, 09:21 PM
  2. Replies: 0
    Last Post: 03-04-2010, 03:14 AM
  3. Yell System not Working?
    By Noosy in forum Help
    Replies: 0
    Last Post: 12-22-2009, 07:29 AM
  4. Npc block anims not working
    By owner blade in forum Help
    Replies: 0
    Last Post: 11-09-2009, 06:56 PM
  5. Save system not working
    By SODIO in forum Application Development
    Replies: 9
    Last Post: 09-02-2009, 05:03 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
  •