Skip to content

Commit

Permalink
Merge branch 'main' into feature/badge-system
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored Apr 25, 2024
2 parents 8460cf0 + 0998429 commit 452bc5f
Show file tree
Hide file tree
Showing 19 changed files with 228 additions and 60 deletions.
12 changes: 5 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ bld/
[Ll]og/
build/
vcproj/
!vcproj/canary.sln
!vcproj/canary.vcxproj
!vcproj/settings.props

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down Expand Up @@ -372,19 +375,14 @@ config.lua
config_canary.lua
client_assertions.txt
.env
otservbr.otbm
canary.otbm
otservbr-custom.otbm
data-otservbr-global/world/otservbr.otbm

# Extensions
*.ini
*.otb
*.exe
*.manifest
*.rar
*-house.xml
*-monster.xml
*-npc.xml
monster_count.txt

# SFTP for Sublime
Expand All @@ -398,4 +396,4 @@ canary.old
vcpkg_installed

# CLION
cmake-build-debug*
cmake-build-*
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function deathEvent.onDeath(creature, _corpse, _lastHitKiller, mostDamageKiller)
end
end
-- Minotaurs
killCheck(player, targetName, Storage.KillingInTheNameOf.BudrikMinos, 0, tasks.Budrik[1].creatures, nil, Storage.Quest.U8_5.KillingInTheNameOf.MonsterKillCount.MinotaurCount)
killCheck(player, targetName, Storage.KillingInTheNameOf.BudrikMinos, 0, tasks.Budrik[1].creatures, Storage.Quest.U8_5.KillingInTheNameOf.AltKillCount.MinotaurCount, Storage.Quest.U8_5.KillingInTheNameOf.MonsterKillCount.MinotaurCount)
-- Necromancers and Priestesses
killCheck(player, targetName, Storage.KillingInTheNameOf.LugriNecromancers, 0, tasks.Lugri[1].creatures, Storage.Quest.U8_5.KillingInTheNameOf.AltKillCount.NecromancerCount, Storage.Quest.U8_5.KillingInTheNameOf.MonsterKillCount.NecromancerCount)
killCheck(player, targetName, Storage.KillingInTheNameOf.LugriNecromancers, 3, tasks.Lugri[1].creatures, Storage.Quest.U8_5.KillingInTheNameOf.AltKillCount.NecromancerCount, Storage.Quest.U8_5.KillingInTheNameOf.MonsterKillCount.NecromancerCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
function onGetFormulaValues(player, skill, attack, factor)
local distanceSkill = player:getEffectiveSkillLevel(SKILL_DISTANCE)
local min = (player:getLevel() / 5)
local max = (0.09 * factor) * distanceSkill * 37 + (player:getLevel() / 5)
local max = (0.09 * factor) * distanceSkill * attack + (player:getLevel() / 5)
return -min, -max
end

Expand Down
7 changes: 5 additions & 2 deletions data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53105,6 +53105,9 @@ hands of its owner. Granted by TibiaRoyal.com"/>
<attribute key="showAttributes" value="1"/>
<attribute key="absorbpercentlifedrain" value="5"/>
<attribute key="weight" value="3800"/>
<attribute key="script" value="moveevent">
<attribute key="slot" value="ammo"/>
</attribute>
</item>
<item id="28494" article="a" name="silver chimes">
<attribute key="primarytype" value="shields"/>
Expand Down Expand Up @@ -75427,7 +75430,7 @@ Granted by TibiaGoals.com"/>
<attribute key="skillboost magic level" value="3"/>
</attribute>
<attribute key="script" value="moveevent;weapon">
<attribute key="level" value="250"/>
<attribute key="level" value="600"/>
<attribute key="mana" value="21"/>
<attribute key="unproperly" value="true"/>
<attribute key="fromDamage" value="113"/>
Expand Down Expand Up @@ -75455,7 +75458,7 @@ Granted by TibiaGoals.com"/>
<attribute key="skillboost magic level" value="3"/>
</attribute>
<attribute key="script" value="moveevent;weapon">
<attribute key="level" value="250"/>
<attribute key="level" value="600"/>
<attribute key="mana" value="21"/>
<attribute key="unproperly" value="true"/>
<attribute key="fromDamage" value="103"/>
Expand Down
15 changes: 13 additions & 2 deletions data/libs/functions/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,38 @@ end

function getTimeInWords(secsParam)
local secs = tonumber(secsParam)
local days = math.floor(secs / (24 * 3600))
secs = secs - (days * 24 * 3600)
local hours, minutes, seconds = getHours(secs), getMinutes(secs), getSeconds(secs)
local timeStr = ""

if days > 0 then
timeStr = days .. (days > 1 and " days" or " day")
end

if hours > 0 then
timeStr = hours .. (hours > 1 and " hours" or " hour")
if timeStr ~= "" then
timeStr = timeStr .. ", "
end

timeStr = timeStr .. hours .. (hours > 1 and " hours" or " hour")
end

if minutes > 0 then
if timeStr ~= "" then
timeStr = timeStr .. ", "
end

timeStr = timeStr .. minutes .. (minutes > 1 and " minutes" or " minute")
end

if seconds > 0 then
if timeStr ~= "" then
timeStr = timeStr .. " and "
end

timeStr = timeStr .. seconds .. (seconds > 1 and " seconds" or " second")
end

return timeStr
end

Expand Down
2 changes: 1 addition & 1 deletion data/modules/scripts/gamestore/gamestore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6770,7 +6770,7 @@ for k, category in ipairs(GameStore.Categories) do
offer.type = GameStore.OfferTypes.OFFER_TYPE_NONE
end
if not offer.coinType then
offer.coinType = GameStore.CoinType.Coin
offer.coinType = GameStore.CoinType.Transferable
end
end
end
Expand Down
46 changes: 25 additions & 21 deletions data/modules/scripts/gamestore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ GameStore.DefaultDescriptions = {
TEMPLE = { "Need a quick way home? Buy this transportation service to get instantly teleported to your home temple. \n\nNote, you cannot use this service while having a battle sign or a protection zone block. Further, the service will not work in no-logout zones or close to your home temple." },
}

GameStore.ItemLimit = {
PREY_WILDCARD = 50,
INSTANT_REWARD_ACCESS = 90,
EXPBOOST = 6,
HIRELING = 10,
}

--==Parsing==--
GameStore.isItsPacket = function(byte)
for k, v in pairs(GameStore.RecivedPackets) do
Expand Down Expand Up @@ -532,8 +539,8 @@ function parseBuyStoreOffer(playerId, msg)
if not pcallOk then
local alertMessage = pcallError.code and pcallError.message or "Something went wrong. Your purchase has been cancelled."

if not pcallError.code then -- unhandled error
-- log some debugging info
-- unhandled error
if not pcallError.code then
logger.warn("[parseBuyStoreOffer] - Purchase failed due to an unhandled script error. Stacktrace: {}", pcallError)
end

Expand Down Expand Up @@ -644,7 +651,6 @@ function sendOfferDescription(player, offerId, description)
end

function Player.canBuyOffer(self, offer)
local playerId = self:getId()
local disabled, disabledReason = 0, ""
if offer.disabled or not offer.type then
disabled = 1
Expand Down Expand Up @@ -723,12 +729,12 @@ function Player.canBuyOffer(self, offer)
disabledReason = "You already have this mount."
end
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_INSTANT_REWARD_ACCESS then
if self:getCollectionTokens() >= 90 then
if self:getCollectionTokens() >= GameStore.ItemLimit.INSTANT_REWARD_ACCESS then
disabled = 1
disabledReason = "You already have maximum of reward tokens."
end
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_PREYBONUS then
if self:getPreyCards() >= 50 then
if self:getPreyCards() >= GameStore.ItemLimit.PREY_WILDCARD then
disabled = 1
disabledReason = "You already have maximum of prey wildcards."
end
Expand All @@ -748,7 +754,7 @@ function Player.canBuyOffer(self, offer)
disabledReason = "You already have 3 slots released."
end
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_EXPBOOST then
if self:getStorageValue(GameStore.Storages.expBoostCount) == 6 then
if self:getStorageValue(GameStore.Storages.expBoostCount) == GameStore.ItemLimit.EXPBOOST then
disabled = 1
disabledReason = "You can't buy XP Boost for today."
end
Expand All @@ -757,7 +763,7 @@ function Player.canBuyOffer(self, offer)
disabledReason = "You already have an active XP boost."
end
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_HIRELING then
if self:getHirelingsCount() >= 10 then
if self:getHirelingsCount() >= GameStore.ItemLimit.HIRELING then
disabled = 1
disabledReason = "You already have bought the maximum number of allowed hirelings."
end
Expand Down Expand Up @@ -1591,8 +1597,9 @@ function GameStore.processAllBlessingsPurchase(player, count)
end

function GameStore.processInstantRewardAccess(player, offerCount)
if player:getCollectionTokens() + offerCount >= 91 then
return error({ code = 1, message = "You cannot own more than 90 reward tokens." })
local limit = GameStore.ItemLimit.INSTANT_REWARD_ACCESS
if player:getCollectionTokens() + offerCount >= limit + 1 then
return error({ code = 1, message = "You cannot own more than " .. limit .. " reward tokens." })
end
player:setCollectionTokens(player:getCollectionTokens() + offerCount)
end
Expand Down Expand Up @@ -1667,7 +1674,6 @@ function GameStore.processHouseRelatedPurchase(player, offer)
decoKit:setAttribute(ITEM_ATTRIBUTE_STORE, systemTime())
end
end
player:sendUpdateContainer(inbox)
else
for i = 1, offer.count do
local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1)
Expand All @@ -1679,10 +1685,10 @@ function GameStore.processHouseRelatedPurchase(player, offer)
decoKit:setAttribute(ITEM_ATTRIBUTE_STORE, systemTime())
end
end
player:sendUpdateContainer(inbox)
end
end
end
player:sendUpdateContainer(inbox)
end
end

