Exemple #1
0
 //Called by base onenter, we replace it with our own special bullet
 public override void FireBullet(Ray aimRay)
 {
     //Play the sound
     Util.PlaySound(this.assetRef.fireSoundString, base.gameObject);
     //Network check
     if (base.isAuthority)
     {
         //Set the damage accordingly
         this.damage = this.baseDamageCoef * base.characterBody.damage;
         //Create the bulletattack
         attack = new BulletAttack
         {
             origin             = aimRay.origin,
             aimVector          = aimRay.direction,
             tracerEffectPrefab = this.assetRef.tracerEffectPrefab,
             muzzleName         = this.assetRef.muzzleName,
             hitEffectPrefab    = this.assetRef.hitEffectPrefab,
             damage             = this.damage,
             owner           = base.gameObject,
             isCrit          = this.isCrit,
             maxDistance     = 1000f,
             smartCollision  = true,
             procCoefficient = this.procCoef,
             HitEffectNormal = false,
             falloffModel    = BulletAttack.FalloffModel.None,
             weapon          = base.gameObject,
             hitCallback     = CallBack
         };
         //Fire
         attack.Fire();
     }
     //Apply the muzzleflash
     EffectManager.SimpleMuzzleFlash(assetRef.muzzleFlashPrefab, base.gameObject, this.assetRef.muzzleName, false);
 }
        private void FireMissile(HurtBox target, Vector3 position)
        {
            var aimVector = target.transform.position - position;

            BulletAttack bulletAttack = default;

            bulletAttack.owner              = base.gameObject;
            bulletAttack.weapon             = base.gameObject;
            bulletAttack.origin             = position;
            bulletAttack.aimVector          = aimVector;
            bulletAttack.minSpread          = this.minSpread;
            bulletAttack.maxSpread          = this.maxSpread;
            bulletAttack.bulletCount        = 1U;
            bulletAttack.damage             = damageCoefficient * this.damageStat;
            bulletAttack.force              = this.force;
            bulletAttack.falloffModel       = BulletAttack.FalloffModel.None;
            bulletAttack.tracerEffectPrefab = this.tracerEffectPrefab;
            bulletAttack.muzzleName         = "MuzzlePistol";
            bulletAttack.hitEffectPrefab    = this.hitEffectPrefab;
            bulletAttack.isCrit             = base.RollCrit();
            bulletAttack.HitEffectNormal    = false;
            bulletAttack.radius             = this.bulletRadius;
            bulletAttack.damageType        |= DamageType.BonusToLowHealth | DamageType.GiveSkullOnKill;
            bulletAttack.smartCollision     = true;
            bulletAttack.Fire();
        }
Exemple #3
0
        private static void AdjustSpreadBullets(On.RoR2.BulletAttack.orig_Fire orig, BulletAttack self)
        {
            if (self.owner)
            {
                var body = self.owner.gameObject.GetComponent <CharacterBody>();
                if (body)
                {
                    var comp = body.masterObject.GetComponent <RBSExtraStatsController>();
                    if (comp)
                    {
                        var accuracy = comp.bulletAccuracy;

                        body.SetSpreadBloom(Mathf.Min(0, body.spreadBloomAngle * accuracy), false);

                        self.maxSpread = SimpleSpread(self.maxSpread, 1.15f);

                        self.minSpread = SimpleSpread(accuracy, self.minSpread);

                        if (body.inputBank)
                        {
                            self.aimVector = Vector3.Lerp(self.aimVector, body.inputBank.aimDirection, 1 - accuracy);
                        }

                        self.spreadPitchScale *= SimpleSpread(accuracy, self.spreadPitchScale);
                        self.spreadYawScale   *= SimpleSpread(accuracy, self.spreadYawScale);
                    }
                }
            }
            orig(self);
        }
        public override void OnEnter()
        {
            base.OnEnter();
            this.duration = FireLightsOut.baseDuration / this.attackSpeedStat;
            base.AddRecoil(-3f * FireLightsOut.recoilAmplitude, -4f * FireLightsOut.recoilAmplitude, -0.5f * FireLightsOut.recoilAmplitude, 0.5f * FireLightsOut.recoilAmplitude);
            Ray aimRay = base.GetAimRay();

            base.StartAimMode(aimRay, 2f, false);
            string muzzleName = "MuzzlePistol";

            Util.PlaySound(FireLightsOut.attackSoundString, base.gameObject);
            base.PlayAnimation("Gesture, Additive", "FireRevolver");
            base.PlayAnimation("Gesture, Override", "FireRevolver");
            if (FireLightsOut.effectPrefab)
            {
                EffectManager.SimpleMuzzleFlash(FireLightsOut.effectPrefab, base.gameObject, muzzleName, false);
            }
            if (base.isAuthority)
            {
                BulletAttack bulletAttack = new BulletAttack();
                bulletAttack.owner              = base.gameObject;
                bulletAttack.weapon             = base.gameObject;
                bulletAttack.origin             = aimRay.origin;
                bulletAttack.aimVector          = aimRay.direction;
                bulletAttack.minSpread          = FireLightsOut.minSpread;
                bulletAttack.maxSpread          = FireLightsOut.maxSpread;
                bulletAttack.bulletCount        = (uint)((FireLightsOut.bulletCount > 0) ? FireLightsOut.bulletCount : 0);
                bulletAttack.damage             = FireLightsOut.damageCoefficient * this.damageStat;
                bulletAttack.force              = FireLightsOut.force;
                bulletAttack.falloffModel       = BulletAttack.FalloffModel.None;
                bulletAttack.tracerEffectPrefab = FireLightsOut.tracerEffectPrefab;
                bulletAttack.muzzleName         = muzzleName;
                bulletAttack.hitEffectPrefab    = FireLightsOut.hitEffectPrefab;
                bulletAttack.isCrit             = Util.CheckRoll(this.critStat, base.characterBody.master);
                bulletAttack.HitEffectNormal    = false;
                bulletAttack.radius             = 0.5f;
                bulletAttack.maxDistance        = 500f;

                if (!ignoreArmor)
                {
                    bulletAttack.damageType |= DamageType.ResetCooldownsOnKill;
                }
                else
                {
                    bulletAttack.damageType = (DamageType.ResetCooldownsOnKill | DamageType.BypassArmor);
                }
                bulletAttack.smartCollision = true;

                if (gainDamageWithLevel)
                {
                    float bonusDamage = gainDamgeWithLevelAmount * (base.gameObject.GetComponent <CharacterBody>().level - 1);
                    if (gainDamgeWithLevelMax > 0f && bonusDamage > gainDamgeWithLevelMax)
                    {
                        bonusDamage = gainDamgeWithLevelMax;
                    }
                    bulletAttack.damage = (FireLightsOut.damageCoefficient + bonusDamage) * this.damageStat;
                }
                bulletAttack.Fire();
            }
        }
 // Token: 0x06000763 RID: 1891 RVA: 0x000243B8 File Offset: 0x000225B8
 private void FireBullet(Transform modelTransform, Ray aimRay, string targetMuzzle)
 {
     if (FireBeam.effectPrefab)
     {
         EffectManager.instance.SimpleMuzzleFlash(FireBeam.effectPrefab, base.gameObject, targetMuzzle, false);
     }
     if (base.isAuthority)
     {
         BulletAttack bulletAttack = new BulletAttack();
         bulletAttack.owner           = base.gameObject;
         bulletAttack.weapon          = base.gameObject;
         bulletAttack.origin          = aimRay.origin;
         bulletAttack.aimVector       = aimRay.direction;
         bulletAttack.minSpread       = FireBeam.minSpread;
         bulletAttack.maxSpread       = FireBeam.maxSpread;
         bulletAttack.bulletCount     = 1u;
         bulletAttack.damage          = FireBeam.damageCoefficient * this.damageStat / FireBeam.fireFrequency;
         bulletAttack.force           = FireBeam.force;
         bulletAttack.muzzleName      = targetMuzzle;
         bulletAttack.hitEffectPrefab = FireBeam.hitEffectPrefab;
         bulletAttack.isCrit          = Util.CheckRoll(this.critStat, base.characterBody.master);
         bulletAttack.HitEffectNormal = false;
         bulletAttack.radius          = 0f;
         bulletAttack.maxDistance     = FireBeam.maxDistance;
         bulletAttack.damageType     |= DamageType.SlowOnHit;
         bulletAttack.Fire();
     }
 }
