本简体中文页面由大康翻译于2021年9月11日。
在求生之路2中,我们发现 Witch 只在晚上坐着摇晃自己。如果有阳光,它们就会四处游荡。你可以通过 Map > Map properties… 菜单项在地图中控制此设置。
如果你将 Time of day 更改为一天中太阳出现的任何时间,包括“Dawn
”(黎明)、“Morning
”(上午)和“Afternoon
”(下午),由导演生成的 Witch 会四处游荡。
在运行时改变行走方式
如果你想同时拥有站立和坐着的 Witch ,或者随机选择使用哪个,你可以使用脚本来实现。
创建一个名为 Witch_behaviour.nut(或任何有意义的名称)的文本文件,并将其放入 scripts/vscripts 文件夹。
该脚本应包含以下内容:
function WitchWalk(){
worldspawn_timeofday <- [
"3"
]
worldspawn <- Entities.FindByClassname (null, "worldspawn");
local i = RandomInt(0,worldspawn_timeofday.len()-1);
worldspawn.__KeyValueFromString("timeofday",worldspawn_timeofday[i]);
}
function WitchSit(){
worldspawn_timeofday <- [
"0"
]
worldspawn <- Entities.FindByClassname (null, "worldspawn");
local i = RandomInt(0,worldspawn_timeofday.len()-1);
worldspawn.__KeyValueFromString("timeofday",worldspawn_timeofday[i]);
}
注意:此脚本基于此脚本示例,但合并为一个脚本并更改了函数名称以使其更有意义。
接下来,将一个 logic_script 实体放入你的地图中,并在“Entity Scripts”字段中输入“Witch_behaviour”。
任何能够触发输出的实体,例如 logic_timer、trigger_once、func_button、logic_case 等可以使用以下输出来改变下一个生成的 Witch 的行为,直到再次改变:
坐着的 Witch
|
My Output |
Target Entity |
Target Input |
Parameter |
Delay |
Only Once
|
|
输出条件取决于实体 |
<logic_script 实体名称> |
RunScriptCode |
WitchSit() |
0.00 |
No
|
游荡的 Witch
|
My Output |
Target Entity |
Target Input |
Parameter |
Delay |
Only Once
|
|
输出条件取决于实体 |
<logic_script 实体名称> |
RunScriptCode |
WitchWalk() |
0.00 |
No
|
注意:这不会使流浪 Witch 坐下,反之亦然。
你还可以使用 logic_case 在 Witch 行走行为之间随机选择并一个接一个地生成它们,并进行复杂的设置,你就有了诸如糖厂(c4m2)之类的地图,但同时包含坐着和游荡的 Witch。
In L4D2, we discover that witches sit and rock themselves only at night. If there's sunlight, they wander. You can control this in your map from the Map > Map Properties... menu item.
If you change Time of day to any time of day when the sun is out, including "Dawn
", "Morning
", and "Afternoon
", witches spawned by the Director will wander.
Changing Behaviour at runtime
If you would like to have both standing and sitting witches, or randomly pick which to use, you can do so by using a vscript.
Create a text file called Witch_behaviour.nut (or any sensical name) and put it into the scripts/vscripts folder.
The script should contain the following:
//This script basically just swaps a Cvar specifically bound to witch behaviour.
function WitchWalk(){
Convars.SetValue("sv_force_time_of_day",3)
}
function WitchSit(){
Convars.SetValue("sv_force_time_of_day",0)
}
Next, place a logic_script entity into your map, using "Witch_behaviour" in the "Entity Scripts" field.
Any entity capable of firing outputs, such as logic_timer, trigger_once, func_button, logic_case, ect. can have the following output to change the behaviour of the next spawned witches until changed:
Sitting Witch
|
My Output |
Target Entity |
Target Input |
Parameter |
Delay |
Only Once
|
|
Depends on entity |
<logic_script entity name> |
RunScriptCode |
WitchSit() |
0.00 |
No
|
Wandering Witch
|
My Output |
Target Entity |
Target Input |
Parameter |
Delay |
Only Once
|
|
Depends on entity |
<logic_script entity name> |
RunScriptCode |
WitchWalk() |
0.00 |
No
|
注意:This will not make a witch stand up or sit down after she has spawned.
You could also make an intricate setup of a logic_case randomly picking between witch behaviours and spawns them one after another, to get a map such as the Sugarmill, but with both sitting and wandering witches.