canary/data/scripts/spells/support/magic_shield.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

36 lines
1.1 KiB
Lua

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
local spell = Spell("instant")
function spell.onCastSpell(creature, var)
local condition = Condition(CONDITION_MANASHIELD)
condition:setParameter(CONDITION_PARAM_TICKS, 180000)
local player = creature:getPlayer()
local grade = player:upgradeSpellsWOD("Magic Shield")
local shield = 300 + 7.6 * player:getLevel() + 7 * player:getMagicLevel()
if grade >= WHEEL_GRADE_REGULAR then
shield = shield * 1.25
end
if player then
condition:setParameter(CONDITION_PARAM_MANASHIELD, math.min(player:getMaxMana(), shield))
end
creature:addCondition(condition)
return combat:execute(creature, var)
end
spell:name("Magic Shield")
spell:words("utamo vita")
spell:group("support")
spell:vocation("druid;true", "elder druid;true", "sorcerer;true", "master sorcerer;true")
spell:castSound(SOUND_EFFECT_TYPE_SPELL_MAGIC_SHIELD)
spell:id(44)
spell:cooldown(14 * 1000)
spell:groupCooldown(2 * 1000)
spell:level(14)
spell:mana(50)
spell:isSelfTarget(true)
spell:isAggressive(false)
spell:register()