中华MOD网

 找回密码
 立即加入

QQ登录

只需一步,快速开始

查看: 4445|回复: 6

[脚本] 罗马全面战争入门脚本教程

[复制链接]
发表于 2013-1-27 01:07:50 | 显示全部楼层 |阅读模式
转自百度贴吧 引用请注明

打开data\export_descr_advice.txt 这个文件。

要想要脚本工作,首先要添加一个线程。
要添加如下代码:

;------------------------------------------
AdviceThread BackgroundScriptThread
GameArea Campaign

Item BackgroundScriptItem1
Uninhibitable
Verbosity 0
Threshold 1
MaxRepeats 0
RepeatInterval 1
Attitude Normal
Presentation Default
Title BackgroundScriptTitle1
On_display scripts\show_me\background_script.txt
Text BackgroundScriptText1

就是这样一段代码。注意,那条横线也是要的。

同样是在export_descr_advice.txt文件,在尾端添加以下代码:

Trigger background_script_trigger_1
WhenToTest ButtonPressed

Condition ButtonPressed faction_button

AdviceThread BackgroundScriptThread 1

;------------------------------------------
Trigger background_script_trigger_2
WhenToTest ButtonPressed

Condition ButtonPressed construction_button

AdviceThread BackgroundScriptThread 1

;------------------------------------------
Trigger background_script_trigger_3
WhenToTest ButtonPressed

Condition ButtonPressed recruitment_button

AdviceThread BackgroundScriptThread 1

;------------------------------------------
Trigger background_script_trigger_4
WhenToTest SettlementSelected

AdviceThread BackgroundScriptThread 1

解释如下:
Trigger background_script_trigger_1
WhenToTest ButtonPressed

Condition ButtonPressed faction_button //按下派系的那个按钮 触发这个脚本

AdviceThread BackgroundScriptThread 1

;------------------------------------------
Trigger background_script_trigger_2
WhenToTest ButtonPressed

Condition ButtonPressed construction_button //这个是建设按钮

AdviceThread BackgroundScriptThread 1

;------------------------------------------
Trigger background_script_trigger_3
WhenToTest ButtonPressed

Condition ButtonPressed recruitment_button //这个是招募单位按钮

AdviceThread BackgroundScriptThread 1

;------------------------------------------
Trigger background_script_trigger_4
WhenToTest SettlementSelected //这个是选择城市

AdviceThread BackgroundScriptThread 1

准备工作完成,然后找data\scripts\show_me文件夹里面
新建一个记事本,名字叫background_script.txt

然后把以下代码复制进去:

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; This is where to put your own code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; For example, this will give you 1 gold at the beginning of every turn
monitor_event FactionTurnStart FactionIsLocal
console_command add_money 1
end_monitor

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; End of your code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Spin forever - Do not let the script terminate or any monitors you have set up will immediately get thrown away.
; In M2TW scripts, this loop is replaced by the wait_monitors command. Unfortunately, this command is not available in RTW.
while I_TurnNumber < 99999
suspend_unscripted_advice true
end_while

end_script

同样,对这段代码简易讲解下:



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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; This is where to put your own code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; For example, this will give you 1 gold at the beginning of every turn
;举个例子 这个代码 在每回合初 将给你的派系一块钱

monitor_event FactionTurnStart FactionIsLocal //这行开始
console_command add_money 1 //这个就是传说中的秘籍了。
end_monitor //到这边,这三行就是脚本的主要内容了。脚本代码都将放在这边。

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; End of your code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Spin forever - Do not let the script terminate or any monitors you have set up will immediately get thrown away.
; In M2TW scripts, this loop is replaced by the wait_monitors command. Unfortunately, this command is not available in RTW.

//在游戏中 第10万回合之前,脚本有效。
while I_TurnNumber < 99999
suspend_unscripted_advice true
end_while

end_script

简单的暴兵脚本


monitor_event FactionTurnStart FactionType carthage
and I_TurnNumber = 1

spawn_army
faction carthage

character Hannibal Barca, named character, age 16, , x 80, y 45
unit carthaginian general's cavalry, 10 exp 3 armour 3 weapon_lvl 3
unit carthaginian sacred band infantry, 10 exp 3 armour 3 weapon_lvl 3
unit carthaginian sacred band infantry, 10 exp 3 armour 3 weapon_lvl 3
unit carthaginian sacred band infantry, 10 exp 3 armour 3 weapon_lvl 3
unit carthaginian sacred band infantry, 10 exp 3 armour 3 weapon_lvl 3

end

terminate_monitor
end_monitor

做简单的说明:

monitor_event FactionTurnStart FactionType carthage //派系是迦太基,可以改别的
and I_TurnNumber = 1 //游戏开始之后的回合数

spawn_army
faction carthage //迦太基派系

