Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. /**
  2. * Attack a provided list of cleave targets.
  3. *
  4. * @param attacker The attacking creature.
  5. * @param targets The targets to cleave.
  6. * @param attack_number ?
  7. * @param effective_attack_number ?
  8. */
  9. void attack_cleave_targets(actor &attacker, list<actor*> &targets,
  10. int attack_number, int effective_attack_number,
  11. wu_jian_attack_type wu_jian_attack)
  12. {
  13. if (wu_jian_attack == WU_JIAN_ATTACK_WHIRLWIND
  14. || wu_jian_attack == WU_JIAN_ATTACK_WALL_JUMP
  15. || wu_jian_attack == WU_JIAN_ATTACK_TRIGGERED_AUX)
  16. {
  17. return; // WJC AOE attacks don't cleave.
  18. }
  19.  
  20. while (attacker.alive() && !targets.empty())
  21. {
  22. actor* def = targets.front();
  23. if (def && def->alive() && !_dont_harm(attacker, *def) && cleave_target_adjacent(attacker, *def))
  24. {
  25. melee_attack attck(&attacker, def, attack_number,
  26. ++effective_attack_number, true);
  27.  
  28. attck.wu_jian_attack = wu_jian_attack;
  29. attck.attack();
  30. }
  31. targets.pop_front();
  32. }
  33. }
  34.  
  35. /**
  36. * Attack a provided list of cleave targets.
  37. *
  38. * @param attacker The attacking creature.
  39. * @param target The target to cleave.
  40. */
  41. bool cleave_target_adjacent(actor &attacker, actor &target)
  42. {
  43. coord_def apos = attacker.pos();
  44. coord_def tpos = target.pos();
  45.  
  46. int dx = abs(apos.x - tpos.x);
  47. int dy = abs(apos.y - tpos.y);
  48.  
  49. int sum = dx + dy;
  50.  
  51. if(sum == 1 || sum == 2)
  52. {
  53. return true;
  54. }
  55. else
  56. {
  57. return false;
  58. }
  59.  
  60. return true;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement