Multiplying damage when hit in the back

Discussion in 'Plugin Development' started by WolfMage1, Apr 6, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    WolfMage1

    Hitting players in the back with a sword does triple damage,

    Jumping from over 10 blocks and hitting a player while still in air will do triple damage.
     
  2. Offline

    Zombie_Striker

    @WolfMage1
    What are you asking? Are you asking how to code this, or are you asking for someone else to make this plugin for you?
     
  3. Offline

    WolfMage1

    Asking how to code it.
     
  4. Offline

    Zombie_Striker

    @WolfMage1
    First, lets do back-stabbing
    1. EntityDamageByEntityEvent
    2. Use Entity#getLocation.getDirection to get the direction the entity is looking. Do this for both the damager and the damaged entity.
    3. If the difference between the two players are less than 45 degrees and -45 degrees, then triple the damage.
    For the jump attack:
    1. Create a HashMap. The key will be UUIDs and the value will be the Location. This store the last location of the player when they were on the ground.
    2. PlayerMoveEvent.
    3. If the player is on the ground, set the location in the hashmap.
    4. On EntityDamageByEntityEvent
    5. If the distance between the damager and the location from the hashmap is greater than 10 blocks, triple the damage.
     
  5. Offline

    WolfMage1

    I'm not sure how to do that. I've never used Bukkits vectors
     
  6. Offline

    Zombie_Striker

    @WolfMage1
    It actually quite simple. Here is the method for comparing vectors
    Code:
    public boolean vectorIsSimilar(Vector v1, Vector v2){
    //v1 and v2 are the player's vector.
    
    if(v1.getX > v1.getZ){
    return Math.cos(Player1.getX()-Player2.getX()) >= Math.PI/4;
    }else {
    return Math.cos(Player1.getZ()-Player2.getZ()) >= Math.PI/4;
    }
    }
     
  7. Just asking for personal interest.
    Wouldn't that be very bad for performance on bigger servers? Let's say about 500 players online and moving?
     
  8. Offline

    martian3333

    I don't know how accurate it would be but couldn't you check to see if the player was on the ground, and if not check player.getFallDistance
     
  9. Offline

    Zombie_Striker

    @Erumeldor
    First, if you have 500 players online and can support all them with minimal lag, the lag caused should be minimal. Even if it were a problem, the alternative to this would be to use repeating tasks to log players locations every couple of ticks. This would help the performance a bit, but in return, you would be reducing the accuracy.
     
Thread Status:
Not open for further replies.

Share This Page