added custom sell value trait. this fixes sell/repair on FACT, and buy/sell exploit on PROC

This commit is contained in:
Chris Forbes
2010-02-11 11:56:07 +13:00
parent f2133458ee
commit eeaf51a859
6 changed files with 31 additions and 3 deletions

View File

@@ -96,8 +96,10 @@ namespace OpenRa.Traits
if (remainingTicks == 0)
{
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
var buildingValue = csv != null ? csv.Value : self.Info.Traits.Get<BuildableInfo>().Cost;
var maxHP = self.Info.Traits.Get<BuildingInfo>().HP;
var costPerHp = (Rules.General.URepairPercent * self.Info.Traits.Get<BuildableInfo>().Cost) / maxHP;
var costPerHp = (Rules.General.URepairPercent * buildingValue) / maxHP;
var hpToRepair = Math.Min(Rules.General.URepairStep, maxHP - self.Health);
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
if (!self.Owner.TakeCash(cost))