Migrate EmitInfantryOnSell ValuePercent and MinHpPercent to int percentages

Additionally, MinHpPercent should now actually have the desired effect (previously there was not logic attached).
This commit is contained in:
reaperrr
2016-03-24 14:06:42 +01:00
parent 3a97757bfa
commit 82f23210d9
2 changed files with 36 additions and 4 deletions

View File

@@ -19,8 +19,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Spawn new actors when sold.")]
public class EmitInfantryOnSellInfo : ITraitInfo
{
public readonly float ValuePercent = 40;
public readonly float MinHpPercent = 30;
public readonly int ValuePercent = 40;
public readonly int MinHpPercent = 30;
[ActorReference]
[Desc("Be sure to use lowercase. Default value is \"e1\".")]
@@ -59,8 +59,12 @@ namespace OpenRA.Mods.Common.Traits
var health = self.TraitOrDefault<Health>();
var dudesValue = info.ValuePercent * cost;
if (health != null)
dudesValue = dudesValue * health.HP / health.MaxHP;
dudesValue /= 100;
{
if (100 * health.HP >= info.MinHpPercent * health.MaxHP)
dudesValue = health.HP * dudesValue / health.MaxHP;
else
dudesValue = 0;
}
var eligibleLocations = FootprintUtils.Tiles(self).ToList();
var actorTypes = info.ActorTypes.Select(a => new { Name = a, Cost = self.World.Map.Rules.Actors[a].TraitInfo<ValuedInfo>().Cost }).ToList();