Fix DamageModifiers
This commit is contained in:
@@ -205,7 +205,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface IRenderModifier { IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r); }
|
public interface IRenderModifier { IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r); }
|
||||||
public interface IDamageModifier { int GetDamageModifier(Actor attacker, DamageWarhead warhead); }
|
public interface IDamageModifier { int GetDamageModifier(Actor attacker, IWarhead warhead); }
|
||||||
public interface ISpeedModifier { int GetSpeedModifier(); }
|
public interface ISpeedModifier { int GetSpeedModifier(); }
|
||||||
public interface IFirepowerModifier { int GetFirepowerModifier(); }
|
public interface IFirepowerModifier { int GetFirepowerModifier(); }
|
||||||
public interface IReloadModifier { int GetReloadModifier(); }
|
public interface IReloadModifier { int GetReloadModifier(); }
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -101,7 +100,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
public int GetDamageModifier(Actor attacker, IWarhead warhead)
|
||||||
{
|
{
|
||||||
return state == PopupState.Closed ? info.ClosedDamageMultiplier : 100;
|
return state == PopupState.Closed ? info.ClosedDamageMultiplier : 100;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.Mods.Common.Warheads;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -64,7 +64,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.Damage <= 0 || e.Warhead == null || !e.Warhead.DamageTypes.Any(x => info.DamageTriggers.Contains(x)))
|
var warhead = e.Warhead as DamageWarhead;
|
||||||
|
if (e.Damage <= 0 || warhead == null || !warhead.DamageTypes.Any(x => info.DamageTriggers.Contains(x)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!IsProne)
|
if (!IsProne)
|
||||||
@@ -81,12 +82,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
localOffset = WVec.Zero;
|
localOffset = WVec.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
public int GetDamageModifier(Actor attacker, IWarhead warhead)
|
||||||
{
|
{
|
||||||
if (!IsProne)
|
if (!IsProne)
|
||||||
return 100;
|
return 100;
|
||||||
|
|
||||||
var modifierPercentages = info.DamageModifiers.Where(x => warhead.DamageTypes.Contains(x.Key)).Select(x => x.Value);
|
var damageWh = warhead as DamageWarhead;
|
||||||
|
if (damageWh == null)
|
||||||
|
return 100;
|
||||||
|
|
||||||
|
var modifierPercentages = info.DamageModifiers.Where(x => damageWh.DamageTypes.Contains(x.Key)).Select(x => x.Value);
|
||||||
return Util.ApplyPercentageModifiers(100, modifierPercentages);
|
return Util.ApplyPercentageModifiers(100, modifierPercentages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.Mods.Common.Warheads;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -42,6 +41,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public class TerrainModifiesDamage : IDamageModifier
|
public class TerrainModifiesDamage : IDamageModifier
|
||||||
{
|
{
|
||||||
|
const int FullDamage = 100;
|
||||||
|
|
||||||
public readonly TerrainModifiesDamageInfo Info;
|
public readonly TerrainModifiesDamageInfo Info;
|
||||||
|
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
@@ -52,11 +53,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
this.self = self;
|
this.self = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
public int GetDamageModifier(Actor attacker, IWarhead warhead)
|
||||||
{
|
{
|
||||||
var percent = 100;
|
var damageWh = warhead as DamageWarhead;
|
||||||
if (attacker.Owner.IsAlliedWith(self.Owner) && (warhead != null && warhead.Damage < 0) && !Info.ModifyHealing)
|
if (attacker.Owner.IsAlliedWith(self.Owner) && (damageWh != null && damageWh.Damage < 0) && !Info.ModifyHealing)
|
||||||
return percent;
|
return FullDamage;
|
||||||
|
|
||||||
var world = self.World;
|
var world = self.World;
|
||||||
var map = world.Map;
|
var map = world.Map;
|
||||||
@@ -67,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var terrainType = tileSet[tileSet.GetTerrainIndex(tiles[pos])].Type;
|
var terrainType = tileSet[tileSet.GetTerrainIndex(tiles[pos])].Type;
|
||||||
|
|
||||||
if (!Info.TerrainModifier.ContainsKey(terrainType))
|
if (!Info.TerrainModifier.ContainsKey(terrainType))
|
||||||
return percent;
|
return FullDamage;
|
||||||
|
|
||||||
return Info.TerrainModifier[terrainType];
|
return Info.TerrainModifier[terrainType];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.GameRules;
|
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -18,6 +17,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
class Invulnerable : IDamageModifier
|
class Invulnerable : IDamageModifier
|
||||||
{
|
{
|
||||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead) { return 0; }
|
public int GetDamageModifier(Actor attacker, IWarhead warhead) { return 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
inaccuracyLevel = newLevel.Clamp(0, info.InaccuracyModifier.Length);
|
inaccuracyLevel = newLevel.Clamp(0, info.InaccuracyModifier.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
public int GetDamageModifier(Actor attacker, IWarhead warhead)
|
||||||
{
|
{
|
||||||
return damageLevel > 0 ? info.DamageModifier[damageLevel - 1] : 100;
|
return damageLevel > 0 ? info.DamageModifier[damageLevel - 1] : 100;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.GameRules;
|
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public InvulnerabilityUpgrade(InvulnerabilityUpgradeInfo info)
|
public InvulnerabilityUpgrade(InvulnerabilityUpgradeInfo info)
|
||||||
: base(info) { }
|
: base(info) { }
|
||||||
|
|
||||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
public int GetDamageModifier(Actor attacker, IWarhead warhead)
|
||||||
{
|
{
|
||||||
return IsTraitDisabled ? 100 : 0;
|
return IsTraitDisabled ? 100 : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user