Merge PoisonedByTiberium and DamagedWithoutFoundations
into DamagedByTerrain.
This commit is contained in:
@@ -78,7 +78,6 @@
|
||||
<Compile Include="CncLoadScreen.cs" />
|
||||
<Compile Include="Traits\AttackPopupTurreted.cs" />
|
||||
<Compile Include="Traits\Buildings\ProductionAirdrop.cs" />
|
||||
<Compile Include="Traits\PoisonedByTiberium.cs" />
|
||||
<Compile Include="Traits\Render\WithGunboatBody.cs" />
|
||||
<Compile Include="Traits\Render\WithCargo.cs" />
|
||||
<Compile Include="Traits\Render\WithDeliveryAnimation.cs" />
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
class PoisonedByTiberiumInfo : UpgradableTraitInfo, IRulesetLoaded
|
||||
{
|
||||
[WeaponReference] public readonly string Weapon = "Tiberium";
|
||||
public readonly HashSet<string> Resources = new HashSet<string> { "Tiberium", "BlueTiberium" };
|
||||
|
||||
public WeaponInfo WeaponInfo { get; private set; }
|
||||
|
||||
public override object Create(ActorInitializer init) { return new PoisonedByTiberium(init, this); }
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai) { WeaponInfo = rules.Weapons[Weapon.ToLowerInvariant()]; }
|
||||
}
|
||||
|
||||
class PoisonedByTiberium : UpgradableTrait<PoisonedByTiberiumInfo>, ITick, ISync
|
||||
{
|
||||
readonly ResourceLayer rl;
|
||||
[Sync] int poisonTicks;
|
||||
|
||||
public PoisonedByTiberium(ActorInitializer init, PoisonedByTiberiumInfo info)
|
||||
: base(info)
|
||||
{
|
||||
rl = init.Self.World.WorldActor.Trait<ResourceLayer>();
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (IsTraitDisabled || --poisonTicks > 0)
|
||||
return;
|
||||
|
||||
// Prevents harming infantry in cargo.
|
||||
if (!self.IsInWorld)
|
||||
return;
|
||||
|
||||
var r = rl.GetResource(self.Location);
|
||||
if (r == null || !Info.Resources.Contains(r.Info.Name))
|
||||
return;
|
||||
|
||||
Info.WeaponInfo.Impact(Target.FromActor(self), self.World.WorldActor, Enumerable.Empty<int>());
|
||||
poisonTicks = Info.WeaponInfo.ReloadDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,6 +325,7 @@
|
||||
<Compile Include="Traits\CustomBuildTimeValue.cs" />
|
||||
<Compile Include="Traits\CustomSellValue.cs" />
|
||||
<Compile Include="Traits\CustomSelectionSize.cs" />
|
||||
<Compile Include="Traits\DamagedByTerrain.cs" />
|
||||
<Compile Include="Traits\Demolishable.cs" />
|
||||
<Compile Include="Traits\Demolition.cs" />
|
||||
<Compile Include="Traits\DetectCloaked.cs" />
|
||||
|
||||
90
OpenRA.Mods.Common/Traits/DamagedByTerrain.cs
Normal file
90
OpenRA.Mods.Common/Traits/DamagedByTerrain.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("This actor receives damage from the given weapon when on the specified terrain type.")]
|
||||
class DamagedByTerrainInfo : UpgradableTraitInfo, IRulesetLoaded, Requires<HealthInfo>
|
||||
{
|
||||
[Desc("The weapon which is used to damage the actor.")]
|
||||
[WeaponReference, FieldLoader.Require] public readonly string Weapon;
|
||||
|
||||
[Desc("Terrain types where the actor will take damage.")]
|
||||
[FieldLoader.Require] public readonly string[] Terrain = { };
|
||||
|
||||
[Desc("Percentage health below which the actor will not receive further damage.")]
|
||||
public readonly int DamageThreshold = 0;
|
||||
|
||||
[Desc("Inflict damage down to the DamageThreshold when the actor gets created on damaging terrain.")]
|
||||
public readonly bool StartOnThreshold = false;
|
||||
|
||||
public WeaponInfo WeaponInfo { get; private set; }
|
||||
|
||||
public override object Create(ActorInitializer init) { return new DamagedByTerrain(init.Self, this); }
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai) { WeaponInfo = rules.Weapons[Weapon.ToLowerInvariant()]; }
|
||||
}
|
||||
|
||||
class DamagedByTerrain : UpgradableTrait<DamagedByTerrainInfo>, ITick, ISync, INotifyAddedToWorld
|
||||
{
|
||||
readonly Health health;
|
||||
|
||||
[Sync] int damageTicks;
|
||||
[Sync] int damageThreshold;
|
||||
|
||||
public DamagedByTerrain(Actor self, DamagedByTerrainInfo info) : base(info)
|
||||
{
|
||||
health = self.Trait<Health>();
|
||||
}
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
{
|
||||
if (!Info.StartOnThreshold)
|
||||
return;
|
||||
|
||||
var safeTiles = 0;
|
||||
var totalTiles = 0;
|
||||
foreach (var kv in self.OccupiesSpace.OccupiedCells())
|
||||
{
|
||||
totalTiles++;
|
||||
if (!Info.Terrain.Contains(self.World.Map.GetTerrainInfo(kv.First).Type))
|
||||
safeTiles++;
|
||||
}
|
||||
|
||||
damageThreshold = (Info.DamageThreshold * health.MaxHP + (100 - Info.DamageThreshold) * safeTiles * health.MaxHP / totalTiles) / 100;
|
||||
|
||||
// Actors start with maximum damage applied
|
||||
var delta = health.HP - damageThreshold;
|
||||
if (delta > 0)
|
||||
health.InflictDamage(self, self.World.WorldActor, delta, null, false);
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (IsTraitDisabled || health.HP <= damageThreshold || --damageTicks > 0)
|
||||
return;
|
||||
|
||||
// Prevents harming cargo.
|
||||
if (!self.IsInWorld)
|
||||
return;
|
||||
|
||||
var t = self.World.Map.GetTerrainInfo(self.Location);
|
||||
if (!Info.Terrain.Contains(t.Type))
|
||||
return;
|
||||
|
||||
Info.WeaponInfo.Impact(Target.FromActor(self), self.World.WorldActor, Enumerable.Empty<int>());
|
||||
damageTicks = Info.WeaponInfo.ReloadDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,6 +222,40 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
}
|
||||
|
||||
if (engineVersion < 20160704)
|
||||
{
|
||||
if (node.Key.Contains("PoisonedByTiberium"))
|
||||
{
|
||||
node.Key = node.Key.Replace("PoisonedByTiberium", "DamagedByTerrain");
|
||||
if (!node.Key.StartsWith("-"))
|
||||
{
|
||||
if (node.Value.Nodes.Any(a => a.Key == "Resources"))
|
||||
node.Value.Nodes.Where(n => n.Key == "Resources").Do(n => n.Key = "Terrain");
|
||||
else
|
||||
node.Value.Nodes.Add(new MiniYamlNode("Terrain", new MiniYaml("Tiberium, BlueTiberium")));
|
||||
|
||||
if (!node.Value.Nodes.Any(a => a.Key == "Weapon"))
|
||||
node.Value.Nodes.Add(new MiniYamlNode("Weapon", new MiniYaml("Tiberium")));
|
||||
}
|
||||
}
|
||||
|
||||
if (node.Key.Contains("DamagedWithoutFoundation"))
|
||||
{
|
||||
node.Key = node.Key.Replace("DamagedWithoutFoundation", "DamagedByTerrain");
|
||||
if (!node.Key.StartsWith("-"))
|
||||
{
|
||||
if (!node.Value.Nodes.Any(a => a.Key == "Weapon"))
|
||||
node.Value.Nodes.Add(new MiniYamlNode("Weapon", new MiniYaml("weathering")));
|
||||
|
||||
Console.WriteLine("SafeTerrain isn't converted. Setup an inverted check using Terrain.");
|
||||
|
||||
node.Value.Nodes.Add(new MiniYamlNode("StartOnThreshold", new MiniYaml("true")));
|
||||
if (!node.Value.Nodes.Any(a => a.Key == "DamageThreshold"))
|
||||
node.Value.Nodes.Add(new MiniYamlNode("DamageThreshold", new MiniYaml("50")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
<Compile Include="Activities\SwallowActor.cs" />
|
||||
<Compile Include="SpriteLoaders\R8Loader.cs" />
|
||||
<Compile Include="Traits\AttackSwallow.cs" />
|
||||
<Compile Include="Traits\Buildings\DamagedWithoutFoundation.cs" />
|
||||
<Compile Include="Traits\Buildings\LaysTerrain.cs" />
|
||||
<Compile Include="Traits\Player\HarvesterInsurance.cs" />
|
||||
<Compile Include="Traits\Render\WithCrumbleOverlay.cs" />
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.D2k.Traits
|
||||
{
|
||||
[Desc("Reduces health points over time when the actor is placed on unsafe terrain.")]
|
||||
class DamagedWithoutFoundationInfo : ITraitInfo, IRulesetLoaded, Requires<HealthInfo>
|
||||
{
|
||||
[WeaponReference, Desc("The weapon to use for causing damage.")]
|
||||
public readonly string Weapon = "weathering";
|
||||
|
||||
[Desc("Terrain types on which no damage is caused.")]
|
||||
public readonly HashSet<string> SafeTerrain = new HashSet<string> { "Concrete" };
|
||||
|
||||
[Desc("The percentage of health the actor should keep.")]
|
||||
public readonly int DamageThreshold = 50;
|
||||
|
||||
public WeaponInfo WeaponInfo { get; private set; }
|
||||
|
||||
public object Create(ActorInitializer init) { return new DamagedWithoutFoundation(init.Self, this); }
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai) { WeaponInfo = rules.Weapons[Weapon.ToLowerInvariant()]; }
|
||||
}
|
||||
|
||||
class DamagedWithoutFoundation : ITick, ISync, INotifyAddedToWorld
|
||||
{
|
||||
readonly DamagedWithoutFoundationInfo info;
|
||||
readonly Health health;
|
||||
|
||||
[Sync] int damageThreshold = 100;
|
||||
[Sync] int damageTicks;
|
||||
|
||||
public DamagedWithoutFoundation(Actor self, DamagedWithoutFoundationInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
health = self.Trait<Health>();
|
||||
}
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
{
|
||||
var safeTiles = 0;
|
||||
var totalTiles = 0;
|
||||
foreach (var kv in self.OccupiesSpace.OccupiedCells())
|
||||
{
|
||||
totalTiles++;
|
||||
if (info.SafeTerrain.Contains(self.World.Map.GetTerrainInfo(kv.First).Type))
|
||||
safeTiles++;
|
||||
}
|
||||
|
||||
if (totalTiles > 0)
|
||||
damageThreshold = (info.DamageThreshold * health.MaxHP + (100 - info.DamageThreshold) * safeTiles * health.MaxHP / totalTiles) / 100;
|
||||
else
|
||||
damageThreshold = health.HP;
|
||||
|
||||
// Actors start with maximum damage applied
|
||||
var delta = health.HP - damageThreshold;
|
||||
if (delta > 0)
|
||||
health.InflictDamage(self, self.World.WorldActor, delta, null, false);
|
||||
|
||||
damageTicks = info.WeaponInfo.ReloadDelay;
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (health.HP <= damageThreshold || --damageTicks > 0)
|
||||
return;
|
||||
|
||||
info.WeaponInfo.Impact(Target.FromActor(self), self.World.WorldActor, Enumerable.Empty<int>());
|
||||
damageTicks = info.WeaponInfo.ReloadDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,9 +210,11 @@
|
||||
Passenger:
|
||||
CargoType: Infantry
|
||||
HiddenUnderFog:
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
UpgradeTypes: hazmatsuits
|
||||
UpgradeMaxEnabledLevel: 0
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Weapon: Tiberium
|
||||
GlobalUpgradable@BIO:
|
||||
Upgrades: hazmatsuits
|
||||
Prerequisites: bio
|
||||
@@ -416,8 +418,9 @@
|
||||
Guard:
|
||||
Voice: Move
|
||||
Guardable:
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: Heal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Voiced:
|
||||
VoiceSet: DinoVoice
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ E5:
|
||||
MuzzleSequence: muzzle
|
||||
AttackFrontal:
|
||||
WithMuzzleOverlay:
|
||||
-PoisonedByTiberium:
|
||||
-DamagedByTerrain:
|
||||
WithInfantryBody:
|
||||
AttackSequence: shoot
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ sietch:
|
||||
Type: wood
|
||||
RevealsShroud:
|
||||
Range: 10c0
|
||||
-DamagedWithoutFoundation:
|
||||
-DamagedByTerrain:
|
||||
-GivesBuildableArea:
|
||||
-Sellable:
|
||||
-Capturable:
|
||||
|
||||
@@ -277,7 +277,11 @@
|
||||
Range: 3c0
|
||||
WithCrumbleOverlay:
|
||||
Demolishable:
|
||||
DamagedWithoutFoundation:
|
||||
DamagedByTerrain:
|
||||
Weapon: weathering
|
||||
Terrain: Rock
|
||||
DamageThreshold: 50
|
||||
StartOnThreshold: true
|
||||
ThrowsShrapnel:
|
||||
Weapons: Debris, Debris2, Debris3, Debris4
|
||||
Pieces: 2, 5
|
||||
|
||||
@@ -43,7 +43,7 @@ concreteb:
|
||||
|
||||
construction_yard:
|
||||
Inherits: ^Building
|
||||
-DamagedWithoutFoundation:
|
||||
-DamagedByTerrain:
|
||||
Building:
|
||||
Footprint: xxx xxx
|
||||
Dimensions: 3,2
|
||||
|
||||
@@ -35,8 +35,9 @@ UMAGON:
|
||||
Speed: 71
|
||||
Health:
|
||||
HP: 150
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Passenger:
|
||||
RevealsShroud:
|
||||
Range: 7c0
|
||||
@@ -90,8 +91,9 @@ MUTANT:
|
||||
VoiceSet: Mutant
|
||||
Health:
|
||||
HP: 50
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Mobile:
|
||||
Speed: 56
|
||||
RevealsShroud:
|
||||
@@ -115,8 +117,9 @@ MWMN:
|
||||
VoiceSet: CivilianFemale
|
||||
Health:
|
||||
HP: 50
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Mobile:
|
||||
Speed: 56
|
||||
RevealsShroud:
|
||||
@@ -140,8 +143,9 @@ MUTANT3:
|
||||
VoiceSet: Mutant
|
||||
Health:
|
||||
HP: 50
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Mobile:
|
||||
Speed: 56
|
||||
RevealsShroud:
|
||||
@@ -165,8 +169,9 @@ TRATOS:
|
||||
VoiceSet: Tratos
|
||||
Health:
|
||||
HP: 200
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Mobile:
|
||||
Speed: 71
|
||||
RevealsShroud:
|
||||
@@ -220,8 +225,9 @@ DOGGIE:
|
||||
HP: 250
|
||||
Shape: Circle
|
||||
Radius: 213
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Valued:
|
||||
Cost: 100
|
||||
Armor:
|
||||
|
||||
@@ -282,7 +282,9 @@
|
||||
Voice: Move
|
||||
HiddenUnderFog:
|
||||
ActorLostNotification:
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Weapon: Tiberium
|
||||
Guard:
|
||||
Voice: Move
|
||||
Guardable:
|
||||
@@ -381,8 +383,9 @@
|
||||
RevealsShroud:
|
||||
Range: 4c0
|
||||
MustBeDestroyed:
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
WithPermanentInjury:
|
||||
WithInfantryBody:
|
||||
AttackSequence: attack
|
||||
@@ -463,9 +466,9 @@
|
||||
Weapons: SmallDebris
|
||||
Pieces: 3, 7
|
||||
Range: 2c0, 5c0
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: Veins
|
||||
Resources: Veins
|
||||
Terrain: Veins
|
||||
UpgradeOnDamage@DAMAGED:
|
||||
Upgrades: damagedspeed
|
||||
ValidDamageStates: Heavy
|
||||
@@ -631,8 +634,9 @@
|
||||
TargetTypes: Ground, Creep
|
||||
AttackMove:
|
||||
HiddenUnderFog:
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Guardable:
|
||||
WithSpriteBody:
|
||||
|
||||
|
||||
@@ -113,8 +113,9 @@ GHOST:
|
||||
Speed: 56
|
||||
Health:
|
||||
HP: 200
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Passenger:
|
||||
RevealsShroud:
|
||||
Range: 6c0
|
||||
|
||||
@@ -93,7 +93,7 @@ HVR:
|
||||
TrailWhileStationary: True
|
||||
StationaryInterval: 18
|
||||
MovingInterval: 6
|
||||
-PoisonedByTiberium:
|
||||
-DamagedByTerrain:
|
||||
|
||||
SMECH:
|
||||
Inherits: ^Vehicle
|
||||
@@ -132,7 +132,7 @@ SMECH:
|
||||
MoveSequence: run
|
||||
Selectable:
|
||||
Bounds: 20, 32, 0, -8
|
||||
-PoisonedByTiberium:
|
||||
-DamagedByTerrain:
|
||||
|
||||
MMCH:
|
||||
Inherits: ^Tank
|
||||
|
||||
@@ -109,8 +109,9 @@ MHIJACK:
|
||||
VoiceSet: Hijacker
|
||||
Health:
|
||||
HP: 300
|
||||
PoisonedByTiberium:
|
||||
DamagedByTerrain:
|
||||
Weapon: TiberiumHeal
|
||||
Terrain: Tiberium, BlueTiberium
|
||||
Mobile:
|
||||
Speed: 99
|
||||
-Crushable:
|
||||
|
||||
@@ -27,7 +27,7 @@ BGGY:
|
||||
Voice: Attack
|
||||
AutoTarget:
|
||||
WithMuzzleOverlay:
|
||||
-PoisonedByTiberium:
|
||||
-DamagedByTerrain:
|
||||
|
||||
BIKE:
|
||||
Inherits: ^VoxelVehicle
|
||||
@@ -257,7 +257,7 @@ WEED:
|
||||
-WithVoxelBody:
|
||||
WithVoxelUnloadBody:
|
||||
-GainsExperience:
|
||||
-PoisonedByTiberium:
|
||||
-DamagedByTerrain:
|
||||
|
||||
SAPC:
|
||||
Inherits: ^VoxelTank
|
||||
|
||||
@@ -96,7 +96,7 @@ HARV:
|
||||
FactionImages:
|
||||
gdi: harv.gdi
|
||||
nod: harv.nod
|
||||
-PoisonedByTiberium:
|
||||
-DamagedByTerrain:
|
||||
|
||||
LPST:
|
||||
Inherits: ^VoxelTank
|
||||
|
||||
Reference in New Issue
Block a user