- 欢迎来到Minecraft插件百科!
- 对百科编辑一脸懵逼?帮助:快速入门带您快速熟悉百科编辑!
- 因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289
Magic/Custom Spells:修订间差异
第90行: | 第90行: | ||
如果可以避免,则不建议使用这类法术,最好还是使用基于'''actions'''【行为】编写的技能(即现在通行的常用技能)。无论如何,一些技能(如工程魔法)还尚未换用新模式。 | 如果可以避免,则不建议使用这类法术,最好还是使用基于'''actions'''【行为】编写的技能(即现在通行的常用技能)。无论如何,一些技能(如工程魔法)还尚未换用新模式。 | ||
== | == Actions【行为】 == | ||
Most spells now use the [[Action System|Actions]]. The '''actions''' section is used to define what actions a spell will perform when cast. | Most spells now use the [[Action System|Actions]]. The '''actions''' section is used to define what actions a spell will perform when cast. |
2021年7月30日 (五) 12:04的版本
插件自定义法术
Magic的法术可以非常复杂,从零开始可能很困难,所以如果默认的内部法术里面有类似于你心中理想的法术,可以试试在此基础上修改修改
Magic的法术类似于脚本事件,可以包含十分复杂的规则、行为和逻辑,借此制作高度自由化的视觉以及游戏体验
工具和参考
在阅读了以下教程后,有些网页工具就显得非常有用了:
- 参考指南 深入所有细节,列出了所有参数、行为、效果以及其他本指南中提到的 Legacy version 1.13-版本专用
- Default survival spell list 查看更高级的内置生存服技能的相关信息,并且把游戏中的关键词转化为相应内容以查到正确的配置
教学
本教程将由魔法导弹技能开始学习,逐步拨云见日地了解它的组成
分析法术
多数法术有五个主要部分,我们每次讨论一个:
- Base Properties: 基础的法术设置,比如图标、SP消耗和SP获取量,以及一些法杖升级或使用/cast parameters无法更改的内容
- Actions: 完善的法术使用Modern spells use the 行为系统, 可以让你灵活地自定义法术的行为,实现你所想的效果
- Effects: 有多种施法时产生的视觉效果,一般由施法多个过程触发
- Parameters: 行为需要参数来改变它们的视觉效果。参数可以作为进阶法术、法杖或使用/cast parameters时的必备部分,更加直接和方便地测试法术的效果。译者注:参数包含如技能伤害、范围、时效等内容
- Costs: 法术需要一些消耗才能释放,大多数情况消耗法力,当然物品、金钱和生命值也是可以作为消耗的
基础配置
拿Magic Missile【魔法导弹】技能举例, 它的配置文件在这.
missile:
这是技能的 "关键" 名。当使用/cast命令或/wand命令时,显示的技能名就是这个,支持非英文
icon: diamond_axe:160 icon_disabled: diamond_hoe:160 icon_url: http://textures.minecraft.net/texture/2ba95570c7b712713632d4c0d2fc66906613d3850a596a0267c6d763fe741ac
上述三个分别是:图标、不可用图标(如缺少法力、冷却未到)、图标URL。技能的图标,表现为在游戏中它显示成什么,通常在法杖、商店中作为物品时显示为这里设置的图标
Magic可以使用资源包里的图标(默认技能使用的图标就是),当然原版物品、玩家头颅也可以。如果config.yml的 "url_icons_enabled"设置为true,技能将会使用icon_url 以通过自定义材质创建玩家头颅作为图标。
如果不这样设置,那么技能将会采用icon属性中的内容作为图标。当一个技能暂不可用时 (法力不足、处于冷却、没有权限) ,则会采用 icon_disabled 属性中的内容作为图标 (头颅图标不支持icon_disabled)。
在官方提供的资源包中,每一个技能的不可用图标会和正常图标相同,但是会多一个红色的 "no" 标志覆盖在上面
upgrade_required_path: beginner upgrade_required_casts: 40
法术是可以进阶的,进阶法术可通过间隔符号"|"定义,这样的话 "missile|2"就代表着第二级别的 Magic Missile【魔法导弹】 Level 2。
法术的继承是根据上一级来的,这意味着未覆盖的设置将继承上一级的设置(比如二级技能只是参数里面的伤害和一级不一样,只写了damage的参数,其余继承一级技能的所有设置)
举例说明,请查阅Magic Missile【魔法导弹】 ,二级的魔法导弹会提高射程和伤害
这些设置决定了进阶这一功能如何运作,恰如魔法导弹的进阶,你必须处于"Beginner"【初学者】 熟练度并且成功释放法术40次
category: combat
技能可以设置类别,主要用于技能书的管理,或用于/spells 命令
worth: 150 earns_sp: 8 earns_cooldown: 10000
这些设置项决定了 技能点 在此技能的运作方式。 worth 属性指此法术技能点 is the cost of the spell in spell points. (或金钱数, 需要有技能商店的设置)
earns_sp 属性决定了释放这一法术可获得的技能点 最大值 。当一个技能被释放时,玩家获得技能点,技能则会进入一段时间的冷却,在这段时间内,法术成功释放时额外获得的技能点数量将会有所削减。这个机制可以防止玩家反复释放技能刷技能点。
earns_cooldown 属性决定了技能点的获取冷却持续多久。注意,这并不是严格的冷却时间,在冷却时间内仍然可以获得技能点,但是会根据上次获得技能点的时间成比例减少。
例如,首次使用Magic Missile【魔法导弹】,将可以获得8技能点,如果在五秒后使用 (假定这个技能自身的冷却是10秒) ,就只会获得4技能点
Magic Missile 【魔法导弹】也是玩家的默认法杖上自带的第一个法术,作为一个默认的教学类技能,它的技能点获取冷却其实是相当短的,其他的法术默认设置都是15分钟
当Magic Missile【魔法导弹】升级时,它的技能点冷却就和其他法术相同了(其实说的还是插件默认给的配置,可以忽略)
游戏内文本
如需本地化游戏文本, 可通过messages.yml修改全部的游戏内文本。每一个技能的名字和描述都可以在"spells" 部分被找到
不管怎样,处于方便起见你也可以在技能的基础配置里设置 name【名字】 和 description【描述】
法术类
一些老的法术,如SuperBlob【超级气泡】,这一技能就使用了如此一个技能类属性:
superblob: class: ConstructSpell
这些法术早于action【行为】系统,所以这类技能不能使用actions【行为】部分
这些发射的表现形式完全硬代码写死。每一个技能都拥有它独立的类,请查阅此处提供的源代码
如果可以避免,则不建议使用这类法术,最好还是使用基于actions【行为】编写的技能(即现在通行的常用技能)。无论如何,一些技能(如工程魔法)还尚未换用新模式。
Actions【行为】
Most spells now use the Actions. The actions section is used to define what actions a spell will perform when cast.
Let's look at Magic Missile again:
actions: cast: - class: CustomProjectile actions: - class: Damage - class: BreakBlock ignore_result: true
There can be multiple sections of actions, but most spells will have only cast, the actions performed when this spell is cast.
Actions are often a hierarchy, meaning one action may have "child" actions that it is responsible for running under certain conditions.
Each action must have at least a class property, this defines what action it is. Classes can be found on the Actions page, or you can look at the source code here.
Note that when referring to the source code, the "Action" part of the class name may be omitted when you use it in a spell configuration.
Many spells in the builtin configs start off with the "CustomProjectile" action. This action creates a virtual projectile (not a vanilla snowball, arrow, etc) with some extremely customizable behavior.
When the projectile hits a target (either block or entity) it will run it's actions list.
In this case, when Magic Missile hits it will perform the Damage action and the BreakBlock action. Both are performed no matter the target, but if hitting a block Damage will do nothing, if hitting an entity BreakBlock will do nothing.
Action Parameters
Every action has some parameters that can change its behavior. These parameters can be put in two places: As properties directly on an action in the actions list, or as common shared parameters in the parameters section (see below).
In this case, the BreakBlock action has ignore_result set to true.
Every action returns a result, generally success, fail or no_target. For a spell to count as a successful cast, at least one action must return success. This is the only way for it to earn SP, or have the cast count towards the spell upgrade counter.
In the case of Magic Missile, breaking blocks is more of a secondary cosmetic effect, and does not count towards earning SP. You must hit and damage an entity for Magic Missile to count as a success.
And so, "ignore_result: true" on the BreakBlock action says to ignore the result of that action, meaning that Damage is the only action that matters for the overall result of the spell.
Effects
The effects section defines the visual effects that a spell will use. Spells should generally at least have a cast effects section so that something visual happens when the spell is cast. Generally some particle FX and a sound are good to make a spell feel meaningful.
Let's look at Magic Missile:
cast: - class: EffectSingle sound: magic.zap_crack location: origin color_override: color effectlib: class: ConeEffect iterations: 10 particle: redstone lengthGrow: 0.1 radiusGrow: 0.003 updateLocations: false updateDirections: false
The cast section will run when the spell is cast. Each section is really a list, so you can run multiple different effects on cast. Each section in the list can have a few properties:
- class: The class of effect. This is sort of outdated and can mostly be ignored and omitted. EffectSingle means to run a single effect, but most effects in Magic now defer to EffectLib. Other options are EffectRing, EffectTrail and EffectTransform but they are rarely used.
- sound: A sound effect to play, which can be a custom sound from a resource pack (such as with "magic.zapcrack" here or a builtin vanilla sound, using its Sound enum. **soundpitch** and sound_volume can also be used to modify the sound.
- location: Where the effect should play. This can be origin (the caster), target or both.
- color_override: Wands have personalized colors which can be used by spells. The color_override property tells the effectlib effects to use the wand color as one if its parameters (usually color, which is how the color of most effectlib effects is controlled). This only works with the redstone and mob_spell particles.
- effectlib: Magic is deeply integrated with EffectLib and most spells use an effectlib effect. See here for details on configuring effectlib effects.
Magic Missile also has a "tick" effect list:
tick: - particle: redstone location: target
In this case you can see that class has been omitted, EffectSingle will be used as the default class.
The tick effect list is a special set of effects used by the CustomProjectile action. These effects will be shown on every server tick while the projectile is running. They may be shown multiple times per tick, depending on the projectile velocity and configuration, so it's best not to put anything too complex in here.
In this case, we are showing a single particle, whose names come from the EffectLib particle enum.
Magic Missile has several other effect blocks, too many to list here. It has special effects for headshots, hitting blocks, etc. If you're curious, take a look at [the configs].(https://github.com/elBukkit/MagicPlugin/blob/master/Magic/src/main/resources/examples/survival/spells/missile.yml#L18).
Parameters
Spells have several base parameters that can be seen here: SpellParameters
Each action also has its own parameters, which can be seen on the Actions page, though it is not completely up to date. Action parameters can also be found in the source code of each action, by searching for the "prepare" method and looking at what it reads out of its configuration.
Parameters in the parameters section affect all actions in the spell.
Let's look at Magic Missile (TODO: Flesh this out)
parameters: allow_max_range: true velocity: 200 range: 24 hitbox: true target_type: Damageable player_damage: 2 entity_damage: 4 target_breakables: 1 cooldown: 1000 reorient: false destructible: solid destructible_durability: 50 break_durability: 2 undo: 10000
Headshots
The CustomProjectile action can detect when you hit an entity in the head. In this case, it may run a separate set of headshot actions, or in some cases (like Magic Missile) just use some extra parameters:
headshot_parameters: damage_multiplier: 1.5
So a headshot with Magic Missile multiplies the damage done by 150%.
Costs
Costs are lists of costs required to cast the spell. It is most often just mana, like this:
costs: mana: 15
Requirements
Spells can have requirements assigned to them, which much be met in order for the player to purchase and use them. This can be used to create reasearch or teching paths, requiring players to have a certain class, skill, spell, etc, before they can purchase the spell.
Right now the current requirements are supported:
- Type: skillapi
- skill - Requires the player to have the specified SkillAPI skill
- class - Requires the player to have the specified SkillAPI class
Here is an example requirement block, which might appear in a spell, Selector or other config. It requires the player to have the skillapi skill enchanting
requirements:
- type: skillapi
- skill: enchanting
type specifies the type of requirement
skill further specifies that a skill from skillAPI is required, and what that skill is