Skip to content

Commit

Permalink
Merge branch 'main' into feature/player-onwalk-callback
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored Apr 18, 2024
2 parents 4ba32fb + fceeac1 commit 3a8a5dd
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 116 deletions.
4 changes: 4 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 Expand Up @@ -239,6 +241,7 @@ onlyPremiumAccount = false
-- NOTE: enablePlayerPutItemInAmmoSlot = true, will enable players to put any items on ammo slot, more used in custom shopping system
-- NOTE: startStreakLevel will make a reward streak level for new players who never logged in
-- NOTE: if showLootsInBestiary is true, will cause all loots to be shown in the bestiary even if the player has not reached the required number of kills
-- NOTE: minTownIdToBankTransfer blocks towns less than defined from receiving money transfers
stashMoving = false
depotChest = 4
autoLoot = false
Expand All @@ -257,6 +260,7 @@ storeInboxMaxLimit = 2000
enablePlayerPutItemInAmmoSlot = false
startStreakLevel = 0
showLootsInBestiary = false
minTownIdToBankTransfer = 3

-- Teleport summon
-- Set to true will never remove the summon
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()
8 changes: 4 additions & 4 deletions data/scripts/creaturescripts/player/offline_training.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function offlineTraining.onLogin(player)
player:setOfflineTrainingSkill(SKILL_NONE)

if offlineTime < 600 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be logged out for more than 10 minutes to start offline training.")
player:sendTextMessage(MESSAGE_OFFLINE_TRAINING, "You must be logged out for more than 10 minutes to start offline training.")
return true
end

Expand Down Expand Up @@ -50,15 +50,15 @@ function offlineTraining.onLogin(player)
end

text = string.format("%s.", text)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
player:sendTextMessage(MESSAGE_OFFLINE_TRAINING, text)

local vocation = player:getVocation()
local promotion = vocation:getPromotion()
local topVocation = not promotion and vocation or promotion

local updateSkills = false

if table.contains({ SKILL_CLUB, SKILL_SWORD, SKILL_AXE, SKILL_DISTANCE }, offlineTrainingSkill) then
local modifier = topVocation:getBaseAttackSpeed() / 1000
local modifier = topVocation:getBaseAttackSpeed() / 1000 / configManager.getFloat(configKeys.RATE_OFFLINE_TRAINING_SPEED)
updateSkills = player:addOfflineTrainingTries(offlineTrainingSkill, (trainingTime / modifier) / (offlineTrainingSkill == SKILL_DISTANCE and 4 or 2))
elseif offlineTrainingSkill == SKILL_MAGLEVEL then
local gainTicks = topVocation:getManaGainTicks() * 2
Expand Down
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.

4 changes: 3 additions & 1 deletion src/config/config_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ enum ConfigKey_t : uint16_t {
CLASSIC_ATTACK_SPEED,
CLEAN_PROTECTION_ZONES,
COMBAT_CHAIN_DELAY,
COMBAT_CHAIN_TARGETS,
COMBAT_CHAIN_SKILL_FORMULA_AXE,
COMBAT_CHAIN_SKILL_FORMULA_CLUB,
COMBAT_CHAIN_SKILL_FORMULA_SWORD,
COMBAT_CHAIN_TARGETS,
COMPRESSION_LEVEL,
CONVERT_UNSAFE_SCRIPTS,
CORE_DIRECTORY,
Expand Down Expand Up @@ -155,6 +155,7 @@ enum ConfigKey_t : uint16_t {
METRICS_PROMETHEUS_ADDRESS,
MIN_DELAY_BETWEEN_CONDITIONS,
MIN_ELEMENTAL_RESISTANCE,
MIN_TOWN_ID_TO_BANK_TRANSFER,
MOMENTUM_CHANCE_FORMULA_A,
MOMENTUM_CHANCE_FORMULA_B,
MOMENTUM_CHANCE_FORMULA_C,
Expand All @@ -178,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
8 changes: 5 additions & 3 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ bool ConfigManager::load() {
loadBoolConfig(L, XP_DISPLAY_MODE, "experienceDisplayRates", true);

loadFloatConfig(L, BESTIARY_RATE_CHARM_SHOP_PRICE, "bestiaryRateCharmShopPrice", 1.0);
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_AXE, "combatChainSkillFormulaAxe", 0.9);
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_CLUB, "combatChainSkillFormulaClub", 0.7);
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_SWORD, "combatChainSkillFormulaSword", 1.1);
loadFloatConfig(L, FORGE_AMOUNT_MULTIPLIER, "forgeAmountMultiplier", 3.0);
loadFloatConfig(L, HAZARD_EXP_BONUS_MULTIPLIER, "hazardExpBonusMultiplier", 2.0);
loadFloatConfig(L, LOYALTY_BONUS_PERCENTAGE_MULTIPLIER, "loyaltyBonusPercentageMultiplier", 1.0);
Expand Down Expand Up @@ -218,9 +221,6 @@ bool ConfigManager::load() {
loadIntConfig(L, CHECK_EXPIRED_MARKET_OFFERS_EACH_MINUTES, "checkExpiredMarketOffersEachMinutes", 60);
loadIntConfig(L, COMBAT_CHAIN_DELAY, "combatChainDelay", 50);
loadIntConfig(L, COMBAT_CHAIN_TARGETS, "combatChainTargets", 5);
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_AXE, "combatChainSkillFormulaAxe", 0.9);
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_CLUB, "combatChainSkillFormulaClub", 0.7);
loadFloatConfig(L, COMBAT_CHAIN_SKILL_FORMULA_SWORD, "combatChainSkillFormulaSword", 1.1);
loadIntConfig(L, COMPRESSION_LEVEL, "packetCompressionLevel", 6);
loadIntConfig(L, CRITICALCHANCE, "criticalChance", 10);
loadIntConfig(L, DAY_KILLS_TO_RED, "dayKillsToRedSkull", 3);
Expand Down Expand Up @@ -287,6 +287,7 @@ bool ConfigManager::load() {
loadIntConfig(L, METRICS_OSTREAM_INTERVAL, "metricsOstreamInterval", 1000);
loadIntConfig(L, MIN_DELAY_BETWEEN_CONDITIONS, "minDelayBetweenConditions", 0);
loadIntConfig(L, MIN_ELEMENTAL_RESISTANCE, "minElementalResistance", -200);
loadIntConfig(L, MIN_TOWN_ID_TO_BANK_TRANSFER, "minTownIdToBankTransfer", 3);
loadIntConfig(L, MONTH_KILLS_TO_RED, "monthKillsToRedSkull", 10);
loadIntConfig(L, MULTIPLIER_ATTACKONFIST, "multiplierSpeedOnFist", 5);
loadIntConfig(L, ORANGE_SKULL_DURATION, "orangeSkullDuration", 7);
Expand Down Expand Up @@ -317,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
Loading

0 comments on commit 3a8a5dd

Please sign in to comment.