LordConversationsCampaignBehavior<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Item[@id='crossbow_f']/@difficulty">
<xsl:attribute name="difficulty">
<xsl:value-of select="75"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="Item[@id='crossbow_f']/ItemComponent/Weapon/@missile_speed">
<xsl:attribute name="missile_speed">
<xsl:value-of select="102"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="Item[@id='crossbow_f']/ItemComponent/Weapon/@thrust_damage">
<xsl:attribute name="thrust_damage">
<xsl:value-of select="115"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
I no longer maintain the mod that has been reported to cause the issue, but both me and other players who don't use the mod anymore have not encountered the issue again so I can pretty much confirm that the issue is related with an older version of that mod.
Mission.MissileHitCallBack before Agent.MakeVoice, then patching it after. [HarmonyPatch(typeof(Agent), "MakeVoice")]
public class Patch
{
private static Harmony _harmony = new Harmony("sy.piercingprojectiles");
public static void Prefix()
{
_harmony.Unpatch(AccessTools.Method(typeof(Mission), "MissileHitCallback"),
AccessTools.Method(typeof(HarmonyPatches), nameof(HarmonyPatches.Mission_MissileHitCallback_Transpiler)));
}
public static void Postfix()
{
_harmony.Patch(AccessTools.Method(typeof(Mission), "MissileHitCallback"),
transpiler: new HarmonyMethod(typeof(HarmonyPatches), nameof(HarmonyPatches.Mission_MissileHitCallback_Transpiler)));
if (!_patchApplied)
PiercingProjectiles.Message($"{nameof(PiercingProjectiles)}: failed to apply patch", false);
}
}
MissileHitCallBack only when needed, then unpatching it immediately after.MissionBehavior in your SubModule like this: public class YourSubModule : MBSubModuleBase
{
public override void OnBeforeMissionBehaviorInitialize(Mission mission) => mission.AddMissionBehavior(new YourMissionBehavior());
}
MissionBehavior, manually patch when an agent shoots a missile and unpatch when the missile hits like this: public class YourMissionBehavior : MissionBehavior
{
private Harmony _harmony = new Harmony("sy.piercingprojectiles");
public override MissionBehaviorType BehaviorType => MissionBehaviorType.Other;
public override void OnAgentShootMissile(Agent shooterAgent, EquipmentIndex weaponIndex, Vec3 position, Vec3 velocity, Mat3 orientation, bool hasRigidBody, int forcedMissileIndex)
{
_harmony.Patch(AccessTools.Method(typeof(Mission), "MissileHitCallback"),
transpiler: new HarmonyMethod(typeof(HarmonyPatches), nameof(HarmonyPatches.Mission_MissileHitCallback_Transpiler)));
if (!_patchApplied)
PiercingProjectiles.Message($"{nameof(PiercingProjectiles)}: failed to apply patch", false);
}
public override void OnMissileHit(Agent attacker, Agent victim, bool isCanceled, AttackCollisionData collisionData)
{
_harmony.Unpatch(AccessTools.Method(typeof(Mission), "MissileHitCallback"),
AccessTools.Method(typeof(HarmonyPatches), nameof(HarmonyPatches.Mission_MissileHitCallback_Transpiler)));
}
}
object.StoryModeCharacterCreationContent and the other from SandboxCharacterCreationContent.