Exemple #6
0
 private void FireBullet(Transform modelTransform, Ray aimRay, string targetMuzzle, float maxDistance)
 {
     if ((bool)effectPrefab)
     {
         EffectManager.SimpleMuzzleFlash(effectPrefab, base.gameObject, targetMuzzle, transmit: false);
     }
     if (base.isAuthority)
     {
         BulletAttack bulletAttack = new BulletAttack();
         bulletAttack.owner           = base.gameObject;
         bulletAttack.weapon          = base.gameObject;
         bulletAttack.origin          = aimRay.origin;
         bulletAttack.aimVector       = aimRay.direction;
         bulletAttack.minSpread       = minSpread;
         bulletAttack.maxSpread       = maxSpread;
         bulletAttack.bulletCount     = 1u;
         bulletAttack.damage          = damageCoefficient * damageStat / fireFrequency;
         bulletAttack.force           = force;
         bulletAttack.muzzleName      = targetMuzzle;
         bulletAttack.hitEffectPrefab = hitEffectPrefab;
         bulletAttack.isCrit          = Util.CheckRoll(critStat, base.characterBody.master);
         bulletAttack.procCoefficient = procCoefficientPerTick;
         bulletAttack.HitEffectNormal = false;
         bulletAttack.radius          = 0f;
         bulletAttack.maxDistance     = maxDistance;
         bulletAttack.Fire();
     }
 }
        private void BulletAttack_Fire(On.RoR2.BulletAttack.orig_Fire orig, BulletAttack self)
        {
            orig(self);
            if (ignoreMugs || !self.owner)
            {
                return;
            }
            var cpt = self.owner.GetComponent <CharacterBody>();

            if (!cpt)
            {
                return;
            }
            var count = GetCount(cpt);

            if (count <= 0)
            {
                return;
            }
            var totalChance = count * procChance;
            int procCount   = (Util.CheckRoll(Wrap(totalChance * 100f, 0f, 100f), cpt.master) ? 1 : 0) + (int)Mathf.Floor(totalChance);

            if (procCount <= 0)
            {
                return;
            }
            self.bulletCount      = (uint)procCount;
            self.maxSpread       += spreadConeHalfAngleDegr;
            self.spreadPitchScale = 1f;
            self.spreadYawScale   = 1f;
            orig(self);
        }
