Skip to content

Commit

Permalink
Merge branch 'main' into merge-branches
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored Apr 18, 2024
2 parents a4ec930 + 6503aa4 commit 6e78c02
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 105 deletions.
2 changes: 2 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ wheelAtelierRevealGreaterCost = 6000000
familiarTime = 30

partyAutoShareExperience = true
-- partyShareRangeMultiplier: the range of the party share experience, default 3/2 (1.5)
partyShareRangeMultiplier = 1.5
partyShareLootBoosts = false
partyShareLootBoostsDimishingFactor = 0.7

Expand Down
3 changes: 0 additions & 3 deletions data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ Storage = {
-- unused ExerciseDummyExhaust = 30029,
SamsOldBackpack = 30030,
SamsOldBackpackDoor = 30031,
StrawberryCupcake = 30032,
ChayenneReward = 30033,
SwampDiggingTimeout = 30034,
HydraEggQuest = 30035,
Expand All @@ -125,8 +124,6 @@ Storage = {
Navigator = 30048,
DwarvenLegs = 30049,
PrinceDrazzakTime = 30050,
LemonCupcake = 30052,
BlueberryCupcake = 30053,
-- Reserved in Global.Storage.FamiliarSummonEvent10 = 30054
-- Reserved in Global.Storage.FamiliarSummonEvent60 = 30055
ChayenneKeyTime = 30056,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/asnarus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ npcConfig.shop = {
{ itemName = "animate dead rune", clientId = 3203, buy = 375 },
{ itemName = "arrow", clientId = 3447, buy = 2 },
{ itemName = "blue quiver", clientId = 35848, buy = 400 },
{ itemName = "bolt", clientId = 3483, buy = 4 },
{ itemName = "bolt", clientId = 3446, buy = 4 },
{ itemName = "bow", clientId = 3350, buy = 400, sell = 100 },
{ itemName = "bowl of terror sweat", clientId = 20204, sell = 500 },
{ itemName = "broken visor", clientId = 20184, sell = 1900 },
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/hireling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function createHirelingType(HirelingName)
},
["distance"] = {
{ itemName = "arrow", clientId = 3447, buy = 2 },
{ itemName = "bolt", clientId = 3483, buy = 4 },
{ itemName = "bolt", clientId = 3446, buy = 4 },
{ itemName = "bow", clientId = 3350, buy = 400, sell = 100 },
{ itemName = "crossbow", clientId = 3349, buy = 500, sell = 120 },
{ itemName = "crystalline arrow", clientId = 15793, buy = 450 },
Expand Down
51 changes: 0 additions & 51 deletions data-otservbr-global/scripts/actions/other/cup_cakes.lua

This file was deleted.

18 changes: 18 additions & 0 deletions data/scripts/actions/items/blueberry_cupcake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local blueberryCupcake = Action()

function blueberryCupcake.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:hasExhaustion("blueberry-cupcake-cooldown") then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.")
return true
end

player:addMana(player:getMaxMana())
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your mana has been refilled.")
player:say("Mmmm.", TALKTYPE_MONSTER_SAY)
player:setExhaustion("blueberry-cupcake-cooldown", 10 * 60)
item:remove(1)
return true
end

blueberryCupcake:id(28484)
blueberryCupcake:register()
24 changes: 24 additions & 0 deletions data/scripts/actions/items/lemon_cupcake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local distanceCondition = Condition(CONDITION_ATTRIBUTES)
distanceCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
distanceCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
distanceCondition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 10)
distanceCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true)

local lemonCupcake = Action()

function lemonCupcake.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:hasExhaustion("lemon-cupcake-cooldown") then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.")
return true
end

player:addCondition(distanceCondition)
player:sendTextMessage(MESSAGE_FAILURE, "You feel more focused.")
player:say("Mmmm.", TALKTYPE_MONSTER_SAY)
player:setExhaustion("lemon-cupcake-cooldown", 10 * 60)
item:remove(1)
return true
end

lemonCupcake:id(28486)
lemonCupcake:register()
11 changes: 7 additions & 4 deletions data/scripts/actions/items/potions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ function flaskPotion.onUse(player, item, fromPosition, target, toPosition, isHot
local deactivatedFlasks = player:kv():get("talkaction.potions.flask") or false
if not deactivatedFlasks then
local container = Container(item:getParent().uid)
local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)

if fromPosition.x == CONTAINER_POSITION and container ~= inbox and container:getEmptySlots() ~= 0 then
container:addItem(potion.flask, 1)
if container then
local storeInbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
if fromPosition.x == CONTAINER_POSITION and container ~= storeInbox and container:getEmptySlots() ~= 0 then
container:addItem(potion.flask, 1)
else
player:addItem(potion.flask, 1)
end
else
Game.createItem(potion.flask, 1, fromPosition)
end
Expand Down
18 changes: 18 additions & 0 deletions data/scripts/actions/items/strawberry_cupcake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local strawberryCupcake = Action()

function strawberryCupcake.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:hasExhaustion("strawberry-cupcake-cooldown") then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.")
return true
end

player:addHealth(player:getMaxHealth())
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your health has been refilled.")
player:say("Mmmm.", TALKTYPE_MONSTER_SAY)
player:setExhaustion("strawberry-cupcake-cooldown", 10 * 60)
item:remove(1)
return true
end

strawberryCupcake:id(28485)
strawberryCupcake:register()
21 changes: 0 additions & 21 deletions data/scripts/spells/conjuring/conjure_diamond_arrow.lua

This file was deleted.

21 changes: 0 additions & 21 deletions data/scripts/spells/conjuring/conjure_spectral_bolt.lua

This file was deleted.

1 change: 1 addition & 0 deletions src/config/config_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ enum ConfigKey_t : uint16_t {
OWNER_NAME,
PARALLELISM,
PARTY_AUTO_SHARE_EXPERIENCE,
PARTY_SHARE_RANGE_MULTIPLIER,
PARTY_LIST_MAX_DISTANCE,
PARTY_SHARE_LOOT_BOOSTS_DIMINISHING_FACTOR,
PARTY_SHARE_LOOT_BOOSTS,
Expand Down
1 change: 1 addition & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ bool ConfigManager::load() {
loadIntConfig(L, STAMINA_PZ_GAIN, "staminaPzGain", 1);
loadIntConfig(L, STAMINA_TRAINER_DELAY, "staminaTrainerDelay", 5);
loadIntConfig(L, STAMINA_TRAINER_GAIN, "staminaTrainerGain", 1);
loadFloatConfig(L, PARTY_SHARE_RANGE_MULTIPLIER, "partyShareRangeMultiplier", 1.5f);
loadIntConfig(L, START_STREAK_LEVEL, "startStreakLevel", 0);
loadIntConfig(L, STATUSQUERY_TIMEOUT, "statusTimeout", 5000);
loadIntConfig(L, STORE_COIN_PACKET, "coinPacketSize", 25);
Expand Down
9 changes: 6 additions & 3 deletions src/creatures/players/grouping/party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ SharedExpStatus_t Party::getMemberSharedExperienceStatus(std::shared_ptr<Player>
return SHAREDEXP_OK;
}

float Party::shareRangeMultiplier() const {
return g_configManager().getFloat(PARTY_SHARE_RANGE_MULTIPLIER, __FUNCTION__);
}

uint32_t Party::getHighestLevel() {
auto leader = getLeader();
if (!leader) {
Expand All @@ -507,7 +511,7 @@ uint32_t Party::getHighestLevel() {
}

uint32_t Party::getMinLevel() {
return static_cast<uint32_t>(std::ceil((static_cast<float>(getHighestLevel()) * 2) / 3));
return static_cast<uint32_t>(std::ceil(static_cast<float>(getHighestLevel()) / shareRangeMultiplier()));
}

uint32_t Party::getLowestLevel() {
Expand All @@ -525,15 +529,14 @@ uint32_t Party::getLowestLevel() {
}

uint32_t Party::getMaxLevel() {
return static_cast<uint32_t>(std::floor((static_cast<float>(getLowestLevel()) * 3) / 2));
return static_cast<uint32_t>(std::floor(static_cast<float>(getLowestLevel()) * shareRangeMultiplier()));
}

bool Party::isPlayerActive(std::shared_ptr<Player> player) {
auto it = ticksMap.find(player->getID());
if (it == ticksMap.end()) {
return false;
}

uint64_t timeDiff = OTSYS_TIME() - it->second;
return timeDiff <= 2 * 60 * 1000;
}
Expand Down
1 change: 1 addition & 0 deletions src/creatures/players/grouping/party.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class Party : public SharedObject {
uint32_t getLowestLevel();
uint32_t getMinLevel();
uint32_t getMaxLevel();
float shareRangeMultiplier() const;

std::map<uint32_t, int64_t> ticksMap;

Expand Down
5 changes: 5 additions & 0 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,11 @@ class Player final : public Creature, public Cylinder, public Bankable {
return loginPosition;
}
const Position &getTemplePosition() const {
if (!town) {
static auto emptyPosition = Position();
return emptyPosition;
}

return town->getTemplePosition();
}
std::shared_ptr<Town> getTown() const {
Expand Down
2 changes: 2 additions & 0 deletions src/game/bank/bank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ bool Bank::transferTo(const std::shared_ptr<Bank> destination, uint64_t amount)
if (destinationPlayer != nullptr) {
auto name = asLowerCaseString(destinationPlayer->getName());
replaceString(name, " ", "");

if (deniedNames.contains(name)) {
g_logger().warn("Bank::transferTo: denied name: {}", name);
return false;
}

if (destinationPlayer->getTown()->getID() < g_configManager().getNumber(MIN_TOWN_ID_TO_BANK_TRANSFER, __FUNCTION__)) {
g_logger().warn("Bank::transferTo: denied town: {}", destinationPlayer->getTown()->getID());
return false;
Expand Down

0 comments on commit 6e78c02

Please sign in to comment.