无法在AzerothCore中使自定义法术生效,求排查方案
自定义AzerothCore法术无响应排查求助
我在AzerothCore中创建了一个自定义法术(ID:400001,基于王者祝福复制修改),期望施法后能成功应用效果,同时Buff图标显示在屏幕右上角。但使用.cast 400001命令时无任何反应,服务器日志中也未找到相关错误信息,且我已完成创建自定义法术的标准流程,问题仍未解决。
已执行的操作步骤
- 以王者祝福为模板,通过法术编辑器复制生成新法术,设置法术ID为
400001 - 导出DBC文件,分别放置到服务器的
RelWithDebInfo/Data/dbc目录,以及WotLK客户端自定义补丁的data文件夹中 - 编写C++法术脚本,路径为
/src/server/scripts/Custom/DraconicBlood/draconic_blood.cpp,代码如下:
#include "ScriptMgr.h" #include "Player.h" #include "SpellAuras.h" #include "SpellScript.h" enum SpellIds { SPELL_DRACONIC_BLOOD = 400001 }; class DraconicBloodSpell : public SpellScriptLoader { public: DraconicBloodSpell() : SpellScriptLoader("DraconicBloodSpell") { } class DraconicBloodAuraScript : public AuraScript { PrepareAuraScript(DraconicBloodAuraScript); void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes mode) { Unit* target = GetTarget(); if (target->IsPlayer()) { Player* player = target->ToPlayer(); // Apply the stat increases as a percentage int32 strengthIncrease = static_cast<int32>(player->GetStat(STAT_STRENGTH) * 1.39f); // 39% increase int32 agilityIncrease = static_cast<int32>(player->GetStat(STAT_AGILITY) * 1.39f); int32 staminaIncrease = static_cast<int32>(player->GetStat(STAT_STAMINA) * 1.39f); int32 intellectIncrease = static_cast<int32>(player->GetStat(STAT_INTELLECT) * 1.39f); int32 spiritIncrease = static_cast<int32>(player->GetStat(STAT_SPIRIT) * 1.39f); player->SetStat(STAT_STRENGTH, strengthIncrease); player->SetStat(STAT_AGILITY, agilityIncrease); player->SetStat(STAT_STAMINA, staminaIncrease); player->SetStat(STAT_INTELLECT, intellectIncrease); player->SetStat(STAT_SPIRIT, spiritIncrease); } } void OnApplyResistance(AuraEffect const* aurEff, AuraEffectHandleModes mode) { Unit* target = GetTarget(); if (target->IsPlayer()) { Player* player = target->ToPlayer(); // Apply the resistance boosts player->SetResistance(SPELL_SCHOOL_NORMAL, player->GetResistance(SPELL_SCHOOL_NORMAL) + 450); player->SetResistance(SPELL_SCHOOL_HOLY, player->GetResistance(SPELL_SCHOOL_HOLY) + 450); player->SetResistance(SPELL_SCHOOL_FIRE, player->GetResistance(SPELL_SCHOOL_FIRE) + 450); player->SetResistance(SPELL_SCHOOL_NATURE, player->GetResistance(SPELL_SCHOOL_NATURE) + 450); player->SetResistance(SPELL_SCHOOL_FROST, player->GetResistance(SPELL_SCHOOL_FROST) + 450); player->SetResistance(SPELL_SCHOOL_SHADOW, player->GetResistance(SPELL_SCHOOL_SHADOW) + 450); player->SetResistance(SPELL_SCHOOL_ARCANE, player->GetResistance(SPELL_SCHOOL_ARCANE) + 450); } } void Register() override { OnEffectApply += AuraEffectApplyFn(DraconicBloodAuraScript::OnApply, EFFECT_0, SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, AURA_EFFECT_HANDLE_REAL); OnEffectApply += AuraEffectApplyFn(DraconicBloodAuraScript::OnApplyResistance, EFFECT_1, SPELL_AURA_MOD_RESISTANCE, AURA_EFFECT_HANDLE_REAL); } }; AuraScript* GetAuraScript() const override { return new DraconicBloodAuraScript(); } }; void AddSC_DraconicBloodSpell() { new DraconicBloodSpell(); }
- 在
custom_script_loader.cpp中注册该自定义法术脚本,代码如下:
void AddSC_DraconicBloodSpell(); // The name of this function should match: // void Add${NameOfDirectory}Scripts() void AddCustomScripts() { AddSC_DraconicBloodSpell(); }
- 在数据库的
spell_script_names表中添加记录:脚本标识符DraconicBloodSpell对应法术ID400001 - 重新配置CMake、清理并重建项目(构建过程无错误),同时删除WotLK客户端的缓存文件夹
恳请告知遗漏的步骤或有效的排查方法,感谢!
内容的提问来源于stack exchange,提问作者Proxy
相关产品推荐
相关产品推荐

