# Battle Algorithm related fixes from battle 7 #1539

Merged
merged 5 commits into from Dec 12, 2018

## Conversation

Projects
None yet
5 participants
Contributor

### fmatthew5876 commented Dec 8, 2018 • edited

 Battle 7 commits related to battle algorithm calculations

### fmatthew5876 changed the title "3.11: RM2000: Getting all the battle formulas right, including all t…Battle Algorithm related fixesDec 8, 2018

Contributor Author

### fmatthew5876 commented Dec 8, 2018

 This one is tested and ready. I have nothing more to add here.

### Ghabry reviewed Dec 11, 2018

src/game_battlealgorithm.cpp

### Ghabry reviewed Dec 11, 2018

src/game_battlealgorithm.cpp Outdated

### fmatthew5876force-pushed the fmatthew5876:battle_algo branch 2 times, most recently from `6ade475` to `e610b8e`Dec 11, 2018

Contributor Author

Member

### Ghabry commented Dec 12, 2018

 @fmatthew5876 merge conflict :/

### Albeleon added some commits Jul 4, 2018

``` "2.33: RM2000 + RM2003: A skill that costs SP and recovers SP, it can… ```
```… recover the SP that spent in that same skill."

Solution: In case the source and the target is the same for a positive action, we keep in mind it can recover the SP lost. Then, in Skill::Apply, before the SP is increased, we move the SP cost before.```
``` f7f783f ```
``` "2.35: RM2000 + RM2003: When an absorb skill attack, if HP or SP are … ```
```…selected and the result is 0, the skill attack misses in its entirety, but it can still hit if they are unselected and the other stat decrease are 0 if the skill does other things (states, attribute resistance, etc.). If it doesn't absorb, the attack misses if it doesn't have HP selected but yes SP and it's 0."

Solution: Put all those conditions at the end of a skill attack.```
``` 42bb3fa ```
``` "3.11: RM2000: Getting all the battle formulas right, including all t… ```
```…he modificators."

Solution: The formulas to solve are:

1. AbsoluteDefense gives x4 defense, not x3.
2. EscapeRate increased each turn is absolute, not relative to the current chances of escaping. This means, if even if you have 0% chance at first you can escape the more you try, 10% each time.
3. The Skill variance has been fixed and applied to both Positive and Negative skills.

Note: Also refactored a bit```
``` a864049 ```
``` Clamp attribute values based on base and battle (2k / 2k3). ```
```Problem: The way the clamp attributes were based before in battle, there were always clamped at 999, when in reality that value always depends of the version (2k or 2k3) and the Battler's type (Ally, Enemy).

Solution: Create MaxHpValue, MaxStatBaseValue and MaxStatBattleValue in Game_Battler and overriden by Game_Actor and Game_Enemy, each one with its own specifics, and replace all the values.```
``` 0a14560 ```
``` Clamp maximum damage depending of version (2k / 2k3). ```
```Problem: Damage or healing isn't clamped. In 2k it's 999 and in 2k3 it's 9999.

Solution: Add a MaxDamageValue in Game_Battler that distinguises and returns each version, and then put in every damage, skill or healing aspect it's needed.```
``` 98a6a58 ```

### fmatthew5876force-pushed the fmatthew5876:battle_algo branch from `e610b8e` to `f7f783f`Dec 12, 2018

Contributor Author

### fmatthew5876 commented Dec 12, 2018

 rebased to master

### fdelapena merged commit `dba6dc0` into EasyRPG:master Dec 12, 2018 7 checks passed

#### 7 checks passed

Android (armeabi-v7a) Build finished.
Details
GNU/Linux Build finished.
Details
OSX Build finished.
Details
Wii (SDL1) Build finished.
Details
Windows (x64) Build finished.
Details
Windows (x86) Build finished.
Details
web Build finished.
Details