Beispiel #1
0
        private void CharacterMotor_onHitGround(ref CharacterMotor.HitGroundInfo hitGroundInfo)
        {
            if (base.characterBody.bodyFlags.HasFlag(CharacterBody.BodyFlags.IgnoreFallDamage))
            {
                base.characterBody.bodyFlags &= ~CharacterBody.BodyFlags.IgnoreFallDamage;
            }

            // TODO: May need to redo the flag assignment?

            base.characterMotor.onHitGround -= this.CharacterMotor_onHitGround;
        }
Beispiel #2
0
 private void CharacterMotor_onHitGround(ref CharacterMotor.HitGroundInfo hitGroundInfo)
 {
     BlastAttack impactAttack = new BlastAttack
     {
         attacker          = base.gameObject,
         attackerFiltering = AttackerFiltering.Default,
         baseDamage        = 3 * base.damageStat,
         baseForce         = 10,
         bonusForce        = new Vector3(0, 0, 0),
         crit             = false,
         damageColorIndex = DamageColorIndex.Default,
         damageType       = DamageType.AOE,
         falloffModel     = BlastAttack.FalloffModel.None,
         inflictor        = base.gameObject,
         losType          = BlastAttack.LoSType.NearestHit,
         position         = hitGroundInfo.position,
         procChainMask    = default,
 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);
     }
 }
Beispiel #4
0
        private void CharacterMotor_OnHitGroundServer(On.RoR2.CharacterMotor.orig_OnHitGroundServer orig, CharacterMotor self, CharacterMotor.HitGroundInfo hitGroundInfo)
        {
            if (!RunArtifactManager.instance.IsArtifactEnabled(GoombaArtifactDef.artifactIndex))
            {
                orig(self, hitGroundInfo);
                return;
            }

            bool hasGoombad        = false;
            bool restoreFallDamage = false;
            var  goombaComponent   = self.GetComponent <GoombaComponent>();

            if (self.body)
            {
                if (goombaComponent.inGoombaState || Math.Abs(hitGroundInfo.velocity.y) >= minFallSpeed.Value)
                {
                    TeamMask teamMask = TeamMask.GetEnemyTeams(self.body.teamComponent.teamIndex);
                    if (FriendlyFireManager.friendlyFireMode != FriendlyFireManager.FriendlyFireMode.Off && friendlyFire.Value)
                    {
                        teamMask = TeamMask.allButNeutral;
                    }
                    //Chat.AddMessage("Speed: " + Math.Abs(hitGroundInfo.velocity.y) + "/" + minFallSpeed);
                    var enemySearch = new BullseyeSearch()
                    {
                        filterByDistinctEntity = false,
                        filterByLoS            = false,
                        maxDistanceFilter      = maxDistance.Value,
                        minDistanceFilter      = 0f,
                        minAngleFilter         = 0f,
                        maxAngleFilter         = angleCheck.Value,
                        teamMaskFilter         = teamMask,
                        sortMode        = BullseyeSearch.SortMode.Distance,
                        viewer          = self.body,
                        searchDirection = Vector3.down,
                        searchOrigin    = hitGroundInfo.position
                    };
                    enemySearch.RefreshCandidates();
                    var listOfEnemies = enemySearch.GetResults().ToList();

                    /*var str = "Nearest Enemies: ";
                     *
                     * foreach(var enemy in listOfEnemies)
                     * {
                     *  if (enemy)
                     *      str += enemy.healthComponent.body.GetDisplayName() + ", ";
                     * }
                     * Debug.Log(str);*/

                    HurtBox enemyHurtbox = GetValidEnemy(listOfEnemies);
                    if (enemyHurtbox)
                    {
                        //var headPos = Helpers.GetHeadPosition(enemyHurtbox.healthComponent.body);
                        //var distance = Vector3.Distance(hitGroundInfo.position, headPos);
                        //Chat.AddMessage("Distance to enemy is "+ distance);
                        goombaComponent.inGoombaState = true;
                        if (enemyHurtbox.healthComponent != goombaComponent.currentHealthComponent)
                        {
                            goombaComponent.bounces = 1;
                            goombaComponent.currentHealthComponent = enemyHurtbox.healthComponent;
                        }
                        enemyHurtbox.healthComponent.TakeDamage(new DamageInfo()
                        {
                            attacker         = self.body.gameObject,
                            damage           = multiplyDmgPerBounce.Value ? goombaDamage.Value * goombaComponent.bounces : goombaDamage.Value,
                            inflictor        = goombaGameObject,
                            position         = hitGroundInfo.position,
                            damageColorIndex = DamageColorIndex.Bleed
                        });
                        if ((self.body.bodyFlags & CharacterBody.BodyFlags.IgnoreFallDamage) == CharacterBody.BodyFlags.None)
                        {
                            self.body.bodyFlags |= CharacterBody.BodyFlags.IgnoreFallDamage;
                            restoreFallDamage    = true;
                        }
                        if (goombaInChat.Value)
                        {
                            Chat.AddMessage("Goomba!");
                        }
                        hasGoombad = true;
                    }
                }
            }

            orig(self, hitGroundInfo);
            if (hasGoombad)
            {
                self.Motor.ForceUnground();
                self.ApplyForce(Vector3.up * bounceForce.Value);
                goombaComponent.bounces++;
            }
            else
            {
                goombaComponent.ExitGoombaState();
            }
            if (restoreFallDamage)
            {
                self.body.bodyFlags &= ~CharacterBody.BodyFlags.IgnoreFallDamage;
            }
        }
        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;
            }
        }
Beispiel #6
0
 // Token: 0x06002FDA RID: 12250 RVA: 0x000CD0C5 File Offset: 0x000CB2C5
 private void OnMotorHitGround(ref CharacterMotor.HitGroundInfo hitGroundInfo)
 {
     this.highestFallSpeed = Mathf.Max(this.highestFallSpeed, -hitGroundInfo.velocity.y);
     this.OnHitGround(this.highestFallSpeed, hitGroundInfo.position);
 }
Beispiel #7
0
 // Token: 0x060006D5 RID: 1749 RVA: 0x000209BD File Offset: 0x0001EBBD
 private void OnMotorHitGround(ref CharacterMotor.HitGroundInfo hitGroundInfo)
 {
     this.OnHitGround(-hitGroundInfo.velocity.y, hitGroundInfo.position);
 }
Beispiel #8
0
 // Token: 0x060034DB RID: 13531 RVA: 0x000E7B52 File Offset: 0x000E5D52
 public static void _WriteHitGroundInfo_CharacterMotor(NetworkWriter writer, CharacterMotor.HitGroundInfo value)
 {
     writer.Write(value.velocity);
     writer.Write(value.position);
 }