Add repairing and unit repaired sounds to fix
This commit is contained in:
@@ -17,11 +17,17 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
public class Repair : Activity
|
||||
{
|
||||
readonly RepairsUnitsInfo repairsUnits;
|
||||
readonly Actor host;
|
||||
int remainingTicks;
|
||||
Actor host;
|
||||
Health health;
|
||||
bool played = false;
|
||||
|
||||
public Repair(Actor host) { this.host = host; }
|
||||
public Repair(Actor host)
|
||||
{
|
||||
this.host = host;
|
||||
repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
@@ -32,15 +38,23 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (health == null) return NextActivity;
|
||||
|
||||
if (health.DamageState == DamageState.Undamaged)
|
||||
{
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.FinishRepairingNotification, self.Owner.Country.Race);
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
if (remainingTicks == 0)
|
||||
{
|
||||
var repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
|
||||
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
var hpToRepair = repairsUnits.HpPerStep;
|
||||
var cost = Math.Max(1, (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100));
|
||||
|
||||
if (!played)
|
||||
{
|
||||
played = true;
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.StartRepairingNotification, self.Owner.Country.Race);
|
||||
}
|
||||
|
||||
if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
|
||||
{
|
||||
remainingTicks = 1;
|
||||
|
||||
@@ -14,9 +14,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class RepairsUnitsInfo : TraitInfo<RepairsUnits>
|
||||
{
|
||||
public readonly int ValuePercentage = 20; // charge 20% of the unit value to fully repair
|
||||
[Desc("Cost in % of the unit value to fully repair the unit.")]
|
||||
public readonly int ValuePercentage = 20;
|
||||
public readonly int HpPerStep = 10;
|
||||
public readonly int Interval = 24; // Ticks
|
||||
|
||||
[Desc("Time (in ticks) between two repair steps.")]
|
||||
public readonly int Interval = 24;
|
||||
|
||||
[Desc("The sound played when starting to repair a unit.")]
|
||||
public readonly string StartRepairingNotification = "Repairing";
|
||||
|
||||
[Desc("The sound played when repairing a unit is done.")]
|
||||
public readonly string FinishRepairingNotification = null;
|
||||
}
|
||||
|
||||
public class RepairsUnits { }
|
||||
|
||||
@@ -34,6 +34,7 @@ Speech:
|
||||
WormSign: WSIGN
|
||||
WormAttack: WATTK
|
||||
EnemyUnitsApproaching: ENEMY
|
||||
UnitRepaired: GANEW
|
||||
|
||||
Sounds:
|
||||
DefaultVariant: .WAV
|
||||
|
||||
@@ -585,6 +585,7 @@ WALL:
|
||||
RepairsUnits:
|
||||
Interval: 15
|
||||
ValuePercentage: 50
|
||||
FinishRepairingNotification: UnitRepaired
|
||||
RallyPoint:
|
||||
RallyPoint: 1,3
|
||||
ProvidesCustomPrerequisite:
|
||||
|
||||
@@ -142,6 +142,7 @@ SPEN:
|
||||
PrimaryBuilding:
|
||||
-EmitInfantryOnSell:
|
||||
RepairsUnits:
|
||||
FinishRepairingNotification: UnitRepaired
|
||||
RallyPoint:
|
||||
ProductionBar:
|
||||
Power:
|
||||
@@ -219,6 +220,7 @@ SYRD:
|
||||
PrimaryBuilding:
|
||||
-EmitInfantryOnSell:
|
||||
RepairsUnits:
|
||||
FinishRepairingNotification: UnitRepaired
|
||||
RallyPoint:
|
||||
ProductionBar:
|
||||
Power:
|
||||
@@ -1435,6 +1437,7 @@ FIX:
|
||||
RallyPoint:
|
||||
RepairsUnits:
|
||||
Interval: 10
|
||||
FinishRepairingNotification: UnitRepaired
|
||||
WithRepairAnimation:
|
||||
Power:
|
||||
Amount: -30
|
||||
|
||||
Reference in New Issue
Block a user