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

Conditions in Battles #815

Merged
merged 10 commits into from Mar 14, 2016
@@ -312,6 +312,21 @@ void Game_BattleAlgorithm::AlgorithmBase::SetTarget(Game_Battler* target) {
}
void Game_BattleAlgorithm::AlgorithmBase::Apply() {
std::vector<int16_t> inflictedStates = source->GetInflictedStates();
if (inflictedStates.size() != 0) {
for (int i = 0; i<inflictedStates.size(); ++i) {
RPG::State state = Data::states[inflictedStates[i]];
int hp = state.hp_change_val;
int sp = state.sp_change_val;
int source_hp = source->GetHp();
int source_sp = source->GetSp();

This comment has been minimized.

@carstene1ns

carstene1ns Mar 12, 2016

Member

Stray spaces detected.

@carstene1ns

carstene1ns Mar 12, 2016

Member

Stray spaces detected.

This comment has been minimized.

@Tondorian

Tondorian Mar 12, 2016

Member

Should be fixed

@Tondorian

Tondorian Mar 12, 2016

Member

Should be fixed

int src_hp = std::min(source_hp + 1, IsPositive() ? hp : -hp);
int src_sp = std::min(source_sp, IsPositive() ? sp : -sp);
source->ChangeHp(src_hp);
source->ChangeSp(src_sp);
}
}
if (GetAffectedHp() != -1) {
int hp = GetAffectedHp();
int target_hp = (*current_target)->GetHp();
@@ -644,7 +659,7 @@ bool Game_BattleAlgorithm::Skill::Execute() {
for (int i = 0; i < (int) skill.state_effects.size(); i++) {
if (!skill.state_effects[i])
continue;
if (!healing || rand() % 100 >= skill.hit)
if (!healing && rand() % 100 >= skill.hit)
continue;
this->success = true;
View
@@ -313,6 +313,10 @@ bool Scene_Battle_Rpg2k::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase
switch (battle_action_state) {
case BattleActionState_Start:
if (battle_action_wait--) {
return false;
}
battle_action_wait = 0;
battle_message_window->Clear();
if (!action->IsTargetValid()) {
@@ -358,22 +362,22 @@ bool Scene_Battle_Rpg2k::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase
Game_System::SePlay(*action->GetStartSe());
}
battle_action_state = BattleActionState_ConditionHeal;
battle_action_state = BattleActionState_Result;
break;
case BattleActionState_ConditionHeal:
if (battle_action_wait--) {
return false;
}
battle_action_wait = 0;
case BattleActionState_ConditionHeal:
if (action->IsFirstAttack()) {
std::vector<int16_t> states = action->GetSource()->NextBattleTurn();
if (!states.empty()) {
std::vector<int16_t> states_to_heal = action->GetSource()->NextBattleTurn();
std::vector<int16_t> states_remaining = action->GetSource()->GetInflictedStates();
if (!states_to_heal.empty() || !states_remaining.empty()) {
battle_message_window->Clear();
for (std::vector<int16_t>::iterator it = states.begin(); it != states.end(); ++it) {
for (std::vector<int16_t>::iterator it = states_to_heal.begin(); it != states_to_heal.end(); ++it) {
battle_message_window->Push(action->GetSource()->GetName() + Data::states[(*it) - 1].message_recovery);
}
for (std::vector<int16_t>::iterator it = states_remaining.begin(); it != states_remaining.end(); ++it) {
battle_message_window->Push(action->GetSource()->GetName() + Data::states[(*it) - 1].message_affected);
}
battle_action_wait = 30;
}
}
@@ -382,7 +386,7 @@ bool Scene_Battle_Rpg2k::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase
battle_action_state = BattleActionState_Finished;
}
else {
battle_action_state = BattleActionState_Result;
battle_action_state = BattleActionState_Start;
}
break;
@@ -450,12 +454,12 @@ bool Scene_Battle_Rpg2k::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase
}
if (action->TargetNext()) {
battle_action_state = BattleActionState_Start;
battle_action_state = BattleActionState_ConditionHeal;
return false;
}
// Reset variables
battle_action_state = BattleActionState_Start;
battle_action_state = BattleActionState_ConditionHeal;

This comment has been minimized.

@Ghabry

Ghabry Mar 12, 2016

Member

You changed all the battle_action_state transitions. This is super super risky, pls don't do this unless you are 100% certain this is required. Because this must be tested with every available battle action available (Normal, different items, different skills, defend) to proof that it doesn't break anything or added a subtil bug.

One problem I already noticed is, that you introduced some delay before everybodys turn.

@Ghabry

Ghabry Mar 12, 2016

Member

You changed all the battle_action_state transitions. This is super super risky, pls don't do this unless you are 100% certain this is required. Because this must be tested with every available battle action available (Normal, different items, different skills, defend) to proof that it doesn't break anything or added a subtil bug.

One problem I already noticed is, that you introduced some delay before everybodys turn.

This comment has been minimized.

@Tondorian

Tondorian Mar 12, 2016

Member

Yeah i needed to change them to get poisen effect working before the battlers attack.
think need to double check, if waiting is needed

@Tondorian

Tondorian Mar 12, 2016

Member

Yeah i needed to change them to get poisen effect working before the battlers attack.
think need to double check, if waiting is needed

This comment has been minimized.

@Ghabry

Ghabry Mar 12, 2016

Member

I reverted all the state changes and I only took your code from line 370 to 388 and it still works fine for me.

@Ghabry

Ghabry Mar 12, 2016

Member

I reverted all the state changes and I only took your code from line 370 to 388 and it still works fine for me.

This comment has been minimized.

@Tondorian

Tondorian Mar 12, 2016

Member

so it shows conditioneffct, Clean enemyAttacks, Damage clean to you?
Takes me 2h yesterday to get it shown correct

@Tondorian

Tondorian Mar 12, 2016

Member

so it shows conditioneffct, Clean enemyAttacks, Damage clean to you?
Takes me 2h yesterday to get it shown correct

This comment has been minimized.

@Ghabry

Ghabry Mar 12, 2016

Member

In my tests your state changes broke the message box. At the beginning it shows an empty message box with a delay and between battle actions, too.

And after an enemy finished his battle animation the delay got removed.

@Ghabry

Ghabry Mar 12, 2016

Member

In my tests your state changes broke the message box. At the beginning it shows an empty message box with a delay and between battle actions, too.

And after an enemy finished his battle animation the delay got removed.

return true;
}
@@ -792,11 +796,11 @@ bool Scene_Battle_Rpg2k::CheckWin() {
std::stringstream ss;
ss << exp << Data::terms.exp_received;
Game_Message::texts.push_back(ss.str());
ss.str("");
ss << Data::terms.gold_recieved_a << " " << money << Data::terms.gold << Data::terms.gold_recieved_b;
Game_Message::texts.push_back(ss.str());
if (money > 0) {
ss.str("");
ss << Data::terms.gold_recieved_a << " " << money << Data::terms.gold << Data::terms.gold_recieved_b;
Game_Message::texts.push_back(ss.str());
}
for (std::vector<int>::iterator it = drops.begin(); it != drops.end(); ++it) {
ss.str("");
ss << Data::items[*it - 1].name << Data::terms.item_recieved;
@@ -834,11 +834,11 @@ bool Scene_Battle_Rpg2k3::CheckWin() {
std::stringstream ss;
ss << exp << Data::terms.exp_received << "\f";
Game_Message::texts.push_back(ss.str());
ss.str("");
ss << Data::terms.gold_recieved_a << " " << money << Data::terms.gold << Data::terms.gold_recieved_b << "\f";
Game_Message::texts.push_back(ss.str());
if (money > 0) {
ss.str("");
ss << Data::terms.gold_recieved_a << " " << money << Data::terms.gold << Data::terms.gold_recieved_b << "\f";
Game_Message::texts.push_back(ss.str());
}
for(std::vector<int>::iterator it = drops.begin(); it != drops.end(); ++it) {
ss.str("");
ss << Data::items[*it - 1].name << Data::terms.item_recieved << "\f";
ProTip! Use n and p to navigate between commits in a pull request.