diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index eb0f396..fa298e4 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/1.6/1.6/Defs/HediffDefs/ARA_Hediffs_Damage.xml b/1.6/1.6/Defs/HediffDefs/ARA_Hediffs_Damage.xml index e5f6963..b181a04 100644 --- a/1.6/1.6/Defs/HediffDefs/ARA_Hediffs_Damage.xml +++ b/1.6/1.6/Defs/HediffDefs/ARA_Hediffs_Damage.xml @@ -196,4 +196,61 @@
  • + + + ARA_ChainReload + + 使用的武器拥有链式装填能力, 装填速度将随每次射击后提升。 + (0.52, 1, 0.95) + HediffWithComps + +
  • +
  • + 1800 + true +
  • + + +
  • + + true + + 0.9 + 0.9 + +
  • +
  • + + 4 + + 0.8 + 0.8 + +
  • +
  • + + 8 + + 0.65 + 0.65 + +
  • +
  • + + 12 + + 0.45 + 0.45 + +
  • +
  • + + 16 + + 0.25 + 0.25 + +
  • +
    + \ No newline at end of file diff --git a/1.6/1.6/Defs/Thing_Misc/Weapons/ARA_Weapon_new.xml b/1.6/1.6/Defs/Thing_Misc/Weapons/ARA_Weapon_new.xml new file mode 100644 index 0000000..358d4c9 --- /dev/null +++ b/1.6/1.6/Defs/Thing_Misc/Weapons/ARA_Weapon_new.xml @@ -0,0 +1,66 @@ + + + + + ARA_RW_Basic_SniperCannon_Gun + + 阿拉克涅虫群的生物武器 + Normal + Animal + + ARA_Cocoon_Weapon_1Stage + + + ArachnaeSwarm/Weapon/ARA_RW_Basic_Acid_Bladder_Gun + Graphic_Single + 1.2 + + SpitterSpawn + + + ARA_Technology_6SPV + UnfinishedWeapon + + + 1300 + + 3.5 + 0.22 + 0.33 + 0.44 + 0.95 + 3.2 + + +
  • + Verb_Shoot + true + Bullet_TurretSniper + 3.5 + 5.9 + 45.9 + 1 + Shot_TurretSniper + GunTail_Heavy + 18 +
  • +
    + + 50 + + +
  • ARA_Armed_Organ
  • +
  • ARA_Armed_Organ_Ranged
  • +
  • ARA_Armed_Organ_T1
  • +
    + +
  • RewardStandardQualitySuper
  • +
    + +
  • + ARA_ChainReload + 0.5 +
  • +
    +
    +
    \ No newline at end of file diff --git a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj index d70bb6c..2f7da4e 100644 --- a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj +++ b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj @@ -154,6 +154,7 @@ + diff --git a/Source/ArachnaeSwarm/CompAndPatch_GiveHediffOnShot.cs b/Source/ArachnaeSwarm/CompAndPatch_GiveHediffOnShot.cs new file mode 100644 index 0000000..dcda01d --- /dev/null +++ b/Source/ArachnaeSwarm/CompAndPatch_GiveHediffOnShot.cs @@ -0,0 +1,75 @@ +using HarmonyLib; +using RimWorld; +using Verse; + +namespace ArachnaeSwarm +{ + // 1. 定义CompProperties来存储我们的数据 + public class CompProperties_GiveHediffOnShot : CompProperties + { + public HediffDef hediffDef; + public float severityToAdd = 0.1f; + + public CompProperties_GiveHediffOnShot() + { + compClass = typeof(CompGiveHediffOnShot); + } + } + + // 2. 创建一个简单的Comp来挂载到武器上,它只负责持有数据 + public class CompGiveHediffOnShot : ThingComp + { + public CompProperties_GiveHediffOnShot Props => (CompProperties_GiveHediffOnShot)props; + } + + // 3. 创建Harmony补丁 + // 补丁目标为 Verb_Shoot.TryCastShot。这是所有射击动作的通用入口。 + [HarmonyPatch(typeof(Verb_Shoot), "TryCastShot")] + public static class Patch_Verb_Shoot_TryCastShot + { + // 使用[HarmonyPostfix]特性来创建一个在原方法执行后运行的补丁 + // 添加一个bool类型的返回值`__result`,它代表了原方法的返回值 + public static void Postfix(Verb_Shoot __instance, bool __result) + { + // __result 是原方法 TryCastShot 的返回值。 + // 如果 __result 为 false,意味着射击动作因某些原因(如目标无效、没有弹药)失败了,我们就不应该添加Hediff。 + if (!__result) + { + return; + } + + // __instance是原方法的实例对象,也就是那个Verb_Shoot + // 检查这个Verb是否来源于一个装备(武器) + if (__instance.EquipmentSource == null || __instance.CasterPawn == null) + { + return; + } + + // 尝试从武器上获取我们自定义的Comp + CompGiveHediffOnShot comp = __instance.EquipmentSource.GetComp(); + if (comp == null) + { + return; + } + + // 检查XML中是否配置了hediffDef + if (comp.Props.hediffDef == null) + { + Log.ErrorOnce($"[ArachnaeSwarm] CompGiveHediffOnShot on {__instance.EquipmentSource.def.defName} has null hediffDef.", __instance.EquipmentSource.def.GetHashCode()); + return; + } + + // 为射击者(CasterPawn)添加或增加Hediff的严重性 + Hediff hediff = __instance.CasterPawn.health.GetOrAddHediff(comp.Props.hediffDef); + hediff.Severity += comp.Props.severityToAdd; + + // 检查Hediff是否带有HediffComp_Disappears组件 + HediffComp_Disappears disappearsComp = hediff.TryGetComp(); + if (disappearsComp != null) + { + // 如果有,则调用正确的方法重置它的消失计时器 + disappearsComp.ResetElapsedTicks(); + } + } + } +} \ No newline at end of file