| 722 | } |
| 723 | |
| 724 | void BattleUnit::onReachGoal(GameState &state) |
| 725 | { |
| 726 | // Remember who seen us before (for interrupt) |
| 727 | std::set<StateRef<BattleUnit>> enemiesThatSeenUsBefore; |
| 728 | if (state.current_battle->mode == Battle::Mode::TurnBased) |
| 729 | { |
| 730 | auto srthis = StateRef<BattleUnit>(&state, id); |
| 731 | for (auto &u : state.current_battle->units) |
| 732 | { |
| 733 | if (u.second->visibleEnemies.find(srthis) != u.second->visibleEnemies.end()) |
| 734 | { |
| 735 | enemiesThatSeenUsBefore.insert(srthis); |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | refreshUnitVisibilityAndVision(state); |
| 740 | // Interrupt |
| 741 | if (state.current_battle->mode == Battle::Mode::TurnBased) |
| 742 | { |
| 743 | auto srthis = StateRef<BattleUnit>(&state, id); |
| 744 | for (auto &u : state.current_battle->units) |
| 745 | { |
| 746 | if (u.second->visibleEnemies.find(srthis) != u.second->visibleEnemies.end()) |
| 747 | { |
| 748 | // Mutual surprise rule: unit can interrupt us only if either is true: |
| 749 | // - he has seen us before |
| 750 | // - we don't see him now |
| 751 | if (enemiesThatSeenUsBefore.find({&state, u.first}) != |
| 752 | enemiesThatSeenUsBefore.end() || |
| 753 | visibleEnemies.find({&state, u.first}) == visibleEnemies.end()) |
| 754 | { |
| 755 | state.current_battle->giveInterruptChanceToUnit( |
| 756 | state, {&state, id}, {&state, u.first}, agent->getReactionValue()); |
| 757 | } |
| 758 | } |
| 759 | } |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | int BattleUnit::getAttackCost(GameState &state, AEquipment &item, Vec3<int> tile) |
| 764 | { |
nothing calls this directly
no test coverage detected