Zh/List of CS:GO Script Functions: Difference between revisions
Dazainerau (talk | contribs) No edit summary |
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified) |
||
(54 intermediate revisions by 11 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LanguageBar|title = CSGO脚本函数列表}} | ||
| | {{Delisted|csgo}} | ||
}} | |||
{{toc-right}} | {{toc-right}} | ||
{{sq}} 这份清单包含了{{ | {{sq}} 这份清单包含了{{csgo|4}}中的与引擎相关的可用于{{L|VScript}}的{{L|Squirrel}}类、函数以及可用的变量. 加载一个地图然后执行<code>script_help</code>, 并且将<code>developer</code>的级别设置为至少1, 可以把这份清单中的部分内容显示于控制台中. 值得一提的是, <code>developer</code>的级别只要不为0, 且加载了任意的地图, 就可以把<code>script_help</code>指令所显示的内容转存到文件中. 步骤如下(请一步一步地在控制台中键入每一行指令): | ||
<code> | <code> | ||
Line 11: | Line 10: | ||
map de_nuke | map de_nuke | ||
developer 0 | developer 0 | ||
con_logfile dump. | con_logfile dump.log | ||
script_help | script_help | ||
con_logfile "" | con_logfile "" | ||
</code> | </code> | ||
这条内容由[//steamcommunity.com/id/utagawashii/ Dazai Nerau]译自英文版页面. 欢迎任何人补充新内容或者修改其中的错误. | |||
== 变量 == | == 变量 == | ||
Line 66: | Line 58: | ||
| | | | ||
|- | |- | ||
|<code>PI</code> | |||
|float | |||
|3.14159 | |||
|} | |} | ||
Line 76: | Line 71: | ||
所有游戏中的脚本句柄都可以从[[#CEntities|Entities]]中访问. 实体脚本可以通过 <code>self</code>来访问它们自身的脚本句柄. | 所有游戏中的脚本句柄都可以从[[#CEntities|Entities]]中访问. 实体脚本可以通过 <code>self</code>来访问它们自身的脚本句柄. | ||
==== | ==== 方法 ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! 函数 | ! 函数 | ||
Line 84: | Line 79: | ||
| <code>__KeyValueFromInt</code> | | <code>__KeyValueFromInt</code> | ||
| <code>void __KeyValueFromInt(string ''key'', int ''value'')</code> | | <code>void __KeyValueFromInt(string ''key'', int ''value'')</code> | ||
| 以整数设置实体的 | | 以整数设置实体的{{L|Keyvalue|键值(KeyValue)}}. 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用. | ||
|- | |- | ||
| <code>__KeyValueFromFloat</code> | | <code>__KeyValueFromFloat</code> | ||
Line 124: | Line 119: | ||
| <code>FirstMoveChild</code> | | <code>FirstMoveChild</code> | ||
| <code>handle FirstMoveChild()</code> | | <code>handle FirstMoveChild()</code> | ||
| | | 如果在层级中则获取第一个移动的子对象. | ||
|- | |- | ||
| <code>GetAngles</code> | | <code>GetAngles</code> | ||
| <code>Vector GetAngles()</code> | | <code>Vector GetAngles()</code> | ||
| 以[[#Vector|向量]] | | 以[[#Vector|向量]]形式获取实体的欧拉角(pitch, yaw, roll). | ||
|- | |- | ||
| <code>GetAngularVelocity</code> | | <code>GetAngularVelocity</code> | ||
Line 136: | Line 131: | ||
| <code>GetBoundingMaxs</code> | | <code>GetBoundingMaxs</code> | ||
| <code>Vector GetBoundingMaxs()</code> | | <code>Vector GetBoundingMaxs()</code> | ||
| | | 将实体边界框的最大范围以向量返回. | ||
|- | |||
| <code>GetBoundingMaxsOriented</code> | |||
| <code>Vector GetBoundingMaxsOriented()</code> | |||
| 将以对象为中心并考虑对象方向的实体边界框的最大范围以向量返回. | |||
|- | |- | ||
| <code>GetBoundingMins</code> | | <code>GetBoundingMins</code> | ||
| <code>Vector GetBoundingMins()</code> | | <code>Vector GetBoundingMins()</code> | ||
| 将实体边界框的最小范围以向量返回. | | 将实体边界框的最小范围以向量返回. | ||
|- | |||
| <code>GetBoundingMinsOriented</code> | |||
| <code>Vector GetBoundingMinsOriented()</code> | |||
| 将以对象为中心并考虑对象方向的实体边界框的最小范围以向量返回. | |||
|- | |- | ||
| <code>GetCenter</code> | | <code>GetCenter</code> | ||
Line 192: | Line 195: | ||
| <code>GetPreTemplateName</code> | | <code>GetPreTemplateName</code> | ||
| <code>string GetPreTemplateName()</code> | | <code>string GetPreTemplateName()</code> | ||
| | | Get the entity name stripped of template unique decoration. | ||
|- | |- | ||
| <code>GetRootMoveParent</code> | | <code>GetRootMoveParent</code> | ||
Line 224: | Line 227: | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
| <code>bool IsValid()</code> | | <code>bool IsValid()</code> | ||
| | | 返回句柄是否属于有效的实体. | ||
|- | |- | ||
| <code>NextMovePeer</code> | | <code>NextMovePeer</code> | ||
| <code>handle NextMovePeer()</code> | | <code>handle NextMovePeer()</code> | ||
| | | 返回统一移动层级的下一个实体. | ||
|- | |- | ||
| <code>PrecacheModel</code> | | <code>PrecacheModel</code> | ||
| <code>void PrecacheModel(string ''modelPath'')</code> | | <code>void PrecacheModel(string ''modelPath'')</code> | ||
| 在地图加载完成后预缓存一个模型. | | 在地图加载完成后预缓存一个模型,资源占用大. | ||
|- | |- | ||
| <code>PrecacheScriptSound</code> | | <code>PrecacheScriptSound</code> | ||
| <code>void PrecacheScriptSound(string ''soundName'')</code> | | <code>void PrecacheScriptSound(string ''soundName'')</code> | ||
| | | 在地图加载完成后预缓存一个声音,资源占用大. | ||
|- | |- | ||
| <code>PrecacheSoundScript</code> | | <code>PrecacheSoundScript</code> | ||
| <code>void PrecacheSoundScript(string ''soundScript'')</code> | | <code>void PrecacheSoundScript(string ''soundScript'')</code> | ||
| 预缓存一个将会被播放的声音. | | 预缓存一个将会被播放的声音,资源占用大. | ||
|- | |- | ||
| <code>SetAbsOrigin</code> | | <code>SetAbsOrigin</code> | ||
| <code>void SetAbsOrigin(Vector ''position'')</code> | | <code>void SetAbsOrigin(Vector ''position'')</code> | ||
| 与SetOrigin()功能相同. | | 与SetOrigin()功能相同,设置实体的绝对位置. | ||
|- | |- | ||
| <code>SetAngles</code> | | <code>SetAngles</code> | ||
Line 280: | Line 283: | ||
| <code>SetSize</code> | | <code>SetSize</code> | ||
| <code>void SetSize(Vector, Vector)</code> | | <code>void SetSize(Vector, Vector)</code> | ||
| | | 设置碰撞体积大小. | ||
|- | |- | ||
| <code>SetTeam</code> | | <code>SetTeam</code> | ||
Line 289: | Line 292: | ||
| <code>void SetVelocity(Vector ''velocity'')</code> | | <code>void SetVelocity(Vector ''velocity'')</code> | ||
| 设置实体的速度向量. | | 设置实体的速度向量. | ||
|- | |||
| <code>StopSound</code> | |||
| <code>void StopSound(String ''soundname'')</code> | |||
| 停止一个在实体上播放的声音. | |||
|- | |- | ||
| <code>ValidateScriptScope</code> | | <code>ValidateScriptScope</code> | ||
| <code>bool ValidateScriptScope()</code> | | <code>bool ValidateScriptScope()</code> | ||
| | | 返回实体的脚本域是否已被创建. | ||
|- | |- | ||
|} | |} | ||
Line 338: | Line 345: | ||
| <code>IsSequenceFinished</code> | | <code>IsSequenceFinished</code> | ||
| <code>bool IsSequenceFinished()</code> | | <code>bool IsSequenceFinished()</code> | ||
| | | 返回主序列是否已经播放完成. | ||
|- | |- | ||
| <code>LookupAttachment</code> | | <code>LookupAttachment</code> | ||
Line 346: | Line 353: | ||
| <code>SetBodygroup</code> | | <code>SetBodygroup</code> | ||
| <code>void SetBodygroup(int ''groupIndex'', int ''value'')</code> | | <code>void SetBodygroup(int ''groupIndex'', int ''value'')</code> | ||
| 通过索引设置模型的bodygroup的值. | | 通过索引设置模型的bodygroup的值.BodyGroup是写死在qc内部的用来定义模型SubModel的信息。 | ||
|} | |} | ||
=== CBaseFlex === | === CBaseFlex === | ||
Line 365: | Line 371: | ||
| <code>GetSceneByIndex</code> | | <code>GetSceneByIndex</code> | ||
| <code>handle GetSceneByIndex(int ''index'')</code> | | <code>handle GetSceneByIndex(int ''index'')</code> | ||
| | | 返回指定索引的场景实体的实例. | ||
|} | |} | ||
=== CBasePlayer === | === CBasePlayer === | ||
Line 380: | Line 385: | ||
| <code>IsNoclipping</code> | | <code>IsNoclipping</code> | ||
| <code>bool IsNoclipping()</code> | | <code>bool IsNoclipping()</code> | ||
| | | 返回玩家是否处于noclip状态. | ||
|} | |} | ||
Line 392: | Line 397: | ||
Extends [[#CBaseEntity|CBaseEntity]] | Extends [[#CBaseEntity|CBaseEntity]] | ||
{{L|env_entity_maker}}的脚本句柄类. | |||
==== Methods ==== | ==== Methods ==== | ||
Line 416: | Line 421: | ||
| 在一个指定名字的实体的位置上创建一个实体。 | | 在一个指定名字的实体的位置上创建一个实体。 | ||
|} | |} | ||
=== CFuncTrackTrain === | |||
Extends [[#CFuncTrackTrain|CFuncTrackTrain]] | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | |||
! 函数 | |||
! 签名 | |||
! 描述 | |||
|- | |||
| <code>GetFuturePosition</code> | |||
| <code>Vector GetFuturePosition(float, float)</code> | |||
| 获取track在未来X秒的内的位置. | |||
|} | |||
=== CGameCoopMissionManager === | |||
Extends [[#CGameCoopMissionManager|CGameCoopMissionManager]] | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | |||
! 函数 | |||
! 签名 | |||
! 描述 | |||
|- | |||
| <code>GetWaveNumber</code> | |||
| <code>int GetWaveNumber()</code> | |||
| 获取玩家已经完成的合作模式波数. | |||
|} | |||
=== CHostage === | |||
Extends [[#CGameCoopMissionManager|CGameCoopMissionManager]] | |||
==== Methods ==== | |||
{| class="standard-table" style="width: 100%;" | |||
! 函数 | |||
! 签名 | |||
! 描述 | |||
|- | |||
| <code>IsBeingCarried</code> | |||
| <code>bool IsBeingCarried()</code> | |||
| 返回人质当前是否正在被护送. | |||
|} | |||
Line 421: | Line 469: | ||
Extends [[#CBaseEntity|CBaseEntity]] | Extends [[#CBaseEntity|CBaseEntity]] | ||
{{L|point_template}}的脚本句柄类. | |||
==== Hooks ==== | ==== Hooks ==== | ||
Line 478: | Line 526: | ||
| <code>IsPaused</code> | | <code>IsPaused</code> | ||
| <code>bool IsPaused()</code> | | <code>bool IsPaused()</code> | ||
| | | 返回这个场景是否暂停. | ||
|- | |- | ||
| <code>IsPlayingBack</code> | | <code>IsPlayingBack</code> | ||
| <code>bool IsPlayingBack()</code> | | <code>bool IsPlayingBack()</code> | ||
| | | 返回这个场景是否正在播放. | ||
|- | |- | ||
| <code>LoadSceneFromString</code> | | <code>LoadSceneFromString</code> | ||
Line 541: | Line 589: | ||
|} | |} | ||
==== | ==== Members ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 实例 | ||
! | ! 类型 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>chains</code> | | <code>chains</code> | ||
Line 562: | Line 610: | ||
=== CEntities === | === CEntities === | ||
游戏实例: <code>Entities</code> | |||
一个用于查找和遍历所有游戏中的实体的脚本句柄的接口. | |||
要遍历一组实体, 请将<code>null</code>传递给适当方法中的前置参数以开始遍历, 或引用先前找到的实体以继续搜索. | |||
以下两个示例都实现了遍历整个地图上的所有武器 | |||
{| width=100% | |||
|- style="vertical-align:top;" | |||
| | |||
<source lang=cpp> | |||
local ent = null; | |||
while ( ent = Entities.FindByClassname(ent, "weapon_*") ) | |||
{ | |||
// ... | |||
} | |||
</source> | |||
| | |||
<source lang=cpp> | |||
for (local ent; ent = Entities.FindByName(ent, "weapon_*"); ) | |||
{ | |||
// ... | |||
} | |||
</source> | |||
|} | |||
{{Note | | |||
* 变量名 <code>ent</code> 可根据自己情况定义. | |||
* 在循环条件中使用 "{{=}}" 而不是"{{=}}{{=}}"!循环将在 <code>ent</code> 变为 <code>null</code>时停止.在循环体中ent是地图中的武器句柄不会为 <code>null</code>. | |||
* <code>FindBy...</code> 函数的字符串参数支持通配符 <code>*</code>.在上面的示例中 <code>FindByClassname</code> 仅返回类名以 "<code>weapon_</code>" 开头的类或者 <code>null</code>. | |||
}} | |||
==== | ==== 方法 ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 函数 | ||
! | ! 签名 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>CreateByClassname</code> | | <code>CreateByClassname</code> | ||
| <code>handle CreateByClassname(string ''class'')</code> | | <code>handle CreateByClassname(string ''class'')</code> | ||
| | | 通过种类名(class name)创建一个实体. | ||
|- | |- | ||
| <code>FindByClassname</code> | | <code>FindByClassname</code> | ||
| <code>handle FindByClassname(handle ''previous'', string ''class'')</code> | | <code>handle FindByClassname(handle ''previous'', string ''class'')</code> | ||
| | | 通过种类名寻找一个实体. | ||
|- | |- | ||
| <code>FindByClassnameNearest</code> | | <code>FindByClassnameNearest</code> | ||
| <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code> | | <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code> | ||
| | | 查找最接近指定点的指定种类名的实体. | ||
|- | |- | ||
| <code>FindByClassnameWithin</code> | | <code>FindByClassnameWithin</code> | ||
| <code>handle FindByClassnameWithin(handle ''previous'', string ''class'', Vector ''origin'', float ''radius'')</code> | | <code>handle FindByClassnameWithin(handle ''previous'', string ''class'', Vector ''origin'', float ''radius'')</code> | ||
| | | 在一个范围内查找一个指定种类名的实体. | ||
|- | |- | ||
| <code>FindByModel</code> | | <code>FindByModel</code> | ||
| <code>handle FindByModel(handle ''previous'', string ''filename'')</code> | | <code>handle FindByModel(handle ''previous'', string ''filename'')</code> | ||
| | | 通过模型名查找一个实体. | ||
|- | |- | ||
| <code>FindByName</code> | | <code>FindByName</code> | ||
| <code>handle FindByName(handle ''previous'', string ''name'')</code> | | <code>handle FindByName(handle ''previous'', string ''name'')</code> | ||
| | | 通过targetname查找一个实体. | ||
|- | |- | ||
| <code>FindByNameNearest</code> | | <code>FindByNameNearest</code> | ||
| <code>handle FindByNameNearest(string ''name'', Vector ''origin'', float ''radius'')</code> | | <code>handle FindByNameNearest(string ''name'', Vector ''origin'', float ''radius'')</code> | ||
| | | 查找最接近指定点的指定targetname的实体. | ||
|- | |- | ||
| <code>FindByNameWithin</code> | | <code>FindByNameWithin</code> | ||
| <code>handle FindByNameWithin(handle ''previous'', string ''name'', Vector ''origin'', float ''radius'')</code> | | <code>handle FindByNameWithin(handle ''previous'', string ''name'', Vector ''origin'', float ''radius'')</code> | ||
| | | 在一个范围内查找一个指定targetname的实体. | ||
|- | |- | ||
| <code>FindByTarget</code> | | <code>FindByTarget</code> | ||
| <code>handle FindByTarget(handle ''previous'', string ''targetname'')</code> | | <code>handle FindByTarget(handle ''previous'', string ''targetname'')</code> | ||
| | | 通过实体自身的target查找一个实体. | ||
|- | |- | ||
| <code>FindInSphere</code> | | <code>FindInSphere</code> | ||
| <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code> | | <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code> | ||
| | | 在一个范围内查找一个实体. | ||
|- | |- | ||
| <code>First</code> | | <code>First</code> | ||
| <code>handle First()</code> | | <code>handle First()</code> | ||
| | | 开始遍历的实体列表. | ||
|- | |- | ||
| <code>Next</code> | | <code>Next</code> | ||
| <code>handle Next(handle ''previous'')</code> | | <code>handle Next(handle ''previous'')</code> | ||
| | | 继续遍历实体列表, 为先前找到的实体提供参照. | ||
|- | |- | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
| <code>bool IsValid()</code> | | <code>bool IsValid()</code> | ||
| | | 返回句柄是否属一个有效的实体. | ||
|} | |} | ||
=== CPlayerVoiceListener === | === CPlayerVoiceListener === | ||
{{ | {{Warning|此类无效! 此类虽然在 CS:GO 中实现,但所需的 <code>PlayerVoiceListener</code> 实例未实现.}} | ||
==== | ==== 方法 ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 函数 | ||
! | ! 签名 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>GetPlayerSpeechDuration</code> | | <code>GetPlayerSpeechDuration</code> | ||
| <code>float GetPlayerSpeechDuration(int)</code> | | <code>float GetPlayerSpeechDuration(int)</code> | ||
| | | 返回玩家持续说话的秒数. | ||
|- | |- | ||
| <code>IsPlayerSpeaking</code> | | <code>IsPlayerSpeaking</code> | ||
| <code>bool IsPlayerSpeaking(int)</code> | | <code>bool IsPlayerSpeaking(int)</code> | ||
| | | 返回指定玩家是否正在说话. | ||
|- | |- | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
| <code>bool IsValid()</code> | | <code>bool IsValid()</code> | ||
| | | 返回句柄是否属于一个有效的实体. | ||
|} | |} | ||
=== CScriptKeyValues === | === CScriptKeyValues === | ||
代表一个模型的{{L|$keyvalues}}块的脚本句柄. | |||
子键是同一类的实例. | |||
==== Methods ==== | ==== Methods ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 函数 | ||
! | ! 签名 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>constructor</code> | | <code>constructor</code> | ||
Line 665: | Line 736: | ||
| <code>FindKey</code> | | <code>FindKey</code> | ||
| <code>CScriptKeyValues FindKey(string ''keyName'')</code> | | <code>CScriptKeyValues FindKey(string ''keyName'')</code> | ||
| | | 通过键名找到一个子键. | ||
|- | |- | ||
| <code>GetFirstSubKey</code> | | <code>GetFirstSubKey</code> | ||
| <code>CScriptKeyValues GetFirstSubKey()</code> | | <code>CScriptKeyValues GetFirstSubKey()</code> | ||
| | | 返回第一个子键对象. | ||
|- | |- | ||
| <code>GetKeyBool</code> | | <code>GetKeyBool</code> | ||
| <code>bool GetKeyBool(string ''keyName'')</code> | | <code>bool GetKeyBool(string ''keyName'')</code> | ||
| | | 以布尔形式返回一个键值. | ||
|- | |- | ||
| <code>GetKeyFloat</code> | | <code>GetKeyFloat</code> | ||
| <code>float GetKeyFloat(string ''keyName'')</code> | | <code>float GetKeyFloat(string ''keyName'')</code> | ||
| | | 以浮点数返回一个键值. | ||
|- | |- | ||
| <code>GetKeyInt</code> | | <code>GetKeyInt</code> | ||
| <code>int GetKeyInt(string ''keyName'')</code> | | <code>int GetKeyInt(string ''keyName'')</code> | ||
| | | 以整数返回一个键值. | ||
|- | |- | ||
| <code>GetKeyString</code> | | <code>GetKeyString</code> | ||
| <code>string GetKeyString(string ''keyName'')</code> | | <code>string GetKeyString(string ''keyName'')</code> | ||
| | | 以字符串形式返回一个键值. | ||
|- | |- | ||
| <code>GetNextKey</code> | | <code>GetNextKey</code> | ||
| <code>handle GetNextKey()</code> | | <code>handle GetNextKey()</code> | ||
| | | 将下一个相邻的键对象返回到调用该方法的对象. | ||
|- | |- | ||
| <code>IsKeyEmpty</code> | | <code>IsKeyEmpty</code> | ||
| <code>bool IsKeyEmpty(string ''keyName'')</code> | | <code>bool IsKeyEmpty(string ''keyName'')</code> | ||
| | | 如果指定的键是空值返回真. | ||
|- | |- | ||
| <code>IsValid</code> | | <code>IsValid</code> | ||
| <code>bool IsValid()</code> | | <code>bool IsValid()</code> | ||
| | | 返回句柄是否属于一个有效的实体. | ||
|- | |- | ||
| <code>ReleaseKeyValues</code> | | <code>ReleaseKeyValues</code> | ||
| <code>void ReleaseKeyValues()</code> | | <code>void ReleaseKeyValues()</code> | ||
| | | 释放实例的内容. | ||
|} | |} | ||
=== CSimpleCallChainer === | === CSimpleCallChainer === | ||
看上去似乎和 [[#CCallChainer|CCallChainer]] 有相同的Members. | |||
{{todo}} | {{todo}} | ||
== LateBinder === | |||
Late binding: allows a table to refer to parts of itself, it's children, it's owner, and then have the references fixed up after it's fully parsed. | Late binding: allows a table to refer to parts of itself, it's children, it's owner, and then have the references fixed up after it's fully parsed. | ||
<source lang=cpp> | <source lang=cpp> | ||
Line 737: | Line 808: | ||
When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with. | When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with. | ||
==== Methods ==== | ==== Methods ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 函数 | ||
! | ! 签名 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>Begin</code> | | <code>Begin</code> | ||
Line 772: | Line 844: | ||
=== regexp === | === regexp === | ||
正则表达式的内置[http://squirrel-lang.org/doc/sqstdlib3.html#d0e2591 Squirrel 类]. | |||
==== Methods ==== | ==== Methods ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 函数 | ||
! | ! 签名 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>constructor</code> | | <code>constructor</code> | ||
Line 786: | Line 858: | ||
| <code>capture</code> | | <code>capture</code> | ||
| <code> [table] capture(''str'', [''start''])</code> | | <code> [table] capture(''str'', [''start''])</code> | ||
| | | 返回在字符串str中的一个正则表达式的第一个匹配的包含2个索引("begin"和"end")的表的数组.为每个捕获的子表达式创建一个数组条目, 如果不匹配, 则返回null. 搜索从字符串的索引开始处开始, 如果忽略start, 则搜索从字符串的起始处开始. | ||
|- | |- | ||
| <code>match</code> | | <code>match</code> | ||
| <code> bool match(''str'')</code> | | <code> bool match(''str'')</code> | ||
| | | 如果正则表达式匹配字符串str, 则返回true, 否则返回false. | ||
|- | |- | ||
| <code>search</code> | | <code>search</code> | ||
| <code>table search(''str'', [''start''])</code> | | <code>table search(''str'', [''start''])</code> | ||
| | | 返回包含字符串"str"中正则表达式第一个匹配的两个索引("begin"和"end")的表, 如果不匹配, 则返回null. 搜索从字符串的索引开始处开始, 如果忽略start, 则搜索从字符串的起始处开始. | ||
|- | |- | ||
| <code>subexpcount</code> | | <code>subexpcount</code> | ||
Line 803: | Line 875: | ||
=== Vector === | === Vector === | ||
Squirrel的{{L|Vector}}类与C++相当. | |||
三维向量用向量值和标量值重载了算术运算. | |||
{{ | {{Note|声明与操作向量的[http://www.leeland.net/hochsuch.html 例子] }} | ||
==== Methods ==== | ==== Methods ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 函数 | ||
! | ! 签名 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>constructor</code> | | <code>constructor</code> | ||
| <code>Vector(float ''x'', float ''y'', float ''z'')</code> | | <code>Vector(float ''x'', float ''y'', float ''z'')</code> | ||
| | | 用指定的笛卡尔坐标创建一个新的向量. | ||
|- | |- | ||
| <code>Cross</code> | | <code>Cross</code> | ||
| <code>float Cross(Vector ''factor'')</code> | | <code>float Cross(Vector ''factor'')</code> | ||
| | | 两个向量的向量乘积. 返回与输入向量正交的向量. | ||
|- | |- | ||
| <code>Dot</code> | | <code>Dot</code> | ||
| <code>float Dot(Vector ''factor'')</code> | | <code>float Dot(Vector ''factor'')</code> | ||
| | | 两个向量的标量积. | ||
|- | |- | ||
| <code>Length</code> | | <code>Length</code> | ||
| <code>float Length()</code> | | <code>float Length()</code> | ||
| | | 向量的幅度. | ||
|- | |- | ||
| <code>LengthSqr</code> | | <code>LengthSqr</code> | ||
| <code>float LengthSqr()</code> | | <code>float LengthSqr()</code> | ||
| | | 向量的幅度的平方. 比上一个方法更快. | ||
|- | |- | ||
| <code>Length2D</code> | | <code>Length2D</code> | ||
| <code>float Length2D()</code> | | <code>float Length2D()</code> | ||
| | | 返回x-y平面上向量的幅度. | ||
|- | |- | ||
| <code>Length2DSqr</code> | | <code>Length2DSqr</code> | ||
| <code>float Length2DSqr()</code> | | <code>float Length2DSqr()</code> | ||
| | | 返回x-y平面上向量幅度的平方. 比上一个方法更快. | ||
|- | |- | ||
| <code>Norm</code> | | <code>Norm</code> | ||
| <code>float Norm()</code> | | <code>float Norm()</code> | ||
| | | 以浮点数返回向量的长度. 这个函数同时也会将向量'''标准化''', X, Y和Z值将被设置为-1和1之间的数字. 然后你可以将这些值乘以例如3000, 以使用该向量来设置游戏中某物的速度. | ||
|- | |- | ||
| <code>ToKVString</code> | | <code>ToKVString</code> | ||
| <code>string ToKVString()</code> | | <code>string ToKVString()</code> | ||
| | | 返回一个没有分隔符的字符串. | ||
|} | |} | ||
==== Members ==== | ==== Members ==== | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 实例 | ||
! | ! 类型 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>x</code> | | <code>x</code> | ||
| <code>float</code> | | <code>float</code> | ||
| | | 笛卡尔x轴. | ||
|- | |- | ||
| <code>y</code> | | <code>y</code> | ||
| <code>float</code> | | <code>float</code> | ||
| | | 笛卡尔y轴. | ||
|- | |- | ||
| <code>z</code> | | <code>z</code> | ||
| <code>float</code> | | <code>float</code> | ||
| | | 笛卡尔z轴. | ||
|} | |} | ||
== 全局函数 == | |||
== | === 打印与绘制 === | ||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 函数 | ||
! | ! 签名 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>DebugDrawBox</code> | | <code>DebugDrawBox</code> | ||
| <code>void DebugDrawBox(vector ''origin'', vector ''min'', vector ''max'', int ''r'', int ''g'', int ''b'', int ''alpha'', float ''duration'')</code> | | <code>void DebugDrawBox(vector ''origin'', vector ''min'', vector ''max'', int ''r'', int ''g'', int ''b'', int ''alpha'', float ''duration'')</code> | ||
| | | 绘制一个调试覆盖框(debug overlay box). | ||
|- | |- | ||
| <code>DebugDrawLine</code> | | <code>DebugDrawLine</code> | ||
| <code>void DebugDrawLine(Vector ''start'', Vector ''end'', int ''red'', int ''green'', int ''blue', bool ''zTest'', float ''time'')</code> | | <code>void DebugDrawLine(Vector ''start'', Vector ''end'', int ''red'', int ''green'', int ''blue', bool ''zTest'', float ''time'')</code> | ||
| | | 在两点间绘制一根调试线(debug line). | ||
|- | |- | ||
| <code>Msg</code> | | <code>Msg</code> | ||
| <code>void Msg(string ''message'')</code> | | <code>void Msg(string ''message'')</code> | ||
| | | 相当于<code>print</code> | ||
|- | |- | ||
| <code>print</code> | | <code>print</code> | ||
| <code>void print(string ''message'')</code> | | <code>void print(string ''message'')</code> | ||
| | | 将给定的消息打印到开发人员控制台. | ||
|- | |- | ||
| <code>printl</code> | | <code>printl</code> | ||
| <code>void printl(string ''message'')</code> | | <code>void printl(string ''message'')</code> | ||
| | | 功能同上, 但会在最后附加一个换行符. | ||
|- | |||
| <code>ScriptPrintMessageCenterAllWithParams</code> | |||
| <code>void ScriptPrintMessageCenterAllWithParams(string, string, string, string)</code> | |||
| 在屏幕中央向所有玩家打印消息. 需要传递token/消息. 可以传递null给param1, param2, param3如果你只需要3个以内的参数. | |||
|- | |- | ||
| <code>ScriptPrintMessageCenterAll</code> | | <code>ScriptPrintMessageCenterAll</code> | ||
| <code>void ScriptPrintMessageCenterAll(string ''message'')</code> | | <code>void ScriptPrintMessageCenterAll(string ''message'')</code> | ||
| | | 在屏幕中央向所有玩家打印消息. | ||
|- | |- | ||
| <code>ScriptPrintMessageCenterTeam</code> | | <code>ScriptPrintMessageCenterTeam</code> | ||
| <code>void ScriptPrintMessageCenterTeam(int, string)</code> | | <code>void ScriptPrintMessageCenterTeam(int, string)</code> | ||
| | | 在屏幕中央向指定队伍的玩家打印消息. | ||
|- | |- | ||
| <code>ScriptPrintMessageChatAll</code> | | <code>ScriptPrintMessageChatAll</code> | ||
| <code>void ScriptPrintMessageChatAll(string ''message'')</code> | | <code>void ScriptPrintMessageChatAll(string ''message'')</code> | ||
| | | 在聊天框中向所有玩家打印消息. | ||
|- | |- | ||
| <code>ScriptPrintMessageChatTeam</code> | | <code>ScriptPrintMessageChatTeam</code> | ||
| <code>void ScriptPrintMessageChatTeam(int ''teamNumber'', string ''message'')</code> | | <code>void ScriptPrintMessageChatTeam(int ''teamNumber'', string ''message'')</code> | ||
| | | 在聊天框中向指定队伍的玩家打印消息. | ||
|- | |- | ||
| <code>ShowMessage</code> | | <code>ShowMessage</code> | ||
| <code>void ShowMessage(string)</code> | | <code>void ShowMessage(string)</code> | ||
| | | 打印一条HUD消息给所有玩家. {{Bug|不起作用}} | ||
|- | |- | ||
| <code>__DumpScope</code> | | <code>__DumpScope</code> | ||
| <code>void __DumpScope(int ''indentation'', handle ''scope'')</code> | | <code>void __DumpScope(int ''indentation'', handle ''scope'')</code> | ||
| | | 转储域内的所有内容. | ||
|- | |- | ||
|} | |} | ||
=== 训练课程相关 === | |||
=== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 函数 | ||
! | ! 签名 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>ScriptGetBestTrainingCourseTime</code> | | <code>ScriptGetBestTrainingCourseTime</code> | ||
| <code>int ScriptGetBestTrainingCourseTime()</code> | | <code>int ScriptGetBestTrainingCourseTime()</code> | ||
| | | 获取玩家完成计时课程的最佳时间. | ||
|- | |- | ||
| <code>ScriptGetPlayerCompletedTraining</code> | | <code>ScriptGetPlayerCompletedTraining</code> | ||
| <code>bool ScriptGetPlayerCompletedTraining()</code> | | <code>bool ScriptGetPlayerCompletedTraining()</code> | ||
| | | 如果玩家已完成训练地图的初始部分, 则返回true. | ||
|- | |- | ||
| <code>ScriptGetValveTrainingCourseTime</code> | | <code>ScriptGetValveTrainingCourseTime</code> | ||
| <code>int ScriptGetValveTrainingCourseTime()</code> | | <code>int ScriptGetValveTrainingCourseTime()</code> | ||
| | | 获得Valve完成计时课程的最佳时间。 | ||
|- | |- | ||
| <code>ScriptHighlightAmmoCounter</code> | | <code>ScriptHighlightAmmoCounter</code> | ||
| <code>void ScriptHighlightAmmoCounter()</code> | | <code>void ScriptHighlightAmmoCounter()</code> | ||
| | | 发送一个刚被指导系统用于显示一个用于突出弹药计数器的提示的事件. | ||
|- | |- | ||
| <code>ScriptSetBestTrainingCourseTime</code> | | <code>ScriptSetBestTrainingCourseTime</code> | ||
| <code>void ScriptSetBestTrainingCourseTime(int ''bestTime'')</code> | | <code>void ScriptSetBestTrainingCourseTime(int ''bestTime'')</code> | ||
| | | 设置玩家完成计时课程的最佳时间. | ||
|- | |- | ||
| <code>ScriptSetMiniScoreHidden</code> | | <code>ScriptSetMiniScoreHidden</code> | ||
| <code>void ScriptSetMiniScoreHidden(bool ''scoreHidden'')</code> | | <code>void ScriptSetMiniScoreHidden(bool ''scoreHidden'')</code> | ||
| | | 切换迷你记分牌HUD元素的可见性. | ||
|- | |- | ||
| <code>ScriptSetPlayerCompletedTraining</code> | | <code>ScriptSetPlayerCompletedTraining</code> | ||
| <code>void ScriptSetPlayerCompletedTraining(bool ''trainingCompleted'')</code> | | <code>void ScriptSetPlayerCompletedTraining(bool ''trainingCompleted'')</code> | ||
| | | 设置玩家是否完成了训练地图的初始部分. | ||
|- | |- | ||
| <code>ScriptShowExitDoorMsg</code> | | <code>ScriptShowExitDoorMsg</code> | ||
| <code>void ScriptShowExitDoorMsg()</code> | | <code>void ScriptShowExitDoorMsg()</code> | ||
| | | 当玩家通过出口门退出时, 在训练课程中显示一个消息框. | ||
|- | |- | ||
| <code>ScriptShowFinishMsgBox</code> | | <code>ScriptShowFinishMsgBox</code> | ||
| <code>void ScriptShowFinishMsgBox()</code> | | <code>void ScriptShowFinishMsgBox()</code> | ||
| | | 显示一个消息框,让玩家在完成训练课程后知道下一步该怎么做. | ||
|- | |- | ||
| <code>ScriptTrainingGivePlayerAmmo</code> | | <code>ScriptTrainingGivePlayerAmmo</code> | ||
| <code>void ScriptTrainingGivePlayerAmmo()</code> | | <code>void ScriptTrainingGivePlayerAmmo()</code> | ||
| | | 对玩家拥有的所有武器重新装填弹药(只在训练模式中有用). | ||
|- | |- | ||
|} | |} | ||
=== 合作模式相关 === | |||
=== | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! | ! 函数 | ||
! | ! 签名 | ||
! | ! 描述 | ||
|- | |- | ||
| <code>ScriptCoopCollectBonusCoin</code> | | <code>ScriptCoopCollectBonusCoin</code> | ||
| <code>void ScriptCoopCollectBonusCoin()</code> | | <code>void ScriptCoopCollectBonusCoin()</code> | ||
| | | 将其中一个奖励币标记为已收集. | ||
|- | |- | ||
| <code>ScriptCoopGiveC4sToCTs</code> | | <code>ScriptCoopGiveC4sToCTs</code> | ||
| <code>void ScriptCoopGiveC4sToCTs(int)</code> | | <code>void ScriptCoopGiveC4sToCTs(int)</code> | ||
| | | 将指定数量的C4给予所有活着的CT玩家. | ||
|- | |- | ||
| <code>ScriptCoopMissionGetMissionNumber</code> | | <code>ScriptCoopMissionGetMissionNumber</code> | ||
| <code>int ScriptCoopMissionGetMissionNumber()</code> | | <code>int ScriptCoopMissionGetMissionNumber()</code> | ||
| | | 获取当前地图的任务编号(备注:地图可以有多个任务). | ||
|- | |- | ||
| <code>ScriptCoopMissionRespawnDeadPlayers</code> | | <code>ScriptCoopMissionRespawnDeadPlayers</code> | ||
| <code>void ScriptCoopMissionRespawnDeadPlayers()</code> | | <code>void ScriptCoopMissionRespawnDeadPlayers()</code> | ||
| | | 仅用于重生玩家. | ||
|- | |- | ||
| <code>ScriptCoopMissionSetNextRespawnIn</code> | | <code>ScriptCoopMissionSetNextRespawnIn</code> | ||
| <code>void ScriptCoopMissionSetNextRespawnIn(float, bool)</code> | | <code>void ScriptCoopMissionSetNextRespawnIn(float, bool)</code> | ||
| | | 设置下一波重生的发生时间. | ||
|- | |- | ||
| <code>ScriptCoopMissionSpawnFirstEnemies</code> | | <code>ScriptCoopMissionSpawnFirstEnemies</code> | ||
| <code>void ScriptCoopMissionSpawnFirstEnemies(int)</code> | | <code>void ScriptCoopMissionSpawnFirstEnemies(int)</code> | ||
| | | 在合作模式中生成第一波敌人. | ||
|- | |- | ||
| <code>ScriptCoopMissionSpawnNextWave</code> | | <code>ScriptCoopMissionSpawnNextWave</code> | ||
| <code>void ScriptCoopMissionSpawnNextWave(int)</code> | | <code>void ScriptCoopMissionSpawnNextWave(int)</code> | ||
| | | 告知合作模式中下一波将要出生的敌人. 此函数也会复活玩家. | ||
|- | |- | ||
| <code>ScriptCoopResetRoundStartTime</code> | | <code>ScriptCoopResetRoundStartTime</code> | ||
| <code>void ScriptCoopResetRoundStartTime()</code> | | <code>void ScriptCoopResetRoundStartTime()</code> | ||
| | | 重设回合时间并开始任务. | ||
|- | |- | ||
| <code>ScriptCoopSetBotQuotaAndRefreshSpawns</code> | | <code>ScriptCoopSetBotQuotaAndRefreshSpawns</code> | ||
| <code>void ScriptCoopSetBotQuotaAndRefreshSpawns(int)</code> | | <code>void ScriptCoopSetBotQuotaAndRefreshSpawns(int)</code> | ||
| | | 通过考量在线玩家数量来设置机器人数量并刷新复活. | ||
|- | |- | ||
|} | |} | ||
=== 数学 === | |||
The built-in [http://www.squirrel-lang.org/mainsite/doc/sqstdlib2.html#d0e1519 Squirrel math library]. | |||
{| class="standard-table" style="width: 100%;" | {| class="standard-table" style="width: 100%;" | ||
! Function | ! Function | ||
! Signature | ! Signature | ||
! Description | ! Description | ||
|- | |||
| <code>abs</code> | |||
| <code> int abs(float ''x'')</code> | |||
| 返回 <code>x</code> 的绝对值 | |||
|- | |||
| <code>acos</code> | |||
| <code> float acos(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行acos运算后的值 | |||
|- | |||
| <code>asin</code> | |||
| <code> float asin(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行asin运算后的值 | |||
|- | |||
| <code>atan</code> | |||
| <code> float atan(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行atan运算后的值 | |||
|- | |||
| <code>atan2</code> | |||
| <code> float atan2(float ''x'', float ''y'')</code> | |||
| 返回对 <code>x</code> 进行atan2运算后的值 | |||
|- | |||
| <code>ceil</code> | |||
| <code> float ceil(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行向上取整的值,返回值是一个float型整数 | |||
|- | |||
| <code>cos</code> | |||
| <code> float cos(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行cos运算后的值 | |||
|- | |||
| <code>exp</code> | |||
| <code> float exp(float ''x'')</code> | |||
| 返回 <code>x</code> 的指数运算后的值 | |||
|- | |||
| <code>fabs</code> | |||
| <code> float fabs(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行float转型后的值 | |||
|- | |||
| <code>floor</code> | |||
| <code> float floor(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行向下取整的值,返回值是一个float型整数 | |||
|- | |||
| <code>log</code> | |||
| <code> float log(float ''x'')</code> | |||
| 返回 <code>x</code> 的log e对数 | |||
|- | |||
| <code>log10</code> | |||
| <code> float log10(float ''x'')</code> | |||
| 返回 <code>x</code> 的log 10对数 | |||
|- | |||
| <code>pow</code> | |||
| <code> float pow(float ''x'', float ''y'')</code> | |||
| 返回<code>x</code> 的 <code>y</code> 次方 | |||
|- | |||
| <code>rand</code> | |||
| <code> int rand()</code> | |||
| 返回一个从 0 到 <code>RAND_MAX</code> 的随机int整数 | |||
|- | |||
| <code>sin</code> | |||
| <code> float sin(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行sin运算后的值 | |||
|- | |||
| <code>sqrt</code> | |||
| <code> float sqrt(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行开平方后的值 | |||
|- | |||
| <code>srand</code> | |||
| <code> void srand(float ''seed'')</code> | |||
| 给上面那个随机数定义一个随机seed | |||
|- | |||
| <code>tan</code> | |||
| <code> float tan(float ''x'')</code> | |||
| 返回对 <code>x</code> 进行tan运算后的值 | |||
|} | |||
=== 其他 === | |||
{| class="standard-table" style="width: 100%;" | |||
! 函数 | |||
! 签名 | |||
! 描述 | |||
|- | |- | ||
| <code>Assert</code> | | <code>Assert</code> | ||
| <code>void Assert(bool ''value'', string ''optional message'')</code> | | <code>void Assert(bool ''value'', string ''optional message'')</code> | ||
| | | 检测布尔值, 如果不是true, 则显示异常, 可附带消息. | ||
|- | |- | ||
| <code>CreateProp</code> | | <code>CreateProp</code> | ||
| <code>handle CreateProp(string ''class'', Vector ''origin'', string ''model'', int ''animation'')</code> | | <code>handle CreateProp(string ''class'', Vector ''origin'', string ''model'', int ''animation'')</code> | ||
| | | 通过指定的类型和模型创建一个prop. 对于prop_physics, prop_dynamic 和其他一些带模型的实体都有效. 这个函数不会预缓存模型. {{bug|hidetested=1|不会初始化prop的物理属性.}} | ||
|- | |- | ||
| <code>CreateSceneEntity</code> | | <code>CreateSceneEntity</code> | ||
| <code>CSceneEntity CreateSceneEntity(string ''scene'')</code> | | <code>CSceneEntity CreateSceneEntity(string ''scene'')</code> | ||
| | | 创建一个场景实体来播放指定的场景.vcd文件. | ||
|- | |- | ||
| <code>DispatchParticleEffect</code> | | <code>DispatchParticleEffect</code> | ||
| <code>void DispatchParticleEffect(string particleName, Vector, Vector)</code> | | <code>void DispatchParticleEffect(string particleName, Vector, Vector)</code> | ||
| | | 调用一个一次性粒子系统. | ||
|- | |- | ||
| <code>DoIncludeScript</code> | | <code>DoIncludeScript</code> | ||
| <code>bool DoIncludeScript(string ''filename'', table ''scope'')</code> | | <code>bool DoIncludeScript(string ''filename'', table ''scope'')</code> | ||
| | | 执行脚本域设定为指定的表的脚本. | ||
|- | |- | ||
| <code>DoEntFire</code> | | <code>DoEntFire</code> | ||
| <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code> | | <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code> | ||
| | | 生成一个实体I/O事件. ''caller''参数为句柄, 所以 ''target'' 可以设置成''!self'' 来触发没有targetname的实体的输出. | ||
|- | |- | ||
| <code>EntFire</code> | | <code>EntFire</code> | ||
| <code>function EntFire(string ''target'', string ''action'', string ''value'', float ''delay'' = 0.0, handle ''activator'' = null)</code> | | <code>function EntFire(string ''target'', string ''action'', string ''value'', float ''delay'' = 0.0, handle ''activator'' = null)</code> | ||
| | | 生成一个实体I/O事件. | ||
|- | |- | ||
| <code>EntFireByHandle</code> | | <code>EntFireByHandle</code> | ||
| <code>void EntFireByHandle(handle ''target'', string ''action'', string 'value'', float ''delay'', handle ''activator'', handle ''caller'')</code> | | <code>void EntFireByHandle(handle ''target'', string ''action'', string 'value'', float ''delay'', handle ''activator'', handle ''caller'')</code> | ||
| | | 生成一个实体I/O事件. 第一个参数是一个实体实例, 所以无名的或者由脚本创建的实体的句柄可以被轻松地传递. | ||
|- | |- | ||
| <code>FrameTime</code> | | <code>FrameTime</code> | ||
| <code>float FrameTime()</code> | | <code>float FrameTime()</code> | ||
| | | 获取上一帧在服务器上花费的时间. | ||
|- | |- | ||
| <code>GetDeveloperLevel</code> | | <code>GetDeveloperLevel</code> | ||
| <code>int GetDeveloperLevel()</code> | | <code>int GetDeveloperLevel()</code> | ||
| | | 获取''developer''模式的级别. | ||
|- | |- | ||
| <code>GetMapName</code> | | <code>GetMapName</code> | ||
| <code>string GetMapName()</code> | | <code>string GetMapName()</code> | ||
| | | 获取地图名. | ||
|- | |- | ||
| <code>LoopSinglePlayerMaps</code> | | <code>LoopSinglePlayerMaps</code> | ||
| <code>bool LoopSinglePlayerMaps()</code> | | <code>bool LoopSinglePlayerMaps()</code> | ||
| | | 连续循环运行单人游戏地图. | ||
|- | |- | ||
| <code>PrintHelp</code> | | <code>PrintHelp</code> | ||
Line 1,084: | Line 1,236: | ||
| <code>RandomFloat</code> | | <code>RandomFloat</code> | ||
| <code>float RandomFloat()</code> | | <code>float RandomFloat()</code> | ||
| | | 生成一个随机浮点数 | ||
|- | |- | ||
| <code>RandomFloat</code> | | <code>RandomFloat</code> | ||
| <code>float RandomFloat(float ''min'', float ''max'')</code> | | <code>float RandomFloat(float ''min'', float ''max'')</code> | ||
| | | 在一个给定范围内生成随机浮点数, 范围边界包括在内. | ||
|- | |- | ||
| <code>RandomInt</code> | | <code>RandomInt</code> | ||
| <code>int RandomInt()</code> | | <code>int RandomInt()</code> | ||
| | | 生成一个随机整数. | ||
|- | |- | ||
| <code>RandomInt</code> | | <code>RandomInt</code> | ||
| <code>int RandomInt(int ''min'', int ''max'')</code> | | <code>int RandomInt(int ''min'', int ''max'')</code> | ||
| | | 在一个给定范围内生成随机整数, 范围边界包括在内. | ||
|- | |- | ||
| <code>RecordAchievementEvent</code> | | <code>RecordAchievementEvent</code> | ||
| <code>void RecordAchievementEvent(string, int)</code> | | <code>void RecordAchievementEvent(string, int)</code> | ||
| | | 录制成就事件或者进程. | ||
|- | |- | ||
| <code>RetrieveNativeSignature</code> | | <code>RetrieveNativeSignature</code> | ||
| <code>void RetrieveNativeSignature(string ''or'' func)</code> | | <code>void RetrieveNativeSignature(string ''or'' func)</code> | ||
| | | 理论上这是用来打印本地函数的调用格式的函数, 但它实际上似乎只能输出 <code><unnamed></code> | ||
|- | |- | ||
| <code>ScriptGetGameMode</code> | | <code>ScriptGetGameMode</code> | ||
| <code>int ScriptGetGameMode()</code> | | <code>int ScriptGetGameMode()</code> | ||
| | | 返回game_mode的设置. 请查阅 [[Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server|CSGODS # 专用服务器]] 了解更多信息. | ||
|- | |- | ||
| <code>ScriptGetGameType</code> | | <code>ScriptGetGameType</code> | ||
| <code>int ScriptGetGameType()</code> | | <code>int ScriptGetGameType()</code> | ||
| | | 返回game_type的设置. 请查阅 [[Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server|CSGODS # 专用服务器]] 了解更多信息. | ||
|- | |- | ||
| <code>ScriptGetRoundsPlayed</code> | | <code>ScriptGetRoundsPlayed</code> | ||
| <code>int ScriptGetRoundsPlayed()</code> | | <code>int ScriptGetRoundsPlayed()</code> | ||
| | | 获取从游戏开始迄今所经历的回合数. | ||
|- | |- | ||
| <code>ScriptIsLocalPlayerUsingController</code> | | <code>ScriptIsLocalPlayerUsingController</code> | ||
| <code>bool ScriptIsLocalPlayerUsingController()</code> | | <code>bool ScriptIsLocalPlayerUsingController()</code> | ||
| | | 返回玩家是否在使用控制器玩游戏. | ||
|- | |- | ||
| <code>ScriptIsWarmupPeriod</code> | | <code>ScriptIsWarmupPeriod</code> | ||
| <code>bool ScriptIsWarmupPeriod()</code> | | <code>bool ScriptIsWarmupPeriod()</code> | ||
| | | 返回是否是热身时间. | ||
|- | |- | ||
| <code>ScriptSetRadarHidden</code> | | <code>ScriptSetRadarHidden</code> | ||
| <code>void ScriptSetRadarHidden(bool ''hideRadar'')</code> | | <code>void ScriptSetRadarHidden(bool ''hideRadar'')</code> | ||
| | | 切换雷达HUD元素的可见性. 仅适用于训练模式(game_type 2且game_mode 0)并且仅适用于连接的第一个人. | ||
|- | |- | ||
| <code>SendToConsole</code> | | <code>SendToConsole</code> | ||
| <code>void SendToConsole(string ''command'')</code> | | <code>void SendToConsole(string ''command'')</code> | ||
| | | 将一串命令以字符串形式发送到控制台. | ||
|- | |- | ||
| <code>SendToConsoleServer</code> | | <code>SendToConsoleServer</code> | ||
| <code>void SendToConsoleServer(string)</code> | | <code>void SendToConsoleServer(string)</code> | ||
| | | 发送一个字符串, 作为服务器命令在服务器上执行. | ||
|- | |- | ||
| <code>Time</code> | | <code>Time</code> | ||
| <code>float Time()</code> | | <code>float Time()</code> | ||
| | | 获取当前的服务器时间. | ||
|- | |- | ||
| <code>TraceLine</code> | | <code>TraceLine</code> | ||
| <code>float TraceLine(Vector, Vector, handle)</code> | | <code>float TraceLine(Vector, Vector, handle)</code> | ||
| given 2 points & ent to ignore, return fraction along line that hits world or models | | given 2 points & ent to ignore, return fraction along line that hits world or models. | ||
|- | |- | ||
| <code>UniqueString</code> | | <code>UniqueString</code> | ||
| <code>function UniqueString(string)</code> | | <code>function UniqueString(string)</code> | ||
| | | 使用可选的根字符串生成一个字符串, 该字符串在脚本VM的整个生命周期中保证是唯一的. 当不知道该表中已经使用了哪些密钥时,对于向表中添加数据来说作用很大. | ||
|- | |- | ||
| <code>__ReplaceClosures</code> | | <code>__ReplaceClosures</code> | ||
|} | |} | ||
== | == 推荐阅读 == | ||
* [http://pastebin.com/7LRsSjEZ Pastebin with script that suggests it is run when Squirrel VM starts] | * [http://pastebin.com/7LRsSjEZ Pastebin with script that suggests it is run when Squirrel VM starts] | ||
* {{L|Left 4 Dead 2/Script Functions}} | |||
* | * {{portal2}} {{L|List of Portal 2 Script Functions}} | ||
* {{portal2}} | {{ACategory|Counter-Strike: Global Offensive}} | ||
{{ACategory|VScript}} | |||
{{ACategory|Scripting}} | |||
Latest revision as of 07:17, 20 May 2025


在此介绍,供历史和技术参考
这份清单包含了
反恐精英:全球攻势中的与引擎相关的可用于VScript 的Squirrel 类、函数以及可用的变量. 加载一个地图然后执行
script_help
, 并且将developer
的级别设置为至少1, 可以把这份清单中的部分内容显示于控制台中. 值得一提的是, developer
的级别只要不为0, 且加载了任意的地图, 就可以把script_help
指令所显示的内容转存到文件中. 步骤如下(请一步一步地在控制台中键入每一行指令):
developer 3
map de_nuke
developer 0
con_logfile dump.log
script_help
con_logfile ""
这条内容由Dazai Nerau译自英文版页面. 欢迎任何人补充新内容或者修改其中的错误.
变量
实例 | 类型 | 描述 |
---|---|---|
Entities
|
CEntities
|
提供一个对当前已生成的实体的访问方式. |
常量
实例 | 类型 | 描述 |
---|---|---|
_charsize_
|
integer | |
_floatsize_
|
integer | |
_intsize_
|
integer | |
_version_
|
string | Squirrel的版本号. |
_versionnumber_
|
integer | Squirrel的版本号的整数形式. |
RAND_MAX
|
integer | |
PI
|
float | 3.14159 |
类
CBaseEntity
CBaseEntity是实体的脚本句柄类. 所有已生成的实体都有一个使用CBaseEntity或者其子类的的脚本句柄.
所有游戏中的脚本句柄都可以从Entities中访问. 实体脚本可以通过 self
来访问它们自身的脚本句柄.
方法
函数 | 签名 | 描述 |
---|---|---|
__KeyValueFromInt
|
void __KeyValueFromInt(string key, int value)
|
以整数设置实体的键值(KeyValue) . 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用. |
__KeyValueFromFloat
|
void __KeyValueFromFloat(string key, float value)
|
以浮点数设置实体的KeyValue. 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用. |
__KeyValueFromString
|
void __KeyValueFromString(string key, string value)
|
以字符串设置实体的KeyValue. 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用. |
__KeyValueFromVector
|
void __KeyValueFromVector(string key, Vector value)
|
以向量(Vector)设置实体的KeyValue. 这个函数只修改数值而不执行实体处理KeyValue所需要的任何代码, 所以可能会有令人意想不到的副作用. |
ConnectOutput
|
void ConnectOutput(string output, string function)
|
添加一个I/O关联, 当指定的输出触发时将调用指定的函数. |
DisconnectOutput
|
void DisconnectOutput(string output, string function)
|
从I/O事件中删除一个已关联的脚本函数. |
Destroy
|
void Destroy()
|
删除实体. |
EmitSound
|
void EmitSound(string soundScript)
|
在这个实体上播放声音. |
entindex
|
int entindex()
|
返回实体的索引. |
EyePosition
|
Vector EyePosition()
|
获取眼睛位置的向量(备注:绝对坐标). |
FirstMoveChild
|
handle FirstMoveChild()
|
如果在层级中则获取第一个移动的子对象. |
GetAngles
|
Vector GetAngles()
|
以向量形式获取实体的欧拉角(pitch, yaw, roll). |
GetAngularVelocity
|
Vector GetAngularVelocity()
|
获取实体的角速度(备注:返回pitch、yaw、roll的向量). |
GetBoundingMaxs
|
Vector GetBoundingMaxs()
|
将实体边界框的最大范围以向量返回. |
GetBoundingMaxsOriented
|
Vector GetBoundingMaxsOriented()
|
将以对象为中心并考虑对象方向的实体边界框的最大范围以向量返回. |
GetBoundingMins
|
Vector GetBoundingMins()
|
将实体边界框的最小范围以向量返回. |
GetBoundingMinsOriented
|
Vector GetBoundingMinsOriented()
|
将以对象为中心并考虑对象方向的实体边界框的最小范围以向量返回. |
GetCenter
|
Vector GetCenter()
|
返回边界框中心位置的向量. |
GetClassname
|
string GetClassname()
|
返回实体的种类名. (备注:包含player ).
|
GetForwardVector
|
Vector GetForwardVector()
|
返回实体的前向量. |
GetHealth
|
int GetHealth()
|
返回实体当前的生命值. |
GetLeftVector
|
Vector GetLeftVector()
|
返回实体的左向量. |
GetMaxHealth
|
int GetMaxHealth()
|
返回实体的最大生命值. |
GetModelKeyValues
|
Keyvalues GetModelKeyValues()
|
返回实体模型的[$keyvalues]块作为一个#Keyvalues对象. 请注意, 这并非实体自身的keyvalues. |
GetModelName
|
string GetModelName()
|
返回实体模型的文件名. |
GetMoveParent
|
CBaseEntity GetMoveParent()
|
如果实体位于层次结构(hierarchy)中, 检索实体的父级(parent). |
GetName
|
string GetName()
|
返回实体的targetname. |
GetOrigin
|
Vector GetOrigin()
|
返回实体的位置. |
GetOwner
|
handle GetOwner()
|
获取实体的所有者(owner). (备注:似乎只有当需要在这个实体上使用SetOwner()时这个函数才有用, 可能也不尽然) |
GetPreTemplateName
|
string GetPreTemplateName()
|
Get the entity name stripped of template unique decoration. |
GetRootMoveParent
|
handle GetRootMoveParent()
|
如果实体位于层次结构中,顺着层次结构检索实体的根父级. |
GetScriptId
|
string GetScriptId()
|
检索用于引用脚本系统中的实体的唯一标识符. |
GetScriptScope
|
handle GetScriptScope()
|
检索存储与此实体关联的实体脚本数据的表. |
GetSoundDuration
|
float GetSoundDuration(string soundName, string actorModelName = "")
|
以浮点数返回声音的持续时间. (备注:采用"soundName"和可选的"actorModelName"作为搜索参数) |
GetTeam
|
int GetTeam()
|
返回玩家的队伍. (备注:观察者 = 1, 恐怖分子 = 2, 反恐精英 = 3). |
GetUpVector
|
Vector GetUpVector()
|
获取实体的顶向量. |
GetVelocity
|
Vector GetVelocity()
|
返回实体的速度向量. |
IsValid
|
bool IsValid()
|
返回句柄是否属于有效的实体. |
NextMovePeer
|
handle NextMovePeer()
|
返回统一移动层级的下一个实体. |
PrecacheModel
|
void PrecacheModel(string modelPath)
|
在地图加载完成后预缓存一个模型,资源占用大. |
PrecacheScriptSound
|
void PrecacheScriptSound(string soundName)
|
在地图加载完成后预缓存一个声音,资源占用大. |
PrecacheSoundScript
|
void PrecacheSoundScript(string soundScript)
|
预缓存一个将会被播放的声音,资源占用大. |
SetAbsOrigin
|
void SetAbsOrigin(Vector position)
|
与SetOrigin()功能相同,设置实体的绝对位置. |
SetAngles
|
void SetAngles(float pitch, float yaw, float roll)
|
设置实体的pitch, yaw, roll. 请注意, 这里并不使用向量. |
SetAngularVelocity
|
void SetAngularVelocity(float pitch, float yaw, float roll)
|
设置实体的角速度.(备注:采用pitch, yaw和roll的浮点数形式的角速度). |
SetForwardVector
|
void SetForwardVector(Vector forwardVector)
|
设置实体的前向量. |
SetHealth
|
void SetHealth(int newHealth)
|
设置实体的生命值. |
SetMaxHealth
|
void SetMaxHealth(int maxHealth)
|
设置实体的最大生命值. |
SetModel
|
void SetModel(string modelName)
|
改变实体的模型, 这个函数并不预缓存模型! 待完善: 检查副作用
|
SetOrigin
|
void SetOrigin(Vector position)
|
将实体移动到指定位置. |
SetOwner
|
void SetOwner(handle owner)
|
设置实体的所有者. |
SetSize
|
void SetSize(Vector, Vector)
|
设置碰撞体积大小. |
SetTeam
|
void SetTeam(int teamNumber)
|
立即转换玩家的团队. (备注:观察者 = 1, 恐怖分子 = 2, 反恐精英 = 3) |
SetVelocity
|
void SetVelocity(Vector velocity)
|
设置实体的速度向量. |
StopSound
|
void StopSound(String soundname)
|
停止一个在实体上播放的声音. |
ValidateScriptScope
|
bool ValidateScriptScope()
|
返回实体的脚本域是否已被创建. |
Hooks
如果其中一个函数在实体脚本中被声明, 实体将在适当的情况下自动运行此函数.
函数 | 签名 | 描述 |
---|---|---|
InputInputName
|
bool InputInputName()
|
当实体从I/O系统中接收到输入时调用. 此函数的名称必须是实体input列表中的Input , 例如表示FireUser1的InputFireUser1 . 当这个函数被调用时, 激活和调用的实体的脚本句柄会被写入接收输入的实体的脚本数据的activator 和caller 变量中. 这个函数必须返回一个布尔值. 将布尔值设定为true 允许实体来处理输入, 否则用false 阻止之.
|
OnPostSpawn
|
void OnPostSpawn()
|
在实体生成时立即被调用. 这个函数可以用于让实体向主脚本注册自身,或以编程方式调整实体参数. |
Precache
|
void Precache()
|
在脚本执行后调用. 可用于在地图加载时调用模型和声音的预缓存函数. |
CBaseAnimating
Extends CBaseEntity
动画实体(如props)的脚本句柄类.
Methods
函数 | 签名 | 描述 |
---|---|---|
GetAttachmentAngles
|
Vector GetAttachmentAngles(int id)
|
以pitch, yaw, roll向量的形式获取附件ID的角度. |
GetAttachmentOrigin
|
Vector GetAttachmentOrigin(int 'id')
|
获取附件ID的位置向量. |
IsSequenceFinished
|
bool IsSequenceFinished()
|
返回主序列是否已经播放完成. |
LookupAttachment
|
int LookupAttachment(string attachmentName)
|
获取指定名字的附件ID. |
SetBodygroup
|
void SetBodygroup(int groupIndex, int value)
|
通过索引设置模型的bodygroup的值.BodyGroup是写死在qc内部的用来定义模型SubModel的信息。 |
CBaseFlex
Extends CBaseAnimating
Methods
函数 | 签名 | 描述 |
---|---|---|
GetCurrentScene
|
handle GetCurrentScene()
|
返回最早的活动场景实体的实例 (备注:如果有的话). |
GetSceneByIndex
|
handle GetSceneByIndex(int index)
|
返回指定索引的场景实体的实例. |
CBasePlayer
Extends CBaseAnimating
Methods
函数 | 签名 | 描述 |
---|---|---|
IsNoclipping
|
bool IsNoclipping()
|
返回玩家是否处于noclip状态. |
CBaseMultiplayerPlayer
Extends CBasePlayer
CSGO玩家的脚本句柄类,无附带方法。
CEnvEntityMaker
Extends CBaseEntity
env_entity_maker 的脚本句柄类.
Methods
函数 | 签名 | 描述 |
---|---|---|
SpawnEntity
|
void SpawnEntity()
|
在制造器的位置上创建一个实体 |
SpawnEntityAtEntityOrigin
|
void SpawnEntityAtEntityOrigin(CBaseEntity entity)
|
在指定实体实例的位置上创建一个实体. |
SpawnEntityAtLocation
|
void SpawnEntityAtLocation(Vector origin, Vector orientation)
|
在指定的位置和方向上创建一个实体,方向为以度为单位的欧拉角(pitch, yaw, roll). |
SpawnEntityAtNamedEntityOrigin
|
void SpawnEntityAtNamedEntityOrigin(string targetName)
|
在一个指定名字的实体的位置上创建一个实体。 |
CFuncTrackTrain
Extends CFuncTrackTrain
Methods
函数 | 签名 | 描述 |
---|---|---|
GetFuturePosition
|
Vector GetFuturePosition(float, float)
|
获取track在未来X秒的内的位置. |
CGameCoopMissionManager
Extends CGameCoopMissionManager
Methods
函数 | 签名 | 描述 |
---|---|---|
GetWaveNumber
|
int GetWaveNumber()
|
获取玩家已经完成的合作模式波数. |
CHostage
Extends CGameCoopMissionManager
Methods
函数 | 签名 | 描述 |
---|---|---|
IsBeingCarried
|
bool IsBeingCarried()
|
返回人质当前是否正在被护送. |
CPointTemplate
Extends CBaseEntity
point_template 的脚本句柄类.
Hooks
table PreSpawnInstance(string entityClass, string entityName)
- 如果定义了此Hook,它将在实体创建之前被调用,并且返回的任何KeyValues都将被分配给该实体。
function PreSpawnInstance( entityClass, entityName )
{
local keyvalues =
{
rendercolor = "0 255 0"
targetname = "mySpawnedEntity"
}
return keyvalues
}
void PostSpawn(table entities)
- 在实体生成后调用. 具有按名称索引的已生成的实体句柄的表被传递给该函数. 可以使用它来关联输出或在创建实体后做任何你想做的事情.
function PostSpawn( entities )
{
foreach( name, handle in entities )
{
printl( name + ": " + handle )
}
}
CSceneEntity
Extends CBaseEntity
Methods
函数 | 签名 | 描述 |
---|---|---|
AddBroadcastTeamTarget
|
void AddBroadcastTeamTarget(int index)
|
添加一个队伍(通过索引)到广播列表中. |
EstimateLength
|
float EstimateLength()
|
以秒为单位返回此场景的长度. |
FindNamedEntity
|
handle FindNamedEntity(string reference)
|
给定一个实体参照, 比如 !target, 以从场景对象中获取真正的实体. |
IsPaused
|
bool IsPaused()
|
返回这个场景是否暂停. |
IsPlayingBack
|
bool IsPlayingBack()
|
返回这个场景是否正在播放. |
LoadSceneFromString
|
bool LoadSceneFromString(string sceneName, string scene)
|
给定一个虚拟的场景名和vcd的字符串, 以加载场景. |
RemoveBroadcastTeamTarget
|
void RemoveBroadcastTeamTarget(int index)
|
从广播列表中删除一个队伍(通过索引). |
CTriggerCamera
Extends CBaseEntity
Methods
函数 | 签名 | 描述 |
---|---|---|
GetFov
|
int GetFov()
|
以整数获取当前相机的FOV设置. |
SetFov
|
void SetFov(int fov, float rate)
|
用整数的度数设置相机的FOV, 用浮点数设置FOV的变化率. |
Hooks
void ScriptStartCameraShot(string shotType, handle sceneEntity, handle actor1, handle actor2, float duration)
- 由SceneEntity调用以响应由一个VCD发送来的CChoreoEvent::CAMERA. [待完善]
CCallChainer
[待完善]
Methods
函数 | 签名 | 描述 |
---|---|---|
constructor
|
[待完善] constructor()
|
|
PostScriptExecute
|
[待完善] PostScriptExecute()
|
|
Call
|
[待完善] Call()
|
Members
实例 | 类型 | 描述 |
---|---|---|
chains
|
null
|
|
prefix
|
null
|
|
scope
|
null
|
CEntities
游戏实例: Entities
一个用于查找和遍历所有游戏中的实体的脚本句柄的接口.
要遍历一组实体, 请将null
传递给适当方法中的前置参数以开始遍历, 或引用先前找到的实体以继续搜索.
以下两个示例都实现了遍历整个地图上的所有武器
local ent = null;
while ( ent = Entities.FindByClassname(ent, "weapon_*") )
{
// ...
}
|
for (local ent; ent = Entities.FindByName(ent, "weapon_*"); )
{
// ...
}
|

- 变量名
ent
可根据自己情况定义. - 在循环条件中使用 "=" 而不是"=="!循环将在
ent
变为null
时停止.在循环体中ent是地图中的武器句柄不会为null
. FindBy...
函数的字符串参数支持通配符*
.在上面的示例中FindByClassname
仅返回类名以 "weapon_
" 开头的类或者null
.
方法
函数 | 签名 | 描述 |
---|---|---|
CreateByClassname
|
handle CreateByClassname(string class)
|
通过种类名(class name)创建一个实体. |
FindByClassname
|
handle FindByClassname(handle previous, string class)
|
通过种类名寻找一个实体. |
FindByClassnameNearest
|
handle FindByClassnameNearest(string class, Vector origin, float radius)
|
查找最接近指定点的指定种类名的实体. |
FindByClassnameWithin
|
handle FindByClassnameWithin(handle previous, string class, Vector origin, float radius)
|
在一个范围内查找一个指定种类名的实体. |
FindByModel
|
handle FindByModel(handle previous, string filename)
|
通过模型名查找一个实体. |
FindByName
|
handle FindByName(handle previous, string name)
|
通过targetname查找一个实体. |
FindByNameNearest
|
handle FindByNameNearest(string name, Vector origin, float radius)
|
查找最接近指定点的指定targetname的实体. |
FindByNameWithin
|
handle FindByNameWithin(handle previous, string name, Vector origin, float radius)
|
在一个范围内查找一个指定targetname的实体. |
FindByTarget
|
handle FindByTarget(handle previous, string targetname)
|
通过实体自身的target查找一个实体. |
FindInSphere
|
handle FindInSphere(handle previous, Vector origin, float radius)
|
在一个范围内查找一个实体. |
First
|
handle First()
|
开始遍历的实体列表. |
Next
|
handle Next(handle previous)
|
继续遍历实体列表, 为先前找到的实体提供参照. |
IsValid
|
bool IsValid()
|
返回句柄是否属一个有效的实体. |
CPlayerVoiceListener

PlayerVoiceListener
实例未实现.方法
函数 | 签名 | 描述 |
---|---|---|
GetPlayerSpeechDuration
|
float GetPlayerSpeechDuration(int)
|
返回玩家持续说话的秒数. |
IsPlayerSpeaking
|
bool IsPlayerSpeaking(int)
|
返回指定玩家是否正在说话. |
IsValid
|
bool IsValid()
|
返回句柄是否属于一个有效的实体. |
CScriptKeyValues
代表一个模型的$keyvalues 块的脚本句柄. 子键是同一类的实例.
Methods
函数 | 签名 | 描述 |
---|---|---|
constructor
| ||
FindKey
|
CScriptKeyValues FindKey(string keyName)
|
通过键名找到一个子键. |
GetFirstSubKey
|
CScriptKeyValues GetFirstSubKey()
|
返回第一个子键对象. |
GetKeyBool
|
bool GetKeyBool(string keyName)
|
以布尔形式返回一个键值. |
GetKeyFloat
|
float GetKeyFloat(string keyName)
|
以浮点数返回一个键值. |
GetKeyInt
|
int GetKeyInt(string keyName)
|
以整数返回一个键值. |
GetKeyString
|
string GetKeyString(string keyName)
|
以字符串形式返回一个键值. |
GetNextKey
|
handle GetNextKey()
|
将下一个相邻的键对象返回到调用该方法的对象. |
IsKeyEmpty
|
bool IsKeyEmpty(string keyName)
|
如果指定的键是空值返回真. |
IsValid
|
bool IsValid()
|
返回句柄是否属于一个有效的实体. |
ReleaseKeyValues
|
void ReleaseKeyValues()
|
释放实例的内容. |
CSimpleCallChainer
看上去似乎和 CCallChainer 有相同的Members. [待完善]
LateBinder =
Late binding: allows a table to refer to parts of itself, it's children, it's owner, and then have the references fixed up after it's fully parsed.
// Usage:
lateBinder <- LateBinder();
lateBinder.Begin( this );
Test1 <-
{
Foo=1
}
Test2 <-
{
FooFoo = "I'm foo foo"
BarBar="@Test1.Foo"
SubTable = { boo=[bah, "@Test2.FooFoo", "@Test1.Foo"], booboo2={one=bah, two="@Test2.FooFoo", three="@Test1.Foo"} }
booboo=[bah, "@Test2.FooFoo", "@Test1.Foo"]
booboo2={one=bah, two="@Test2.FooFoo", three="@Test1.Foo"}
bah=wha
}
lateBinder.End();
delete lateBinder;
When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with.
Methods
函数 | 签名 | 描述 |
---|---|---|
Begin
| ||
End
| ||
EstablishDelegation
| ||
HookRootMetamethod
| ||
Log
| ||
m_bindNamesStack
| ||
m_fixupSet
| ||
m_log
| ||
m_logIndent
| ||
m_targetTable
| ||
RemoveDelegation
| ||
Resolve
| ||
UnhookRootMetamethod
|
regexp
正则表达式的内置Squirrel 类.
Methods
函数 | 签名 | 描述 |
---|---|---|
constructor
|
regexp()
|
|
capture
|
[table] capture(str, [start])
|
返回在字符串str中的一个正则表达式的第一个匹配的包含2个索引("begin"和"end")的表的数组.为每个捕获的子表达式创建一个数组条目, 如果不匹配, 则返回null. 搜索从字符串的索引开始处开始, 如果忽略start, 则搜索从字符串的起始处开始. |
match
|
bool match(str)
|
如果正则表达式匹配字符串str, 则返回true, 否则返回false. |
search
|
table search(str, [start])
|
返回包含字符串"str"中正则表达式第一个匹配的两个索引("begin"和"end")的表, 如果不匹配, 则返回null. 搜索从字符串的索引开始处开始, 如果忽略start, 则搜索从字符串的起始处开始. |
subexpcount
|
Vector
Squirrel的Vector 类与C++相当.
三维向量用向量值和标量值重载了算术运算.

Methods
函数 | 签名 | 描述 |
---|---|---|
constructor
|
Vector(float x, float y, float z)
|
用指定的笛卡尔坐标创建一个新的向量. |
Cross
|
float Cross(Vector factor)
|
两个向量的向量乘积. 返回与输入向量正交的向量. |
Dot
|
float Dot(Vector factor)
|
两个向量的标量积. |
Length
|
float Length()
|
向量的幅度. |
LengthSqr
|
float LengthSqr()
|
向量的幅度的平方. 比上一个方法更快. |
Length2D
|
float Length2D()
|
返回x-y平面上向量的幅度. |
Length2DSqr
|
float Length2DSqr()
|
返回x-y平面上向量幅度的平方. 比上一个方法更快. |
Norm
|
float Norm()
|
以浮点数返回向量的长度. 这个函数同时也会将向量标准化, X, Y和Z值将被设置为-1和1之间的数字. 然后你可以将这些值乘以例如3000, 以使用该向量来设置游戏中某物的速度. |
ToKVString
|
string ToKVString()
|
返回一个没有分隔符的字符串. |
Members
实例 | 类型 | 描述 |
---|---|---|
x
|
float
|
笛卡尔x轴. |
y
|
float
|
笛卡尔y轴. |
z
|
float
|
笛卡尔z轴. |
全局函数
打印与绘制
函数 | 签名 | 描述 |
---|---|---|
DebugDrawBox
|
void DebugDrawBox(vector origin, vector min, vector max, int r, int g, int b, int alpha, float duration)
|
绘制一个调试覆盖框(debug overlay box). |
DebugDrawLine
|
void DebugDrawLine(Vector start, Vector end, int red, int green, int blue', bool zTest, float time)
|
在两点间绘制一根调试线(debug line). |
Msg
|
void Msg(string message)
|
相当于print
|
print
|
void print(string message)
|
将给定的消息打印到开发人员控制台. |
printl
|
void printl(string message)
|
功能同上, 但会在最后附加一个换行符. |
ScriptPrintMessageCenterAllWithParams
|
void ScriptPrintMessageCenterAllWithParams(string, string, string, string)
|
在屏幕中央向所有玩家打印消息. 需要传递token/消息. 可以传递null给param1, param2, param3如果你只需要3个以内的参数. |
ScriptPrintMessageCenterAll
|
void ScriptPrintMessageCenterAll(string message)
|
在屏幕中央向所有玩家打印消息. |
ScriptPrintMessageCenterTeam
|
void ScriptPrintMessageCenterTeam(int, string)
|
在屏幕中央向指定队伍的玩家打印消息. |
ScriptPrintMessageChatAll
|
void ScriptPrintMessageChatAll(string message)
|
在聊天框中向所有玩家打印消息. |
ScriptPrintMessageChatTeam
|
void ScriptPrintMessageChatTeam(int teamNumber, string message)
|
在聊天框中向指定队伍的玩家打印消息. |
ShowMessage
|
void ShowMessage(string)
|
打印一条HUD消息给所有玩家. ![]() |
__DumpScope
|
void __DumpScope(int indentation, handle scope)
|
转储域内的所有内容. |
训练课程相关
函数 | 签名 | 描述 |
---|---|---|
ScriptGetBestTrainingCourseTime
|
int ScriptGetBestTrainingCourseTime()
|
获取玩家完成计时课程的最佳时间. |
ScriptGetPlayerCompletedTraining
|
bool ScriptGetPlayerCompletedTraining()
|
如果玩家已完成训练地图的初始部分, 则返回true. |
ScriptGetValveTrainingCourseTime
|
int ScriptGetValveTrainingCourseTime()
|
获得Valve完成计时课程的最佳时间。 |
ScriptHighlightAmmoCounter
|
void ScriptHighlightAmmoCounter()
|
发送一个刚被指导系统用于显示一个用于突出弹药计数器的提示的事件. |
ScriptSetBestTrainingCourseTime
|
void ScriptSetBestTrainingCourseTime(int bestTime)
|
设置玩家完成计时课程的最佳时间. |
ScriptSetMiniScoreHidden
|
void ScriptSetMiniScoreHidden(bool scoreHidden)
|
切换迷你记分牌HUD元素的可见性. |
ScriptSetPlayerCompletedTraining
|
void ScriptSetPlayerCompletedTraining(bool trainingCompleted)
|
设置玩家是否完成了训练地图的初始部分. |
ScriptShowExitDoorMsg
|
void ScriptShowExitDoorMsg()
|
当玩家通过出口门退出时, 在训练课程中显示一个消息框. |
ScriptShowFinishMsgBox
|
void ScriptShowFinishMsgBox()
|
显示一个消息框,让玩家在完成训练课程后知道下一步该怎么做. |
ScriptTrainingGivePlayerAmmo
|
void ScriptTrainingGivePlayerAmmo()
|
对玩家拥有的所有武器重新装填弹药(只在训练模式中有用). |
合作模式相关
函数 | 签名 | 描述 |
---|---|---|
ScriptCoopCollectBonusCoin
|
void ScriptCoopCollectBonusCoin()
|
将其中一个奖励币标记为已收集. |
ScriptCoopGiveC4sToCTs
|
void ScriptCoopGiveC4sToCTs(int)
|
将指定数量的C4给予所有活着的CT玩家. |
ScriptCoopMissionGetMissionNumber
|
int ScriptCoopMissionGetMissionNumber()
|
获取当前地图的任务编号(备注:地图可以有多个任务). |
ScriptCoopMissionRespawnDeadPlayers
|
void ScriptCoopMissionRespawnDeadPlayers()
|
仅用于重生玩家. |
ScriptCoopMissionSetNextRespawnIn
|
void ScriptCoopMissionSetNextRespawnIn(float, bool)
|
设置下一波重生的发生时间. |
ScriptCoopMissionSpawnFirstEnemies
|
void ScriptCoopMissionSpawnFirstEnemies(int)
|
在合作模式中生成第一波敌人. |
ScriptCoopMissionSpawnNextWave
|
void ScriptCoopMissionSpawnNextWave(int)
|
告知合作模式中下一波将要出生的敌人. 此函数也会复活玩家. |
ScriptCoopResetRoundStartTime
|
void ScriptCoopResetRoundStartTime()
|
重设回合时间并开始任务. |
ScriptCoopSetBotQuotaAndRefreshSpawns
|
void ScriptCoopSetBotQuotaAndRefreshSpawns(int)
|
通过考量在线玩家数量来设置机器人数量并刷新复活. |
数学
The built-in Squirrel math library.
Function | Signature | Description |
---|---|---|
abs
|
int abs(float x)
|
返回 x 的绝对值
|
acos
|
float acos(float x)
|
返回对 x 进行acos运算后的值
|
asin
|
float asin(float x)
|
返回对 x 进行asin运算后的值
|
atan
|
float atan(float x)
|
返回对 x 进行atan运算后的值
|
atan2
|
float atan2(float x, float y)
|
返回对 x 进行atan2运算后的值
|
ceil
|
float ceil(float x)
|
返回对 x 进行向上取整的值,返回值是一个float型整数
|
cos
|
float cos(float x)
|
返回对 x 进行cos运算后的值
|
exp
|
float exp(float x)
|
返回 x 的指数运算后的值
|
fabs
|
float fabs(float x)
|
返回对 x 进行float转型后的值
|
floor
|
float floor(float x)
|
返回对 x 进行向下取整的值,返回值是一个float型整数
|
log
|
float log(float x)
|
返回 x 的log e对数
|
log10
|
float log10(float x)
|
返回 x 的log 10对数
|
pow
|
float pow(float x, float y)
|
返回x 的 y 次方
|
rand
|
int rand()
|
返回一个从 0 到 RAND_MAX 的随机int整数
|
sin
|
float sin(float x)
|
返回对 x 进行sin运算后的值
|
sqrt
|
float sqrt(float x)
|
返回对 x 进行开平方后的值
|
srand
|
void srand(float seed)
|
给上面那个随机数定义一个随机seed |
tan
|
float tan(float x)
|
返回对 x 进行tan运算后的值
|
其他
函数 | 签名 | 描述 |
---|---|---|
Assert
|
void Assert(bool value, string optional message)
|
检测布尔值, 如果不是true, 则显示异常, 可附带消息. |
CreateProp
|
handle CreateProp(string class, Vector origin, string model, int animation)
|
通过指定的类型和模型创建一个prop. 对于prop_physics, prop_dynamic 和其他一些带模型的实体都有效. 这个函数不会预缓存模型. ![]() |
CreateSceneEntity
|
CSceneEntity CreateSceneEntity(string scene)
|
创建一个场景实体来播放指定的场景.vcd文件. |
DispatchParticleEffect
|
void DispatchParticleEffect(string particleName, Vector, Vector)
|
调用一个一次性粒子系统. |
DoIncludeScript
|
bool DoIncludeScript(string filename, table scope)
|
执行脚本域设定为指定的表的脚本. |
DoEntFire
|
void DoEntFire(string target, string action, string value, float delay, handle activator, handle caller)
|
生成一个实体I/O事件. caller参数为句柄, 所以 target 可以设置成!self 来触发没有targetname的实体的输出. |
EntFire
|
function EntFire(string target, string action, string value, float delay = 0.0, handle activator = null)
|
生成一个实体I/O事件. |
EntFireByHandle
|
void EntFireByHandle(handle target, string action, string 'value, float delay, handle activator, handle caller)
|
生成一个实体I/O事件. 第一个参数是一个实体实例, 所以无名的或者由脚本创建的实体的句柄可以被轻松地传递. |
FrameTime
|
float FrameTime()
|
获取上一帧在服务器上花费的时间. |
GetDeveloperLevel
|
int GetDeveloperLevel()
|
获取developer模式的级别. |
GetMapName
|
string GetMapName()
|
获取地图名. |
LoopSinglePlayerMaps
|
bool LoopSinglePlayerMaps()
|
连续循环运行单人游戏地图. |
PrintHelp
|
[待完善] | |
RandomFloat
|
float RandomFloat()
|
生成一个随机浮点数 |
RandomFloat
|
float RandomFloat(float min, float max)
|
在一个给定范围内生成随机浮点数, 范围边界包括在内. |
RandomInt
|
int RandomInt()
|
生成一个随机整数. |
RandomInt
|
int RandomInt(int min, int max)
|
在一个给定范围内生成随机整数, 范围边界包括在内. |
RecordAchievementEvent
|
void RecordAchievementEvent(string, int)
|
录制成就事件或者进程. |
RetrieveNativeSignature
|
void RetrieveNativeSignature(string or func)
|
理论上这是用来打印本地函数的调用格式的函数, 但它实际上似乎只能输出 <unnamed>
|
ScriptGetGameMode
|
int ScriptGetGameMode()
|
返回game_mode的设置. 请查阅 CSGODS # 专用服务器 了解更多信息. |
ScriptGetGameType
|
int ScriptGetGameType()
|
返回game_type的设置. 请查阅 CSGODS # 专用服务器 了解更多信息. |
ScriptGetRoundsPlayed
|
int ScriptGetRoundsPlayed()
|
获取从游戏开始迄今所经历的回合数. |
ScriptIsLocalPlayerUsingController
|
bool ScriptIsLocalPlayerUsingController()
|
返回玩家是否在使用控制器玩游戏. |
ScriptIsWarmupPeriod
|
bool ScriptIsWarmupPeriod()
|
返回是否是热身时间. |
ScriptSetRadarHidden
|
void ScriptSetRadarHidden(bool hideRadar)
|
切换雷达HUD元素的可见性. 仅适用于训练模式(game_type 2且game_mode 0)并且仅适用于连接的第一个人. |
SendToConsole
|
void SendToConsole(string command)
|
将一串命令以字符串形式发送到控制台. |
SendToConsoleServer
|
void SendToConsoleServer(string)
|
发送一个字符串, 作为服务器命令在服务器上执行. |
Time
|
float Time()
|
获取当前的服务器时间. |
TraceLine
|
float TraceLine(Vector, Vector, handle)
|
given 2 points & ent to ignore, return fraction along line that hits world or models. |
UniqueString
|
function UniqueString(string)
|
使用可选的根字符串生成一个字符串, 该字符串在脚本VM的整个生命周期中保证是唯一的. 当不知道该表中已经使用了哪些密钥时,对于向表中添加数据来说作用很大. |
__ReplaceClosures
|