canary/data/scripts/spells/attack/energy_wave.lua
Paco def12a7fcd
feat: add configurable retro spell learning system (#3971)
Add a config boolean to enable the retro spell learning system.

Main changes:
- Add retro spell learning support behind a configuration option.
- Update all spells to respect the new config.
- Update spell-related NPCs to handle the learning system according to TibiaWiki behavior.
- Update Dawnport NPCs for the retro spell learning flow.
- Update the Rookgaard Oracle to handle Monk vocation selection.

Validation:
- Debugged and tested on tibiatales.com using the Canary/TFS Crystal server distribution.

This allows servers to enable classic spell-learning behavior via config while keeping the existing spell behavior configurable.
2026-05-29 12:17:08 -03:00

52 lines
1.6 KiB
Lua

local function formulaFunction(player, level, maglevel)
local min = (level / 5) + (maglevel * 4.5)
local max = (level / 5) + (maglevel * 9)
return -min, -max
end
function onGetFormulaValues(player, level, maglevel)
return formulaFunction(player, level, maglevel)
end
function onGetFormulaValuesWOD(player, level, maglevel)
return formulaFunction(player, level, maglevel)
end
local function createCombat(area, areaDiagonal, combatFunc)
local initCombat = Combat()
initCombat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, combatFunc)
initCombat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
initCombat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
initCombat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
initCombat:setArea(createCombatArea(area, areaDiagonal))
return initCombat
end
local combat = createCombat(AREA_SQUAREWAVE5, AREADIAGONAL_SQUAREWAVE5, "onGetFormulaValues")
local combatWOD = createCombat(AREA_WAVE7, AREADIAGONAL_WAVE7, "onGetFormulaValuesWOD")
local spell = Spell("instant")
function spell.onCastSpell(creature, var)
local player = creature:getPlayer()
if creature and player then
if player:getWheelSpellAdditionalArea("Energy Wave") then
return combatWOD:execute(creature, var)
end
end
return combat:execute(creature, var)
end
spell:group("attack")
spell:id(13)
spell:name("Energy Wave")
spell:words("exevo vis hur")
spell:castSound(SOUND_EFFECT_TYPE_SPELL_ENERGY_WAVE)
spell:level(38)
spell:mana(170)
spell:needDirection(true)
spell:cooldown(8 * 1000)
spell:groupCooldown(2 * 1000)
spell:vocation("sorcerer;true", "master sorcerer;true")
spell:register()