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

40 lines
1.2 KiB
Lua

local condition = Condition(CONDITION_OUTFIT)
condition:setTicks(180000)
local spell = Spell("instant")
function spell.onCastSpell(creature, variant)
local returnValue = RETURNVALUE_NOERROR
local monsterType = MonsterType(variant:getString())
if not monsterType then
returnValue = RETURNVALUE_CREATUREDOESNOTEXIST
elseif not creature:hasFlag(PlayerFlag_CanIllusionAll) and not monsterType:isIllusionable() then
returnValue = RETURNVALUE_NOTPOSSIBLE
end
if returnValue ~= RETURNVALUE_NOERROR then
creature:sendCancelMessage(returnValue)
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
condition:setOutfit(monsterType:getOutfit())
creature:addCondition(condition)
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
return true
end
spell:name("Creature Illusion")
spell:words("utevo res ina")
spell:group("support")
spell:vocation("druid;true", "elder druid;true", "sorcerer;true", "master sorcerer;true")
spell:castSound(SOUND_EFFECT_TYPE_SPELL_CREATURE_ILLUSION)
spell:id(38)
spell:cooldown(2 * 1000)
spell:groupCooldown(2 * 1000)
spell:level(23)
spell:mana(100)
spell:hasParams(true)
spell:isAggressive(false)
spell:register()