Adorius Black
Advanced OT User
- Joined
- Mar 31, 2020
- Messages
- 348
- Solutions
- 3
- Reaction score
- 226
Hi everyone,
Today I was just casually chatting with ChatGPT and we ended up creating this script. It looks pretty interesting. It works like "exevo gran mas vis", with the difference that each SQM has a random effect, and whichever effect hits the player is the one that applies to them.
By the way, I wanted to upload it to Resources → Spells, but I can’t anymore.
What do you think — is this a good script or complete nonsense? I don’t really understand LUA very well, but I tried to create a fully functional code. If anyone who knows more spots a bug, feel free to point it out

Today I was just casually chatting with ChatGPT and we ended up creating this script. It looks pretty interesting. It works like "exevo gran mas vis", with the difference that each SQM has a random effect, and whichever effect hits the player is the one that applies to them.
By the way, I wanted to upload it to Resources → Spells, but I can’t anymore.
What do you think — is this a good script or complete nonsense? I don’t really understand LUA very well, but I tried to create a fully functional code. If anyone who knows more spots a bug, feel free to point it out

LUA:
local animationDelay = 60
local combat = {}
local area = {
{{0},{0},{0},{3}},
{{0},{0},{1},{2}},
{{0},{1},{0},{2}},
{{1},{0},{0},{2}},
{{1},{0},{0},{0},{2}},
{{1},{0},{0},{0},{0},{2}},
}
local effects = {
CONST_ME_FIREAREA,
CONST_ME_ENERGYAREA,
CONST_ME_MAGIC_BLUE,
CONST_ME_HOLYDAMAGE,
CONST_ME_MORTAREA,
CONST_ME_CARNIPHILA,
CONST_ME_SMALLCLOUDS,
CONST_ME_POISONAREA,
CONST_ME_TELEPORT,
CONST_ME_EXPLOSIONAREA
}
-- Funkcia na náhodný damage podľa efektu
local function getRandomDamage(effect, level, maglevel)
local baseMin = (level / 5) + (maglevel * 3.6) + 22
local baseMax = (level / 5) + (maglevel * 6) + 37
-- Tu môžeš upraviť multiplikátory podľa efektu
if effect == CONST_ME_FIREAREA then
return -math.random(baseMin, baseMax)
elseif effect == CONST_ME_ENERGYAREA then
return -math.random(baseMin*0.8, baseMax*1.2)
elseif effect == CONST_ME_MAGIC_BLUE then
return -math.random(baseMin*0.5, baseMax*1.5)
elseif effect == CONST_ME_HOLYDAMAGE then
return -math.random(baseMin*1.5, baseMax*2)
else
return -math.random(baseMin, baseMax)
end
end
for i, a in ipairs(area) do
combat[i] = Combat()
combat[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) -- neutrálne, aby sa dali efekty meniť
combat[i]:setArea(createCombatArea(a))
end
local function executeCombat(_combat, cid, var, level, maglevel)
local player = Player(cid)
if player then
local effect = effects[math.random(#effects)]
_combat:setParameter(COMBAT_PARAM_EFFECT, effect)
local dmg = getRandomDamage(effect, level, maglevel)
_combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, dmg, 0, dmg) -- nastavenie damage pre túto vlnu
_combat:execute(player, var)
end
end
function onCastSpell(creature, var)
local player = creature:getPlayer()
if not player then return false end
local level = player:getLevel()
local maglevel = player:getMagicLevel()
for i, c in ipairs(combat) do
if i == 1 then
executeCombat(c, player:getId(), var, level, maglevel)
else
addEvent(executeCombat, animationDelay * (i - 1), c, player:getId(), var, level, maglevel)
end
end
return true
end

