Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented Maniacs Command 3010: ControlATBGauge #3291

Merged
merged 4 commits into from
Nov 9, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 74 additions & 2 deletions src/game_interpreter_battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,84 @@
return true;
}

bool Game_Interpreter_Battle::CommandManiacControlAtbGauge(lcf::rpg::EventCommand const&) {
bool Game_Interpreter_Battle::CommandManiacControlAtbGauge(lcf::rpg::EventCommand const& com) {
if (!Player::IsPatchManiac()) {
return true;
}

Output::Warning("Maniac Patch: Command ControlAtbGauge not supported");
int target_flags = com.parameters[0];
int target_reference_flags = com.parameters[1];
int target_reference_identifier = com.parameters[2];
int operation_flags = com.parameters[3];
int operand_flags = com.parameters[4];
int value_reference_flags = com.parameters[5];
int value_reference_identifier = com.parameters[6];

int target_id = ValueOrVariable(target_reference_flags, target_reference_identifier);

auto getAtbValue = [this, value_reference_flags, value_reference_identifier](int flags) {
int value = ValueOrVariable(value_reference_flags, value_reference_identifier);

switch (flags) {
case 0:
// value
return value;
break;
case 1:
// percentage
return (int) ((double)value / 100 * Game_Battler::GetMaxAtbGauge());
break;
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved
}
};

Check warning on line 628 in src/game_interpreter_battle.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

control reaches end of non-void function [-Wreturn-type]

Check warning on line 628 in src/game_interpreter_battle.cpp

View workflow job for this annotation

GitHub Actions / debian:12

control reaches end of non-void function [-Wreturn-type]

auto executeOperation = [getAtbValue, operand_flags](int flags, Game_Battler* battler) {
switch (flags) {
case 0:
// set
battler->SetAtbGauge(getAtbValue(operand_flags));
break;
case 1:
// add
battler->IncrementAtbGauge(getAtbValue(operand_flags));
break;
case 2:
// sub
battler->IncrementAtbGauge(-getAtbValue(operand_flags));
break;
}
};

switch (target_flags) {
case 0:
// actor
if (target_id > 0) {
executeOperation(operation_flags, Main_Data::game_actors->GetActor(target_id));
}
break;
case 1:
// party member
executeOperation(operation_flags, Main_Data::game_party->GetActor(target_id));
break;
case 2:
// entire party
for (Game_Battler* member : Main_Data::game_party->GetActors()) {
executeOperation(operation_flags, member);
}
break;
case 3:
// troop member
if (target_id > 0) {
executeOperation(operation_flags, Main_Data::game_enemyparty->GetEnemy(target_id));
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved
}
break;
case 4:
// entire troop
for (Game_Battler* member : Main_Data::game_enemyparty->GetEnemies()) {
executeOperation(operation_flags, member);
}
break;
}

return true;
}

Expand Down
Loading