Skip to content

Commit

Permalink
Lua code format - (Stylua)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 4, 2024
1 parent dd2f967 commit 09aef6b
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 108 deletions.
48 changes: 24 additions & 24 deletions data-otservbr-global/lib/others/soulpit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ SoulPit = {
["Purple Butterfly"] = "butterfly soul core (purple)",
["Butterfly"] = "butterfly soul core (blue)",
["Blue Butterfly"] = "butterfly soul core (blue)",
["Red Butterfly"] = "butterfly soul core (red)"
["Red Butterfly"] = "butterfly soul core (red)",
},
monstersDifficulties = {
["Harmless"] = 1,
["Trivial"] = 2,
["Easy"] = 3,
["Medium"] = 4,
["Hard"] = 5,
["Challenge"] = 6
}
["Challenge"] = 6,
},
},
encounter = nil,
kickEvent = nil,
Expand All @@ -32,79 +32,79 @@ SoulPit = {
{
pos = Position(32371, 31155, 8),
teleport = Position(32373, 31138, 8),
effect = CONST_ME_TELEPORT
effect = CONST_ME_TELEPORT,
},
{
pos = Position(32371, 31156, 8),
teleport = Position(32373, 31138, 8),
effect = CONST_ME_TELEPORT
effect = CONST_ME_TELEPORT,
},
{
pos = Position(32371, 31157, 8),
teleport = Position(32373, 31138, 8),
effect = CONST_ME_TELEPORT
effect = CONST_ME_TELEPORT,
},
{
pos = Position(32371, 31158, 8),
teleport = Position(32373, 31138, 8),
effect = CONST_ME_TELEPORT
effect = CONST_ME_TELEPORT,
},
{
pos = Position(32371, 31159, 8),
teleport = Position(32373, 31138, 8),
effect = CONST_ME_TELEPORT
}
effect = CONST_ME_TELEPORT,
},
},
waves = {
[1] = {
stacks = {
[1] = 7
}
[1] = 7,
},
},
[2] = {
stacks = {
[1] = 4,
[5] = 3
}
[5] = 3,
},
},
[3] = {
stacks = {
[1] = 5,
[15] = 2
}
[15] = 2,
},
},
[4] = {
stacks = {
[1] = 3,
[5] = 3,
[40] = 1
}
}
[40] = 1,
},
},
},
effects = {
[1] = CONST_ME_TELEPORT,
[5] = CONST_ME_ORANGETELEPORT,
[15] = CONST_ME_REDTELEPORT,
[40] = CONST_ME_PURPLETELEPORT
[40] = CONST_ME_PURPLETELEPORT,
},
possibleAbilities = {
"overpowerSoulPit",
"enrageSoulPit",
"opressorSoulPit"
"opressorSoulPit",
},
bossAbilities = {
overpowerSoulPit = {
player = true,
monster = false
monster = false,
},
enrageSoulPit = {
player = false,
monster = true
monster = true,
},
opressorSoulPit = {
player = false,
monster = true
}
monster = true,
},
},
timeToKick = 3 * 1000, -- 3 seconds
checkMonstersDelay = 4.5 * 1000, -- 4.5 seconds | The check delay should never be less than the timeToSpawnMonsters.
Expand Down
168 changes: 84 additions & 84 deletions data/scripts/actions/items/soul_prism.lua
Original file line number Diff line number Diff line change
@@ -1,106 +1,106 @@
local soulPrism = Action()

local function getNextDifficultyLevel(currentLevel)
for level, value in pairs(SoulPit.SoulCoresConfiguration.monstersDifficulties) do
if value == currentLevel + 1 then
return level
end
end
return nil
for level, value in pairs(SoulPit.SoulCoresConfiguration.monstersDifficulties) do
if value == currentLevel + 1 then
return level
end
end
return nil
end

local function getPreviousDifficultyLevel(currentLevel)
for level, value in pairs(SoulPit.SoulCoresConfiguration.monstersDifficulties) do
if value == currentLevel - 1 then
return level
end
end
return nil
for level, value in pairs(SoulPit.SoulCoresConfiguration.monstersDifficulties) do
if value == currentLevel - 1 then
return level
end
end
return nil
end

local function getSoulCoreItemForMonster(monsterName)
local lowerMonsterName = monsterName:lower()
local soulCoreName = SoulPit.SoulCoresConfiguration.monsterVariationsSoulCore[monsterName]
if soulCoreName then
local newSoulCoreId = getItemIdByName(soulCoreName)
if newSoulCoreId then
return newSoulCoreId
end
else
local newMonsterSoulCore = monsterName .. " soul core"
local newSoulCoreId = getItemIdByName(newMonsterSoulCore)
if newSoulCoreId then
return newSoulCoreId
end
end
return false
local lowerMonsterName = monsterName:lower()
local soulCoreName = SoulPit.SoulCoresConfiguration.monsterVariationsSoulCore[monsterName]

