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

Implement Maniacs Command 3009: ControlBattle #3295

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions src/game_battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,28 @@ void Game_Battle::UpdateAtbGauges() {
const auto multiplier = std::max(1.0, static_cast<double>(275000 - cur_atb) / 55000.0);
increment = Utils::RoundTo<int>(multiplier * increment);
}

ManiacBattleHook(
Game_Interpreter_Battle::AtbIncrement,
bat->GetType() == Game_Battler::Type_Enemy,
bat->GetPartyIndex(),
bat->GetAtbGauge(),
increment
);

bat->IncrementAtbGauge(increment);
}
}
}

bool Game_Battle::ManiacBattleHook(Game_Interpreter_Battle::ManiacBattleHookType hook_type, int var1, int var2, int var3, int var4, int var5, int var6) {
return interpreter->ManiacBattleHook(hook_type, var1, var2, var3, var4, var5, var6);
}

bool Game_Battle::ManiacProcessSubEvents() {
return interpreter->ProcessManiacSubEvents();
}

void Game_Battle::ChangeBackground(const std::string& name) {
background_name = name;
}
Expand Down
10 changes: 10 additions & 0 deletions src/game_battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <lcf/rpg/system.h>
#include <lcf/rpg/troop.h>
#include "teleport_target.h"
#include "game_interpreter_battle.h"
#include "utils.h"
#include "point.h"

Expand Down Expand Up @@ -109,6 +110,15 @@ namespace Game_Battle {
*/
void UpdateAtbGauges();

/**
* Convenience function to call a maniacs battle hook, which processes sub-events at any time.
*/
bool ManiacBattleHook(Game_Interpreter_Battle::ManiacBattleHookType hook_type, int var1, int var2, int var3, int var4 = 0, int var5 = 0, int var6 = 0);
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved
/**
* Convenience function to process all maniacs sub-events, and return whether they're currently running
*/
bool ManiacProcessSubEvents();

void ChangeBackground(const std::string& name);

const std::string& GetBackground();
Expand Down
111 changes: 111 additions & 0 deletions src/game_battlealgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ Game_BattleAlgorithm::AlgorithmBase::AlgorithmBase(Type ty, Game_Battler* source
party_target = target;
}

int Game_BattleAlgorithm::AlgorithmBase::GetActionType() {
return 0;
}

int Game_BattleAlgorithm::AlgorithmBase::GetActionId() {
return 0;
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved
}

void Game_BattleAlgorithm::AlgorithmBase::Reset() {
hp = 0;
sp = 0;
Expand Down Expand Up @@ -185,7 +193,18 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplySpEffect() {
// Only absorb the sp that were left
source->ChangeSp(-sp);
}

Game_Battle::ManiacBattleHook(
Game_Interpreter_Battle::StatChange,
target->GetType() == Game_Battler::Type_Enemy,
target->GetPartyIndex(),
target->GetDisplayX(),
target->GetDisplayY(),
3,
sp
);
}

return sp;
}

Expand All @@ -198,6 +217,16 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyAtkEffect() {
if (IsAbsorbAtk()) {
source->ChangeAtkModifier(-atk);
}

Game_Battle::ManiacBattleHook(
Game_Interpreter_Battle::StatChange,
target->GetType() == Game_Battler::Type_Enemy,
target->GetPartyIndex(),
target->GetDisplayX(),
target->GetDisplayY(),
4,
atk
);
}
return atk;
}
Expand All @@ -211,6 +240,16 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyDefEffect() {
if (IsAbsorbDef()) {
source->ChangeDefModifier(-def);
}

Game_Battle::ManiacBattleHook(
Game_Interpreter_Battle::StatChange,
target->GetType() == Game_Battler::Type_Enemy,
target->GetPartyIndex(),
target->GetDisplayX(),
target->GetDisplayY(),
5,
def
);
}
return def;
}
Expand All @@ -224,6 +263,16 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplySpiEffect() {
if (IsAbsorbSpi()) {
source->ChangeSpiModifier(-spi);
}

Game_Battle::ManiacBattleHook(
Game_Interpreter_Battle::StatChange,
target->GetType() == Game_Battler::Type_Enemy,
target->GetPartyIndex(),
target->GetDisplayX(),
target->GetDisplayY(),
6,
spi
);
}
return spi;
}
Expand All @@ -237,6 +286,16 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyAgiEffect() {
if (IsAbsorbAgi()) {
source->ChangeAgiModifier(-agi);
}

Game_Battle::ManiacBattleHook(
Game_Interpreter_Battle::StatChange,
target->GetType() == Game_Battler::Type_Enemy,
target->GetPartyIndex(),
target->GetDisplayX(),
target->GetDisplayY(),
7,
agi
);
}
return agi;
}
Expand Down Expand Up @@ -532,6 +591,10 @@ AlgorithmBase(Type::None, source, source) {
// no-op
}

