예제 #1
0
 private void AddEliteMaterials(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
 {
     if (self.HasBuff(EliteBuffIndex) && !self.GetComponent <HyperchargedBuffTracker>())
     {
         var modelLocator = self.modelLocator;
         if (modelLocator)
         {
             var modelTransform = self.modelLocator.modelTransform;
             if (modelTransform)
             {
                 var model = self.modelLocator.modelTransform.GetComponent <RoR2.CharacterModel>();
                 if (model)
                 {
                     var hyperchargedBuffTracker = self.gameObject.AddComponent <HyperchargedBuffTracker>();
                     hyperchargedBuffTracker.Body = self;
                     RoR2.TemporaryOverlay overlay = self.modelLocator.modelTransform.gameObject.AddComponent <RoR2.TemporaryOverlay>();
                     overlay.duration              = float.PositiveInfinity;
                     overlay.alphaCurve            = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
                     overlay.animateShaderAlpha    = true;
                     overlay.destroyComponentOnEnd = true;
                     overlay.originalMaterial      = EliteMaterial;
                     overlay.AddToCharacerModel(model);
                     hyperchargedBuffTracker.Overlay = overlay;
                 }
             }
         }
     }
     orig(self);
 }
예제 #2
0
        //private void GrantBaseShield(ILContext il)
        //{
        //    //Provided by Harb from their HarbCrate mod. Thanks Harb!
        //    ILCursor c = new ILCursor(il);
        //    int shieldsLoc = 33;
        //    c.GotoNext(
        //        MoveType.Before,
        //        x => x.MatchLdloc(out shieldsLoc),
        //        x => x.MatchCallvirt<CharacterBody>("set_maxShield")
        //    );
        //    c.Emit(OpCodes.Ldloc, shieldsLoc);
        //    c.EmitDelegate<Func<CharacterBody, float, float>>((self, shields) =>
        //    {
        //        var InventoryCount = GetCount(self);
        //        if (InventoryCount > 0)
        //        {
        //            shields += self.maxHealth * 0.04f;
        //        }
        //        return shields;
        //    });
        //    c.Emit(OpCodes.Stloc, shieldsLoc);
        //    c.Emit(OpCodes.Ldarg_0);
        //}

        private void ShieldedCoreValidator(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            orig(self);

            var shieldComponent = self.GetComponent <ShieldedCoreComponent>();

            if (!shieldComponent)
            {
                shieldComponent = self.gameObject.AddComponent <ShieldedCoreComponent>();
            }

            var newInventoryCount = GetCount(self);
            var IsShielded        = self.healthComponent.shield > 0 ? true : false;

            bool IsDifferent = false;

            if (shieldComponent.cachedInventoryCount != newInventoryCount)
            {
                IsDifferent = true;
                shieldComponent.cachedInventoryCount = newInventoryCount;
            }
            if (shieldComponent.cachedIsShielded != IsShielded)
            {
                IsDifferent = true;
                shieldComponent.cachedIsShielded = IsShielded;
            }

            if (!IsDifferent)
            {
                return;
            }

            self.statsDirty = true;
        }
예제 #3
0
        private void On_CBFixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            orig(self);
            var cpt = self.GetComponent <GoldenGunComponent>();

            if (!cpt)
            {
                return;
            }
            var newMoney = self.master?.money ?? 0;

            if (inclDeploys)
            {
                var dplc = self.GetComponent <Deployable>();
                if (dplc)
                {
                    newMoney += dplc.ownerMaster?.money ?? 0;
                }
            }
            if (cpt.cachedMoney != newMoney || cpt.cachedDiff != Run.instance.difficultyCoefficient)
            {
                cpt.cachedMoney = newMoney;
                cpt.cachedDiff  = Run.instance.difficultyCoefficient;
                UpdateGGBuff(self);
            }
        }
예제 #4
0
 private void CharacterBody_FixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
 {
     orig(self);
     if (stageRequirementMet && self == localUser.cachedBody && self.corePosition.y >= yThreshold && (!self.characterMotor || self.characterMotor.isGrounded))
     {
         Grant();
     }
 }
