Skip to content

New Database terms for Maniacs #3371

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ add_library(${PROJECT_NAME} OBJECT
src/baseui.h
src/battle_animation.cpp
src/battle_animation.h
src/battle_message.cpp
src/battle_message.h
src/bitmap.cpp
src/bitmapfont.h
src/bitmapfont_glyph.h
Expand Down Expand Up @@ -192,6 +190,8 @@ add_library(${PROJECT_NAME} OBJECT
src/game_map.h
src/game_message.cpp
src/game_message.h
src/game_message_terms.cpp
src/game_message_terms.h
src/game_party_base.cpp
src/game_party_base.h
src/game_party.cpp
Expand Down
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ libeasyrpg_player_a_SOURCES = \
src/baseui.h \
src/battle_animation.cpp \
src/battle_animation.h \
src/battle_message.cpp \
src/battle_message.h \
src/bitmap.cpp \
src/bitmap.h \
src/bitmapfont.h \
Expand Down Expand Up @@ -168,6 +166,8 @@ libeasyrpg_player_a_SOURCES = \
src/game_map.h \
src/game_message.cpp \
src/game_message.h \
src/game_message_terms.cpp \
src/game_message_terms.h \
src/game_party.cpp \
src/game_party.h \
src/game_party_base.cpp \
Expand Down
49 changes: 4 additions & 45 deletions src/game_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "attribute.h"
#include "rand.h"
#include "algo.h"
#include "game_message_terms.h"

constexpr int max_level_2k = 50;
constexpr int max_level_2k3 = 99;
Expand Down Expand Up @@ -274,7 +275,7 @@ bool Game_Actor::LearnSkill(int skill_id, PendingMessage* pm) {
std::sort(data.skills.begin(), data.skills.end());

if (pm) {
pm->PushLine(GetLearningMessage(*skill));
pm->PushLine(ActorMessage::GetLearningMessage(*this, *skill));
}

return true;
Expand Down Expand Up @@ -790,56 +791,14 @@ void Game_Actor::SetLevel(int _level) {

}

std::string Game_Actor::GetLevelUpMessage(int new_level) const {
std::stringstream ss;
if (Player::IsRPG2k3E()) {
ss << GetName();
ss << " " << lcf::Data::terms.level_up << " ";
ss << " " << lcf::Data::terms.level << " " << new_level;
return ss.str();
} else if (Player::IsRPG2kE()) {
ss << new_level;
return Utils::ReplacePlaceholders(
lcf::Data::terms.level_up,
Utils::MakeArray('S', 'V', 'U'),
Utils::MakeSvArray(GetName(), ss.str(), lcf::Data::terms.level)
);
} else {
std::string particle, space = "";
if (Player::IsCP932()) {
particle = "は";
space += " ";
}
else {
particle = " ";
}
ss << GetName();
ss << particle << lcf::Data::terms.level << " ";
ss << new_level << space << lcf::Data::terms.level_up;
return ss.str();
}
}

std::string Game_Actor::GetLearningMessage(const lcf::rpg::Skill& skill) const {
if (Player::IsRPG2kE()) {
return Utils::ReplacePlaceholders(
lcf::Data::terms.skill_learned,
Utils::MakeArray('S', 'O'),
Utils::MakeSvArray(GetName(), skill.name)
);
}

return ToString(skill.name) + (Player::IsRPG2k3E() ? " " : "") + ToString(lcf::Data::terms.skill_learned);
}

void Game_Actor::ChangeLevel(int new_level, PendingMessage* pm) {
int old_level = GetLevel();
SetLevel(new_level);
new_level = GetLevel(); // Level adjusted to max

if (new_level > old_level) {
if (pm) {
pm->PushLine(GetLevelUpMessage(new_level));
pm->PushLine(ActorMessage::GetLevelUpMessage(*this, new_level));
}

// Learn new skills
Expand Down Expand Up @@ -1112,7 +1071,7 @@ void Game_Actor::ChangeClass(int new_class_id,

SetLevel(new_level);
if (pm && new_level > 1 && (new_level > prev_level || new_skill != eSkillNoChange)) {
pm->PushLine(GetLevelUpMessage(new_level));
pm->PushLine(ActorMessage::GetLevelUpMessage(*this, new_level));
}

// RPG_RT always resets EXP when class is changed, even if level unchanged.
Expand Down
3 changes: 0 additions & 3 deletions src/game_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,6 @@ class Game_Actor final : public Game_Battler {
*/
float GetCriticalHitChance(Weapon weapon = WeaponAll) const override;

std::string GetLevelUpMessage(int new_level) const;
std::string GetLearningMessage(const lcf::rpg::Skill& skill) const;

BattlerType GetType() const override;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/game_battlealgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "game_switches.h"
#include "game_system.h"
#include "main_data.h"
#include "battle_message.h"
#include "game_message_terms.h"
#include "output.h"
#include "player.h"
#include <lcf/reader_util.h>
Expand Down
118 changes: 117 additions & 1 deletion src/battle_message.cpp → src/game_message_terms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,78 @@
* You should have received a copy of the GNU General Public License
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#include "battle_message.h"
#include "game_message_terms.h"
#include "player.h"
#include "utils.h"
#include "algo.h"
#include "game_actor.h"
#include "game_battler.h"
#include <lcf/rpg/state.h>
#include <lcf/data.h>
#include <lcf/reader_util.h>
#include "feature.h"

namespace ActorMessage {

std::string GetLevelUpMessage(const Game_Actor& actor, int new_level) {
std::stringstream ss;
if (Player::IsRPG2k3E()) {
if (Player::IsPatchManiac() && !lcf::Data::terms.maniac_level_up_a.empty()) {
ss << lcf::Data::terms.maniac_level_up_a << " ";
}
ss << actor.GetName();
ss << " " << lcf::Data::terms.level_up << " ";
ss << " " << lcf::Data::terms.level;

if (Player::IsPatchManiac() && !lcf::Data::terms.maniac_level_up_b.empty()) {
ss << " " << lcf::Data::terms.maniac_level_up_b;
}
ss << " " << new_level;
if (Player::IsPatchManiac() && !lcf::Data::terms.maniac_level_up_c.empty()) {
ss << lcf::Data::terms.maniac_level_up_c;
}
return ss.str();
} else if (Player::IsRPG2kE()) {
ss << new_level;
return Utils::ReplacePlaceholders(
lcf::Data::terms.level_up,
Utils::MakeArray('S', 'V', 'U'),
Utils::MakeSvArray(actor.GetName(), ss.str(), lcf::Data::terms.level)
);
} else {
std::string particle, space = "";
if (Player::IsCP932()) {
particle = "は";
space += " ";
} else {
particle = " ";
}
ss << actor.GetName();
ss << particle << lcf::Data::terms.level << " ";
ss << new_level << space << lcf::Data::terms.level_up;
return ss.str();
}
}

std::string GetLearningMessage(const Game_Actor& actor, const lcf::rpg::Skill& skill) {
if (Player::IsRPG2kE()) {
return Utils::ReplacePlaceholders(
lcf::Data::terms.skill_learned,
Utils::MakeArray('S', 'O'),
Utils::MakeSvArray(actor.GetName(), skill.name)
);
}
std::stringstream ss;
if (Player::IsPatchManiac() && !lcf::Data::terms.maniac_skill_learned_a.empty()) {
ss << lcf::Data::terms.maniac_skill_learned_a << " ";
}
ss << ToString(skill.name) + (Player::IsRPG2k3E() ? " " : "");
ss << ToString(lcf::Data::terms.skill_learned);
return ss.str();
}

} // namespace ActorMessage

namespace BattleMessage {

static std::string GetStateMessage(std::string_view target_name, std::string_view message) {
Expand Down Expand Up @@ -552,3 +614,57 @@ std::string GetEscapeStartMessage2k3(const Game_Battler& source) {
}

} // namespace BattleMessage

namespace PartyMessage {

std::string GetExperienceGainedMessage(int exp) {
if (Feature::HasPlaceholders()) {
return Utils::ReplacePlaceholders(
lcf::Data::terms.exp_received,
Utils::MakeArray('V', 'U'),
Utils::MakeSvArray(std::to_string(exp), lcf::Data::terms.exp_short)
);
}
std::string space = Player::IsRPG2k3E() ? " " : "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this space here and in itemreceived a bugfix? I cannot see this in the old code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaah i missed it because it was not on a red line. Can you remove it? Is unused now ;)

std::stringstream ss;
if (Player::IsPatchManiac() && !lcf::Data::terms.maniac_exp_received_a.empty()) {
ss << lcf::Data::terms.maniac_exp_received_a << " ";
}
ss << exp << space << lcf::Data::terms.exp_received;
return ss.str();
}

std::string GetGoldReceivedMessage(int money) {
if (Feature::HasPlaceholders()) {
return Utils::ReplacePlaceholders(
lcf::Data::terms.gold_recieved_a,
Utils::MakeArray('V', 'U'),
Utils::MakeSvArray(std::to_string(money), lcf::Data::terms.gold)
);
}
std::stringstream ss;
ss << lcf::Data::terms.gold_recieved_a << " " << money << lcf::Data::terms.gold << lcf::Data::terms.gold_recieved_b;
return ss.str();
}

std::string GetItemReceivedMessage(const lcf::rpg::Item* item) {
// No Output::Warning needed here, reported later when the item is added
std::string_view item_name = item ? std::string_view(item->name) : std::string_view("??? BAD ITEM ???");

if (Feature::HasPlaceholders()) {
return Utils::ReplacePlaceholders(
lcf::Data::terms.item_recieved,
Utils::MakeArray('S'),
Utils::MakeSvArray(item_name)
);
}
std::string space = Player::IsRPG2k3E() ? " " : "";
std::stringstream ss;
if (Player::IsPatchManiac() && !lcf::Data::terms.maniac_item_received_a.empty()) {
ss << lcf::Data::terms.maniac_item_received_a << " ";
}
ss << item_name << space << lcf::Data::terms.item_recieved;
return ss.str();
}

} // namespace PartyMessage
23 changes: 21 additions & 2 deletions src/battle_message.h → src/game_message_terms.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,24 @@
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef EP_BATTLE_MESSAGE_H
#define EP_BATTLE_MESSAGE_H
#ifndef EP_GAME_MESSAGE_TERMS_H
#define EP_GAME_MESSAGE_TERMS_H

#include <string>
#include "string_view.h"
#include <lcf/rpg/fwd.h>

class Game_Actor;
class Game_Battler;

namespace ActorMessage {

std::string GetLevelUpMessage(const Game_Actor& actor, int new_level);

std::string GetLearningMessage(const Game_Actor& actor, const lcf::rpg::Skill& skill);

} // namespace ActorMessage

namespace BattleMessage {

std::string GetStateInflictMessage(const Game_Battler& target, const lcf::rpg::State& state);
Expand Down Expand Up @@ -116,4 +125,14 @@ std::string GetEscapeStartMessage2k3(const Game_Battler& source);

} // namespace BattleMessage

namespace PartyMessage {

std::string GetExperienceGainedMessage(int exp);

std::string GetGoldReceivedMessage(int money);

std::string GetItemReceivedMessage(const lcf::rpg::Item* item);

} // namespace PartyMessage

#endif
58 changes: 10 additions & 48 deletions src/scene_battle_rpg2k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "rand.h"
#include "autobattle.h"
#include "enemyai.h"
#include "battle_message.h"
#include "game_message_terms.h"
#include "feature.h"

Scene_Battle_Rpg2k::Scene_Battle_Rpg2k(const BattleArgs& args) :
Expand Down Expand Up @@ -1948,62 +1948,24 @@ bool Scene_Battle_Rpg2k::CheckWait() {
}

void Scene_Battle_Rpg2k::PushExperienceGainedMessage(PendingMessage& pm, int exp) {
if (Feature::HasPlaceholders()) {
pm.PushLine(
Utils::ReplacePlaceholders(
lcf::Data::terms.exp_received,
Utils::MakeArray('V', 'U'),
Utils::MakeSvArray(std::to_string(exp), lcf::Data::terms.exp_short)
) + Player::escape_symbol + "."
);
}
else {
std::stringstream ss;
ss << exp << lcf::Data::terms.exp_received << Player::escape_symbol << ".";
pm.PushLine(ss.str());
}
pm.PushLine(
PartyMessage::GetExperienceGainedMessage(exp)
+ Player::escape_symbol + ".");
}

void Scene_Battle_Rpg2k::PushGoldReceivedMessage(PendingMessage& pm, int money) {
pm.PushLine(
PartyMessage::GetGoldReceivedMessage(money)
+ Player::escape_symbol + ".");

if (Feature::HasPlaceholders()) {
pm.PushLine(
Utils::ReplacePlaceholders(
lcf::Data::terms.gold_recieved_a,
Utils::MakeArray('V', 'U'),
Utils::MakeSvArray(std::to_string(money), lcf::Data::terms.gold)
) + Player::escape_symbol + "."
);
}
else {
std::stringstream ss;
ss << lcf::Data::terms.gold_recieved_a << " " << money << lcf::Data::terms.gold << lcf::Data::terms.gold_recieved_b << Player::escape_symbol << ".";
pm.PushLine(ss.str());
}
}

void Scene_Battle_Rpg2k::PushItemRecievedMessages(PendingMessage& pm, std::vector<int> drops) {
std::stringstream ss;

for (std::vector<int>::iterator it = drops.begin(); it != drops.end(); ++it) {
const lcf::rpg::Item* item = lcf::ReaderUtil::GetElement(lcf::Data::items, *it);
// No Output::Warning needed here, reported later when the item is added
std::string_view item_name = item ? std::string_view(item->name) : std::string_view("??? BAD ITEM ???");

if (Feature::HasPlaceholders()) {
pm.PushLine(
Utils::ReplacePlaceholders(
lcf::Data::terms.item_recieved,
Utils::MakeArray('S'),
Utils::MakeSvArray(item_name)
) + Player::escape_symbol + "."
);
}
else {
ss.str("");
ss << item_name << lcf::Data::terms.item_recieved << Player::escape_symbol << ".";
pm.PushLine(ss.str());
}
pm.PushLine(
PartyMessage::GetItemReceivedMessage(item)
+ Player::escape_symbol + ".");
}
}

Expand Down
Loading
Loading