帝国全面战争吧 关注:62,201贴子:2,010,146

帝国全面战争修改:添加任务教程

只看楼主收藏回复


瑞典军队镇楼


IP属地:广东1楼2020-11-07 21:43回复
    添加任务这个操作帝国和拿破仑通用,他们的脚本语言,常量都是差不多哒。如果帝国和拿破仑有所不同的地方我会注明。
    Total War Center里有人教授如何添加任务,地址如下:https://www.twcenter.net/forums/showthread.php?432951-How-to-create-custom-missions。要是自己看得懂英语的话就去看看。


    IP属地:广东2楼2020-11-07 21:58
    回复


      IP属地:广东来自Android客户端3楼2020-11-07 22:37
      回复
        所谓任务就是以下两张图那些东西,图一为颁布任务的触发,图二是查看任务的窗口。以大英为例,英国在第二回合接到了关于殖民地的任务。只要占领佐治亚州,新法兰西地区和切洛基人地区就可以让十三州殖民地加入英国。


        我们打开Empire Total War\data\campaigns\main里面的scripting.lua文件
        你可以用lua编辑器和记事本等等东西打开这个文件。
        找到这一段

        这一段就是给予任务的触发
        elseif conditions.TurnNumber(context) == 2 then
        if conditions.FactionName("britain", context) and conditions.FactionIsHuman("britain", context) then
        scripting.game_interface:trigger_custom_mission("britain_protectorate", "britain", "protectorate_region_capture", 0, "georgia_usa+cherokee_territory+new_france", "", "mission_text_text_main_protectorate_thirteen_colonies_text", "mission_text_text_main_protectorate_thirteen_colonies_reward", 0, "thirteen_colonies", context)
        if elseif and end then字面意思
        conditions.TurnNumber(context) == 2 意思是当前回合是第二回合
        if conditions.FactionName("britain", context) and conditions.FactionIsHuman("britain", context)意思是判断英国的faction ID和英国是玩家指挥,如果两个条件成立,触发以下代码:
        scripting.game_interface:trigger_custom_mission("britain_protectorate", "britain", "protectorate_region_capture", 0, "georgia_usa+cherokee_territory+new_france", "", "mission_text_text_main_protectorate_thirteen_colonies_text", "mission_text_text_main_protectorate_thirteen_colonies_reward", 0, "thirteen_colonies", context)
        scripting.game_interface:trigger_custom_mission触发任务的代码
        (1)"britain_protectorate"是任务ID 每个任务的ID都是唯一的,不能两个任务共用一个ID。
        (2)"britain"是任务接收国,填下faction ID
        (3)"protectorate_region_capture"是任务类型
        任务类型如下:
        assassination刺杀
        blockade_port封锁港口
        build_building建造建筑
        capture_city占领城市
        capture_fort占领要塞
        duel决斗
        engage_character于某人物交战(?不明)
        engage_faction和某一个国家处于交战状态
        gain_military_access获得军事通行权
        forge_alliance缔结联盟
        make_trade_agreement缔结贸易协定
        recruit招募
        research研究科技
        spy_on_city派遣间谍于该城市
        protectorate_region_capture占领该城市于附属国(合并)(帝国独有)
        (4)0 回合限制 这个值表示在第几回合任务失败,如果写0就是没有回合限制
        (5)"georgia_usa+cherokee_territory+new_france"任务目标,可以是地区,科技,人物,势力(国家),要塞,兵种
        (6)"" 不用理
        (7)"mission_text_text_main_protectorate_thirteen_colonies_text"任务的名称text 请去patch_en.pack里的localisation.loc去编辑
        (8)"mission_text_text_main_protectorate_thirteen_colonies_reward"任务的奖励介绍text 请去localisation.loc去编辑
        (9)0 奖励的金钱
        (10) "thirteen_colonies" 奖励的目标(可用于protectorate_region_capture任务类型,合并整个国家)
        (11)context 不用理,照写
        (12)(用于拿站,帝国不用写直接隐蔽)只需要写false就可以
        (13)额外奖励(用于拿站,帝国不用写直接隐蔽)
        money:1000 奖励一千
        grant_experience_army:1 全国部队获得一经验值
        grant_unit:Inf_Line_Austrian_German_Fusiliers#settlement:eur_baden_wurttemberg:stuttgart
        在巴登符腾堡地区斯图加特城奖励一个奥地利德意志火枪兵


        IP属地:广东4楼2020-11-07 22:48
        回复
          由于这个脚本是用lua语言写的,一些没有接触脚本编程的孩纸可能需要另外的协助。
          Total War Center拿站脚本教程:
          https://www.twcenter.net/forums/showthread.php?418658-The-NTW-Script-o-Rama-(Updated-27-03-2011)
          也可以去lua官网查查基本语句和操作符的运用。


          IP属地:广东5楼2020-11-07 22:59
          回复
            虽然很好……但是上面两个网址一个都进不去


            IP属地:广东来自Android客户端6楼2020-11-07 23:12
            收起回复
              图不错


              IP属地:上海来自iPhone客户端7楼2020-11-07 23:14
              回复
                图是1700-1721年大北方战争的瑞典卡洛林步兵吧,为数不多保留长枪的部队


                IP属地:广东来自Android客户端8楼2020-11-08 14:08
                收起回复
                  @醋溜便当西瓜
                  是在Napoleon Total War\data\campaigns\eur_napoleon\scripting.lua里面的一段
                  --
                  -- Mission 7 - Monument to Triumph --
                  --
                  local function build_arc()
                  out.ting ("Monument to Triumph")
                  scripting.game_interface:trigger_custom_mission("eur_build_arc",
                  "france", "build_building", 0, "sPrest_france_arcdetriomphe",
                  "mission_text_text_eur_france_build_arc_de_triomphe_heading",
                  "mission_text_text_eur_france_build_arc_de_triomphe_text",
                  "", 0, "", context,
                  false, "grant_experience_army:1")
                  end
                  其中:
                  "france"任务接收国家:法国
                  "build_building"任务类型:建造建筑
                  "sPrest_france_arcdetriomphe"建筑目标凯旋门
                  "grant_experience_army:1"触发的奖励给所有部队一经验值


                  IP属地:广东10楼2020-11-10 13:45
                  收起回复
                    @醋溜便当西瓜
                    这个有点复杂,我希望你能听懂。
                    local function OnSettlementOccupied(context)
                    -- Has a victory regionbeen taken by the player? Have they managed to hold it?
                    if conditions.SettlementIsLocal(context) then
                    -- Vienna?
                    if conditions.SettlementName("settlement:eur_austria:vienna", context) then
                    out.ting("Vienna has been taken by the player.")
                    BOOL_vienna_taken = true
                    -- Berlin?
                    elseif conditions.SettlementName("settlement:eur_brandenburg:berlin", context) then
                    out.ting("Berlin has been taken by the player.")
                    BOOL_berlin_taken = true
                    if VAR_konigsberg_countdown == 0 then
                    out.ting("Konigsberg Countdown Initialised: 1")
                    VAR_konigsberg_countdown = VAR_konigsberg_countdown +1
                    end
                    -- Warsaw?
                    elseif conditions.SettlementName("settlement:eur_greater_poland:warsaw", context) then
                    out.ting("Warsaw has been taken by the player.")
                    BOOL_warsaw_taken = true
                    -- Konigsberg?
                    elseif conditions.SettlementName("settlement:eur_east_prussia:konigsberg", context) then
                    out.ting("Konigsberg has been taken by the player.")
                    BOOL_konigsberg_taken = true
                    -- Moscow?
                    elseif conditions.SettlementName("settlement:eur_moscow_guberniya:moscow", context) then
                    out.ting("Moscow has been taken by the player.")
                    BOOL_moscow_taken = true
                    -- Madrid?
                    elseif conditions.SettlementName("settlement:eur_spain:madrid", context) then
                    out.ting("Madrid has been taken by the player.")
                    BOOL_madrid_taken = true
                    end
                    -- Count up as France captures regions...
                    out.ting("Victory count: "..tostring(VAR_victory_count))
                    VAR_victory_count = VAR_victory_count + 1
                    end
                    end
                    这段代码的意思是每占领一个地区VAR_victory_count 这个值就会+1
                    接下来
                    local function OnFactionTurnStart(context)
                    if conditions.FactionIsLocal(context) then
                    -- If Vienna is taken, issue Take Berlin!
                    if BOOL_vienna_taken and not BOOL_berlin_issued and not BOOL_berlin_taken then
                    scripting.game_interface:force_declare_war("france", "prussia")
                    take_berlin()
                    BOOL_berlin_issued = true
                    -- If Berlin is taken, issue Take Warsaw!
                    elseif BOOL_berlin_taken and not BOOL_warsaw_issued and not BOOL_warsaw_taken then
                    take_warsaw()
                    BOOL_warsaw_issued = true
                    -- If Warsaw is taken, issue Take Konigsberg!
                    elseif BOOL_warsaw_taken and BOOL_berlin_taken and not BOOL_konigsberg_issued and not BOOL_konigsberg_taken then
                    take_konigsberg()
                    BOOL_konigsberg_issued = true
                    -- If Konigsberg is taken, issue Take Moscow!
                    elseif BOOL_konigsberg_taken and not BOOL_moscow_issued and not BOOL_moscow_taken then
                    take_moscow()
                    BOOL_moscow_issued = true
                    end
                    -- If Portugal is at war with France, then trigger Take Madrid!
                    if conditions.FactionIsEnemyCampaign("portugal", context) and not BOOL_madrid_issued and not BOOL_madrid_taken then
                    take_madrid()
                    BOOL_madrid_issued = true
                    -- If Prussia is at war with France and Berlin has not been issued, then issue it!
                    elseif conditions.FactionIsEnemyCampaign("prussia", context) and not BOOL_berlin_issued and not BOOL_berlin_taken then
                    take_berlin()
                    BOOL_berlin_issued = true
                    end
                    -- If 6 turns have passed since France took Berlin, then tell 'em to take Konigsberg!
                    if VAR_konigsberg_countdown == 6 then
                    out.ting("Trigerring 'Capture Konigsberg' if it hasn't been triggered already")
                    if not BOOL_konigsberg_issued and not BOOL_konigsberg_taken then
                    take_konigsberg()
                    BOOL_konigsberg_issued = true
                    end
                    end
                    -- If France has conquered a load of settlements, then tell 'em to build the Arc de Triomphe!
                    if VAR_victory_count == 6 and not BOOL_arc_built and not BOOL_arc_mission_issued then
                    build_arc()
                    BOOL_arc_mission_issued = true
                    end
                    -- If 48 turns have passed and France hasn't been told to take Moscow yet, then tell 'em now!
                    if conditions.TurnNumber(context) == 48 and not BOOL_moscow_issued and not BOOL_moscow_taken then
                    take_moscow()
                    BOOL_moscow_issued = true
                    end
                    -- If France has fought Russia a load, then tell 'em to take Moscow!
                    if VAR_france_fought_russia >= 3 then
                    out.ting("...thrice!")
                    if not BOOL_moscow_issued and not BOOL_moscow_taken then
                    take_moscow()
                    BOOL_moscow_issued = true
                    end
                    end
                    end
                    end
                    重点在这里
                    -- If France has conquered a load of settlements, then tell 'em to build the Arc de Triomphe!
                    if VAR_victory_count == 6 and not BOOL_arc_built and not BOOL_arc_mission_issued then
                    build_arc()
                    BOOL_arc_mission_issued = true
                    end
                    这段代码的意思是如果VAR_victory_count 等于 6(就是占领六个地区的时候),并且 BOOL_arc_built 和 BOOL_arc_mission_issued 的值为false,触发颁布建造凯旋门的任务。每回合判断一次。
                    build_arc()是颁布代码的函数。
                    local BOOL_arc_mission_issued = false-- Has the player been asked to build the Arc de Triomphe?
                    local BOOL_arc_built = false-- Has the Arc de Triomphe been built?
                    开头设置BOOL_arc_built和BOOL_arc_mission_issued 这个值为false
                    local function OnBuildingConstructionIssuedByPlayer(context)
                    if conditions.BuildingLevelName("sPrest_france_arcdetriomphe", context) then
                    out.ting("The Arc de Triomphe is being built")
                    BOOL_arc_built = true
                    end
                    end
                    这段代码的意思是你建造了凯旋门BOOL_arc_built 会变为true
                    BOOL_arc_mission_issued 会在颁布任务的时候触发为true,就是说只要任务没有颁布,这个值永远都是false


                    IP属地:广东11楼2020-11-17 11:45
                    收起回复
                      我自己在帝国写了一个克里米亚汗国的任务——恢复金帐汗国


                      完成任务后会获得两万块钱,至于恢复金帐汗国的效果还没写好


                      IP属地:广东12楼2020-11-17 12:06
                      回复
                        楼主太强了


                        IP属地:广东来自Android客户端13楼2020-11-22 13:11
                        收起回复
                          lua确实是全战修改的精华,然而我只会pfmesf


                          IP属地:湖北来自Android客户端14楼2020-11-25 00:52
                          收起回复
                            顶一个,相当详细,比我之前自己乱蒙着改好多了


                            来自Android客户端15楼2020-12-04 20:30
                            回复