int Game_BattleAlgorithm::None::GetActionId() {
return 7;
}

Game_BattleAlgorithm::Normal::Normal(Game_Battler* source, Game_Battler* target, int hits_multiplier, Style style) :
AlgorithmBase(Type::Normal, source, target), hits_multiplier(hits_multiplier)
{
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -849,6 +912,14 @@ Game_BattleAlgorithm::Skill::Skill(Game_Battler* source, const lcf::rpg::Skill&
{
}

int Game_BattleAlgorithm::Skill::GetActionType() {
return 1;
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved
}

int Game_BattleAlgorithm::Skill::GetActionId() {
return skill.ID;
}

void Game_BattleAlgorithm::Skill::Init() {
}

Expand Down Expand Up @@ -1236,6 +1307,14 @@ Game_BattleAlgorithm::Item::Item(Game_Battler* source, Game_Party_Base* target,
// no-op
}

int Game_BattleAlgorithm::Item::GetActionType() {
return 3;
}

int Game_BattleAlgorithm::Item::GetActionId() {
return item.ID;
}

bool Game_BattleAlgorithm::Item::vStart() {
Main_Data::game_party->ConsumeItemUse(item.ID);
return true;
Expand Down Expand Up @@ -1340,6 +1419,10 @@ Game_BattleAlgorithm::Defend::Defend(Game_Battler* source) :
source->SetIsDefending(true);
}

int Game_BattleAlgorithm::Defend::GetActionId() {
return 2;
}

std::string Game_BattleAlgorithm::Defend::GetStartMessage(int line) const {
if (line == 0) {
if (Feature::HasRpg2kBattleSystem()) {
Expand All @@ -1360,6 +1443,10 @@ AlgorithmBase(Type::Observe, source, source) {
// no-op
}

int Game_BattleAlgorithm::Observe::GetActionId() {
return 3;
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved
}

std::string Game_BattleAlgorithm::Observe::GetStartMessage(int line) const {
if (line == 0) {
if (Feature::HasRpg2kBattleSystem()) {
Expand All @@ -1376,6 +1463,10 @@ AlgorithmBase(Type::Charge, source, source) {
// no-op
}

int Game_BattleAlgorithm::Charge::GetActionId() {
return 4;
}

std::string Game_BattleAlgorithm::Charge::GetStartMessage(int line) const {
if (line == 0) {
if (Feature::HasRpg2kBattleSystem()) {
Expand All @@ -1396,6 +1487,10 @@ AlgorithmBase(Type::SelfDestruct, source, target) {
// no-op
}

int Game_BattleAlgorithm::SelfDestruct::GetActionId() {
return 5;
}

std::string Game_BattleAlgorithm::SelfDestruct::GetStartMessage(int line) const {
if (line == 0) {
if (Feature::HasRpg2kBattleSystem()) {
Expand Down Expand Up @@ -1450,6 +1545,10 @@ Game_BattleAlgorithm::Escape::Escape(Game_Battler* source) :
// no-op
}

int Game_BattleAlgorithm::Escape::GetActionId() {
return 6;
}

std::string Game_BattleAlgorithm::Escape::GetStartMessage(int line) const {
if (line == 0) {
if (Feature::HasRpg2kBattleSystem()) {
Expand Down Expand Up @@ -1487,6 +1586,14 @@ AlgorithmBase(Type::Transform, source, source), new_monster_id(new_monster_id) {
// no-op
}

int Game_BattleAlgorithm::Transform::GetActionType() {
return 2;
}

int Game_BattleAlgorithm::Transform::GetActionId() {
return new_monster_id;
}

std::string Game_BattleAlgorithm::Transform::GetStartMessage(int line) const {
if (line == 0 && Feature::HasRpg2kBattleSystem()) {
auto* enemy = lcf::ReaderUtil::GetElement(lcf::Data::enemies, new_monster_id);
Expand All @@ -1509,3 +1616,7 @@ AlgorithmBase(Type::DoNothing, source, source) {
// no-op
}

int Game_BattleAlgorithm::DoNothing::GetActionId() {
return 7;
}

Loading
Loading