求生之路2脚本

From Valve Developer Community
Jump to: navigation, search

<Squirrel Language><Left 4 Dead 2> Left 4 Dead 2 脚本是运行在服务器端的虚拟机。 它们用一种类似于Lua 的编译脚本语言 Squirrel写的。


Uses

导演实体脚本

脚本用在求生之路2里最常见的就是[1]。 这些脚本能从infected spawning到prohibiting boss infected的小范围调整, 自定义一些比如onslaughts和gauntlets, 甚至复杂的恐慌事件和完全自定义的custom finales。官方宣传活动中的大部分都是以这种方式实现的。

Director脚本主要通过将Director所使用的各个变量的值覆盖到DirectorOptions表中来工作。

导演实体脚本一次只能运行一个。而且执行一个新的将会终止任何先前运行的一个,并删除它在DirectorOptions中设置的任何值。

实体脚本

实体脚本也是另一种常用的脚本,主要给实体附上脚本。该实体脚本能让我们轻松访问和修改实体的属性, 甚至添加一个新的键值。这允许以对于Hammer中的实体I / O系统非常复杂或不可能的方式来控制实体。

任何实体都能够运行脚本,并且能够将指定的think函数设置为每0.1秒运行一次,以及将脚本代码作为实体输出执行。

一些实体还具有专用于VScript的功能,其中最突出的是point_script_use_target,允许将其他实体转换为完全可编程的定时按钮。

Global Scripts

Scripts can also be made to run on map load, based on game mode and optionally map name. These scripts are commonly used to create scripting and modify global Director options for mutations, but can also be used in custom maps.

Global scripts can have script hook functions added that get called from the game at certain events, like when players/objects take damage.

There are many utility functions and features readily available for these scripts, including a resource and building system, and custom panic wave spawning. Please see Valve's Expanded Mutation System tutorial for more information.

Other uses

All scripts can access functions for many features, including spawning entities either from precompiled lists or programmatically, spawning infected, a HUD system, storing data across levels and to disk, and much more.

Please see L4D2 Vscript Examples for more examples and ideas.