Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Attack a provided list of cleave targets.
- *
- * @param attacker The attacking creature.
- * @param targets The targets to cleave.
- * @param attack_number ?
- * @param effective_attack_number ?
- */
- void attack_cleave_targets(actor &attacker, list<actor*> &targets,
- int attack_number, int effective_attack_number,
- wu_jian_attack_type wu_jian_attack)
- {
- if (wu_jian_attack == WU_JIAN_ATTACK_WHIRLWIND
- || wu_jian_attack == WU_JIAN_ATTACK_WALL_JUMP
- || wu_jian_attack == WU_JIAN_ATTACK_TRIGGERED_AUX)
- {
- return; // WJC AOE attacks don't cleave.
- }
- while (attacker.alive() && !targets.empty())
- {
- actor* def = targets.front();
- if (def && def->alive() && !_dont_harm(attacker, *def) && cleave_target_adjacent(attacker, *def))
- {
- melee_attack attck(&attacker, def, attack_number,
- ++effective_attack_number, true);
- attck.wu_jian_attack = wu_jian_attack;
- attck.attack();
- }
- targets.pop_front();
- }
- }
- /**
- * Attack a provided list of cleave targets.
- *
- * @param attacker The attacking creature.
- * @param target The target to cleave.
- */
- bool cleave_target_adjacent(actor &attacker, actor &target)
- {
- coord_def apos = attacker.pos();
- coord_def tpos = target.pos();
- int dx = abs(apos.x - tpos.x);
- int dy = abs(apos.y - tpos.y);
- int sum = dx + dy;
- if(sum == 1 || sum == 2)
- {
- return true;
- }
- else
- {
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement