forked from Mirrors/openclonk
Tweak sound making on Windmill
- Don't make sounds while the wheel is stopped. - Make less sounds while the wheel is turning fast. - Make less sounds overall.liquid_container
parent
931705d339
commit
f8e16686d8
|
@ -76,6 +76,7 @@ public func Wind2Turn()
|
|||
// Only produce power if fully constructed.
|
||||
if (GetCon() < 100)
|
||||
return;
|
||||
var current_wind = GetWeightedWind();
|
||||
// Determine the current power production.
|
||||
var power = 0;
|
||||
if (!wheel->Stuck() && !wheel->HasStopped())
|
||||
|
@ -83,6 +84,10 @@ public func Wind2Turn()
|
|||
// Produced power ranges from 0 to 80 in steps of 10.
|
||||
power = Abs(wheel->GetRDir(MinRevolutionTime() / 90));
|
||||
power = BoundBy((10 * power + 60) / 125 * 10, 0, 80);
|
||||
|
||||
// Make some sounds.
|
||||
if (Random(10 + Abs(current_wind)) < 5 && !Random(5))
|
||||
Sound(["Hits::Materials::Wood::WoodCreak?","Structures::HingeCreak?"][Random(2)], false, nil, nil, nil, 75);
|
||||
}
|
||||
// Update the power consumption if the produced power has changed.
|
||||
if (last_power != power)
|
||||
|
@ -93,11 +98,7 @@ public func Wind2Turn()
|
|||
RegisterPowerRequest(this->PowerNeed());
|
||||
}
|
||||
// Adjust the wheel speed.
|
||||
var current_wind = GetWeightedWind();
|
||||
wheel->SetRDir(current_wind * 90, MinRevolutionTime());
|
||||
// Make some sounds.
|
||||
if (Abs(current_wind) >= 10 && Random(15 - Abs(current_wind / 10)) < 5)
|
||||
Sound(["Hits::Materials::Wood::WoodCreak?","Structures::HingeCreak?"][Random(2)], false, nil, nil, nil, 75);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue