Beginner's Scripting Guide (翻译完毕)
本帖最后由 freefen 于 2011-7-5 22:06 编辑lanson老大在他的罗马核心教程索引中把这篇“Beginner's Scripting Guide ”教程视为核心教程之一,既然是这样,它就应该具有翻译的价值吧。所以我就试着翻译一下,翻译地不准确不正确勿怪!
教程原地址如下:http://www.twcenter.net/forums/showthread.php?p=5147473#post5147473
原文如下:
May 09, 2009, 05:52 AM / Beginner's Scripting Guide
Hello all . With this post , i hope to get a lot more players/modders interested in scripting . Most people get lost in scipting immediatly , and then say that it's way to hard . I used to do this too , until i kept trying again , and now i really like scripting ..
It's all about the way you approach it . Some tutorials for scripting just ask to copy-paste a certain script in the appropriate folders and teach you almost nothing . Others start off good , but become to complicated at the end .
I'll try to come off as gentle as possible with this tutorial . We'll take it step-by-step , and i'll try to make it easy to understand ..
But at first , we need a background script . I won't give any further comments about this , since HouseOfHam already has an excellent post about it . Check it out here :
http://www.twcenter.net/forums/showthread.php?t=169689
Step 1 : How to make a script
Step 2 : Basic conditions and commands
Step 3 : Making more complicated scripts
Step 4 : Some other stuff
Step 5 : What if's and counters ?
Some info about counters
Step 1 : How to make a script
Once you have a background script , open the file in your data/scripts/show_me folder called background_script (so the folder in wich you made your background script) . If you took it from HoH's tutorial (HoH = HouseOfHam) , then it should look like this :
Code:
script
; Anything following a semicolon is a comment.
; Remove the adviser portrait from screen.
select_ui_element advisor_dismiss_button
simulate_mouse_click lclick_up
; Wait for it to go away.
while I_AdvisorVisible
end_while
suspend_unscripted_advice true
; Open the adviser message bubble automatically whenever advance_advice_thread is called.
; I recommend using this method instead of the select_ui_element + simulate_mouse_click approach.
; Do NOT mix both methods, though, or the advisor will show and then immediately close before
; you get a chance to read the text.
declare_show_me
; Very useful for debugging - uncomment to use
;console_command toggle_perfect_spy
;;;
;;; --- Forced shutdown ---
;;;
;;; Press 'Esc' on the campaign map, then click on the '?' button in the
;;; menu scroll to terminate the script.
;;;
;;; When would this be useful? -- When you are already in a game and
;;; exit back to the main menu to restart the campaign, or reload a saved
;;; game, RTW does not automatically terminate the script, so you have
;;; to do it yourself. If you leave the old script running, you'll have all
;;; sorts of weird problems with the script in the new game.
;;;
monitor_event ScrollAdviceRequested ScrollAdviceRequested end_game_scroll
terminate_script
end_monitor
; Handle saved game reloads
monitor_event GameReloaded TrueCondition
terminate_script
end_monitor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Start script
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
while I_TurnNumber < 99999
suspend_unscripted_advice true
end_while
end_script
Alright , let's get started with scripting .. If your mod uses some small scripts , you can put all scripts in the 'background_script' folder . If you try to get a heavy scripted mod however (like LOTR-TW) , it might be better to make multiple files , to sort everyting out . For instance , Bardo (the LOTR-TW scripter) made for his 'palantir script' 3 new entries in 3 different folders . the palantir script is based on the 'Palantir' in the LOTR-trilogy , and shows the world for 10 seconds .. I'll show you where he pu all entries , so you could understand :
In the background_script.txt file :
Code:
;**********************************************
;PALANTIR trigger:
;**********************************************
monitor_event CharacterTurnStart CharacterIsLocal
and not FactionType romans_julii
and Attribute Electability = 10
and RandomPercent < 10
advance_advice_thread UsePalantir_Thread
end_monitor
monitor_event FactionTurnEnd I_FactionNearTile slave 0 248,211
console_command move_character SpecialGuy, 249,212
end_monitor
Take a look at the underlined line . It targets to another line , that's inside the 'export_descr_advice'.txt file . Now , if we take a look at that file , and search for 'Palantir' , we see the following :
Inside the export_descr_advice.txt' file :
Code:
;------------------------------------------ LOTR-TW
AdviceThread UsePalantir_Thread
GameArea Campaign
Item UsePalantir_Text_01
Uninhibitable
Verbosity0
Threshold1
MaxRepeats0
RepeatInterval1
Attitude Excited
Presentation Default
Title UsePalantir_Text_01_Title
Script scripts\show_me\palantir.txt
Text UsePalantir_Text_01_Text1
And here again , take a look at the underlined line . it targets us to the data/scripts/show_me/palantir file . And if we take a look there ... :
In the palantir.txt file :
Code:
script
zoom_strat_camera 1
inhibit_camera_input true
console_command toggle_fow
console_command toggle_perfect_spy
wait 20
console_command toggle_perfect_spy
console_command toggle_fow
inhibit_camera_input false
console_command move_character SpecialGuy, 248,211
select_ui_element advisor_dismiss_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_script
... we see the actual script , or what happens when all previous "triggers" are activated
So , this was just to show you , that when you make lots of scripts , you better organize it . here , we saw a 'loop' , that goes from the background_script.txt file , to the 'export_descr_advice.txt' file , and ends in the 'palantir.txt' file .
Alright , now , lets take a look at how most (or the basic) scripts are made :
Code:
script
monitor_event 'conditions'
'commands given to the game'
end_monitor
end_script
Some experienced modders may say that that's not totally true , but as i mentioned , we'll start of as easy and gentle as possible .. now , you can put this in your backround script , but it must be between the 'loop' :
Code:
while I_TurnNumber < 99999
suspend_unscripted_advice true
end_while
end_script
and the previous stuff :
Code:
script
; Anything following a semicolon is a comment.
; Remove the adviser portrait from screen.
select_ui_element advisor_dismiss_button
simulate_mouse_click lclick_up
; Wait for it to go away.
while I_AdvisorVisible
end_while
suspend_unscripted_advice true
; Open the adviser message bubble automatically whenever advance_advice_thread is called.
; I recommend using this method instead of the select_ui_element + simulate_mouse_click approach.
; Do NOT mix both methods, though, or the advisor will show and then immediately close before
; you get a chance to read the text.
declare_show_me
; Very useful for debugging - uncomment to use
;console_command toggle_perfect_spy
;;;
;;; --- Forced shutdown ---
;;;
;;; Press 'Esc' on the campaign map, then click on the '?' button in the
;;; menu scroll to terminate the script.
;;;
;;; When would this be useful? -- When you are already in a game and
;;; exit back to the main menu to restart the campaign, or reload a saved
;;; game, RTW does not automatically terminate the script, so you have
;;; to do it yourself. If you leave the old script running, you'll have all
;;; sorts of weird problems with the script in the new game.
;;;
monitor_event ScrollAdviceRequested ScrollAdviceRequested end_game_scroll
terminate_script
end_monitor
; Handle saved game reloads
monitor_event GameReloaded TrueCondition
terminate_script
end_monitor
So in the end , it looks like this :
Code:
script
; Anything following a semicolon is a comment.
; Remove the adviser portrait from screen.
select_ui_element advisor_dismiss_button
simulate_mouse_click lclick_up
; Wait for it to go away.
while I_AdvisorVisible
end_while
suspend_unscripted_advice true
; Open the adviser message bubble automatically whenever advance_advice_thread is called.
; I recommend using this method instead of the select_ui_element + simulate_mouse_click approach.
; Do NOT mix both methods, though, or the advisor will show and then immediately close before
; you get a chance to read the text.
declare_show_me
; Very useful for debugging - uncomment to use
;console_command toggle_perfect_spy
;;;
;;; --- Forced shutdown ---
;;;
;;; Press 'Esc' on the campaign map, then click on the '?' button in the
;;; menu scroll to terminate the script.
;;;
;;; When would this be useful? -- When you are already in a game and
;;; exit back to the main menu to restart the campaign, or reload a saved
;;; game, RTW does not automatically terminate the script, so you have
;;; to do it yourself. If you leave the old script running, you'll have all
;;; sorts of weird problems with the script in the new game.
;;;
monitor_event ScrollAdviceRequested ScrollAdviceRequested end_game_scroll
terminate_script
end_monitor
; Handle saved game reloads
monitor_event GameReloaded TrueCondition
terminate_script
end_monitor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Your script
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;script Note that the 'script' lines , are already listed in this file . if you take a look at the top of the file , you'll see the word 'script there , meaning that it's already listed in this script . Scripts must have only 1 'script' , and 'end_script' "word" .
monitor_event 'conditions'
'commands given to the game'
end_monitor
;end_script Same as above
while I_TurnNumber < 99999
suspend_unscripted_advice true
end_while
end_script
Alright , now we've put up the base , we'll start with some basic commands and stuff
Step 2 : Basic conditions and commands
Alright , we'll start of with the probably most basic condition : The 'turn start' condition . This condition will be activated whenever it's your turn again . So when you press 'end turn' , it shows all other factions , and then it's your turn again . The "correct description" for this condition is :
Code:
FactionTurnStart FactionIsLocal
Unfortunately , we can't type what we want , so for instance :
Code:
monitor_event If i'm at the start of my turn
end_monitor
Now , if we put this in our little 'basic script' , we'll get the following :
Code:
monitor_event FactionTurnStart FactionIsLocal
'commands given to the game'
end_monitor
Alas , we need the correct description , so double check spelling , so that you don't make silly typing errors like this:
'FactionTurnTsart FactionIsLocal'
Now , the script will activate as soon as it's your turn . only 1 problem : We don't have any commands listed .
So for now , we'll use a basic command : Giving money to a faction ..
Code:
console_command add_money 'faction' 'amount'
Now , this won't work , as we need to specify the faction that gets the money , and the amount of cash it gets .. So we get this :
Code:
console_command add_money greek_cities 1000
Thus , this will add 1000 money to the greeks .. but when ? That is why we use conditions . Previously , you set up a basic condition , that activates at each start of your turn .. So , if we mix both conditions and commands , we get this :
Code:
monitor_event FactionTurnStart FactionIsLocal
console_command add_money greek_cities 1000
end_monitor
This will add 1000 denarii to the greeks , no matetr wich faction you're playin as .
Congratz , you put up a basic script ! You can test it out now if you want .
If you don't know what the 'console_command' is , i'll explain it . Most "cheaters" will already now it ! So cheaters actually have an advantage in scripting ..
The 'console panel' , is a "program" that you can activate during your campaign , by pressing '~' (without quotes) , '²' , or something else . When you opened it , you can type some 'commands' in it , like :
add_money greek_cities 1000
So , then the greek_cities get 1000 denarii .. Already saw it ? In our script , we "opened" the console panel whenever it's your turn , and gave a command to it , just like above . (add_money greek_cities 1000)
Step 3 : Making more complicated scripts
Part 1 :
Alright , you made a script , but with the previous commands and conditions , you won't be able to get some nice results . That's why we'll dig a little deeper .
First of all , I'll show you a new condition . Also a pretty basic one , and it also involves 'Factions' . This is how you should put it in your script :
Code:
I_FactionType greek_cities
As you could probably see , this condition looks if you're the stated faction , in this case , if you're playing as the greeks
Part 2 :
However , you can't just use it like our previous condition .. So you can't use it this way :
Code:
monitor_event I_LocalFaction greek_cities
However , there are 2 other ways to do it :
Either you use this :
Code:
monitor_event FactionTurnStart FactionIsLocal
and I_LocalFaction greek_cities
-your commands-
end_monitor
or this :
Code:
if I_LocalFaction greek_cities
-yourcommands-
end_if
i suggest you use the first options , as you probably don't know what an 'if' is , although you can probably guess it http://www.twcenter.net/forums/images/smilies/emoticons/tongue.gif So , if we use our new script :
Code:
monitor_event FactionTurnStart FactionIsLocal
and I_LocalFaction greek_cities
console_command add_money greek_cities 1000
end_monitor
Instead of our previous script , this won't occur each time it's your turn . You also need to be playing as the greeks . So , you need to be playing as the greeks , and it needs to be your turn , in order to activate the command .
Now , we also need a new command . We'll take a very popular , and probably the most used one : The spawn_army command ..
this is how it should be listed in your script :
Code:
spawn_army
faction 'faction' ; (so for instance , greek_cities)
character "character name" ,'type of character' (for instance , general , named_character , ...) ,age ,coörds
'list of units' , for instance :
unit greek general's guard cavalry early, 'amount of soldiers' 'exp' 'armour' 'weapon_lvl'
end
Now , this won't work ofcourse .. We need to get some working names , coörds , factions , etc .. So , if we do everyting correctly , it should look like this :
Code:
spawn_army
faction greek_cities ; So this will spawn an army for the greek faction
character Polydoros, general, age 25, x 123, y 65
unit greek general's guard cavalry early, 30 exp 5 armour 2 weapon_lvl 3
end
This will spawn a general for the greeks called Polydoros , who'll be of age 25 , and he'll be spawned on the listed coördinates . As for the units , there'll be a greek early general , with 30 units , 5 experience bonus , 2 armour bonus , and 3 wep_lvl bonus .
But i won't go any deeper here , as there are already lots of tutorials about this command :
HouseOfHam's tutorial :
Tutorial
Now , if we use this command in a script , combined with our new conditions , it should look like this :
Code:
monitor_event FactionTurnStart FactionsIslocal
and I_LocalFaction greek_cities
Code:
spawn_army
faction greek_cities ; So this will spawn an army for the greek faction
character Polydoros, general, age 25, x 123, y 65
unit greek general's guard cavalry early, 30 exp 5 armour 2 weapon_lvl 3
end
end_monitor
Alright , we now have a more complicated script than our previous one .
There are much more conditions and commands , and they are listed in the docudemons .. Download them here :
http://www.totalwar.org/Downloads/Rt...ad/BI_docs.zip
Just unzip it wherever you want . there should be 4 text files in them .. Just check the appropriate folder to find conitions or commands , or whatever you like .
Step 4 : Some other stuff
There are some other basic thingies you can use in scripts .. For instance , the 'not' word .. this can be used in conditions , to trigger when something isn't activated , but for instance :
Code:
monitor_event FactionTurnStart FactionIsLocal
and not I_LocalFaction romans_julii
So , if you're playing as the Julii , this script will not trigger ! If you're playing as another faction , however , it should trigger perfectly http://www.twcenter.net/forums/images/smilies/emoticons/wink.gif This can be used for some scripts (e.g.scripts who add units to weaker factions faction , so they die less quickly) .. For instance :
Code:
monitor_event FactionTurnStart FactionIsLocal
and not I_LocalFaction romans_julii
and not I_LocalFaction romans_brutii
and not I_LocalFaction romans_scipii
and not I_LocalFaction romans_senate
and not I_LocalFaction egypt
and RandomPercent < 10 ; This declares a random percent , so that the script only activated 1/10 of ;the time
spawn_army 'blah blah'
character 'blah blah'
units 'blah blah'
end
end_monitor
This script will neither activate for all roman factions , nor for the egyptians , as these are the strongest factions in vanilla ..
Step 5 : What if's and counters ?
In one of my previous examples , i showed you something new .. The usage of 'if' , instead of 'monitor_event' .. Some conditions require an 'if' instead of 'monitor event' , like this one :
Code:
if I_SettlementOwner Sparta = greek_cities- yourcommands-end_if
with this example , i showed you how to use the 'if' , and i showed you a new condition .. This condition can be used if you want a certain faction to own a settlement , in order to activate the script .. This is a very usefull condition , and is one of my most-used ones (although i'm not so long into scripting http://www.twcenter.net/forums/images/smilies/emoticons/tongue.gif)
This condition can also be used in combination with 'counters' .. What are counters , you say ? Take a look here
this combination can give you some nice results :
Code:
if I_SettlementOwner Sparta = greek_citiesset_counter SettlementOwner_Sparta 1end_ifIf I_CompareCounter SettlementOwner_Sparta = 1console_command add_money romans_julii -1000end_if
1 Note about this script is that i used a negative digit to add money .. So what will it do ? CTD ? nope , it'll just decrease the amount of denarii the romans_julii get , by 1000
-More will be added later -
Some info about counters :
Counters are quite handy in scripting .. they'll keep count of something , for instance the amount of settlements you own .. Counters can - combined with some basic conditions and commands - come over quite professional and great , and they aren't hard to use .. There are multiple conditions needed in order to succesfully get a counter .. these are :
Code:
set_counter 'target' 1
set_counter .. You'll need this whenever you want to start a counter .. It's pretty obvious that this "sets" or "initiates" a counter , and in this case , the counter in-game will be one .. Here's a sample use of a set_counter , in combination with previously learned stuff :
Code:
scriptif I_SettlementOwner Rome = romans_juliiset_counter SettlementOwner_Rome 1end_script
Now , the counter will be set if you are in control of Rome as the Julii .. Note that there's an underscore between the '..Owner' and the 'Rome' , otherwise , the game will actually take 'Rome' as a digit ! Anything followed by a space , is read as a number by the game ..
Now , another counter condition :
Code:
inc_counter SettlementOwner_Rome 1
this will increase our previous counter with 1 . Since it was already 1 , it'll now be two (1+1 = 2 http://www.twcenter.net/forums/images/smilies/emoticons/tongue.gif)
A sample use :
Code:
scriptif I_SettlementOwner Rome = romans_juliiset_counter SettlementOwner_Rome 1end_ifif I_SettlementOwner Arretium = romans_juliiinc_counter SettlementOwner_Rome 1end_ifend_script
Ok , now that we used that one , let's go to another important counter thing : The Compare Counter . this condition will actually check the current counter , and gives the game a series of commands , whenever the counter is okay .. You don't get it ? Check out how to use it :
Code:
scriptif I_SettlementOwner Rome = romans_julii set_counter SettlementOwner_Rome 1end_ifif I_SettlementOwner Arretium = romans_juliiinc_counter SettlementOwner_Rome 1end_ifif I_CompareCounter SettlementOwner_Rome = 2 console_command add_money romans_julii 1250end_ifend_script
So , when you have both settlements , the counter will be "2" . And the 'CompareCounter' looked if the counter was set on 2 .. Wich is the case , so the command will be used in-game .. the 'CompareCounter can also be used in combination with the monitor_event , and other conditions :
Code:
script if I_SettlementOwner Rome = romans_juliiset_counter SettlementOwner_Rome 1end_ifif I_SettlementOwner Arretium = romans_julii inc_counter SettlementOwner_Rome 1end_ifmonitor_event FactionTurnStart FactionIsLocal and not I_LocalFaction romans_senate and I_CompareCounter SettlementOwner_Rome = 2 console_command add_money romans_julii 1250end_monitor end_script
No need to explain any further , i think ..
Important note about counters : Counterscan get messed up when you reload a game (so when you save , and reload it) I will try to post a solution as soon as possible ..
Garisson scripts ?
How to make a "garisson script ? if we take a look at the docudemons , we don't see a
Code:
If I_SettlementOwnerSettlementUnderSiege 'faction' 'settlement'
; or other things that could trigger a garisson script ? Well , we can , although there can be some in-accuracies . The condition we'll use for this is :
Code:
I_CharacterTypeNearTile romans_julii named_character, 10 48,30
This condition will be activated , as soon as a named character of the romans_julii faction is at 10 tiles from the listed coords (48,30) .. Explanation of the docudemon :
Quote:
Is a particular character type of a faction near a particular tile?
So how could we get from this , to a settlement garisson script ? Well , we can change some values .. first of all , set up a base .. This is how it should look like :
(To get settlement coörds , get HoH's excellent settlement locator) For now , we'll use a garisson script for the Brits (and the Region of Belgica = Samarobriva in-game) Coörds are : x 61 , y 118
Spoiler Alert, click show to read:
Code:
scriptIf I_CharacterTypeNearTile germans named_character, 1 61,118 console_command kill_character "Aneirin" ; to avoid cloning CTDspawn_army faction britons character Aneirin, general, age 25, x 61, y 118 unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3 unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 endend_ifwhile I_TurnNumber < 50000 suspend_unscripted_advice trueend_whileend_script
Explanation ? This script will activate and thus spawn a (big and strong) army , under command of a young (=age 25) general called Aneirin , whenever a german named_character is at 1 tile of the settlement .. If they siege , they are automatically at 1 tile of the city http://www.twcenter.net/forums/images/smilies/emoticons/wink.gif
Some flaws : - The german army must contain a named_character (a family member) , in order to spawn the army ..
- This script will only spawn if a german army/character is near .. So how could we improve this ?
Simply copy-paste the script for a few times , and change the faction to the most common one .. I don't think brits will encounter Seleucids in Belgica .. So , the most frequent ones are (except for germans) imo : gauls , romans (julii) , spain , dacia , scythia ..
- It's also possible that characters siege a city in a "diagonal" (for instance , top right-corner of a city) postion . it is possible that this requires that you list 2 tiles from your settlement coörds (= 1 tile to the right , and 1 tile up). Must need some testing though ..
So , this would be a loong script .. the end-result :
Spoiler Alert, click show to read:
Code:
scriptIf I_CharacterTypeNearTile germans named_character, 1 61,118console_command kill_character "Aneirin" ; to avoid cloning CTDspawn_army faction britons character Aneirin, general, age 25, x 61, y 118 unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3 unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 endend_ifIf I_CharacterTypeNearTile gauls named_character, 1 61,118 console_command kill_character "Aneirin" ; to avoid cloning CTD spawn_army faction britons character Aneirin, general, age 25, x 61, y 118 unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3 unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 end end_ifIf I_CharacterTypeNearTile romans_julii named_character, 1 61,118console_command kill_character "Aneirin" ; to avoid cloning CTDspawn_army faction britons character Aneirin, general, age 25, x 61, y 118 unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3 unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 endend_ifIf I_CharacterTypeNearTile spain named_character, 1 61,118 console_command kill_character "Aneirin" ; to avoid cloning CTD spawn_army faction britons character Aneirin, general, age 25, x 61, y 118 unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3 unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 end end_if If I_CharacterTypeNearTile dacia named_character, 1 61,118 console_command kill_character "Aneirin" ; to avoid cloning CTD spawn_army faction britons character Aneirin, general, age 25, x 61, y 118 unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3 unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 end end_ifIf I_CharacterTypeNearTile scythia named_character, 1 61,118 console_command kill_character "Aneirin" ; to avoid cloning CTD spawn_army faction britons character Aneirin, general, age 25, x 61, y 118 unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3 unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 end end_if while I_TurnNumber < 50000 suspend_unscripted_advice trueend_whileend_script
You can experiment with this .. If you want to have the garisson script to appear just once , you must add some extra steps :
Spoiler Alert, click show to read:
Code:
If I_CharacterTypeNearTile scythia named_character, 1 61,118set_counter garisson_script 1end_ifIf I_CharacterTypeNearTile germans named_character, 1 61,118set_counter garisson_script 1end_if ; and so on for all factionsmonitor_event FactionTurnStart FactionIsLocal and I_SettlementOwner Samarobriva = britons and i_CompareCounter garisson_script = 1 spawn_army faction britons character Aneirin, general, age 25, x 61, y 118 unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3 unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3 end terminate_monitor end_monitor
Saw the bold line at the end ? The 'terminate_monitor' ? This will 'terminate' a command , so after it activated , it won't activate again .. Can be usefull if you don't want to have to large armies , so that your economy goes down , or you simply get over-powered ..
EDIT : Important note : Do not reload too much , or otherwise the scripts could get messed up !
I suggest the garisson script for factions tha get eliminated quickly , like the Seleucids , Gauls , Armenia , ...
本帖最后由 freefen 于 2011-7-5 22:10 编辑
Hello all . With this post , i hope to get a lot more players/modders interested in scripting . Most people get lost in scipting immediatly , and then say that it's way to hard . I used to do this too , until i kept trying again , and now i really like scripting ..
大家好 ,随着这个帖子,我希望更多的玩家/修改者对脚本撰写感兴趣。许多人对脚本撰写感到很迷茫,然后说它的方法很难(注:这里scipting应该是作者笔误,应该为scripting)。我过去也是这样的,然后我就一直试着,现在我真正喜欢脚本撰写..
It's all about the way you approach it . Some tutorials for scripting just ask to copy-paste a certain script in the appropriate folders and teach you almost nothing . Others start off good , but become to complicated at the end .
这个贴子关于你接触脚本撰写的所有方法。一些关于脚本撰写的教程只是要求在合适的文件夹去复制-粘贴某一脚本,然而几乎没教你什么东西。
其它的教程刚开始很好,但最后变得很复杂。
I'll try to come off as gentle as possible with this tutorial . We'll take it step-by-step , and i'll try to make it easy to understand ..
我将尽可能缓和地达到预期效果随着这个教程。我们将一步一步学习它,并且我将尽可能让它容易被理解..
But at first , we need a background script . I won't give any further comments about this , since HouseOfHam already has an excellent post about it . Check it out here :
http://www.twcenter.net/forums/showthread.php?t=169689
Step 1 : How to make a script
Step 2 : Basic conditions and commands
Step 3 : Making more complicated scripts
Step 4 : Some other stuff
Step 5 : What if's and counters ?
首先,我们需要一个背景脚本。我将给这个脚本进一步评论,关于这个HouseOfHam已经有一个优秀的帖子。来看看吧:
第一步:怎样去制作一个脚本
第二步:基础条件和命令
第三步:制作更多复杂的脚本
第四步:一些其它东西
第五步: "if's"和计数器是什么?
本帖最后由 freefen 于 2011-7-5 22:13 编辑
Step 1 : How to make a script
Once you have a background script , open the file in your data/scripts/show_me folder called background_script (so the folder in wich you made your background script) . If you took it from HoH's tutorial (HoH = HouseOfHam) , then it should look like this :
第一步:怎样制作一个脚本
你一旦有一个背景脚本,在你的文件夹data/scripts/show_me中打开叫“ background_script”文件(在这个文件夹你可以制作你的背景脚本)。假如你从“HouseOfHam”的教程中提取它,它看起来是这样的:
Code:
script
; Anything following a semicolon is a comment.
; Remove the adviser portrait from screen.
select_ui_element advisor_dismiss_button
simulate_mouse_click lclick_up
; Wait for it to go away.
while I_AdvisorVisible
end_while
suspend_unscripted_advice true
; Open the adviser message bubble automatically whenever advance_advice_thread is called.
; I recommend using this method instead of the select_ui_element + simulate_mouse_click approach.
; Do NOT mix both methods, though, or the advisor will show and then immediately close before
; you get a chance to read the text.
declare_show_me
; Very useful for debugging - uncomment to use
;console_command toggle_perfect_spy
;;;
;;; --- Forced shutdown ---
;;;
;;; Press 'Esc' on the campaign map, then click on the '?' button in the
;;; menu scroll to terminate the script.
;;;
;;; When would this be useful? -- When you are already in a game and
;;; exit back to the main menu to restart the campaign, or reload a saved
;;; game, RTW does not automatically terminate the script, so you have
;;; to do it yourself. If you leave the old script running, you'll have all
;;; sorts of weird problems with the script in the new game.
;;;
monitor_event ScrollAdviceRequested ScrollAdviceRequested end_game_scroll
terminate_script
end_monitor
; Handle saved game reloads
monitor_event GameReloaded TrueCondition
terminate_script
end_monitor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Start script
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
while I_TurnNumber < 99999
suspend_unscripted_advice true
end_while
end_script
原码如上:......
Alright , let's get started with scripting .. If your mod uses some small scripts , you can put all scripts in the 'background_script' folder . If you try to get a heavy scripted mod however (like LOTR-TW) , it might be better to make multiple files , to sort everytingout . For instance , Bardo (the LOTR-TW scripter) made for his 'palantir script' 3 new entries in 3 different folders . the palantir script is based on the 'Palantir' in the LOTR-trilogy , and shows the world for 10 seconds .. I'll show you where he pu all entries , so you could understand :
好的,让我们开始脚本撰写...假如你的MOD用一些小脚本,你可以把所有脚本放在文件里'background_script'。假如你想做一个大脚本MOD(像LOTR-TW剧本), 它可能需要制作多个文件去处理每件事。例如,Bardo(LOTR-TW剧本制作者)为他的“palantir script”在三个不同文件夹设置3个新条目。这个“palantir”脚本是基于“LOTR-三部曲”的“palantir”,并向世界展示10秒(这个在语境里不知什么意思,只能直译)..我将让你看到他所提出所有条目(这里原文“pu”我觉得应该改为“put”),以便你能理解:
In the background_script.txt file :
Code:
;**********************************************
;PALANTIR trigger:
;**********************************************
monitor_event CharacterTurnStart CharacterIsLocal
and not FactionType romans_julii
and Attribute Electability = 10
and RandomPercent < 10
advance_advice_thread UsePalantir_Thread(这一行带下划线)
end_monitor
monitor_event FactionTurnEnd I_FactionNearTile slave 0 248,211
console_command move_character SpecialGuy, 249,212
end_monitor
在“background_script.txt”文件里:
原码如上:
Take a look at the underlined line . It targets to another line , that's inside the 'export_descr_advice'.txt file . Now , if we take a look at that file , and search for 'Palantir' , we see the following :
看一下带下划线一行(上面这句:advance_advice_thread UsePalantir_Thread)。它为其它行服务,这个在“export_descr_advice.txt”文件里。现在,假如我们看一下那个文件,并搜索“Palantir”
,我们看见如下内容:
Inside the export_descr_advice.txt' file :
Code:
;------------------------------------------ LOTR-TW
AdviceThread UsePalantir_Thread
GameArea Campaign
Item UsePalantir_Text_01
Uninhibitable
Verbosity0
Threshold1
MaxRepeats0
RepeatInterval1
Attitude Excited
Presentation Default
Title UsePalantir_Text_01_Title
Script scripts\show_me\palantir.txt(这行带下划线)
Text UsePalantir_Text_01_Text1
在“export_descr_advice.txt”文件里:
原码如上:
And here again , take a look at the underlined line . it targets us to the data/scripts/show_me/palantir file . And if we take a look there ... :
这里再次看一下带下划线那行(上面这句:Script scripts\show_me\palantir.txt)。它让我们目标对向文件夹“data/scripts/show_me/”
里的“palantir.txt”文件。假如我们看一下那里...:
In the palantir.txt file :
Code:
script
zoom_strat_camera 1
inhibit_camera_input true
console_command toggle_fow
console_command toggle_perfect_spy
wait 20
console_command toggle_perfect_spy
console_command toggle_fow
inhibit_camera_input false
console_command move_character SpecialGuy, 248,211
select_ui_element advisor_dismiss_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_script
在“palantir.txt”文件:
原码如上:
... we see the actual script , or what happens when all previous "triggers" are activated
我们看到实际的脚本,或者所有先前有活性的触发器发生。
So , this was just to show you , that when you make lots of scripts , you better organize it . here , we saw a 'loop' , that goes from the background_script.txt file , to the 'export_descr_advice.txt' file , and ends in the 'palantir.txt' file .
这样,这就是展示给你的东西,当你制作许多脚本时,你更好地组织它。这里,我们看见一个“循环”,它从文件“background_script.txt”开始,然后是文件“export_descr_advice.txt”,最后是文件“palantir.txt”。
Alright , now , lets take a look at how most (or the basic) scripts are made :
Code:
script
monitor_event 'conditions'
'commands given to the game'
end_monitor
end_script
好了,现在让我们看一下高层次或基础的脚本是如何制作的:
原码如上:
Some experienced modders may say that that's not totally true , but as i mentioned , we'll start of as easy and gentle as possible .. now , you can put this in your backround script , but it must be between the 'loop' :
Code:
while I_TurnNumber < 99999
suspend_unscripted_advice true
end_while
end_script
一些有经验的修改者可能说那不是都正确的,但作为我提到的,我们从容易开始并且尽可能缓和的..现在,你可以把这些放入你的背景脚本,但是它必须在“循环”中间:
原码如上:
and the previous stuff :
Code:
script
; Anything following a semicolon is a comment.
; Remove the adviser portrait from screen.
select_ui_element advisor_dismiss_button
simulate_mouse_click lclick_up
; Wait for it to go away.
while I_AdvisorVisible
end_while
suspend_unscripted_advice true
; Open the adviser message bubble automatically whenever advance_advice_thread is called.
; I recommend using this method instead of the select_ui_element + simulate_mouse_click approach.
; Do NOT mix both methods, though, or the advisor will show and then immediately close before
; you get a chance to read the text.
declare_show_me
; Very useful for debugging - uncomment to use
;console_command toggle_perfect_spy
;;;
;;; --- Forced shutdown ---
;;;
;;; Press 'Esc' on the campaign map, then click on the '?' button in the
;;; menu scroll to terminate the script.
;;;
;;; When would this be useful? -- When you are already in a game and
;;; exit back to the main menu to restart the campaign, or reload a saved
;;; game, RTW does not automatically terminate the script, so you have
;;; to do it yourself. If you leave the old script running, you'll have all
;;; sorts of weird problems with the script in the new game.
;;;
monitor_event ScrollAdviceRequested ScrollAdviceRequested end_game_scroll
terminate_script
end_monitor
; Handle saved game reloads
monitor_event GameReloaded TrueCondition
terminate_script
end_monitor
先前的特质:
原码如上:
(注这段原码就是第一步最开始引用原码那段)
So in the end , it looks like this :
Spoiler Alert, click show to read:
Code:
script
; Anything following a semicolon is a comment.
; Remove the adviser portrait from screen.
select_ui_element advisor_dismiss_button
simulate_mouse_click lclick_up
; Wait for it to go away.
while I_AdvisorVisible
end_while
suspend_unscripted_advice true
; Open the adviser message bubble automatically whenever advance_advice_thread is called.
; I recommend using this method instead of the select_ui_element + simulate_mouse_click approach.
; Do NOT mix both methods, though, or the advisor will show and then immediately close before
; you get a chance to read the text.
declare_show_me
; Very useful for debugging - uncomment to use
;console_command toggle_perfect_spy
;;;
;;; --- Forced shutdown ---
;;;
;;; Press 'Esc' on the campaign map, then click on the '?' button in the
;;; menu scroll to terminate the script.
;;;
;;; When would this be useful? -- When you are already in a game and
;;; exit back to the main menu to restart the campaign, or reload a saved
;;; game, RTW does not automatically terminate the script, so you have
;;; to do it yourself. If you leave the old script running, you'll have all
;;; sorts of weird problems with the script in the new game.
;;;
monitor_event ScrollAdviceRequested ScrollAdviceRequested end_game_scroll
terminate_script
end_monitor
; Handle saved game reloads
monitor_event GameReloaded TrueCondition
terminate_script
end_monitor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Your script
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;script Note that the 'script' lines , are already listed in this file . if you take a look at the top of the file , you'll see the word 'script there , meaning that it's already listed in this script . Scripts must have only 1 'script' , and 'end_script' "word" . 注:这里开头script原文划掉,这里复制不过来效果
monitor_event 'conditions'
'commands given to the game'
end_monitor
;end_script Same as above 注:这里end_script原文划掉,这里复制不过来效果
while I_TurnNumber < 99999
suspend_unscripted_advice true
end_while
end_script
原码如上:
Alright , now we've put up the base , we'll start with some basic commands and stuff
好了,现在我们有这些基础,我将开始一些基础命令和东西。
本帖最后由 freefen 于 2011-7-5 22:15 编辑
Step 2 : Basic conditions and commands
第二步:基础条件和命令
Alright , we'll start of with the probably most basic condition : The 'turn start' condition . This condition will be activated whenever it's your turn again . So when you press 'end turn' , it shows all other factions , and then it's your turn again . The "correct description" for this condition is :
Code:
FactionTurnStart FactionIsLocal
好了,通过尽可能多基础条件我们开始了(这里原文“start of”应该是作者笔误,实为“start off”):“翻转开始”条件。这个条件将被激活每当再次轮到你的时候。如此当你按下“回合结束”,它显示所有其他派系,然后再次轮到你。对这个条件正确描述是:
原码:FactionTurnStart FactionIsLocal
Unfortunately , we can't type what we want , so for instance :
Code:
monitor_event If i'm at the start of my turn
end_monitor
很遗憾,我们不能打出我们想要的,所以例如:
原码如上:
Now , if we put this in our little 'basic script' , we'll get the following :
Code:
monitor_event FactionTurnStart FactionIsLocal
'commands given to the game'
end_monitor
现在,假如我们把这个放入我们小的“基础脚本”,我们将得到如下:
原码如上:
Alas , we need the correct description , so double check spelling , so that you don't make silly typing errors like this:
'FactionTurnTsart FactionIsLocal'
Now , the script will activate as soon as it's your turn . only 1 problem : We don't have any commands listed .
So for now , we'll use a basic command : Giving money to a faction ..
Code:
console_command add_money 'faction' 'amount'
哎呀,我们需要正确的描述,如此复核拼写,以致你不犯可笑的像这样输入错误:“FactionTurnTsart FactionIsLocal”
现在,脚本将被激活一旦轮到你的时候。只有一个难题:我们没有什么列出的命令。
所以现在,我将用一个基础命令:给一个派系增加金钱。
原码:console_command add_money 'faction' 'amount'
Now , this won't work , as we need to specify the faction that gets the money , and the amount of cash it gets .. So we get this :
Code:
console_command add_money greek_cities 1000
现在,这将不工作,当我需要给指定派系增加金钱,然后它得到一笔金钱..如此我们得到这个:
原码:console_command add_money greek_cities 1000
Thus , this will add 1000 money to the greeks .. but when ? That is why we use conditions . Previously , you set up a basic condition , that activates at each start of your turn .. So , if we mix both conditions and commands , we get this :
Code:
monitor_event FactionTurnStart FactionIsLocal
console_command add_money greek_cities 1000
end_monitor
这样,这将给“greeks”势力增加1000金钱..但在什么时候?那个就是我们用到条件的原因。事先,你建立一个基础条件,当每一次轮到你的时候激活..
This will add 1000 denarii to the greeks , no matetr wich faction you're playin as .
Congratz , you put up a basic script ! You can test it out now if you want .
If you don't know what the 'console_command' is , i'll explain it . Most "cheaters" will already now it ! So cheaters actually have an advantage in scripting ..
The 'console panel' , is a "program" that you can activate during your campaign , by pressing '~' (without quotes) , '2' , or something else . When you opened it , you can type some 'commands' in it , like :
add_money greek_cities 1000
So , then the greek_cities get 1000 denarii .. Already saw it ? In our script , we "opened" the console panel whenever it's your turn , and gave a command to it , just like above . (add_money greek_cities 1000)
这将给势力“greeks”增加1000金钱,无论你玩哪一中派系(注:原文“matetr”应该是作者笔误,应该是“matter”)。
你建立一个基础脚本!现在假如你想的话,可以测试它。假如你不知道控制台命令是什么,我解释一下。
控制面板是一个在你的战略地图里尼可以激活的程序,由按“~”(没有引号),“2”,或者其它东西。当你打开它时候,你可以打入一些命令,像这样:add_money greek_cities 1000
因此,给“greek”城市增加1000金币..已经看见它了吗?在我们脚本,当轮到你的时候我们打开控制台面板,并给它一个命令,像上面那样。(add_money greek_cities 1000)
本帖最后由 freefen 于 2011-7-5 22:17 编辑
Step 3 : Making more complicated scripts
第三步:制作更多复杂脚本
Part 1 :
Alright , you made a script , but with the previous commands and conditions , you won't be able to get some nice results . That's why we'll dig a little deeper .
First of all , I'll show you a new condition . Also a pretty basic one , and it also involves 'Factions' . This is how you should put it in your script :
Code:
I_FactionType greek_cities
第一部分:
好了,随着先前的命令和条件你制作脚本,你将不能得到一些好的结果。那就是我们为什么要挖深一点原因(注:这里我觉得应该意译为“研究深入一点”)。
首先,我将给你看一个新的条件。它也是漂亮的基础的一个,而且它也涉及到派系。这是你怎样把它放入你的脚本:
原码:I_FactionType greek_cities
As you could probably see , this condition looks if you're the stated faction , in this case , if you're playing as the greeks
你大概可以明白,这个条件?????????假如你选择国家派系(这句我怀疑作者又漏了什么单词,我实在想不出来,太纠结了),在这种情况下,假如你玩势力“greeks”。
Part 2 :
However , you can't just use it like our previous condition .. So you can't use it this way :
Code:
monitor_event I_LocalFaction greek_cities
第二部分:
不管怎么,你不能像我们先前的条件那样使用它..因此你不能通过这种方式用它:
原码:monitor_event I_LocalFaction greek_cities
However , there are 2 other ways to do it :
Either you use this :
Code:
monitor_event FactionTurnStart FactionIsLocal
and I_LocalFaction greek_cities
-your commands-
end_monitor
不管怎样,有2种其它方法去做它:
二者之一你用这个:
原码如上:......
or this :
Code:
if I_LocalFaction greek_cities
-yourcommands-
end_if
或者这个:
原码如上:......
i suggest you use the first options , as you probably don't know what an 'if' is , although you can probably guess itSo , if we use our new script :
Code:
monitor_event FactionTurnStart FactionIsLocal
and I_LocalFaction greek_cities
console_command add_money greek_cities 1000
end_monitor
我建议你用第一个选项,你可能不知道“if”是什么,尽管你可以大概猜测它是这样的,假如我们用我们新的脚本:
原码如上:
Instead of our previous script , this won't occur each time it's your turn . You also need to be playing as the greeks . So , you need to be playing as the greeks , and it needs to be your turn , in order to activate the command .
而不是我们先前的脚本,每一次轮到你的时候这将不会发生当。你也需要像玩势力“ greeks”那样玩。因此,你需要像玩势力“ greeks”那样玩,并且为了激活命令必需轮到你的时候,。
Now , we also need a new command . We'll take a very popular , and probably the most used one : The spawn_army command ..
this is how it should be listed in your script :
Code:
spawn_army
faction 'faction' ; (so for instance , greek_cities)
character "character name" ,'type of character' (for instance , general , named_character , ...) ,age ,co?rds
'list of units' , for instance :
unit greek general's guard cavalry early, 'amount of soldiers' 'exp' 'armour' 'weapon_lvl'
end
现在,我们也需要一个新的命令。我们需要一个非常普遍并且可能大量用到一个命令“spawn_army”..
这是在你的脚本中被列举出来:
原码如上:
Now , this won't work ofcourse .. We need to get some working names , co?rds, factions , etc .. So , if we do everyting correctly , it should look like this :
Code:
spawn_army
faction greek_cities ; So this will spawn an army for the greek faction
character Polydoros, general, age 25, x 123, y 65
unit greek general's guard cavalry early, 30 exp 5 armour 2 weapon_lvl 3
end
现在,当然这将不会工作(注:这里ofcourse 应为分开的“of course”)..我们需要得到一些工作名字,“坐标 ”,“派系”,等等..,假如我们做每一件事都是对的,它看起来是这样的:
原码如上:
This will spawn a general for the greeks called Polydoros , who'll be of age 25 , and he'll be spawned on the listed co?rdinates. As for the units , there'll be a greek early general , with 30 units , 5 experience bonus , 2 armour bonus , and 3 wep_lvl bonus .
这将为势力“greeks”产生一个叫“Polydoros”的将军,他年龄是25岁,并且他将产生在列举的坐标。至于单位,将有一个“greek”将军带经验等级为5,盔甲等级为2,武器等级为3的30个单位。
But i won't go any deeper here , as there are already lots of tutorials about this command :
HouseOfHam's tutorial :
Tutorial
Now , if we use this command in a script , combined with our new conditions , it should look like this :
Code:
monitor_event FactionTurnStart FactionsIslocal
and I_LocalFaction greek_cities
Code:
spawn_army
faction greek_cities ; So this will spawn an army for the greek faction
character Polydoros, general, age 25, x 123, y 65
unit greek general's guard cavalry early, 30 exp 5 armour 2 weapon_lvl 3
end
end_monitor
但在这里我将不深入挖掘,因为关于这个命令已经有很多的教程:HouseOfHam's tutorial
http://www.twcenter.net/forums/showthread.php?t=221683(这是我特意从原文复制过来链接,方便有需要的筒子)
现在,假如我们把这个命令用在脚本,结合我们新的条件,它看起来是是这样的:
原码如上两段:
Alright , we now have a more complicated script than our previous one .
好了,现在我们有一个比先前那个较为复杂的脚本。
There are much more conditions and commands , and they are listed in the docudemons .. Download them here :
http://www.totalwar.org/Downloads/Rt...ad/BI_docs.zip
Just unzip it wherever you want . there should be 4 text files in them .. Just check the appropriate folder to find conitions or commands , or whatever you like .
有更多条件和命令,并且他们在“docudemons”被列举..,这里可以下载他们:
http://www.totalwar.org/Downloads/Rt...ad/BI_docs.zip
你就把解压它在你想要的地方。他们包含四个文件。检查合适文件夹就会找到条件或者命令或者你想要的任何东西。
本帖最后由 freefen 于 2011-7-5 22:18 编辑
Step 4 : Some other stuff
第四步:一些其它东西
There are some other basic thingies you can use in scripts .. For instance , the 'not' word .. this can be used in conditions , to trigger when something isn't activated , but for instance :
Code:
monitor_event FactionTurnStart FactionIsLocal
and not I_LocalFaction romans_julii
有一些其它基础东西你可以用在脚本..例如,单词“not",这可以用在条件里,去触发某些事情当它没有被激活时候,例如:
原码如上:
So , if you're playing as the Julii , this script will not trigger ! If you're playing as another faction , however , it should trigger perfectly . This can be used for some scripts (e.g.scripts who add units to weaker factions faction , so they die less quickly) .. For instance :
Code:
monitor_event FactionTurnStart FactionIsLocal
and not I_LocalFaction romans_julii
and not I_LocalFaction romans_brutii
and not I_LocalFaction romans_scipii
and not I_LocalFaction romans_senate
and not I_LocalFaction egypt
and RandomPercent < 10 ; This declares a random percent , so that the script only activated 1/10 of ;the time
spawn_army 'blah blah'
character 'blah blah'
units 'blah blah'
end
end_monitor
因此,假如你玩势力“Julii”,这个脚本将不会被触发!假如你玩其它派系,不管怎么样,它将会完美触发。这可以用在一些脚本(比方说脚本给弱势力增加单位,因而他们死得慢一些)..举个例子:(注:这里原文“factions faction”我觉得应该是原作者多写了一个faction)
原码如上:
This script will neither activate for all roman factions , nor for the egyptians , as these are the strongest factions in vanilla ..
这个脚本既不会被所有罗马派系被激活,也不会被势力埃及激活,就像在“vanilla”中的很强派系..
本帖最后由 freefen 于 2011-7-5 22:19 编辑
Step 5 : What if's and counters ?
“if”是什么和计数器
In one of my previous examples , i showed you something new .. The usage of 'if' , instead of 'monitor_event' .. Some conditions require an 'if' instead of 'monitor event' , like this one :
Code:
if I_SettlementOwner Sparta = greek_cities
- yourcommands-
end_if
在我的以前一个列子里,我让你们看了新的东西..“if”使用方法,而不是“monitor_event”..一些条件需要“if”而不是
“monitor_event”,像这一个:
原码如上:
with this example , i showed you how to use the 'if' , and i showed you a new condition .. This condition can be used if you want a certain faction to own a settlement , in order to activate the script .. This is a very usefull condition , and is one of my most-used ones (although i'm not so long into scripting )
随着这个例子,我让你看到如何使用“if”,并且我让你看一个新条件..假如你想让某一派系有自己势力点(注:这里我把“settlement”引申势力点的意思,就相当于你的势力占据地盘)这个条件会被用到,为了激活脚本..这是一个非常有用的条件,并且是我大量用到的其中一个(虽然我没有一直攥写脚本)
This condition can also be used in combination with 'counters' .. What are counters , you say ? Take a look here
this combination can give you some nice results :
Code:
if I_SettlementOwner Sparta = greek_cities
set_counter SettlementOwner_Sparta 1
end_if
If I_CompareCounter SettlementOwner_Sparta = 1
console_command add_money romans_julii -1000
end_if
这个条件也可以结合“counters”使用..你说什么是计数器?看这儿,这个组合能给你一些不错结果:
原码如上:
1 Note about this script is that i used a negative digit to add money .. So what will it do ? CTD ? nope , it'll just decrease the amount of denarii the romans_julii get , by 1000
More will be added later
注意这个脚本是用负的数字去加钱..那它有什么效果呢?“CTD(注:我不知道这里CTD是什么意思)”?不对,它将从势力“romans_julii”中减少1000数量的金钱。
更多以后再补充。
本帖最后由 freefen 于 2011-7-5 22:26 编辑
Some info about counters
关于计数器的一些信息
Counters are quite handy in scripting .. they'll keep count of something , for instance the amount of settlements you own .. Counters can - combined with some basic conditions and commands - come over quite professional and great , and they aren't hard to use .. There are multiple conditions needed in order to succesfully get a counter .. these are :
Code:
set_counter 'target' 1
计数器在脚本里是相当方便好用的..它们将用来某事物的计算,举个例子你自己一些势力点..计数器能结合一些基础条件和命令,会变得相当专业和重要,并且它们使用起来并不困难..有多种条件需为了成功得获得一个计数器..这些:
原码如上:
set_counter .. You'll need this whenever you want to start a counter .. It's pretty obvious that this "sets" or "initiates" a counter , and in this case , the counter in-game will be one .. Here's a sample use of a set_counter , in combination with previously learned stuff :
Code:
script
if I_SettlementOwner Rome = romans_julii
set_counter SettlementOwner_Rome 1
end_script
每当你想要开始一个计数器,你都需要这个“set_counter”..它是相对明显的那这个“sets”或“initiates”一个计数器,在这种情况下,在程序中就产生一个计数器..这里是一个关于“set_counter”简单运用,再结合先前学到的东西:
原码如上:
Now , the counter will be set if you are in control of Rome as the Julii .. Note that there's an underscore between the '..Owner' and the 'Rome' , otherwise , the game will actually take 'Rome' as a digit ! Anything followed by a space , is read as a number by the game ..
现在,假如你控制罗马中势力“Julii”,计数器就可以设置了..注意在“Owner”和“Rome”之间有个下划线,要不然,游戏将把“Rome”当成一个数字!任何有一个间隔跟随的事物,会被游戏读为一个数字..
Now , another counter condition :
Code:
inc_counter SettlementOwner_Rome 1
现在,另外一个计数器条件:
原码如上:
this will increase our previous counter with 1 . Since it was already 1 , it'll now be two (1+1 = 2 )
A sample use :
Code:
script
if I_SettlementOwner Rome = romans_julii
set_counter SettlementOwner_Rome 1
end_if
if I_SettlementOwner Arretium = romans_julii
inc_counter SettlementOwner_Rome 1
end_if
end_script
这将为我们先前的计数器加1。既然它已经是1,现在它将变为2(1+1=2)
一个样本用法:
原码如上:
Ok , now that we used that one , let's go to another important counter thing : The Compare Counter . this condition will actually check the current counter , and gives the game a series of commands , whenever the counter is okay .. You don't get it ? Check out how to use it :
Code:
script
if I_SettlementOwner Rome = romans_julii
set_counter SettlementOwner_Rome 1
end_if
if I_SettlementOwner Arretium = romans_julii
inc_counter SettlementOwner_Rome 1
end_if
if I_CompareCounter SettlementOwner_Rome = 2
console_command add_money romans_julii 1250
end_if
end_script
好的,现在我们使用了那一种了,让我们转到另外一种重要的计数器事情:比较计数器。这个条件将实际核对现在的计数器,当计数器被批准时候,并给游戏一系列的命令..你没有掌握它?检测如何使用它:
原码如上:
So , when you have both settlements , the counter will be "2" . And the 'CompareCounter' looked if the counter was set on 2 .. Wich is the case , so the command will be used in-game .. the 'CompareCounter can also be used in combination with the monitor_event , and other conditions :
Code:
script
if I_SettlementOwner Rome = romans_julii
set_counter SettlementOwner_Rome 1
end_if
if I_SettlementOwner Arretium = romans_julii
inc_counter SettlementOwner_Rome 1
end_if
monitor_event FactionTurnStart FactionIsLocal
and not I_LocalFaction romans_senate
and I_CompareCounter SettlementOwner_Rome = 2
console_command add_money romans_julii 1250
end_monitor
end_script
因此,当你有两个势力点时候(注:我这里引申翻译“势力点”跟城市或地方意思差不多),计数器变为2。假如计数器被设置为2,比较计数器会注意到..那种情况下(注:这里原文中“wich”是作者笔误应为“which”),在游戏里命令将被使用..比较计数器也可以结合“monitor_event”和其它条件使用:
原码如上:
No need to explain any further , i think ..
我想没有必要去进一步解释..
Important note about counters : Counterscan get messed up when you reload a game (so when you save , and reload it) I will try to post a solution as soon as possible ..
Garisson scripts ?
关于计数器的重要注意事项:当你载入一个游戏时计数器会变得混乱(当你保存和载入时候)(注:这里原文中“Counterscan”我觉得应为“Counterscan”),我将尽快给出一个解决方案 ..“Garisson”脚本?
How to make a "garisson script ? if we take a look at the docudemons , we don't see a
Code:
If I_SettlementOwnerSettlementUnderSiege 'faction' 'settlement'
怎样制作一个“Garisson”脚本?假如我们看一下“docudemons”文件(注这里“docudemons”我不知道是不是指这三个罗马的文件docudemon_events、docudemon_conditions、docudemon_commands),我们什么也看不到
原码如上:
; or other things that could trigger a garisson script ? Well , we can , although there can be some in-accuracies . The condition we'll use for this is :
Code:
I_CharacterTypeNearTile romans_julii named_character, 10 48,30
或者其它事情能触发一个“Garisson”脚本?好的,我们可以,尽管有些不精确。我们这样用这个条件:
原码如上:
This condition will be activated , as soon as a named character of the romans_julii faction is at 10 tiles from the listed coords (48,30) .. Explanation of the docudemon :
Quote:
Is a particular character type of a faction near a particular tile?
一旦一个“romans_julii ”派系的角色出现在坐标“48,30”附近10个范围,这个条件将被激活..关于“docudemon”的解释:
引述:
是特定的派系角色在特定的格附近?
So how could we get from this , to a settlement garisson script ? Well , we can change some values .. first of all , set up a base .. This is how it should look like :
我们怎么从一个解决的脚本得到这个?好了,我们可以改变一些属性..首先,建立一个基础..这就是它应该看起来这样了:
(To get settlement co?rds , get HoH's excellent settlement locator) For now , we'll use a garisson script for the Brits (and the Region of Belgica = Samarobriva in-game) Co?rds are : x 61 , y 118
(为了得到势力点坐标,为了得到“HoH”好的势力点位置)现在,我将为“Brits”用一个“garisson”脚本,坐标是x 16,y118
Code:
script
If I_CharacterTypeNearTile germans named_character, 1 61,118
console_command kill_character "Aneirin" ; to avoid cloning CTD
spawn_army
faction britons
character Aneirin, general, age 25, x 61, y 118
unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3
unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
end
end_if
while I_TurnNumber < 50000
suspend_unscripted_advice true
end_while
end_script
原码如上:
Explanation ? This script will activate and thus spawn a (big and strong) army , under command of a young (=age 25) general called Aneirin , whenever a german named_character is at 1 tile of the settlement .. If they siege , they are automatically at 1 tile of the city
解释?这个脚本将被激活并从而产生一个强大的军队,当一个德国角色在设置好点的1格范围,按照命令杀死一个叫“Aneirin”的将军。假如他们围城,他们自动在城市的一个格。
Some flaws : - The german army must contain a named_character (a family member) , in order to spawn the army ..
- This script will only spawn if a german army/character is near .. So how could we improve this ?
一些缺陷:德国军队必需包含有名角色(一个家庭成员),为了产生军队..
假如一个德国军队/角色在附近,这个脚本将会产生军队或角色..我们怎样能改进这个?
Simply copy-paste the script for a few times , and change the faction to the most common one .. I don't think brits will encounter Seleucids in Belgica .. So , the most frequent ones are (except for germans) imo : gauls , romans (julii) , spain , dacia , scythia ..
简单地剪贴脚本几次,改变派系是最常用一种..我不想“brits”遇上“ Belgica”里“Seleucids”..因此,大多数常见(除了德国)是:“gauls , romans (julii) , spain , dacia , scythia”。(注这里“imo”我不知道什么意思)
- It's also possible that characters siege a city in a "diagonal" (for instance , top right-corner of a city) postion . it is possible that this requires that you list 2 tiles from your settlement co?rds (= 1 tile to the right , and 1 tile up). Must need some testing though ..
它也是有可能的,角色包围城市在一个对角线(例如,一个城市上部右角)位置。它是可能的这需要2个格从你设置好的坐标。虽然必需需要一些检验..
So , this would be a loong script .. the end-result :
Code:
script
If I_CharacterTypeNearTile germans named_character, 1 61,118
console_command kill_character "Aneirin" ; to avoid cloning CTD
spawn_army
faction britons
character Aneirin, general, age 25, x 61, y 118
unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3
unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
end
end_if
If I_CharacterTypeNearTile gauls named_character, 1 61,118
console_command kill_character "Aneirin" ; to avoid cloning CTD
spawn_army
faction britons
character Aneirin, general, age 25, x 61, y 118
unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3
unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
end
end_if
If I_CharacterTypeNearTile romans_julii named_character, 1 61,118
console_command kill_character "Aneirin" ; to avoid cloning CTD
spawn_army
faction britons
character Aneirin, general, age 25, x 61, y 118
unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3
unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
end
end_if
If I_CharacterTypeNearTile spain named_character, 1 61,118
console_command kill_character "Aneirin" ; to avoid cloning CTD
spawn_army
faction britons
character Aneirin, general, age 25, x 61, y 118
unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3
unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
end
end_if
If I_CharacterTypeNearTile dacia named_character, 1 61,118
console_command kill_character "Aneirin" ; to avoid cloning CTD
spawn_army
faction britons
character Aneirin, general, age 25, x 61, y 118
unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3
unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
end
end_if
If I_CharacterTypeNearTile scythia named_character, 1 61,118
console_command kill_character "Aneirin" ; to avoid cloning CTD
spawn_army
faction britons
character Aneirin, general, age 25, x 61, y 118
unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3
unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
end
end_if
while I_TurnNumber < 50000
suspend_unscripted_advice true
end_while
end_script
这是一个很长的脚本(注:这里的作者用“loong"我觉得是不是作者又笔误,所以我改为”long“),结果是:
原码如上:
You can experiment with this .. If you want to have the garisson script to appear just once , you must add some extra steps :
Code:
If I_CharacterTypeNearTile scythia named_character, 1 61,118
set_counter garisson_script 1
end_if
If I_CharacterTypeNearTile germans named_character, 1 61,118
set_counter garisson_script 1
end_if ; and so on for all factions
monitor_event FactionTurnStart FactionIsLocal
and I_SettlementOwner Samarobriva = britons
and i_CompareCounter garisson_script = 1
spawn_army
faction britons
character Aneirin, general, age 25, x 61, y 118
unit barb british general briton, 30 exp 5 armour 2 weapon_lvl 3
unit barb chariot heavy briton, 45 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband woad briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit barb warguard briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
unit warband sword briton, 60 exp 5 armour 2 weapon_lvl 3
end
terminate_monitor
end_monitor
你可以用这个实验,假如你想“ garisson”脚本只出现一次,你必须增加一些额外步骤:
原码如上:
Saw the bold line at the end ? The 'terminate_monitor' ? This will 'terminate' a command , so after it activated , it won't activate again .. Can be usefull if you don't want to have to large armies , so that your economy goes down , or you simply get over-powered ..
EDIT : Important note : Do not reload too much , or otherwise the scripts could get messed up !
I suggest the garisson script for factions tha get eliminated quickly , like the Seleucids , Gauls , Armenia , ...
看见最后加黑体那行了吗(就是这个“terminate_monitor”)?这将结束一个命令,它被激活之后,它将不会再次激活..假如你不想有大量的军队它会有用吗,这样你的经济会下滑,或者你仅仅变得强大..
编辑:重要信息:不要重新载入太多否则其它脚本会引起混乱!
我建议对于派系的“garisson”脚本要很快消除,像“the Seleucids , Gauls , Armenia”。
现在英文教程翻译区人也多起来了,速来支持 哪个呦,发这么好的帖子,顶你 好东西啊,抱走了,正是我需要的 {:5_131:}{:5_131:}{:5_131:}
页:
[1]