Esempio n. 1
0
 private void MasterCatalog_Init(On.RoR2.MasterCatalog.orig_Init orig)
 {
     orig();
     EquipmentDroneMasterIndex = MasterCatalog.FindMasterIndex("EquipmentDroneMaster");
     //Debug.Log($"Equipment Drone MAster Index: {EquipmentDroneMasterIndex.i}");
     On.RoR2.MasterCatalog.Init -= MasterCatalog_Init;
 }
Esempio n. 2
0
 private void AssignMinion(CharacterMaster obj)
 {
     if (obj.masterIndex == MasterCatalog.FindMasterIndex("GurrenAllyMaster") &&
         obj.minionOwnership &&
         obj.minionOwnership.ownerMaster == this.owner)
     {
         gurrenMinion = obj;
     }
 }
Esempio n. 3
0
        public override void OnEnter()
        {
            base.OnEnter();
            base.characterBody.isSprinting = true;
            this.dashVector = -base.characterDirection.forward;

            Util.PlaySound("HenryStinger", base.gameObject);
            base.PlayAnimation("Gesture, Override", "BufferEmpty");

            base.gameObject.layer = LayerIndex.fakeActor.intVal;
            base.characterMotor.Motor.RebuildCollidableLayers();

            if (NetworkServer.active)
            {
                //base.characterBody.AddBuff(BuffIndex.HiddenInvincibility);

                CharacterMaster newCloneMaster = new MasterSummon
                {
                    masterPrefab          = MasterCatalog.GetMasterPrefab(MasterCatalog.FindMasterIndex("MrGreenCloneMaster")),
                    position              = base.transform.position,
                    rotation              = base.modelLocator.modelBaseTransform.rotation,
                    summonerBodyObject    = base.gameObject,
                    ignoreTeamMemberLimit = true
                }.Perform();

                Inventory inventory = newCloneMaster.inventory;
                inventory.CopyItemsFrom(base.characterBody.master.inventory);

                /*inventory.ResetItem(ItemIndex.WardOnLevel);
                 * inventory.ResetItem(ItemIndex.BeetleGland);
                 * inventory.ResetItem(ItemIndex.CrippleWardOnLevel);
                 * inventory.ResetItem(ItemIndex.TPHealingNova);
                 * inventory.ResetItem(ItemIndex.FocusConvergence);
                 * inventory.ResetItem(ItemIndex.TitanGoldDuringTP);*/

                var delayedDamage = newCloneMaster.gameObject.AddComponent <Modules.Components.DelayedDamageOnSpawn>();
                delayedDamage.attacker = this.attacker;
                delayedDamage.damage   = this.storedDamage;
                delayedDamage.tracker  = this.tracker;
            }
        }
            // Token: 0x06002C6E RID: 11374 RVA: 0x0002168E File Offset: 0x0001F88E
            public override void OnExit()
            {
                if (base.isAuthority)
                {
                    base.characterBody.SendConstructTurret(base.characterBody, base.characterBody.corePosition + (3f * Vector3.up), base.characterBody.gameObject.transform.rotation, MasterCatalog.FindMasterIndex("RoboBallMiniMaster"));
                }

                base.OnExit();
            }
