法术效果函数
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