Thread: NPC drops with Ice Barrage

Results 1 to 7 of 7
  1. #1 NPC drops with Ice Barrage 
    Registered Member
    Join Date
    Aug 2012
    Posts
    59
    Thanks given
    5
    Thanks received
    7
    Rep Power
    23
    Hey guys,

    Something that I am struggling to do on a Ruse Base is with Ice Barrage or actually any Spells that hit inMulti
    Right now, I've got an area where there are Chickens that are easy to 1 hit as they've only got 1 hp, but the thing is only the Chicken that I click on when casting the spell will drop loot such as bones.
    Every other chicken that dies from the Area of Effect from a Barrage spell doesn't drop anything.

    What I've done so far is just played around with CombatAncientSpell.java where in finishCast as it mentions hitting the NPCs in multi.
    This is the code that I am working with, it's pretty much in every Ruse base.

    Code:
    Iterator<? extends Character> it = null;
    	        if (cast.isPlayer() && castOn.isPlayer()) {
    	            it = ((Player) cast).getLocalPlayers().iterator();
    	        } else if (cast.isPlayer() && castOn.isNpc()) {
    	            it = ((Player) cast).getLocalNpcs().iterator();
    	        } else if (cast.isNpc() && castOn.isNpc()) {
    	            it = World.getNpcs().iterator();
    	        } else if (cast.isNpc() && castOn.isPlayer()) {
    	            it = World.getPlayers().iterator();
    	        }
    
    	        for (Iterator<? extends Character> $it = it; $it.hasNext();) {
    	            Character next = $it.next();
    
    	            if (next == null) {
    	                continue;
    	            }
    	            
    	            if(next.isNpc()) {
    	            	NPC n = (NPC)next;
    	            	if(!n.getDefinition().isAttackable() || n.isSummoningNpc()) {
    	            		continue;
    	            	}
    	            } else {
    	            	Player p = (Player)next;
    	            	if(p.getLocation() != Location.WILDERNESS || !Location.inMulti(p)) {
    	            		continue;
    	            	}
    	            }
    	            
    
    	            if (next.getPosition().isWithinDistance(castOn.getPosition(),
    	                spellRadius()) && !next.equals(cast) && !next.equals(castOn) && next.getConstitution() > 0 && next.getConstitution() > 0) {
    	                cast.getCurrentlyCasting().endGraphic().ifPresent(next::performGraphic);
    	                int calc = Misc.random(damage);
    	                next.dealDamage(new Hit(calc, Hitmask.RED, CombatIcon.MAGIC));
    	                next.getCombatBuilder().addDamage(cast, calc);
    	                
    	                
    	                
    	                spellEffect(cast, next, calc);
    	            }
    	        }
    Any pointers on what I should be doing, or looking for?
    I've just concluded that the inMulti damage isn't considered the players which is why it doesn't drop anything.
    Reply With Quote  
     

  2. #2  
    Registered Member
    arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,711
    Thanks given
    170
    Thanks received
    285
    Discord
    Arch337#1337
    Rep Power
    631
    Make it so the damage know that the player dealt it instead of just dealing the damage.
    Because with your code it seems like it just deal the damage and have no idea who the killer of the npc was to reward anything.


    "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. #3  
    Registered Member
    Join Date
    Aug 2012
    Posts
    59
    Thanks given
    5
    Thanks received
    7
    Rep Power
    23
    Quote Originally Posted by arch337 View Post
    Make it so the damage know that the player dealt it instead of just dealing the damage.
    Because with your code it seems like it just deal the damage and have no idea who the killer of the npc was to reward anything.
    Yeah, that's what I thought. Do you know which Java file I would need to look at to do that?
    Or I'd just need to add more code in this file to specify the owner of the damage.
    Reply With Quote  
     

  4. #4  
    Registered Member
    arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,711
    Thanks given
    170
    Thanks received
    285
    Discord
    Arch337#1337
    Rep Power
    631
    Quote Originally Posted by Rng Rng Ownu View Post
    Yeah, that's what I thought. Do you know which Java file I would need to look at to do that?
    Or I'd just need to add more code in this file to specify the owner of the damage.
    I would advice to check your combat code to see how they deal the damage.
    Like take a look at a single target spell to see how it determ the damage as.


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

  5. #5  
    Registered Member
    Join Date
    Sep 2016
    Posts
    51
    Thanks given
    24
    Thanks received
    37
    Discord
    knd6060#4741
    Rep Power
    15
    Code:
    	/**
    	 * Adds damage to the damage map, as long as the argued amount of damage is
    	 * above 0 and the argued entity is a player.
    	 * 
    	 * @[Only registered and activated users can see links. ] entity
    	 *            the entity to add damage for.
    	 * @[Only registered and activated users can see links. ] amount
    	 *            the amount of damage to add for the argued entity.
    	 */
    	public void addDamage(Character entity, int amount) {
    
    		// No damage below 0, and no npcs can be added to the map.
    		if (amount < 1 || entity.isNpc()) {
    			return;
    		}
    
    		// Add on to the damage for existing players.
    		Player player = (Player) entity;
    		if (damageMap.containsKey(player)) {
    			damageMap.get(player).incrementDamage(amount);
    			return;
    		}
    
    		// Or add a completely new entry.
    		damageMap.put(player, new CombatDamageCache(amount));
    	}
    this should work fine, nothing wrong with the code you posted I think. Maybe the drop code has a problem.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Aug 2012
    Posts
    59
    Thanks given
    5
    Thanks received
    7
    Rep Power
    23
    Quote Originally Posted by knd6060 View Post

    this should work fine, nothing wrong with the code you posted I think. Maybe the drop code has a problem.
    Yeah I found out that it was fine all along. It only bugs out with no drops because it 1 hits the NPC. I tested it out NPCs with higher HP and I don't have that issue. It's only when that multi hit actually 1 shots something does this happen. Thank you though.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Sep 2016
    Posts
    51
    Thanks given
    24
    Thanks received
    37
    Discord
    knd6060#4741
    Rep Power
    15
    Quote Originally Posted by Rng Rng Ownu View Post
    Yeah I found out that it was fine all along. It only bugs out with no drops because it 1 hits the NPC. I tested it out NPCs with higher HP and I don't have that issue. It's only when that multi hit actually 1 shots something does this happen. Thank you though.
    Try swapping around the add damage and deal damage statements. It might execute the NPCDeathTask and try get the killer in the same call before it updates the damage map, which would explain why it works on higher hp but not on one hit. I'd have to check code again to see if that is the case.

    EDIT:This code would get executed immediately inside dealDamage sub calls
    Code:
    @Override
    	public void appendDeath() {
    		if(!isDying && !summoningNpc) {
    			TaskManager.submit(new NPCDeathTask(this));
    			isDying = true;
    		}
    	}
    EDIT2: It appears that the NPCDeathTask is not an immediate task so and gets the killer 2 ticks later rather than executing in same call chain. So this isn't the problem either and the swapping won't likely fix it. Can try anyway
    Reply With Quote  
     

  8. Thankful user:



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. help with ice barrage
    By Kingrambo in forum Help
    Replies: 2
    Last Post: 12-22-2015, 02:15 PM
  2. [667/*] Npc drop with random amount
    By Coinflipper in forum Snippets
    Replies: 4
    Last Post: 11-06-2012, 08:37 AM
  3. [Delta] help with ice barrage sound
    By Mr Sandman in forum Help
    Replies: 6
    Last Post: 10-25-2011, 03:15 PM
  4. need help with ice barrage
    By lorenzo in forum Help
    Replies: 1
    Last Post: 02-12-2010, 11:44 PM
  5. NPC drops with Java file
    By Mrquarterx in forum Tutorials
    Replies: 13
    Last Post: 07-07-2009, 08:47 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
  •