Thread: Attack then do something

Page 1 of 3 123 LastLast
Results 1 to 10 of 28
  1. #1 Attack then do something 
    Banned
    Join Date
    Feb 2013
    Posts
    1,067
    Thanks given
    72
    Thanks received
    28
    Rep Power
    0
    well when i attack and them do something when it does animation the hit splat does not show after i attack and do nothing it will hit normally
    for example


    Another example


    this is base im using
    http://www.rune-server.org/runescape...at-system.html

    here is the playervsentity method
    Code:
    public static void playerVsEntity(Entity attacker, Entity target) {
    		Player p = (Player) attacker;
    		if (target == null || target.isDead || attacker.isDead
    				|| target.getConstitution() <= 0
    				|| attacker.getConstitution() <= 0 || attacker.respawnTimer > 0) {
    			p.usingMagic = false;
    			p.faceUpdate(0);
    			p.setTarget(null);
    			return;
    		}
    
    			
    		if (!RequerimentHandler.playerReqs(attacker, target))
    			return;
    		p.setFollowEntity(target);
    		if (p.attackTimer > 0)
    			return;
    		if (!RequerimentHandler.combatDistance(attacker, target)) {
    			p.attackTimer = 2;
    			return;
    		}
    		int faceId = target.isPlayer() ? target.getIndex() + 32768 : target
    				.getIndex();
    		attacker.accuracyIncrease = attacker.damageIncrease = 1;
    		attacker.setAttackType(WeaponsHandler.getWeaponType(attacker));
    		p.attackTimer = WeaponsHandler.getHitDelay(attacker);
    		p.faceUpdate(faceId);
    		target.setAggressor(attacker);
    		switch (attacker.getAttackType()) {
    		case MELEE:
    			applyMelee(attacker, target);
    			break;
    		case RANGED:
    			applyRanged(attacker, target);
    			break;
    		case MAGIC:
    			applyMagic(attacker, target);
    			break;
    		default:
    			return;
    		}
    	}
    Reply With Quote  
     

  2. #2  
    Banned
    Join Date
    Feb 2013
    Posts
    1,067
    Thanks given
    72
    Thanks received
    28
    Rep Power
    0
    bump really need help on this
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Jul 2013
    Posts
    594
    Thanks given
    261
    Thanks received
    104
    Rep Power
    247
    this dosent make alot of sense, could you explain a bit better?
    Reply With Quote  
     

  4. #4  
    Banned
    Join Date
    Feb 2013
    Posts
    1,067
    Thanks given
    72
    Thanks received
    28
    Rep Power
    0
    Quote Originally Posted by Number One Fag View Post
    this dosent make alot of sense, could you explain a bit better?
    umm lets say i attack an npc
    during when the animation is taking place if i click away it will not cause any damage
    is that better, sorry i just dont know how to explain it properly, guess im just shit at explaining things lol
    Reply With Quote  
     

  5. #5  
    Banned
    Join Date
    Feb 2013
    Posts
    1,067
    Thanks given
    72
    Thanks received
    28
    Rep Power
    0
    added a method if that helps, still really need help with this
    Reply With Quote  
     

  6. #6  
    Banned
    Join Date
    May 2014
    Posts
    27
    Thanks given
    6
    Thanks received
    3
    Rep Power
    0
    Does this happen with the other 2 combt classes? (Magic, Range)
    Reply With Quote  
     

  7. #7  
    Banned
    Join Date
    Feb 2013
    Posts
    1,067
    Thanks given
    72
    Thanks received
    28
    Rep Power
    0
    Quote Originally Posted by Kale View Post
    Does this happen with the other 2 combt classes? (Magic, Range)
    yes happens with all 3
    Reply With Quote  
     

  8. #8  
    Banned
    Join Date
    May 2014
    Posts
    27
    Thanks given
    6
    Thanks received
    3
    Rep Power
    0
    Quote Originally Posted by bhans12 View Post
    yes happens with all 3
    I need to see the method where the hit is actually applied
    Reply With Quote  
     

  9. #9  
    Banned
    Join Date
    Feb 2013
    Posts
    1,067
    Thanks given
    72
    Thanks received
    28
    Rep Power
    0
    here is sethit methods
    Code:
    public void setSingleHit(int damage, int mask, int icon) {
    		this.singleDamage = damage;
    		this.hitMask = mask;
    		this.hitIcon = icon;
    		setConstitution(getConstitution() - damage);
    		getUpdateFlag().flag(Flag.SINGLE_HIT);
    		if (isPlayer())
    			((Player) this).getPA().refreshSkill(3);
    		if (getConstitution() <= 0)
    			applyDead();
    		updateRequired = true;
    	}
    
    	public void setDoubleHit(int damage, int mask, int icon) {
    		this.doubleDamage = damage;
    		this.hitMask2 = mask;
    		this.hitIcon2 = icon;
    		setConstitution(getConstitution() - damage);
    		getUpdateFlag().flag(Flag.DOUBLE_HIT);
    		if (isPlayer())
    			((Player) this).getPA().refreshSkill(3);
    		if (getConstitution() <= 0)
    			applyDead();
    		updateRequired = true;
    	}

    here is the calculate hit method
    Code:
    	public static int calculateHit(Entity attacker, Entity target,
    			boolean isSpecial) {
    		int hit = 0;
    		if (attacker.isPlayer()) {
    			Player p = (Player) attacker;
    			if (attacker.getAttackType() == AttackTypes.MELEE)
    				hit = 1 + Misc.random((int) (CombatFormulas.getMeleeMaxHit(p,
    						target, p.usingSpecial) - 1));
    			if (attacker.getAttackType() == AttackTypes.RANGED)
    				hit = 1 + Misc.random(((int) CombatFormulas.getRangedMaxHit(
    						attacker, isSpecial) - 1));
    			if (attacker.getAttackType() == AttackTypes.MAGIC) {
    
    				switch (SpellLoader.getSpellDefinitions()[attacker.getFields()
    						.getSpellIndex(p)].getSpellId()) {
    				case 1190:
    				case 1191:
    				case 1192:
    					hit = 1 + Misc
    							.random(SpellLoader.getSpellDefinitions()[attacker
    									.getFields().getSpellIndex(p)].getMaxHit() - 1);
    					break;
    				default:
    					hit = 1 + Misc
    							.random(SpellLoader.getSpellDefinitions()[attacker
    									.getFields().getSpellIndex(p)].getMaxHit() - 1);
    					break;
    				}
    
    			}
    		} else {
    			Npc n = (Npc) attacker;
    			hit = Misc.random(n.maxHit);
    		}
    		return hit;
    	}






    also here is applydamage method
    Code:
    public static void applyDamage(Entity attacker, Entity target) {
    		Player p = (Player) attacker;
    		if (target == null || target.isDead || attacker.isDead
    				|| target.getConstitution() <= 0
    				|| attacker.getConstitution() <= 0 || attacker.respawnTimer > 0) {
    			p.usingMagic = false;
    			p.faceUpdate(0);
    			p.setTarget(null);
    			return;
    		}
    		if (target.isPlayer()) {
    			Player t = (Player) target;
    			t.setAggressor(attacker);
    			t.logoutDelay = System.currentTimeMillis();
    			t.singleCombatDelay = System.currentTimeMillis();
    		}
    		target.lastDamageTaken = System.currentTimeMillis();
    		attacker.attackTimer = WeaponsHandler.getHitDelay(attacker);
    		int damage = CalculateHit.getAccuracy(attacker, target);
    		int damage2 = CalculateHit.getAccuracy(attacker, target);
    		//Curses.applyCurses(attacker, target, damage);
    		int crit = 0;
    		int crit2 = 0;
    		Extras.addCombatExp(p, damage);
    		if (p.doubleHit)
    			Extras.addCombatExp(p, damage2);
    		switch (attacker.getAttackType()) {
    		case MELEE:
    			crit = damage * 0.92 > CombatFormulas.getMeleeMaxHit(attacker,
    					target, p.usingSpecial) ? 1 : 0;
    			crit2 = damage2 * 0.92 > CombatFormulas.getMeleeMaxHit(attacker,
    					target, p.usingSpecial) ? 1 : 0;
    			target.setSingleHit(damage, crit, 0);
    			if (p.doubleHit)
    				target.setDoubleHit(damage2, crit2, 0);
    			p.doubleHit = false;
    			break;
    		case MAGIC:
    			if (p.usingMagic && !attacker.getFields().isAutoCasting())
    				CombatAssistant.resetPlayerAttack(p);
    			crit = damage * 0.92 > SpellLoader.getSpellDefinitions()[attacker
    					.getFields().getSpellIndex(attacker)].getMaxHit() ? 1 : 0;
    			target.setSingleHit(damage, crit, 2);
    			target.performGraphic(new Graphic(
    					SpellLoader.getSpellDefinitions()[attacker.getFields()
    							.getSpellIndex(attacker)].getEndGraphicId()));
    			break;
    		case RANGED:
    			Ranged.boltEffects(attacker, target, damage);
    			crit = damage * 0.92 > CombatFormulas.getRangedMaxHit(attacker,
    					p.usingSpecial) ? 1 : 0;
    			crit2 = damage2 * 0.92 > CombatFormulas.getRangedMaxHit(attacker,
    					p.usingSpecial) ? 1 : 0;
    			target.setSingleHit(damage, crit, 1);
    			if (p.doubleHit)
    				target.setDoubleHit(damage2, crit2, 1);
    			p.doubleHit = false;
    			break;
    		default:
    			break;
    		}
    	}
    Reply With Quote  
     

  10. #10  
    Banned
    Join Date
    May 2014
    Age
    29
    Posts
    78
    Thanks given
    0
    Thanks received
    6
    Rep Power
    0
    In whatever class you're handling all the clicking packets just make it reset combat?
    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. Someone Should Do Something
    By Mrquarterx in forum RS2 Server
    Replies: 10
    Last Post: 04-09-2009, 06:33 AM
  2. We need to do something about this.
    By Simon in forum RS2 Server
    Replies: 10
    Last Post: 03-24-2008, 12:47 PM
  3. Doing something for $1 paypal.
    By Dawgg in forum Chat
    Replies: 0
    Last Post: 01-27-2008, 08:52 PM
  4. Replies: 8
    Last Post: 11-23-2007, 01:51 AM
  5. Make an object do something
    By delta11 in forum Tutorials
    Replies: 4
    Last Post: 10-21-2007, 05:56 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
  •