From afcc2c439f4592745f416b77e551300150831825 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 12 Oct 2024 20:53:13 -0300 Subject: [PATCH 1/3] update --- data-otservbr-global/lib/functions/load.lua | 2 + .../lib/functions/players.lua | 76 +++++++++++++++++ data-otservbr-global/lib/lib.lua | 3 + data/libs/functions/player.lua | 84 ------------------- 4 files changed, 81 insertions(+), 84 deletions(-) create mode 100644 data-otservbr-global/lib/functions/load.lua create mode 100644 data-otservbr-global/lib/functions/players.lua diff --git a/data-otservbr-global/lib/functions/load.lua b/data-otservbr-global/lib/functions/load.lua new file mode 100644 index 00000000000..0dc1720de85 --- /dev/null +++ b/data-otservbr-global/lib/functions/load.lua @@ -0,0 +1,2 @@ +dofile(DATA_DIRECTORY .. "/lib/functions/players.lua") + diff --git a/data-otservbr-global/lib/functions/players.lua b/data-otservbr-global/lib/functions/players.lua new file mode 100644 index 00000000000..45fec4c6653 --- /dev/null +++ b/data-otservbr-global/lib/functions/players.lua @@ -0,0 +1,76 @@ +function Player.getCookiesDelivered(self) + local storage, amount = + { + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.SimonTheBeggar, + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Markwin, + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Ariella, + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Hairycles, + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Djinn, + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.AvarTar, + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.OrcKing, + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Lorbas, + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Wyda, + Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Hjaern, + }, 0 + for i = 1, #storage do + if self:getStorageValue(storage[i]) == 1 then + amount = amount + 1 + end + end + return amount +end + +function Player.checkGnomeRank(self) + local points = self:getStorageValue(Storage.Quest.U9_60.BigfootsBurden.Rank) + local questProgress = self:getStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine) + if points >= 30 and points < 120 then + if questProgress <= 25 then + self:setStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine, 26) + self:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) + self:addAchievement("Gnome Little Helper") + end + elseif points >= 120 and points < 480 then + if questProgress <= 26 then + self:setStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine, 27) + self:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) + self:addAchievement("Gnome Little Helper") + self:addAchievement("Gnome Friend") + end + elseif points >= 480 and points < 1440 then + if questProgress <= 27 then + self:setStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine, 28) + self:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) + self:addAchievement("Gnome Little Helper") + self:addAchievement("Gnome Friend") + self:addAchievement("Gnomelike") + end + elseif points >= 1440 then + if questProgress <= 29 then + self:setStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine, 30) + self:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) + self:addAchievement("Gnome Little Helper") + self:addAchievement("Gnome Friend") + self:addAchievement("Gnomelike") + self:addAchievement("Honorary Gnome") + end + end + return true +end + +function Player.addFamePoint(self) + local points = self:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points) + local current = math.max(0, points) + self:setStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points, current + 1) + self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received a fame point.") +end + +function Player.getFamePoints(self) + local points = self:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points) + return math.max(0, points) +end + +function Player.removeFamePoints(self, amount) + local points = self:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points) + local current = math.max(0, points) + self:setStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points, current - amount) +end diff --git a/data-otservbr-global/lib/lib.lua b/data-otservbr-global/lib/lib.lua index 2e9ead889eb..e6ee85db8b4 100644 --- a/data-otservbr-global/lib/lib.lua +++ b/data-otservbr-global/lib/lib.lua @@ -9,3 +9,6 @@ dofile(DATA_DIRECTORY .. "/lib/quests/quest.lua") -- Tables library dofile(DATA_DIRECTORY .. "/lib/tables/load.lua") + +-- Functions library +dofile(DATA_DIRECTORY .. "/lib/functions/load.lua") diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index a8497b9bef1..5afb4eae1f6 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -90,90 +90,6 @@ function Player.addManaSpent(...) end -- Functions From OTServBR-Global -function Player.getCookiesDelivered(self) - if not IsRunningGlobalDatapack() then - return true - end - - local storage, amount = - { - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.SimonTheBeggar, - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Markwin, - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Ariella, - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Hairycles, - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Djinn, - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.AvarTar, - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.OrcKing, - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Lorbas, - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Wyda, - Storage.Quest.U8_1.WhatAFoolishQuest.CookieDelivery.Hjaern, - }, 0 - for i = 1, #storage do - if self:getStorageValue(storage[i]) == 1 then - amount = amount + 1 - end - end - return amount -end - -function Player.checkGnomeRank(self) - if not IsRunningGlobalDatapack() then - return true - end - - local points = self:getStorageValue(Storage.Quest.U9_60.BigfootsBurden.Rank) - local questProgress = self:getStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine) - if points >= 30 and points < 120 then - if questProgress <= 25 then - self:setStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine, 26) - self:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) - self:addAchievement("Gnome Little Helper") - end - elseif points >= 120 and points < 480 then - if questProgress <= 26 then - self:setStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine, 27) - self:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) - self:addAchievement("Gnome Little Helper") - self:addAchievement("Gnome Friend") - end - elseif points >= 480 and points < 1440 then - if questProgress <= 27 then - self:setStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine, 28) - self:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) - self:addAchievement("Gnome Little Helper") - self:addAchievement("Gnome Friend") - self:addAchievement("Gnomelike") - end - elseif points >= 1440 then - if questProgress <= 29 then - self:setStorageValue(Storage.Quest.U9_60.BigfootsBurden.QuestLine, 30) - self:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) - self:addAchievement("Gnome Little Helper") - self:addAchievement("Gnome Friend") - self:addAchievement("Gnomelike") - self:addAchievement("Honorary Gnome") - end - end - return true -end - -function Player.addFamePoint(self) - local points = self:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points) - local current = math.max(0, points) - self:setStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points, current + 1) - self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received a fame point.") -end - -function Player.getFamePoints(self) - local points = self:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points) - return math.max(0, points) -end - -function Player.removeFamePoints(self, amount) - local points = self:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points) - local current = math.max(0, points) - self:setStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Fame_Points, current - amount) -end function Player.depositMoney(self, amount) return Bank.deposit(self, amount) From a9704d4c62795a34ba15909343887fb8dbebf64f Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sat, 12 Oct 2024 23:53:45 +0000 Subject: [PATCH 2/3] Lua code format - (Stylua) --- data-otservbr-global/lib/functions/load.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/data-otservbr-global/lib/functions/load.lua b/data-otservbr-global/lib/functions/load.lua index 0dc1720de85..9862b00d2d8 100644 --- a/data-otservbr-global/lib/functions/load.lua +++ b/data-otservbr-global/lib/functions/load.lua @@ -1,2 +1 @@ dofile(DATA_DIRECTORY .. "/lib/functions/players.lua") - From 63831bd1e2d3edbbbe9b7cc17498f8544c07ab49 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Mon, 14 Oct 2024 00:15:29 -0300 Subject: [PATCH 3/3] Update data/libs/functions/player.lua Co-authored-by: murilo09 <78226931+murilo09@users.noreply.github.com> --- data/libs/functions/player.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index 5afb4eae1f6..f22acdd804f 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -90,7 +90,6 @@ function Player.addManaSpent(...) end -- Functions From OTServBR-Global - function Player.depositMoney(self, amount) return Bank.deposit(self, amount) end