Skip to content

Commit

Permalink
Merge branch 'main' into game-tester
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Jan 12, 2025
2 parents 676978d + 0bce574 commit 5b581d1
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion data-global/monster/bosses/chagorz.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local monster = {}
monster.description = "Chagorz"
monster.experience = 3250000
monster.outfit = {
lookType = 1665,
lookType = 1666,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
Expand Down
2 changes: 1 addition & 1 deletion data-global/monster/bosses/vemiath.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local monster = {}
monster.description = "Vemiath"
monster.experience = 3250000
monster.outfit = {
lookType = 1665,
lookType = 1668,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
Expand Down
2 changes: 1 addition & 1 deletion data-global/monster/quests/rotten_bood/mushroom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local monster = {}
monster.description = "a Mushroom"
monster.experience = 0
monster.outfit = {
lookType = 1669, --todo get correct lookType
lookType = 1773,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/actions/objects/cask_and_kegs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local targetIdList = {
local flasks = Action()

function flasks.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or not target:getItem() then
if not target or not target:isItem() then
return false
end

Expand Down
6 changes: 3 additions & 3 deletions src/creatures/npcs/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,13 +828,13 @@ void Npc::removeShopPlayer(uint32_t playerGUID) {
}

void Npc::closeAllShopWindows() {
for (const auto &playerGUID : shopPlayers | std::views::keys) {
const auto &player = g_game().getPlayerByGUID(playerGUID);
for (auto it = shopPlayers.begin(); it != shopPlayers.end();) {
const auto &player = g_game().getPlayerByGUID(it->first);
if (player) {
player->closeShopWindow();
}
it = shopPlayers.erase(it);
}
shopPlayers.clear();
}

void Npc::handlePlayerMove(const std::shared_ptr<Player> &player, const Position &newPos) {
Expand Down
9 changes: 5 additions & 4 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9058,12 +9058,13 @@ void Game::playerCreateMarketOffer(uint32_t playerId, uint8_t type, uint16_t ite
}

uint64_t totalPrice = price * amount;
uint64_t totalFee = totalPrice * 0.02;
uint64_t maxFee = std::min<uint64_t>(1000000, totalFee);
uint64_t fee = std::max<uint64_t>(20, totalFee);
uint64_t totalFee = totalPrice * 0.02; // 2% fee
uint64_t maxFee = std::min<uint64_t>(1000000, totalFee); // Max fee is 1kk
uint64_t fee = std::clamp(totalFee, uint64_t(20), maxFee); // Limit between 20 and maxFee

if (type == MARKETACTION_SELL) {
if (fee > (player->getBankBalance() + player->getMoney())) {
uint64_t totalPriceWithFee = totalPrice + fee;
if (totalPriceWithFee > (player->getMoney() + player->getBankBalance())) {
offerStatus << "Fee is greater than player money";
return;
}
Expand Down
20 changes: 17 additions & 3 deletions src/items/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,11 +1888,25 @@ std::shared_ptr<Item> Tile::getUseItem(int32_t index) const {
return ground;
}

if (const auto &thing = getThing(index)) {
return thing->getItem();
if (index >= 0 && index < static_cast<int32_t>(items->size())) {
if (const auto &thing = getThing(index)) {
if (auto thingItem = thing->getItem()) {
return thingItem;
}
}
}

return nullptr;
if (auto topDownItem = getTopDownItem()) {
return topDownItem;
}

for (auto it = items->rbegin(), end = items->rend(); it != end; ++it) {
if ((*it)->getDoor()) {
return (*it)->getItem();
}
}

return !items->empty() ? *items->begin() : nullptr;
}

std::shared_ptr<Item> Tile::getDoorItem() const {
Expand Down
18 changes: 9 additions & 9 deletions src/map/spectators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ bool Spectators::checkCache(const SpectatorsCache::FloorData &specData, bool onl
for (const auto &creature : *list) {
const auto &specPos = creature->getPosition();
if ((centerPos.x - specPos.x >= minRangeX
&& centerPos.y - specPos.y >= minRangeY
&& centerPos.x - specPos.x <= maxRangeX
&& centerPos.y - specPos.y <= maxRangeY
&& (multifloor || specPos.z == centerPos.z)
&& ((onlyPlayers && creature->getPlayer())
|| (onlyMonsters && creature->getMonster())
|| (onlyNpcs && creature->getNpc()))
|| (!onlyPlayers && !onlyMonsters && !onlyNpcs))) {
&& centerPos.y - specPos.y >= minRangeY
&& centerPos.x - specPos.x <= maxRangeX
&& centerPos.y - specPos.y <= maxRangeY
&& (multifloor || specPos.z == centerPos.z)
&& ((onlyPlayers && creature->getPlayer())
|| (onlyMonsters && creature->getMonster())
|| (onlyNpcs && creature->getNpc())))
|| (!onlyPlayers && !onlyMonsters && !onlyNpcs)) {
spectators.emplace_back(creature);
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ Spectators Spectators::excludePlayerMaster() const {
specs.creatures.reserve(creatures.size());

for (const auto &c : creatures) {
if ((c->getMonster() != nullptr && !c->getMaster() || !c->getMaster()->getPlayer())) {
if ((c->getMonster() != nullptr && !c->getMaster()) || (!c->getMaster() || !c->getMaster()->getPlayer())) {
specs.insert(c);
}
}
Expand Down

0 comments on commit 5b581d1

Please sign in to comment.