MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / launch_rocket

Method launch_rocket

battlecode-engine/src/world.rs:1965–1982  ·  view source on GitHub ↗

Launches the rocket into space, damaging the units adjacent to the takeoff location. NoSuchUnit - the rocket does not exist (inside the vision range). TeamNotAllowed - the rocket is not on the current player's team. SamePlanet - the rocket cannot fly to a location on the same planet. InappropriateUnitType - the unit is not a rocket. StructureNotYetBuilt - the rocket has not yet been completed. Ro

(&mut self, rocket_id: UnitID, destination: MapLocation)

Source from the content-addressed store, hash-verified

1963 /// * LocationOffMap - the given location is off the map.
1964 /// * LocationNotEmpty - the given location contains impassable terrain.
1965 pub fn launch_rocket(&mut self, rocket_id: UnitID, destination: MapLocation)
1966 -> Result<(), GameError> {
1967 self.ok_if_can_launch_rocket(rocket_id, destination)?;
1968 let takeoff_loc = self.my_unit(rocket_id)?.location().map_location()?;
1969 let blast_damage = self.my_unit(rocket_id)?.rocket_blast_damage()?;
1970 for dir in Direction::all() {
1971 self.damage_location(takeoff_loc.add(dir), blast_damage);
1972 }
1973 self.move_to_space(rocket_id);
1974 self.my_unit_mut(rocket_id)?.launch_rocket();
1975
1976 let landing_round = self.round + self.orbit.duration(self.round)
1977 - self.my_unit(rocket_id)?.rocket_travel_time_decrease().unwrap();
1978 self.my_team_mut().rocket_landings.add_landing(
1979 landing_round, RocketLanding::new(rocket_id, destination)
1980 );
1981 Ok(())
1982 }
1983
1984 /// Lands the rocket, damaging the units in adjacent squares. The rocket
1985 /// is destroyed if it lands on a factory, rocket, or impassable terrain.

Callers 2

applyMethod · 0.45
test_rocket_successFunction · 0.45

Calls 13

map_locationMethod · 0.80
locationMethod · 0.80
my_unitMethod · 0.80
rocket_blast_damageMethod · 0.80
damage_locationMethod · 0.80
move_to_spaceMethod · 0.80
my_unit_mutMethod · 0.80
durationMethod · 0.80
add_landingMethod · 0.80
my_team_mutMethod · 0.80

Tested by 1

test_rocket_successFunction · 0.36