Permalink
Browse files

RPG2k3 everybody get damages if anyone does his turn

RPG2k Message Delay fixed
Cleanup ConditionApply() and fixed damage calculation
  • Loading branch information...
Tondorian committed Mar 12, 2016
1 parent 97ee082 commit 4e501f6b266f2e9e77d24151d4714772d1809789
Showing with 54 additions and 37 deletions.
  1. +29 −26 src/game_battler.cpp
  2. +9 −3 src/scene_battle_rpg2k.cpp
  3. +16 −8 src/scene_battle_rpg2k3.cpp
View
@@ -330,34 +330,37 @@ static bool non_permanent(int state_id) {
int Game_Battler::ApplyConditions()
{
int damageTaken = 0;
std::vector<int16_t> inflictedStates = this->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 = this->GetHp();
int source_sp = this->GetSp();
int src_hp = 0;
int src_sp = 0;
if (state.hp_change_type == state.ChangeType_lose) {
src_hp = -std::min(source_hp + 1, hp);
}
else {
src_hp = std::min(source_hp, hp);
}
if (state.sp_change_type == state.ChangeType_lose) {
source_sp = -std::min(source_sp, sp);
}
else {
source_sp = std::min(source_sp, sp);
}
this->ChangeHp(src_hp);
this->ChangeSp(src_sp);
damageTaken += src_hp;
for (int16_t inflicted : GetInflictedStates()) {
RPG::State state = Data::states[inflicted - 1];
int hp = state.hp_change_val + (int)(std::ceil(GetMaxHp() * state.hp_change_max / 100.0));
int sp = state.sp_change_val + (int)(std::ceil(GetMaxHp() * state.sp_change_max / 100.0));
int source_hp = this->GetHp();
int source_sp = this->GetSp();
int src_hp = 0;
int src_sp = 0;
if (state.hp_change_type == state.ChangeType_lose) {
src_hp = -std::min(source_hp + 1, hp);
}
else if(state.hp_change_type == state.ChangeType_gain) {
src_hp = std::min(source_hp, hp);
}
else {
src_hp = 0;
}
if (state.sp_change_type == state.ChangeType_lose) {
source_sp = -std::min(source_sp, sp);
}
else if(state.sp_change_type == state.ChangeType_gain) {
source_sp = std::min(source_sp, sp);
}
else {
source_sp = 0;
}
this->ChangeHp(src_hp);
this->ChangeSp(src_sp);
damageTaken += src_hp;
}
return damageTaken;
return -damageTaken;
}
View
@@ -36,8 +36,8 @@
#include "scene_gameover.h"
Scene_Battle_Rpg2k::Scene_Battle_Rpg2k() : Scene_Battle(),
battle_action_wait(30),
battle_action_state(BattleActionState_Start)
battle_action_wait(0),
battle_action_state(BattleActionState_ConditionHeal)
{
}
@@ -371,21 +371,27 @@ bool Scene_Battle_Rpg2k::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase
std::vector<int16_t> states_to_heal = action->GetSource()->NextBattleTurn();
std::vector<int16_t> states_remaining = action->GetSource()->GetInflictedStates();
action->GetSource()->ApplyConditions();
bool message_to_show = false;
if (!states_to_heal.empty() || !states_remaining.empty()) {
battle_message_window->Clear();
for (std::vector<int16_t>::iterator it = states_to_heal.begin(); it != states_to_heal.end(); ++it) {
if (!Data::states[(*it) - 1].message_recovery.empty()) {
battle_message_window->Push(action->GetSource()->GetName() + Data::states[(*it) - 1].message_recovery);
message_to_show = true;
}
}
for (std::vector<int16_t>::iterator it = states_remaining.begin(); it != states_remaining.end(); ++it) {
if (!Data::states[(*it) - 1].message_affected.empty()) {
battle_message_window->Push(action->GetSource()->GetName() + Data::states[(*it) - 1].message_affected);
message_to_show = true;
}
}
if (battle_message_window->GetLineCount() != 0) {
if (message_to_show) {
battle_action_wait = 30;
}
else {
battle_action_wait = 0;
}
}
}
@@ -532,14 +532,22 @@ bool Scene_Battle_Rpg2k3::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBas
if (action->IsFirstAttack() && action->GetStartSe()) {
Game_System::SePlay(*action->GetStartSe());

This comment has been minimized.

Show comment
Hide comment
@Ghabry

Ghabry Mar 13, 2016

The damage applying is still depending on "action->GetStartSe()".

@Ghabry

Ghabry Mar 13, 2016

The damage applying is still depending on "action->GetStartSe()".

int damageTaken = action->GetSource()->ApplyConditions();
if (damageTaken != 0) {
DrawFloatText(
action->GetTarget()->GetBattleX(),
action->GetTarget()->GetBattleY(),
0,
boost::lexical_cast<std::string>(damageTaken),
30);
std::vector<Game_Battler*> battlers;
Main_Data::game_party->GetBattlers(battlers);
Main_Data::game_enemyparty->GetBattlers(battlers);
for (auto& b : battlers)
{
int damageTaken = b->ApplyConditions();
if (damageTaken != 0) {
DrawFloatText(
b->GetBattleX(),
b->GetBattleY(),
0,
boost::lexical_cast<std::string>(damageTaken),
30);
}
}
}

0 comments on commit 4e501f6

Please sign in to comment.