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

Zh/$declaresequence: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
(deepseek translation)
(deepseek translation)
 
Line 1: Line 1:
{{LanguageBar}}
{{LanguageBar}}
{{translate}}
{{translate}}
{{this is a|QC 命令|name=$declaresequence}} 它用于前向声明一个[[序列|{{L|sequence}}]]
{{this is a|QC 命令|name=$declaresequence}} 该命令用于前向声明一个{{L|sequence}}。


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


简单来说:$declaresequence 可以用于告诉编译器,声明的序列将从[[$includemodel|{{L|$includemodel}}]]中获取,而未声明的序列将从当前编译中获取。这在多人游戏模组中通过更改声明序列的顺序来防止序列索引不匹配时非常有用。<br>
简而言之:$declaresequence 可用于告知编译器,已声明的序列将从{{L|$includemodel}}中获取,而未声明的序列则来自当前编译。这对多人游戏模组中通过调整声明顺序来防止序列索引错位非常有效。<br>
声明的序列将按照 $declaresequence 行的出现顺序进行编译,而不是按照原始 $includemodel 文件的顺序。如果您希望保持 $includemodel 的序列顺序而不做任何更改,则不需要使用 $declaresequence。
声明序列将按照$declaresequence行的出现顺序编译,而非原$includemodel文件中的顺序。若需完全保留$includemodel的原始序列顺序且不作任何修改,则无需使用$declaresequence。
 
{{Warning|若使用两个包含同名序列的{{L|$includemodel}}.mdl文件,$declaresequence 将无法区分具体声明哪个模型的动画,最终会以相同名称同时声明两者。<br>
通常使用{{L|$sequence}}时会弹出"重复序列"错误,但使用declaresequence编译时不会报错,但游戏中可能出现异常表现。}}


{{Warning|如果您使用两个具有相同名称序列的[[$includemodel|{{L|$includemodel}}]].mdl 文件,$declaresequence 将无法区分哪个 mdl 的动画被声明,最终会以相同名称声明两者。<br>
通常情况下,如果使用[[$sequence|{{L|$sequence}}]],会出现“重复序列”错误,但使用 declaresequence 在编译时不会产生此错误,但在游戏中可能会看到结果。}}
== 语法 ==
== 语法 ==
<syntaxhighlight lang=php highlight=4>
<syntaxhighlight lang=php highlight=4>
  $declaresequence (序列名称)
  $declaresequence (序列名称)
</syntaxhighlight>
</syntaxhighlight>
{{ACategory|QC 命令|declaresequence}}
{{ACategory|QC Commands|declaresequence}}


== 示例 ==
== 示例 ==
如果您想替换模型的某个动画,同时使用[[$includemodel|{{L|$includemodel}}]]中的所有其他动画,则需要创建一个 DeclareSequence.qci 文件,列出所有动画。[[Crowbar|{{L|Crowbar}}]] 可以为您生成此文件。<br>
若需替换模型中的一个动画,同时保留{{L|$includemodel}}中的其他动画,需创建DeclareSequence.qci文件列出所有动画。{{L|Crowbar}}工具可自动生成该文件。<br>
然后只需注释掉您希望声明的序列,并在其位置添加一个 $sequence。
然后只需注释掉目标声明序列,并添加$sequence替换即可。
<syntaxhighlight lang=php highlight=6,7>
<syntaxhighlight lang=php highlight=6,7>
...
...
Line 32: Line 33:
$declaresequence "Defibrillate_Incap_Standing"
$declaresequence "Defibrillate_Incap_Standing"
...</syntaxhighlight>
...</syntaxhighlight>
当然,您需要使用 $includemodel 和 $include 命令将 declaresequence.qci 文件和 $includemodel 添加到您的编译 QC 文件中。
最后需要通过$includemodel和$include命令将declaresequence.qci文件与模型包含进编译QC文件:
<syntaxhighlight lang=php highlight=2,4>//包含原始 anim_teenangst.mdl 以从中获取动画
<syntaxhighlight lang=php highlight=2,4>//引用原始anim_teenangst.mdl获取动画
$includemodel "survivors/animaTeenAngst.mdl"
$includemodel "survivors/animaTeenAngst.mdl"
//声明序列以复制所有动画但替换一个(或多个)
//通过声明序列保留所有动画并替换指定部分
$include "anim_teenangst_DeclareSequence.qci"</syntaxhighlight>
$include "anim_teenangst_DeclareSequence.qci"</syntaxhighlight>

Latest revision as of 08:27, 28 January 2025

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(en)),此命令非常有用。$declaresequence 会创建一个空序列条目,使得本地序列指针可以被设置。在运行时,这些引用会被实际的序列索引覆盖。

简而言之:$declaresequence 可用于告知编译器,已声明的序列将从$includemodel(en)中获取,而未声明的序列则来自当前编译。这对多人游戏模组中通过调整声明顺序来防止序列索引错位非常有效。
声明序列将按照$declaresequence行的出现顺序编译,而非原$includemodel文件中的顺序。若需完全保留$includemodel的原始序列顺序且不作任何修改,则无需使用$declaresequence。

Warning.png警告:若使用两个包含同名序列的$includemodel(en).mdl文件,$declaresequence 将无法区分具体声明哪个模型的动画,最终会以相同名称同时声明两者。
通常使用$sequence(en)时会弹出"重复序列"错误,但使用declaresequence编译时不会报错,但游戏中可能出现异常表现。

语法

 $declaresequence (序列名称)

示例

若需替换模型中的一个动画,同时保留$includemodel(en)中的其他动画,需创建DeclareSequence.qci文件列出所有动画。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文件与模型包含进编译QC文件:

//引用原始anim_teenangst.mdl获取动画
$includemodel "survivors/animaTeenAngst.mdl"
//通过声明序列保留所有动画并替换指定部分
$include "anim_teenangst_DeclareSequence.qci"