Skip to content

Commit

Permalink
Merge branch 'main' into update-outfits-and-mounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Luan Luciano authored Mar 14, 2024
2 parents 98c1176 + d2a5b8f commit 7f53ac1
Show file tree
Hide file tree
Showing 28 changed files with 85 additions and 48 deletions.
2 changes: 1 addition & 1 deletion data-canary/monster/demons/fury.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Fury")
local monster = {}

monster.description = "a fury"
monster.experience = 3600
monster.experience = 4000
monster.outfit = {
lookType = 149,
lookHead = 94,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/demons/hellfire_fighter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Hellfire Fighter")
local monster = {}

monster.description = "a hellfire fighter"
monster.experience = 3120
monster.experience = 3400
monster.outfit = {
lookType = 243,
lookHead = 0,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/demons/hellflayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Hellflayer")
local monster = {}

monster.description = "a hellflayer"
monster.experience = 11000
monster.experience = 11720
monster.outfit = {
lookType = 856,
lookHead = 0,
Expand Down
4 changes: 2 additions & 2 deletions data-otservbr-global/monster/demons/juggernaut.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ monster.Bestiary = {
Oramond Dungeon, Grounds of Destruction and Halls of Ascension.",
}

monster.health = 20000
monster.maxHealth = 20000
monster.health = 18000
monster.maxHealth = 18000
monster.race = "blood"
monster.corpse = 6335
monster.speed = 170
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/demons/plaguesmith.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Plaguesmith")
local monster = {}

monster.description = "a plaguesmith"
monster.experience = 3555
monster.experience = 3800
monster.outfit = {
lookType = 247,
lookHead = 0,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/magicals/nightmare.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Nightmare")
local monster = {}

monster.description = "a nightmare"
monster.experience = 1666
monster.experience = 1800
monster.outfit = {
lookType = 245,
lookHead = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Ferumbras Mortal Shell")
local monster = {}

monster.description = "Ferumbras Mortal Shell"
monster.experience = 100000
monster.experience = 500000
monster.outfit = {
lookType = 229,
lookHead = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Mazoran")
local monster = {}

monster.description = "Mazoran"
monster.experience = 50000
monster.experience = 250000
monster.outfit = {
lookType = 842,
lookHead = 77,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Plagirath")
local monster = {}

monster.description = "Plagirath"
monster.experience = 50000
monster.experience = 250000
monster.outfit = {
lookType = 862,
lookHead = 84,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Ragiaz")
local monster = {}

monster.description = "Ragiaz"
monster.experience = 50000
monster.experience = 250000
monster.outfit = {
lookType = 862,
lookHead = 76,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Razzagorn")
local monster = {}

monster.description = "Razzagorn"
monster.experience = 50000
monster.experience = 250000
monster.outfit = {
lookType = 842,
lookHead = 78,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Shulgrax")
local monster = {}

monster.description = "Shulgrax"
monster.experience = 21000
monster.experience = 250000
monster.outfit = {
lookType = 842,
lookHead = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Tarbaz")
local monster = {}

monster.description = "Tarbaz"
monster.experience = 55000
monster.experience = 250000
monster.outfit = {
lookType = 842,
lookHead = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Zamulosh")
local monster = {}

monster.description = "Zamulosh"
monster.experience = 50000
monster.experience = 250000
monster.outfit = {
lookType = 862,
lookHead = 16,
Expand Down
4 changes: 2 additions & 2 deletions data-otservbr-global/monster/undeads/blightwalker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ monster.Bestiary = {
Locations = "Pits of Inferno, Edron (In the Vats during The Inquisition Quest), Roshamuul Prison, Grounds of Undeath.",
}

monster.health = 8900
monster.maxHealth = 8900
monster.health = 8100
monster.maxHealth = 8100
monster.race = "undead"
monster.corpse = 6353
monster.speed = 175
Expand Down
4 changes: 2 additions & 2 deletions data-otservbr-global/monster/undeads/hand_of_cursed_fate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ monster.Bestiary = {
Locations = "Pits of Inferno, The Battlefield, The Arcanum, The Blood Halls and The Crystal Caves.",
}

monster.health = 7500
monster.maxHealth = 7500
monster.health = 6600
monster.maxHealth = 6600
monster.race = "blood"
monster.corpse = 6311
monster.speed = 130
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/undeads/undead_dragon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ monster.elements = {
{ type = COMBAT_LIFEDRAIN, percent = 0 },
{ type = COMBAT_MANADRAIN, percent = 0 },
{ type = COMBAT_DROWNDAMAGE, percent = 100 },
{ type = COMBAT_ICEDAMAGE, percent = 50 },
{ type = COMBAT_ICEDAMAGE, percent = 90 },
{ type = COMBAT_HOLYDAMAGE, percent = -25 },
{ type = COMBAT_DEATHDAMAGE, percent = 100 },
}
Expand Down
2 changes: 1 addition & 1 deletion data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42216,7 +42216,6 @@
<attribute key="level" value="70"/>
<attribute key="unproperly" value="true"/>
<attribute key="weaponType" value="club"/>
ogre klubb
</attribute>
</item>
<item id="21220" name="RESERVED SPRITE"/>
Expand Down Expand Up @@ -75870,3 +75869,4 @@ Granted by TibiaGoals.com"/>
<attribute key="weight" value="120" />
</item>
</items>

6 changes: 5 additions & 1 deletion data/scripts/movements/snow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ local snow = MoveEvent()

function snow.onStepOut(creature, item, position, fromPosition)
local player = creature:getPlayer()
if player and player:isInGhostMode() then
if not player then
return true
end

if player:isInGhostMode() then
return true
end

Expand Down
29 changes: 17 additions & 12 deletions src/creatures/players/achievement/player_achievement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,7 @@
#include "kv/kv.hpp"

PlayerAchievement::PlayerAchievement(Player &player) :
m_player(player) {
auto unlockedAchievements = getUnlockedKV()->keys();
for (const auto &achievementName : unlockedAchievements) {
const Achievement &achievement = g_game().getAchievementByName(achievementName);
if (achievement.id == 0) {
g_logger().error("[{}] - Achievement {} not found.", __FUNCTION__, achievementName);
continue;
}

m_achievementsUnlocked.push_back({ achievement.id, getUnlockedKV()->get(achievementName)->getNumber() });
}
}
m_player(player) { }

bool PlayerAchievement::add(uint16_t id, bool message /* = true*/, uint32_t timestamp /* = 0*/) {
if (isUnlocked(id)) {
Expand Down Expand Up @@ -108,6 +97,22 @@ std::vector<std::pair<uint16_t, uint32_t>> PlayerAchievement::getUnlockedAchieve
return m_achievementsUnlocked;
}

void PlayerAchievement::loadUnlockedAchievements() {
const auto &unlockedAchievements = getUnlockedKV()->keys();
g_logger().debug("[{}] - Loading unlocked achievements: {}", __FUNCTION__, unlockedAchievements.size());
for (const auto &achievementName : unlockedAchievements) {
const Achievement &achievement = g_game().getAchievementByName(achievementName);
if (achievement.id == 0) {
g_logger().error("[{}] - Achievement {} not found.", __FUNCTION__, achievementName);
continue;
}

g_logger().debug("[{}] - Achievement {} found for player {}.", __FUNCTION__, achievementName, m_player.getName());

m_achievementsUnlocked.push_back({ achievement.id, getUnlockedKV()->get(achievementName)->getNumber() });
}
}

void PlayerAchievement::sendUnlockedSecretAchievements() {
std::vector<std::pair<Achievement, uint32_t>> m_achievementsUnlocked;
uint16_t unlockedSecret = 0;
Expand Down
1 change: 1 addition & 0 deletions src/creatures/players/achievement/player_achievement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class PlayerAchievement {
void addPoints(uint16_t toAddPoints);
void removePoints(uint16_t toRemovePoints);
std::vector<std::pair<uint16_t, uint32_t>> getUnlockedAchievements() const;
void loadUnlockedAchievements();
void sendUnlockedSecretAchievements();
const std::shared_ptr<KV> &getUnlockedKV();

Expand Down
12 changes: 10 additions & 2 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,15 @@ std::shared_ptr<Item> Game::transformItem(std::shared_ptr<Item> item, uint16_t n
uint16_t itemId = item->getID();
int32_t count = item->getSubType();

if (curType.id != newType.id) {
auto decaying = item->getDecaying();
// If the item is decaying, we need to transform it to the new item
if (decaying > DECAYING_FALSE && item->getDuration() <= 1) {
g_logger().debug("Decay duration old type {}, transformEquipTo {}, transformDeEquipTo {}", curType.decayTo, curType.transformEquipTo, curType.transformDeEquipTo);
g_logger().debug("Decay duration new type, decayTo {}, transformEquipTo {}, transformDeEquipTo {}", newType.decayTo, newType.transformEquipTo, newType.transformDeEquipTo);
if (newType.decayTo) {
itemId = newType.decayTo;
}
} else if (curType.id != newType.id) {
if (newType.group != curType.group) {
item->setDefaultSubtype();
}
Expand Down Expand Up @@ -5285,7 +5293,7 @@ void Game::playerSetManagedContainer(uint32_t playerId, ObjectCategory_t categor
}

std::shared_ptr<Container> container = thing->getContainer();
auto allowConfig = !g_configManager().getBoolean(TOGGLE_GOLD_POUCH_ALLOW_ANYTHING, __FUNCTION__) || !g_configManager().getBoolean(TOGGLE_GOLD_POUCH_QUICKLOOT_ONLY, __FUNCTION__);
auto allowConfig = g_configManager().getBoolean(TOGGLE_GOLD_POUCH_ALLOW_ANYTHING, __FUNCTION__) || g_configManager().getBoolean(TOGGLE_GOLD_POUCH_QUICKLOOT_ONLY, __FUNCTION__);
if (!container || (container->getID() == ITEM_GOLD_POUCH && category != OBJECTCATEGORY_GOLD) && !allowConfig) {
player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE);
return;
Expand Down
3 changes: 3 additions & 0 deletions src/io/functions/iologindata_load_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "pch.hpp"

#include "creatures/players/wheel/player_wheel.hpp"
#include "creatures/players/achievement/player_achievement.hpp"
#include "io/functions/iologindata_load_player.hpp"
#include "game/game.hpp"
#include "enums/object_category.hpp"
Expand Down Expand Up @@ -910,6 +911,8 @@ void IOLoginDataLoad::loadPlayerInitializeSystem(std::shared_ptr<Player> player)
player->wheel()->loadDBPlayerSlotPointsOnLogin();
player->wheel()->initializePlayerData();

player->achiev()->loadUnlockedAchievements();

player->initializePrey();
player->initializeTaskHunting();
}
Expand Down
1 change: 1 addition & 0 deletions src/io/iomarket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ MarketOfferList IOMarket::getActiveOffers(MarketAction_t action) {
} while (result->next());
return offerList;
}

MarketOfferList IOMarket::getActiveOffers(MarketAction_t action, uint16_t itemId, uint8_t tier) {
MarketOfferList offerList;

Expand Down
5 changes: 2 additions & 3 deletions src/items/functions/item/item_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ void ItemParse::createAndRegisterScript(ItemType &itemType, pugi::xml_node attri

auto stringKey = asLowerCaseString(subKeyAttribute.as_string());
if (stringKey == "slot") {
if (moveevent && (moveevent->getEventType() == MOVE_EVENT_EQUIP || moveevent->getEventType() == MOVE_EVENT_DEEQUIP)) {
auto slotName = asLowerCaseString(subValueAttribute.as_string());
auto slotName = asLowerCaseString(subValueAttribute.as_string());
if (moveevent && slotName != "two-handed" && (moveevent->getEventType() == MOVE_EVENT_EQUIP || moveevent->getEventType() == MOVE_EVENT_DEEQUIP)) {
if (slotName == "head") {
moveevent->setSlot(SLOTP_HEAD);
} else if (slotName == "necklace") {
Expand Down Expand Up @@ -1055,7 +1055,6 @@ void ItemParse::createAndRegisterScript(ItemType &itemType, pugi::xml_node attri
} else if (weapon) {
uint16_t id = weapon->getID();
ItemType &it = Item::items.getItemType(id);
auto slotName = asLowerCaseString(subValueAttribute.as_string());
if (slotName == "two-handed") {
it.slotPosition = SLOTP_TWO_HAND;
} else {
Expand Down
11 changes: 6 additions & 5 deletions src/lua/creature/movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,17 +524,18 @@ uint32_t MoveEvent::EquipItem(const std::shared_ptr<MoveEvent> moveEvent, std::s
return 1;
}

const ItemType &it = Item::items[item->getID()];
if (it.transformEquipTo != 0) {
g_game().transformItem(item, it.transformEquipTo);
}

if (player->isItemAbilityEnabled(slot)) {
g_logger().debug("[{}] item ability is already enabled", __FUNCTION__);
return 1;
}

player->setItemAbility(slot, true);

const ItemType &it = Item::items[item->getID()];
if (it.transformEquipTo != 0) {
g_game().transformItem(item, it.transformEquipTo);
}

for (uint8_t slotid = 0; slotid < item->getImbuementSlot(); slotid++) {
player->updateImbuementTrackerStats();
ImbuementInfo imbuementInfo;
Expand Down
4 changes: 3 additions & 1 deletion src/server/network/connection/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ void Connection::parseHeader(const std::error_code &error) {
readTimer.cancel();

if (error) {
g_logger().debug("[Connection::parseHeader] - Read error: {}", error.message());
if (error != asio::error::operation_aborted && error != asio::error::eof && error != asio::error::connection_reset) {
g_logger().debug("[Connection::parseHeader] - Read error: {}", error.message());
}
close(FORCE_CLOSE);
return;
} else if (connectionState == CONNECTION_STATE_CLOSED) {
Expand Down
19 changes: 16 additions & 3 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3949,6 +3949,10 @@ void ProtocolGame::sendStats() {
}

void ProtocolGame::sendBasicData() {
if (!player) {
return;
}

NetworkMessage msg;
msg.addByte(0x9F);
if (player->isPremium() || player->isVip()) {
Expand Down Expand Up @@ -5921,7 +5925,12 @@ void ProtocolGame::sendRestingStatus(uint8_t protection) {
msg.addByte(0xA9);
msg.addByte(protection); // 1 / 0

int32_t dailyStreak = static_cast<int32_t>(player->kv()->scoped("daily-reward")->get("streak")->getNumber());
uint8_t dailyStreak = 0;
auto dailyRewardKV = player->kv()->scoped("daily-reward")->get("streak");
if (dailyRewardKV && dailyRewardKV.has_value()) {
dailyStreak = static_cast<uint8_t>(dailyRewardKV->getNumber());
}

msg.addByte(dailyStreak < 2 ? 0 : 1);
if (dailyStreak < 2) {
msg.addString("Resting Area (no active bonus)", "ProtocolGame::sendRestingStatus - Resting Area (no active bonus)");
Expand Down Expand Up @@ -6105,6 +6114,10 @@ void ProtocolGame::sendPartyCreatureShowStatus(std::shared_ptr<Creature> target,
}

void ProtocolGame::sendPartyPlayerVocation(std::shared_ptr<Player> target) {
if (!target) {
return;
}

uint32_t cid = target->getID();
if (!knownCreatureSet.contains(cid)) {
sendPartyCreatureUpdate(target);
Expand All @@ -6124,7 +6137,7 @@ void ProtocolGame::sendPartyPlayerVocation(std::shared_ptr<Player> target) {
}

void ProtocolGame::sendPlayerVocation(std::shared_ptr<Player> target) {
if (!player || oldProtocol) {
if (!player || !target || oldProtocol) {
return;
}

Expand Down Expand Up @@ -8618,7 +8631,7 @@ void ProtocolGame::sendMonsterPodiumWindow(std::shared_ptr<Item> podium, const P
}

void ProtocolGame::parseSetMonsterPodium(NetworkMessage &msg) const {
if (oldProtocol) {
if (!player || oldProtocol) {
return;
}

Expand Down

0 comments on commit 7f53ac1

Please sign in to comment.