Difference between revisions of "Regeneration"
m (Rewrote the terrain repair section to be a lot clearer. Minor changes elsewhere in light of that.) |
|||
| (5 intermediate revisions by 3 users not shown) | |||
| Line 16: | Line 16: | ||
*Cloaking Field(Wraith): -21 (-13 net) | *Cloaking Field(Wraith): -21 (-13 net) | ||
*Heal: -100 (-92 net) | *Heal: -100 (-92 net) | ||
| − | + | <br /> | |
| + | <u>For repair:</u><br /> | ||
SCVs repair units and buildings in a similar way, based on build time and total HP. Multiple SCVs increase the repair rate by adding them together.<br /> | SCVs repair units and buildings in a similar way, based on build time and total HP. Multiple SCVs increase the repair rate by adding them together.<br /> | ||
| − | R = roundup(.9 * H/B)<br /> | + | <br /> |
| − | where R = repair rate in | + | '''R''' = roundup(0.9 * <u>H</u>/<u>B</u>)<br /> |
| − | One important note is that | + | where '''R''' = repair rate in <u>hp</u> per <u>frame</u> (of animation), with:<br /> |
| − | A Terran Barracks with a build time of 1, HP of 9999.<br /> | + | <u>H</u> = health of the unit<br /> |
| − | + | <u>B</u> = build time of the unit in SCMDraft (which is counted as ''frames of animation'')<br /> | |
| − | + | <br /> | |
| − | A slightly more realistic value is that of the default battlecruiser with 500 HP, 2000 | + | <br /> |
| − | + | ''Further'', '''R2''' = 256*'''R''', and '''R2''' is the value that gets added or subtracted each frame to the first byte of a unit's HP. <br /> | |
| − | + | One important note is that '''R2''' is a 2 byte value, which means that when '''R2''' > 65535, it loops back over to 0. Here is an example:<br /> | |
| − | Building units follows the same formula, and this explains why some buildings/units come out injured, except they start out with 10% of the base HP, plus 1 frame of "repairing", plus the time it takes to build. In the case of the terran barracks, it will build in 1 frame and come out with .1 * 9999 + 10010/256 + 10010/256 = 1078.1 HP. | + | <br /> |
| + | A Terran Barracks with a <u>build time of 1 frame</u>, <u>HP of 9999</u>.<br /> | ||
| + | '''R2''' = 256 * roundup(0.9 * <u>9999</u>/<u>1</u>) = 2303770. R2 > 65535, so it rolls over in multiples of 65535.<br /> | ||
| + | '''R2''' = 2303770 - k65535, '''R2''' = 10010. Note that this is still fairly large, and means that each SCV will repair approximately <u>39 HP every frame</u>.<br /> | ||
| + | <br /> | ||
| + | A slightly more realistic value is that of the default battlecruiser with <u>500 HP</u>, <u>2000 frames build time</u>:<br /> | ||
| + | '''R2''' = 256 * roundup(0.9 * <u>500</u>/<u>2000</u>) = 58.<br /> | ||
| + | '''R''' = '''R2'''/256 = <u>0.2266 hp per frame of animation</u><br /> | ||
| + | 0.2266 hp per frame * 24 frames of animation per real-time second = <u>5.44 hp per real-time second</u>.<br /> | ||
| + | <br /> | ||
| + | <u>Building units, following from repair:</u><br /> | ||
| + | Building units follows the same formula, and this explains why some buildings/units come out injured, except they start out with 10% of the base HP, plus 1 frame of "repairing", plus the time it takes to build. In the case of the terran barracks, it will build in 1 frame and come out with .1 * 9999 + 10010/256 + 10010/256 = 1078.1 HP.<br /> | ||
| − | === | + | ===Calculation of healing rates=== |
| − | Since Starcraft is normally played on fastest, or | + | ''The time used here is realtime.'' |
| − | *Protoss shields use 7, | + | Since Starcraft is normally played on fastest, or 42ms/frame, we can calculate the approximate rates of healing: |
| − | *Zerg Health use 4, so 256/4/ | + | *Let sp = shield points, hp = hit points, f = frames, ms = milliseconds, s = seconds, p = fraction of points |
| − | *Medics' Healing uses 200, so 256/200/ | + | *Protoss shields use 7, (256p/sp / 7p/f) / (1000ms/s / 42ms/f) = 1.536 seconds per shield point. |
| − | *Shield batteries use 1280, so 256/1280/24=0. | + | *Zerg Health use 4, so (256/4)/(1000/42) = 2.688 seconds per health point. |
| + | *Medics' Healing uses 200, so (256/200)/(1000/42) = 0.05376 seconds per health point or ~18.6 health per second. | ||
| + | *Shield batteries use 1280, so 256/1280/24 = 0.0084 seconds per shield point or ~119 shields per second. | ||
Other rates can be similarly calculated. | Other rates can be similarly calculated. | ||
[[Category:StarCraft]] | [[Category:StarCraft]] | ||
[[Category:Reference]] | [[Category:Reference]] | ||
Latest revision as of 02:04, 23 January 2025
In StarCraft, regeneration is the slow increase of a unit's health, shields, or energy.
How It Works
To understand regeneration, you have to understand that Starcraft hides data from you. Health and Shields each are stored in memory in 4 bytes, however Starcraft only tells you the last 3 bytes. The first byte is actually a hidden value which acts as a timer for regeneration. 1 byte = 8 bits, or 28 = 256.
Each frame, a certain regeneration amount is added (or subtracted) to the first byte, according to values in the mpqs:
- Protoss Shields: 7
- Zerg Health: 4
- Energy: 8
- Shield Battery: 1280
- Recharge Shields: -640 (-632 net)
- Burning Terran Building: -20
- Medic: 200
- Personnel Cloaking(Ghost): -18 (-10 net)
- Cloaking Field(Wraith): -21 (-13 net)
- Heal: -100 (-92 net)
For repair:
SCVs repair units and buildings in a similar way, based on build time and total HP. Multiple SCVs increase the repair rate by adding them together.
R = roundup(0.9 * H/B)
where R = repair rate in hp per frame (of animation), with:
H = health of the unit
B = build time of the unit in SCMDraft (which is counted as frames of animation)
Further, R2 = 256*R, and R2 is the value that gets added or subtracted each frame to the first byte of a unit's HP.
One important note is that R2 is a 2 byte value, which means that when R2 > 65535, it loops back over to 0. Here is an example:
A Terran Barracks with a build time of 1 frame, HP of 9999.
R2 = 256 * roundup(0.9 * 9999/1) = 2303770. R2 > 65535, so it rolls over in multiples of 65535.
R2 = 2303770 - k65535, R2 = 10010. Note that this is still fairly large, and means that each SCV will repair approximately 39 HP every frame.
A slightly more realistic value is that of the default battlecruiser with 500 HP, 2000 frames build time:
R2 = 256 * roundup(0.9 * 500/2000) = 58.
R = R2/256 = 0.2266 hp per frame of animation
0.2266 hp per frame * 24 frames of animation per real-time second = 5.44 hp per real-time second.
Building units, following from repair:
Building units follows the same formula, and this explains why some buildings/units come out injured, except they start out with 10% of the base HP, plus 1 frame of "repairing", plus the time it takes to build. In the case of the terran barracks, it will build in 1 frame and come out with .1 * 9999 + 10010/256 + 10010/256 = 1078.1 HP.
Calculation of healing rates
The time used here is realtime. Since Starcraft is normally played on fastest, or 42ms/frame, we can calculate the approximate rates of healing:
- Let sp = shield points, hp = hit points, f = frames, ms = milliseconds, s = seconds, p = fraction of points
- Protoss shields use 7, (256p/sp / 7p/f) / (1000ms/s / 42ms/f) = 1.536 seconds per shield point.
- Zerg Health use 4, so (256/4)/(1000/42) = 2.688 seconds per health point.
- Medics' Healing uses 200, so (256/200)/(1000/42) = 0.05376 seconds per health point or ~18.6 health per second.
- Shield batteries use 1280, so 256/1280/24 = 0.0084 seconds per shield point or ~119 shields per second.
Other rates can be similarly calculated.