返回目录
Chapter 10 第十章:物品修饰符
开发者文档 更新于 2024-03-21 19:30:39

第十章:物品修饰符

在本章中,我们将探讨如何为“骑马与砍杀2”中的装备添加自定义前缀,通过使用物品修饰符(Item Modifiers)来实现。这些修饰符可以改变装备的基础属性,如伤害、速度、防护等,从而为玩家提供更多的自定义选项和游戏内物品多样性。

步骤1:创建rc_item_modifiers.xml文件

首先,在MOD的ModuleData文件夹下创建一个名为item_modifiers.xml的新XML文件。如果文件已存在,则可以直接编辑该文件。

示例代码

<?xml version="1.0" encoding="utf-8"?>
<ItemModifiers>
  <!-- 剑 -->
  <ItemModifier modifier_group="ItemModifierGroup.sword"
                id="myth_sword"
                name="{=*}神话 {ITEMNAME}"
                loot_drop_score="100"
                production_drop_score="2000"
                damage="50"
                speed="20"
                price_factor="2.5"
                quality="legendary" />

  <!-- 弓 -->
  <ItemModifier modifier_group="ItemModifierGroup.bow"
                id="exquisite_bow"
                name="{=*}精良 {ITEMNAME}"
                loot_drop_score="80"
                production_drop_score="160"
                damage="8"
                speed="6"
                missile_speed="10"
                price_factor="2.0"
                quality="legendary" />

  <!-- 弩 -->
  <ItemModifier modifier_group="ItemModifierGroup.crossbow"
                id="masterwork_crossbow"
                name="{=*}大师级 {ITEMNAME}"
                loot_drop_score="120"
                production_drop_score="240"
                damage="12"
                speed="4"
                missile_speed="20"
                price_factor="3.0"
                quality="legendary" />

  <!-- 箭矢 -->
  <ItemModifier modifier_group="ItemModifierGroup.arrow"
                id="fine_arrows"
                name="{=*}优质 {ITEMNAME}"
                loot_drop_score="90"
                production_drop_score="180"
                damage="15"
                stack_count="20"
                price_factor="2.2"
                quality="legendary" />

  <!-- 盾牌 -->
  <ItemModifier modifier_group="ItemModifierGroup.shield"
                id="reinforced_shield"
                name="{=*}加固 {ITEMNAME}"
                loot_drop_score="110"
                production_drop_score="220"
                hit_points="220"
                armor="10"
                price_factor="2.8"
                quality="legendary" />

  <!-- 铠甲 -->
  <ItemModifier modifier_group="ItemModifierGroup.plate"
                id="forged_plate"
                name="{=*}锻造 {ITEMNAME}"
                loot_drop_score="130"
                production_drop_score="260"
                armor="20"
                price_factor="3.5"
                quality="legendary" />

  <!-- 铁甲 -->
  <ItemModifier modifier_group="ItemModifierGroup.chain"
                id="tempered_chain"
                name="{=*}回火 {ITEMNAME}"
                loot_drop_score="70"
                production_drop_score="140"
                armor="14"
                price_factor="1.9"
                quality="legendary" />

  <!-- 皮甲 -->
  <ItemModifier modifier_group="ItemModifierGroup.leather"
                id="sturdy_leather"
                name="{=*}坚固 {ITEMNAME}"
                loot_drop_score="60"
                production_drop_score="120"
                armor="12"
                price_factor="1.7"
                quality="legendary" />

  <!-- 布甲 -->
  <ItemModifier modifier_group="ItemModifierGroup.cloth"
                id="woven_cloth"
                name="{=*}编织 {ITEMNAME}"
                loot_drop_score="50"
                production_drop_score="100"
                armor="9"
                price_factor="1.5"
                quality="legendary" />

  <!-- 长杆武器 -->
  <ItemModifier modifier_group="ItemModifierGroup.polearm"
                id="veteran_polearm"
                name="{=*}老练 {ITEMNAME}"
                loot_drop_score="70"
                production_drop_score="140"
                damage="9"
                speed="2"
                price_factor="2.0"
                quality="legendary" />

  <!-- 飞刀 -->
  <ItemModifier modifier_group="ItemModifierGroup.knife_throwing"
                id="sharp_throwing_knife"
                name="{=*}锐利 {ITEMNAME}"
                loot_drop_score="80"
                production_drop_score="160"
                stack_count="5"
                missile_speed="10"
                price_factor="2.2"
                quality="legendary" />

  <!-- 标枪 -->
  <ItemModifier modifier_group="ItemModifierGroup.spear_dart_throwing"
                id="heavy_javelin"
                name="{=*}沉重 {ITEMNAME}"
                loot_drop_score="90"
                production_drop_score="180"
                damage="12"
                missile_speed="8"
                price_factor="2.5"
                quality="legendary" />

  <!-- 长矛 -->
  <ItemModifier modifier_group="ItemModifierGroup.spear"
                id="balanced_spear"
                name="{=*}平衡 {ITEMNAME}"
                loot_drop_score="60"
                production_drop_score="120"
                damage="10"
                speed="4"
                missile_speed="5" 
                price_factor="1.8"
                quality="legendary" />

  <!-- 飞斧 -->
  <ItemModifier modifier_group="ItemModifierGroup.axe_throwing"
                id="precise_throwing_axe"
                name="{=*}精准 {ITEMNAME}"
                loot_drop_score="100"
                production_drop_score="200"
                stack_count="4"
                missile_speed="9"
                price_factor="2.8"
                quality="legendary" />
</ItemModifiers>

解释

步骤2:在SubModule.xml中注册item_modifiers文件

为了让游戏能够识别和加载item_modifiers.xml文件,您需要在SubModule.xml文件中进行相应的配置。

SubModule.xml配置

<Xmls>
  <XmlNode>
    <XmlName id="Item_modifiers" path="item_modifiers" />
    <IncludedGameTypes>
      <GameType value="Campaign"/>
      <GameType value="Native"/>
      <GameType value="Sandbox"/>
      <GameType value="SandBoxCore"/>
      <GameType value="CampaignStoryMode"/>
    </IncludedGameTypes>
  </XmlNode>
</Xmls>

这段配置告诉游戏在启动时包含item_modifiers.xml文件,并指定它在哪些游戏类型中有效。

总结

通过添加自定义的装备前缀和物品修饰符,您可以为游戏中的装备引入丰富的属性变化和命名多样性。这不仅增强了玩家的游戏体验,还为装备的获取和使用增加了更多的策略和选择。正确配置并使用物品修饰符可以大大增强游戏的深度和可玩性。