diff --git a/resources/yaml/assault_rifle.yaml b/resources/yaml/assault_rifle.yaml index 459b705..3c41963 100644 --- a/resources/yaml/assault_rifle.yaml +++ b/resources/yaml/assault_rifle.yaml @@ -8,4 +8,5 @@ reload_time: 2000 automatic: true magazine_size: 30 max_total_ammo: 270 -spread: 2.0 \ No newline at end of file +spread: 2.0 +spread_moving: 5.0 \ No newline at end of file diff --git a/resources/yaml/hmg.yaml b/resources/yaml/hmg.yaml index 57a80d5..5394c6c 100644 --- a/resources/yaml/hmg.yaml +++ b/resources/yaml/hmg.yaml @@ -3,9 +3,10 @@ name: Machine Gun bullet: bullet.yaml projectile_speed: 1000 damage: 20 -fire_interval: 100 +fire_interval: 150 reload_time: 5000 automatic: true magazine_size: 60 max_total_ammo: 400 -spread: 5.0 \ No newline at end of file +spread: 5.0 +spread_moving: 15.0 \ No newline at end of file diff --git a/source/items/Weapon.cpp b/source/items/Weapon.cpp index 48148c8..338afba 100755 --- a/source/items/Weapon.cpp +++ b/source/items/Weapon.cpp @@ -30,7 +30,8 @@ Weapon::Weapon(World& world, Character& holder, const Yaml& config) : mPellets(config.get("pellets", 0)), mPelletSpread(config.get("pellet_spread", 0.0f)), mReloadSingle(config.get("reload_single", false)), - mSpread(config.get("spread", 0.0f)) { + mSpread(config.get("spread", 0.0f)), + mSpreadMoving(config.get("spread_moving", 0.0f)) { } /** @@ -135,7 +136,10 @@ Weapon::insertProjectile(float angle) { sf::Vector2f offset(0, - mHolder.getRadius()); thor::rotate(offset, thor::polarAngle(mHolder.getDirection())); - std::uniform_real_distribution distribution(- mSpread, mSpread); + float spread = (mHolder.getSpeed() == sf::Vector2f()) + ? mSpread + : mSpreadMoving; + std::uniform_real_distribution distribution(- spread, spread); angle += distribution(mGenerator); //float random = ((float) rand()) / (float) RAND_MAX; diff --git a/source/items/Weapon.h b/source/items/Weapon.h index 2988b6a..b9737c1 100755 --- a/source/items/Weapon.h +++ b/source/items/Weapon.h @@ -58,6 +58,7 @@ private: const float mPelletSpread; const bool mReloadSingle; const float mSpread; + const float mSpreadMoving; std::default_random_engine mGenerator; };