Esempio n. 5
0
 // Token: 0x06003136 RID: 12598 RVA: 0x000D3F50 File Offset: 0x000D2150
 public override void FixedUpdate()
 {
     base.FixedUpdate();
     if (base.isAuthority)
     {
         this.entryCountdown -= Time.fixedDeltaTime;
         if (this.exitPending)
         {
             this.exitCountdown -= Time.fixedDeltaTime;
             if (this.exitCountdown <= 0f)
             {
                 this.outer.SetNextStateToMain();
                 return;
             }
         }
         else if (base.inputBank && this.entryCountdown <= 0f)
         {
             if ((base.inputBank.skill1.down || base.inputBank.skill4.justPressed) && this.currentPlacementInfo.ok)
             {
                 if (base.characterBody)
                 {
                     base.characterBody.SendConstructTurret(base.characterBody, this.currentPlacementInfo.position, this.currentPlacementInfo.rotation, MasterCatalog.FindMasterIndex(this.turretMasterPrefab));
                     if (base.skillLocator)
                     {
                         GenericSkill skill = base.skillLocator.GetSkill(SkillSlot.Special);
                         if (skill)
                         {
                             skill.DeductStock(1);
                         }
                     }
                 }
                 Util.PlaySound(this.placeSoundString, base.gameObject);
                 this.DestroyBlueprints();
                 this.exitPending = true;
             }
             if (base.inputBank.skill2.justPressed)
             {
                 this.DestroyBlueprints();
                 this.exitPending = true;
             }
         }
     }
 }
        public override void OnEnter()
        {
            base.OnEnter();

            base.characterBody.SendConstructTurret(base.characterBody, base.characterBody.corePosition + Vector3.up, Quaternion.identity, MasterCatalog.FindMasterIndex("RoboBallMiniMaster"));

            base.OnExit();
        }
        private bool PerformEquipmentActionInternal(EquipmentSlot slot)
        {
            var candidates = CharacterMaster.readOnlyInstancesList.Where(x => x.IsDeadAndOutOfLivesServer() && x.teamIndex == TeamIndex.Player);

            GameObject obj;
            GameObject podPrefab = LegacyResourcesAPI.Load <GameObject>("Prefabs/NetworkedObjects/RoboCratePod");

            var        nodeGraph = SceneInfo.instance.GetNodeGraph(MapNodeGroup.GraphType.Ground);
            var        nodeInd   = nodeGraph.FindClosestNodeWithFlagConditions(slot.transform.position, HullClassification.Human, NodeFlags.None, NodeFlags.None, false);
            Vector3    nodePos   = slot.transform.position;
            Quaternion nodeRot   = Quaternion.identity;

            if (nodeGraph.GetNodePosition(nodeInd, out nodePos))
            {
                var targPos = slot.transform.position;
                targPos.y = nodePos.y;
                nodeRot   = Util.QuaternionSafeLookRotation(nodePos - targPos);
            }

            if (candidates.Count() > 0)
            {
                var which   = rng.NextElementUniform(candidates.ToArray());
                var newBody = which.Respawn(nodePos, nodeRot);
                if (!newBody)
                {
                    return(false);
                }
                obj = newBody.gameObject;
                string rezTargetName = Language.GetString(newBody.baseNameToken);
                var    newBodyUser   = Util.LookUpBodyNetworkUser(newBody);
                if (newBodyUser)
                {
                    rezTargetName = newBodyUser.userName;
                }
                var rezzerName = slot.characterBody ? Language.GetString(slot.characterBody.baseNameToken) : "Someone";
                var rezzerUser = Util.LookUpBodyNetworkUser(slot.characterBody);
                if (rezzerUser)
                {
                    rezzerName = rezzerUser.userName;
                }
                NetUtil.ServerSendGlobalChatMsg($"{rezzerName} called down a clone of {rezTargetName}!");
            }
            else
            {
                var whichName  = rng.NextElementUniform(droneMasterPrefabNames.ToArray());
                var whichIndex = MasterCatalog.FindMasterIndex(whichName);
                var which      = MasterCatalog.GetMasterPrefab(whichIndex);
                if (!which)
                {
                    return(false);
                }
                var summon = new MasterSummon {
                    masterPrefab          = which,
                    position              = nodePos,
                    rotation              = nodeRot,
                    summonerBodyObject    = slot.characterBody ? slot.characterBody.gameObject : null,
                    ignoreTeamMemberLimit = true,
                    useAmbientLevel       = new bool?(true)
                }.Perform();
                if (!summon)
                {
                    return(false);
                }
                obj = summon.GetBodyObject();
                if (!obj)
                {
                    return(false);
                }
                if (obj.name == "EquipmentDroneBody(Clone)")
                {
                    var droneInv = obj.GetComponent <Inventory>();
                    if (droneInv)
                    {
                        var randomEqp = rng.NextElementUniform(RoR2.Artifacts.EnigmaArtifactManager.validEquipment);
                        droneInv.SetEquipment(new EquipmentState(randomEqp, Run.FixedTimeStamp.negativeInfinity, 1), 0);
                    }
                }
                else if (which == ItemDrone.instance.itemDroneMasterPrefab)
                {
                    var wardPersist = summon.GetComponent <ItemDroneWardPersist>();

                    var drops = LegacyResourcesAPI.Load <BasicPickupDropTable>("DropTables/dtSmallChest");
                    var drop  = drops.GenerateDrop(rng);
                    var pdef  = PickupCatalog.GetPickupDef(drop);
                    if (wardPersist && pdef != null && pdef.itemIndex != ItemIndex.None)
                    {
                        int remCount = 1;
                        if (pdef.itemTier == ItemTier.Tier2 || pdef.itemTier == ItemTier.VoidTier2)
                        {
                            remCount = 3;
                        }
                        if (pdef.itemTier == ItemTier.Tier1 || pdef.itemTier == ItemTier.VoidTier1)
                        {
                            remCount = 5;
                        }
                        wardPersist.index = pdef.itemIndex;
                        wardPersist.count = remCount;
                    }
                }
            }

            if (!obj)
            {
                return(false);
            }
            var objBody = obj.GetComponent <CharacterBody>();

            var podObj  = GameObject.Instantiate(podPrefab, nodePos, nodeRot);
            var podSeat = podObj.GetComponent <VehicleSeat>();

            if (podSeat)
            {
                podSeat.AssignPassenger(obj);
            }
            else
            {
                TinkersSatchelPlugin._logger.LogError($"Pod {podObj} spawned for revived prefab {obj} has no seat!");
            }
            NetworkServer.Spawn(podObj);
            objBody.SetBodyStateToPreferredInitialState();

            slot.inventory.SetEquipment(new EquipmentState(EquipmentIndex.None, Run.FixedTimeStamp.now + cooldown, 0), (uint)slot.inventory.activeEquipmentSlot);
            return(true);
        }
