Solved Trying to change Damage dealt based on Player

Discussion in 'Spigot Plugin Development' started by He-light, Jan 28, 2020.

  1. Hello,
    I trie to make a Plugin, which allows players to use combat based magic, like striking another player with a lightning. My problem is: Based on another feature of my plugin, you are able to skill attributes of your character. For example, you should also be able to increase your "magic" damage. Now I need to figure out a way to observe, which player was the "caster" of the spell, so I can check his magic damage rating and adjust the damage. But if you spawn a lightning or spawn an explosion for a spell effect, there is no relation to the player who casted the spell. Any suggestions?
     
  2. EntityDamageByEntityEvent -> Player? -> get modified attribute -> damage more
     
  3. Wouldn't the lightning itself be the entity, who damaged the other entity? Because in this case, how should i check for the player?
     
  4. Well, if you summon the strike like so:
    Code (Java):
    final LightningStrike strike = world.spawn(location, LightningStrike.class);
    you can store the player that cast the strike and the strike in a Map. You can then (in the EntityDamageByEntityEvent) check if the strike hit the player and get the player that caused the Strike
     
  5. wow, thats a very interesting solution! Thanks for the Help! :D