[Crash Fix] D20 crash if mitigation average resulted in 0 (#4131)

This commit is contained in:
nytmyr 2024-02-28 19:35:56 -06:00 committed by GitHub
parent 34f19489d0
commit 103a37e762
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1005,7 +1005,7 @@ double Mob::RollD20(int offense, int mitigation)
auto atk_roll = zone->random.Roll0(offense + 5);
auto def_roll = zone->random.Roll0(mitigation + 5);
int avg = (offense + mitigation + 10) / 2;
int avg = std::max(1, (offense + mitigation + 10) / 2);
int index = std::max(0, (atk_roll - def_roll) + (avg / 2));
index = EQ::Clamp((index * 20) / avg, 0, 19);