Esempio n. 8
0
        public override void OnEnter()
        {
            if (!Stage.instance.sceneDef.suppressNpcEntry)
            {
                base.OnEnter();

                Vector3 direction = base.GetAimRay().direction;

                base.characterBody.SendConstructTurret(base.characterBody, transform.position, Quaternion.Euler(direction), MasterCatalog.FindMasterIndex("Drone2Master"));

                base.OnExit();
            }
        }
Esempio n. 9
0
        public void Awake()
        {
            ReadConfig();
            On.RoR2.Run.Start += (orig, self) =>
            {
                orig(self);
                for (int i = 0; i < NextTitanSpawn.Length; i++)
                {
                    NextTitanSpawn[i] = -1f;
                    NextTitanKill[i]  = -1f;
                }
            };
            On.RoR2.Run.FixedUpdate += (orig, self) =>
            {
                orig(self);
                string scenename = SceneManager.GetActiveScene().name;
                if (scenename == "moon" || scenename == "moon2")
                {
                    for (int i = 0; i < NextTitanSpawn.Length; i++)
                    {
                        if (NextTitanSpawn[i] >= 0f)
                        {
                            if (NextTitanSpawn[i] <= Time.time)
                            {
                                if (i == 2)
                                {
                                    CreateTitanGoldCombatSquad((TeamIndex)i, BossSeedCount);
                                }
                                else
                                {
                                    CreateTitanGoldCombatSquad((TeamIndex)i, GetTeamSeedCount((TeamIndex)i));
                                }
                                NextTitanSpawn[i] = -1f;
                            }
                        }
                        if (NextTitanKill[i] >= 0f)
                        {
                            if (NextTitanKill[i] <= Time.time)
                            {
                                KillTitanSquad(TitanTeam[i]);
                                NextTitanKill[i] = -1f;
                            }
                        }
                    }
                }
            };

            On.EntityStates.Missions.BrotherEncounter.Phase1.OnEnter += (orig, self) =>
            {
                orig(self);
                if (Config_SpawnOnPhase.Value == 1)
                {
                    NextTitanSpawn[1] = Time.time + 5.0f;
                }
            };
            On.EntityStates.Missions.BrotherEncounter.Phase2.OnEnter += (orig, self) =>
            {
                orig(self);
                if (Config_SpawnOnPhase.Value == 2)
                {
                    NextTitanSpawn[1] = Time.time + 3.0f;
                }
            };
            On.EntityStates.Missions.BrotherEncounter.Phase3.OnEnter += (orig, self) =>
            {
                orig(self);
                if (Config_SpawnOnPhase.Value == 3)
                {
                    NextTitanSpawn[1] = Time.time + 5.0f;
                }
            };
            On.EntityStates.Missions.BrotherEncounter.Phase4.OnEnter += (orig, self) =>
            {
                orig(self);
                if (Config_KillOnSteal.Value)
                {
                    NextTitanKill[1] = Time.time + 7.5f;
                }
                if (Config_SpawnOnSteal.Value)
                {
                    BossSeedCount     = GetTeamSeedCount(TeamIndex.Player);
                    NextTitanSpawn[2] = Time.time + 12.0f;
                }
            };
            On.EntityStates.Missions.BrotherEncounter.EncounterFinished.OnEnter += (orig, self) =>
            {
                orig(self);
                for (int i = 0; i < NextTitanSpawn.Length; i++)
                {
                    NextTitanSpawn[i] = -1f;
                    NextTitanKill[i]  = Time.time + 2.5f;
                }
            };
            On.RoR2.GoldTitanManager.OnBossGroupStartServer += (orig, bossGroup) =>
            {
                bool        IsMithrix   = false;
                CombatSquad combatSquad = bossGroup.combatSquad;
                using (IEnumerator <CharacterMaster> enumerator = combatSquad.readOnlyMembersList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        if (enumerator.Current.masterIndex == MasterCatalog.FindMasterIndex("BrotherHurtMaster"))
                        {
                            IsMithrix = true;
                            break;
                        }
                    }
                }
                if (IsMithrix)
                {
                }
                else
                {
                    orig(bossGroup);
                }
            };
            int GetTeamSeedCount(TeamIndex team)
            {
                int SeedCount = 0;

                SeedCount = Util.GetItemCountForTeam(team, RoR2Content.Items.TitanGoldDuringTP.itemIndex, true, true);
                return(SeedCount);
            };
            void CreateTitanGoldCombatSquad(TeamIndex team, int SeedCount)
            {
                if (SeedCount > 0)
                {
                    CombatSquad combatSquad;
                    if (team == TeamIndex.Player)
                    {
                        combatSquad = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/Encounters/MonstersOnShrineUseEncounter")).GetComponent <CombatSquad>();
                    }
                    else
                    {
                        combatSquad = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/Encounters/ShadowCloneEncounter")).GetComponent <CombatSquad>();
                    }
                    int SpawnCount = 1;
                    //This is just here really.
                    //Like, swarms doesn't double aurelionite so this shouldn't be needed

                    /*if (RunArtifactManager.instance.IsArtifactEnabled(ArtifactCatalog.FindArtifactDef("Swarms")))
                     * {
                     *      if (Config_Debug.Value)
                     *      {
                     *              print("Doubled Aurelionite for Swarms");
                     *      }
                     * }*/
                    for (int i = 0; i < SpawnCount; i++)
                    {
                        Vector3         offsetpos = GetRandomSpawnPos();
                        CharacterMaster component = new MasterSummon
                        {
                            masterPrefab          = team == TeamIndex.Player ? TitanFriendly : TitanHostile,
                            position              = spawnposition + offsetpos,
                            summonerBodyObject    = null,
                            ignoreTeamMemberLimit = true,
                            teamIndexOverride     = team,
                        }.Perform();
                        AddTitanInventory(component, SeedCount);
                        combatSquad.AddMember(component);
                    }
                    if (combatSquad)
                    {
                        NetworkServer.Spawn(combatSquad.gameObject);
                        RegisterTitanSquad(combatSquad, team);
                    }
                }
            }

            Vector3 GetRandomSpawnPos()
            {
                Vector3 angle = new Vector3(1f, 1f, 1f);
                //Rotate the angle by a random degree
                float rotation = UnityEngine.Random.Range(0.0f, 360.0f);
                float x        = angle[0];
                float y        = angle[2];

                angle[1] = 0f;
                angle[0] = x * (float)Math.Cos(rotation) - y * (float)Math.Sin(rotation);
                angle[2] = x * (float)Math.Sin(rotation) + y * (float)Math.Cos(rotation);
                //Then normalize the angles
                angle  = Vector3.Normalize(angle);
                angle *= UnityEngine.Random.Range(20f, 40f);
                print(angle);
                return(angle);
            }

            void AddTitanInventory(CharacterMaster titan, int seeds)
            {
                float num  = 1f;
                float num2 = 1f;

                num  += Run.instance.difficultyCoefficient / 2f;
                num2 += Run.instance.difficultyCoefficient / 2f;
                num  *= Mathf.Pow((float)seeds, 1f);
                num2 *= Mathf.Pow((float)seeds, 0.5f);
                if (titan.teamIndex != TeamIndex.Player)
                {
                    num  = Mathf.Pow(num2, 0.5f);
                    num2 = Mathf.Pow(num2, 0.5f);
                }
                titan.inventory.GiveItem(RoR2Content.Items.BoostHp.itemIndex, Mathf.RoundToInt((num - 1f) * 10f));
                titan.inventory.GiveItem(RoR2Content.Items.BoostDamage.itemIndex, Mathf.RoundToInt((num2 - 1f) * 10f));
                if (Config_Debug.Value)
                {
                    print("Aurelionite spawned with " + (10 + Mathf.RoundToInt((num - 1f) * 10f)) * 10.0f + "% health.");
                    print("Aurelionite spawned with " + (10 + Mathf.RoundToInt((num2 - 1f) * 10f)) * 10.0f + "% damage.");
                }
            }

            void RegisterTitanSquad(CombatSquad combatSquad, TeamIndex team)
            {
                int slot = (int)team;

                if (slot >= 0 && slot <= TitanTeam.GetLength(0))
                {
                    KillTitanSquad(TitanTeam[slot]);
                    TitanTeam[slot] = combatSquad;
                }
            }

            void KillTitanSquad(CombatSquad combatSquad)
            {
                CharacterMaster[] HitList = new CharacterMaster[0];
                if (combatSquad)
                {
                    using (IEnumerator <CharacterMaster> enumerator = combatSquad.readOnlyMembersList.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            if (enumerator.Current)
                            {
                                if (enumerator.Current.GetBody())
                                {
                                    if (enumerator.Current.GetBody().healthComponent.alive)
                                    {
                                        Array.Resize <CharacterMaster>(ref HitList, HitList.Length + 1);
                                        HitList[HitList.Length - 1] = enumerator.Current;
                                    }
                                }
                            }
                        }
                    }
                }
                for (int i = 0; i < HitList.Length; i++)
                {
                    if (HitList[i])
                    {
                        HitList[i].TrueKill();
                    }
                }
            }
        }
 public override void FixedUpdate()
 {
     fixedAge += Time.fixedDeltaTime;
     if (!isAuthority)
     {
         return;
     }
     entryCountdown -= Time.fixedDeltaTime;
     if (exitPending)
     {
         exitCountdown -= Time.fixedDeltaTime;
         if (exitCountdown <= 0f)
         {
             outer.SetNextStateToMain();
         }
         return;
     }
     if (inputBank && entryCountdown <= 0f)
     {
         var deploy = (inputBank.skill1.down || inputBank.skill4.justPressed) && currentPlacementInfo.ok;
         var cancel = inputBank.skill2.justPressed;
         if (deploy || cancel)
         {
             if (characterBody && !cancel)
             {
                 new MsgConstructDispenser(characterBody, currentPlacementInfo.position, currentPlacementInfo.rotation, MasterCatalog.FindMasterIndex(turretMasterPrefab))
                 .Send(R2API.Networking.NetworkDestination.Server);
                 if (base.skillLocator)
                 {
                     var skill = skillLocator.GetSkill(SkillSlot.Utility);
                     if (skill)
                     {
                         skill.DeductStock(1);
                     }
                 }
                 Util.PlaySound(placeSoundString, gameObject);
             }
             DestroyBlueprints();
             exitPending = true;
         }
     }
 }