if soulCoreName then
local newSoulCoreId = getItemIdByName(soulCoreName)
if newSoulCoreId then
return newSoulCoreId
end
else
local newMonsterSoulCore = monsterName .. " soul core"
local newSoulCoreId = getItemIdByName(newMonsterSoulCore)
if newSoulCoreId then
return newSoulCoreId
end
end

return false
end

function soulPrism.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local itemName = target:getName()
local monsterName = itemName:match("^(.-) soul core")
if not monsterName then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use Soul Prism with a Soul Core.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local itemName = target:getName()
local monsterName = itemName:match("^(.-) soul core")

if not monsterName then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use Soul Prism with a Soul Core.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local monsterType = MonsterType(monsterName)
if not monsterType then
player:sendTextMessage(MESSAGE_GAME_HIGHLIGHT, "Invalid monster type. Please contact an administrator.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local monsterType = MonsterType(monsterName)
if not monsterType then
player:sendTextMessage(MESSAGE_GAME_HIGHLIGHT, "Invalid monster type. Please contact an administrator.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local currentDifficulty = monsterType:getBestiaryStars()
local nextDifficultyLevel = getNextDifficultyLevel(currentDifficulty)
local nextDifficultyMonsters = nil
local currentDifficulty = monsterType:getBestiaryStars()
local nextDifficultyLevel = getNextDifficultyLevel(currentDifficulty)
local nextDifficultyMonsters = nil

if nextDifficultyLevel then
nextDifficultyMonsters = monsterType:getMonstersByBestiaryStars(SoulPit.SoulCoresConfiguration.monstersDifficulties[nextDifficultyLevel])
else
nextDifficultyLevel = currentDifficulty
nextDifficultyMonsters = monsterType:getMonstersByBestiaryStars(SoulPit.SoulCoresConfiguration.monstersDifficulties[currentDifficulty])
end
if nextDifficultyLevel then
nextDifficultyMonsters = monsterType:getMonstersByBestiaryStars(SoulPit.SoulCoresConfiguration.monstersDifficulties[nextDifficultyLevel])
else
nextDifficultyLevel = currentDifficulty
nextDifficultyMonsters = monsterType:getMonstersByBestiaryStars(SoulPit.SoulCoresConfiguration.monstersDifficulties[currentDifficulty])
end

if #nextDifficultyMonsters == 0 then
player:sendTextMessage(MESSAGE_GAME_HIGHLIGHT, "No monsters available for the next difficulty level. Please contact an administrator.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if #nextDifficultyMonsters == 0 then
player:sendTextMessage(MESSAGE_GAME_HIGHLIGHT, "No monsters available for the next difficulty level. Please contact an administrator.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local newMonsterType = nextDifficultyMonsters[math.random(#nextDifficultyMonsters)]
local newSoulCoreItem = getSoulCoreItemForMonster(newMonsterType:getName())
if not newSoulCoreItem then -- Retry a second time.
newSoulCoreItem = getSoulCoreItemForMonster(newMonsterType:getName())
if not newSoulCoreItem then
player:sendTextMessage(MESSAGE_GAME_HIGHLIGHT, "Failed to generate a Soul Core. Please contact an administrator.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
end
local newMonsterType = nextDifficultyMonsters[math.random(#nextDifficultyMonsters)]
local newSoulCoreItem = getSoulCoreItemForMonster(newMonsterType:getName())
if not newSoulCoreItem then -- Retry a second time.
newSoulCoreItem = getSoulCoreItemForMonster(newMonsterType:getName())
if not newSoulCoreItem then
player:sendTextMessage(MESSAGE_GAME_HIGHLIGHT, "Failed to generate a Soul Core. Please contact an administrator.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
end

if player:getFreeCapacity() < ItemType(newSoulCoreItem):getWeight() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You do not have enough capacity.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if player:getFreeCapacity() < ItemType(newSoulCoreItem):getWeight() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You do not have enough capacity.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

if math.random(100) <= SoulPit.SoulCoresConfiguration.chanceToGetOminousSoulCore then
player:addItem(49163, 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received an Ominous Soul Core.")
else
player:addItem(newSoulCoreItem, 1)
player:removeItem(target:getId(), 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received a " .. newMonsterType:getName() .. " soul core.")
end
player:removeItem(item:getId(), 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
return true
if math.random(100) <= SoulPit.SoulCoresConfiguration.chanceToGetOminousSoulCore then
player:addItem(49163, 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received an Ominous Soul Core.")
else
player:addItem(newSoulCoreItem, 1)
player:removeItem(target:getId(), 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received a " .. newMonsterType:getName() .. " soul core.")
end
player:removeItem(item:getId(), 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
return true
end

soulPrism:id(49164)
soulPrism:register()
soulPrism:register()

0 comments on commit 09aef6b

Please sign in to comment.