Skip to content

Commit

Permalink
Merge branch 'main' into hotfix/fix-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored Nov 23, 2023
2 parents 33fb5f2 + 45e622d commit a0da360
Show file tree
Hide file tree
Showing 49 changed files with 718 additions and 873 deletions.
2 changes: 2 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ houseRentRate = 1.0
houseOwnedByAccount = false
houseBuyLevel = 100
housePurchasedShowPrice = false
houseLoseAfterInactivity = 30 -- days; 0 = never
onlyInvitedCanMoveHouseItems = true
togglehouseTransferOnRestart = true

Expand Down Expand Up @@ -479,6 +480,7 @@ vipBonusSkill = 0
vipAutoLootVipOnly = false
vipStayOnline = false
vipFamiliarTimeCooldownReduction = 0
vipKeepHouse = false

-- NOTE: set rewardChestCollectEnabled to true to enable the reward collect system
-- NOTE set rewardChestMaxCollectItems max items per collect action
Expand Down
12 changes: 6 additions & 6 deletions data-canary/scripts/actions/other/exercise_training.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function exerciseTraining.onUse(player, item, fromPosition, target, toPosition,
local targetId = target:getId()

if target:isItem() and (table.contains(HouseDummies, targetId) or table.contains(FreeDummies, targetId)) then
if onExerciseTraining[playerId] then
if _G.OnExerciseTraining[playerId] then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This exercise dummy can only be used after a 30 second cooldown.")
LeaveTraining(playerId)
return true
Expand All @@ -26,7 +26,7 @@ function exerciseTraining.onUse(player, item, fromPosition, target, toPosition,

if table.contains(HouseDummies, targetId) then
local playersOnDummy = 0
for _, playerTraining in pairs(onExerciseTraining) do
for _, playerTraining in pairs(_G.OnExerciseTraining) do
if playerTraining.dummyPos == targetPos then
playersOnDummy = playersOnDummy + 1
end
Expand All @@ -43,10 +43,10 @@ function exerciseTraining.onUse(player, item, fromPosition, target, toPosition,
return true
end

onExerciseTraining[playerId] = {}
if not onExerciseTraining[playerId].event then
onExerciseTraining[playerId].event = addEvent(ExerciseEvent, 0, playerId, targetPos, item.itemid, targetId)
onExerciseTraining[playerId].dummyPos = targetPos
_G.OnExerciseTraining[playerId] = {}
if not _G.OnExerciseTraining[playerId].event then
_G.OnExerciseTraining[playerId].event = addEvent(ExerciseEvent, 0, playerId, targetPos, item.itemid, targetId)
_G.OnExerciseTraining[playerId].dummyPos = targetPos
player:setTraining(true)
player:setStorageValue(Storage.IsTraining, os.time() + 30)
end
Expand Down
12 changes: 6 additions & 6 deletions data-canary/scripts/creaturescripts/login.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function login.onLogin(player)
end

-- Stamina
nextUseStaminaTime[player.uid] = 0
_G.NextUseStaminaTime[player.uid] = 0

-- Promotion
local vocation = player:getVocation()
Expand All @@ -33,9 +33,9 @@ function login.onLogin(player)
player:registerEvent("DropLoot")
player:registerEvent("BossParticipation")

if onExerciseTraining[player:getId()] then -- onLogin & onLogout
stopEvent(onExerciseTraining[player:getId()].event)
onExerciseTraining[player:getId()] = nil
if _G.OnExerciseTraining[player:getId()] then -- onLogin & onLogout
stopEvent(_G.OnExerciseTraining[player:getId()].event)
_G.OnExerciseTraining[player:getId()] = nil
player:setTraining(false)
end

Expand Down Expand Up @@ -98,10 +98,10 @@ function login.onLogin(player)
local playerId = player:getId()

-- Stamina
nextUseStaminaTime[playerId] = 1
_G.NextUseStaminaTime[playerId] = 1

-- EXP Stamina
nextUseXpStamina[playerId] = 1
_G.NextUseXpStamina[playerId] = 1

-- Set Client XP Gain Rate --
if configManager.getBoolean(configKeys.XP_DISPLAY_MODE) then
Expand Down
10 changes: 5 additions & 5 deletions data-canary/scripts/creaturescripts/logout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ local logout = CreatureEvent("PlayerLogout")

function logout.onLogout(player)
local playerId = player:getId()
if nextUseStaminaTime[playerId] then
nextUseStaminaTime[playerId] = nil
if _G.NextUseStaminaTime[playerId] then
_G.NextUseStaminaTime[playerId] = nil
end

if onExerciseTraining[playerId] then
stopEvent(onExerciseTraining[playerId].event)
onExerciseTraining[playerId] = nil
if _G.OnExerciseTraining[playerId] then
stopEvent(_G.OnExerciseTraining[playerId].event)
_G.OnExerciseTraining[playerId] = nil
player:setTraining(false)
end
return true
Expand Down
2 changes: 1 addition & 1 deletion data-canary/scripts/movements/tiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function tile.onStepIn(creature, item, position, fromPosition)
local depotItem = playerPosition:getTile():getItemByType(ITEM_TYPE_DEPOT)
if depotItem ~= nil then
local depotItems = 0
for id = 1, configManager.getNumber("depotBoxes") do
for id = 1, configManager.getNumber(configKeys.DEPOT_BOXES) do
depotItems = depotItems + player:getDepotChest(id, true):getItemHoldingCount()
end
player:sendTextMessage(MESSAGE_FAILURE, "Your depot contains " .. depotItems .. " item" .. (depotItems > 1 and "s." or ".") .. "\
Expand Down
14 changes: 11 additions & 3 deletions data-otservbr-global/npc/hireling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function createHirelingType(HirelingName)
end

local npcConfig = {}
local enableBankSystem = {}

npcConfig.name = HirelingName
npcConfig.description = HirelingName
Expand Down Expand Up @@ -355,6 +356,7 @@ function createHirelingType(HirelingName)
end

npcType.onDisappear = function(npc, creature)
enableBankSystem[creature:getId()] = nil
npcHandler:onDisappear(npc, creature)
end

Expand All @@ -363,6 +365,7 @@ function createHirelingType(HirelingName)
end

npcType.onCloseChannel = function(npc, creature)
enableBankSystem[creature:getId()] = nil
npcHandler:onCloseChannel(npc, creature)
end

Expand Down Expand Up @@ -586,7 +589,9 @@ function createHirelingType(HirelingName)
elseif MsgContains(message, "stash") then
if hireling:hasSkill(HIRELING_SKILLS.STEWARD) then
npcHandler:say(GREETINGS.STASH, npc, creature)
player:setSpecialContainersAvailable(true)
player:openStash(true)
player:sendTextMessage(MESSAGE_FAILURE, "Your supply stash contains " .. player:getStashCount() .. " item" .. (player:getStashCount() > 1 and "s." or "."))
else
sendSkillNotLearned(npc, creature, HIRELING_SKILLS.STEWARD)
end
Expand Down Expand Up @@ -614,15 +619,18 @@ function createHirelingType(HirelingName)
npcHandler:setTopic(playerId, TOPIC.SERVICES)
npcHandler:say("Alright then, I will be here.", npc, creature)
end
elseif npcHandler:getTopic(playerId) >= TOPIC.BANK and npcHandler:getTopic(playerId) < TOPIC.FOOD then
elseif npcHandler:getTopic(playerId) == TOPIC.BANK then
enableBankSystem[playerId] = true
elseif npcHandler:getTopic(playerId) >= TOPIC.FOOD and npcHandler:getTopic(playerId) < TOPIC.GOODS then
handleFoodActions(npc, creature, message)
end
if enableBankSystem[playerId] then
-- Parse bank
npc:parseBank(message, npc, creature, npcHandler)
-- Parse guild bank
npc:parseGuildBank(message, npc, creature, playerId, npcHandler)
-- Normal messages
npc:parseBankMessages(message, npc, creature, npcHandler)
elseif npcHandler:getTopic(playerId) >= TOPIC.FOOD and npcHandler:getTopic(playerId) < TOPIC.GOODS then
handleFoodActions(npc, creature, message)
end
return true
end
Expand Down
63 changes: 59 additions & 4 deletions data-otservbr-global/npc/lynda.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,61 @@ local function creatureSayCallback(npc, creature, type, message)
end
end

local function tryEngage(npc, creature, message, keywords, parameters, node)
local player = Player(creature)
local playerStatus = getPlayerMarriageStatus(player:getGuid())
local playerSpouse = getPlayerSpouse(player:getGuid())
if playerStatus == MARRIED_STATUS then -- check if the player is already married
npcHandler:say("You are already married to {" .. player:getName() .. "}.", npc, creature)
elseif playerStatus == PROPOSED_STATUS then --check if the player already made a proposal to some1 else
npcHandler:say("You already made a wedding proposal to {" .. player:getName() .. "}. You can always remove the proposal by saying {remove} proposal.", npc, creature)
else
local candidate = getPlayerGUIDByName(message)
if candidate == 0 then -- check if there is actually a player called like this
npcHandler:say("A player with this name does not exist.", npc, creature)
elseif candidate == player:getGuid() then -- if it's himself, cannot marry
npcHandler:say("You REALLY want to marry yourself? c'mon, be serious.", npc, creature)
else
if player:getItemCount(ITEM_WEDDING_RING) == 0 or player:getItemCount(9586) == 0 then -- check for items (wedding ring and outfit box)
npcHandler:say("As I said, you need a wedding ring and the wedding outfit box in order to marry.", npc, creature)
else
local candidateStatus = getPlayerMarriageStatus(candidate)
local candidateSpouse = getPlayerSpouse(candidate)
if candidateStatus == MARRIED_STATUS then -- if the player you want to marry is already married and to whom
npcHandler:say("{" .. getPlayerNameById(candidate) .. "} is already married to {" .. getPlayerNameById(candidateSpouse) .. "}.", npc, creature)
elseif candidateStatus == PROPACCEPT_STATUS then -- if the player you want to marry is already going to marry some1 else
npcHandler:say("{" .. getPlayerNameById(candidate) .. "} is already engaged to {" .. getPlayerNameById(candidateSpouse) .. "} and they will going to marry soon.", npc, creature)
elseif candidateStatus == PROPOSED_STATUS then -- if he/she already made a proposal to some1
if candidateSpouse == player:getGuid() then -- if this someone is you.
-- if this some1 is not you
npcHandler:say("Since both of you are willing to marry, I accept to celebrate your marriage, go prepare yourself, and tell me when you are ready for the {celebration}", npc, creature)
player:removeItem(ITEM_WEDDING_RING, 1)
player:removeItem(9586, 1) -- wedding outfit box
player:addOutfit(329) --Wife
player:addOutfit(328) --Husb
setPlayerMarriageStatus(player:getGuid(), PROPACCEPT_STATUS)
setPlayerMarriageStatus(candidate, PROPACCEPT_STATUS)
setPlayerSpouse(player:getGuid(), candidate)
local player = Player(getPlayerNameById(candidate))
player:addOutfit(329)
player:addOutfit(328)
else
npcHandler:say("{" .. getPlayerNameById(candidate) .. "} already made a wedding proposal to {" .. getPlayerNameById(candidateSpouse) .. "}.", npc, creature)
end
else -- if the player i want to propose doesn't have other proposal
npcHandler:say("Ok, now let's wait and see if {" .. getPlayerNameById(candidate) .. "} accepts your proposal. I'll give you back your wedding ring as soon as {" .. getPlayerNameById(candidate) .. "} accepts your proposal or you {remove} it.", npc, creature)
player:removeItem(ITEM_WEDDING_RING, 1)
player:removeItem(9586, 1)
setPlayerMarriageStatus(player:getGuid(), PROPOSED_STATUS)
setPlayerSpouse(player:getGuid(), candidate)
end
end
end
end
keywordHandler:moveUp(player, 1)
return false
end

local function confirmWedding(npc, creature, message, keywords, parameters, node)
local player = Player(creature)
local playerStatus = getPlayerMarriageStatus(player:getGuid())
Expand Down Expand Up @@ -199,12 +254,12 @@ local function confirmRemoveEngage(npc, creature, message, keywords, parameters,
setPlayerMarriageStatus(player:getGuid(), 0)
setPlayerSpouse(player:getGuid(), -1)
npcHandler:say(parameters.text, npc, creature)
keywordHandler:moveUp(parameters.moveup)
keywordHandler:moveUp(player, parameters.moveup)
end
node:addChildKeyword({ "yes" }, removeEngage, { moveup = 3, text = "Ok, your marriage proposal to {" .. getPlayerNameById(playerSpouse) .. "} has been removed. Take your wedding ring back." })
else
npcHandler:say("You don't have any pending proposal to be removed.", npc, creature)
keywordHandler:moveUp(2)
keywordHandler:moveUp(player, 2)
end
return true
end
Expand All @@ -225,12 +280,12 @@ local function confirmDivorce(npc, creature, message, keywords, parameters, node
setPlayerMarriageStatus(spouse, 0)
setPlayerSpouse(spouse, -1)
npcHandler:say(parameters.text, npc, creature)
keywordHandler:moveUp(parameters.moveup)
keywordHandler:moveUp(player, parameters.moveup)
end
node:addChildKeyword({ "yes" }, divorce, { moveup = 3, text = "Ok, you are now divorced of {" .. getPlayerNameById(playerSpouse) .. "}. Think better next time after marrying someone." })
else
npcHandler:say("You aren't married to get a divorce.", npc, creature)
keywordHandler:moveUp(2)
keywordHandler:moveUp(player, 2)
end
return true
end
Expand Down
12 changes: 6 additions & 6 deletions data-otservbr-global/scripts/actions/other/exercise_training.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function exerciseTraining.onUse(player, item, fromPosition, target, toPosition,
local targetId = target:getId()

if target:isItem() and isDummy(targetId) then
if onExerciseTraining[playerId] then
if _G.OnExerciseTraining[playerId] then
player:sendTextMessage(MESSAGE_FAILURE, "You are already training!")
return true
end
Expand All @@ -42,7 +42,7 @@ function exerciseTraining.onUse(player, item, fromPosition, target, toPosition,
return true
end
local playersOnDummy = 0
for _, playerTraining in pairs(onExerciseTraining) do
for _, playerTraining in pairs(_G.OnExerciseTraining) do
if playerTraining.dummyPos == targetPos then
playersOnDummy = playersOnDummy + 1
end
Expand All @@ -59,10 +59,10 @@ function exerciseTraining.onUse(player, item, fromPosition, target, toPosition,
return true
end

onExerciseTraining[playerId] = {}
if not onExerciseTraining[playerId].event then
onExerciseTraining[playerId].event = addEvent(ExerciseEvent, 0, playerId, targetPos, item.itemid, targetId)
onExerciseTraining[playerId].dummyPos = targetPos
_G.OnExerciseTraining[playerId] = {}
if not _G.OnExerciseTraining[playerId].event then
_G.OnExerciseTraining[playerId].event = addEvent(ExerciseEvent, 0, playerId, targetPos, item.itemid, targetId)
_G.OnExerciseTraining[playerId].dummyPos = targetPos
player:setTraining(true)
player:setStorageValue(Storage.IsTraining, os.time() + cooldown)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have started training on an exercise dummy.")
Expand Down
8 changes: 4 additions & 4 deletions data-otservbr-global/scripts/actions/other/potions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ function flaskPotion.onUse(player, item, fromPosition, target, toPosition, isHot
end

-- Delay potion
if not playerDelayPotion[player:getId()] then
playerDelayPotion[player:getId()] = 0
if not _G.PlayerDelayPotion[player:getId()] then
_G.PlayerDelayPotion[player:getId()] = 0
end
if playerDelayPotion[player:getId()] > systemTime() then
if _G.PlayerDelayPotion[player:getId()] > systemTime() then
player:sendTextMessage(MESSAGE_FAILURE, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
return true
end
Expand Down Expand Up @@ -284,7 +284,7 @@ function flaskPotion.onUse(player, item, fromPosition, target, toPosition, isHot

player:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ITEM_USE_POTION, player:isInGhostMode() and nil or player)
-- Delay potion
playerDelayPotion[player:getId()] = systemTime() + 500
_G.PlayerDelayPotion[player:getId()] = systemTime() + 500

if potion.func then
potion.func(player)
Expand Down
12 changes: 6 additions & 6 deletions data-otservbr-global/scripts/creaturescripts/others/login.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ function playerLogin.onLogin(player)
player:initializeLoyaltySystem()

-- Stamina
nextUseStaminaTime[playerId] = 1
_G.NextUseStaminaTime[playerId] = 1

-- EXP Stamina
nextUseXpStamina[playerId] = 1
_G.NextUseXpStamina[playerId] = 1

-- Concoction Duration
nextUseConcoctionTime[playerId] = 1
_G.NextUseConcoctionTime[playerId] = 1

if player:getAccountType() == ACCOUNT_TYPE_TUTOR then
local msg = [[:: Tutor Rules
Expand Down Expand Up @@ -275,10 +275,10 @@ function playerLogin.onLogin(player)

player:getFinalLowLevelBonus()

if onExerciseTraining[player:getId()] then
if _G.OnExerciseTraining[player:getId()] then
-- onLogin & onLogout
stopEvent(onExerciseTraining[player:getId()].event)
onExerciseTraining[player:getId()] = nil
stopEvent(_G.OnExerciseTraining[player:getId()].event)
_G.OnExerciseTraining[player:getId()] = nil
player:setTraining(false)
end
return true
Expand Down
10 changes: 5 additions & 5 deletions data-otservbr-global/scripts/creaturescripts/others/logout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local playerLogout = CreatureEvent("PlayerLogout")
function playerLogout.onLogout(player)
local playerId = player:getId()

if nextUseStaminaTime[playerId] ~= nil then
nextUseStaminaTime[playerId] = nil
if _G.NextUseStaminaTime[playerId] ~= nil then
_G.NextUseStaminaTime[playerId] = nil
end

player:saveSpecialStorage()
Expand All @@ -22,9 +22,9 @@ function playerLogout.onLogout(player)
end
end

if onExerciseTraining[playerId] then
stopEvent(onExerciseTraining[playerId].event)
onExerciseTraining[playerId] = nil
if _G.OnExerciseTraining[playerId] then
stopEvent(_G.OnExerciseTraining[playerId].event)
_G.OnExerciseTraining[playerId] = nil
player:setTraining(false)
end

Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/scripts/movements/others/tiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function tiles.onStepIn(creature, item, position, fromPosition)

if depotItem ~= nil then
local depotItems = 0
for id = 1, configManager.getNumber("depotBoxes") do
for id = 1, configManager.getNumber(configKeys.DEPOT_BOXES) do
depotItems = depotItems + player:getDepotChest(id, true):getItemHoldingCount()
end

Expand Down
Loading

0 comments on commit a0da360

Please sign in to comment.