using static ItemActionMelee; namespace Harmony.ItemActionMeleePatches { [HarmonyPatch(typeof(ItemActionMelee))] [HarmonyPatch("hitTheTarget")] public class hitTheTargetPatch { public static bool Prefix(ItemActionMelee __instance, ItemActionMelee.InventoryDataMelee _actionData, WorldRayHitInfo hitInfo, float damageScale) { EntityAlive entityAlive = ItemActionAttack.GetEntityFromHit(hitInfo) as EntityAlive; if (entityAlive is EntityPlayer) { //Log.Out("ItemActionMeleePatches-hitTheTarget EntityName: " + entityAlive.EntityName); ProgressionValue progressionValue = entityAlive.Progression.GetProgressionValue("perkDodge"); bool hitTarget = true; if (progressionValue != null) { float chance = progressionValue.level * 5f; int random = GameManager.Instance.World.GetGameRandom().RandomRange(0, 101); //Log.Out("ItemActionMeleePatches-hitTheTarget progressionValue.level: " + progressionValue.level); //Log.Out("ItemActionMeleePatches-hitTheTarget chance: " + chance); //Log.Out("ItemActionMeleePatches-hitTheTarget random: " + random); if (random < chance) { //Log.Out("ItemActionMeleePatches-hitTheTarget EXIT"); hitTarget = false; } } if (!hitTarget) { return false; } } return true; } } [HarmonyPatch(typeof(ItemActionMelee))] [HarmonyPatch("OnHoldingUpdate")] public class OnHoldingUpdatePatch { public static bool Prefix(ItemActionMelee __instance, ItemActionData _actionData) { EntityAlive holdingEntity = _actionData.invData.holdingEntity; if (holdingEntity.IsDead()) { return false; } /*Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.EntityClass.entityClassName: " + holdingEntity.EntityClass.entityClassName); Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.IsRagdollActive: " + holdingEntity.emodel.IsRagdollActive); Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.avatarController.IsAnimationStunRunning(): " + holdingEntity.emodel.avatarController.IsAnimationStunRunning()); Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.IsEating: " + holdingEntity.IsEating); Log.Out("ItemActionMeleePatches-OnHoldingUpdate RebirthUtilities.HasBuffLike(holdingEntity, \"FuriousRamsayRangedStun\"): " + RebirthUtilities.HasBuffLike(holdingEntity, "FuriousRamsayRangedStun")); Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.HasAnyTags(FastTags.Parse(\"ally\")): " + holdingEntity.HasAnyTags(FastTags.Parse("ally"))); Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel != null: " + (holdingEntity.emodel != null)); Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.avatarController != null: " + (holdingEntity.emodel.avatarController != null)); Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.avatarController.anim != null: " + (holdingEntity.emodel.avatarController.anim != null)); Log.Out("ItemActionMeleePatches-OnHoldingUpdate holdingEntity.emodel.avatarController.anim.IsInTransition(0): " + holdingEntity.emodel.avatarController.anim.IsInTransition(0));*/ if (RebirthUtilities.canAttack2(holdingEntity)) { //Log.Out("ItemActionMeleePatches-OnHoldingUpdate CANNOT ATTACK"); return false; } return true; } } }