Thread: Custom charm dropping & charming imp

Results 1 to 6 of 6
  1. #1 Custom charm dropping & charming imp 
    Registered Member

    Join Date
    Mar 2011
    Age
    27
    Posts
    555
    Thanks given
    168
    Thanks received
    190
    Rep Power
    0
    In sendDrop method
    Code:
    Charms charm = calculateCharm(killer, this);
    			if (charm != null) {
    				int charmCount = getCharmsAmount(this, charm);
    				Drop charmDrop = Drop.create(charm.getItemId(), 100, charmCount, charmCount, false);
    				if (killer.getInventory().containsItem(9952, 1)) {// charming
    																	// imp
    					if (killer.getInventory().containsItem(charm.getItemId(), 1)
    							|| killer.getInventory().hasFreeSlots())
    						killer.getInventory().addItem(new Item(charmDrop.getItemId(), charmCount));
    					else
    						drops.add(charmDrop);
    				} else
    					drops.add(charmDrop);
    			}

    Add methods

    Code:
    	private enum Charms {
    
    		GOLD_CHARM(12158, 45.0),
    
    		GREEN_CHARM(12159, 27.0),
    
    		CRIMSON_CHARM(12160, 11.0),
    
    		BLUE_CHARM(12163, 5.0);
    
    		private int itemId;
    
    		private double chance;
    
    		private Charms(int itemId, double chance) {
    			this.itemId = itemId;
    			this.chance = chance;
    		}
    
    		public int getItemId() {
    			return itemId;
    		}
    
    		public double getChance() {
    			return chance;
    		}
    
    	}
    Code:
    private double NO_CHARMS_CHANCE = 50;
    Code:
    private Charms calculateCharm(Player player, NPC npc) {
    		if (npc.getCombatLevel() < 10)
    			return null;
    		if ((npc.getId() != 7134) && Utils.getRandomDouble(100) < NO_CHARMS_CHANCE)
    			return null;
    		while (true) {
    			double chance = Utils.getRandomDouble(100);
    			Charms charm = Charms.values()[Utils.getRandom(Charms.values().length - 1)];
    			if ((charm.getChance()) > chance) {
    				return charm;
    			} else
    				continue;
    		}
    	}
    Code:
    private int getCharmsAmount(NPC npc, Charms charm) {
    		if (npc.getId() == 7134)
    			return Utils.random(10, 38);
    		int charmAmount = (int) (Utils.random(npc.getCombatLevel()) * 0.1);
    		switch (charm) {
    		case BLUE_CHARM:
    			return charmAmount;
    		case CRIMSON_CHARM:
    			return charmAmount;
    		case GOLD_CHARM:
    			return charmAmount;
    		case GREEN_CHARM:
    			return charmAmount;
    		}
    		return -1;
    	}
    Avalon Developer
    Reply With Quote  
     

  2. #2  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Code:
    while (true) {
    Shouldn't be using that lol
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member

    Join Date
    Mar 2011
    Age
    27
    Posts
    555
    Thanks given
    168
    Thanks received
    190
    Rep Power
    0
    Quote Originally Posted by Professor Oak View Post
    Code:
    while (true) {
    Shouldn't be using that lol
    Fair enough
    Avalon Developer
    Reply With Quote  
     

  5. #4  
    BoomScape #1
    BoomScape's Avatar
    Join Date
    May 2013
    Posts
    2,422
    Thanks given
    289
    Thanks received
    234
    Rep Power
    48
    I'm sure someone released something like this ages ago no?
    Attached image
    Reply With Quote  
     

  6. #5  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    As Oak said, shouldn't use an endless loop. Even though it will continually just "continue" it'll still use up resource. Plus I don't think you even need it to loop it? You just need it once.
    Could also modify the getCharmsAmount method into this:
    Code:
    private int getCharmsAmount(NPC npc, Charms charm) {
    		if (npc.getId() == 7134)
    			return Utils.random(10, 38);
    		int charmAmount = (int) (Utils.random(npc.getCombatLevel()) * 0.1);
    		switch (charm) {
    		case BLUE_CHARM:
    		case CRIMSON_CHARM:
    		case GOLD_CHARM:
    		case GREEN_CHARM:
    			return charmAmount;
    		default:
    			return -1;
    		}
    	}
    It's pretty nice overall, no major mistakes whatsoever. Clean code, good job.
    However, if you were really into the detail, you could essentially dump charm drop rates from RSWikia I believe. Most NPCs have the charm drop rates in percentages on their wiki pages. Surprised no one has dumped that data yet tbh.

    EDIT: Decided to dump all combat NPC info from RSWikia (At least for the NPCs that exist in 562), including the charm percentages. A lot of the charms had a drop rate ranging from double to another double, so I decided to just add the two up and divide by two (Getting the middle value for them). Anyways, if anyone wants to use this data, feel free to. NOTE: It only contains 171 NPCs data (Went through 9300 NPCs in reality, but a lot of them were still missing some charm percentages on RSWikia and majority of the NPCs weren't even combat related NPCs - only 803 were - does not include any duplicates, goes by NPC name).
    EDIT V2:
    Refer to this link: https://www.rune-server.ee/showthrea...65#post5323565
    Dumped data for up to revision 876 along with the amounts which weren't included before.
    Attached image
    Reply With Quote  
     

  7. Thankful user:


  8. #6  
    Registered Member

    Join Date
    Mar 2011
    Age
    27
    Posts
    555
    Thanks given
    168
    Thanks received
    190
    Rep Power
    0
    Quote Originally Posted by Kris View Post
    As Oak said, shouldn't use an endless loop. Even though it will continually just "continue" it'll still use up resource. Plus I don't think you even need it to loop it? You just need it once.
    Could also modify the getCharmsAmount method into this:
    Code:
    private int getCharmsAmount(NPC npc, Charms charm) {
    		if (npc.getId() == 7134)
    			return Utils.random(10, 38);
    		int charmAmount = (int) (Utils.random(npc.getCombatLevel()) * 0.1);
    		switch (charm) {
    		case BLUE_CHARM:
    		case CRIMSON_CHARM:
    		case GOLD_CHARM:
    		case GREEN_CHARM:
    			return charmAmount;
    		default:
    			return -1;
    		}
    	}
    It's pretty nice overall, no major mistakes whatsoever. Clean code, good job.
    However, if you were really into the detail, you could essentially dump charm drop rates from RSWikia I believe. Most NPCs have the charm drop rates in percentages on their wiki pages. Surprised no one has dumped that data yet tbh.

    EDIT: Decided to dump all combat NPC info from RSWikia (At least for the NPCs that exist in 562), including the charm percentages. A lot of the charms had a drop rate ranging from double to another double, so I decided to just add the two up and divide by two (Getting the middle value for them). Anyways, if anyone wants to use this data, feel free to. NOTE: It only contains 171 NPCs data (Went through 9300 NPCs in reality, but a lot of them were still missing some charm percentages on RSWikia and majority of the NPCs weren't even combat related NPCs - only 803 were - does not include any duplicates, goes by NPC name).
    Code:
    Aberrant spectre - 73 12 6 4 5 
    Abyssal demon - 53 8.5 4 33.5 1 
    Abyssal guardian - 80.0 3.5 12.5 2.5 0.8
    Abyssal leech - 97.5 0.7 1.2 0.4 0.4
    Abyssal walker - 73.5 5.5 17.5 3 0.6
    Animated spade - 86.0 7.5 4.5 1.5 1.1
    Ankou - 72 23.5 2 2 0.5
    Aquanite - 74.5 10 5 5 6.5
    Armoured zombie - 82.5 7.5 4 3 3 
    Baby black dragon - 56.0 9.5 22.0 11.0 2 
    Banshee - 89 2.5 7 1 0.3
    Barbarian - 94.0 4.5 1.3 0.3 0.3
    Basilisk - 67 7 19.5 5 1 
    Bat - 81.5 16.0 1.5 0.5 0.7
    Black bear - 82.0 16.5 0.6 0.7 0.5
    Black demon - 23 21 11 44 2 
    Black dragon - 56.5 8.5 26.5 7 1 
    Black Guard - 73.5 5.0 9.5 2.0 11.0
    Black Knight Titan - 37.5 12.5 16.5 18.5 15.0
    Black Knight - 94 3.5 1 0.8 0.7
    Black unicorn - 84.5 5.0 9.5 0.6 0.3
    Bloodveld - 54 9 31 5 1 
    Bloodworm - 79.5 4.5 13.0 2.5 0.8
    Blue dragon - 48.5 11 27.5 11 2 
    Brine rat - 73.5 22.5 1.5 1.5 0.5
    Bronze dragon - 39.5 14.0 31.0 12.5 3.5
    Brutal green dragon - 71.5 15.5 8.0 4.5 1.6
    Catablepon - 77.0 19.0 1.5 2.5 0.3
    Cave bug - 53.0 6.5 36.5 3.5 0.9
    Cave crawler - 87.5 9 2 0.9 0.5
    Cave goblin - 87.0 6.5 2.5 2.5 1.2
    Cave horror - 78.5 5 2 14 0.6
    Chaos dwarf hand cannoneer - 51.0 28.0 11.0 6.5 3.5
    Chaos dwarf - 82.0 9.5 4.5 2.5 2.5
    Chaos dwogre - 64.5 30.5 1.5 2 0.8
    Cockatrice - 89.5 2 7 1 0.3
    Cockroach drone - 93.0 1.5 1.0 4.0 0.4
    Cockroach soldier - 58.5 8 6 26.5 1 
    Cockroach worker - 72.0 6.5 3.5 17.0 1.1
    Commander Zilyana - 30.5 17.0 19.5 23.5 10.0
    Corporeal Beast - 3.5 22.0 12.0 21.5 41.5
    Cow calf - 93.0 3.0 3.0 1.2 0.7
    Cow - 95 0.9 4 0.3 0.1
    Crawling Hand - 89 9.5 0.6 0.6 0.2
    Dark beast - 64.5 9 4.5 8 14 
    Dark warrior - 74.0 18.0 5.0 2 1.2
    Deadly red spider - 72.5 25.0 1.0 1.5 0.2
    Dire Wolf - 60.5 7.5 22.5 8.5 2.1
    Dried zombie - 80.0 6.5 4 3.5 5.5
    Dust devil - 55 12 6 26 0.9
    Dwarf - 90.5 4 2 3 0.6
    Earth warrior - 74.5 9 4.5 11 0.7
    Elf warrior - 60.0 7.5 24.0 6.5 1.5
    Elite Black Knight - 45.5 28.0 8.5 3.5 14.0
    Elite Dark Mage - 97.5 1.4 0.8 1.4 1.4
    Elite Dark Ranger - 87.0 5.0 4.5 2.5 1.1
    Elite Dark Warrior - 53.5 29.0 7.5 10.0 2.9
    Elite Khazard guard - 63.5 25.0 4.0 3.5 5.0
    Enclave guard - 0 0 0 0 0
    Fenris wolf - 61.5 34.0 3.0 1.8 0.5
    Fire elemental - 86.0 4.0 2.5 7.0 0.7
    Fire giant - 31 55.5 7 5 1.5
    Flesh Crawler - 89 4 6 0.8 0.3
    Gargoyle - 74 9.5 5 5 7 
    General Graardor - 42.5 19.0 14.0 14.5 10.0
    Ghoul - 79.5 18.5 0.8 1 0.2
    Giant ant soldier - 82.5 5.0 11.5 2.1 1.1
    Giant bat - 78.5 19.5 0.5 1 0.3
    Giant crypt rat - 91.5 5.0 2.5 1.1 0.3
    Giant crypt spider - 89.5 6.0 2.8 1.2 2.3
    Giant Rock Crab - 2.5 79.5 9.5 6.5 2 
    Giant spider - 88.0 8.5 0.9 2.5 0.7
    Gnoeals - 90.0 4.5 3.7 3.7 2.6
    Goblin - 89 9.5 0.3 0.9 0.2
    Greater demon - 62 7 4 26 0.9
    Greater reborn mage - 0 0 0 0 0
    Greater reborn ranger - 19.0 5.0 61.5 13.0 1.6
    Greater reborn warrior - 35.5 13.0 50.0 3.3 2.3
    Green dragon - 66.5 8.5 16.5 7.5 1.5
    Grizzly bear cub - 85.0 10.5 2.0 2.5 1.2
    Grizzly bear - 85.5 10.5 1.5 2 0.3
    Guard Bandit - 85.5 14.5 8.1 8.1 8.1
    Guard - 91.5 7 0.8 0.5 0.2
    Harpie Bug Swarm - 91.5 2 6 0.5 0.2 
    Hellhound - 20 69 5 5 1 
    Hill Giant - 83.5 14.5 0.9 1 0.2
    Hobgoblin - 82.5 16 0.5 1.0 0.2
    Ice giant - 45.5 45.0 4 4.5 0.7
    Ice spider - 59.5 27.5 7.5 5.0 2.0
    Ice troll female - 81.0 6.5 7.0 3.5 2.0
    Ice troll male - 29.5 22.5 34.0 10.0 4.0
    Ice warrior - 53.5 42.5 1.5 2.5 0.5
    Icefiend - 91.5 3 2 3.5 0.3
    Infernal Mage - 61.5 32.5 3 2.5 0.6
    Iron dragon - 39.5 12.5 32.5 13 3 
    Jelly - 66 7.5 22 3.5 0.9
    Jogre - 56.5 38.0 2.5 2.5 0.4
    Jungle horror - 81.5 3.5 12.5 2 0.5
    K'ril Tsutsaroth - 55.0 12.5 3.5 10.5 18.5
    Kalphite Guardian - 65.0 13.5 6.5 7 8.5
    Kalphite Queen - 79.0 3.0 3.5 6.0 8.5
    Kalphite Soldier - 72.0 8.5 5.5 7.5 6.5
    Kalphite Worker - 87.5 6 3 1.5 2 
    Khazard trooper - 86.0 11.0 1.5 1.1 0.7
    Killerwatt - 84.5 13.5 1.1 0.8 0.2
    King Black Dragon - 29.5 4.0 4.5 61.0 1.5
    Knight of Saradomin - 66.5 27.0 1.6 1.6 7.5
    Kraka - 67.0 22.0 5.5 4.5 2.0
    Kree'arra - 39.0 25.0 13.5 15.5 7.5
    Kurask - 56.5 8.5 27 6.5 1 
    Lesser demon - 94 2 0.8 3 0.6
    Lesser reborn mage - 95.5 1.5 1.1 1.1 1.1
    Lesser reborn ranger - 73.0 13.0 7.0 5.5 3.0
    Lesser reborn warrior - 92.0 2.3 5.5 2.3 2.3
    Locust rider - 68.0 4.5 5.5 22.5 1.1
    Mammoth - 69.5 2.1 5.5 9.5 15.5
    Mighty banshee - 71.5 5.5 17 4.5 1 
    Mithril dragon - 9.5 19.5 49.0 19.5 3.5
    Monk of Zamorak - 88.5 0.7 9.0 1.5 0.7
    Monkey - 100 0.1 0.1 0.1 0.1
    Moss giant - 61.5 32.5 3 2.5 0.6
    Mounted terrorbird gnome - 82.5 12.5 0.8 4.5 0.6
    Mutated bloodveld - 46.5 43.5 5.5 4 1 
    Nechryael - 55 9 4.5 30.5 1.1
    Ogre - 82.5 13.5 2 1.5 0.4
    Ogress champion - 13.5 79.5 4 2.5 0.8
    Ogress warrior - 53.0 39.0 3.5 3.5 2.1
    Ogress - 53.0 39.0 4.0 4.5 0.7
    Ork legion - 2.5 62.5 25.5 10.0 0.1
    Pee Hat - 54.0 36.5 8.0 5.0 1.3
    Poison spider - 61.5 10.0 28.5 0.1 0.3
    Pyrefiend - 86.5 5 2.5 5.5 0.5
    Red dragon - 19.0 18.0 42.5 17.0 3.5
    Rock Crab - 88 10 0.5 1 0.3
    Rock lobster - 47.5 16.0 9.0 24.0 3.5
    Rogue - 85.0 5.0 3.5 3.5 3 
    Scabaras ranger - 90.0 5.0 1.5 1.5 1.5
    Shadow Hound - 86.0 7.0 2.5 2.5 1.3
    Shadow warrior - 70.5 10.5 5.5 13 0.6
    Skeletal hand - 73.5 23.0 2.5 1.4 0.3
    Skeletal Wyvern - 34.0 6.5 3.5 54.5 1.5
    Skeleton - 90.0 5.5 0.9 2.5 1.0
    Skogre - 60.0 28.0 8.0 3.5 1.5
    Spider - 92.0 2.5 3.5 1.4 1.5
    Steel dragon - 33.5 14 35.5 14 3 
    Suqah - 64.5 14 8 6 7.5
    Terror dog - 71.5 9.5 7.5 8.5 3 
    Thug - 86.5 11.5 0.8 0.7 0.3
    Tormented demon - 25.5 14.0 9.0 15.5 37.0
    Tormented wraith - 47.0 12.5 5.0 13.0 22.0
    Troll general - 50.5 39.5 5.0 3.5 2.5
    Turoth - 64 7.5 22 5.5 1 
    Undead Lumberjack - 0 0 0 0 0
    Undead troll - 89.5 5.0 1.1 2.5 3.0
    Vampire - 90.0 4.5 2 3.5 0.4
    Vyrewatch - 92.5 2.5 1.0 2.5 1.5
    Wall beast - 73.5 10.0 6.0 10.0 1.1
    Wallasalki - 56.5 15.5 7.5 8.5 11.5
    Warped tortoise - 80.5 9 4 3 3.5
    Warrior woman - 89.5 6.0 2.0 2.0 1.6
    Waterfiend - 5 9 5 79 2 
    Werewolf - 46.5 44.5 4 4 1.1
    White wolf - 73.0 10.0 4.0 12.5 0.5
    Wild dog - 70.0 6.5 16.0 6.5 1.5
    Wizard - 78.0 12.5 6.0 4.0 0.3
    Wolf - 88.5 3.5 2.0 6.0 0.5
    Yeti - 54.5 22.5 12.0 7.5 7.5
    Zamorak ranger - 78.5 1.4 2.5 4.5 13.5
    Zamorak warrior - 76.5 18.0 3.0 2.5 0.8
    Zogre - 86.0 11.0 1.5 1.5 0 
    Zombie hand - 76.5 21.5 1.4 1.6 0.6
    Format:
    NPC name - NO_CHARM_CHANCE GOLD_CHARM_CHANCE GREEN_CHARM_CHANCE CRIMSON_CHARM_CHANCE BLUE_CHARM_CHANCE

    Ignore the fact that the amounts added up don't always equal to 100%. It's due to how I rounded them.
    Thanks, i never botherd to dump the drop rates on wiki.
    Avalon Developer
    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. [718] Charms drop on npcs
    By CheaterXman in forum Tutorials
    Replies: 15
    Last Post: 05-03-2014, 01:06 PM
  2. World Ground item help Charm drop
    By 1123r123r in forum Help
    Replies: 0
    Last Post: 10-19-2012, 07:50 PM
  3. Zenith Scape Charm Drop Amount
    By PvMLegacyTyler in forum Help
    Replies: 1
    Last Post: 09-16-2012, 03:01 AM
  4. Replies: 8
    Last Post: 01-05-2012, 10:45 AM
  5. charm dropping
    By tasha in forum Help
    Replies: 5
    Last Post: 07-07-2011, 07:20 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
  •