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

45 lines
1.4 KiB
Lua

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
local condition = Condition(CONDITION_HASTE)
condition:setParameter(CONDITION_PARAM_TICKS, 5000)
condition:setFormula(1.9, 40, 1.9, 40)
combat:addCondition(condition)
local spell = Spell("instant")
function spell.onCastSpell(creature, variant)
local summons = creature:getSummons()
if summons and type(summons) == "table" and #summons > 0 then
for i = 1, #summons do
local summon = summons[i]
local summon_t = summon:getType()
if summon_t and summon_t:familiar() then
local deltaSpeed = math.max(creature:getBaseSpeed() - summon:getBaseSpeed(), 0)
local FamiliarSpeed = ((summon:getBaseSpeed() + deltaSpeed) * 0.9) - 72
local FamiliarHaste = Condition(CONDITION_HASTE)
FamiliarHaste:setParameter(CONDITION_PARAM_TICKS, 5000)
FamiliarHaste:setParameter(CONDITION_PARAM_SPEED, FamiliarSpeed)
summon:addCondition(FamiliarHaste)
end
end
end
return combat:execute(creature, variant)
end
spell:name("Charge")
spell:words("utani tempo hur")
spell:group("support")
spell:vocation("knight;true", "elite knight;true")
spell:id(131)
spell:cooldown(2 * 1000)
spell:groupCooldown(2 * 1000)
spell:level(25)
spell:mana(100)
spell:isSelfTarget(true)
spell:isAggressive(false)
spell:isPremium(true)
spell:castSound(SOUND_EFFECT_TYPE_SPELL_CHARGE)
spell:register()