# [Personal Contacts](
http://fractalsoftworks.com/2020/08/13/personal-contacts/)
# 人脉关系
Posted August 13, 2020 by **`Alex`** in `Development`, `Modding`
Translated at Auguest 13 by **`jn_xyp`**
于2020年08月13日翻译,译者:**`jn_xyp`**
> 注意,文中出现的`联络人(Contact)`为暂定翻译,不能代表汉化组的意见。
> 感谢 **`灰色渡鸦`**,**`免费的午餐`** 在翻译过程中提供的协助。
## **摘要(译者添加)**
**本文主要介绍了新的游戏任务机制和API,现在玩家可以和数位联络人建立关系,并从他们那里接到任务。不同类型的联络人派发不同种类的任务,任务等级取决于联络人本身的地位和与联络人间的关系级别。新加入大量任务类型:包括针对余晖、精英佣兵和势力巡逻队的特殊赏金任务,赏金任务难度可选。亦包括使用新突袭系统的营救或瘫痪任务。新任务API采用声明式设计,降低了常见需求的实现难度。**
One of the bigger tasks for this release cycle has been adding new content into the game. Since a lot of it is story content – think the “Red Planet” mission, but on a bigger scale with things tying together and building up – it’s not something that I can really talk about without spoiling it.
But, not all the new missions are “story” missions. A lot of them missions are just new things you can do in the game, without being unique one-offs. Consider, for example, the current missions to scan a derelict, survey a planet, or collect a bounty – these new missions are all roughly along these lines, with of course more variety thrown in.
本次版本更新的主要任务之一就是为游戏添加更多的内容;主要是类似于先前“红色星球”这样的,但是规模更加宏大,更加复杂的剧情内容。为了避免剧透,我不能透露太多这方面的信息。
然而,并非所有的新任务都是这种剧情性的任务。其中很多任务只是你在新版游戏中可以做的新事情,而不是那种独一无二的一次性任务。举例而言,当前版本中的遗弃物扫描、星球调查和赏金任务都属于此类。新的非剧情性任务与此类似,但是会有更丰富的种类和变化。
The question is, how do we make them available to the player?
问题在于,我们应当如何将这些任务提供给玩家?
## Current System 目前的体系
The current missions just “pop up” as a new message in the lower left of the screen, and they can be looked at (and accepted) by looking at their details in the intel screen. This is nice because you become aware of new opportunities as they become available.
目前的任务信息是通过界面左下方的弹出消息来发布的,玩家可以在网路信息面板中查看任务的细节以及接受任务。这种设计的好处在于,玩家可以及时了解新出现的任务信息。
Since only opportunities that are reasonably nearby show up this way, there’s some filtering going on, so the player isn’t overwhelmed by, say, postings for minor procurement missions on the other side of the core worlds. At least, that’s the theory. In practice, missions tend to be important enough that this filtering doesn’t accomplish too much, but with relatively few missions being offered this way, it still works out.
由于任务过滤机制的存在,只有在玩家附近合理距离内的任务才会被显示出来,以避免玩家被来自星区另一头的小商品采购信息淹没。虽然理论上没问题,但是在实践中,过滤器对重要程度足够高的任务并不生效;但由于仅有少量此类高重要度任务,过滤的效果还是可以接受的。
However, this approach doesn’t scale – add an extra 20 or so mission types, and one of two things will happen. Either the player will be overwhelmed with non-stop new mission notifications, or we tone down the rate at which new missions are generated, and the player doesn’t get enough of the ones they’re actually interested in. For example, if you’re playing as a bounty hunter, and all you’re getting is trade contracts of some kind, that’s no good.
然而,这种机制并不能适应更大规模的应用。在比如增加了二十多种不同类型的任务之后,要么玩家会被刷屏的任务通知淹没,要么就得调低每种任务生成的频率,而这样就会导致玩家接不到他们真正感兴趣的任务。比如你这把玩的是赏金流,结果却不停地接到各种贸易合约,那就不好了。
What we need, then, is a way for the player to express what they’re interested in on any given playthrough. This could take the form of some kind of UI where you say, “I mostly want bounty missions, and some underworld ones” and you’d get notified about those.
This… would probably work, actually. One potential issue is that generating missions on the fly like that can be computationally expensive. For example – this is a bit of a simplification, but say the mission requires a specific kind of object to be placed in a specific kind of star system etc etc. Finding something matching all these parameters could potentially take too long for it to be something you can do without causing a frame drop. At the very least, it means a lot of care has to be exercised to make sure that doesn’t happen.
我们其实需要一种途径,让玩家表达出他们对于某种玩法的意向。这可以通过某种用户界面设计来实现:玩家可以选择说“我主要想打赏金,还有干一些黑道上的活计”,那么玩家就只会收到这方面的任务提醒。
这无疑是一种可行的途径。然而,这种做法的一个隐患就是动态生成任务导致的大量性能开销。举一个简单的例子,任务需要在符合某种要求的星系生成某种物体等等之类的。要想在不导致掉帧的情况下,检索到这么一个符合要求的对象几乎是不可能的。至少需要投入大量的精力才能避免这种情况的发生。
I think we can do something that both gets around this and is more fun, though.
我想到了一种既能避免这种问题,又更加有趣的解决方法。
## Contacts 联络人
How would a proper star-faring captain – of perhaps somewhat questionable moral fibre – get a hold of opportunities? Naturally, they would do it through a network of contacts. Above-board opportunities are for suckers – I mean, you might even have to pay tariffs. The horror! And even for a more principled brand of captain, the best opportunities would still be found from like-minded people in positions of influence – they wouldn’t be offered to just anyone.
对于一位遨游星间的舰长来说,如何才能把握机会?公开的贸易情报是给菜鸟们看的,随之而来的关税更是恐怖如斯。而无良的舰长们则会通过他们的地下关系网来抢占先机。即使对于那些有原则的正直舰长,为得到那些绝佳的,从不公开的机会,与位高权重者的亲密关系也是不可或缺的。
So! On a high-level, the player develops various kinds of contacts, and, as the relationships progress, they offer more interesting opportunities. What kind of opportunities the contact offers depends on who they are. The sort of contacts the player develops, then, is the way the player tells the game what they’re interested in, which the game can then deliver.
Aside from this mechanical role, this also offers the player more roleplaying opportunities, and the feeling of developing a personal connection with someone in the game world.
所以在实际游戏中,玩家将会发展各种各样的人脉关系;并且随着关系的发展,联络人将会为玩家提供更多有趣的机会。联络人所能提供的任务种类取决于他们的身份。由此,玩家可以通过选择不同类型的联络人,来告诉游戏自己的玩法偏好,以便游戏据此提供相应的内容。
除了在游戏机制中的功能,这一系统也为玩家提供了更多进行角色扮演的机会,以及这种在游戏世界中建立人脉网络的体验。
## Contact Basics 联络人机制简介
There are three types of contacts – military, underworld, and trade. These are “tags”, so it’s possible (though very rare) for a contact to combine two of these. A contact is generally located at a colony, and when the player visits them, the contact will have some missions for them. Note that it’s “will”, not “may” – since the player needs to make the commitment to actually go visit the contact, there needs to be some kind of payoff. Of course, there’s a slight cooldown immediately after a contact is visited, but any sort of normal visiting schedule will result in missions being available.
目前有三种不同的联络人分类:军方,黑道和商贸。需要注意的是,这些分类是一种“标签”,也就是说在罕见的情况下,一位联系人可以同时属于两个分类。联系人一般是定居在某处殖民地上,并且当玩家去拜访他们时,他们将会给玩家发布任务。因为玩家需要承诺去拜访某位联络人,所以作为回报,联络人一定会给与玩家任务。当然,在拜访过后会有一段冷却时间,但每次拜访必定会接到一个新的任务。
Tying this back to an earlier point: since the missions are generated when the player talks to the contact – that is, the game is paused and in a UI interaction – we don’t have to worry quite so much about the performance of generating the missions. First of all, since the game is paused, there’s less computation being done. And, since we’re in a UI interaction and the computations happen as a result of player input, even if we did get a frame drop, it wouldn’t interrupt anything the player was doing – and happens on a static screen, to boot – so it wouldn’t be noticeable. I should say, this isn’t the biggest concern, but not having to worry about it is definitely a nice-to-have.
这种实现解决了一开始提到的问题:因为新的任务是在玩家与联络人交互时生成的,也就是说,是在游戏暂停时的交互界面上。因此,我们就不太需要担心任务生成带来的性能问题。首先,因为游戏目前处于暂停状态,所以在当时不需要进行太多的运算。并且,因为我们是在交互界面上,而任务生成的运算是由玩家的输入所触发的,所以即便是出现掉帧也不会打断玩家的任何操作。而且在静态屏幕上的卡顿也不会很明显。我想说,虽然这不是目前最重要的问题,但不用再操心这个绝对是件好事。
In addition to tags, a contact also has an “importance” – a measure of how influential they are within the hierarchy of whatever organization they belong to. There are 5 levels of importance, from “very low” to “very high”. For example, a low importance trade contact would offer missions involving smaller quantities of cheaper commodities. A high importance trade contact, on the other hand… let’s just say you might need an Atlas freighter or two. Or even a colony.
除了标签之外,每位联络人还有一个"重要性"指标,衡量他们在所属组织权力结构中的影响力。重要性分为5个等级,从 "非常低 "到 "非常高"。例如,一个低重要性的商贸联络人仅能提供涉及较小数量廉价商品的贸易任务。而一个高重要性联络人所提供的任务,则很有可能需要一两艘阿特拉斯-级货舰,甚至是一整个殖民地来完成。
A high importance contact doesn’t just start offering juicy missions, though – getting to that point requires completing a number of lower-importance missions. One way to think about it is the relationship level caps the “importance” of the contact, so the effects of higher importance only become realized once the relationship is higher.
然而,一个高重要性的联络人并不会上来就给你提供油水丰富的任务:你需要完成许多低级别的贸易合约才能实现。你可以这样想:能接到任务的级别上限取决于你与联络人的关系,所以只有当关系更高的时候,才有可能接到更高等级的任务。
## Developing Contacts 发展人脉关系
So, how do you find a contact? You need some sort of “in”. This takes the form of bar encounters – if you meet someone at a bar and they offer you a mission, and you complete it, there is a chance they will be a contact you can “develop”. (Most “contact” missions also have a “bar” version of the mission, by the way, so there will be a lot more going on in an average dockside bar.)
所以,玩家要上哪发展一位联络人呢?玩家需要某种“入伙”的途径,这个途径就是酒吧邂逅。如果你在空间站酒吧接到了某人的任务,在任务陈工完成后,你就有机会将任务发布者发展成你的联络人。(目前的大部分合约任务也会有其对应的“酒吧版本”,所以日后游戏里的普通港口酒吧将会有许多事情发生。
Why wouldn’t you just develop every single contact you come across? It seems like doing this would both be beneficial (more opportunities, easier access) and a grind to get all the relationships high. That wouldn’t be good, so “you and a hundred of your closest friends” shouldn’t be a thing.
那么,为什么不把每一个发布任务的人都发展成你的联络人呢?毕竟这样不仅可以让你获得更多的机遇,更方便找到他们,而且也能提高和所有人的关系。这种结果无疑是不好的,不应该允许“我和我一百个最好的朋友”的情况出现。
Fortunately, we can leverage story points (talked about at length [here](
http://fractalsoftworks.com/2019/07/08/skills-and-story-points/)) as a soft limiting mechanism. The rules are simple:
1. Up to 5 concurrent contacts are “free”; deleting a contact is also free
2. Contacts beyond 5 require a story point to develop
幸运的是,我们可以通过[剧情点数](thread-502-1-1.html)作为一种软性限制,规则很简单:
1. 前5位联络人的位置是“免费”的,移除一名联络人同样是免费的。
2. 超过5名联络人的部分需要剧情点数来增加。
This way, the player can ultimately develop as many contacts as they like, but since story points have other uses, it’s no longer “optimal” to just develop every potential contact. (In an interesting parallel, story points are *also* a mechanism the player can use to express what they’re more interested in doing. E.G. investing them into having more contacts would be one way of doing so.)
在这种限制下,虽然玩家仍然可以与任意位联络人建立关系,但是因为剧情点数也有其他的用途,所以发展每一位遇到的联络人并不是一种“最优”策略。(从另一方面来说,剧情点数的设计初衷*也是*为了让玩家表现出对游戏玩法的倾向。将点数用于发展人脉关系就是一个很好的例子。)
## Priority Contacts 优先联络人
Going further in the direction of letting the player express what they’re interested in, each contact can be designated as “priority” or not. Priority contacts offer more – and higher quality, as if the relationship was higher – missions.
为了让玩家进一步表现他们的兴趣所在,每位联络人均可以被标记为“优先”。优先联络人将会提供更多的任务,并且在关系足够的情况下,有着更高的任务质量。
The more contacts are flagged as “priority”, the less the effect on each individual contact. Also, turning this flag on takes about a month to take full effect – so that, for example, you don’t just have to toggle it on right before talking to any specific contact.
被标记为“优先”的联络人数量越多,标记本身对每位联络人的影响越弱。而且,优先标记需要大约一个月的时间才能展现出效果,所以也不用想着每次和联络人交谈前临时将其标为优先。
## Mission Examples 任务样例
Here, I just want to mention some examples of the various missions that you might find being offered by a contact – or at a bar, by a potential contact.
下面列出了一些可能存在的任务种类和样例,你可以在联络人,或是在酒吧的潜在联络人那里接到这些任务。
- Perform a “combat extraction” – use the new raid mechanics to rescue an agent, either stuck at a colony, or perhaps at a pirate base on the fringes of the Sector
- Deliver an item to a “dead drop” location
- Disrupt spaceport operations at a target colony for at least X days
- Begin producing at least X economy-units of a commodity at a colony you control to fill a cycles-long contract that will pay you for this production
- Smuggle a load of cargo to a colony
- Collect a special bounty
- 进行一次“武装救援”,使用新的突袭系统,从某处殖民地或星域边缘的海盗基地,营救一名特工
- 将某样物品丢在某处藏匿点
- 将某处殖民地的空间站瘫痪至少X天
- 签订为期1年的生产合约,承诺在你属下的殖民地中,生产至少X经济单位的某种商品来进行贸易
- 将一些货物偷偷运进某个殖民地
- 完成某项特别悬赏
> 注:经济单位指在殖民地管理页面显示的产出、消耗单位,并非市场中的货物物品数量。
The missions also generally have “complications”, so even ones that don’t on the face of it lead to the possibility of combat, will often do so. There’s also an emphasis on using the new raid mechanics for various custom objectives. This is both adding variety to missions, and giving marines (and ground combat related skills) a more prominent place in the game.
这些任务一般会包含额外的复杂情况,即使是某些目测不会酿成冲突的任务,也经常有引发战斗的可能。此外,新的任务还强调使用新的突袭机制来实现各种各样的自定义目标。这既增加了任务的多样性,也提高了陆战队员(和地面作战相关技能)在游戏中的重要性。
## Special Bounties 特殊赏金
The “special bounties” mission is a good one to elaborate on, because it triples-down on letting the player express what they’re interested in (it’s apparently today’s theme!)
“特殊赏金”类任务在此值得一提,因为这种任务也在鼓励玩家表达自己对于游戏内容的偏好(今天的主题就是这个)。
The basic mission is straightforward – you receive a bounty for eliminating a target. There is a pool of a bit over ten different types of bounty targets, ranging from the standard (pirates, deserters) to more exotic stuff like REDACTED stations and fleets, elite mercenaries, and faction patrols (when given by underworld contacts), and some other ones I won’t mention, because spoilers. The more unusual target types become available as the difficulty (and reward!) of the bounties ramps up.
基本的赏金任务非常简单:消灭目标,获得赏金。有超过十种不同类型的赏金目标,从普通的目标(海盗或逃兵)到一些更奇特的东西,例如余晖舰队和空间站,精英佣兵以及各大势力的巡逻队(黑道联络人提供此类赏金)等等,为了避免剧透就不多说了。随着赏金任务难度(和金额)的提升,这些稀有目标将会越来越多地出现。
This is where it gets interesting – managing what difficulty level is appropriate. Internally, the difficulty is a value from 0 to 10, and it goes up gradually as the player completes more bounties for that contact. However, when being offered a bounty, the player is also offered a choice – do they want an easier, average, or tougher target? The “average” choice results in the difficulty going up slowly over time, while the easier/tougher choices quickly take it up or down.
For example, if the player already has a strong fleet, but is developing a new contact, they can start off with a reasonable target right away, and get to the highest bounty level by selecting just a few of the “tougher” bounty options in a row. (Please pardon the placeholder text in the screenshot below!)
如何提供合理难度的赏金是一个有趣的问题;在游戏内部,对于每个联络人,赏金任务难度是一个从0到10的数值,随玩家完成来自该联络人赏金的次数增加而上升。不仅如此,在玩家接到赏金任务时,玩家也可以选择是要更加简单、困难或是一般般的目标。选择“一般”会导致难度随时间缓慢上升,而更简单或更难则会迅速降低或增加难度值。
例如,对于拥有一支强大舰队的玩家,当他们刚刚发展了一个新的联络人时,这一机制有助于快速获得合理难度的赏金目标:只需要连续选择几次“更难”选项,就可以获得最高等级的赏金任务。(下面截图中的字仅为占位使用,请见谅!)
On the other hand, if a player is facing bounties that are too difficult – either as a result of losing some ships, or due to the normal difficulty growth from completing bounties outpacing the player’s progression – they can easily turn it down a notch. Since these new high-end bounties are some of the most challenging enemies in the game, that’s a useful option to have.
(The choice of bounty difficulty, by the way, is not just scaling the strength of one specific target – I think it would feel pretty odd to do that. Rather, there are three separate bounties that the player can choose from.)
从另一方面来说,如果认为当前的赏金任务难度过高,不管是因为有船被打爆了抑或是难度等级的增长速度超过了玩家的游戏进度,玩家也可以很容易地将难度调低一个档次。因为这些新的赏金目标包括游戏中某些最有挑战性的敌人,所以这无疑是一个有用的选项。
(这三个赏金难度选项并不是通过修改同一目标的难度来实现的,因为我觉得这样挺奇怪的;它们其实对应三个不同的敌人。)
The system is also set up to make it easy for mods to plug in additional types of bounty targets.
这套新的赏金系统也提供了便捷的方法,来让Mod添加额外的赏金目标类型。
## Modding Mod制作
Speaking of mods, I’d like to talk a bit about how the new missions are implemented. It’s a lot of new content, so it made sense to first spend some time putting together a system that makes creating this content much easier. (This part will get a bit technical, so if it’s not your cup of tea, feel free to skip it.)
谈到Mod,我想谈一下新任务系统的实现方式。因为本次更新将会添加大量的新内容,为这些内容提前设计一套方便的制作工具就变得很有必要了。(这段内容可能比较偏向于技术,如果不感兴趣的话可以跳过)
There are a bunch of common tasks one has to do when creating a new mission. Some quick examples are, say, “find a star system / planet / entity matching some set of parameters”, or “create a specific type of fleet and give it certain orders”. These are not very complicated! But, annoyingly, the considerations are usually complex enough that just writing a single method with some arguments isn’t a good option. And there are also mission state transitions and such to consider.
在创建一个新游戏任务时,有许多常见的需求必须被实现。例如,“找到一个符合某些参数的星系/行星/实体”,或者 “创建一个特定类型的舰队并给它下达特定的命令”。这些需求本身并不太复杂,但是恼人的是,其复杂性又超过了写一个有一些参数的简单函数的范畴。除此之外,还要考虑任务的状态转换问题。
The bigger problem, though, is that the coding style for these is what’s generally called “imperative” – the code for a mission would spell out exactly how to find the right star system, or spawn the fleet. This means that the programmer (i.e. myself, or a modder) has to be quite careful and detail oriented, and do a mental “context switch” to immerse themselves in the technical details of what they’re doing.
This means that coming back to the mission code after doing something else is a pain – it takes time to re-immerse in what the code was doing. Even if you’re just switching back and forth between coding the specifics of the mission, and writing some dialogue for it, there’s a very real mental cost here. It means both more time spent per mission, and more bugs (which can be found and fixed, but still).
更大的问题在于,原有游戏任务代码的编码风格是一般所谓的“命令式”编程,代码必须准确具体地描述如何找到合适的星系,或是生成舰队。这意味着,对于我或者其它modder来说,必须加倍谨慎,精益求精,并随时切换思路的“上下文”,让自己沉浸到所做的技术细节中。
因此,在做其他的事之后再重新回来看任务代码,是一件很痛苦的事情:需要时间来将自己重新沉浸到代码细节中。就算是在一个游戏任务本身的代码细节和对话文稿之间进行切换,也有很高的精力上的成本。这不仅意味着制作每个任务要花费更多的时间,也意味着更多的bug(虽然能修但是仍然很烦)。
## New Approach 新的尝试
It’d be nice if instead of code, the specifics of the mission could all be data entry. Then you wouldn’t have to think about the details so much when putting that together. We can’t do that, can we? … well, probably not as such, but after all, all code is data (and vice versa, really). There’s a middle ground here – creating a basic framework that focuses on making mission code “declarative” – that is, describing what needs to be done, rather than how it needs to be done.
What this means is that writing mission code won’t require as much thinking about the details – it’ll be easier to just do something, and be confident that if it works in major ways, it just works, and there aren’t minor errors lurking somewhere. This could really do with an example. Let’s say you’re trying to find a star system that… I don’t know, has at least 4 planets in it.
如果能不用代码,而是能象录入数据一样描述任务的具体内容就好了。这样一来,就无需担心那些随之而来的琐碎细节了。可是这可能吗?好吧,虽然不能完全实现这一点,但毕竟所有的代码也是一种数据(反过来也是这样,真的),所以我们可以实现一种折衷方案,即创建一个允许以“声明式”代码来编写任务的框架——也就是说,代码应当描述所需结果的性质,而不是具体的过程。
这意味着,编写任务代码变得简单,不再需要考虑这么多细节了。只需要想着去做某件事情,只要大体上没问题,就一定不会存在那些细枝末节的错误。用一个常见的例子来说明,比方说你想要找到一个星系,有比如说至少四颗行星。
“Imperative”-style code would look like this:
“命令式”的代码看起来是这样的:
```
List<StarSystemAPI> potential = new ArrayList<StarSystemAPI>();
for (StarSystemAPI system : Global.getSector().getStarSystems()) {
if (system.getPlanets().size() >= 4) {
potential.add(system);
}
}
```
And then we’d pick one of those potential systems. And, by the way, that’s a trivial set of parameters – and yet, there’s a bug in that code. The “`getPlanets()`” method returns stars as well as regular planets, as under the hood they’re just different types of planets – so we’d need to subtract the number of stars in the system from the total. Now, I’d know this particular bit offhand, but there are tons of cases where I wouldn’t be 100% sure, and writing correct code would require looking more under the hood. That’s what I mean when I’m talking about needing to become “immersed” – it’s remembering all the little details in the area of the code you’re working with.
然后再从结果中选择一个星系。作为一个不能再简单的功能实现,这段代码中却仍然隐藏着一个bug。星系的`getPlanets()`方法不仅会返回星系中的行星,也会返回恒星;毕竟本质上它们都是不同类型的星球。所以在这里我们就需要从结果中减去星系中恒星的数量。虽然这个bug在这里很容易被发现,但除此以外还有数不胜数的,我自己都不确定的例子。在这些情况下,必须对于内部机制足够了解才能编写正确的代码。这种“了解”就是我前面所说“沉浸到细节中”的意思:你必须记住你编写和使用的代码的每一个细节。
## Declarative Example 声明式的例子
With the new system, we can instead write more “declarative” code to solve the same problem:
有了新的声明式任务系统,我们就可以编写更加“声明式”的代码来完成同样的任务。
```
requireSystemHasNumPlanets(4);
StarSystemAPI system = pickSystem();
```
… and that’s it, actually. That’s all there is to it! The code that runs as a result of this knows about the “don’t count stars” issue, so we don’t need to worry about it every time we’re looking through some planets. Again, it’s not hard, but if I’ve got to do it 20 times in slightly different ways (that are, as I mentioned, usually annoyingly hard to parameterize), chances are I’ll probably screw it up at least once.
就这,没了,结束了。通过这种方式所调用的代码知道需要排除恒星的问题,所以日后我们就不用操心这一点了。再说一次,实现这个功能本身没什么难的,但是如果要我写20遍,每次又有一点变化的话(因为之前提到很难抽象成带参数的方法,老烦人了),我可能至少得写错个一次。
We could also easily add some more search parameters:
我们也可以很容易地添加更多的搜索参数:
```
requireSystemNotHasPulsar();
preferSystemUnexplored();
```
This’ll search for a system that’s not going to fry the player to a crisp with a pulsar beam when they enter it, and preferably one that they haven’t been to before. Being able to do this requires creating a ton of these kinds of methods – that implement various search parameters and other actions. But that’s a one-time task, not something one has to engage in every time when adding a new mission.
这样写的话,将会找到一个没有中子星的星系,以免在跳进去时把玩家射爆;并且更倾向于选择尚未被探索的星系。虽然要做到这种程度需要常见一大堆这样的方法,以实现各种各样的搜索条件和其他操作,但比起每次新写任务都要操心,这种一劳永逸的做法显然更好。
## More Examples 更多的例子
(I won’t show equivalent imperative-style code here – in large part because it would be too long and complicated for this post. Which, really, just demonstrates the point.)
(我就不再这里展示与声明式等价的命令式代码了,因为对写文章来说太长太复杂了。文章主要就是展示一下这种思路。)
Wiring up basic mission state transitions and similar:
编写基本的任务状态转换和其它类似的东西:
```
setStartingStage(Stage.GO_TO_RUINS);
addSuccessStages(Stage.COMPLETED);
addFailureStages(Stage.FAILED);
makeImportant(planet, “$gada_targetPlanet”, Stage.GO_TO_RUINS);
connectWithGlobalFlag(Stage.GO_TO_RUINS, Stage.GET_IN_COMMS_RANGE, “$gada_gotData”);
connectWithInRangeOfCommRelay(Stage.GET_IN_COMMS_RANGE, Stage.COMPLETED);
setTimeLimit(Stage.FAILED, MISSION_DAYS);
```
Spawning a pirate fleet at a jump-point and making it go to a planet and patrol around it, triggered when the player is approaching the system in hyperspace:
在跳跃点生成一队海盗舰队,并使其前往一个星球并在其周围巡逻,触发条件是当玩家在超空间中接近本星系。
```
beginWithinHyperspaceRangeTrigger(planet, 1f, false, Stage.GO_TO_RUINS);
triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.DEFAULT, Factions.PIRATES);
triggerSetStandardAggroPirateFlags();
triggerFleetAllowLongPursuit();
triggerPickLocationAtInSystemJumpPoint(planet.getStarSystem());
triggerSpawnFleetAtPickedLocation(“$gada_pirate”, null);
triggerOrderFleetPatrol(planet);
endTrigger();
```
There’s a large set of methods that make common tasks easy. Probably the pinnacle of this is being able to, with a single method call, under certain conditions spawn a fleet that will talk to the player, make certain demands (or perhaps a lucrative offer), and fail the mission if they accede. Being able to do these kinds of things easily, on a whim, is such a difference from having to write even fairly simple code that has to do this imperatively.
下一个版本提供了许多让创建常规游戏任务变得简单的方法。简化的最高境界可能就是通过一次方法调用,就能在特定的条件下,生成一只舰队与玩家交流,提出某些要求或是有利可图的提议,如果玩家同意,则任务失败。能够轻松地、随手完成做这些事情,与必须写出哪怕相当简单的命令式代码来做这些事情,是如此的不同。
It’s also possible to add new methods in the same style, and – since this is in code, not a text file – it’s also easy to resort to imperative-style programming for one-off mission specific tasks that it doesn’t make sense to try to make into general-purpose units.
也可以遵照同样的思路,来添加更多的方法。而且因为这是代码,不是文本文档,所以对于一次性的特殊任务,仍可以灵活地采用原先的命令式进行实现。对这种特殊需求进行抽象或通用化是没有意义的。
## Missions, Bar Events, and Contact Tags 任务,酒吧事件和联络人标签
If you’re a modder, this is probably on your mind – how easy is it to add new missions for contacts? The answer is “very”. There are a couple of new spreadsheets – for bar events, and contact missions – and adding a new mission there is all it takes to have it show up. It’s also possible to define entirely new tags for contacts, to expand the current set of “trade/military/underworld”.
如果你是mod作者,你也许想问,为一位联络人添加新任务难度如何?答案是“非常简单”。将会有几个新的csv,对应酒吧事件和联络人的任务,只需要把新的任务添加到那里即可。你也可以自己定义全新的联络人分类,以扩充目前的“商贸、军事和黑道”分类组。
> 激光烤肉,干了兄弟们!