MCPcopy Create free account
hub / github.com/EasyRPG/Player / UpdateAtbGauges

Method UpdateAtbGauges

src/game_battle.cpp:192–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void Game_Battle::UpdateAtbGauges() {
193 std::vector<Game_Battler*> battlers;
194 Main_Data::game_enemyparty->GetBattlers(battlers);
195 Main_Data::game_party->GetBattlers(battlers);
196
197 const auto use_2k3e_algo = Player::IsRPG2k3E();
198
199 int sum_agi = 0;
200 for (auto* bat: battlers) {
201 // RPG_RT uses dead and state restricted battlers to contribute to the sum.
202 if (!bat->IsHidden()) {
203 sum_agi += bat->GetAgi();
204 }
205 }
206 sum_agi *= 100;
207
208 const int max_atb = Game_Battler::GetMaxAtbGauge();
209
210 for (auto* bat: battlers) {
211 // RPG_RT always updates atb for non-hidden enemies, even if they can't act.
212 // We don't update ATB for battlers with a pending battle algo
213 if (!bat->GetBattleAlgorithm() && bat->Exists() && (bat->CanAct() || bat->GetType() == Game_Battler::Type_Enemy))
214 {
215 const auto agi = bat->GetAgi();
216 auto increment = max_atb / (sum_agi / (agi + 1));
217 if (use_2k3e_algo) {
218 const auto cur_atb = bat->GetAtbGauge();
219 const auto multiplier = std::max(1.0, static_cast<double>(275000 - cur_atb) / 55000.0);
220 increment = Utils::RoundTo<int>(multiplier * increment);
221 }
222
223 ManiacBattleHook(
224 Game_Interpreter_Battle::ManiacBattleHookType::AtbIncrement,
225 bat->GetType() == Game_Battler::Type_Enemy,
226 bat->GetPartyIndex(),
227 bat->GetAtbGauge(),
228 increment
229 );
230
231 bat->IncrementAtbGauge(increment);
232 }
233 }
234}
235
236bool Game_Battle::ManiacBattleHook(Game_Interpreter_Battle::ManiacBattleHookType hook_type, int var1, int var2, int var3, int var4, int var5, int var6) {
237 if (Player::IsPatchManiac() && interpreter) {

Callers

nothing calls this directly

Calls 11

maxFunction · 0.85
GetBattlersMethod · 0.80
IsHiddenMethod · 0.80
GetAgiMethod · 0.80
GetBattleAlgorithmMethod · 0.80
CanActMethod · 0.80
GetAtbGaugeMethod · 0.80
GetPartyIndexMethod · 0.80
IncrementAtbGaugeMethod · 0.80
ExistsMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected