[(英文)求翻译]新手脚本修改指南
http://forums.totalwar.org/vb/images/icons/icon0.gif A Beginner's Guide to Scripting & Scripting "How To"sThis guide was developed from the research of several members of the modding community. The research thread can be found hereA BEGINNER'S GUIDE TO SCRIPTING
Scripting allows modders a way of changing the game’s mechanics in ways that are impossible by other means.
What is a script?
A script is simply a text file that contains series of commands, similar to those that can be entered into the RomeShell console.
There are two types of script, referred to as Campaign scripts and Show Me scripts.
Campaign scripts are scripts that are launched at the very beginning of a new campaign – the most famous example (and indeed the only one provided in the original game) is the Prologue script which runs throughout most of the Sons of Mars prologue campaign and controls much of the automated activity within it.
Show Me scripts are scripts that are activated by the player through the ‘Show Me How’ button on the advisor interface. They were intended to be used to help demonstrate how to do certain actions within the game, but they will run any script and can be used for the modder’s own evil purposes *bwa*ha*ha*ha* http://forums.totalwar.org/vb/images/smilies/gc/gc-evilgrin.gif
Due to limitations on Campaign scripts (they only activate at the start of campaigns and you can’t save while one is running) they have only a few uses to the modder and so by far the most common kind of modded script is the Show Me script.
The most significant limitation on the Show Me script is that they can’t be run without the player’s consent (ie, if they don’t click on the show me how button then the script will never be run). But then why the hell are they playing a scripted mod if they’re not prepared to run the scripts in the first place?
In this guide, however, we’re going to walk-through a simple Show Me script (the Mo Money script) in order to familiarise ourselves with a script’s components and terminology.
Components of a Show Me script
A Show Me script is just a text file contained within the data\scripts\show_me\ folder, however to implement a script other components are required:
- a Trigger – contained within export_descr_advice.txt
- an Advice Thread – also contained within export_descr_advice.txt
- a Script – a text file itself contained within data\scripts\show_me\ folder
The Trigger tells the game what actions or events it should be looking for evaluating whether the advisor should appear.
The Advice Thread is a control which sets the number of times a trigger can be activated and other criteria before the advisor appears.
The Script is the series of commands which are run when the player clicks on the ‘show me how’ button in the advisor’s window.
For this example we’re going to work forwards through these steps, just to illustrate the process flow. When you actually come to making your own scripts it may be easier to work backwards or forwards through the steps.
Step One – The Trigger
The triggers are contained within the bottom section of export_descr_advice.txt. There you’ll find the 1,019 triggers that come with the basic game. Most of these are entirely useless to us and so we often have to define our own. In this case, however, we’ll be using a trigger that’s already there.
Code:
;------------------------------------------Trigger 2137_Help_Campaign_Keyboard_Shortcuts_Scroll_Trigger WhenToTest ScrollAdviceRequested Condition ScrollAdviceRequested help_scroll AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread0
This is just for your information at the moment; no adjustments need to be made as the trigger already exists. We’ll get into the technicalities of what the individual lines mean on another occasion. Suffice it to say that it should be obvious that this trigger is activated when the player clicks on the request advice button on the Help Scroll (otherwise known as the Keyboard Shortcuts scroll). This scroll can be accessed simply by pressing F1 during the game.
Trigger 2137 is very useful for testing out other components because it is slightly tucked away and therefore unlikely to be clicked during the course of play and it is completely within the player’s control. Press the request advice button once and the trigger will be activated once – so a modder can tell if the other components are working properly.
Step Two – The Advice Thread
The advice threads are contained within the top section of export_descr_advice.txt. They provide the connection between the trigger and the script that we want to run and determine whether the activation of a trigger actually results in the appearance of the advisor.
This is the normal version of the advice thread that is connected to Trigger 2137
Code:
;------------------------------------------AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread GameArea Campaign Item Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01 Uninhibitable Verbosity0 Threshold1 Attitude Normal Presentation Default Title Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Title Text Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1
Again, we’ll have a look at this line-by-line on another occasion. The significant things to note here are the Advice Thread line at the top – which is how this Advice Thread is linked to the Trigger and also the Title and Text lines at the bottom which are refer to blurb contained with export_descr_advice_enums.txt.
But at the moment this advice contains no reference to a script and therefore we are going to have to add one.
This is the new version:
Code:
;------------------------------------------AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread GameArea Campaign Item Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01 Uninhibitable Verbosity0 Threshold1 Attitude Normal Presentation Default Title Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Title Script scripts\show_me\mo_money.txt Text Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1
The only line we’ve added is the one that begins Script and this refers to our script text file that we are just about to place in the show_me folder.
Step Three – The Script
Create a new text file within data\scripts\show_me\ and copy and paste the following into it.
Code:
script console_command add_money 1000 campaign_wait 5 console_command add_money 1000end_script
Then save the file as mo_money.txt
In case it’s not obvious, when activated this script adds 1,000 denarii to the player’s treasury, will wait for 5 seconds and then add another 1,000. Big whoop, but it does make it easy to tell when the script has been activated and so again is useful for testing other components.
Congratulations, you have now installed your first script. Launch a campaign as normal, then press F1 to get to the keyboard shortcuts scroll, click on Request Advice and the advisor should appear. Click on the ‘show me how’ button and the script should run as described.
NB - the full parameter for the add_money command is:
Code:
add_money (opt:faction) (amount)
so you can also specify which faction gets the money if you wanted to make it a reward for a mission (similar to a senate mission) or to represent a general time of prosperity or donations from clients or allies in times of distress.
More Scripting How tos
How to: Toggle Perfect Spy
How to: Create units ~ including unique units
How to: Capture Settlements
How to: Create Buildings
How to: Change the Date
How to: Spawn an Army
Scripting links
Events, Conditions & Commands - this is a list of all the Identifiers, Conditions and Events from files included in the RTW demo
Research: Parameters for commands & console commands - an attempt to compile a definitive list of command parameters
Console commands & command line options - this is a list of many possible console commands some of which can be used through scripting
Scripting research thread
Hot Seat Mod - Beta Release
More than two turns a year - release
Client Kingdoms expansion mod
How to: Toggle Perfect SpyHow to: Toggle Perfect Spy
toggle_perfect_spy was one of those frustrating commands that we were told could be used through the RomeShell console but it turned out that we couldn't.
Fortunately it runs perfectly well from a script. Use the below in place of the mo_money script in Step Three above.
perfect_spy.txt
Code:
script console_command toggle_perfect_spyend_script
This command is of great use to modders who want to observe how the AI is reacting to their changes. toggle_perfect_spy allows you to look inside each banner and settlement and look at the troop composition and characters therein. It is best used with the toggle_fow RomeShell command which lifts the shroud from the campaign map.
How to: Create units ~ including unique unitsHow to: Create units ~ including unique units
The Client Kingdoms mod uses this in order to generate the troops the player is offered though there are many, many other uses.
Here's a sample script:
Code:
scriptconsole_command create_unit Campus_Scythii "barb infantry briton" 4end_script
In this case when the script is activated 4 units of the Briton Warband will be created in Campus Scythii.
It need not necessarily be a settlement, you can also use a character name. This example comes from the Prologue script.
Code:
scriptconsole_command create_unit "Gaius Julius" "roman velite" 2end_script
RomeShell provide these parameters:
Code:
create_unit (settlement/character_name) (unit_id) (opt: how many)(opt: exp/armour/weapon)
Here's the relevant points
- the troop description corresponds to their Type line in export_descr_unit
- character names must be in "quotes", settlements not
- double or triple-barrelled settlement names must have an _ instead of spaces
- importantly, the troops become owned by whoever controls the settlement or the character's faction, there is no need for a faction to be able to build the unit or even have ownership in export_descr_unit.
This gives us the potential to have unique units appear not just at the beginning of the game but also as it progresses as you can trigger this script based on date, the capture of a particular settlement, the construction of a building or anything else specified amongst the event identifiers.
And as no changes are needed to export_descr_unit it means that custom battles and bribery are completely unchanged.
How to: Capture SettlementsHow to: Capture Settlements
This script ousts whatever garrison is in the settlement and gives it to the local faction (ie, the player's faction)
Code:
scriptconsole_command capture_settlement Londiniumend_script
It can be used in conjunction with the create_unit command to provide an instant garrison loyal to the player, or equally with a negative add_money that would represent the player purchasing the settlement or sponsoring an uprising.
Because this command only gives the settlement to the player, it can't be used on the player's own settlements.
How to: Create BuildingsHow to: Create Buildings
Code:
scriptconsole_command create_building Londinium muster_fieldend_script
The building name is referenced from the entry export_descr_buildings.
There are no limitations on which buildings can be given to which faction - even buildings which aren't normally available (such as Royal Barracks or Amphitheatres for the Britons). You can even have duplicate buildings.
Combined with a date trigger, this allows you to build a unique building at a specific time in the game and therefore could be used for "Wonder"-like buildings.
原文链接:http://forums.totalwar.org/vb/showthread.php?46738-A-Beginner-s-Guide-to-Scripting-amp-Scripting-quot-How-To-quot-s
英文教程翻译区的帖子真少啊,不给力啊{:5_136:}!http://bbs.3mod.org/thread-15959-1-1.html这个不错{:5_155:}。可惜没有大大翻译一下!本人水平有限,抛砖引玉吧!争取将这两个长篇英文帖子翻译一下!希望大家不要骂俺!水平所限,出错难免!明天开始上课,时间很紧啊!下了周末(星期天吧)发布译文!时间所限啊!本人习惯意译,这样有利于理解!不喜勿喷!以后多转转英文教程和大家分享!
请各位大大指正。本人非常愿意接受批评!说实话,我接触三国全面战争时间很短,罗马就更不用说了。但我非常喜欢它!我对游戏的修改和其他什么的摸索都处于一片空白阶段,更不论MOD的制作。所以我只好多为论坛翻译一些英文文章来表达我对全战的喜爱。为论坛的建设尽自己一份力。本人是一名普通大学生,时间各方面有限。但有一颗热爱全战的心。希望三国全面战争越来越好! 加油干!!人民支持你!! 特来支持~~~~等待加分 一起来支持 过来支持下下 本帖最后由 tutain 于 2011-6-25 10:49 编辑
译文如下:
新手脚本修改指南
这个指导是源于某个模组团队的几位成员的研究成果。这里(是个连接
http://forums.totalwar.org/vb/showthread.php?40178-Scripting。有兴趣的可以去看看)可
以发现他们的思路。
新手脚本指南
脚本允许模组制作人员通过一些方式改变游戏力学(个人觉得游戏运行规则更合适),这是其他方
法无法实现的。
脚本是什么?
脚本仅仅是个文本文件,它包含很多命令语句,这些语句类似于可以输入全战游戏控制台的语句(
类似秘籍之类的)。
脚本有两种类型,作为参考的有战役脚本和show me脚本(就是参谋头像下面的绿圈圈)。
战役脚本是一种每开始一场新战役就启动——一个非常好的例子(确实由原始游戏单独提供)是
序幕脚本运行是在它内部通过战神之子开场战役和控制自动运动(对脚本修改实在不懂有哪位大大
知道请指教,谢谢)。战役脚本就是当一次新战役开始时被发动的那些脚本(the very 不是每一个的意思,用来修饰beginning,意思是“正是”,这里是强调作用。)-最著名的例子(并且事实上是原版游戏提供的唯一一个)是贯穿于大部分火星之子训练战役并且控制战役中的大部分自动活动的那个序言脚本。(申明一下这段是前辈liu1412翻译的,拿过来便于大家对比,当然比我翻译的要好啦!liu1412大大的翻译在16楼。)
“show me”脚本是玩家通过点击参谋界面的“show me how”按钮激活脚本。这个脚本旨在帮
助展示在游戏中如何进行某些行为(比如应该盖哪座建筑),但是它们可以运行任意脚本,这些脚
本应用于模组制作人员邪恶(这个不是我说的原文就是这么个意思)的目的。*bwa*ha*ha*ha*(
作者淫荡的笑声直接无视)
由于战役脚本的限制(战役脚本只能在战役开始时启动,而且当它运行的时候你将不能保存)它们
对于模组制作人员而言用途十分单一,所以到目前为止多数的一般模组制作人员运用的都
是“show me”脚本(不知道柱子大大们会不会战役脚本?呵呵)。
“show me”脚本最具特点的限制是没有经过玩家的同意它们是不会运行(如果玩家不点
击“show me how”按钮脚本将不会被激活)。但是他们首先不准备运行脚本,那他们到底为什
么玩这个脚本?
在这个指南中,我们将简单的尝试一下“show me”脚本(the Mo Money script(这个就不译
了))来熟悉一下脚本的组件和术语。
“show me”脚本组件
“show me”脚本仅仅是一个文本文件,位于Data\scripts\show_me目录下,无论怎样去实现一
个脚本一些组件是必须的:
一个触发器——包含在export_descr_advice.txt文件内
一个建议思路——也包含在export_descr_advice.txt文件内
一个脚本——一个文本文件包含在Data\scripts\show_me目录下
触发器判断游戏某个动作或事件发生时决定参谋是否应该出现。
建议思路是一种控制方式,在设定一段时间后触发器或者在参谋出现前的某些判断条件将被执行。
脚本是许多当玩家点击参谋界面的“show me how”按钮后运行的命令语句。
按照这个例子我们将通过一下步骤,仅仅阐明处理流程。当你的确开始制作你自己的脚本时你会觉
得这几个步骤是如此容易。
第一步——触发器
触发器包含在export_descr_advice.txt文件章节的底部。你将在基本游戏文件中发现1019个触发
器。它们中的大多数对于我们而言完全没有用处所以我们经常只好定义自己的。然而既然这样我们
将使用一个已经准备好的触发器。
code(代码部分不翻译,下同)
;------------------------------------------Trigger
2137_Help_Campaign_Keyboard_Shortcuts_Scroll_Trigger WhenToTest
ScrollAdviceRequested Condition ScrollAdviceRequested help_scroll AdviceThread
Help_Campaign_Keyboard_Shortcuts_Scroll_Thread0
目前这仅是你的信息,不需要做任何修改的触发器已经存在。我们将接触其他场合中的个人意义的
术语。当玩家在帮助目录点击需求建议按钮(其他已知道的如键盘快捷键目录)时触发器将工作。
这是显而易见的。在游戏中你只需按F1键即可看见这个目录。
触发器2137对测试组件是非常有用的,因为它有一点隐藏。因此玩家在游戏过程中未必会点击它
,它却完全属于玩家控制。一旦按下需求建议按钮触发器立即触发,所以一个模组制作人员能知道
某个组件是否在正确的工作。
第二步——建议思路
建议思路是包含在 export_descr_advice.txt文件的顶部。它们提供触发器和我们想运行的脚本之
间的联系。它决定触发器激活将导致参谋的出现。
常规的建议思路和触发器2137是联系的。
Code:
;------------------------------------------AdviceThread
Help_Campaign_Keyboard_Shortcuts_Scroll_Thread GameArea Campaign Item
Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01 Uninhibitable Verbosity0
Threshold1 Attitude Normal Presentation Default Title
Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Title Text
Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1
再次,我们在另一个场合需要逐行寻找。这里的特征信息是建议思路文件在顶部——建议思路是
如何连接触发器以及在下部分文章和文本线涉及宣传包含于export_descr_advice_enums.txt文件
。
但是此刻脚本的建议没有包含参考因此我们要增加一个。
这是新的版本:
Code:
;------------------------------------------AdviceThread
Help_Campaign_Keyboard_Shortcuts_Scroll_Thread GameArea Campaign Item
Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01 Uninhibitable Verbosity0
Threshold1 Attitude Normal Presentation Default Title
Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Title Script scripts\show_me
\mo_money.txt Text Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1
我们添加脚本开始的几行代码。这个将在show_me文件夹下引用我们的脚本文件。
第三步——脚本
在data\scripts\show_me目录下创建一个新的文本文件,复制下列代码然后粘贴到文本中。
Code:
script console_command add_money 1000 campaign_wait 5
console_command add_money 1000end_script
Then save the file as mo_money.txt
万一当激活脚本给玩家国库增加1000便士后没有明显变化,等待5秒后在增加1000便士。大叫一
声,但是当脚本运行时不会使它变容易所以测试其他组件是有用的。
祝贺!你已经植入你第一个脚本。正常开始一场战役,然后按F1键打开键盘快捷键目录,点击需求
建议。参谋出现,点击"show me how"按钮然后脚本会如期运行。
NB——the add_money command的所有参量:
Code:
add_money (opt:faction) (amount)
所以你也可以指定派系获得金币如果你想从使团(例如元老院)获得奖励或者为了体现繁荣时刻或
者门客的捐赠或者盟友危急时刻的救济。
如何制作其他脚本
How to: Toggle Perfect Spy
How to: Create units ~ including unique units
How to: Capture Settlements
How to: Create Buildings
How to: Change the Date
How to: Spawn an Army
(这些链接指向下面的文章)
更多脚本链接:
Events, Conditions & Commands(这次不粘链接了,想了解的自己点击原文链接,下同)——
这是所有标识符,条件和事件的目录,这个目录包含在罗马全面战争的样本中。
Research: Parameters for commands & console commands——一种编译限定命令参数的尝
试
Console commands & command line options——这是一些能通过脚本运行的控制台命令的列
表
Scripting research thread
Hot Seat Mod - Beta Release
More than two turns a year - release
Client Kingdoms expansion mod
如何触发完美间谍
触发完美间谍是个使人沮丧的的命令。我们得知它能通过全战控制台运行,但是我们却无法这么做
。
幸运的是我们通过脚本完美的运行它。在the mo_money脚本三个步骤前使用下面代码。
perfect_spy.txt
Code:
script console_command toggle_perfect_spyend_script
对于想观察电脑AI在改变后如何做出什么反应的模组制作人员而言,这个命令是十分有用的。
toggle_perfect_spy允许你你观看每一派系、城池的详细资料和每支军队的组成及武将属性。它和
战争迷雾开关命令配合使用能提升战役地图的隐藏性。
如何创建单位~~包括独一无二的单位
国王的门客(武将)模组通过这个脚本提供无数单位给玩家,玩家可以组成一个庞大的军团。
类似的脚本:
Code:
scriptconsole_command create_unit Campus_Scythii "barb infantry briton" 4end_script
当脚本运行时,4对英国蛮族兵将在出现卡布斯西席境内。
这不需要通过城池,你也可以使用一个角色名称。这是一个序幕脚本的例子:
Code:
scriptconsole_command create_unit "Gaius Julius" "roman velite" 2end_script
全战提供了这些参数:
Code:
create_unit (settlement/character_name) (unit_id) (opt: how many)(opt:
exp/armour/weapon)
有关的几点:
军队的描述要符合export_descr_unit文件中军队的属性
角色姓名必须用引号标注,城池不需要
两个或者三个城池名字必须用”_“代替空格
重要的是:你可以控制这个军队这与城池的控制和角色的派系有关。你创建军队与这个派系是否能
征召甚至和export_descr_unit文件中军队所属关系无关。
这样你可以触发这个脚本组建独一无二的单位不仅在游戏开始也可以在游戏过程中。特殊城池的战
利品,建筑的建造或任何指定事件都可以触发。
export_descr_unit文件没有改变意味着定制战斗和行贿是无法改变的。
如何占领城池
这个脚本可以城中守卫移除然后其他派系(玩家派系)进入城池。
Code:
scriptconsole_command capture_settlement Londiniumend_script
这个脚本可以和创建单位脚本同时使用,这可以给玩家立即提供一对忠诚的守卫占领城池。或者相
应的消极加钱去购买城池或者鼓动起义。
因为这个命令只能给玩家城池,他不能被运用于玩家的城池。
如何创造建筑
Code:
scriptconsole_command create_building Londinium muster_fieldend_script
建筑的名称在export_descr_building文件内。
这个没有限制哪个派系能创造哪个建筑——甚至建筑是不可得的(例如英国的皇家军营 决斗场)
。你也可以复制建筑。
结合一个日期的触发器,你可以在游戏中在一个特殊的时间建造一个独一无二的建筑。因此可以用
于奇迹式的建筑。
弄出来了,呵呵,忙里偷闲,匆匆忙忙翻译了一下,这几天时间很赶!下周三和周六要考试。{:5_120:}。没时间啊!课间和晚上选修课时偷偷的做了一点{:5_140:}。今天总算干完了。时间比较仓促,翻译的时候难免有错,希望大家指正!希望不要错误百出,毕竟没接触过脚本的修改。指明一下,译文中红色的字是我加上去的!个人习惯请各位谅解!这里加亮一下,希望大家看见。还有http://bbs.3mod.org/thread-15959-1-1.html这篇英语原文我尽量赶完!就怕没时间,希望各位原谅!不好意思!这个礼拜天弄不玩的话下个礼拜一定给大家弄出来!求原谅啊!!!!{:5_136:} 提个意见 译文最好是原文 一小段 译文一小段 ,不然看起来很费劲!!请调整下!!
这个你可以参考下这个
http://bbs.3mod.org/thread-15954-1-1.html freefen 发表于 2011-6-22 12:18 static/image/common/back.gif
提个意见 译文最好是原文 一小段 译文一小段 ,不然看起来很费劲!!请调整下!!
这个你可以参考下这个
...
下次尝试一下,谢谢 好 ,希望 继续努力!! 谢谢各位支持,热情高涨!{:5_114:}呵呵!没时间上网的话我会用手机继续支持论坛。请大家等一等,考完试我就翻译这篇(http://bbs.3mod.org/thread-15959-1-1.html)帖子。{:5_138:} 回复 Nicole 的帖子
只要你们不嫌弃就行,最怕别人喷!辛辛苦苦不说,还要挨骂!以前也在别的论坛呆过,后来被骂跑了。话说柱子论坛人虽然少了一点,但是气氛很好{:5_138:}。希望大家更加支持柱子。进论坛时间不常但也知道一点前辈们的纠纷,不管怎么样希望柱子排除万难继续把这个浩大的工程做下去!永远支持你们!感谢每一位为柱子三国做出努力的人! 翻译地非常好,不过战役脚本那点最好改下。战役脚本就是当一次新战役开始时被发动的那些脚本(the very 不是每一个的意思,用来修饰beginning,意思是“正是”,这里是强调作用。)-最著名的例子(并且事实上是原版游戏提供的唯一一个)是贯穿于大部分火星之子训练战役并且控制战役中的大部分自动活动的那个序言脚本。 回复 liu1412 的帖子
谢谢指点,下次继续努力,我看看能不能修改一下我的帖子。 好了,再次编辑了一下,把liu1412大大和我的放一起对照一下。如果liu1412大大有任何意见请继续指点!谢谢 回复 tutain 的帖子
翻译地很好,没什么意见哦。不用谢。
页:
[1]