void shroud_clearing_action::take_village() { team ¤t_team = resources::controller->current_team(); const map_location back = route.back(); if(resources::gameboard->map().is_village(back)) { get_village(back, current_team.side(), NULL, false); //MP_COUNTDOWN restore capture bonus if(take_village_timebonus) { current_team.set_action_bonus_count(1 + current_team.action_bonus_count()); } } }
void shroud_clearing_action::return_village() { team ¤t_team = resources::controller->current_team(); const map_location back = route.back(); if(resources::gameboard->map().is_village(back)) { get_village(back, original_village_owner, NULL, false); //MP_COUNTDOWN take away capture bonus if(take_village_timebonus) { current_team.set_action_bonus_count(current_team.action_bonus_count() - 1); } } }
/** * Undoes this action. * @return true on success; false on an error. */ bool move_action::undo(int side) { game_display & gui = *resources::screen; unit_map & units = *resources::units; team ¤t_team = (*resources::teams)[side-1]; // Copy some of our stored data. const int saved_moves = starting_moves; std::vector<map_location> rev_route = route; std::reverse(rev_route.begin(), rev_route.end()); // Check units. unit_map::iterator u = units.find(rev_route.front()); const unit_map::iterator u_end = units.find(rev_route.back()); if ( u == units.end() || u_end != units.end() ) { //this can actually happen if the scenario designer has abused the [allow_undo] command ERR_NG << "Illegal 'undo' found. Possible abuse of [allow_undo]?" << std::endl; return false; } if ( resources::gameboard->map().is_village(rev_route.front()) ) { get_village(rev_route.front(), original_village_owner + 1, NULL, false); //MP_COUNTDOWN take away capture bonus if ( countdown_time_bonus ) { current_team.set_action_bonus_count(current_team.action_bonus_count() - 1); } } // Record the unit's current state so it can be redone. starting_moves = u->movement_left(); goto_hex = u->get_goto(); // Move the unit. unit_display::move_unit(rev_route, u.get_shared_ptr(), true, starting_dir); units.move(u->get_location(), rev_route.back()); unit::clear_status_caches(); // Restore the unit's old state. u = units.find(rev_route.back()); u->set_goto(map_location()); u->set_movement(saved_moves, true); u->anim_comp().set_standing(); gui.invalidate_unit_after_move(rev_route.front(), rev_route.back()); execute_undo_umc_wml(); return true; }
/** * Redoes this action. * @return true on success; false on an error. */ bool move_action::redo(int side) { game_display & gui = *resources::screen; unit_map & units = *resources::units; team ¤t_team = (*resources::teams)[side-1]; // Check units. unit_map::iterator u = units.find(route.front()); if ( u == units.end() ) { ERR_NG << "Illegal movement 'redo'." << std::endl; assert(false); return false; } // Adjust starting moves. const int saved_moves = starting_moves; starting_moves = u->movement_left(); // Move the unit. unit_display::move_unit(route, u.get_shared_ptr()); units.move(u->get_location(), route.back()); u = units.find(route.back()); unit::clear_status_caches(); // Set the unit's state. u->set_goto(goto_hex); u->set_movement(saved_moves, true); u->anim_comp().set_standing(); if ( resources::gameboard->map().is_village(route.back()) ) { get_village(route.back(), u->side(), NULL, false); //MP_COUNTDOWN restore capture bonus if ( countdown_time_bonus ) { current_team.set_action_bonus_count(1 + current_team.action_bonus_count()); } } gui.invalidate_unit_after_move(route.front(), route.back()); resources::recorder->redo(replay_data); replay_data.clear(); execute_redo_umc_wml(); return true; }
/** * Does some bookkeeping and event firing, for use after movement. * This includes village capturing and the undo stack. */ void unit_mover::post_move(undo_list *undo_stack) { const map_location & final_loc = final_hex(); int orig_village_owner = -1; int action_time_bonus = 0; // Reveal ambushers? if ( ambushed_ || blocked_ ) reveal_ambushers(); else if ( teleport_failed_ && spectator_ ) spectator_->set_failed_teleport(resources::units->find(*obstructed_)); unit::clear_status_caches(); if ( move_it_.valid() ) { // Update the moving unit. move_it_->set_interrupted_move( sighted_stop_ && !resources::whiteboard->is_executing_actions() ? *(full_end_-1) : map_location::null_location); if ( ambushed_ || final_loc == zoc_stop_ ) move_it_->set_movement(0, true); // Village capturing. if ( resources::game_map->is_village(final_loc) ) { // Is this a capture? orig_village_owner = village_owner(final_loc); if ( orig_village_owner != current_side_-1 ) { // Captured. Zap movement and take over the village. move_it_->set_movement(0, true); event_mutated_ |= get_village(final_loc, current_side_, &action_time_bonus); post_wml(); } } } // Finally, the moveto event. event_mutated_ |= game_events::fire("moveto", final_loc, *begin_); post_wml(); // Record keeping. if ( spectator_ ) spectator_->set_unit(move_it_); if ( undo_stack ) { const bool mover_valid = move_it_.valid(); if ( mover_valid ) { // MP_COUNTDOWN: added param undo_stack->add_move( *move_it_, begin_, real_end_, orig_moves_, action_time_bonus, orig_village_owner, orig_dir_); } if ( !mover_valid || undo_blocked() || (resources::whiteboard->is_active() && resources::whiteboard->should_clear_undo()) ) { undo_stack->clear(); } } // Update the screen. resources::screen->redraw_minimap(); resources::screen->draw(); }