private void On_CMOnHitGround(On.RoR2.CharacterMotor.orig_OnHitGround orig, CharacterMotor self, CharacterMotor.HitGroundInfo ghi) { orig(self, ghi); if (!self.body) { return; } if (GetCount(self.body) > 0 && Math.Abs(ghi.velocity.y) > velThreshold) { float scalefac = Mathf.Lerp(0f, baseDamage + (GetCount(self.body) - 1f) * stackDamage, Mathf.InverseLerp(velThreshold, velMax + velThreshold, Math.Abs(ghi.velocity.y))); //most properties borrowed from H3AD-5T v2 BlastAttack blastAttack = new BlastAttack { attacker = self.body.gameObject, inflictor = self.body.gameObject, teamIndex = TeamComponent.GetObjectTeam(self.body.gameObject), position = ghi.position, procCoefficient = 0.5f, radius = 10f, baseForce = 2000f, bonusForce = Vector3.up * 2000f, baseDamage = self.body.damage * scalefac, falloffModel = BlastAttack.FalloffModel.SweetSpot, crit = Util.CheckRoll(self.body.crit, self.body.master), damageColorIndex = DamageColorIndex.Item, attackerFiltering = AttackerFiltering.NeverHit }; blastAttack.Fire(); EffectData effectData = new EffectData { origin = ghi.position, scale = 10f }; EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/BootShockwave"), effectData, true); } }
private static void CharacterMotor_OnHitGround(On.RoR2.CharacterMotor.orig_OnHitGround orig, CharacterMotor self, CharacterMotor.HitGroundInfo hitGroundInfo) { bool hasGoombad = false; bool restoreFallDamage = false; if (RunArtifactManager.instance.IsArtifactEnabled(GoombaArtifactDef.artifactIndex)) { if (self.body) { if (Math.Abs(hitGroundInfo.velocity.y) >= minFallSpeed) { Chat.AddMessage("Speed: " + Math.Abs(hitGroundInfo.velocity.y) + "/" + minFallSpeed); var bodySearch = new BullseyeSearch() //let's just get the nearest player { viewer = self.body, sortMode = BullseyeSearch.SortMode.Distance, teamMaskFilter = TeamMask.GetEnemyTeams(self.body.teamComponent.teamIndex), }; bodySearch.RefreshCandidates(); Debug.Log("Nearest Enemies: " + bodySearch.GetResults().ToList()); var nearestBody = bodySearch.GetResults().ToList(); // We very likely landed on an enemy. if (nearestBody.Count > 0) { var firstBody = nearestBody.FirstOrDefault(); var distance = Vector3.Distance(hitGroundInfo.position, Helpers.GetHeadPosition(firstBody.healthComponent.body)); if (distance <= maxDistance) { goombaDamageInfo.attacker = self.body.gameObject; firstBody.healthComponent.TakeDamage(goombaDamageInfo); if ((self.body.bodyFlags & CharacterBody.BodyFlags.IgnoreFallDamage) == CharacterBody.BodyFlags.None) { self.body.bodyFlags |= CharacterBody.BodyFlags.IgnoreFallDamage; restoreFallDamage = true; } Chat.AddMessage("Goomba!"); hasGoombad = true; } } } } } orig(self, hitGroundInfo); if (hasGoombad) { self.Motor.ForceUnground(); self.ApplyForce(Vector3.up * bounceForce); } if (restoreFallDamage) { self.body.bodyFlags &= ~CharacterBody.BodyFlags.IgnoreFallDamage; } }