Expand All @@ -1703,11 +1709,7 @@ function GameStore.processOutfitPurchase(player, offerSexIdTable, addon)
elseif player:hasOutfit(looktype, _addon) then
return error({ code = 0, message = "You already own this outfit." })
else
if
not (player:addOutfitAddon(looktype, _addon)) -- TFS call failed
or (not player:hasOutfit(looktype, _addon)) -- Additional check; if the looktype doesn't match player sex for example,
-- then the TFS check will still pass... bug? (TODO)
then
if not player:addOutfitAddon(looktype, _addon) or not player:hasOutfit(looktype, _addon) then
error({ code = 0, message = "There has been an issue with your outfit purchase. Your purchase has been cancelled." })
else
player:addOutfitAddon(offerSexIdTable.male, _addon)
Expand Down Expand Up @@ -1795,8 +1797,9 @@ function GameStore.processTaskHuntingThirdSlot(player)
end

function GameStore.processPreyBonusReroll(player, offerCount)
if player:getPreyCards() + offerCount >= 51 then
return error({ code = 1, message = "You cannot own more than 50 prey wildcards." })
local limit = GameStore.ItemLimit.PREY_WILDCARD
if player:getPreyCards() + offerCount >= limit + 1 then
return error({ code = 1, message = "You cannot own more than " .. limit .. " prey wildcards." })
end
player:addPreyCards(offerCount)
end
Expand Down Expand Up @@ -1838,8 +1841,8 @@ function GameStore.processHirelingPurchase(player, offer, productType, hirelingN
return addPlayerEvent(sendStorePurchaseSuccessful, 650, player:getId(), message)
-- If not, we ask him to do!
else
if player:getHirelingsCount() >= 10 then
return error({ code = 1, message = "You cannot have more than 10 hirelings." })
if player:getHirelingsCount() >= GameStore.ItemLimit.HIRELING then
return error({ code = 1, message = "You cannot have more than " .. GameStore.ItemLimit.HIRELING .. " hirelings." })
end
-- TODO: Use the correct dialog (byte 0xDB) on client 1205+
-- for compatibility, request name using the change name dialog
Expand Down Expand Up @@ -2245,7 +2248,8 @@ function sendHomePage(playerId)
msg:sendToPlayer(player)
end

function Player:openStore(serviceName) --exporting the method so other scripts can use to open store
--exporting the method so other scripts can use to open store
function Player:openStore(serviceName)
local playerId = self:getId()
openStore(playerId)

Expand Down
1 change: 1 addition & 0 deletions data/scripts/eventcallbacks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Event callbacks are available for several categories of game entities, such as `
- `(void)` `playerOnCombat`
- `(void)` `playerOnInventoryUpdate`
- `(bool)` `playerOnRotateItem`
- `(void)` `playerOnWalk`
- `(void)` `monsterOnDropLoot`
- `(void)` `monsterPostDropLoot`
- `(void)` `monsterOnSpawn`
Expand Down
7 changes: 7 additions & 0 deletions data/scripts/runes/destroy_field_rune.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ local fields = { 105, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2132
local rune = Spell("rune")

function rune.onCastSpell(creature, variant, isHotkey)
local inPz = creature:getTile():hasFlag(TILESTATE_PROTECTIONZONE)
if inPz then
creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local position = Variant.getPosition(variant)
local tile = Tile(position)
local field = tile and tile:getItemByType(ITEM_TYPE_MAGICFIELD)
Expand Down
8 changes: 8 additions & 0 deletions data/scripts/spells/house/kick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ function spell.onCastSpell(player, variant)
local targetPlayer = Player(variant:getString()) or player
local guest = targetPlayer:getTile():getHouse()
local owner = player:getTile():getHouse()

-- Owner kick yourself from house
if targetPlayer == player then
player:getPosition():sendMagicEffect(CONST_ME_POFF)
player:teleportTo(owner:getExitPosition())
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end

if not owner:canEditAccessList(GUEST_LIST, player) then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

if not owner or not guest or not guest:kickPlayer(player, targetPlayer) then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
Expand Down
Loading

0 comments on commit 452bc5f

Please sign in to comment.