Skip to content

自定义专长

自定义专长类必须从 Feat 派生。

cs
internal class FeatMyExample: Feat

应用事件

由于 Elin 将所有专长效果都写在 Feat.Apply 这个方法中,CWL 提供了一个事件 _OnApply,通过在你的专长类中定义一个可选的事件处理 _OnApply 以便应用你自己的专长效果:

cs
internal class FeatMyExample : Feat
{
    internal void _OnApply(int add, ElementContainer eleOwner, bool hint)
    {
        if (hint) {
            hints.Add("This is a custom feat"); // 可选
        } else {
            // 修改属性、设置潜力、应用效果等
            // 只有在不是 hint 模式时才执行这些
            eleOwner.ModBase(SKILL.life, add * 15);
            eleOwner.ModPotential(SKILL.DEX, add * 2);
            // 其他内容
        }
    }
}

这并不要求引用 CustomWhateverLoader.dll。

图标

自定义专长还可以拥有自定义图标,您的图标需要放置在 Texture 文件夹中,使用与 alias 相同的文件名,例如 featMyExample.png。然后重写 GetIcon 方法,将图标重定向到该图标:

cs
internal class FeatMyExample : Feat
{
    public override Sprite GetIcon(string suffix = "") 
    { 
        return SpriteSheet.Get(source.alias); 
    } 
}

如果纹理大小不是32x32,CWL会将其调整为32x32。

自动获取

使用标签 addEleOnLoad,玩家在加载时将自动获得这个专长。

This project is an unofficial documentation site and is not affiliated with, endorsed by, or associated with Elin or Lafrontier / Noa. All trademarks are the property of their respective owners.