Exemple #8
0
        private void AdjustSpreadBullets(On.RoR2.BulletAttack.orig_Fire orig, BulletAttack self)
        {
            //doesn't work on MULT?????
            CharacterBody characterBody = self.owner.gameObject.GetComponent <CharacterBody>();

            if (characterBody)
            {
                var inventory = characterBody.inventory;
                if (inventory)
                {
                    var ResultMult = CalculateSpreadMultiplier(inventory, false);

                    characterBody.SetSpreadBloom(Mathf.Min(0, characterBody.spreadBloomAngle * ResultMult), false);

                    //Debug.Log("Bulletscope: maxspread: "+self.maxSpread+" multiplier: "+ResultMult+" result: "+ Mathf.Max(self.maxSpread * ResultMult, 0));

                    //if (self.radius == 0) //(maybe?)
                    //self.radius = ResultMult;

                    self.maxSpread = SimpleSpread(self.maxSpread, 1.15f);

                    self.minSpread = SimpleSpread(ResultMult, self.minSpread);

                    self.spreadPitchScale *= SimpleSpread(ResultMult, self.spreadPitchScale);
                    self.spreadYawScale   *= SimpleSpread(ResultMult, self.spreadYawScale);

                    //self.owner.GetComponent<CharacterBody>().SetSpreadBloom(ResultMult, false);
                }
            }
            orig(self);
        }
Exemple #9
0
        private void FireShotgun2_FireBullet(On.EntityStates.Bandit2.Weapon.FireShotgun2.orig_FireBullet orig, EntityStates.Bandit2.Weapon.FireShotgun2 self, Ray aimRay)
        {
            self.StartAimMode(aimRay, 3f, false);
            self.DoFireEffects();
            self.PlayFireAnimation();
            self.AddRecoil(-1f * self.recoilAmplitudeY, -1.5f * self.recoilAmplitudeY, -1f * self.recoilAmplitudeX, 1f * self.recoilAmplitudeX);
            if (self.isAuthority)
            {
                Vector3 rhs         = Vector3.Cross(Vector3.up, aimRay.direction);
                Vector3 axis        = Vector3.Cross(aimRay.direction, rhs);
                float   spreadBloom = self.characterBody.spreadBloomAngle;

                float angle = 0f;
                float num2  = 0f;
                if (self.bulletCount > 1)
                { //here
                    var ResultMult = CalculateSpreadMultiplier(self.characterBody.inventory, false);
                    num2 = UnityEngine.Random.Range(SimpleSpread(ResultMult, self.minFixedSpreadYaw + spreadBloom),
                                                    SimpleSpread(ResultMult, self.maxFixedSpreadYaw + spreadBloom)) * 2f;
                    angle = num2 / (self.bulletCount - 1);
                }
                Vector3    direction = Quaternion.AngleAxis(-num2 * 0.5f, axis) * aimRay.direction;
                Quaternion rotation  = Quaternion.AngleAxis(angle, axis);
                Ray        aimRay2   = new Ray(aimRay.origin, direction);
                for (int i = 0; i < self.bulletCount; i++)
                {
                    BulletAttack bulletAttack = self.GenerateBulletAttack(aimRay2);
                    self.ModifyBullet(bulletAttack);
                    bulletAttack.Fire();
                    aimRay2.direction = rotation * aimRay2.direction;
                }
            }
        }
 // Token: 0x0600308B RID: 12427 RVA: 0x000D147C File Offset: 0x000CF67C
 private void FireBullet(Transform modelTransform, Ray laserRay, string targetMuzzle)
 {
     if (this.effectPrefab)
     {
         EffectManager.SimpleMuzzleFlash(this.effectPrefab, base.gameObject, targetMuzzle, false);
     }
     if (base.isAuthority)
     {
         BulletAttack bulletAttack = new BulletAttack();
         bulletAttack.owner           = base.gameObject;
         bulletAttack.weapon          = base.gameObject;
         bulletAttack.origin          = laserRay.origin;
         bulletAttack.aimVector       = laserRay.direction;
         bulletAttack.minSpread       = this.minSpread;
         bulletAttack.maxSpread       = this.maxSpread;
         bulletAttack.bulletCount     = 1U;
         bulletAttack.damage          = this.damageCoefficient * this.damageStat / this.fireFrequency;
         bulletAttack.procCoefficient = this.procCoefficient / this.fireFrequency;
         bulletAttack.force           = this.force;
         bulletAttack.muzzleName      = targetMuzzle;
         bulletAttack.hitEffectPrefab = this.hitEffectPrefab;
         bulletAttack.isCrit          = Util.CheckRoll(this.critStat, base.characterBody.master);
         bulletAttack.HitEffectNormal = false;
         bulletAttack.radius          = 0f;
         bulletAttack.maxDistance     = this.maxDistance;
         this.ModifyBullet(bulletAttack);
         bulletAttack.Fire();
     }
 }
