Skip to content

Commit

Permalink
Merge pull request #1439 from fmatthew5876/fix_skill_usable
Browse files Browse the repository at this point in the history
Various engine logic fixes
  • Loading branch information
carstene1ns committed Nov 1, 2018
2 parents d2a34c4 + c0daba9 commit 937401d
Show file tree
Hide file tree
Showing 28 changed files with 249 additions and 172 deletions.
2 changes: 1 addition & 1 deletion src/fps_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void FpsOverlay::Draw() {
// Always drawn when speedup is on independent of FPS
if (last_speed_mod > 1) {
if (speedup_dirty) {
std::string text = "> x" + Utils::ToString(last_speed_mod);
std::string text = "> x" + std::to_string(last_speed_mod);

Rect rect = Font::Default()->GetSize(text);

Expand Down
8 changes: 8 additions & 0 deletions src/game_battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ void Game_Battle::Quit() {
(*it)->SetBattleAlgorithm(BattleAlgorithmRef());
}

Main_Data::game_party->IncBattleCount();
switch (Game_Temp::battle_result) {
case Game_Temp::BattleVictory: Main_Data::game_party->IncWinCount(); break;
case Game_Temp::BattleEscape: Main_Data::game_party->IncRunCount(); break;
case Game_Temp::BattleDefeat: Main_Data::game_party->IncDefeatCount(); break;
case Game_Temp::BattleAbort: break;
}

page_executed.clear();
page_can_run.clear();

Expand Down
22 changes: 8 additions & 14 deletions src/game_battlealgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,15 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetAttackFailureMessage(const s
}

std::string Game_BattleAlgorithm::AlgorithmBase::GetHpSpRecoveredMessage(int value, const std::string& points) const {
std::stringstream ss;

if (Player::IsRPG2kE()) {
ss << value;
return Utils::ReplacePlaceholders(
Data::terms.hp_recovery,
{'S', 'V', 'U'},
{GetTarget()->GetName(), ss.str(), points}
{GetTarget()->GetName(), std::to_string(value), points}
);
}
else {
std::stringstream ss;
std::string particle, particle2, space = "";

ss << GetTarget()->GetName();
Expand Down Expand Up @@ -282,17 +280,16 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetHpSpAbsorbedMessage(int valu
const std::string& message = target_is_ally ?
Data::terms.actor_hp_absorbed :
Data::terms.enemy_hp_absorbed;
std::stringstream ss;

if (Player::IsRPG2kE()) {
ss << value;
return Utils::ReplacePlaceholders(
message,
{'S', 'O', 'V', 'U'},
{GetSource()->GetName(), GetTarget()->GetName(), ss.str(), points}
{GetSource()->GetName(), GetTarget()->GetName(), std::to_string(value), points}
);
}
else {
std::stringstream ss;
std::string particle, particle2, space = "";

ss << GetTarget()->GetName();
Expand All @@ -319,17 +316,15 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetDamagedMessage() const {
Data::terms.enemy_damaged;
int value = GetAffectedHp();

std::stringstream ss;

if (Player::IsRPG2kE()) {
ss << value;
return Utils::ReplacePlaceholders(
message,
{'S', 'V', 'U'},
{GetTarget()->GetName(), ss.str(), Data::terms.health_points}
{GetTarget()->GetName(), std::to_string(value), Data::terms.health_points}
);
}
else {
std::stringstream ss;
std::string particle, space = "";
ss << GetTarget()->GetName();

Expand All @@ -348,17 +343,16 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetParameterChangeMessage(bool
const std::string& message = is_positive ?
Data::terms.parameter_increase :
Data::terms.parameter_decrease;
std::stringstream ss;

if (Player::IsRPG2kE()) {
ss << value;
return Utils::ReplacePlaceholders(
message,
{'S', 'V', 'U'},
{GetTarget()->GetName(), ss.str(), points}
{GetTarget()->GetName(), std::to_string(value), points}
);
}
else {
std::stringstream ss;
std::string particle, particle2, space = "";
ss << GetTarget()->GetName();

Expand Down
3 changes: 3 additions & 0 deletions src/game_battler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "game_party.h"
#include "game_party_base.h"
#include "game_switches.h"
#include "game_system.h"
#include "util_macro.h"
#include "main_data.h"
#include "utils.h"
Expand Down Expand Up @@ -311,8 +312,10 @@ bool Game_Battler::UseSkill(int skill_id) {
}
}
} else if (skill->type == RPG::Skill::Type_teleport || skill->type == RPG::Skill::Type_escape) {
Game_System::SePlay(skill->sound_effect);
was_used = true;
} else if (skill->type == RPG::Skill::Type_switch) {
Game_System::SePlay(skill->sound_effect);
Game_Switches[skill->switch_id] = true;
was_used = true;
}
Expand Down
15 changes: 10 additions & 5 deletions src/game_character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,10 @@ bool Game_Character::IsStopping() const {

bool Game_Character::MakeWay(int x, int y, int d) const {
if (d > 3) {
int dx = (d == UpRight || d == DownRight) - (d == DownLeft || d == UpLeft);
int dy = (d == DownRight || d == DownLeft) - (d == UpRight || d == UpLeft);
return ((MakeWay(x, y, dy + 1) && MakeWay(x, y + dy, -dx + 2)) ||
(MakeWay(x, y, -dx + 2) && MakeWay(x + dx, y, dy + 1)));
return MakeWayDiagonal(x, y, d);
}

return Game_Map::MakeWay(x, y, d, *this);
return Game_Map::MakeWay(x, y, d, *this, false);
}

bool Game_Character::IsLandable(int x, int y) const
Expand Down Expand Up @@ -954,3 +951,11 @@ int Game_Character::ReverseDir(int dir) {
{ Down, Left, Up, Right, DownLeft, UpLeft, UpRight, DownRight };
return reversed[dir];
}


bool Game_Character::MakeWayDiagonal(int x, int y, int d) const {
int dx = (d == UpRight || d == DownRight) - (d == DownLeft || d == UpLeft);
int dy = (d == DownRight || d == DownLeft) - (d == UpRight || d == UpLeft);
return ((MakeWay(x, y, dy + 1) && MakeWay(x, y + dy, -dx + 2)) ||
(MakeWay(x, y, -dx + 2) && MakeWay(x + dx, y, dy + 1)));
}
1 change: 1 addition & 0 deletions src/game_character.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ class Game_Character {
static Game_Character* GetCharacter(int character_id, int event_id);

protected:
bool MakeWayDiagonal(int x, int y, int d) const;
virtual void UpdateSelfMovement();
void UpdateJump();

Expand Down
3 changes: 3 additions & 0 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ void Game_Interpreter::Update() {
if (Main_Data::game_player->IsBoardingOrUnboarding())
break;

if (Main_Data::game_player->InVehicle() && Main_Data::game_player->GetVehicle()->IsAscendingOrDescending())
break;

if (Game_Message::message_waiting)
break;
} else {
Expand Down
1 change: 1 addition & 0 deletions src/game_interpreter_battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ bool Game_Interpreter_Battle::CommandChangeMonsterHP(RPG::EventCommand const& co
enemy.ChangeHp(change);

if (enemy.IsDead()) {
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_EnemyKill));
Game_Battle::SetNeedRefresh(true);
}

Expand Down
4 changes: 2 additions & 2 deletions src/game_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,14 @@ static CollisionResult TestCollisionDuringMove(
return NoCollision;
}

bool Game_Map::MakeWay(int x, int y, int d, const Game_Character& self) {
bool Game_Map::MakeWay(int x, int y, int d, const Game_Character& self, bool force_through) {
int new_x = RoundX(x + (d == Game_Character::Right ? 1 : d == Game_Character::Left ? -1 : 0));
int new_y = RoundY(y + (d == Game_Character::Down ? 1 : d == Game_Character::Up ? -1 : 0));

if (!Game_Map::IsValid(new_x, new_y))
return false;

if (self.GetThrough()) return true;
if (self.GetThrough() || force_through) return true;

// A character can move to a position with an impassable tile by
// standing on top of an event below it. These flags track whether
Expand Down
3 changes: 2 additions & 1 deletion src/game_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ namespace Game_Map {
* @param y tile y.
* @param d direction
* @param self Character to move.
* @param force_through act as if self.SetThrough() == true
* @return whether is passable.
*/
bool MakeWay(int x, int y, int d, const Game_Character& self);
bool MakeWay(int x, int y, int d, const Game_Character& self, bool force_through);

/**
* Gets if a tile coordinate is passable in a direction.
Expand Down
Loading

0 comments on commit 937401d

Please sign in to comment.