求生之路2关卡设计/武器和物品的生成

来自Valve Developer Community
跳转至: 导航搜索
English (en)Русский (ru)中文 (zh)
编辑

本简体中文页面由 Gloria 汉化,最后由大康更新于2022年8月5日。

求生之路二代的武器生成机制有了很大的扩充和增强。虽然你还是可以像一代在地图中放置特定的武器、物品实体,但二代新的weapon_spawn实体让AI导演得以参与到武器生成的控制当中。另一个好处在于,它可以为对抗/清道夫模式提供对应的生成物。

相对于 info_landmark,安全室内的武器将被转移到下一张地图中。这意味着即将到来的地图中的所有武器生成都将被删除并替换为上一张地图末端安全室中可用的任何武器和物品。这允许你放置 weapon_spawn 实体以随机出现武器,并让相同的武器出现在下一个安全室中。
这也意味着你不必非常注意将枪支放在两个安全室的字面上完全相同的位置。因为唯一重要的部分是 info_landmark,它为你完成了复杂的工作。

放置武器生成实体

点击Entity tool Mt-entities.png并在Objects下拉框中选择weapon_spawn实体

在3D视图中,找到你的关卡开始的地方,在桌子上点击来放置武器生成实体。示例地图中已经有了一个。把你的放在旁边就好了。

武器生成实体

尽管为了方便摆放,在Hammer视图中显示的是M16步枪模型, 但游戏中实际生成的枪是各式各样的。

把武器生成列表限制为“一级主武器(tier 1 primary)”,这样我们可以在稍后的地图中放2级主武器。选中放置好的weapon_spawn实体之后,打开属性窗口,点击Selection属性。

在下拉框中,选择“Any tier 1 primary”。

正如下拉框中所展示的,你也可以限制它生成的武器类别,比如霰弹枪、手枪等等。

直接的武器生成器

如果您正在构建 weapon_spawnweapon_item_spawn 不起作用的生还者地图,你可以使用以下实体确定始终在同一地点生成的特定武器:

Note.png注意:这些也适用于默认地图,但导演不会决定是否生成它们。

机枪

游戏中还有机枪,使用时间过长会过热。它们通常被放置在要塞地点,例如结局或废弃的军事前哨。
转轮机枪在 20 秒后过热并冷却 3 秒。机枪过热需要 15 秒,冷却需要 60 秒。

生成近战武器

放置近战武器的方法和上面差不多,区别在于用的是weapon_melee_spawn实体。去放一个在地图里然后打开属性窗口吧。

把允许生成的近战武器种类写在Melee Weapon栏中。可选的武器名称有:

  • golfclub (高尔夫球杆)
  • fireaxe (消防斧)
  • frying_pan (平底锅)
  • machete (大砍刀)
  • baseball_bat (棒球棍)
  • crowbar (撬棍)
  • cricket_bat (板球棒)
  • tonfa (警棍)
  • katana (武士刀)
  • electric_guitar (电吉他)
  • riotshield (防爆盾)
  • Any (任意武器) – 导演随机放置不同的近战武器

你还可以自定义一个用逗号隔开的近战武器列表,导演会从中选取一种武器生成:

crowbar,fireaxe,machete

注意:防爆盾在90 0 0角度才是平放的,而不像其它武器平放角度是90 0 0。

生成物品

物品生成的方式几乎一样,使用的是weapon_item_spawn实体。我们来丰富一下桌子上的军火库吧。

在实体属性中,可以通过把它们的值设置成1来控制允许生成的物品。 类似的,可以用upgrade_spawn来生成激光瞄具和燃烧子弹升级包。

预先确定的物品生成点

对于预先确定的物品生成点,使用以下实体。

以下项目需要 FGD 文件编辑才能正确使用。如何执行此操作可以在此 Steam 指南上找到

可携带物品

尽管氧气罐、丙烷罐和烟花箱有自己的实体,但它们生成为 prop_physics

prop_physics 实体放入你的地图并使用以下任何模型生成可携带的对应物:

  • models/props_junk/propanecanister001a.mdl
  • models/props_junk/explosive_box001.mdl
  • models/props_equipment/oxygentank01.mdl

汽油桶可以使用 weapon_gascan_spawn 生成


测试运行

生成物品

现在可以运行地图了。每次重新载入,都会生成不同的武器。示例地图中的一代霰弹枪是个例外,因为它是weapon_pumpshotgun_spawn实体,因此每次生成的都一样。

Note.png注意:如果你想让旧的 weapon_pumpshotgun_spawn 不出现在 Left 4 Dead 2 版本的地图中,但仍希望将其保留在 .VMF 中,你可以在 求生之路 2 的 .VMF 中创建一个 logic_auto 并让它移除(Kill)泵霰弹枪。