Exemple #11
0
        private void FireBeam_FixedUpdate(On.EntityStates.EngiTurret.EngiTurretWeapon.FireBeam.orig_FixedUpdate orig, FireBeam self)
        {
            float optionFireTimer = self.fireTimer + Time.fixedDeltaTime;

            orig(self);
            if (DroneNameCheck(self.characterBody, "RoboBallGreenBuddy") || DroneNameCheck(self.characterBody, "RoboBallRedBuddy"))
            {
                FireForAllOptions(self.characterBody, (option, behavior, target, direction) =>
                {
                    Ray laserRay   = new Ray(option.transform.position, direction);
                    float rate     = self.fireFrequency * self.characterBody.attackSpeed;
                    float fraction = 1f / rate;
                    if (optionFireTimer > fraction)
                    {
                        if (self.effectPrefab)
                        {
                            option.MuzzleEffect(self.effectPrefab, false);
                        }
                        if (self.isAuthority)
                        {
                            BulletAttack bulletAttack = new BulletAttack()
                            {
                                owner           = self.gameObject,
                                weapon          = option,
                                origin          = laserRay.origin,
                                aimVector       = laserRay.direction,
                                minSpread       = self.minSpread,
                                maxSpread       = self.maxSpread,
                                bulletCount     = 1U,
                                damage          = self.damageCoefficient * self.damageStat / self.fireFrequency * damageMultiplier,
                                procCoefficient = self.procCoefficient * self.fireFrequency,
                                force           = self.force * damageMultiplier,
                                muzzleName      = self.muzzleString,
                                hitEffectPrefab = self.hitEffectPrefab,
                                isCrit          = self.characterBody.RollCrit(),
                                HitEffectNormal = false,
                                radius          = 0f,
                                maxDistance     = self.maxDistance
                            };
                            self.ModifyBullet(bulletAttack);
                            if (!empathyCoresOptionSyncEffect)
                            {
                                bulletAttack.tracerEffectPrefab = FireGatling.tracerEffectPrefab;
                            }
                            bulletAttack.Fire();
                        }
                    }
                    if (empathyCoresOptionSyncEffect && behavior.U.SafeCheck("laserEffectInstance") && behavior.U.SafeCheck("laserEffectInstanceEndTransform"))
                    {
                        Vector3 position = ((GameObject)behavior.U["laserEffectInstance"]).transform.parent.position;
                        Vector3 point    = laserRay.GetPoint(self.maxDistance);
                        if (Physics.Raycast(laserRay.origin, laserRay.direction, out RaycastHit raycastHit, self.maxDistance,
                                            LayerIndex.world.mask | LayerIndex.entityPrecise.mask, QueryTriggerInteraction.UseGlobal))
                        {
                            point = raycastHit.point;
                        }
                        ((Transform)behavior.U["laserEffectInstanceEndTransform"]).position = point;
                    }
                });
 // Token: 0x0600038B RID: 907 RVA: 0x0000E544 File Offset: 0x0000C744
 protected virtual void FireBullet(Ray aimRay)
 {
     base.StartAimMode(aimRay, 3f, false);
     this.DoFireEffects();
     this.PlayFireAnimation();
     if (base.isAuthority)
     {
         BulletAttack bulletAttack = this.GenerateBulletAttack(aimRay);
         this.ModifyBullet(bulletAttack);
         bulletAttack.Fire();
     }
 }
 // Token: 0x06002A06 RID: 10758 RVA: 0x000B0A24 File Offset: 0x000AEC24
 protected virtual void FireBullet(Ray aimRay)
 {
     base.StartAimMode(aimRay, 3f, false);
     this.DoFireEffects();
     this.PlayFireAnimation();
     base.AddRecoil(-1f * this.recoilAmplitudeY, -1.5f * this.recoilAmplitudeY, -1f * this.recoilAmplitudeX, 1f * this.recoilAmplitudeX);
     if (base.isAuthority)
     {
         BulletAttack bulletAttack = this.GenerateBulletAttack(aimRay);
         this.ModifyBullet(bulletAttack);
         bulletAttack.Fire();
     }
 }
Exemple #14
0
 private void BulletAttack_Fire(On.RoR2.BulletAttack.orig_Fire orig, BulletAttack self)
 {
     bulletAttackDidHit = false;
     orig(self);
     if (!bulletAttackDidHit && self.owner == this.localUser.cachedBodyObject)
     {
         userProfile.statSheet.PushStatValue(Mug.instance.whiffsStatDef, 1UL);
         if (ProgressForAchievement() >= 1.0f)
         {
             Grant();
         }
     }
 }
        public override void OnEnter()
        {
            base.OnEnter();

            duration = baseDuration / attackSpeedStat;
            AddRecoil(-3f * recoilAmplitude, -4f * recoilAmplitude, -0.5f * recoilAmplitude, 0.5f * recoilAmplitude);
            Ray aimRay = GetAimRay();

            StartAimMode(aimRay, 2f, false);
            string muzzleName = "MuzzlePistol";

            Util.PlaySound(attackSoundString, gameObject);
            PlayAnimation("Gesture, Additive", "FireRevolver");
            PlayAnimation("Gesture, Override", "FireRevolver");
            if (effectPrefab)
            {
                EffectManager.instance.SimpleMuzzleFlash(effectPrefab, gameObject, muzzleName, true);
            }
            if (isAuthority)
            {
                skill = gameObject?.GetComponentInChildren <SkillLocator>();
                BulletAttack bulletAttack = new BulletAttack
                {
                    owner              = gameObject,
                    weapon             = gameObject,
                    origin             = aimRay.origin,
                    aimVector          = aimRay.direction,
                    minSpread          = minSpread,
                    maxSpread          = maxSpread,
                    bulletCount        = (uint)((bulletCount > 0) ? bulletCount : 0),
                    damage             = damageCoefficient * damageStat,
                    force              = force,
                    falloffModel       = BulletAttack.FalloffModel.None,
                    tracerEffectPrefab = tracerEffectPrefab,
                    muzzleName         = muzzleName,
                    hitEffectPrefab    = hitEffectPrefab,
                    isCrit             = Util.CheckRoll(critStat, characterBody.master),
                    HitEffectNormal    = false,
                    radius             = 0.5f,
                    smartCollision     = true
                };
                bulletAttack.damageType |= DamageType.ResetCooldownsOnKill;
                if (Timer.Timer.flag)
                {
                    bulletAttack.hitCallback = new BulletAttack.HitCallback(Hit) + bulletAttack.hitCallback;
                }
                bulletAttack.Fire();
            }
        }
Exemple #16
0
        // Token: 0x06003AB3 RID: 15027 RVA: 0x000F3280 File Offset: 0x000F1480
        protected override void ModifyBullet(BulletAttack bulletAttack)
        {
            base.ModifyBullet(bulletAttack);
            bulletAttack.falloffModel    = BulletAttack.FalloffModel.None;
            bulletAttack.damage          = damageStat * 6 * charge;
            bulletAttack.force           = 100 * charge;
            bulletAttack.procCoefficient = 0.05f * charge;
            bulletAttack.radius          = 0.1f;
            if (!tracerEffectPrefab)
            {
                tracerEffectPrefab = Resources.Load <GameObject>("prefabs/effects/tracers/TracerHuntressSnipe");
            }

            Util.PlaySound("gravekeeper_impact_body_04", base.characterBody.gameObject);

            bulletAttack.tracerEffectPrefab = tracerEffectPrefab;
        }
Exemple #17
0
        //Event called when bullet hits anything
        private bool CallBack(BulletAttack bulletattack, ref BulletAttack.BulletHit hitInfo)
        {
            //Run the hit as normal first
            bool hit = BulletAttack.DefaultHitCallbackImplementation(bulletattack, ref hitInfo);
            //Pos is where the bullet hit
            Vector3 pos = hitInfo.point;

            //If it actually hit something, add the main hurtbox of them to our list
            if (hitInfo.hitHurtBox)
            {
                hitHurtBoxes.Add(hitInfo.hitHurtBox.hurtBoxGroup.mainHurtBox);
            }
            //Execute our richochet code
            HandleRichochet(pos);
            //Return the previously found hit / nohit
            return(hit);
        }
Exemple #18
0
    private void OnTriggerEnter(Collider other)
    {
        BulletAttack bullet = other.GetComponent <BulletAttack>();

        if (bullet != null)
        {
            enemyHealth -= bullet.bulletDamage;
            UpdateUI();
            if (enemyHealth <= 0)
            {
                Destroy(this.gameObject);
                score.AddScore();
                if (Random.value < 0.3f)
                {
                    Instantiate(healthPackPrefab, healthPackSpawnPoint.position, healthPackSpawnPoint.rotation);
                }
            }
            Destroy(other.gameObject);
        }
    }
        /// <summary>
        /// Filters the owner out from the attack so that they do not hit themselves with their own attack.
        /// Useful for Option Seeds' behavior to avoid hitting the owner.
        /// </summary>
        /// <param name="bulletAttack">The bullet attack being worked on.</param>
        public static void FilterOutOwnerFromAttack(this BulletAttack bulletAttack)
        {
            bulletAttack.filterCallback = (ref BulletHit hitInfo) =>
            {
                if (bulletAttack.owner == hitInfo.entityObject || bulletAttack.weapon == hitInfo.entityObject)
                {
                    return(false);
                }

                return(bulletAttack.DefaultFilterCallback(ref hitInfo));
            };

            bulletAttack.hitCallback = (ref BulletHit hitInfo) =>
            {
                if (bulletAttack.owner == hitInfo.entityObject || bulletAttack.weapon == hitInfo.entityObject)
                {
                    return(false);
                }

                return(bulletAttack.DefaultHitCallback(ref hitInfo));
            };
        }
Exemple #20
0
            public static bool AltModeHitCallback(BulletAttack atk, ref BulletAttack.BulletHit hitInfo)
            {
                var retv = BulletAttack.DefaultHitCallbackImplementation(atk, ref hitInfo);

                if (!atk.owner)
                {
                    return(false);
                }
                if (!atk.owner.TryGetComponent <CommandoPrimaryPulseAltModeTracker>(out var tracker))
                {
                    tracker = atk.owner.AddComponent <CommandoPrimaryPulseAltModeTracker>();
                }
                if (hitInfo.hitHurtBox && hitInfo.hitHurtBox.healthComponent)
                {
                    tracker.OnHit(hitInfo.hitHurtBox.healthComponent.gameObject);
                }
                else
                {
                    tracker.OnHit(null);
                }
                return(retv);
            }
            private void ShootAtTarget()
            {
                FindTarget();
                //this.targetFinder.maxDistanceFilter = cfgWolfRadius.Value;
                this.targetFinder.RefreshCandidates();
                this.targetFinder.FilterOutGameObject(base.gameObject);

                var result = targetFinder.GetResults().FirstOrDefault <HurtBox>();

                if (result)
                {
                    BulletAttack bulletAttack = new BulletAttack()
                    {
                        aimVector          = characterMaster.GetBody().corePosition - result.healthComponent.body.corePosition,
                        bulletCount        = (uint)cfgChainsPelletCount.Value,
                        damage             = cfgChainsDamageCoefficient.Value * characterMaster.GetBody().damage,
                        damageType         = DamageType.Generic,
                        owner              = gameObject,
                        falloffModel       = BulletAttack.FalloffModel.Buckshot,
                        tracerEffectPrefab = EntityStates.CaptainDefenseMatrixItem.DefenseMatrixOn.tracerEffectPrefab
                    };
                    bulletAttack.Fire();
                }
            }
 public override void FireBullet(Ray aimRay)
 {
     base.StartAimMode(aimRay, 3f, false);
     this.DoFireEffects();
     this.PlayFireAnimation();
     base.AddRecoil(-1f * this.recoilAmplitudeY, -1.5f * this.recoilAmplitudeY, -1f * this.recoilAmplitudeX, 1f * this.recoilAmplitudeX);
     if (base.isAuthority)
     {
         Vector3 rhs  = Vector3.Cross(Vector3.up, aimRay.direction);
         Vector3 axis = Vector3.Cross(aimRay.direction, rhs);
         float   num  = 0f;
         if (base.characterBody)
         {
             num = base.characterBody.spreadBloomAngle;
         }
         float angle = 0f;
         float num2  = 0f;
         if (this.bulletCount > 1)
         {
             var accuracy = statsController.bulletAccuracy;
             num2 = UnityEngine.Random.Range(SimpleSpread(accuracy, this.minFixedSpreadYaw + num),
                                             SimpleSpread(accuracy, this.maxFixedSpreadYaw + num)) * 2f;
             angle = num2 / (float)(this.bulletCount - 1);
         }
         Vector3    direction = Quaternion.AngleAxis(-num2 * 0.5f, axis) * aimRay.direction;
         Quaternion rotation  = Quaternion.AngleAxis(angle, axis);
         Ray        aimRay2   = new Ray(aimRay.origin, direction);
         for (int i = 0; i < this.bulletCount; i++)
         {
             BulletAttack bulletAttack = base.GenerateBulletAttack(aimRay2);
             this.ModifyBullet(bulletAttack);
             bulletAttack.Fire();
             aimRay2.direction = rotation * aimRay2.direction;
         }
     }
 }
Exemple #23
0
 public override void ModifyBullet(BulletAttack bulletAttack)
 {
     base.ModifyBullet(bulletAttack);
     bulletAttack.stopperMask  = LayerIndex.world.mask;
     bulletAttack.falloffModel = BulletAttack.FalloffModel.None;
 }
        // Token: 0x06002E87 RID: 11911 RVA: 0x000C5B08 File Offset: 0x000C3D08
        private void FireBeamServer(Ray aimRay, GameObject tracerEffectPrefab, float maxDistance, bool isInitialBeam)
        {
            bool         didHit       = false;
            BulletAttack bulletAttack = new BulletAttack
            {
                origin                  = aimRay.origin,
                aimVector               = aimRay.direction,
                bulletCount             = 1U,
                damage                  = base.GetDamage() * FireMainBeamState.mainBeamDamageCoefficient,
                damageColorIndex        = DamageColorIndex.Item,
                damageType              = DamageType.Generic,
                falloffModel            = BulletAttack.FalloffModel.None,
                force                   = FireMainBeamState.mainBeamForce,
                hitEffectPrefab         = FireMainBeamState.mainBeamImpactEffect,
                HitEffectNormal         = false,
                hitMask                 = LayerIndex.entityPrecise.mask,
                isCrit                  = this.isCrit,
                maxDistance             = maxDistance,
                minSpread               = 0f,
                maxSpread               = 0f,
                muzzleName              = "",
                owner                   = base.ownerBody.gameObject,
                procChainMask           = default(ProcChainMask),
                procCoefficient         = FireMainBeamState.mainBeamProcCoefficient,
                queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
                radius                  = FireMainBeamState.mainBeamRadius,
                smartCollision          = true,
                sniper                  = false,
                spreadPitchScale        = 1f,
                spreadYawScale          = 1f,
                stopperMask             = LayerIndex.world.mask,
                tracerEffectPrefab      = (isInitialBeam ? tracerEffectPrefab : null),
                weapon                  = base.gameObject
            };
            TeamIndex teamIndex = base.ownerBody.teamComponent.teamIndex;

            bulletAttack.hitCallback = delegate(ref BulletAttack.BulletHit info)
            {
                bool flag = bulletAttack.DefaultHitCallback(ref info);
                if (!isInitialBeam)
                {
                    return(true);
                }
                if (flag)
                {
                    HealthComponent healthComponent = info.hitHurtBox ? info.hitHurtBox.healthComponent : null;
                    if (healthComponent && healthComponent.alive && info.hitHurtBox.teamIndex != teamIndex)
                    {
                        flag = false;
                    }
                }
                if (!flag)
                {
                    didHit = true;
                    this.beamHitPosition = info.point;
                }
                return(flag);
            };
            bulletAttack.Fire();
            if (!didHit)
            {
                RaycastHit raycastHit;
                if (Physics.Raycast(aimRay, out raycastHit, FireMainBeamState.mainBeamMaxDistance, LayerIndex.world.mask, QueryTriggerInteraction.Ignore))
                {
                    didHit = true;
                    this.beamHitPosition = raycastHit.point;
                }
                else
                {
                    this.beamHitPosition = aimRay.GetPoint(FireMainBeamState.mainBeamMaxDistance);
                }
            }
            if (didHit & isInitialBeam)
            {
                FireProjectileInfo fireProjectileInfo = default(FireProjectileInfo);
                fireProjectileInfo.projectilePrefab = FireMainBeamState.secondBombPrefab;
                fireProjectileInfo.owner            = base.ownerBody.gameObject;
                fireProjectileInfo.position         = this.beamHitPosition - aimRay.direction * 0.5f;
                fireProjectileInfo.rotation         = Quaternion.identity;
                fireProjectileInfo.damage           = base.GetDamage() * FireMainBeamState.secondBombDamageCoefficient;
                fireProjectileInfo.damageColorIndex = DamageColorIndex.Item;
                fireProjectileInfo.crit             = this.isCrit;
                ProjectileManager.instance.FireProjectile(fireProjectileInfo);
            }
            if (!isInitialBeam)
            {
                EffectData effectData = new EffectData
                {
                    origin = aimRay.origin,
                    start  = base.transform.position
                };
                effectData.SetNetworkedObjectReference(base.gameObject);
                EffectManager.SpawnEffect(tracerEffectPrefab, effectData, true);
            }
        }
Exemple #25
0
        private bool BulletAttack_ProcessHit(On.RoR2.BulletAttack.orig_ProcessHit orig, BulletAttack self, ref BulletAttack.BulletHit hitInfo)
        {
            var retv = orig(self, ref hitInfo);

            if (hitInfo.hitHurtBox && hitInfo.hitHurtBox.name != "TempHurtbox")
            {
                bulletAttackDidHit = true;
            }
            return(retv);
        }
 private void BulletAttack_Fire(On.RoR2.BulletAttack.orig_Fire orig, BulletAttack self)
 {
     self.damageType = ShockRoll(self.owner, self.damageType, self.procCoefficient);
     orig(self);
 }
 // Token: 0x06002CBF RID: 11455 RVA: 0x0000409B File Offset: 0x0000229B
 public override void ModifyBullet(BulletAttack bulletAttack)
 {
 }
Exemple #28
0
        private void FireServer(Ray aimRay)
        {
            bool            hasHit             = false;
            Vector3         hitPoint           = Vector3.zero;
            float           hitDistance        = 0f;
            HealthComponent hitHealthComponent = null;
            var             bulletAttack       = new BulletAttack
            {
                bulletCount             = 1,
                aimVector               = aimRay.direction,
                origin                  = aimRay.origin,
                damage                  = YokoShootRifle.damageCoefficient * this.damageStat,
                damageColorIndex        = DamageColorIndex.Default,
                damageType              = DamageType.Generic,
                falloffModel            = BulletAttack.FalloffModel.DefaultBullet,
                maxDistance             = YokoShootRifle.range,
                force                   = YokoShootRifle.force,
                hitMask                 = LayerIndex.CommonMasks.bullet,
                minSpread               = 0f,
                maxSpread               = 0f,
                isCrit                  = base.RollCrit(),
                owner                   = base.gameObject,
                muzzleName              = muzzleString,
                smartCollision          = false,
                procChainMask           = default(ProcChainMask),
                procCoefficient         = procCoefficient,
                radius                  = 0.75f,
                sniper                  = false,
                stopperMask             = LayerIndex.CommonMasks.bullet,
                weapon                  = null,
                tracerEffectPrefab      = Modules.Assets.yokoRifleBeamEffect,
                spreadPitchScale        = 0f,
                spreadYawScale          = 0f,
                queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
                hitEffectPrefab         = Modules.Assets.yokoRifleHitSmallEffect,
            };

            if (maxRicochetCount > 0 && bulletAttack.isCrit)
            {
                bulletAttack.hitCallback = delegate(BulletAttack bulletAttackRef, ref BulletHit hitInfo)
                {
                    var result = BulletAttack.defaultHitCallback(bulletAttackRef, ref hitInfo);
                    hasHit      = true;
                    hitPoint    = hitInfo.point;
                    hitDistance = hitInfo.distance;
                    if (hitInfo.hitHurtBox)
                    {
                        hitHealthComponent = hitInfo.hitHurtBox.healthComponent;
                    }
                    return(result);
                };
            }
            bulletAttack.filterCallback = delegate(BulletAttack bulletAttackRef, ref BulletAttack.BulletHit info)
            {
                return((!info.entityObject || info.entityObject != bulletAttack.owner) && BulletAttack.defaultFilterCallback(bulletAttackRef, ref info));
            };
            bulletAttack.Fire();
            if (hasHit)
            {
                this.Explode(hitPoint, bulletAttack.isCrit, (hitHealthComponent) ? hitHealthComponent.gameObject : null);
                if (hitHealthComponent != null)
                {
                    if (bulletAttack.isCrit)
                    {
                        CritRicochetOrb critRicochetOrb = new CritRicochetOrb();
                        critRicochetOrb.bouncesRemaining    = maxRicochetCount - 1;
                        critRicochetOrb.resetBouncedObjects = resetBouncedObjects;
                        critRicochetOrb.damageValue         = bulletAttack.damage;
                        critRicochetOrb.isCrit             = base.RollCrit();
                        critRicochetOrb.teamIndex          = TeamComponent.GetObjectTeam(base.gameObject);
                        critRicochetOrb.attacker           = base.gameObject;
                        critRicochetOrb.attackerBody       = base.characterBody;
                        critRicochetOrb.procCoefficient    = bulletAttack.procCoefficient;
                        critRicochetOrb.duration           = 0.1f;
                        critRicochetOrb.bouncedObjects     = new List <HealthComponent>();
                        critRicochetOrb.range              = Mathf.Max(30f, hitDistance);
                        critRicochetOrb.tracerEffectPrefab = Modules.Assets.yokoRifleBeamEffect;
                        critRicochetOrb.hitEffectPrefab    = Modules.Assets.yokoRifleHitSmallEffect;
                        critRicochetOrb.hitSoundString     = "TTGLTokoRifleCrit";
                        critRicochetOrb.origin             = hitPoint;
                        critRicochetOrb.bouncedObjects.Add(hitHealthComponent);
                        var nextTarget = critRicochetOrb.PickNextTarget(hitPoint);
                        if (nextTarget)
                        {
                            critRicochetOrb.target = nextTarget;
                            OrbManager.instance.AddOrb(critRicochetOrb);
                        }
                    }
                }
            }
        }
Exemple #29
0
        // Token: 0x060004AF RID: 1199 RVA: 0x000137A4 File Offset: 0x000119A4
        public override void OnEnter()
        {
            base.OnEnter();
            float num = 0f;

            if (base.skillLocator)
            {
                GenericSkill secondary = base.skillLocator.secondary;
                if (secondary)
                {
                    EntityStateMachine stateMachine = secondary.stateMachine;
                    if (stateMachine)
                    {
                        ScopeSniper scopeSniper = stateMachine.state as ScopeSniper;
                        if (scopeSniper != null)
                        {
                            num = scopeSniper.charge;
                            scopeSniper.charge = 0f;
                        }
                    }
                }
            }
            base.AddRecoil(-1f * FireRifle.recoilAmplitude, -2f * FireRifle.recoilAmplitude, -0.5f * FireRifle.recoilAmplitude, 0.5f * FireRifle.recoilAmplitude);
            this.duration = FireRifle.baseDuration / this.attackSpeedStat;
            Ray aimRay = base.GetAimRay();

            base.StartAimMode(aimRay, 2f, false);
            Util.PlaySound(FireRifle.attackSoundString, base.gameObject);
            base.PlayAnimation("Gesture", "FireShotgun", "FireShotgun.playbackRate", this.duration * 1.1f);
            string muzzleName = "MuzzleShotgun";

            if (FireRifle.effectPrefab)
            {
                EffectManager.instance.SimpleMuzzleFlash(FireRifle.effectPrefab, base.gameObject, muzzleName, false);
            }
            if (base.isAuthority)
            {
                BulletAttack bulletAttack = new BulletAttack();
                bulletAttack.owner              = base.gameObject;
                bulletAttack.weapon             = base.gameObject;
                bulletAttack.origin             = aimRay.origin;
                bulletAttack.aimVector          = aimRay.direction;
                bulletAttack.minSpread          = 0f;
                bulletAttack.maxSpread          = base.characterBody.spreadBloomAngle;
                bulletAttack.bulletCount        = (uint)((FireRifle.bulletCount > 0) ? FireRifle.bulletCount : 0);
                bulletAttack.procCoefficient    = 1f / (float)FireRifle.bulletCount;
                bulletAttack.damage             = Mathf.LerpUnclamped(FireRifle.minChargeDamageCoefficient, FireRifle.maxChargeDamageCoefficient, num) * this.damageStat / (float)FireRifle.bulletCount;
                bulletAttack.force              = Mathf.LerpUnclamped(FireRifle.minChargeForce, FireRifle.maxChargeForce, num);
                bulletAttack.falloffModel       = BulletAttack.FalloffModel.None;
                bulletAttack.tracerEffectPrefab = FireRifle.tracerEffectPrefab;
                bulletAttack.muzzleName         = muzzleName;
                bulletAttack.hitEffectPrefab    = FireRifle.hitEffectPrefab;
                bulletAttack.isCrit             = Util.CheckRoll(this.critStat, base.characterBody.master);
                if (num == 1f)
                {
                    bulletAttack.stopperMask = LayerIndex.world.mask;
                }
                bulletAttack.HitEffectNormal = false;
                bulletAttack.radius          = 0f;
                bulletAttack.sniper          = true;
                bulletAttack.Fire();
            }
            base.characterBody.AddSpreadBloom(FireRifle.spreadBloomValue);
        }
Exemple #30
0
        public override void OnEnter()
        {
            base.OnEnter();
            base.AddRecoil(-1f * Scatter.recoilAmplitude, -2f * Scatter.recoilAmplitude, -0.5f * Scatter.recoilAmplitude, 0.5f * Scatter.recoilAmplitude);

            this.maxDuration = Scatter.baseMaxDuration / this.attackSpeedStat;
            this.minDuration = Scatter.baseMinDuration / this.attackSpeedStat;
            Util.PlaySound(Scatter.attackSoundString, base.gameObject);
            base.characterBody.skillLocator.primary.rechargeStopwatch = 0f;
            if (!Scatter.noReload && base.characterBody.skillLocator.primary.stock == 0)
            {
                Util.PlaySound("Play_commando_M2_grenade_throw", base.gameObject);
            }

            Ray aimRay = base.GetAimRay();

            base.StartAimMode(aimRay, 2f, false);

            if (BanditReloaded.BanditReloaded.useOldModel)
            {
                base.PlayAnimation("Gesture, Additive", "FireShotgun", "FireShotgun.playbackRate", this.maxDuration * 0.8f);
                base.PlayAnimation("Gesture, Override", "FireShotgun", "FireShotgun.playbackRate", this.maxDuration * 0.8f);
            }
            else
            {
                base.PlayAnimation("Gesture, Additive", "FireMainWeapon", "FireMainWeapon.playbackRate", this.maxDuration);
            }

            string muzzleName = "MuzzleShotgun";

            if (Scatter.effectPrefab)
            {
                EffectManager.SimpleMuzzleFlash(Scatter.effectPrefab, base.gameObject, muzzleName, false);
            }
            if (base.isAuthority)
            {
                BulletAttack ba = new BulletAttack
                {
                    owner              = base.gameObject,
                    weapon             = base.gameObject,
                    origin             = aimRay.origin,
                    aimVector          = aimRay.direction,
                    minSpread          = 0f,
                    maxSpread          = Mathf.Max(Scatter.spreadBloomValue, base.characterBody.spreadBloomAngle),
                    bulletCount        = Scatter.pelletCount,
                    procCoefficient    = Scatter.procCoefficient,
                    damage             = Scatter.damageCoefficient * this.damageStat,
                    force              = Scatter.force,
                    falloffModel       = BulletAttack.FalloffModel.DefaultBullet,
                    tracerEffectPrefab = Scatter.tracerEffectPrefab,
                    muzzleName         = muzzleName,
                    hitEffectPrefab    = Scatter.hitEffectPrefab,
                    isCrit             = Util.CheckRoll(this.critStat, base.characterBody.master),
                    HitEffectNormal    = false,
                    radius             = Scatter.bulletRadius,
                    smartCollision     = true,
                    maxDistance        = Scatter.range,
                    stopperMask        = Scatter.penetrateEnemies ? LayerIndex.world.mask : LayerIndex.entityPrecise.mask
                };
                ba.Fire();
                base.characterBody.AddSpreadBloom(Scatter.spreadBloomValue);
            }
        }