예제 #5
0
 private void BloodBookBleedManager(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
 {
     if (self.modelLocator && self.modelLocator.modelTransform && self.HasBuff(InsaneBloodBuff) && !self.GetComponent <InsaneBleed>())
     {
         var Meshes = BloodBook.ItemBodyModelPrefab.GetComponentsInChildren <MeshRenderer>();
         Meshes[0].gameObject.AddComponent <InsaneBleed>();
     }
 }
예제 #6
0
        private void SummonFriend(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            if (NetworkServer.active && self.master)
            {
                var LunarChimeraComponent = self.master.GetComponent <LunarChimeraComponent>();
                if (!LunarChimeraComponent)
                {
                    LunarChimeraComponent = self.masterObject.AddComponent <LunarChimeraComponent>();
                }

                var SummonerBodyMaster = self.master;
                if (SummonerBodyMaster) //Check if we're a minion or not. If we are, we don't summon a friend.
                {
                    if (SummonerBodyMaster.teamIndex == TeamIndex.Player && !self.isPlayerControlled)
                    {
                        orig(self);
                        return;
                    }
                }

                int InventoryCount = GetCount(self);
                if (InventoryCount > 0)
                {
                    if (LunarChimeraComponent.LastChimeraSpawned == null || !LunarChimeraComponent.LastChimeraSpawned.master || !LunarChimeraComponent.LastChimeraSpawned.master.hasBody)
                    {
                        LunarChimeraComponent.LastChimeraSpawned = null;
                        LunarChimeraComponent.ResummonCooldown  -= Time.fixedDeltaTime;
                        if (LunarChimeraComponent.ResummonCooldown <= 0f)
                        {
                            var minDistance = 10f;
                            var maxDistance = 20f;


                            MasterSummon masterSummon = new MasterSummon
                            {
                                masterPrefab = characterPrefab,
                                position     = self.transform.position + new Vector3(UnityEngine.Random.Range(minDistance, maxDistance),
                                                                                     5,
                                                                                     UnityEngine.Random.Range(minDistance, maxDistance)),
                                rotation              = self.transform.rotation,
                                summonerBodyObject    = self.gameObject,
                                ignoreTeamMemberLimit = true,
                                teamIndexOverride     = new TeamIndex?(TeamIndex.Player)
                            };
                            masterSummon.Perform();
                            RecentlySpawned = true;

                            if (RecentlySpawned)
                            {
                                LunarChimeraComponent.ResummonCooldown = lunarChimeraResummonCooldownDuration;
                                RecentlySpawned = false;
                            }
                        }
                    }
                }
            }
            orig(self);
        }
예제 #7
0
        private void CheckFrenzyBuff(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
        {
            var frenzyPotionTracker = self.GetComponent <FrenzyPotionTracker>();

            if (frenzyPotionTracker)
            {
                self.teamComponent.teamIndex = TeamIndex.None;
                self.master.teamIndex        = TeamIndex.None;
            }
        }
 private void On_CBFixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
 {
     orig(self);
     if (!self.characterMotor)
     {
         return;
     }
     if (GetCount(self) > 0 && self.inputBank.jump.down && (
             !PhotonJetpack.instance.enabled ||
             !ClassicItemsPlugin.globalConfig.coolYourJets ||
             (self.GetComponent <PhotonJetpackComponent>()?.fuel ?? 0f) <= 0f))
     {
         self.characterMotor.velocity.y -= Time.fixedDeltaTime * Physics.gravity.y * gravMod;
     }
 }
예제 #9
0
        private void ManageLightningStrikes(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
        {
            if (self.HasBuff(LightningStormBuffIndex))
            {
                var lightningTracker = self.GetComponent <LightningTracker>();
                if (!lightningTracker)
                {
                    lightningTracker = self.gameObject.AddComponent <LightningTracker>();
                }

                if (lightningTracker.LightningCooldown > 0)
                {
                    lightningTracker.LightningCooldown -= Time.fixedDeltaTime;
                }
                if (lightningTracker.LightningCooldown <= 0)
                {
                    for (int i = 1; i <= AmountOfLightningStrikesPerBarrage; i++)
                    {
                        var newProjectileInfo = new FireProjectileInfo
                        {
                            owner              = self.gameObject,
                            projectilePrefab   = HyperchargedProjectile,
                            speedOverride      = 150.0f,
                            damage             = self.damage,
                            damageTypeOverride = null,
                            damageColorIndex   = DamageColorIndex.Default,
                            procChainMask      = default
                        };
                        var theta           = (Math.PI * 2) / AmountOfLightningStrikesPerBarrage;
                        var angle           = theta * i;
                        var radius          = 20 + random.RangeFloat(-15, 15);
                        var positionChosen  = new Vector3((float)(radius * Math.Cos(angle) + self.corePosition.x), self.corePosition.y + 1, (float)(radius * Math.Sin(angle) + self.corePosition.z));
                        var raycastedChosen = MiscUtils.RaycastToFloor(positionChosen, 1000f);
                        if (raycastedChosen != null)
                        {
                            positionChosen = raycastedChosen.Value + new Vector3(0, 0.5f, 0);
                        }
                        newProjectileInfo.position = positionChosen;
                        newProjectileInfo.rotation = RoR2.Util.QuaternionSafeLookRotation(positionChosen + Vector3.down);
                        ProjectileManager.instance.FireProjectile(newProjectileInfo);
                    }
                    lightningTracker.LightningCooldown = LightningStrikeCooldown;
                }
            }
            orig(self);
        }
예제 #10
0
        private void TickDamage(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
        {
            orig(self);

            var bleedComponent = self.GetComponent <BleedTrackerComponent>();

            if (!bleedComponent)
            {
                bleedComponent = self.gameObject.AddComponent <BleedTrackerComponent>();
            }

            foreach (BleedStack stack in bleedComponent.BleedStacks)
            {
                stack.FixedUpdate(self);
            }
            bleedComponent.BleedStacks.RemoveAll(x => x.TicksLeft <= 0);
        }
 private void CharacterBody_FixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
 {
     orig(self);
     if (IsVampire.Value && GetPlayer(self) != null)
     {
         var health = self.healthComponent.health;
         if (degenerating && health <= DegenerationThreshold.Value)
         {
             degenerating = false;
             self.RecalculateStats();
         }
         if (!degenerating && health > DegenerationThreshold.Value)
         {
             degenerating = true;
             self.RecalculateStats();
         }
     }
 }
예제 #12
0
        private void AddTrackerToBodies(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
        {
            var slot = self.equipmentSlot;

            if (slot)
            {
                if (slot.equipmentIndex == equipmentDef.equipmentIndex)
                {
                    var bulletTracker = self.GetComponent <JarBulletTracker>();
                    if (!bulletTracker)
                    {
                        bulletTracker      = self.gameObject.AddComponent <JarBulletTracker>();
                        bulletTracker.body = self;
                    }
                }
            }
            orig(self);
        }
예제 #13
0
 private void VoidheartOverlayManager(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
 {
     if (self.modelLocator && self.modelLocator.modelTransform && self.HasBuff(VoidInstabilityDebuff) && !self.GetComponent <VoidheartCooldown>())
     {
         var Meshes = Voidheart.ItemBodyModelPrefab.GetComponentsInChildren <MeshRenderer>();
         RoR2.TemporaryOverlay overlay = self.modelLocator.modelTransform.gameObject.AddComponent <RoR2.TemporaryOverlay>();
         overlay.duration              = voidHeartCooldownDebuffDuration;
         overlay.alphaCurve            = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
         overlay.animateShaderAlpha    = true;
         overlay.destroyComponentOnEnd = true;
         overlay.originalMaterial      = Meshes[0].material;
         overlay.AddToCharacerModel(self.modelLocator.modelTransform.GetComponent <RoR2.CharacterModel>());
         var VoidheartCooldownTracker = self.gameObject.AddComponent <Voidheart.VoidheartCooldown>();
         VoidheartCooldownTracker.Overlay = overlay;
         VoidheartCooldownTracker.Body    = self;
     }
     orig(self);
 }
예제 #14
0
 private void CharacterBody_FixedUpdate_PerformanceMode(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
 {
     orig(self);
     if (NetworkServer.active)
     {
         if (preventMoneyDrops)
         {
             return;
         }
         int doshCount = self.GetBuffCount(DoshContent.pendingDoshBuff);
         if (doshCount > 0)
         {
             self.ClearTimedBuffs(DoshContent.pendingDoshBuff);
             if (self.master)
             {
                 ReleaseMoney(self.master, doshCount);
             }
         }
     }
 }
예제 #15
0
 private void CharacterBody_FixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
 {
     orig(self);
     if (!self || self != localUser.cachedBody)
     {
         return;
     }
     stopwatch -= Time.fixedDeltaTime;
     if (stopwatch <= 0f)
     {
         stopwatch = 0.5f;
         var mdt = self.GetComponent <MoustacheDamageTracker>();
         if (!mdt)
         {
             mdt = self.gameObject.AddComponent <MoustacheDamageTracker>();
         }
         if (mdt.lastEnemyScoreTracked >= 30f)
         {
             Grant();
         }
     }
 }
예제 #16
0
        private void ForceFeedPotion(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
        {
            if (NetworkServer.active)
            {
                var InventoryCount = GetCount(self);
                if (InventoryCount > 0)
                {
                    if (!self.HasBuff(AccursedPotionSipCooldownDebuff) && self.activeBuffsListCount <= maxEffectsAccrued)
                    {
                        BuffIndex ChosenBuff = RoR2.BuffCatalog.buffDefs[random.RangeInt(0, RoR2.BuffCatalog.buffCount - 1)].buffIndex;
                        if (RoR2.BuffCatalog.GetBuffDef(ChosenBuff).iconPath != null && ChosenBuff != BuffIndex.Immune && ChosenBuff != BuffIndex.HiddenInvincibility)
                        {
                            var BuffCount = RoR2.BuffCatalog.GetBuffDef(ChosenBuff).canStack ? InventoryCount : 1;

                            var            randomEffectDuration = random.RangeFloat(10, 20);
                            RoR2.TeamMask  enemyTeams           = RoR2.TeamMask.GetEnemyTeams(self.teamComponent.teamIndex);
                            RoR2.HurtBox[] hurtBoxes            = new RoR2.SphereSearch
                            {
                                radius = baseRadiusGranted + (additionalRadiusGranted * (InventoryCount - 1)),
                                mask   = RoR2.LayerIndex.entityPrecise.mask,
                                origin = self.corePosition
                            }.RefreshCandidates().FilterCandidatesByHurtBoxTeam(enemyTeams).OrderCandidatesByDistance().FilterCandidatesByDistinctHurtBoxEntities().GetHurtBoxes();

                            for (int i = 0; i < hurtBoxes.Length; i++)
                            {
                                var body = hurtBoxes[i].healthComponent.body;
                                if (body)
                                {
                                    AddBuffAndDot(ChosenBuff, randomEffectDuration, BuffCount, body);
                                }
                            }
                            AddBuffAndDot(AccursedPotionSipCooldownDebuff, baseSipCooldownDuration * (float)Math.Pow(additionalStackSipCooldownReductionPercentage, InventoryCount - 1), 1, self);
                            AddBuffAndDot(ChosenBuff, randomEffectDuration, BuffCount, self);
                        }
                    }
                }
            }
            orig(self);
        }
예제 #17
0
        private void UpdateDebuffPulse(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody body)
        {
            orig(body);

            var component      = body.GetComponentInChildren <DebuffPulse>()?.gameObject;
            var InventoryCount = GetCount(body);

            if (InventoryCount <= 0 || body.outOfCombat) //This is going to run constantly what the f**k is this ok?
            {
                if (component)
                {
#if DEBUG
                    TurboEdition._logger.LogWarning("Player has either zero items or out of combat, destroying component.");
#endif
                    UnityEngine.Object.Destroy(component);
                }
            }
            else
            {
                if (!component)
                {
#if DEBUG
                    TurboEdition._logger.LogWarning("Player does not have a component, creating one.");
#endif
                    //fixedTime = Run.FixedTimeStamp.now; //I forgot why im using this

                    component = UnityEngine.Object.Instantiate(debuffPulsePrefab);
                    component.GetComponent <TeamFilter>().teamIndex = body.teamComponent.teamIndex;
                    component.GetComponent <DebuffPulse>().owner    = body.gameObject;
                    component.GetComponent <NetworkedBodyAttachment>().AttachToGameObjectAndSpawn(body.gameObject);
                }
#if DEBUG
                TurboEdition._logger.LogWarning("Updating component properties.");
#endif
                component.GetComponent <DebuffPulse>().netRadius   = baseRadius + (InventoryCount - 1) * stackRadius;
                component.GetComponent <DebuffPulse>().netPulse    = InventoryCount * stackPulse;
                component.GetComponent <DebuffPulse>().netDuration = pulseDuration;
            }
        }
예제 #18
0
        private void CharacterBody_FixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            if (self && self.skillLocator.secondary && self.skillLocator.special && self.baseNameToken == "DG_SAMUS_NAME")
            {
                if (!SkillStates.BaseStates.BaseSamus.morphBall)
                {
                    if (self.skillLocator.secondary.stock >= 5)
                    {
                        self.skillLocator.special.stock = 1;
                    }
                    else
                    {
                        self.skillLocator.special.RemoveAllStocks();
                    }
                }

                //Debug.Log("test");
            }



            orig(self);
        }
예제 #19
0
 private void CharacterBody_FixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
 {
     orig(self);
     if (NetworkServer.active)
     {
         if (preventMoneyDrops)
         {
             return;
         }
         int doshCount = Mathf.Min(self.GetBuffCount(DoshContent.pendingDoshBuff.buffIndex), 8);    //Can queue up to 8
         if (doshCount > 0)
         {
             self.ClearTimedBuffs(DoshContent.pendingDoshBuff.buffIndex);
             if (self.master)
             {
                 for (int i = 0; i < doshCount; i++)
                 {
                     ReleaseMoney(self.master);
                 }
             }
         }
     }
 }
예제 #20
0
        private void ApplyBuffAsIndicatorForReady(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
        {
            var InventoryCount = GetCount(self);

            if (InventoryCount > 0)
            {
                if (self.healthComponent.combinedHealthFraction >= 1 && !self.HasBuff(BlasterSwordActiveBuff))
                {
                    self.AddBuff(BlasterSwordActiveBuff);
                }
                if (self.healthComponent.combinedHealthFraction < 1 && self.HasBuff(BlasterSwordActiveBuff))
                {
                    self.RemoveBuff(BlasterSwordActiveBuff);
                }
            }
            else
            {
                if (self.HasBuff(BlasterSwordActiveBuff))
                {
                    self.RemoveBuff(BlasterSwordActiveBuff);
                }
            }
            orig(self);
        }
예제 #21
0
        ////// Hooks //////

        private void On_CBFixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            orig(self);
            UpdateGGBuff(self);
        }
예제 #22
0
 private void ApplyWeightToVictims(On.RoR2.CharacterBody.orig_FixedUpdate orig, RoR2.CharacterBody self)
 {
 }
예제 #23
0
        private void CharacterBody_FixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            orig(self);
            if (!NetworkServer.active || !self)
            {
                return;
            }
            var cpt = self.gameObject.GetComponent <HeadsetComponent>();

            if (!cpt)
            {
                cpt = self.gameObject.AddComponent <HeadsetComponent>();
            }
            var count = GetCount(self);

            if (count <= 0)
            {
                cpt.hitsRemaining = 0;
            }
            else if (cpt.hitsRemaining > 0)
            {
                var atkTeam = TeamComponent.GetObjectTeam(self.gameObject);
                var p1      = cpt.previousPos;
                var p2      = self.transform.position;

                Collider[] res;
                if (p1 == p2)
                {
                    res = Physics.OverlapSphere(p1, HITBOX_RADIUS, LayerIndex.entityPrecise.mask, QueryTriggerInteraction.Ignore);
                }
                else
                {
                    res = Physics.OverlapCapsule(p1, p2, HITBOX_RADIUS, LayerIndex.entityPrecise.mask, QueryTriggerInteraction.Ignore);
                }

                var damageInfo = new DamageInfo {
                    attacker         = self.gameObject,
                    inflictor        = self.gameObject,
                    crit             = false,
                    damage           = self.damage * (baseDamagePct + stackDamagePct * (count - 1)),
                    damageColorIndex = DamageColorIndex.Item,
                    damageType       = DamageType.Generic,
                    force            = Vector3.zero,
                    procCoefficient  = 1f
                };

                foreach (var hit in res)
                {
                    if (!hit)
                    {
                        continue;
                    }
                    var hurtbox = hit.GetComponent <HurtBox>();
                    if (!hurtbox ||
                        !hurtbox.healthComponent ||
                        hurtbox.healthComponent == self.healthComponent ||
                        !FriendlyFireManager.ShouldSplashHitProceed(hurtbox.healthComponent, atkTeam))
                    {
                        continue;
                    }
                    var icd = hurtbox.healthComponent.gameObject.GetComponent <HeadsetICDComponent>();
                    if (!icd)
                    {
                        icd = hurtbox.healthComponent.gameObject.AddComponent <HeadsetICDComponent>();
                    }
                    if (Time.fixedTime - icd.lastHit < HIT_INTERVAL)
                    {
                        continue;
                    }
                    icd.lastHit = Time.fixedTime;

                    damageInfo.position = hit.transform.position;
                    hurtbox.healthComponent.TakeDamage(damageInfo);
                    var ssoh = hurtbox.healthComponent.GetComponent <SetStateOnHurt>();
                    if (ssoh && ssoh.canBeStunned)
                    {
                        ssoh.SetStun(stunDuration);
                    }

                    cpt.hitsRemaining--;
                    if (cpt.hitsRemaining <= 0)
                    {
                        break;
                    }
                }

                cpt.previousPos = p2;
            }

            int currBuffStacks = self.GetBuffCount(headsetBuff);

            if (cpt.hitsRemaining != currBuffStacks)
            {
                self.SetBuffCount(headsetBuff.buffIndex, cpt.hitsRemaining);
            }
        }
예제 #24
0
        private void On_CBFixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            orig(self);

            var cpt = self.GetComponent <PhotonJetpackComponent>();

            if (!self.characterMotor || !cpt || cpt.fuelCap == 0)
            {
                return;
            }

            uint oldstate = cpt.flyState;
            uint newstate = oldstate;

            bool jumpDn            = self.inputBank.jump.down;
            bool isGrounded        = self.characterMotor.isGrounded;
            bool hasJumps          = self.characterMotor.jumpCount < self.maxJumpCount;
            bool isJumpIndependent = extraJumpInteraction != ExtraJumpInteractionType.UseJumpsFirst;

            if (isGrounded || (hasJumps && !isJumpIndependent))
            {
                newstate = 0;
            }
            else if (!hasJumps || isJumpIndependent)
            {
                if (jumpDn && oldstate == 0)
                {
                    newstate = 1;
                }
                if (!jumpDn && oldstate == 1)
                {
                    newstate = 2;
                }
            }

            if (newstate == 2 && jumpDn)
            {
                if (cpt.fuel > 0.0f)
                {
                    cpt.cooldown = rchDelay;
                    cpt.fuel    -= Time.fixedDeltaTime;
                    self.characterMotor.velocity.y -= Time.fixedDeltaTime * Physics.gravity.y
                                                      * (gravMod + ((self.characterMotor.velocity.y < 0) ? fallBoost : 0f));
                }
                if (cpt.fuel <= 0.0f)
                {
                    newstate = 1;
                }
            }
            else
            {
                cpt.cooldown -= Time.fixedDeltaTime;
                if (cpt.cooldown < 0.0f)
                {
                    cpt.fuel = Mathf.Min(cpt.fuel + rchRate * Time.fixedDeltaTime, cpt.fuelCap);
                }
            }

            cpt.flyState = newstate;

            int tgtFuelStacks  = Mathf.CeilToInt(cpt.fuel / cpt.fuelCap * 100f);
            int currFuelStacks = self.GetBuffCount(photonFuelBuff);

            if (tgtFuelStacks != currFuelStacks)
            {
                self.SetBuffCount(photonFuelBuff.buffIndex, tgtFuelStacks);
            }
        }
예제 #25
0
        private void On_CBFixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            orig(self);

            var cpt = self.GetComponent <PhotonJetpackComponent>();

            if (!self.characterMotor || !cpt || cpt.fuelCap == 0)
            {
                return;
            }

            uint oldstate = cpt.flyState;

            //0: on ground, or midair with jumps remaining
            //1: in air, no jumps remaining, space is held from last jump/from running out of fuel
            //2: in air, no jumps remaining, space may be held but has been released at least once since the last state=1

            bool jumpDn     = self.inputBank.jump.down;
            bool hasJumps   = self.characterMotor.jumpCount < self.maxJumpCount;
            bool isGrounded = self.characterMotor.isGrounded;

            uint newstate = oldstate;

            if (isGrounded || hasJumps)
            {
                newstate = 0;
            }
            else if (!hasJumps)
            {
                if (jumpDn && oldstate == 0)
                {
                    newstate = 1;
                }
                if (!jumpDn && oldstate == 1)
                {
                    newstate = 2;
                }
            }

            //float photonFuelCap = cpt.fuelCap;

            if (newstate == 2 && jumpDn)
            {
                //float fuel = (float)cPl.VGet(self, "photonJetpackFuel", 0.0f);
                if (cpt.fuel > 0.0f)
                {
                    cpt.cooldown = rchDelay;
                    cpt.fuel    -= Time.fixedDeltaTime;
                    self.characterMotor.velocity.y -= Time.fixedDeltaTime * Physics.gravity.y
                                                      * (gravMod + ((self.characterMotor.velocity.y < 0) ? fallBoost : 0f));
                }
                if (cpt.fuel <= 0.0f)
                {
                    newstate = 1;
                }
            }
            else
            {
                cpt.cooldown -= Time.fixedDeltaTime;
                if (cpt.cooldown < 0.0f)
                {
                    cpt.fuel = Mathf.Min(cpt.fuel + rchRate * Time.fixedDeltaTime, cpt.fuelCap);
                }
            }

            cpt.flyState = newstate;

            int tgtFuelStacks  = Mathf.CeilToInt(cpt.fuel / cpt.fuelCap * 100f);
            int currFuelStacks = self.GetBuffCount(photonFuelBuff);

            if (tgtFuelStacks != currFuelStacks)
            {
                self.SetBuffCount(photonFuelBuff, tgtFuelStacks);
            }
        }
예제 #26
0
        private void SummonLunarChimera(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            int             inventoryCount = GetCount(self);
            CharacterMaster master         = self.master;

            if (NetworkServer.active && inventoryCount > 0 && master && !IsMinion(master)) //Check if we're a minion or not. If we are, we don't summon a chimera.
            {
                LunarChimeraComponent lcComponent = LunarChimeraComponent.GetOrCreateComponent(master);
                if (!lcComponent.LastChimeraSpawned || !lcComponent.LastChimeraSpawned.master || !lcComponent.LastChimeraSpawned.master.hasBody)
                {
                    lcComponent.LastChimeraSpawned = null;
                    lcComponent.ResummonCooldown  -= Time.fixedDeltaTime;
                    if (lcComponent.ResummonCooldown <= 0f && SceneCatalog.mostRecentSceneDef != SceneCatalog.GetSceneDefFromSceneName("bazaar"))
                    {
                        DirectorPlacementRule placeRule = new DirectorPlacementRule
                        {
                            placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                            minDistance   = 10f,
                            maxDistance   = 40f,
                            spawnOnTarget = self.transform
                        };
                        DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest(lunarChimeraSpawnCard, placeRule, RoR2Application.rng)
                        {
                            teamIndexOverride = TeamIndex.Player
                                                //summonerBodyObject = self.gameObject
                        };
                        GameObject gameObject = DirectorCore.instance.TrySpawnObject(directorSpawnRequest);
                        if (gameObject)
                        {
                            CharacterMaster cMaster = gameObject.GetComponent <CharacterMaster>();
                            if (cMaster)
                            {
                                //RoR2.Chat.AddMessage($"Character Master Found: {component}");
                                cMaster.teamIndex = TeamIndex.Neutral;
                                cMaster.inventory.GiveItem(ItemIndex.BoostDamage, lunarChimeraBaseDamageBoost + (lunarChimeraAdditionalDamageBoost * inventoryCount - 1));
                                cMaster.inventory.GiveItem(ItemIndex.BoostHp, lunarChimeraBaseHPBoost * inventoryCount);
                                cMaster.inventory.GiveItem(ItemIndex.BoostAttackSpeed, lunarChimeraBaseAttackSpeedBoost);
                                cMaster.inventory.GiveItem(ItemIndex.Hoof, lunarChimeraBaseMovementSpeedBoost * inventoryCount);
                                cMaster.minionOwnership.SetOwner(master);

                                CharacterBody cBody = cMaster.GetBody();
                                if (cBody)
                                {
                                    //RoR2.Chat.AddMessage($"CharacterBody Found: {component4}");
                                    cBody.teamComponent.teamIndex = TeamIndex.Neutral;
                                    cBody.gameObject.AddComponent <LunarChimeraRetargetComponent>();
                                    lcComponent.LastChimeraSpawned = cBody;
                                    DeathRewards deathRewards = cBody.GetComponent <DeathRewards>();
                                    if (deathRewards)
                                    {
                                        //RoR2.Chat.AddMessage($"DeathRewards Found: {component5}");
                                        deathRewards.goldReward = 0;
                                        deathRewards.expReward  = 0;
                                    }
                                    NetworkIdentity bodyNet = cBody.GetComponent <NetworkIdentity>();
                                    if (bodyNet)
                                    {
                                        new AssignOwner(lcComponent.netId, bodyNet.netId).Send(NetworkDestination.Clients);
                                    }
                                }
                            }
                            lcComponent.ResummonCooldown = lunarChimeraResummonCooldownDuration;
                        }
                    }
                }
            }
            orig(self);
        }