Weapon placement capability in L4D2 maps has been expanded and enhanced. While you can still place specific weapon and item entities as in L4D1, the new weapon_spawn allows more flexibility by allowing the A.I. Director to procedurally generate your player's arsenal. Another benefit of using these new spawn entities is that they will provide matching items for both versus/scavenge teams.

Weapons inside saferooms will be carried over into the next map, relative to the info_landmark. Which means all the weapon spawns in the upcoming map will be deleted and replaced with whatever weapons and items were available in the previous map's end saferoom. This allows you to place weapon_spawn entities to randomize the appearing weapon and have the same weapon show up in the next saferoom.
This also means that you don't have to pay a lot of attention to having the guns be in the literal exact same spot for both saferooms. Because the only important part will be the info_landmark, which does the heavy lifting for you.

Placing Weapon Spawners

Activate the the Entity tool Mt-entities.png and select the weapon_spawn entity from the Objects drop-down menu.
This entity is a random spawn point for a set of possible weapons based on tier or weapon type.
The Director will randomly pick which weapon_spawn and weapon_item_spawn should be spawned. Sometimes nothing will spawn. The info_map_parameters entity can be used to determine how the map should be populated with items, when used in conjunction with the console command, director_solve_item_density x.

Using the 3D view, navigate to the starting area in the map and click to place a weapon spawn on the table. You should see an older weapon spawn in the instance. Just place it next to it.

Weapon spawning Entity

Although it appears in the Hammer viewport as an M16 rifle for placement purposes, what it spawns during gameplay will vary.
You can add a "Helper Model" to the entity, to pick what model you want to see. This can be achieved by editing the FGD file, as explained in this Steam Guide

Let's restrict this weapon spawn to tier 1 primary, so we can save tier 2 for later in the map. With the recently placed weapon_spawn entity selected, open the Properties window and click on the Selection field. From the drop down menu, select "Any tier 1 primary".

As you can see from the drop-down, you can similarly limit it to a certain type of weapon, such as any shotgun, any pistol, etc.

Direct Weapon Spawners

If you are building a survival map in which weapon_spawn and weapon_item_spawn does not work, you can determine a specific weapon to always spawn in the same spot using the following entities:

Note.png注意:These work on default maps as well, but the Director will not decide whether to spawn them or not.

Mounted weapons

Mounted guns are also available, which overheat when used for too long. They are usually placed in fortified locations such as Finales or abandoned military outposts.
The minigun overheats after 20 seconds and cools down for 3 seconds. The machine gun takes 15 seconds to overheat and 60 seconds to cool down.

Melee weapons

Placing melee weapons procedurally works in much the same way using the weapon_melee_spawn entity. Go ahead and place one of these and open up the Properties dialog.

The weapons that you want to allow to spawn at this location have to be included in the text field. Names include:

  • Any – director will place any melee weapon listed in the Missionfile's "meleeweapons" string.
  • baseball_bat
  • cricket_bat
  • crowbar
  • electric_guitar
  • fireaxe
  • frying_pan
  • golfclub
  • katana
  • knife
  • machete
  • pitchfork
  • shovel
  • tonfa

You may also list multiple specific melee weapons separated by a comma, and the director will select from among that subset of weapons:

crowbar,fireaxe,machete

You may even have additional custom melee weapons by crating a working weapon model and then creating a melee weapon script in "scripts/melee". Copy an existing one as a base and modify it to make it easier for you.
The name of that script, without extension, is the name to use in the missionfile to allow it at all, and the weapon_melee_spawn entity.

Item spawning

Item spawning works in much the same way, with weapon_item_spawn providing a way to spawn any one of a set of items. Let's go ahead and add a couple to the arsenal on the table.

Under Properties, you can specify the items that you wish to allow by changing their value to 1. Similarly, laser sights and ammo upgrade packs are placed using the upgrade_spawn entity.

Predetermined Item Spawners

For Predetermined item spawn points, use the following entities.

The following items require FGD file edits to use properly. How to do so can be found on this Steam Guide

Carryable Objects

Although Oxygen Tanks, Propane Tanks and Firework Crates have their own entities, they're spawned as Prop_physics instead.

Place a Prop_physics entity into your map and use any of the following models to spawn their carryable counterpart:

  • models/props_junk/propanecanister001a.mdl
  • models/props_junk/explosive_box001.mdl
  • models/props_equipment/oxygentank01.mdl

Gascans can be spawned using weapon_gascan_spawn

Test run

Item spawning

Go ahead and run your map. Each time you reload it, you should see a different collections of weapons, with the exception of the L4D1 shotgun in the original instance. That will remain the same since it is a weapon_pumpshotgun_spawn.

Note.png注意: If you want to have that older weapon_pumpshotgun_spawn not appear in the Left 4 Dead 2 version of the map, but still want to keep it in the .VMF, you can create a logic_auto in the L4D2 .VMF and have it kill the pump shotgun.