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
|
public class Repair : Activity
|
||||||
{
|
{
|
||||||
|
readonly RepairsUnitsInfo repairsUnits;
|
||||||
|
readonly Actor host;
|
||||||
int remainingTicks;
|
int remainingTicks;
|
||||||
Actor host;
|
|
||||||
Health health;
|
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)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
@@ -32,15 +38,23 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (health == null) return NextActivity;
|
if (health == null) return NextActivity;
|
||||||
|
|
||||||
if (health.DamageState == DamageState.Undamaged)
|
if (health.DamageState == DamageState.Undamaged)
|
||||||
|
{
|
||||||
|
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.FinishRepairingNotification, self.Owner.Country.Race);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
}
|
||||||
|
|
||||||
if (remainingTicks == 0)
|
if (remainingTicks == 0)
|
||||||
{
|
{
|
||||||
var repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
|
|
||||||
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||||
var hpToRepair = repairsUnits.HpPerStep;
|
var hpToRepair = repairsUnits.HpPerStep;
|
||||||
var cost = Math.Max(1, (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100));
|
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))
|
if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
|
||||||
{
|
{
|
||||||
remainingTicks = 1;
|
remainingTicks = 1;
|
||||||
|
|||||||
@@ -14,9 +14,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
public class RepairsUnitsInfo : TraitInfo<RepairsUnits>
|
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 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 { }
|
public class RepairsUnits { }
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ Speech:
|
|||||||
WormSign: WSIGN
|
WormSign: WSIGN
|
||||||
WormAttack: WATTK
|
WormAttack: WATTK
|
||||||
EnemyUnitsApproaching: ENEMY
|
EnemyUnitsApproaching: ENEMY
|
||||||
|
UnitRepaired: GANEW
|
||||||
|
|
||||||
Sounds:
|
Sounds:
|
||||||
DefaultVariant: .WAV
|
DefaultVariant: .WAV
|
||||||
|
|||||||
@@ -585,6 +585,7 @@ WALL:
|
|||||||
RepairsUnits:
|
RepairsUnits:
|
||||||
Interval: 15
|
Interval: 15
|
||||||
ValuePercentage: 50
|
ValuePercentage: 50
|
||||||
|
FinishRepairingNotification: UnitRepaired
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
RallyPoint: 1,3
|
RallyPoint: 1,3
|
||||||
ProvidesCustomPrerequisite:
|
ProvidesCustomPrerequisite:
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ SPEN:
|
|||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
-EmitInfantryOnSell:
|
-EmitInfantryOnSell:
|
||||||
RepairsUnits:
|
RepairsUnits:
|
||||||
|
FinishRepairingNotification: UnitRepaired
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
ProductionBar:
|
ProductionBar:
|
||||||
Power:
|
Power:
|
||||||
@@ -219,6 +220,7 @@ SYRD:
|
|||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
-EmitInfantryOnSell:
|
-EmitInfantryOnSell:
|
||||||
RepairsUnits:
|
RepairsUnits:
|
||||||
|
FinishRepairingNotification: UnitRepaired
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
ProductionBar:
|
ProductionBar:
|
||||||
Power:
|
Power:
|
||||||
@@ -1435,6 +1437,7 @@ FIX:
|
|||||||
RallyPoint:
|
RallyPoint:
|
||||||
RepairsUnits:
|
RepairsUnits:
|
||||||
Interval: 10
|
Interval: 10
|
||||||
|
FinishRepairingNotification: UnitRepaired
|
||||||
WithRepairAnimation:
|
WithRepairAnimation:
|
||||||
Power:
|
Power:
|
||||||
Amount: -30
|
Amount: -30
|
||||||
|
|||||||
Reference in New Issue
Block a user