New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement D2k Death Hand & TS Cluster Missile warheads #16363
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d9194d1
Add FireClusterWarhead
GraionDilach b3788a8
Add DetonationAltitude to NukePower
reaperrr f1d5372
Implement TS cluster missile warhead
reaperrr bb8cb16
Implement D2k DeathHand cluster logic
reaperrr 4c43db9
Fix launch delay and offset of TS ClusterMissile
reaperrr File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#region Copyright & License Information | ||
/* | ||
* Copyright 2007-2019 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.Common.Warheads | ||
{ | ||
public class FireClusterWarhead : Warhead, IRulesetLoaded<WeaponInfo> | ||
{ | ||
[WeaponReference, FieldLoader.Require] | ||
[Desc("Has to be defined in weapons.yaml as well.")] | ||
public readonly string Weapon = null; | ||
|
||
[Desc("Number of weapons fired at random 'x' cells. Negative values will result in a number equal to 'x' footprint cells fired.")] | ||
public readonly int RandomClusterCount = -1; | ||
|
||
[FieldLoader.Require] | ||
[Desc("Size of the cluster footprint")] | ||
public readonly CVec Dimensions = CVec.Zero; | ||
|
||
[FieldLoader.Require] | ||
[Desc("Cluster footprint. Cells marked as X will be attacked.", | ||
"Cells marked as x will be attacked randomly until RandomClusterCount is reached.")] | ||
public readonly string Footprint = string.Empty; | ||
|
||
WeaponInfo weapon; | ||
|
||
public void RulesetLoaded(Ruleset rules, WeaponInfo info) | ||
{ | ||
if (!rules.Weapons.TryGetValue(Weapon.ToLowerInvariant(), out weapon)) | ||
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(Weapon.ToLowerInvariant())); | ||
} | ||
|
||
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers) | ||
{ | ||
if (!target.IsValidFor(firedBy)) | ||
return; | ||
|
||
var map = firedBy.World.Map; | ||
var targetCell = map.CellContaining(target.CenterPosition); | ||
|
||
var targetCells = CellsMatching(targetCell, false); | ||
foreach (var c in targetCells) | ||
FireProjectileAtCell(map, firedBy, target, c, damageModifiers); | ||
|
||
if (RandomClusterCount != 0) | ||
{ | ||
var randomTargetCells = CellsMatching(targetCell, true); | ||
var clusterCount = RandomClusterCount < 0 ? randomTargetCells.Count() : RandomClusterCount; | ||
if (randomTargetCells.Any()) | ||
for (var i = 0; i < clusterCount; i++) | ||
FireProjectileAtCell(map, firedBy, target, randomTargetCells.Random(firedBy.World.SharedRandom), damageModifiers); | ||
} | ||
} | ||
|
||
void FireProjectileAtCell(Map map, Actor firedBy, Target target, CPos targetCell, IEnumerable<int> damageModifiers) | ||
{ | ||
var tc = Target.FromCell(firedBy.World, targetCell); | ||
|
||
if (!weapon.IsValidAgainst(tc, firedBy.World, firedBy)) | ||
return; | ||
|
||
var args = new ProjectileArgs | ||
{ | ||
Weapon = weapon, | ||
Facing = (map.CenterOfCell(targetCell) - target.CenterPosition).Yaw.Facing, | ||
|
||
DamageModifiers = damageModifiers.ToArray(), | ||
InaccuracyModifiers = new int[0], | ||
RangeModifiers = new int[0], | ||
|
||
Source = target.CenterPosition, | ||
CurrentSource = () => target.CenterPosition, | ||
SourceActor = firedBy, | ||
PassiveTarget = map.CenterOfCell(targetCell), | ||
GuidedTarget = tc | ||
}; | ||
|
||
if (args.Weapon.Projectile != null) | ||
{ | ||
var projectile = args.Weapon.Projectile.Create(args); | ||
if (projectile != null) | ||
firedBy.World.AddFrameEndTask(w => w.Add(projectile)); | ||
|
||
if (args.Weapon.Report != null && args.Weapon.Report.Any()) | ||
Game.Sound.Play(SoundType.World, args.Weapon.Report, firedBy.World, target.CenterPosition); | ||
} | ||
} | ||
|
||
IEnumerable<CPos> CellsMatching(CPos location, bool random) | ||
{ | ||
var cellType = !random ? 'X' : 'x'; | ||
var index = 0; | ||
var footprint = Footprint.Where(c => !char.IsWhiteSpace(c)).ToArray(); | ||
var x = location.X - (Dimensions.X - 1) / 2; | ||
var y = location.Y - (Dimensions.Y - 1) / 2; | ||
for (var j = 0; j < Dimensions.Y; j++) | ||
for (var i = 0; i < Dimensions.X; i++) | ||
if (footprint[index++] == cellType) | ||
yield return new CPos(x + i, y + j); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,7 +259,7 @@ missile2: | |
Facings: -32 | ||
ZOffset: 1023 | ||
|
||
atomic: | ||
deathhand: | ||
up: DATA.R8 | ||
Start: 2147 | ||
ZOffset: 1023 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean relative to the original game, or relative to common sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both. TS Cluster Missile was normally a guaranteed kill for at least up to Advanced Power Plants in the original, provided they were on the targeted cell.
Death Hand in the original had some inherent Missile inaccuracy, but when it hit something directly, it hit pretty hard.
Additionally, Ornithopters in our mod are more powerful than in the original, and actually feel a tiny bit more powerful than the DH even with this.
But to be honest, I'd prefer to leave any further D2k balance polishing to someone like @MustaphaTR, this was just to make the difference between the super weapons small enough that it doesn't make the DH a joke in comparison.