这篇条目有关 Source引擎。如需详情,点击这里。

$declaresequence

From Valve Developer Community
< Zh
Revision as of 08:20, 28 January 2025 by MoRanYue (talk | contribs) (deepseek translation)
Jump to navigation Jump to search
English (en)中文 (zh)Translate (Translate)
Info content.png
This page needs to be translated.
This page either contains information that is only partially or incorrectly translated, or there isn't a translation yet.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article complies with the alternate languages guide.(en)

$declaresequence是一个QC 命令,可在所有的 起源 起源 游戏中使用。 它用于前向声明一个[[序列|sequence(en)]]。

当您希望添加其他未在本地声明的序列作为层时(例如,这些序列实际上是外部 .mdl 文件的一部分,参见[[$includemodel|$includemodel(en)]]),此命令非常有用。$declaresequence 会创建一个空的序列条目,以便可以设置本地序列指针,并在运行时用实际的序列索引覆盖这些引用。

简单来说:$declaresequence 可以用于告诉编译器,声明的序列将从[[$includemodel|$includemodel(en)]]中获取,而未声明的序列将从当前编译中获取。这在多人游戏模组中通过更改声明序列的顺序来防止序列索引不匹配时非常有用。
声明的序列将按照 $declaresequence 行的出现顺序进行编译,而不是按照原始 $includemodel 文件的顺序。如果您希望保持 $includemodel 的序列顺序而不做任何更改,则不需要使用 $declaresequence。

Warning.png警告:如果您使用两个具有相同名称序列的[[$includemodel|$includemodel(en)]].mdl 文件,$declaresequence 将无法区分哪个 mdl 的动画被声明,最终会以相同名称声明两者。
通常情况下,如果使用[[$sequence|$sequence(en)]],会出现“重复序列”错误,但使用 declaresequence 在编译时不会产生此错误,但在游戏中可能会看到结果。

语法

 $declaresequence (序列名称)

示例

如果您想替换模型的某个动画,同时使用[[$includemodel|$includemodel(en)]]中的所有其他动画,则需要创建一个 DeclareSequence.qci 文件,列出所有动画。[[Crowbar|Crowbar(en)]] 可以为您生成此文件。
然后只需注释掉您希望声明的序列,并在其位置添加一个 $sequence。

...
$declaresequence "melee_sweep_FirstAidKit"
$declaresequence "use_cola"
$declaresequence "melee_sweep_cola"

//$declaresequence "use_ammopack"
$sequence "use_ammopack" "anims/use_ammopack_NEW" fadein 0.2 fadeout 0.2 fps 30

$declaresequence "crouch_use_ammopack"
$declaresequence "melee_sweep_ammopack"
$declaresequence "Defibrillate_Incap_Standing"
...

当然,您需要使用 $includemodel 和 $include 命令将 declaresequence.qci 文件和 $includemodel 添加到您的编译 QC 文件中。

//包含原始 anim_teenangst.mdl 以从中获取动画
$includemodel "survivors/animaTeenAngst.mdl"
//声明序列以复制所有动画但替换一个(或多个)
$include "anim_teenangst_DeclareSequence.qci"