Add DamageTypes to Kill() and make some traits use it.
This commit is contained in:
committed by
reaperrr
parent
b620e8107f
commit
5e7e3bb011
@@ -20,6 +20,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Does a suicide attack where it moves next to the target when used in combination with `Explodes`.")]
|
||||
class AttackSuicidesInfo : ConditionalTraitInfo, Requires<IMoveInfo>
|
||||
{
|
||||
[Desc("Types of damage that this trait causes to self while suiciding. Leave empty for no damage types.")]
|
||||
public readonly HashSet<string> DamageTypes = new HashSet<string>();
|
||||
|
||||
[VoiceReference] public readonly string Voice = "Action";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackSuicides(init.Self, this); }
|
||||
@@ -82,10 +85,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
self.QueueActivity(move.MoveToTarget(self, target));
|
||||
|
||||
self.QueueActivity(new CallFunc(() => self.Kill(self)));
|
||||
self.QueueActivity(new CallFunc(() => self.Kill(self, Info.DamageTypes)));
|
||||
}
|
||||
else if (order.OrderString == "Detonate")
|
||||
self.Kill(self);
|
||||
self.Kill(self, Info.DamageTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public WeaponInfo DemolishWeaponInfo { get; private set; }
|
||||
|
||||
[Desc("Types of damage that this bridge causes to units over/in path of it while being destroyed/repaired. Leave empty for no damage types.")]
|
||||
public readonly HashSet<string> DamageTypes = new HashSet<string>();
|
||||
|
||||
public object Create(ActorInitializer init) { return new Bridge(init.Self, this); }
|
||||
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
@@ -241,7 +244,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var c in footprint.Keys)
|
||||
foreach (var a in self.World.ActorMap.GetActorsAt(c))
|
||||
if (a.Info.HasTraitInfo<IPositionableInfo>() && !a.Trait<IPositionable>().CanEnterCell(c))
|
||||
a.Kill(self);
|
||||
a.Kill(self, info.DamageTypes);
|
||||
}
|
||||
|
||||
bool NeighbourIsDeadShore(Bridge neighbour)
|
||||
|
||||
@@ -30,6 +30,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public WeaponInfo DemolishWeaponInfo { get; private set; }
|
||||
|
||||
[Desc("Types of damage that this bridge causes to units over/in path of it while being destroyed/repaired. Leave empty for no damage types.")]
|
||||
public readonly HashSet<string> DamageTypes = new HashSet<string>();
|
||||
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
WeaponInfo weapon;
|
||||
@@ -95,7 +98,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var c in cells)
|
||||
foreach (var a in self.World.ActorMap.GetActorsAt(c))
|
||||
if (a.Info.HasTraitInfo<IPositionableInfo>() && !a.Trait<IPositionable>().CanEnterCell(c))
|
||||
a.Kill(self);
|
||||
a.Kill(self, Info.DamageTypes);
|
||||
}
|
||||
|
||||
void IBridgeSegment.Repair(Actor repairer)
|
||||
|
||||
@@ -57,7 +57,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
Game.Sound.Play(SoundType.World, Info.CrushSound, crusher.CenterPosition);
|
||||
|
||||
self.Kill(crusher);
|
||||
var crusherMobile = crusher.TraitOrDefault<Mobile>();
|
||||
self.Kill(crusher, crusherMobile != null ? crusherMobile.Info.CrushDamageTypes : new HashSet<string>());
|
||||
}
|
||||
|
||||
bool ICrushable.CrushableBy(Actor self, Actor crusher, HashSet<string> crushClasses)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -163,9 +164,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public void Kill(Actor self, Actor attacker)
|
||||
public void Kill(Actor self, Actor attacker, HashSet<string> damageTypes = null)
|
||||
{
|
||||
InflictDamage(self, attacker, new Damage(MaxHP), true);
|
||||
if (damageTypes == null)
|
||||
damageTypes = new HashSet<string>();
|
||||
|
||||
InflictDamage(self, attacker, new Damage(MaxHP, damageTypes), true);
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -21,6 +22,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("The amount of time (in ticks) before the actor dies. Two values indicate a range between which a random value is chosen.")]
|
||||
public readonly int[] Delay = { 0 };
|
||||
|
||||
[Desc("Types of damage that this trait causes. Leave empty for no damage types.")]
|
||||
public readonly HashSet<string> DamageTypes = new HashSet<string>();
|
||||
|
||||
[GrantedConditionReference]
|
||||
[Desc("The condition to grant moments before suiciding.")]
|
||||
public readonly string GrantsCondition = null;
|
||||
@@ -81,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (Info.RemoveInstead || !self.Info.HasTraitInfo<HealthInfo>())
|
||||
self.Dispose();
|
||||
else
|
||||
self.Kill(self);
|
||||
self.Kill(self, Info.DamageTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("e.g. crate, wall, infantry")]
|
||||
public readonly HashSet<string> Crushes = new HashSet<string>();
|
||||
|
||||
[Desc("Types of damage that are caused while crushing. Leave empty for no damage types.")]
|
||||
public readonly HashSet<string> CrushDamageTypes = new HashSet<string>();
|
||||
|
||||
public readonly int WaitAverage = 5;
|
||||
|
||||
public readonly int WaitSpread = 2;
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("If we land on invalid terrain for my actor type should we be killed?")]
|
||||
public readonly bool KilledOnImpassableTerrain = true;
|
||||
|
||||
[Desc("Types of damage that this trait causes to self when 'KilledOnImpassableTerrain' is true. Leave empty for no damage types.")]
|
||||
public readonly HashSet<string> DamageTypes = new HashSet<string>();
|
||||
|
||||
[Desc("Image where Ground/WaterCorpseSequence is looked up.")]
|
||||
public readonly string Image = "explosion";
|
||||
|
||||
@@ -101,7 +104,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (sequence != null && palette != null)
|
||||
self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(self.OccupiesSpace.CenterPosition, w, info.Image, sequence, palette)));
|
||||
|
||||
self.Kill(self);
|
||||
self.Kill(self, info.DamageTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,15 +219,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
break;
|
||||
|
||||
var actor = order.Target.Actor;
|
||||
var health = actor.TraitOrDefault<Health>();
|
||||
var args = order.TargetString.Split(' ');
|
||||
var damageTypes = new HashSet<string>();
|
||||
|
||||
foreach (var damageType in args)
|
||||
damageTypes.Add(damageType);
|
||||
|
||||
if (health != null)
|
||||
health.InflictDamage(actor, actor, new Damage(health.HP, damageTypes), true);
|
||||
actor.Kill(actor, damageTypes);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
[Desc("How much (raw) damage to deal.")]
|
||||
public readonly int Damage = 0;
|
||||
|
||||
[Desc("Types of damage that this warhead causes. Leave empty for no damage.")]
|
||||
[Desc("Types of damage that this warhead causes. Leave empty for no damage types.")]
|
||||
public readonly HashSet<string> DamageTypes = new HashSet<string>();
|
||||
|
||||
[Desc("Damage percentage versus each armortype.")]
|
||||
|
||||
Reference in New Issue
Block a user