- 好友
 - 0
  
- 在线时间
 - 128 小时
  
- 最后登录
 - 2025-10-28
  
 
 
 
 
见习骑士 
  
 
- UID
 - 2758789
  
- 第纳尔
 - 2183 
  
- 精华
 - 0
  
- 互助
 - 23 
  
- 荣誉
 - 1 
  
- 贡献
 - 0 
  
- 魅力
 - 201 
  
- 注册时间
 - 2016-7-18
  
 
  鲜花( 29)   鸡蛋( 0)  
 | 
 
 本帖最后由 路过的罗格 于 2024-4-8 17:30 编辑  
 
又是一个基础教程,这玩意这两天也是跑通了,过来写一下.主要是烤肉社那个网站上给出的xslt教程那叫一个烂,都给我看麻了. 
 
 
 
简介:你也不想公布一个mod的时候,还让别人去替换游戏原本的xml配置文件来实现修改吧?xslt是一个在不破坏原有的文件的前提下,修改游戏配置文件的方法,现在你可以把你修改过的配置放在自己的mod文件夹里,而不用让别人折腾游戏原本的配置. 
错误示例:https://bbs.mountblade.com.cn/thread-2095937-1-1.html 像这个垃圾教程里就是直接跑去修改游戏原本的文件,搞得改错了还没备份的话,就得去把文件删了然后重新验证完整性下载原文件. 
 
 
前置知识需求:xml入门,比如能完成上面错误示例中的修改.xslt的知识可以不需要,我这边试了一下,基础的修改需求可以直接丢给包括百度那个在内的GPT大语言模型来完成. 
需要的mod进度:已经有一个正常建好的SubModule.xml,差不多就是用插件新建工程的状态,编辑器版游戏新建mod的状态应该也一样 
(插件:https://github.com/BUTR/Bannerlord.Module.Template) 
工具,好像要梯子,谁有国内能用的来一个:在线 XSLT 测试工具 (xslttest.appspot.com) 
 
咱们通过一个具体的示例来说明这个xslt怎么使用,比如完成一下类似上面那个错误示例的修改,给双手剑的剑柄里添加一些长杆配件,让咱们能做一把剑枪,并且把它的攻击动作改一下,让它的突刺动作,改为长杆的动作,我是嫌弃双手剑突刺动作不好用的. 
首先,确定要修改的文件,是Native/ModuleData/weapon_descriptions.xml和item_usage_sets.xml和crafting_templates.xml 
weapon_descriptions/crafting_templates管的其中之一是一个类的武器可以使用哪些配件,我们把双手锤的杆配件添加到双手剑的握柄里 
item_usage_sets是管动作模组,修改攻击时使用哪个动作靠的是这里 
所以,在我们的mod文件夹里,对应的去新建一下ModuleData文件夹,并且新建几个xslt文件,用于处理对应的xml.方便起见,保持文件名为item_usage_sets.xslt和weapon_descriptions.xslt和crafting_templates.xslt 
然后还需要新建一个名为project.mbproj的文件,当然实际建议直接把Native/ModuleData目录下的project.mbproj复制过来,然后对他进行修改. 
 
 
接着先不去写xslt,先把让xslt生效的环境配置好,也就是修改SubModule.xml和project.mbproj. 
这两个东西都可以用文本编辑器打开,(注:这一步的资料是混乱且缺失的,只能说照着官方原文件抄)理论上编辑SubModule.xml或project.mbproj任选其一即可,但实际上因为没有资料,所以两个都得改 
在SubModule.xml里添加这一段,声明一下这两个文件的调用.如果已经有Xmls标签了,就只用在里面添加这两个XmlNode标签及内容即可.这里要保证path="xxxxx"中的字符串,是你ModuleData文件夹下对应模块的文件名.(也就是文件名你可以随便改,但是在这里你要对应上) 
 
 
然后是project.mbproj文件,因为是直接复制的,所以现在要给他删的只剩我们要修改的文件.老样子注意文件名的对应,这里是name="ModuleData/item_usage_sets.xml",需要填入文件在你mod文件夹中的路径.文件名可以自定义,但是后缀保持.xml 
 
 
 
到这里,已经完成了xslt的声明,现在这几个文件里的东西可以被游戏调用了. 
继续完成我们的双手剑枪的制作. 
先是给双手剑添加长杆,之前说了直接用GPT,所以我们只需要描述清除我们要进行的操作就好了,先是crafting_templates文件 
 
[url=https://yiyan.baidu.com/share/nTWsI9RHAc]使用xslt的方法,修改xml.具体来说:在CraftingTemplates标签下的CraftingTemplate标签里,当CraftingTemplate标签的属性id="TwoHandedSword"时,给CraftingTemplate标签下的UsablePieces标签里,添加[/url] 
 
因为xslt这个东西并不是骑砍独有的,所以准确率还行.刚才让他随便输入了一个配件,现在把那个随便输入的配件改成我们需要的长杆(这里使用的时标枪杆) 
 
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
 
 -     <xsl:output method="xml" indent="yes"/>  
 
 -     <xsl:strip-space elements="*"/>  
 
 -   
 
 -     <!-- 复制所有内容,除非另有说明 -->  
 
 -     <xsl:template match="@*|node()">  
 
 -         <xsl:copy>  
 
 -             <xsl:apply-templates select="@*|node()"/>  
 
 -         </xsl:copy>  
 
 -     </xsl:template>  
 
 -   
 
 -     <!-- 当遇到CraftingTemplate元素且其id属性为"TwoHandedSword"时 -->  
 
 -     <xsl:template match="CraftingTemplate[@id='TwoHandedSword']">  
 
 -         <!-- 复制当前CraftingTemplate元素 -->  
 
 -         <xsl:copy>  
 
 -             <!-- 复制所有属性 -->  
 
 -             <xsl:apply-templates select="@*"/>  
 
 -             <!-- 复制所有子元素 -->  
 
 -             <xsl:apply-templates select="node()"/>  
 
 -             <!-- 在UsablePieces元素内添加新的UsablePiece元素 -->  
 
 -             <xsl:if test="UsablePieces">  
 
 -                 <UsablePieces>  
 
 -                     <xsl:apply-templates select="UsablePieces/node()"/>  
 
 -                     <UsablePiece piece_id="spear_handle_2" />  
 
 -                     <UsablePiece piece_id="spear_handle_9" />  
 
 -                     <UsablePiece piece_id="spear_handle_10" />  
 
 -                     <UsablePiece piece_id="spear_handle_11" />  
 
 -                     <UsablePiece piece_id="spear_handle_12" />  
 
 -                 </UsablePieces>  
 
 -             </xsl:if>  
 
 -         </xsl:copy>  
 
 -     </xsl:template>  
 
 - </xsl:stylesheet>
 
  复制代码 [color=rgba(0, 0, 0, 0.85)] 
 
 
类似的,完成weapon_descriptions文件的部分 
继续完成类似的操作,这次需要在WeaponDescriptions标签下的WeaponDescription标签里,当WeaponDescription的属性id="TwoHandedSword"时,在WeaponDescription下的AvailablePieces标签里,添加 
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
 
 -     <xsl:output method="xml" indent="yes"/>  
 
 -     <xsl:strip-space elements="*"/>  
 
 -   
 
 -     <!-- 复制所有内容,除非另有说明 -->  
 
 -     <xsl:template match="@*|node()">  
 
 -         <xsl:copy>  
 
 -             <xsl:apply-templates select="@*|node()"/>  
 
 -         </xsl:copy>  
 
 -     </xsl:template>  
 
 -   
 
 -     <!-- 当遇到WeaponDescriptions/WeaponDescription元素且其id属性为"TwoHandedSword"时 -->  
 
 -     <xsl:template match="WeaponDescriptions/WeaponDescription[@id='TwoHandedSword']">  
 
 -         <xsl:copy>  
 
 -             <xsl:apply-templates select="@*"/>  
 
 -             <xsl:apply-templates select="node()"/>  
 
 -             <xsl:if test="AvailablePieces">  
 
 -                 <AvailablePieces>  
 
 -                     <xsl:apply-templates select="AvailablePieces/node()"/>  
 
 -                     <!-- 添加新的AvailablePiece元素 -->  
 
 -                     <AvailablePiece id="spear_handle_2"/>  
 
 -                     <AvailablePiece id="spear_handle_9"/>  
 
 -                     <AvailablePiece id="spear_handle_10"/>  
 
 -                     <AvailablePiece id="spear_handle_11"/>  
 
 -                     <AvailablePiece id="spear_handle_12"/>  
 
 -                 </AvailablePieces>  
 
 -             </xsl:if>  
 
 -             <xsl:if test="not(AvailablePieces)">  
 
 -                 <!-- 如果没有AvailablePieces元素,则创建一个并添加新的AvailablePiece元素 -->  
 
 -                 <AvailablePieces>  
 
 -                     <AvailablePiece id="spear_handle_2"/>  
 
 -                     <AvailablePiece id="spear_handle_9"/>  
 
 -                     <AvailablePiece id="spear_handle_10"/>  
 
 -                     <AvailablePiece id="spear_handle_11"/>  
 
 -                     <AvailablePiece id="spear_handle_12"/>  
 
 -                 </AvailablePieces>  
 
 -             </xsl:if>  
 
 -         </xsl:copy>  
 
 -     </xsl:template>  
 
 - </xsl:stylesheet>
 
  复制代码 
 
现在可以进游戏试试,你的打造界面的双手剑模块里,剑柄部分已经有了几个标枪杆,拿来做剑枪已经有最基础的效果了. 
 
然后处理动作的部分,这里我试了几次才差不多 
使用xslt的方法,修改xml.具体来说:在CraftingTemplates标签下的CraftingTemplate标签里,当CraftingTemplate标签的属性id="TwoHandedSword"时,给CraftingTemplate标签下的UsablePieces标签里,添加 
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
 
 -     <xsl:output method="xml" indent="yes"/>  
 
 -     <xsl:strip-space elements="*"/>  
 
 -   
 
 -     <!-- 复制所有内容,除非另有说明 -->  
 
 -     <xsl:template match="@*|node()">  
 
 -         <xsl:copy>  
 
 -             <xsl:apply-templates select="@*|node()"/>  
 
 -         </xsl:copy>  
 
 -     </xsl:template>  
 
 -   
 
 -     <!-- 当遇到item_usage_sets/item_usage_set,且其id属性为"twohanded_block_swing_thrust"时 -->  
 
 -     <xsl:template match="item_usage_sets/item_usage_set[@id='twohanded_block_swing_thrust']">  
 
 -         <xsl:copy>  
 
 -             <!-- 复制item_usage_set的所有属性 -->  
 
 -             <xsl:apply-templates select="@*"/>  
 
 -             <!-- 复制item_usage_set下的所有子元素,除了usages -->  
 
 -             <xsl:apply-templates select="node()[not(self::usages)]"/>  
 
 -             <!-- 如果usages存在,则复制它但移除其下的所有usage元素 -->  
 
 -             <xsl:if test="usages">  
 
 -                 <usages>  
 
 -                   <xsl:apply-templates select="usages/usage[@style!='attack_down']"/>  
 
 -                     <!-- 添加两个新的usage元素 -->  
 
 -                     <usage
 
 -                       style="attack_down"
 
 -                       ready_action="act_ready_thrust_staff_horseback"
 
 -                       quick_release_action="act_quick_release_thrust_staff_horseback"
 
 -                       release_action="act_release_thrust_staff_horseback"
 
 -                       quick_blocked_action="act_quick_blocked_thrust_staff_horseback"
 
 -                       blocked_action="act_blocked_thrust_staff_horseback"
 
 -                       is_mounted="True"
 
 -                       quick_stuck_action="act_quick_stuck_thrust_staff"
 
 -                       stuck_action="act_stuck_thrust_staff"
 
 -                       require_free_left_hand="True"
 
 -                       strike_type="thrust"
 
 -                       begin_hand_position="0,-0.6,-0.1"
 
 -                       begin_hand_rotation="0,-90"
 
 -                       begin_arm_rotation="0,0"
 
 -                       begin_arm_length="0"
 
 -                       end_hand_position="0,1.3,-0.1"
 
 -                       end_hand_rotation="0,-90"
 
 -                       end_arm_rotation="0,0"
 
 -                       end_arm_length="0" />
 
 -                     <usage
 
 -                       style="attack_down"
 
 -                       ready_action="act_ready_thrust_staff"
 
 -                       quick_release_action="act_quick_release_thrust_staff"
 
 -                       release_action="act_release_thrust_staff"
 
 -                       quick_blocked_action="act_quick_blocked_thrust_staff"
 
 -                       blocked_action="act_blocked_thrust_staff"
 
 -                       quick_stuck_action="act_quick_stuck_thrust_staff"
 
 -                       stuck_action="act_stuck_thrust_staff"
 
 -                       is_mounted="False"
 
 -                       require_free_left_hand="True"
 
 -                       strike_type="thrust"
 
 -                       begin_hand_position="0,-0.6,-0.1"
 
 -                       begin_hand_rotation="0,-90"
 
 -                       begin_arm_rotation="0,0"
 
 -                       begin_arm_length="0"
 
 -                       end_hand_position="0,1.3,-0.1"
 
 -                       end_hand_rotation="0,-90"
 
 -                       end_arm_rotation="0,0"
 
 -                       end_arm_length="0" />
 
 -                     <usage
 
 -                       style="attack_down"
 
 -                       ready_action="act_ready_thrust_staff_left_stance"
 
 -                       quick_release_action="act_quick_release_thrust_staff_left_stance"
 
 -                       release_action="act_release_thrust_staff_left_stance"
 
 -                       quick_blocked_action="act_quick_blocked_thrust_staff_left_stance"
 
 -                       blocked_action="act_blocked_thrust_staff_left_stance"
 
 -                       is_mounted="False"
 
 -                       quick_stuck_action="act_quick_stuck_thrust_staff_left_stance"
 
 -                       stuck_action="act_stuck_thrust_staff_left_stance"
 
 -                       require_free_left_hand="True"
 
 -                       is_left_stance="True"
 
 -                       strike_type="thrust"
 
 -                       begin_hand_position="0,-0.6,-0.1"
 
 -                       begin_hand_rotation="0,-90"
 
 -                       begin_arm_rotation="0,0"
 
 -                       begin_arm_length="0"
 
 -                       end_hand_position="0,1.3,-0.1"
 
 -                       end_hand_rotation="0,-90"
 
 -                       end_arm_rotation="0,0"
 
 -                       end_arm_length="0" />
 
 -                     <usage
 
 -                       style="attack_down"
 
 -                       ready_action="act_ready_thrust_1h_lance"
 
 -                       quick_release_action="act_quick_release_thrust_1h_lance"
 
 -                       release_action="act_release_thrust_1h_lance"
 
 -                       quick_blocked_action="act_quick_blocked_thrust_1h_lance"
 
 -                       blocked_action="act_blocked_thrust_1h_lance"
 
 -                       is_mounted="False"
 
 -                       quick_stuck_action="act_quick_stuck_thrust_1h_lance"
 
 -                       stuck_action="act_stuck_thrust_1h_lance"
 
 -                       require_free_left_hand="False"
 
 -                       strike_type="thrust"
 
 -                       begin_hand_position="0,-0.6,-0.3"
 
 -                       begin_hand_rotation="0,-90"
 
 -                       begin_arm_rotation="0,0"
 
 -                       begin_arm_length="0"
 
 -                       end_hand_position="0,1.3,-0.3"
 
 -                       end_hand_rotation="0,-90"
 
 -                       end_arm_rotation="0,0"
 
 -                       end_arm_length="0" />
 
 -                     <usage
 
 -                       style="attack_down"
 
 -                       ready_action="act_ready_thrust_1h_lance_left_stance"
 
 -                       quick_release_action="act_quick_release_thrust_1h_lance_left_stance"
 
 -                       release_action="act_release_thrust_1h_lance_left_stance"
 
 -                       quick_blocked_action="act_quick_blocked_thrust_1h_lance_left_stance"
 
 -                       blocked_action="act_blocked_thrust_1h_lance_left_stance"
 
 -                       is_mounted="False"
 
 -                       quick_stuck_action="act_quick_stuck_thrust_1h_lance_left_stance"
 
 -                       stuck_action="act_stuck_thrust_1h_lance_left_stance"
 
 -                       require_free_left_hand="False"
 
 -                       is_left_stance="True"
 
 -                       strike_type="thrust"
 
 -                       begin_hand_position="0,-0.6,-0.3"
 
 -                       begin_hand_rotation="0,-90"
 
 -                       begin_arm_rotation="0,0"
 
 -                       begin_arm_length="0"
 
 -                       end_hand_position="0,1.3,-0.3"
 
 -                       end_hand_rotation="0,-90"
 
 -                       end_arm_rotation="0,0"
 
 -                       end_arm_length="0" />
 
 -                     <usage
 
 -                       style="attack_down"
 
 -                       ready_action="act_ready_thrust_1h_lance"
 
 -                       quick_release_action="act_quick_release_thrust_1h_lance_horseback"
 
 -                       release_action="act_release_thrust_1h_lance_horseback"
 
 -                       quick_blocked_action="act_quick_blocked_thrust_1h_lance"
 
 -                       blocked_action="act_blocked_thrust_1h_lance"
 
 -                       is_mounted="True"
 
 -                       quick_stuck_action="act_quick_stuck_thrust_1h_lance"
 
 -                       stuck_action="act_stuck_thrust_1h_lance"
 
 -                       require_free_left_hand="False"
 
 -                       strike_type="thrust"
 
 -                       begin_hand_position="0,-0.6,-0.3"
 
 -                       begin_hand_rotation="0,-90"
 
 -                       begin_arm_rotation="0,0"
 
 -                       begin_arm_length="0"
 
 -                       end_hand_position="0,1.3,-0.3"
 
 -                       end_hand_rotation="0,-90"
 
 -                       end_arm_rotation="0,0"
 
 -                       end_arm_length="0" />
 
  
-                 </usages>  
 
 -             </xsl:if>  
 
 -         </xsl:copy>  
 
 -     </xsl:template>
 
 - </xsl:stylesheet>
 
 -     
 
  复制代码 
 
至此完事,去游戏里建一下武器,不过我感觉还是应该用长杆,这短杆看着也太丑了  
xslt这东西主要还是怎么声明这一点比较麻烦,比较GPT也不知道你骑砍内部是怎么定义的.到了真用xslt的部分反而直接丢给GPT去简单处理了. 
如果有更高级的需求,还是需要学一下xslt的语法什么的,不过现在看GPT写了几个功能,两个增,一个删改,也差不多能看懂了吧  
 
 
 
 |   
 
评分
- 
查看全部评分
 
 
 
 
 
 |