Hero bug deals millions of damage to bosses when sold (explanation in description)

Описание к видео Hero bug deals millions of damage to bosses when sold (explanation in description)

You may get removed from leaderboards if you use this, be warned. Only level 14+ heroes work on solo, level 20 will damage less than lvl 14.

explanation:
In Bloons TD 6 (BTD 6), the boss "Lych" has a mechanic where it heals based on the tiers of towers sold. The healing calculation is as follows:

1. **Healing Calculation**:
- Heal = tiers * boss_hp
- Here, `tiers` is the number of tiers of the tower being sold, and `boss_hp` is the current health of the boss.

2. **Overflow Issue**:
- The game uses a 32-bit signed integer to store the heal value.
- The maximum value a 32-bit signed integer can hold is 2,147,483,647.
- If the heal value exceeds this maximum, it will overflow. In programming, when a signed integer overflows, it wraps around to a negative value due to the way integer overflow is handled in two's complement representation.

3. **Scenario Analysis**:
- *Scenario 1: Selling a Tower with 15 Tiers*
- Let's say the boss has 144 million health (144,000,000).
- You sell a tower with 15 tiers (level 14 hero).
- Calculation: heal = 15 * 144,000,000 = 2,160,000,000
- Since 2,160,000,000 exceeds 2,147,483,647 (the maximum for a 32-bit signed integer), an overflow occurs.
- After overflow, heal wraps around to a negative value, specifically -2,136,313,344.
- Final heal = -2,136,313,344 / 100 = -21,363,133.44 (approximated)
- Therefore, the boss would effectively receive damage of approximately 21.36 million hp due to the negative heal.

- *Scenario 2: Selling a Tower with 13 Tiers*
- Calculation: heal = 13 * 144,000,000 = 1,872,000,000
- 1,872,000,000 is less than 2,147,483,647, so no overflow occurs.
- Final heal = 1,872,000,000 / 100 = 18,720,000
- In this case, the boss would heal for approximately 18.72 million hp.

4. **Conclusion**:
- Selling a tower with 15 tiers causes the heal calculation to overflow a 32-bit signed integer when multiplied with the boss's health.
- The overflow results in a negative heal value, which translates to damage against the boss in the game mechanics.
- Selling a tower with 13 tiers or any lower number of tiers will not cause an overflow, and the heal value will be positive, resulting in actual healing for the boss.

Комментарии

Информация по комментариям в разработке