Skip to content
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

fix: remove bakragore icons talkaction #2828

Merged
merged 1 commit into from
Sep 6, 2024
Merged
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
6 changes: 1 addition & 5 deletions data/scripts/talkactions/god/icons_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ function bakragoreIcon.onSay(player, words, param)
end

if param == "remove" then
for i = 1, 10 do
if player:hasCondition(CONDITION_BAKRAGORE, i) then
player:removeCondition(CONDITION_BAKRAGORE, i)
end
end
player:removeIconBakragore()
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Removed all Bakragore icons.")
return true
end
Expand Down
14 changes: 14 additions & 0 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6209,6 +6209,20 @@ void Player::sendIconBakragore(const IconBakragore icon) {
}
}

void Player::removeBakragoreIcons() {
for (auto icon : magic_enum::enum_values<IconBakragore>()) {
if (hasCondition(CONDITION_BAKRAGORE, enumToValue(icon))) {
removeCondition(CONDITION_BAKRAGORE, CONDITIONID_DEFAULT, true);
}
}
}

void Player::removeBakragoreIcon(const IconBakragore icon) {
if (hasCondition(CONDITION_BAKRAGORE, enumToValue(icon))) {
removeCondition(CONDITION_BAKRAGORE, CONDITIONID_DEFAULT, true);
}
}

void Player::sendCyclopediaCharacterAchievements(uint16_t secretsUnlocked, std::vector<std::pair<Achievement, uint32_t>> achievementsUnlocked) {
if (client) {
client->sendCyclopediaCharacterAchievements(secretsUnlocked, achievementsUnlocked);
Expand Down
2 changes: 2 additions & 0 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,8 @@ class Player final : public Creature, public Cylinder, public Bankable {
void sendClosePrivate(uint16_t channelId);
void sendIcons();
void sendIconBakragore(const IconBakragore icon);
void removeBakragoreIcons();
void removeBakragoreIcon(const IconBakragore icon);
void sendClientCheck() const {
if (client) {
client->sendClientCheck();
Expand Down
19 changes: 19 additions & 0 deletions src/lua/functions/creatures/player/player_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4408,3 +4408,22 @@ int PlayerFunctions::luaPlayerSendIconBakragore(lua_State* L) {
pushBoolean(L, true);
return 1;
}

int PlayerFunctions::luaPlayerRemoveIconBakragore(lua_State* L) {
// player:removeIconBakragore(iconType or nil for remove all bakragore icons)
const auto &player = getUserdataShared<Player>(L, 1);
if (!player) {
lua_pushnil(L);
return 1;
}

auto iconType = getNumber<IconBakragore>(L, 2, IconBakragore::None);
if (iconType == IconBakragore::None) {
player->removeBakragoreIcons();
} else {
player->removeBakragoreIcon(iconType);
}

pushBoolean(L, true);
return 1;
}
2 changes: 2 additions & 0 deletions src/lua/functions/creatures/player/player_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ class PlayerFunctions final : LuaScriptInterface {
registerMethod(L, "Player", "takeScreenshot", PlayerFunctions::luaPlayerTakeScreenshot);

registerMethod(L, "Player", "sendIconBakragore", PlayerFunctions::luaPlayerSendIconBakragore);
registerMethod(L, "Player", "removeIconBakragore", PlayerFunctions::luaPlayerRemoveIconBakragore);

GroupFunctions::init(L);
GuildFunctions::init(L);
Expand Down Expand Up @@ -743,6 +744,7 @@ class PlayerFunctions final : LuaScriptInterface {

static int luaPlayerTakeScreenshot(lua_State* L);
static int luaPlayerSendIconBakragore(lua_State* L);
static int luaPlayerRemoveIconBakragore(lua_State* L);

friend class CreatureFunctions;
};
Loading