How to increase the explosion velocity done to players?

Discussion in 'Spigot Plugin Development' started by GodzillaCodes, Sep 4, 2016.

  1. I am trying to increase the explosion velocity done to the players. e.g Fireballs, tnt, etc. Im not sure how to do this though :/ Thanks for helping :)
     
  2. Just increase the explosion power. Alternatively, you can manually apply velocities (if you don't wish to increase the size of the explosion)
     
  3. Increasing the explosion power then cancelling the explosion will still keep the increased velocity?
     
  4. Not certain but I think velocities are calculated after the explosion event. Actually I'm fairly certain of that.

    So you'll need to manually calculate the velocities to add. You should get a vector between the explosion source and entity location. Take the reciprocal the vector and multiply it by a constant. Apply it to the entity. Repeat for all entities in range.
     
    • Agree Agree x 1
  5. Sorry for being a little noobish... But how would i go about doing that? Can you please put it in code form? Not an entire method, just bits and pieces. thanks :)
     
  6. So when the entity explodes, get entities in a nearby radius. explodingEntity.getNearbyEntities(rad, rad, rad)
    Next loop through them.
    With each, make a new vector
    You can do this by doing endlocation (the entity) minus startlocation (the exploding point). endlocation.toVector().subtract(startlocation.toVector()).
    Now you have a delta vector. You should get its recipricoal so that closer entities have larger numbers and entities further away have smaller vectors. You can do this by creating a new vector with x as 1/oldx and so on. Now, apply the vector to the entity (entity.setVelocity(vec)).
    Tweak the 1 from 1/oldx. The larger that number, the further the entities should fly.

    Note: This is all off the top of my head and may/may not work

    Hope I helped.