Skip to content

Commit

Permalink
exercise_training: improved msg.
Browse files Browse the repository at this point in the history
broadcast: removed unnecessary Webhook.sendMessage.
reward: fixes charges.
prision bosses: created flag to enable minus players. removed functions already created.
login: removed create torch when player login.
bosses teleports: fixes in 'clearBossRoom' function usage.
  • Loading branch information
elsongabriel committed Nov 14, 2023
1 parent b8bfcaa commit df24bd8
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 51 deletions.
1 change: 0 additions & 1 deletion config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ pvpRateDamageTakenPerLevel = 0.0 -- recommended to start with 0.1
pvpRateDamageReductionPerLevel = 0.0 -- recommended to start with 0.1
pvpMaxLevelDifference = 0


-- Wheel of destiny system
-- NOTE: set wheelSystemEnabled = false to disable the wheel of destiny
-- NOTE: only the wheel points are modified, all other data is on the client executable and cannot be modified
Expand Down
36 changes: 22 additions & 14 deletions data-otservbr-global/scripts/actions/roshamuul/prison/golden.lua
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
local setting = {
timeToFightAgain = 10,
clearRoomTime = 60, -- In hour
centerRoom = { x = 33528, y = 32334, z = 12 },
ignorePlayersCount = true,
clearRoomTime = 60, -- In minutes
leverPosition = Position(33606, 32362, 11),
centerRoom = Position(33528, 32334, 12),
range = 10,
storage = Storage.PrinceDrazzakTime,
clearRoomStorage = GlobalStorage.PrinceDrazzakEventTime,
bossName = "prince drazzak",
bossPosition = { x = 33528, y = 32333, z = 12 },
bossName = "Prince Drazzak",
bossPosition = Position(33528, 32333, 12),
}

local playerPositions = {
{ fromPos = { x = 33607, y = 32362, z = 11 }, toPos = { x = 33526, y = 32341, z = 12 } },
{ fromPos = { x = 33608, y = 32362, z = 11 }, toPos = { x = 33527, y = 32341, z = 12 } },
{ fromPos = { x = 33609, y = 32362, z = 11 }, toPos = { x = 33528, y = 32341, z = 12 } },
{ fromPos = { x = 33610, y = 32362, z = 11 }, toPos = { x = 33529, y = 32341, z = 12 } },
{ fromPos = { x = 33611, y = 32362, z = 11 }, toPos = { x = 33530, y = 32341, z = 12 } },
{ fromPos = Position(33607, 32362, 11), toPos = Position(33526, 32341, 12) },
{ fromPos = Position(33608, 32362, 11), toPos = Position(33527, 32341, 12) },
{ fromPos = Position(33609, 32362, 11), toPos = Position(33528, 32341, 12) },
{ fromPos = Position(33610, 32362, 11), toPos = Position(33529, 32341, 12) },
{ fromPos = Position(33611, 32362, 11), toPos = Position(33530, 32341, 12) },
}

local golden = Action()

