Talk:Craft Combat Mechanics
Testing Air Combat Mechanics
See main article page for completed research.
Relative rates of fire for XCom weapons
Control of Range
Make a hit counter
Counting rounds fired, and the ratios between rounds fired of different XCom weapons is now easily done. But it's hard to tell how many hits (and by implication misses) have occurred. Should be possible to make a hit counter by the following process:
- Set a test weapon to a value of 1 damage and a large ammo count (1000 maybe). In theory, this will always do 1 point of damage, since 0.5 - 1.0 range should always round to 1. Of course it depends on the rounding algorithm used, so it needs to be tested.
- Set a control weapon to 0 damage and a larger ammo count. This is only to make sure combat doesn't break off before you can save the game, when the test weapon runs out of ammo.
- Verify the test weapon. Run a thousand rounds. Hopefully the damage will average close to 1.00, maybe less.
Once the hit counter is validated it useful for lots of new tests
Test relative fire rates between XCom and UFOs
This is hard to do because it's hard to spot a hit from a UFO. It can be done approximately by using high damage, slow fire rate weapons. With a hit counter, it's possible to do it much more accurately. The XCom number of rounds fired can be easily determined from the ammo counter. The hit counter, and the XCom damage level, can then be used to determine the number of UFO rounds fired.
Test if hit probability / damage changes based on attack mode
This has not been tested in detail, it would be much easier to test with a hit counter.
Check if "Cannon Timer" is fixed or variable
Verify variable rate of fire and see if it applies to XCom
UFO rate of fire is believed (from code decompilation) to vary by 1.0x to 2.0x nominal value, reduced by Difficulty Level. Observations show the average to be 1.5x, which matches this range. What is not known is whether XCom rate of fire also varies, or if it is (for example) constant at the nominal level. The hit counter helps with verifying this. This is quite important, since it determines whether the "Cannon Timer", the baseline for all other time measurements, is a fixed time (2gs) or a variable time (2gs - 4gs, average 3gs). Test procedure:
- Create an XCom test craft with a test weapon, reload rate 96, damage 1, high ammo
- Create a UFO test craft with a test weapon, reload rate 96, damage 1
- Set the ranges of both weapons to be the same value, say 65km
- Ensure Difficulty is on Beginner, to maximise the UFO RoF penalty and keep it constant. If also testing on other difficulty levels, e.g. Superhuman, start a new game or use XComUtil to change difficulty of a saved game.
- Add a dmg=0 weapon with greater ammo and range, to prevent early abort of the combat
- First of all find out if the initial XCom shot and the first UFO return shot are synchronised, or if the return fire is delayed. Take this into account.
- Run short tests
- Repeat many times but only for short runs. If the UFO ever fires more hits than XCom, XCom is also random. If XCom always fires more times, then (probably) UFO has a random reload rate but XCom has a fixed reload rate.
- If the shots are always exactly synchronised, either both are fixed (contrary to the code decompilation) or both vary but use the same random value.
- Even with a reload rate of 96, it could be quite hard to save the game. Hopefully it won't matter much as, whatever time you save the game, the hit counts on either side will still be useful data
- Don't go above a reload rate of 96 in case there is a byte value that might overflow at 255.
- Actually saving while the Intercept window is hard anyway. Still need to figure out how to do it reliably. It might require multiple aircraft (the others must be unarmed), breaking off with another aircraft and minimising, then saving. The hotkeys from UFO Extender certainly help. Slight risk that the extra aircraft might bias the results (see Engagement by Multiple Attackers for weirdness). So unfortunately, at least at first, do tests with 2/3/4 aircraft to see if it makes a difference.
Can a UFO be given limited ammo?
No. When UFO fires it neigther checks ammo value nor decreasing it.
Can an XCom Craft be given a UFO-type weapon?
Can a UFO be given a hardpoint mounted weapon and ammo?
What are all the values in INTER.DAT?
Does air combat damage vs UFOs persist between Intercept screens?
- I'm pretty sure it does. Once I tested using an Avenger vs a Battleship which was in a retaliation mission. I let the Avenger attack, and then withdraw after inflicting some damage and let the UFO get to a X-COM base. It took less defence hits than usual to destroy the battleship (IIRC, it was destroyed after 1 or 2 hits. The first being impossible without retaining damage, the second being very unlikely). Cesium 16:12, 15 March 2010 (EDT)
Yes. There is an entry in CRAFT.DAT that tracks the crafts current damage level. When this level reaches or exceeds 1/2 of the UFO's total hull points the UFO will crash or the craft is destroyed if the amount reaches or exceeds its total hull points.-Tycho (talk) 07:56, 23 June 2015 (EDT)
Can the attacking side be switched so that up to 4 UFOs attack one XCom plane?
This value of craft just for Ufopaedia information. It doesn't affect on anything of gameplay itself. It's just a virtual value.
- Are we sure about this? Because my experience has been that Small Scouts (which have the highest Acceleration value but lowest maximum speed) get away much faster than anything bigger (this is part of why they're so hard to shoot down without destroying them; an Interceptor with Stingrays won't be able to close before the Small Scout starts escaping). My interpretation of that is that the game keeps a "UFO speed" variable that starts at the Geoscape value and rises at a rate proportional to the Acceleration value until it exceeds the X-Com craft's maximum speed (that's when "UFO OUTRUNNING INTERCEPTOR" comes up and it starts getting away) or caps out. But that's a supposition, not based on a code dig. So a) is it actually confirmed that Acceleration doesn't do anything, b) if Acceleration indeed doesn't do anything, then why do Small Scouts escape so much faster than Medium/Large Scouts? Magic9mushroom (talk) 21:44, 23 June 2015 (EDT)
Testing Effects of Range and Attack Mode
I did some tests on timing events in the Interception Window. In particular, I was interested in seeing how long an XCom aircraft is exposed to enemy fire, whilst closing range to the target. In other words, what happens when the XCom aircraft's weapons do not give it a full stand-off advantage.
My test rig for this was to hack up a "magic weapon" to use as a timer. This was a modified Cannon that does no damage, with range increased to the maximum/opening range in the interception window. I use the 2 game second (2gs) firing interval of the Cannon as a timer.
Note: In all of the following sections, I refer to "game seconds". But actually this is a supposition. What I'm actually measuring is multiples of the firing interval of a standard Cannon. This is stated in the in-game UFOPaedia to be 2 (game) seconds. But (as we will see below), the in-game statements of firing intervals of craft weapons are neither accurate or consistent. So it may or may not be meaningful to talk about these being actual game seconds. Maybe they are no more than multiples of the Cannon firing interval. And quite possibly the Cannon firing interval itself is not fixed, but is variable.
I hacked the executable by using XComUtil and editing the XComUtil.cfg configuration file, then rerunning xcusetup.bat to reinstall XCU. I discovered that XCU was not apparently able to reliably change the fire rate of weapons, so I stuck with the game default values (eg 1 per 2 gs for Cannon). Here are my findings:
- In the Interception Window, all aircraft close range with the enemy at the same rate (measured in shots fired).
- This is regardless of whether the aircraft is an Interceptor (2100 kts, Acc=3) or an Avenger (5400 kts, Acc=10).
- This is also regardless of whether the attack mode is Cautious, Standard, or Aggressive
- Of course, the range that the aircraft will attempt to close to, and hold, does depend on the attack mode
- The approach speed of 2 mutually approaching aircraft is 0.5km per game second, i.e. 1800 kmh / 900 kts (assuming the Cannon rate of fire to be 1 per 2 game seconds).
- Evidence for this:
- Closing from 70km to 30km, 40 volleys of Cannon fire are fired, at 1 / 2gs
- 40 volleys x 2gs = 80 gs time taken to close
- 40km / 80gs = 0.5 km/s
- This was also cross checked with a (hacked) Stingray launcher (zero damage, 75km range, 100 rounds) as the timer.
- Closing from 75km to 0km. 10 rounds fired. Stingray fire rate is 1 / 15 or 16gs
- 10 x 15 gs = Time taken was 150 - 160 gs,
- 75km / 150 gs = 0.5 km/s
- The fire rate for missiles varies with the attack mode, but the fire rate for cannon type weapons seems to be unchanged. See more below.
- Or it's just barely possible that the fire rate, and the closing speed, both change by the same margin and remain in the same ratio.
- However I think this is unlikely and it violates Occam's Razor.
- Also, even if true, it doesn't really make any difference.
- The initial opening range on the Interception Window is 75km (600 distance units).
- That is the maximum distance visible, at the top of the window. Opening range = maximum range.
- UFOs seem to often settle at 70km range, if they are able to control the range.
- XComUtil does not let you enter a weapon range value above 75km. Probably Scott Jones was aware of this limit.
- Clearly, the Geoscape phase of Interception is different from the Interception Window
- Geoscape time freezes while you are in the Interception window
- Nothing happens at all until you hit the first button, so there's no rush
- On the Geoscape, relative aircraft speed is highly significant to whether an interception is possible.
- Probably so is Acceleration.
- I didn't try multiple aircraft interceptions. Maybe these are different.
- I only tried one target type, a Small Scout (speed 2200 kts). It would be prudent to try other target types though.
- I think there's enough granularity in the tests I did (45 data points, greater than 100% difference in speed and acceleration between Interceptor and Avenger). But more is always good.
- I didn't test the speed of breaking off, or the speed of opening range after the initial closing. It's possible this is affected by aircraft speed and/or relative speed, and/or by acceleration.
- Misc Notes
- XComUtil does not let you enter an ammo capacity higher than 200. Other sources claim the field can be hacked higher than this.
- There is a bug in the in-game UFOPaedia. It mistakenly reads the damage value field when reporting the hit chance for a craft weapon. Hence:
- Cannon shows 10% not 25%
- Avalanche shows 100% not 80%
- Laser Cannon shows 70% not 35%
- Plasma Beam shows 140% not 50%
- Fusion Ball shows 230% (!!!) not 100%
- Possibly the reason this bug was missed is that the first weapon in the data files, Stingray, actually does have Dmg = %Hit
Spike 19:38, 2 July 2009 (EDT)
- From my own experience: Attack mode only adjusts the range of the inteceptor and UFO. The actual distance between the ships however influences how fast the weapon exchanges go. The closer they are the faster the exchange. However, I believe this is all at the same rate of fire - it just plays out faster between that particular interceptor and UFO (in the case of multiple interceptors).
- By the way, when a UFO flees and you minimize the screen before it goes out of range, and then you chase after it and catch up to it again and then re-open the screen, the UFO will be way out of range as you close in on it. I guess in a way, real world position does influence position of the UFO at the time the interception window is opened. -NKF 02:52, 3 July 2009 (EDT)
Hi NKF. Actually I've found attack mode does affect some important variables and I will reveal all as soon as I get to a proper PC - in transit right now. There is the question of whether fire rate increases at shorter range - the "Space Invaders Effect" - and whether it is real in terms of game time units, or just subjective on the user display. I still don't know though I have seen no evidence for it and pretty good evidence against. But not conclusive and to be honest I have avoided test situations where that might happen in order to reduce variables in my tests. So there might be such an effect.
I am not sure I understand your point about re-engagement. To me it makes sense that Interception always opens at maximum range, since the presumption is that the target has opened the range beyond effective combat range, and then susbequently in the Geoscape we have closed again to within the outer limits of combat range, triggering the Intercept window. Or have I misunderstood what you are saying?
Anyway I hope to be able to write something soon to put together most of how the air combat system works, or at least a good chunk more of it, at least from the human side.
Spike 15:02, 3 July 2009 (EDT)
- To test range/ROF You may want to test dual interceptors with your magic test weapon. Have both armed with one test weapon and have one interceptor arm a cannon/laser cannon. Set both to standard range. The one with the cannon/laser cannon would obviously have to be much closer. Watch your test weapon's ammo consumption.
- What I meant with re-engaging a UFO that had previously fled, but you then minimized the window before it went beyond the limits of the intercept screen (and thus keeping the intercept window 'live' even though it's beyond intercept range). When the UFO slows down enough for the interceptor to catch up, and you then re-open the intercept screen, the UFO will sometimes be way off the screen. I'm guessing this is based off your actual distance in the Geoscape at the time you re-opened that interceptor's intercept window. Also I'm guessing the UFO must be in a fleeing-state for the intercept window to automatically shut itself down once it's beyond range. Heh, not sure if that made any sense. -NKF 23:00, 3 July 2009 (EDT)
Effect of Range on Rate of Fire
It's likely that the perception that range can affect rate of fire just arises from the fact that attack mode affects both rate of fire AND range. However this should be tested.
Attack in Standard mode with different weapons. Hack the ranges of either or both weapons. This allows the actual firing range of the longer-ranged weapon to be controlled to any arbitrary value. Set the range of the shorter-ranged weapon to be eg 25/50/75% of the range of the longer ranged weapon.
Actually for direct comparisons, you need 2 hacked short ranged weapon and probably one unhacked longer ranged weapon "C" which you are testing (eg Avalanches). Then put up 2 aircraft, one with short range weapon A at 25% of the range of C, and the other with short range weapon B at eg 50% of the range of C. Then attack with both at the same time and watch the ammo counters on the C. As usual, set the damage of all weapons to zero so that the experiment is not interrupted by the untimely destruction of any craft!
A high ammo count for the launchers will also assist.
Just to round off the attack mode test towards the end, it might be a good idea to have a test weapon that has a range equal to standoff range (or even beyond) to see how standoff range behaves as an attack mode. A standoff range cannon would certainly be something to look at. -NKF 18:13, 4 July 2009 (EDT)
- I have been hacking pretty much everything up to 100 ammo as that gives good granularity and a nice round number to work from. It's a good suggestion about Standoff mode, it didn't occur to me to test that - even though I had weapons set at 75km. From memory nothing happens until you select one of the 3 other attack modes - but I will check again. Spike 19:13, 4 July 2009 (EDT)
- OK I've confirmed this and amended the main page. Re your question, even if the range of the weapon is hacked to equal or exceed standoff range, it does not fire when in Standoff mode (or in Disengage). So Standoff mode also appears to mean "Weapons Safe". In fact, with a hacked weapon range, you can have the curious phenomenon that the aircraft actually pulls back from Standoff range (70km) to maximum firing range (eg 75km) when ordered into a Standard/Cautious attack. Spike 07:05, 5 July 2009 (EDT)
Another interesting result. A UFO with a hacked weapon range of 75km will open fire immediately, even if the XCom Craft is at Standoff range. In normal play, the UFO never initiates the attack. The status window message even reflects this "UFO Returns Fire!". In effect, XCom normally controls the initiation of hostilities, by choosing if and when to move into weapon range. The UFOs always react to XCom moves but never initiate. The hacked weapon situation is different. (It also makes testing harder since you have to hit an Attack button quickly or the UFO gets an unfair head start, skewing the numbers). I might try using 69km for testing. It still makes the period of time while the UFO is closing into range pretty insignificant. But it allows me to control when the "clock" starts on the test. Spike 14:43, 5 July 2009 (EDT)
Further results: Equip 2 craft with Fusion Ball Launchers and Stingrays. According to the published fire interval numbers (25 and 15 respectively) these have different rates of fire. By observation, they have the same rate of fire. This is seen on Beginner and Superhuman. It is seen on Aggressive, when ranges are the same, and it is also seen on Cautious, when the FBL attacks at more than twice the range of the Stingray. This is using 100 rounds for each weapon, and about 5 trials. I think this proves conclusively that rate of fire does not vary with range.
However, I'm still not sure how to reconcile 2 facts:
- For missile weapons (only), hacking the firing interval bytes in the executable up or down does decrease or increase the rate of fire.
- The observed ratios of rates of fire of the different missile weapons do not match the ratios between the firing interval bytes in the executable.
Basically the bytes in the executable must be part of the rate of fire calculation, but not the whole calculation. Spike 17:13, 13 July 2009 (EDT)
OK contrary to what I said earlier, on repeat testing, I don't see any effects from changing the game executable XCom craft weapon data firing interval offsets (starting at offset 0x6fb18 in WinCE geoscape.exe). I don't see it either for missile-type weapons nor gun-type weapons. I do see an RoF effect when changing offset 0x10 of UFOs in the craft data at 0x6f9a8. This affects the built-in weapons of UFOs only, and is not used for XCom craft. My conclusion is that the RoFs values in the craft weapon data structure for XCom craft weapons are ignored, that the actual values are hard coded elsewhere in the executable, and are proportional to the values given above at Observed Rates of Fire. The only effect of hacking these craft data weapon values is to change what is listed in the in-game UFOPaedia; there is no actual effect. Spike 20:09, 13 July 2009 (EDT)
- XComUtil does not let you enter an ammo capacity higher than 200. Other sources claim the field can be hacked higher than this.