Skip to content

Commit

Permalink
Merge branch 'main' into dudantas/fix-chain-bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Mar 16, 2024
2 parents 5c8f4f4 + af7126a commit 069d418
Show file tree
Hide file tree
Showing 44 changed files with 91 additions and 111 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
8 changes: 0 additions & 8 deletions data-canary/scripts/actions/tools/crowbar.lua

This file was deleted.

8 changes: 0 additions & 8 deletions data-canary/scripts/actions/tools/machete.lua

This file was deleted.

8 changes: 0 additions & 8 deletions data-canary/scripts/actions/tools/pick.lua

This file was deleted.

8 changes: 0 additions & 8 deletions data-canary/scripts/actions/tools/rope.lua

This file was deleted.

8 changes: 0 additions & 8 deletions data-canary/scripts/actions/tools/scythe.lua

This file was deleted.

8 changes: 0 additions & 8 deletions data-canary/scripts/actions/tools/shovel.lua

This file was deleted.

8 changes: 0 additions & 8 deletions data-canary/scripts/actions/tools/spoon.lua

This file was deleted.

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
7 changes: 4 additions & 3 deletions data-otservbr-global/npc/gnomadness.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ local function creatureSayCallback(npc, creature, type, message)
end
if hazard:setPlayerCurrentLevel(player, desiredLevel) then
npcHandler:say("Your hazard level has been set to " .. desiredLevel .. ". Good luck!", npc, creature)
if desiredLevel >= hazard.maxLevel and not player:kv():scoped("primal-ordeal"):get("received-prize") then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Congratulations you received the Noxious Ripptor mount.")
if desiredLevel >= 6 and not player:kv():scoped("primal-ordeal"):get("received-prize") then
player:addMount(202)
npcHandler:say("You've achived the maximum hazard level. As a reward, you've received the Noxious Ripptor mount and a primal bag.", npc, creature)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Congratulations you received the Noxious Ripptor mount.")
player:addAchievement("Ripp-Ripp Hooray!")
player:addItem(PRIMAL_BAG, 1)
player:kv():scoped("primal-ordeal"):set("received-prize", true)
npcHandler:say("You've achieved the necessary hazard level. As a reward, you've received the Noxious Ripptor mount and a primal bag.", npc, creature)
end
else
npcHandler:say("You can't set your hazard level higher than your maximum unlocked level.", npc, creature)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions data/scripts/lib/register_achievements.lua
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ ACHIEVEMENTS = {
[531] = { name = "First Achievement", grade = 1, points = 1, secret = true, description = "Congratulations to your very first achievement! ... Well, not really. But imagine, it is. Because at this point during your journey into Tibia's past, achievements have been introduced." },
[532] = { name = "Sharp Dressed", grade = 1, points = 2, description = "Just everyone will be crazy about you if you are wearing this formal dress. They will come running, promise!" },
[533] = { name = "Engine Driver", grade = 1, points = 3, description = "This glooth-driven locomotive will bring you to any party in the blink of an eye." },
[540] = { name = "Ripp-Ripp Hooray!", grade = 1, points = 3, description = "Don't get carried away by your success. Get carried away by your Ripptor." },
}

--[[
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
24 changes: 11 additions & 13 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3246,11 +3246,7 @@ ReturnValue Player::queryAdd(int32_t index, const std::shared_ptr<Thing> &thing,
}
}
} else if (slotPosition & SLOTP_TWO_HAND) {
if (inventory[CONST_SLOT_LEFT] && inventory[CONST_SLOT_LEFT] != item) {
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
} else {
ret = RETURNVALUE_NOERROR;
}
ret = RETURNVALUE_CANNOTBEDRESSED;
} else if (inventory[CONST_SLOT_LEFT]) {
std::shared_ptr<Item> leftItem = inventory[CONST_SLOT_LEFT];
WeaponType_t type = item->getWeaponType(), leftType = leftItem->getWeaponType();
Expand All @@ -3273,11 +3269,19 @@ ReturnValue Player::queryAdd(int32_t index, const std::shared_ptr<Thing> &thing,
}

case CONST_SLOT_LEFT: {
if (slotPosition & SLOTP_LEFT) {
if (item->isQuiver()) {
ret = RETURNVALUE_CANNOTBEDRESSED;
} else if (slotPosition & SLOTP_LEFT) {
WeaponType_t type = item->getWeaponType();
if (type == WEAPON_NONE || type == WEAPON_SHIELD || type == WEAPON_AMMO) {
ret = RETURNVALUE_CANNOTBEDRESSED;
} else if (inventory[CONST_SLOT_RIGHT] && (slotPosition & SLOTP_TWO_HAND)) {
} else {
ret = RETURNVALUE_NOERROR;
}
} else if (slotPosition & SLOTP_TWO_HAND) {
if (inventory[CONST_SLOT_RIGHT]) {
WeaponType_t type = item->getWeaponType();
// Allow equip bow when quiver is in SLOT_RIGHT
if (type == WEAPON_DISTANCE && inventory[CONST_SLOT_RIGHT]->isQuiver()) {
ret = RETURNVALUE_NOERROR;
} else {
Expand All @@ -3286,12 +3290,6 @@ ReturnValue Player::queryAdd(int32_t index, const std::shared_ptr<Thing> &thing,
} else {
ret = RETURNVALUE_NOERROR;
}
} else if (slotPosition & SLOTP_TWO_HAND) {
if (inventory[CONST_SLOT_RIGHT] && inventory[CONST_SLOT_RIGHT] != item) {
ret = RETURNVALUE_BOTHHANDSNEEDTOBEFREE;
} else {
ret = RETURNVALUE_NOERROR;
}
} else if (inventory[CONST_SLOT_RIGHT]) {
std::shared_ptr<Item> rightItem = inventory[CONST_SLOT_RIGHT];
WeaponType_t type = item->getWeaponType(), rightType = rightItem->getWeaponType();
Expand Down
10 changes: 9 additions & 1 deletion 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
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 @@ -887,6 +888,8 @@ void IOLoginDataLoad::loadPlayerInitializeSystem(std::shared_ptr<Player> player)
player->wheel()->loadDBPlayerSlotPointsOnLogin();
player->wheel()->initializePlayerData();

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

player->initializePrey();
player->initializeTaskHunting();
}
Expand Down
2 changes: 1 addition & 1 deletion src/io/functions/iologindata_save_player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class IOLoginDataSave : public IOLoginData {
static bool savePlayerTaskHuntingClass(std::shared_ptr<Player> player);
static bool savePlayerForgeHistory(std::shared_ptr<Player> player);
static bool savePlayerBosstiary(std::shared_ptr<Player> player);
static bool savePlayerStorage(std::shared_ptr<Player> palyer);
static bool savePlayerStorage(std::shared_ptr<Player> player);

protected:
using ItemBlockList = std::list<std::pair<int32_t, std::shared_ptr<Item>>>;
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
Loading

0 comments on commit 069d418

Please sign in to comment.