ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

The YR Combat System

From ModEnc
Revision as of 00:20, 27 November 2009 by SomeGuy (talk | contribs) (Created page with '=Abstract:= The purpose of this presentation is to illustrate the many myriad approaches, tags, and conditions describing what attacks what in Command and Conquer: Yuri's Reveng…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Abstract:

The purpose of this presentation is to illustrate the many myriad approaches, tags, and conditions describing what attacks what in Command and Conquer: Yuri's Revenge. Detailed inside include technical details, various example situations, and more . This presentation is to be taken as a guide and manual rather than a step by step tutorial. If there is anything you as a modder are unfamiliar with or don't understand in here, there are guides and aides available for modding CnC on the Internet to help you become familiar with what is being discussed.


Introduction:

The YR Combat System is prior to Generals the single most complicated fighting system devised for the Command and Conquer real time strategy series. It encompasses many facets and abilities not featured in prior installments. Some of the older portions no longer work as they are traditionally known and many of the newer functions are exclusive to this or Red Alert 2 proper.

The following is a list of items being discussed for how the system works:

1: Primary vs Secondary weapons
2: Warheads
3: Projectiles
4: Land Targeting
5: Naval Targeting
6: Special cases
7: Limitations/Bugs/Side Effects
8: Discussion

Let's begin shall we?


Part I: Primary vs Secondary Weapons

In all CnC games since Red Alert 1 the most basic of listing for where to list weapons on a unit is the Primary and Secondary tags. While in earlier installments, both were presented almost identically they have several differences in the RA2/YR system.

First off, unless the weapon itself is incapable of attacking land for whatever reason (more below) the Primary will *always* attack the terrain tiles first. The Secondaryif not explicitly allowed to do so will be incapable. The Secondary weapon is more a fallback measure for objects the Primary cannot attack.

It should be noted that several effects depend on correct ordering of Primary/Secondary in your code. For example a Secondary weapon that is anti-air (see Projectile Projectiles section) will not gain any bonus from AirRangeBonus even if the bonus is defined in your code properly. That tag explicitly goes towards Primary weapons. More effects of this nature are described in the Special cases section below.


Part II: Warheads

Ahh Warheads, the part that actually makes things go boom in CnC. This element is by far the single strongest "general" tag applicable to any weapon. The following goes into great detail how Warheads affect combat.

In Combat the Warhead is checked as one of the first things (the others before it being the projectile settings for AA/AG/AN and LandTargeting/NavalTargeting) for comparison before the actual attack can commence. If the weapon has no restrictions prior to the Warhead, then the Warhead itself decides whether the weapon will attack a specific target or whether it will be passed on to the Secondary (if applicable).

This decision is done by the Verses. The Verses is a list of all applicable Armor types in YR in this order: none, flak, plate, light, medium, heavy, wood, steel, concrete, special_1, special_2. A realistic showing of how this is presented goes as follows:

[WarheadX]
Verses=100%,45%,30%,15%,10%,50%,80%,150%,10%,5%,5%

This means a weapon with this warhead will do 100% damage to Armor=none, 45% to Armor=flak, 30% to Armor=plate, 15% to Armor=light, 10% to Armor=medium, 50% to Armor=heavy, 80% to Armor=wood, 150% to Armor=steel, 10% to Armor=concrete, 5% to Armor=special_1, and 5% to Armor=special_2. Yes the Verses is the damage attenuator for YR in addition to deciding what weapon attacks what. This is done by special case.

The Verses contains several special cases that determine whether the warhead is allowed to attack another target under normal conditions. A Verses value greater than 3% will allow normal combat. A Verses of 2% according to documentation allows no passive acquire (even if allowed), however this effect is broken and 2% works like normal combat. A Verses of 1% disallows both passive acquiring and retaliation of a unit with this weapon assuming the Primary/Secondary opposite of this weapon cannot attack the target. A Verses value of 0% forbids any action from this weapon towards that particular armor type. Even force firing will not cause damage. The 0% in RA2/YR is the deciding factor whether a Primary/Secondary can attack the target given multiple targets of differing armor types on the same targeting plane (e.g. land, naval, air). A 0% will automatically pass the targeting over to the Secondary or another weapon if applicable.

Related tags for Warheads include:

Spread: Controls the radius affected by the warhead in pixels. No longer functional in RA2/YR.
Wall: Can this Warhead affect walls? (Default no)
WallAbsoluteDestroyer: Will this Warhead deal "killing" damage to a wall? (Default no)
Wood: Can this Warhead affect wooden objects such as trees, wood fences and bridges? (Default no)
Fire: Does this Warhead simulate heat and thusly affect ice tiles? (Default no) Not applicable to stock RA2/YR.
Radiation: Does this Warhead create a radiation field upon impact? (Default no) Certain things can be made immune to this effect.
Tiberium: Does this Warhead damage/destroy Tiberium/Ore tiles? (Default no)
Sparky: Does this Warhead cause residual flames? (Default no) Note: This tag is wonky and needs work before you can use it.
Conventional: Does this Warhead make a splash literally? (As in make a splash in water) (Default no)
Rocker: Can this Warhead jostle units around? (As in rock them from side to side or turn over) (Default no) Note: this affects only voxel units.
AnimList: List of applicable animations for impacts. The further right in the list the higher the weapon damage needs to be. The more entries the shorter the damage interval between anims. Note: damage intervals between anims cannot be reliably predicted.
InfDeath: Style of death for infantry.
Deform: Percent chance this Warhead will deform terrain a la Tiberian Sun. Not applicable to stock RA2/YR.
DeformThreshhold: Minimum damage needed to cause deformation of terrain. Not applicable to stock RA2/YR.
Particle: Particle effect upon impact.
ProneDamage: Damage multiplier for "prone" infantry units. This is applied AFTER the Verses.
Bright: Does this Warhead produce a light flash upon impact? (Default no) This is overridden by a similar tag for Weapons.
CombatLightSize: Percent of max size. Value greater than 0 forces the size of light effects rather than being controlled by damage.
Bullets: Is this warhead a bunch of bullet-like projectiles? (Default no) Note: Actual effect (IFV name uses Tip:MachineGun) does not appear to work properly in YR.
CellSpread: Value in cells the Warhead can affect in area. Overrides the now obsolete Spread. Values below 1 affect only a single target.
CellInset: Use this to tell autodeploy how much inside CellSpread we need to get before autodeploying. (Used on Desolator)
PercentAtMax: Maximum damage percent at the fringes of a particular CellSpread. For values greater than 1 this is at the edge of the affect. For CellSpread values less than 1, this appears to have a damage multiplier effect on BuildingTypes.
Sonic: Is this a sonic Warhead? (Default no) This removes Parasite units.
EMEffect: Can this Warhead disable objects instead of harm them? Time controlled by damage. No longer functional in RA2/YR.
PenetratesBunker: Will this Warhead transfer damage to units inside a bunker object (such as the Yuri Tank Bunker). (Default no)
Parasite: Is this Warhead controlled by parasitic actions? (Like Terror Drones and Attack Dogs) (Default no)
Culling: Does this Warhead insta-kill when target gets in the red? (Default no)
Paralyzes: Does this Warhead "paralyze" targets in place? (Used on giant squid and controlled by internal code)
MindControl: Does this Warhead have mind-control properties? (Default no)
PsychicDamage: Is this a psychic weapon? (Default no) Units can be made immune to this tag via ImmuneToPsionics.
AffectsAllies: Will this Warhead affect friendlies in the target area? (Default yes)
IvanBomb: Sabotage effect used by Crazy Ivan style attacks.
CausesDelayKill: Links up with EligibleForDelayKill effects. (Default no)
DelayKillFrames: Time in frames between impact and DelayKill effects.
DelayKillAtMax: Multiply by DelayKillFrames to get DelayKill time at a specific CellSpread.
NukeMaker: Used on Nuclear Missile superweapon. Causes weapon to shoot straight up then come back down via house targeting.
Temporal: Is this a temporal weapon? (Used on Chrono Legionnaire)
IsLocomotor: Is this a locomotor derived weapon? (Used on Chrono Legionnaire and Magnetron)
Airstrike: Is this an airstrike weapon? Used by Boris in stock YR. Triggers the BorisAirstrike ability.
MinDebris: Debris spawned by this weapon's impact. (Minimum value) Debris spawned is apparently random.
MaxDebris: Debris spawned by this weapon's impact. (Maximum value) Debris spawned is apparently random.
BombDisarm: Disarms the effect of IvanBomb style weapons and warheads. (Default no)
ShakeXlo: Screen shake value X direction. (Lower limit)
ShakeXhi: Screen shake value X direction. (Upper limit)
ShakeYlo: Screen shake value Y direction. (Lower limit)
ShakeYhi: Screen shake value Y direction. (Upper limit)
MakesDisguise: Can this Warhead cause the disguise effect? (SHP only)
CLDisableBlue: Disable the blue effects of RGB? (Used on Mirage Tank to ensure the color of impact)
CLDisableGreen: Disable the green effects of RGB?
CLDisableRed: Disable the red effects of RGB?

This list was compiled from a runthrough of rulesmd.ini and may not have absolutely everything. Many of these tags directly affect combat, hence their listing here.


Part III: Projectiles

Projectiles in the YR combat system are how the damage travels to the target. Without defining one, the game will hate you since it would be forced to use defaults. Get it wrong and it won't behave how you want it.

How this relates to determining what shoots what is simple and comes down to 3 settings. AA, AG, AN. AA controls whether the projectile can attack air, AG controls whether the projectile can attack ground, and AN controls whether it can attack submersibles. Without defining these as you need there are no assurances your weapon will behave properly or choose the right one in the first place.

It should also be noted that AN (and other tags like AS) are wholly redundant in RA2/YR. AG will handle naval units just as easily as it handles ground.

To explain this better here is a very basic demonstration:

[Unit]
Primary=GroundGun
Secondary=AirGun

[GroundGun]
Projectile=GroundProjectile

[AirGun]
Projectile=AirProjectile

[GroundProjectile]
AG=yes
AA=no

[AirProjectile]
AA=yes
AG=yes

With this the Primary weapon will shoot everything on the ground. The Secondary weapon can also shoot ground but is overridden by the Primary/Secondary order of operation described earlier. (Unless one of the warheads has a 0%) Now, the Primary cannot shoot air in this case but the Secondary can, therefore all things being equal the Secondary will attack the aerial unit that the Primary is forbidden from doing.

Apart from these, everything else in Projectiles (sans a limitation described below) is just aesthetic for the most part. None of it will affect the determination of which weapon to use.


Part IV: Land Targeting

LandTargeting is a bit of a useful function in the RA2/YR combat system. It provides a check against things attacking stuff they shouldn't. (Such as AI controlled SAM sites attacking tanks) In addition it can provide a level of control for units (usually naval) as per which weapon you want to attack per a particular target.

Like its cousin NavalTargeting described below, LandTargeting will supersede all other considerations for what attacks what excepting air units. (Such as Warhead or Projectile)

The following constants describe how the system works in relation to established rules.
LAND_OKAY = 0
LAND_NOT_OKAY = 1
LAND_SECONDARY = 2

This means that a unit/building with LandTargeting=1 will be expressly forbidden from shooting at the ground at all regardless of the AG setting. Likewise if two weapons can both attack ground but LandTargeting=2 is in effect, only the Secondary will attack ground targets. LandTargeting=0 is simply the default and reverts to normal combat rules.


Part V: Naval Targeting

NavalTargeting is very much like LandTargeting in form and function. Only it applies to the naval setting (anything on or cloaked in water) and has more constants for use. Consider it a reverse LandTargeting.

Like LandTargeting, NavalTargeting will supersede all other considerations for what attacks what except for air units. (Such as Warhead or Projectile)

The following constants describe how the system works in relation to established rules.
UNDERWATER_NEVER = 0
UNDERWATER_SECONDARY = 1
UNDERWATER_ONLY = 2
ORGANIC_SECONDARY = 3
SEAL_SPECIAL = 4
NAVAL_ALL = 5
NAVAL_NONE = 6
NAVAL_PRIMARY = 7

This means a unit with NavalTargeting=6 will not be able to attack any naval based unit or structure at all even if it can attack land. Likewise, a unit with NavalTargeting=4 will use its Secondary weapon against naval targets. (Just like the SEAL from RA2/YR) NavalTargeting=7 will shoot absolutely everything with the Primary. The default value of NavalTargeting is 0 and only forbids underwater units from being attacked directly.


Part VI: Special cases

There are some instances where normal combat logic is either not needed by design or outright fails to behave as predicted, this is where the special cases come in. (Assuming no errors in code)

Some of these such as Verses and AirRangeBonus have been described already. Then there are others which either suspend the typical order of operation or defy it such as Gunner and IsGattling logic.

Gunner logic such as the original IFV behaves by suspending typical Primary/Secondary ordering in favor of the WeaponX listing. When triggered correctly, the Gunner logic will activate the weapon associated with a particular slot listed on the parent unit. This weapon then becomes the Primary in essence and then follows most of the rules of normal combat (LandTargeting, Warhead, etc.)

IsGattling is a bit of a defiance towards the rules. It simply increments weapons over time. Only very specific cases (such as a 0% on a warhead or LandTargeting=1) will cause a weapon to fail to attack it's target during firing. Even then it will just move to the next weapon in the list.

One other case is IsChargeTurret. This suspends the Primary/Secondary ordering in much the same vein as Gunner logic only it does so just to get an animated turret. It's possible (though unlikely) that with IsChargeTurret, an indefinite number of weapons can be attached to a single object.

Some other things also modify the rules of combat as well. Spawner on the unit coupled with Warhead=Special turns the unit into a spawn-maker. Examples of this logic are seen on the Allied Aircraft Carrier and the V3. Warhead=Special really is a special case as it is neither defined nor needs to be and will attack any armor type possible only pausing in regard to LandTargeting/NavalTargeting and AG/AA=no.


Part VII: Limitations/Bugs/Side effects

It must be noted that a Secondary weapon will not fire until the ROF of the Primary has finished. The same is true for Primary if the Secondary attacked first. This is done to prevent ROF abuse of certain weapons.

Projectiles that fire in Arcing=true patterns behave badly when done via AA AA=yes weapons. The weapon will fire according to proper rules but the projectile will never reach the target. Such projectiles fly up approximately 300 leptons and then come back down. It is unknown why this happens.

Unless a weapon has a cursor sabotage effect like C4 or MigAttackCursor, even a Verses value of 1% will not force a swap to another weapon. Additionally, cursor sabotage effects overriding previous weapons is also denied by CanC4=no, thus if a weapon is Versed at 0% against a target to get the weapon that has a cursor sabotage effect, it will be denied completely if the target has CanC4=no. Special care needs to be done in these instances.

When using Warheads, take care when utilising CellSpreads bigger than 1. Values above 1 will affect ALL applicable cells on BuildingTypes with Foundations greater than 1x1 therefore significantly increasing damage to buildings. For example, a building with 3x3 Foundation will take damage on all 9 cells from a CellSpread=1 warhead. Thus if PercentAtMax=1 (the default value), that building will have that weapon's damage (after Verses) multiplied 9 fold. Even small damage values can be magnified significantly this way. The maximum multplier possible with this effect is 16 times due to maximum Foundation size equating to 4x4.


Part VIII: Discussion

In conclusion it must be noted that every rule and observation seen here has been replicated and tested in code. These rules are not merely suggestions. Sometimes they are harsh realities of why things work.

As a reminder targeting hierarchy is summarized as follows: (Further left denotes greater importance)

Land/Naval Targeting --> Warheads --> Projectiles --> Primary/Secondary order.

This guide can and probably will be updated to reflect new knowledge or revisions of inaccuracies in this system. Special thanks goes to ModEnc and Project Perfect Mod for providing either guides or information shown here.