基本信息函数
GetId
获取法术的ID
spell:GetId()
-- 检查法术ID并执行特定逻辑
local spellId = spell:GetId()
if spellId == 133 then -- 火球术
print("玩家释放了火球术!")
end
GetCaster
获取法术的施法者
spell:GetCaster()
-- 获取施法者并发送消息
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
caster:SendBroadcastMessage("你释放了一个强大的法术!")
end
GetTarget
获取法术的目标
spell:GetTarget()
-- 检查法术目标
local target = spell:GetTarget()
if target and target:IsPlayer() then
target:SendBroadcastMessage("你被法术击中了!")
end
法术控制函数
Cancel
取消法术的施放
spell:Cancel()
-- 在特定条件下取消法术
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
if player:GetLevel() < 10 then
spell:Cancel()
player:SendBroadcastMessage("等级不足,无法释放此法术!")
end
end
SetDamage
设置法术的伤害值
spell:SetDamage(damage)
-- 根据施法者等级调整伤害
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local level = player:GetLevel()
local newDamage = spell:GetDamage() * (1 + level * 0.1)
spell:SetDamage(newDamage)
end
法术效果函数
GetDamage
获取法术的伤害值
spell:GetDamage()
-- 获取并显示法术伤害
local damage = spell:GetDamage()
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
caster:SendBroadcastMessage("法术伤害:" .. damage)
end
GetHeal
获取法术的治疗值
spell:GetHeal()
-- 获取治疗量并增强效果
local heal = spell:GetHeal()
if heal > 0 then
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
if player:GetClass() == 5 then -- 牧师
spell:SetHeal(heal * 1.2) -- 牧师治疗效果+20%
end
end
end
SetHeal
设置法术的治疗值
spell:SetHeal(heal)
-- 根据施法者属性调整治疗量
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local level = player:GetLevel()
local baseHeal = spell:GetHeal()
local newHeal = baseHeal + (level * 10) -- 每级增加10点治疗
spell:SetHeal(newHeal)
end
法术目标和范围函数
GetTargetDest
获取法术目标位置坐标
spell:GetTargetDest()
-- 获取法术目标位置
local x, y, z = spell:GetTargetDest()
if x and y and z then
print(string.format("法术目标位置: X=%.2f, Y=%.2f, Z=%.2f", x, y, z))
end
GetUnitType
获取法术目标的单位类型
spell:GetUnitType()
-- 根据目标类型调整法术效果
local unitType = spell:GetUnitType()
local target = spell:GetTarget()
if unitType == 7 and target then -- 目标是NPC
local damage = spell:GetDamage()
spell:SetDamage(damage * 1.5) -- 对NPC伤害增加50%
end
法术状态和属性函数
GetCastTime
获取法术施法时间
spell:GetCastTime()
-- 检查施法时间并给予提示
local castTime = spell:GetCastTime()
local caster = spell:GetCaster()
if castTime > 3000 and caster and caster:IsPlayer() then -- 超过3秒
local player = caster:ToPlayer()
player:SendBroadcastMessage("正在施放强力法术,请保持专注!")
end
GetPowerType
获取法术消耗的能量类型
spell:GetPowerType()
-- 检查法术能量类型
local powerType = spell:GetPowerType()
local powerNames = {
[0] = "法力值",
[1] = "怒气",
[2] = "专注",
[3] = "能量",
[6] = "符文能量"
}
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local typeName = powerNames[powerType] or "未知"
player:SendBroadcastMessage("消耗能量类型: " .. typeName)
end
GetPowerCost
获取法术的能量消耗
spell:GetPowerCost()
-- 检查法术消耗并给予折扣
local powerCost = spell:GetPowerCost()
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
if player:GetLevel() >= 70 then -- 高级玩家享受折扣
local newCost = math.floor(powerCost * 0.9) -- 10%折扣
spell:SetPowerCost(newCost)
player:SendBroadcastMessage("高级玩家法术消耗减少10%!")
end
end
SetPowerCost
设置法术的能量消耗
spell:SetPowerCost(cost)
-- 动态调整法术消耗
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local originalCost = spell:GetPowerCost()
-- 根据玩家装备调整消耗
local hasSpecialItem = player:HasItem(12345, 1) -- 特殊法术装备
if hasSpecialItem then
local reducedCost = math.floor(originalCost * 0.8) -- 减少20%消耗
spell:SetPowerCost(reducedCost)
player:SendBroadcastMessage("特殊装备减少了法术消耗!")
end
end
法术修改和增强函数
AddSpellMod
为法术添加修正效果
spell:AddSpellMod(modType, value)
-- 根据天赋和装备添加法术修正
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local spellId = spell:GetId()
-- 火系法术增强
if spellId == 133 or spellId == 2136 then -- 火球术或火焰冲击
-- 检查是否有火系天赋
if player:HasSpell(11069) then -- 火焰专精天赋
spell:AddSpellMod(0, 25) -- 增加25%伤害
player:SendBroadcastMessage("火焰专精增强了法术威力!")
end
-- 检查特殊装备
if player:HasItem(11324, 1) then -- 火焰法杖
spell:AddSpellMod(1, -15) -- 减少15%施法时间
end
end
end
GetSpellSchool
获取法术的魔法学派
spell:GetSpellSchool()
-- 根据法术学派应用不同效果
local spellSchool = spell:GetSpellSchool()
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
-- 法术学派对应表
local schoolNames = {
[1] = "物理", [2] = "神圣", [4] = "火焰",
[8] = "自然", [16] = "冰霜", [32] = "暗影",
[64] = "奥术"
}
local schoolName = schoolNames[spellSchool] or "未知"
-- 根据学派给予专精加成
if spellSchool == 4 and player:GetClass() == 8 then -- 火系法师
local damage = spell:GetDamage()
spell:SetDamage(damage * 1.1) -- 火系专精+10%
player:SendBroadcastMessage("火系专精生效!")
elseif spellSchool == 16 and player:GetClass() == 8 then -- 冰系法师
-- 冰系法术有几率冰冻目标
local target = spell:GetTarget()
if target and math.random(1, 100) <= 20 then -- 20%几率
target:AddAura(12484, caster) -- 冰冻效果
end
end
end
GetSpellLevel
获取法术的等级要求
spell:GetSpellLevel()
-- 检查法术等级并调整效果
local spellLevel = spell:GetSpellLevel()
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local playerLevel = player:GetLevel()
-- 如果玩家等级远高于法术等级,增强效果
local levelDiff = playerLevel - spellLevel
if levelDiff > 10 then
local bonusMultiplier = 1 + (levelDiff * 0.02) -- 每级差距+2%
local damage = spell:GetDamage()
spell:SetDamage(math.floor(damage * bonusMultiplier))
player:SendBroadcastMessage(string.format(
"高等级加成: +%.0f%% 伤害",
(bonusMultiplier - 1) * 100
))
end
end
法术效果和光环函数
HasAura
检查目标是否有指定光环效果
target:HasAura(auraId)
-- 检查目标状态并调整法术效果
local target = spell:GetTarget()
local caster = spell:GetCaster()
if target and caster then
-- 检查目标是否有护盾效果
if target:HasAura(1459) then -- 奥术智慧
-- 对有奥术智慧的目标,法术效果减半
local damage = spell:GetDamage()
spell:SetDamage(damage * 0.5)
if caster:IsPlayer() then
caster:SendBroadcastMessage("目标有魔法护盾,伤害减少!")
end
end
-- 检查目标是否被虚弱
if target:HasAura(702) then -- 虚弱诅咒
-- 对虚弱目标增加伤害
local damage = spell:GetDamage()
spell:SetDamage(damage * 1.3)
if caster:IsPlayer() then
caster:SendBroadcastMessage("目标被虚弱,造成额外伤害!")
end
end
end
AddAura
为目标添加光环效果
target:AddAura(auraId, caster)
-- 法术命中后添加额外效果
local target = spell:GetTarget()
local caster = spell:GetCaster()
local spellId = spell:GetId()
if target and caster then
-- 火球术有几率点燃目标
if spellId == 133 and math.random(1, 100) <= 15 then -- 15%几率
target:AddAura(11119, caster) -- 燃烧效果
if caster:IsPlayer() then
caster:SendBroadcastMessage("目标被点燃了!")
end
end
-- 冰霜法术有几率减速
if spellId == 116 and math.random(1, 100) <= 25 then -- 25%几率
target:AddAura(6136, caster) -- 冰霜减速
if caster:IsPlayer() then
caster:SendBroadcastMessage("目标被冰霜减速!")
end
end
end
RemoveAura
移除目标的指定光环效果
target:RemoveAura(auraId)
-- 驱散法术移除负面效果
local target = spell:GetTarget()
local caster = spell:GetCaster()
local spellId = spell:GetId()
if target and caster and spellId == 527 then -- 驱散魔法
-- 移除常见负面效果
local debuffs = {
702, -- 虚弱诅咒
1714, -- 腐蚀诅咒
6136, -- 冰霜减速
11119 -- 燃烧
}
local removedCount = 0
for _, debuffId in ipairs(debuffs) do
if target:HasAura(debuffId) then
target:RemoveAura(debuffId)
removedCount = removedCount + 1
end
end
if removedCount > 0 and caster:IsPlayer() then
caster:SendBroadcastMessage("成功驱散了 " .. removedCount .. " 个负面效果!")
end
end
GetDuration
获取法术的持续时间
spell:GetDuration()
-- 检查法术持续时间并调整效果
local duration = spell:GetDuration()
local caster = spell:GetCaster()
if duration > 0 and caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local playerLevel = player:GetLevel()
-- 高级玩家法术持续时间加成
if playerLevel >= 60 then
local newDuration = duration * 1.2 -- 增加20%持续时间
spell:SetDuration(newDuration)
player:SendBroadcastMessage("高级法师天赋:法术持续时间延长!")
end
player:SendBroadcastMessage("法术持续时间: " .. duration .. " 毫秒")
end
SetDuration
设置法术的持续时间
spell:SetDuration(duration)
-- 根据装备调整法术持续时间
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local spellId = spell:GetId()
-- 检查是否有延长持续时间的装备
if player:HasItem(12345, 1) then -- 特殊法杖
local currentDuration = spell:GetDuration()
spell:SetDuration(currentDuration * 1.5) -- 延长50%
player:SendBroadcastMessage("装备效果:法术持续时间延长!")
end
-- 特定法术的特殊处理
if spellId == 1459 then -- 奥术智慧
spell:SetDuration(1800000) -- 设置为30分钟
end
end
GetRange
获取法术的施法距离
spell:GetRange()
-- 检查法术射程并给予提示
local range = spell:GetRange()
local caster = spell:GetCaster()
local target = spell:GetTarget()
if caster and target then
local distance = caster:GetDistance(target)
if distance > range then
caster:SendBroadcastMessage("目标距离过远!最大射程: " .. range .. " 码")
spell:Cancel()
else
local rangePercent = (distance / range) * 100
if rangePercent > 80 then
caster:SendBroadcastMessage("目标在射程边缘,小心移动!")
end
end
end
法术效果和光环函数
AddAura
为目标添加光环效果
spell:AddAura(target, auraId, duration)
-- 添加特殊光环效果
local function AddSpecialAura(spell, target)
local caster = spell:GetCaster()
local spellId = spell:GetId()
if spellId == 133 then -- 火球术
-- 添加燃烧效果
spell:AddAura(target, 11366, 8000) -- 燃烧8秒
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
if player:GetLevel() >= 40 then
-- 高级玩家额外效果
spell:AddAura(target, 12654, 5000) -- 额外点燃效果
end
end
elseif spellId == 168 then -- 冰霜护甲
-- 添加减速光环
spell:AddAura(target, 6136, 30000) -- 寒冷效果30秒
end
end
RemoveAura
移除目标的指定光环
spell:RemoveAura(target, auraId)
-- 净化法术效果
local function PurifyTarget(spell, target)
local spellId = spell:GetId()
if spellId == 527 then -- 驱散魔法
-- 移除有害魔法效果
local harmfulAuras = {
11366, -- 燃烧
12654, -- 点燃
6136, -- 寒冷
1714 -- 诅咒
}
for _, auraId in ipairs(harmfulAuras) do
if target:HasAura(auraId) then
spell:RemoveAura(target, auraId)
target:SendBroadcastMessage("有害效果已被驱散!")
end
end
end
end
GetEffectValue
获取法术效果的数值
spell:GetEffectValue(effectIndex)
-- 分析法术效果数值
local function AnalyzeSpellEffects(spell)
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
player:SendBroadcastMessage("=== 法术效果分析 ===")
for i = 0, 2 do -- 检查3个效果槽
local effectValue = spell:GetEffectValue(i)
local effectType = spell:GetEffectType(i)
if effectValue and effectValue > 0 then
local effectNames = {
[1] = "瞬间伤害", [2] = "学习法术", [3] = "传送",
[6] = "治疗", [10] = "伤害护盾", [18] = "召唤",
[27] = "持续伤害", [28] = "召唤宠物"
}
local effectName = effectNames[effectType] or ("效果" .. effectType)
player:SendBroadcastMessage("效果" .. (i+1) .. ": " .. effectName .. " 数值: " .. effectValue)
end
end
end
end
SetEffectValue
设置法术效果的数值
spell:SetEffectValue(effectIndex, value)
-- 动态调整法术效果
local function AdjustSpellEffects(spell)
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local playerLevel = player:GetLevel()
local spellId = spell:GetId()
-- 根据等级调整法术效果
if spellId == 133 then -- 火球术
local baseDamage = spell:GetEffectValue(0)
local levelBonus = playerLevel * 2 -- 每级增加2点伤害
spell:SetEffectValue(0, baseDamage + levelBonus)
player:SendBroadcastMessage("等级加成:火球术伤害 +" .. levelBonus)
elseif spellId == 2061 then -- 快速治疗
local baseHealing = spell:GetEffectValue(0)
local spiritBonus = player:GetStat(5) * 1.5 -- 精神加成
spell:SetEffectValue(0, baseHealing + spiritBonus)
player:SendBroadcastMessage("精神加成:治疗效果 +" .. spiritBonus)
end
end
end
法术冷却和资源函数
GetCooldown
获取法术的冷却时间
spell:GetCooldown()
-- 检查法术冷却时间
local cooldown = spell:GetCooldown()
local caster = spell:GetCaster()
if cooldown > 0 and caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local cooldownSeconds = cooldown / 1000
player:SendBroadcastMessage("法术冷却时间: " .. cooldownSeconds .. " 秒")
-- 检查是否有减少冷却时间的天赋或装备
if player:HasSpell(11175) then -- 冰冷血脉天赋
local reducedCooldown = cooldown * 0.8 -- 减少20%冷却
spell:SetCooldown(reducedCooldown)
player:SendBroadcastMessage("天赋效果:冷却时间减少20%!")
end
end
SetCooldown
设置法术的冷却时间
spell:SetCooldown(cooldown)
-- 动态调整法术冷却
local function AdjustSpellCooldown(spell)
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local spellId = spell:GetId()
local currentCooldown = spell:GetCooldown()
-- VIP玩家冷却减免
if player:HasItem(99999, 1) then -- VIP徽章
local newCooldown = currentCooldown * 0.5 -- 减少50%冷却
spell:SetCooldown(newCooldown)
player:SendBroadcastMessage("VIP特权:法术冷却时间减半!")
end
-- 特定法术的特殊处理
if spellId == 1953 then -- 闪现术
-- 战斗中增加冷却时间
if player:IsInCombat() then
spell:SetCooldown(currentCooldown * 1.5)
player:SendBroadcastMessage("战斗中使用闪现,冷却时间增加!")
end
end
end
end
GetManaCost
获取法术的法力消耗
spell:GetManaCost()
-- 检查法术法力消耗
local manaCost = spell:GetManaCost()
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local currentMana = player:GetPower(0) -- 获取当前法力值
if currentMana < manaCost then
player:SendBroadcastMessage("法力不足!需要 " .. manaCost .. " 点法力")
spell:Cancel()
else
local manaPercent = (manaCost / player:GetMaxPower(0)) * 100
if manaPercent > 50 then
player:SendBroadcastMessage("警告:此法术消耗大量法力!")
end
player:SendBroadcastMessage("法术消耗: " .. manaCost .. " 法力")
end
end
SetManaCost
设置法术的法力消耗
spell:SetManaCost(cost)
-- 动态调整法术消耗
local function AdjustManaCost(spell)
local caster = spell:GetCaster()
if caster and caster:IsPlayer() then
local player = caster:ToPlayer()
local originalCost = spell:GetManaCost()
local playerLevel = player:GetLevel()
-- 高级玩家法力消耗减少
if playerLevel >= 70 then
local reducedCost = originalCost * 0.9 -- 减少10%
spell:SetManaCost(reducedCost)
player:SendBroadcastMessage("大师级法师:法力消耗减少10%!")
end
-- 检查法力节约装备
if player:HasItem(11324, 1) then -- 法力节约戒指
local newCost = originalCost * 0.85 -- 减少15%
spell:SetManaCost(newCost)
player:SendBroadcastMessage("装备效果:法力消耗减少!")
end
-- 特殊时间段法力消耗减半
local gameTime = GetGameTime()
local hour = math.floor(gameTime / 3600) % 24
if hour >= 0 and hour < 6 then -- 午夜到早晨6点
spell:SetManaCost(originalCost * 0.5)
player:SendBroadcastMessage("深夜魔法时刻:法力消耗减半!")
end
end
end
法术目标和范围函数
GetTargetCount
获取法术影响的目标数量
spell:GetTargetCount()
参数
无参数
返回值
number - 目标数量
示例
-- 群体法术效果调整
local function AdjustAOESpell(spell)
local targetCount = spell:GetTargetCount()
local caster = spell:GetCaster()
if targetCount > 5 then
-- 目标过多时减少伤害
local damage = spell:GetDamage()
local reducedDamage = damage * 0.8 -- 减少20%伤害
spell:SetDamage(reducedDamage)
if caster and caster:IsPlayer() then
caster:ToPlayer():SendBroadcastMessage("群体目标过多,伤害降低20%")
end
elseif targetCount >= 3 then
-- 中等目标数量时正常伤害
if caster and caster:IsPlayer() then
caster:ToPlayer():SendBroadcastMessage("群体法术命中 " .. targetCount .. " 个目标")
end
end
end
AddTarget
为法术添加额外目标
spell:AddTarget(unit)
参数
unit
(Unit)
要添加的目标单位
返回值
无返回值
示例
-- 智能目标扩展系统
local function SmartTargetExpansion(spell)
local caster = spell:GetCaster()
local originalTarget = spell:GetTarget()
if not caster or not originalTarget then return end
local spellId = spell:GetId()
-- 治疗法术自动扩展到队友
if spellId == 2061 then -- 快速治疗
local group = caster:GetGroup()
if group then
local members = group:GetMembers()
for _, member in pairs(members) do
if member ~= originalTarget and member:GetDistance(caster) <= 30 then
local healthPercent = (member:GetHealth() / member:GetMaxHealth()) * 100
if healthPercent < 50 then -- 血量低于50%
spell:AddTarget(member)
end
end
end
end
end
-- 攻击法术扩展到附近敌人
if spellId == 133 then -- 火球术
local nearbyEnemies = caster:GetNearbyEnemies(15) -- 15码范围
local addedTargets = 0
for _, enemy in pairs(nearbyEnemies) do
if enemy ~= originalTarget and addedTargets < 2 then
spell:AddTarget(enemy)
addedTargets = addedTargets + 1
end
end
if addedTargets > 0 and caster:IsPlayer() then
caster:ToPlayer():SendBroadcastMessage("火球术扩展到 " .. addedTargets .. " 个额外目标")
end
end
end
RemoveTarget
从法术中移除指定目标
spell:RemoveTarget(unit)
参数
unit
(Unit)
要移除的目标单位
返回值
无返回值
示例
-- 智能目标过滤系统
local function SmartTargetFilter(spell)
local caster = spell:GetCaster()
local spellId = spell:GetId()
-- 获取所有目标
local targets = spell:GetTargets() -- 假设有这个函数
for _, target in pairs(targets) do
local shouldRemove = false
-- 友善法术不应该影响敌人
if spell:IsPositive() and caster:IsHostileTo(target) then
shouldRemove = true
end
-- 攻击法术不应该影响队友
if spell:IsNegative() and caster:IsFriendlyTo(target) then
shouldRemove = true
end
-- 检查目标免疫
if target:IsImmuneTo(spellId) then
shouldRemove = true
if caster:IsPlayer() then
caster:ToPlayer():SendBroadcastMessage(target:GetName() .. " 对此法术免疫")
end
end
-- 检查距离限制
if caster:GetDistance(target) > spell:GetRange() then
shouldRemove = true
if caster:IsPlayer() then
caster:ToPlayer():SendBroadcastMessage(target:GetName() .. " 超出法术范围")
end
end
if shouldRemove then
spell:RemoveTarget(target)
end
end
end
法术修改器和增强函数
AddSpellMod
为法术添加修改器
spell:AddSpellMod(modType, value)
参数
modType
(number)
修改器类型
value
(number)
修改值
返回值
无返回值
示例
-- 动态法术增强系统
local function DynamicSpellEnhancement(spell)
local caster = spell:GetCaster()
if not caster or not caster:IsPlayer() then return end
local player = caster:ToPlayer()
local spellId = spell:GetId()
local playerLevel = player:GetLevel()
-- 等级加成系统
if playerLevel >= 60 then
spell:AddSpellMod(1, 20) -- 增加20%伤害
player:SendBroadcastMessage("大师级加成:法术效果提升20%")
elseif playerLevel >= 40 then
spell:AddSpellMod(1, 10) -- 增加10%伤害
player:SendBroadcastMessage("专家级加成:法术效果提升10%")
end
-- 装备加成检查
if player:HasItem(12345, 1) then -- 法师之杖
spell:AddSpellMod(2, -15) -- 减少15%法力消耗
player:SendBroadcastMessage("法师之杖:法力消耗减少15%")
end
-- 天赋加成
if player:HasSpell(11175) then -- 某个天赋
spell:AddSpellMod(3, -10) -- 减少10%施法时间
player:SendBroadcastMessage("天赋加成:施法时间减少10%")
end
-- 特殊时间加成
local gameTime = GetGameTime()
local hour = math.floor(gameTime / 3600) % 24
if hour >= 0 and hour < 6 then -- 深夜时段
spell:AddSpellMod(1, 25) -- 深夜魔法加成
player:SendBroadcastMessage("深夜魔法:法术威力大幅提升!")
end
end
GetSpellSchool
获取法术的魔法学派
spell:GetSpellSchool()
参数
无参数
返回值
number - 魔法学派ID
示例
-- 魔法学派专精系统
local function SpellSchoolSpecialization(spell)
local school = spell:GetSpellSchool()
local caster = spell:GetCaster()
if not caster or not caster:IsPlayer() then return end
local player = caster:ToPlayer()
local schoolNames = {
[1] = "物理", [2] = "神圣", [4] = "火焰", [8] = "自然",
[16] = "冰霜", [32] = "暗影", [64] = "奥术"
}
local schoolName = schoolNames[school] or "未知"
-- 检查玩家的学派专精
local playerClass = player:GetClass()
local specialization = player:GetData("spellSchoolSpec") or 0
if specialization == school then
-- 专精学派加成
local damage = spell:GetDamage()
spell:SetDamage(damage * 1.15) -- 增加15%伤害
player:SendBroadcastMessage(schoolName .. "学派专精:伤害提升15%")
-- 减少法力消耗
local manaCost = spell:GetManaCost()
spell:SetManaCost(manaCost * 0.9) -- 减少10%法力消耗
elseif school == 2 and playerClass == 5 then -- 牧师使用神圣法术
spell:AddSpellMod(1, 10) -- 牧师神圣法术加成
player:SendBroadcastMessage("牧师天赋:神圣法术威力提升")
elseif school == 4 and playerClass == 8 then -- 法师使用火焰法术
spell:AddSpellMod(1, 12) -- 法师火焰法术加成
player:SendBroadcastMessage("法师天赋:火焰法术威力提升")
end
-- 记录学派使用统计
local schoolStats = player:GetData("schoolStats") or {}
schoolStats[school] = (schoolStats[school] or 0) + 1
player:SetData("schoolStats", schoolStats)
end
SetSpellSchool
设置法术的魔法学派
spell:SetSpellSchool(school)
参数
school
(number)
魔法学派ID
返回值
无返回值
示例
-- 动态学派转换系统
local function DynamicSchoolConversion(spell)
local caster = spell:GetCaster()
if not caster or not caster:IsPlayer() then return end
local player = caster:ToPlayer()
local originalSchool = spell:GetSpellSchool()
local spellId = spell:GetId()
-- 特殊装备效果:学派转换
if player:HasItem(99999, 1) then -- 元素转换法杖
local conversionMap = {
[4] = 16, -- 火焰转冰霜
[16] = 8, -- 冰霜转自然
[8] = 4, -- 自然转火焰
[32] = 2, -- 暗影转神圣
[2] = 32 -- 神圣转暗影
}
local newSchool = conversionMap[originalSchool]
if newSchool then
spell:SetSpellSchool(newSchool)
local schoolNames = {
[2] = "神圣", [4] = "火焰", [8] = "自然",
[16] = "冰霜", [32] = "暗影", [64] = "奥术"
}
local oldName = schoolNames[originalSchool] or "未知"
local newName = schoolNames[newSchool] or "未知"
player:SendBroadcastMessage("元素转换:" .. oldName .. " → " .. newName)
end
end
-- 时间驱动的学派变化
local gameTime = GetGameTime()
local hour = math.floor(gameTime / 3600) % 24
if hour >= 6 and hour < 18 then -- 白天
if originalSchool == 32 then -- 暗影法术在白天转为神圣
spell:SetSpellSchool(2)
player:SendBroadcastMessage("白天的力量:暗影转为神圣")
end
else -- 夜晚
if originalSchool == 2 then -- 神圣法术在夜晚转为暗影
spell:SetSpellSchool(32)
player:SendBroadcastMessage("夜晚的力量:神圣转为暗影")
end
end
end