function golden.onUse(player, item, fromPosition, target, toPosition, monster, isHotkey)
if toPosition == Position(33606, 32362, 11) then
function golden.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if toPosition == setting.leverPosition and not setting.ignorePlayersCount then
for i = 1, #playerPositions do
local creature = Tile(playerPositions[i].fromPos):getTopCreature()
if not creature then
Expand All @@ -30,11 +32,15 @@ function golden.onUse(player, item, fromPosition, target, toPosition, monster, i
end
end

if toPosition == Position(33606, 32362, 11) then
if roomIsOccupied(setting.centerRoom, setting.range, setting.range) or Game.getStorageValue(setting.clearRoomStorage) == 1 then
if toPosition == setting.leverPosition then
if roomIsOccupied(setting.centerRoom, setting.range, setting.range) then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting against the boss! You need wait awhile.")
return true
end
if Game.getStorageValue(setting.clearRoomStorage) == 1 then
Game.setStorageValue(setting.clearRoomStorage, 0)
clearRoom(setting.centerRoom, setting.range, setting.range, setting.clearRoomStorage)
end

for i = 1, #playerPositions do
local creature = Tile(playerPositions[i].fromPos):getTopCreature()
Expand All @@ -49,7 +55,9 @@ function golden.onUse(player, item, fromPosition, target, toPosition, monster, i
creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
else
return false
if not setting.ignorePlayersCount then
return false
end
end
end
item:remove()
Expand Down
26 changes: 1 addition & 25 deletions data-otservbr-global/scripts/actions/roshamuul/prison/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,6 @@ local config = {
},
}

local function roomIsOccupied(centerPosition, rangeX, rangeY)
local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
if #spectators ~= 0 then
return true
end

return false
end

local function clearBossRoom(playerId, centerPosition, rangeX, rangeY, exitPosition)
local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isPlayer() and spectator.uid == playerId then
spectator:teleportTo(exitPosition)
exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
end

if spectator:isMonster() then
spectator:remove()
end
end
end

local keys = Action()

function keys.onUse(player, item, fromPosition, target, toPosition, isHotkey)
Expand Down Expand Up @@ -93,7 +69,7 @@ function keys.onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have fifteen minutes to kill and loot this boss, else you will lose that chance.")

-- Let's roll
addEvent(clearBossRoom, 60 * tmpConfig.time * 1000, player:getId(), tmpConfig.centerPosition, tmpConfig.rangeX, tmpConfig.rangeY, tmpConfig.exitPosition)
addEvent(clearBossRoom, 60 * tmpConfig.time * 1000, player:getId(), monster.uid, tmpConfig.centerPosition, tmpConfig.rangeX, tmpConfig.rangeY, tmpConfig.exitPosition)
item:remove()
player:teleportTo(tmpConfig.newPosition)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function playerLogin.onLogin(player)
backpack:addItem(items[i][1], items[i][2])
end
end
player:addItem(2920, 1, true, 1, CONST_SLOT_AMMO)

db.query("UPDATE `players` SET `istutorial` = 0 where `id`=" .. player:getGuid())
-- Open channels
if table.contains({ TOWNS_LIST.DAWNPORT, TOWNS_LIST.DAWNPORT_TUTORIAL }, player:getTown():getId()) then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function entranceTeleport.onStepIn(creature, item, position, fromPosition)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:say("You have ten minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.", TALKTYPE_MONSTER_SAY)
player:setBossCooldown(setting.bossName, os.time() + 2 * 3600)
addEvent(clearBossRoom, 60 * 30 * 1000, player.uid, monster.uid, setting.bossPos, setting.range, fromPosition)
addEvent(clearBossRoom, 60 * 30 * 1000, player.uid, monster.uid, setting.bossPos, setting.range, setting.range, fromPosition)
return true
end
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function caveSpiderRoom.onStepIn(creature, item, position, fromPosition)
position:sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(room.newPos)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
addEvent(clearBossRoom, 60 * room.time * 1000, player.uid, room.centerPos, room.rangeX, room.rangeY, room.exitPos)
addEvent(clearBossRoom, 60 * room.time * 1000, player.uid, monster.uid, room.centerPos, room.rangeX, room.rangeY, room.exitPos)
player:setStorageValue(room.access, 10)
return true
end
Expand Down
2 changes: 1 addition & 1 deletion data/libs/exercise_training.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function ExerciseEvent(playerId, tilePosition, weaponId, dummyId)
end

if player:isTraining() == 0 then
player:sendTextMessage(MESSAGE_FAILURE, "You left training!")
player:sendTextMessage(MESSAGE_FAILURE, "You've stopped training!")
return LeaveTraining(playerId)
end

Expand Down
1 change: 0 additions & 1 deletion data/scripts/talkactions/gm/broadcast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function broadcast.onSay(player, words, param)

local text = player:getName() .. " broadcasted: " .. param
logger.info(text)
Webhook.sendMessage("Broadcast", text, WEBHOOK_COLOR_WARNING, announcementChannels["serverAnnouncements"])
for _, targetPlayer in ipairs(Game.getPlayers()) do
targetPlayer:sendPrivateMessage(player, param, TALKTYPE_BROADCAST)
end
Expand Down
13 changes: 7 additions & 6 deletions data/scripts/talkactions/player/reward.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
local config = {
items = {
{ id = 35284, charges = 64000 },
{ id = 35279, charges = 64000 },
{ id = 35281, charges = 64000 },
{ id = 35283, charges = 64000 },
{ id = 35282, charges = 64000 },
{ id = 35280, charges = 64000 },
{ id = 35284, charges = 64400 },
{ id = 35279, charges = 64400 },
{ id = 35281, charges = 64400 },
{ id = 35283, charges = 64400 },
{ id = 35282, charges = 64400 },
{ id = 35280, charges = 64400 },
{ id = 44066, charges = 64400 },
},
storage = tonumber(Storage.PlayerWeaponReward), -- storage key, player can only win once
}
Expand Down

0 comments on commit df24bd8

Please sign in to comment.