-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Added Loyalty System (10.74) #4148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff
src/player.cpp
Outdated
|
||
bool Player::addLoyalty(int32_t points) | ||
{ | ||
if (loyaltyPoints == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not understand how this work, but why would you not allow adding loyalty points if loyaltyPoints is 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, my bad... I was using this as a "loyaltyEnabled" check... should I add a check if LOYALTY SYSTEM is enabled or allow users to give loyalty points even if the system is disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, but I think it doesn't matter, so just let it work even with loyalty system disabled
fixed an issue when advancing base skills/maglevel not syncing with bonus "loyalty" skills... now it's working as expected (cipbia)
@@ -334,6 +364,19 @@ float ConfigManager::getExperienceStage(uint32_t level) const | |||
return std::get<2>(*it); | |||
} | |||
|
|||
float ConfigManager::getLoyaltyBonus(uint16_t points) const | |||
{ | |||
auto it = std::find_if(loyaltyBonuses.begin(), loyaltyBonuses.end(), [points](LoyaltyBonuses::value_type bonus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto it = std::find_if(loyaltyBonuses.begin(), loyaltyBonuses.end(), [points](const auto& bonus) {
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should just be (auto bonus)
, otherwise 👍
|
||
uint16_t points = getNumber<uint16_t>(L, 2, 1); | ||
pushBoolean(L, player->addLoyalty(-points)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove newline
|
||
uint16_t points = getNumber<uint16_t>(L, 2, 1); | ||
pushBoolean(L, player->addLoyalty(points)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove newline
@@ -146,6 +151,16 @@ std::string Player::getDescription(int32_t lookDistance) const | |||
} else { | |||
s << " has no vocation."; | |||
} | |||
|
|||
if (g_config.getBoolean(ConfigManager::LOYALTY_SYSTEM) && loyaltyPoints >= 50) { | |||
if (sex == PLAYERSEX_FEMALE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use fmt::format?
@@ -126,6 +126,11 @@ std::string Player::getDescription(int32_t lookDistance) const | |||
} else { | |||
s << " You have no vocation."; | |||
} | |||
|
|||
if (g_config.getBoolean(ConfigManager::LOYALTY_SYSTEM) && loyaltyPoints >= 50) { | |||
s << " You are " << getLoyaltyTitleDescription(loyaltyPoints) << " " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use fmt::format?
|
||
count = static_cast<uint64_t>(amount); | ||
|
||
if (manaSpentFractional == (int)manaSpentFractional) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use static_cast and int32_t
@@ -135,6 +135,22 @@ experienceStages = { | |||
{ minlevel = 101, multiplier = 3 } | |||
} | |||
|
|||
-- Loyalty system | |||
loyaltyEnabled = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can drop this flag and let users effectively disable the loyalty system by removing all tiers.
could you leave some extra functions in LUA to be used in cyclopedia? I also think it would be better to move the descriptions to onLook instead of keeping them directly in the engine |
I'd have to rewrite this and make a new pull request (taking your comments in consideration), IIRC I stopped this because I was having issues with float values being inexact 👀 |
Pull Request Prelude
Changes Proposed
Missing:
Issues addressed:
#3871 Version 10.74 (The Loyalty System was introduced.)
Any comments would be highly appreciated. 😃