character Hannibal Barca, named character, age 16, , x 80, y 45 //将军名字叫汉尼拔巴卡,16岁,会在80,45这个坐标出现。
unit carthaginian general's cavalry, 10 exp 3 armour 3 weapon_lvl 3 //迦太基后期将军卫队,人数,经验,金防,金攻。
unit carthaginian sacred band infantry, 10 exp 3 armour 3 weapon_lvl 3 //圣团骑兵。
unit carthaginian sacred band infantry, 10 exp 3 armour 3 weapon_lvl 3
unit carthaginian sacred band infantry, 10 exp 3 armour 3 weapon_lvl 3
unit carthaginian sacred band infantry, 10 exp 3 armour 3 weapon_lvl 3

end

terminate_monitor
end_monitor
强制外交关系:同盟、中立、战争。

monitor_event FactionTurnStart FactionIsLocal
and I_TurnNumber < 100

console_command diplomatic_stance romans_julii gauls allied
console_command diplomatic_stance romans_julii romans_brutii neutral
console_command diplomatic_stance britons numidia war
end_monitor


给钱脚本, 实际上只有n-1个回合加了钱 并且不使用红罗的时候才加钱。

monitor_event FactionTurnStart FactionIsLocal
and not I_LocalFaction romans_julii
and I_TurnNumber < 3

console_command add_money romans_julii, 40000
end_monitor








发帖求助前要善用【网站搜索】功能,那里可能会有你要找的答案

中华MOD网推荐搜索:https://kan.1mod.org/

中华MOD网新浪微博:https://weibo.com/1mod

中华MOD网推荐浏览器点击我下载

中华MOD网腾讯微信:All1mod 或首页左边

中华MOD网游戏帮助Q群:218311682

发表于 2013-1-27 01:43:41 | 显示全部楼层
这个表示看不懂 ,{:5_145:}

发帖求助前要善用【网站搜索】功能,那里可能会有你要找的答案

中华MOD网推荐搜索:https://kan.1mod.org/

中华MOD网新浪微博:https://weibo.com/1mod

中华MOD网推荐浏览器点击我下载

中华MOD网腾讯微信:All1mod 或首页左边

中华MOD网游戏帮助Q群:218311682

回复 鲜花 砖头

使用道具 举报

发表于 2013-1-27 05:07:52 | 显示全部楼层
进来看看

发帖求助前要善用【网站搜索】功能,那里可能会有你要找的答案

中华MOD网推荐搜索:https://kan.1mod.org/

中华MOD网新浪微博:https://weibo.com/1mod

中华MOD网推荐浏览器点击我下载

中华MOD网腾讯微信:All1mod 或首页左边

中华MOD网游戏帮助Q群:218311682

回复 鲜花 砖头

使用道具 举报

发表于 2013-1-27 08:35:15 | 显示全部楼层
打个酱油            

发帖求助前要善用【网站搜索】功能,那里可能会有你要找的答案

中华MOD网推荐搜索:https://kan.1mod.org/

中华MOD网新浪微博:https://weibo.com/1mod

中华MOD网推荐浏览器点击我下载

中华MOD网腾讯微信:All1mod 或首页左边

中华MOD网游戏帮助Q群:218311682

回复 鲜花 砖头

使用道具 举报

发表于 2013-1-27 08:37:17 | 显示全部楼层
路过看看{:5_117:}{:5_117:}

发帖求助前要善用【网站搜索】功能,那里可能会有你要找的答案

中华MOD网推荐搜索:https://kan.1mod.org/

中华MOD网新浪微博:https://weibo.com/1mod

中华MOD网推荐浏览器点击我下载

中华MOD网腾讯微信:All1mod 或首页左边

中华MOD网游戏帮助Q群:218311682

回复 鲜花 砖头

使用道具 举报

发表于 2013-1-27 09:02:12 | 显示全部楼层
这个表示看不懂 {:5_108:}

发帖求助前要善用【网站搜索】功能,那里可能会有你要找的答案

中华MOD网推荐搜索:https://kan.1mod.org/

中华MOD网新浪微博:https://weibo.com/1mod

中华MOD网推荐浏览器点击我下载

中华MOD网腾讯微信:All1mod 或首页左边

中华MOD网游戏帮助Q群:218311682

回复 鲜花 砖头

使用道具 举报

发表于 2013-1-27 09:03:14 | 显示全部楼层
剪水作花飞请陈宫喝酒,花了 1 枚 金币.

发帖求助前要善用【网站搜索】功能,那里可能会有你要找的答案

中华MOD网推荐搜索:https://kan.1mod.org/

中华MOD网新浪微博:https://weibo.com/1mod

中华MOD网推荐浏览器点击我下载

中华MOD网腾讯微信:All1mod 或首页左边

中华MOD网游戏帮助Q群:218311682

回复 鲜花 砖头

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

本版积分规则

关闭

站长推荐上一条 /2 下一条

QQ|Archiver|手机版|手机专用客户端|中华MOD官网

GMT+8, 2024-11-22 01:36

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表