Beispiel #1
0
sanguis::server::weapons::attack_result
sanguis::server::weapons::spawn::do_attack(
	sanguis::server::weapons::attack const &_attack
)
{
	return
		!sanguis::creator::tile_is_visible(
			_attack.environment().grid(),
			sanguis::server::world::center_to_grid_pos(
				sanguis::server::center{
					_attack.target().get()
				}
			),
			sanguis::server::world::center_to_grid_pos(
				this->owner().center()
			)
		)
		?
			sanguis::server::weapons::attack_result::failure
		:
			fcppt::optional::maybe(
				this->do_spawn(
					_attack,
					spawn_weapon_
				),
				[]{
					return
						sanguis::server::weapons::attack_result::failure;
				},
				[
					this
				](
					fcppt::reference<
						sanguis::server::entities::base
					> const _inserted
				)
				{
					this->kill_spawned();

					spawned_ =
						dynamic_cast<
							sanguis::server::entities::ifaces::with_links &
						>(
							_inserted.get()
						).link();

					return
						sanguis::server::weapons::attack_result::success;
				}
			)
		;
}
Beispiel #2
0
sanguis::server::weapons::attack_result
sanguis::server::weapons::monster_spawner::do_attack(
	sanguis::server::weapons::attack const &_attack
)
{
	return
		sanguis::server::weapons::insert_to_attack_result(
			_attack.environment().insert(
				sanguis::server::entities::enemies::create(
					this->random_generator(),
					common_parameters_,
					fcppt::random::distribution::make_basic(
						fcppt::random::distribution::parameters::make_uniform_enum<
							sanguis::creator::enemy_type
						>()
					)(
						this->random_generator()
					),
					sanguis::creator::enemy_kind::normal,
					_attack.environment().difficulty(),
					_attack.environment().load_context(),
					sanguis::server::entities::spawn_owner(
						sanguis::server::entities::auto_weak_link()
					),
					sanguis::server::entities::enemies::special_chance(
						1.f
					)
				),
				sanguis::server::entities::insert_parameters(
					sanguis::server::center(
						_attack.target().get()
					),
					_attack.angle()
				)
			)
		);
}
Beispiel #3
0
sanguis::server::weapons::attack_result
sanguis::server::weapons::shotgun::do_attack(
	sanguis::server::weapons::attack const &_attack
)
{
	typedef fcppt::random::distribution::basic<
		fcppt::random::distribution::parameters::normal<
			sanguis::server::space_unit
		>
	> angle_distribution;

	sanguis::random_variate<
		angle_distribution
	> angle_rng(
		this->random_generator(),
		angle_distribution(
			angle_distribution::param_type::mean(
				_attack.angle().get()
			),
			angle_distribution::param_type::stddev(
				spread_radius_.value().get()
			)
		)
	);

	fcppt::algorithm::repeat(
		shells_.get(),
		[
			&angle_rng,
			&_attack,
			this
		]()
		{
			sanguis::server::angle const angle(
				angle_rng()
			);

			sanguis::server::environment::insert_no_result(
				_attack.environment(),
				fcppt::unique_ptr_to_base<
					sanguis::server::entities::with_id
				>(
					fcppt::make_unique_ptr<
						sanguis::server::entities::projectiles::simple_bullet
					>(
						_attack.environment().load_context(),
						this->owner().team(),
						damage_.value(),
						sanguis::server::entities::modify_damages(
							this->owner(),
							sanguis::server::damage::make_array({
								sanguis::server::damage::piercing =
									sanguis::server::damage::full
							})
						),
						sanguis::server::direction(
							angle.get()
						)
					)
				),
				sanguis::server::entities::insert_parameters(
					this->owner().center(),
					angle
				)
			);
		}
	);

	return
		sanguis::server::weapons::attack_result::success;
}