Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
luanluciano93 committed Sep 6, 2024
2 parents b0c04b4 + d4b1b61 commit fc2608b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
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 @@ -4412,3 +4412,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;
};

0 comments on commit fc2608b

Please sign in to comment.