Пример #1
0
        // Copy from TeleporterHelper, but uses a different strategy so they don't spawn on top of the person
        public static Vector3?FindSafeTeleportDestination(Vector3 characterFootPosition, CharacterBody characterBodyOrPrefabComponent, Xoroshiro128Plus rng)
        {
            Vector3?  result    = null;
            SpawnCard spawnCard = ScriptableObject.CreateInstance <SpawnCard>();

            spawnCard.hullSize = characterBodyOrPrefabComponent.hullClassification;
            //spawnCard.nodeGraphType = MapNodeGroup.GraphType.Ground;
            spawnCard.prefab = Resources.Load <GameObject>("SpawnCards/HelperPrefab");
            DirectorPlacementRule placementRule = new DirectorPlacementRule
            {
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                position      = characterFootPosition
            };

            DirectorCore.GetMonsterSpawnDistance(DirectorCore.MonsterSpawnDistance.Close,
                                                 out placementRule.minDistance, out placementRule.maxDistance);
            GameObject gameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(spawnCard, placementRule, rng));

            if (gameObject)
            {
                result = new Vector3?(gameObject.transform.position);
                Destroy(gameObject);
            }
            Destroy(spawnCard);
            return(result);
        }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        float xPos = 0F;
        float yPos = 0F;

        float scale = 0.25F;
        float xOffset = scale * 10F;
        //float rotation = 6F;

        int handId = 0;
        List<Card> hand = new List<Card>();
        hand = CollectionLoader.LoadCollection();

        for(int i = 0; i < 3; i++)
        {
            Card card = hand[i];
            GameObject cardClone = Instantiate(cardPrefab, new Vector3 (0F, 0F, 0F), Quaternion.Euler (0, 0, 0)) as GameObject;

            SpawnCard SpawnCard = new SpawnCard();

            SpawnCard.CreateCard(cardClone, card, manaPrefab);
            cardClone.name = handId.ToString();
            cardClone.transform.parent = transform;
            cardClone.transform.localPosition = new Vector3 (xPos, yPos, (float)-handId);
            cardClone.transform.localScale = new Vector3 (scale, scale, 0.5F);

            xPos += xOffset;
            handId += 1;
        }
    }
Пример #3
0
        // Token: 0x06003156 RID: 12630 RVA: 0x000D45DC File Offset: 0x000D27DC
        public virtual void OnImpactServer(Vector3 contactPoint)
        {
            string text = BodyCatalog.GetBodyName(base.characterBody.bodyIndex);

            text = text.Replace("Body", "");
            text = "iscBroken" + text;
            SpawnCard spawnCard = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/" + text);

            if (spawnCard != null)
            {
                DirectorPlacementRule placementRule = new DirectorPlacementRule
                {
                    placementMode = DirectorPlacementRule.PlacementMode.Direct,
                    position      = contactPoint
                };
                GameObject gameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(spawnCard, placementRule, new Xoroshiro128Plus(0UL)));
                if (gameObject)
                {
                    PurchaseInteraction component = gameObject.GetComponent <PurchaseInteraction>();
                    if (component && component.costType == CostTypeIndex.Money)
                    {
                        component.Networkcost = Run.instance.GetDifficultyScaledCost(component.cost);
                    }
                }
            }
        }
Пример #4
0
 private void TeleportCharacter(CharacterBody characterBody)
 {
     if (!Physics.GetIgnoreLayerCollision(base.gameObject.layer, characterBody.gameObject.layer))
     {
         SpawnCard spawnCard = ScriptableObject.CreateInstance<SpawnCard>();
         spawnCard.hullSize = characterBody.hullClassification;
         spawnCard.nodeGraphType = MapNodeGroup.GraphType.Ground;
         spawnCard.prefab = Resources.Load<GameObject>("SpawnCards/HelperPrefab");
         GameObject gameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(spawnCard, new DirectorPlacementRule
         {
             placementMode = DirectorPlacementRule.PlacementMode.NearestNode,
             position = characterBody.transform.position
         }, RoR2Application.rng));
         if (gameObject)
         {
             Debug.Log("tp back");
             TeleportHelper.TeleportBody(characterBody, gameObject.transform.position);
             GameObject teleportEffectPrefab = Run.instance.GetTeleportEffectPrefab(characterBody.gameObject);
             if (teleportEffectPrefab)
             {
                 EffectManager.instance.SimpleEffect(teleportEffectPrefab, gameObject.transform.position, Quaternion.identity, true);
             }
             UnityEngine.Object.Destroy(gameObject);
         }
         UnityEngine.Object.Destroy(spawnCard);
     }
 }
Пример #5
0
 public override void OnEnter()
 {
     attackSoundString = SummonEggs.attackSoundString;
     spitPrefab        = SummonEggs.spitPrefab;
     guardSpawnCard    = SummonEggs.spawnCard;
     base.OnEnter();
     animator       = GetModelAnimator();
     modelTransform = GetModelTransform();
     childLocator   = modelTransform.GetComponent <ChildLocator>();
     duration       = baseDuration;
     PlayCrossfade("Gesture", "SummonEggs", 0.5f);
     Util.PlaySound(attackSoundString, base.gameObject);
     if (NetworkServer.active)
     {
         enemySearch = new BullseyeSearch();
         enemySearch.filterByDistinctEntity = false;
         enemySearch.filterByLoS            = false;
         enemySearch.maxDistanceFilter      = float.PositiveInfinity;
         enemySearch.minDistanceFilter      = 0f;
         enemySearch.minAngleFilter         = 0f;
         enemySearch.maxAngleFilter         = 180f;
         enemySearch.teamMaskFilter         = TeamMask.GetEnemyTeams(GetTeam());
         enemySearch.sortMode = BullseyeSearch.SortMode.Distance;
         enemySearch.viewer   = base.characterBody;
     }
 }
Пример #6
0
            private bool TeleportBody(Vector3 desiredPosition, GraphType nodeGraphType)
            {
                SpawnCard spawnCard = ScriptableObject.CreateInstance <SpawnCard>();

                spawnCard.hullSize      = BotBody.hullClassification;
                spawnCard.nodeGraphType = nodeGraphType;
                spawnCard.prefab        = Resources.Load <GameObject>("SpawnCards/HelperPrefab");
                GameObject gameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(spawnCard, new DirectorPlacementRule
                {
                    placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                    position      = desiredPosition,
                    minDistance   = 20,
                    maxDistance   = 45
                }, RoR2Application.rng));

                if (gameObject)
                {
                    TeleportHelper.TeleportBody(BotBody, gameObject.transform.position);
                    GameObject teleportEffectPrefab = Run.instance.GetTeleportEffectPrefab(BotBody.gameObject);
                    if (teleportEffectPrefab)
                    {
                        EffectManager.SimpleEffect(teleportEffectPrefab, gameObject.transform.position, Quaternion.identity, true);
                    }
                    Destroy(gameObject);
                    Destroy(spawnCard);
                    return(true);
                }
                else
                {
                    Destroy(spawnCard);
                    return(false);
                }
            }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        float xPos = 0F;
        float yPos = 0F;

        float scale   = 0.25F;
        float xOffset = scale * 10F;
        //float rotation = 6F;

        int         handId = 0;
        List <Card> hand   = new List <Card>();

        hand = CollectionLoader.LoadCollection();

        for (int i = 0; i < 3; i++)
        {
            Card       card      = hand[i];
            GameObject cardClone = Instantiate(cardPrefab, new Vector3(0F, 0F, 0F), Quaternion.Euler(0, 0, 0)) as GameObject;

            SpawnCard SpawnCard = new SpawnCard();

            SpawnCard.CreateCard(cardClone, card, manaPrefab);
            cardClone.name                    = handId.ToString();
            cardClone.transform.parent        = transform;
            cardClone.transform.localPosition = new Vector3(xPos, yPos, (float)-handId);
            cardClone.transform.localScale    = new Vector3(scale, scale, 0.5F);

            xPos   += xOffset;
            handId += 1;
        }
    }
Пример #8
0
 public static void UpdateDropTableItemOdds(DropList dropList, SpawnCard spawnCard, string interactableName)
 {
     if (DropTableItemInteractables.Contains(interactableName))
     {
         var dropTable = spawnCard.prefab.GetComponent <ShopTerminalBehavior>().dropTable as ExplicitPickupDropTable;
         DropOdds.UpdateDropTableItemOdds(dropList, dropTable, interactableName);
     }
 }
Пример #9
0
        private void SpawnMoneyLunarPod(Vector3 moneyPodPosition)
        {
            SpawnCard             chestCard     = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscLunarChest");
            DirectorPlacementRule placementRule = new DirectorPlacementRule();

            placementRule.placementMode = DirectorPlacementRule.PlacementMode.Direct;
            moneyLunarPod = chestCard.DoSpawn(moneyPodPosition, Quaternion.identity, new DirectorSpawnRequest(chestCard, placementRule, Run.instance.runRNG)).spawnedInstance;
            displayItems.Add(moneyLunarPod);
        }
Пример #10
0
        public static void Init()
        {
            SceneDirector.onGenerateInteractableCardSelection += (director, selection) =>
            {
                DirectorCardCategorySelection.Category dupCategory = selection.categories.FirstOrDefault(x => x.name == "Duplicator");

                if ((dupCategory.cards?.Length ?? 0) > 0)
                {
                    var copyCard      = dupCategory.cards[0];
                    var copySpawnCard = copyCard.spawnCard;

                    SpawnCard spawnCard = ScriptableObject.CreateInstance <SpawnCard>();
                    spawnCard.name = "DuplicatorLunar";
                    spawnCard.directorCreditCost = LunarScrapPlugin.CreditCost.Value;
                    spawnCard.forbiddenFlags     = copySpawnCard.forbiddenFlags;
                    spawnCard.hullSize           = copySpawnCard.hullSize;
                    spawnCard.nodeGraphType      = copySpawnCard.nodeGraphType;
                    spawnCard.occupyPosition     = copySpawnCard.occupyPosition;
                    spawnCard.prefab             = Object.Instantiate(copySpawnCard.prefab);
                    spawnCard.requiredFlags      = copySpawnCard.requiredFlags;
                    spawnCard.sendOverNetwork    = copySpawnCard.sendOverNetwork;

                    var lunarCard = new DirectorCard()
                    {
                        spawnCard               = spawnCard,
                        selectionWeight         = LunarScrapPlugin.SelectionWeight.Value,
                        spawnDistance           = copyCard.spawnDistance,
                        allowAmbushSpawn        = copyCard.allowAmbushSpawn,
                        preventOverhead         = copyCard.preventOverhead,
                        minimumStageCompletions = copyCard.minimumStageCompletions,
                        requiredUnlockableDef   = copyCard.requiredUnlockableDef,
                        forbiddenUnlockableDef  = copyCard.forbiddenUnlockableDef
                    };
                    lunarCard.spawnCard.prefab.transform.SetPositionAndRotation(new UnityEngine.Vector3(0, -1000, 0), new UnityEngine.Quaternion());

                    lunarCard.spawnCard.prefab.GetComponent <PurchaseInteraction>().costType = CostTypeIndex.LunarItemOrEquipment;

                    var shop = lunarCard.spawnCard.prefab.GetComponent <ShopTerminalBehavior>();
                    shop.itemTier  = ItemTier.Lunar;
                    shop.dropTable = ScriptableObject.CreateInstance <LunarDropTable>();

                    var newCardArray = new DirectorCard[dupCategory.cards.Length + 1];
                    dupCategory.cards.CopyTo(newCardArray, 0);
                    newCardArray[newCardArray.Length - 1] = lunarCard;
                    dupCategory.cards = newCardArray;

                    for (int i = 0; i < selection.categories.Length; i++)
                    {
                        if (selection.categories[i].name == "Duplicator")
                        {
                            selection.categories[i] = dupCategory;
                        }
                    }
                }
            };
        }
 private void On_ServerStageBegin(Stage stage)
 {
     if (chestlocations.ContainsKey(stage.sceneDef.sceneName))
     {
         //grab first position
         var        position  = chestlocations[stage.sceneDef.sceneName][0];
         SpawnCard  chestCard = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscChest3");
         GameObject chest     = chestCard.DoSpawn(position, Quaternion.Euler(0, 0, 0), null);
     }
 }
Пример #12
0
        /*
         *  This will update the subset odds for the interactables that utilize ChestBehavior.
         */
        public static void UpdateChestTierOdds(SpawnCard spawnCard, string interactableName)
        {
            if (ChestInteractables.Contains(interactableName))
            {
                ChestBehavior chestBehavior = spawnCard.prefab.GetComponent <ChestBehavior>();
                if (!ChestTierOdds.ContainsKey(interactableName))
                {
                    ChestTierOdds.Add(interactableName, new List <float>());
                    ChestTierOdds[interactableName].Add(chestBehavior.tier1Chance);
                    ChestTierOdds[interactableName].Add(chestBehavior.tier2Chance);
                    ChestTierOdds[interactableName].Add(chestBehavior.tier3Chance);
                }

                if (ChestTierOdds.ContainsKey(interactableName))
                {
                    chestBehavior.tier1Chance = ChestTierOdds[interactableName][0];
                    chestBehavior.tier2Chance = ChestTierOdds[interactableName][1];
                    chestBehavior.tier3Chance = ChestTierOdds[interactableName][2];
                }

                if (ItemDropAPI.PlayerInteractables.SubsetTiersPresent.ContainsKey(interactableName))
                {
                    //  This is for damage, healing and utility chests
                    if (!ItemDropAPI.PlayerInteractables.SubsetTiersPresent[interactableName][InteractableCalculator.DropType.tier1])
                    {
                        chestBehavior.tier1Chance = 0;
                    }
                    if (!ItemDropAPI.PlayerInteractables.SubsetTiersPresent[interactableName][InteractableCalculator.DropType.tier2])
                    {
                        chestBehavior.tier2Chance = 0;
                    }
                    if (!ItemDropAPI.PlayerInteractables.SubsetTiersPresent[interactableName][InteractableCalculator.DropType.tier3])
                    {
                        chestBehavior.tier3Chance = 0;
                    }
                }
                else
                {
                    //  This is for everything else
                    if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier1])
                    {
                        chestBehavior.tier1Chance = 0;
                    }
                    if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier2])
                    {
                        chestBehavior.tier2Chance = 0;
                    }
                    if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier3])
                    {
                        chestBehavior.tier3Chance = 0;
                    }
                }
            }
        }
Пример #13
0
            static public void UpdateChestTierOdds(SpawnCard spawnCard, string interactableName)
            {
                if (InteractableCalculator.chestInteractables.Contains(interactableName))
                {
                    ChestBehavior chestBehavior = spawnCard.prefab.GetComponent <ChestBehavior>();
                    if (!ItemDropAPIFixes.playerInteractables.chestTierOdds.ContainsKey(interactableName))
                    {
                        ItemDropAPIFixes.playerInteractables.chestTierOdds.Add(interactableName, new List <float>());
                        ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName].Add(chestBehavior.tier1Chance);
                        ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName].Add(chestBehavior.tier2Chance);
                        ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName].Add(chestBehavior.tier3Chance);
                    }

                    if (ItemDropAPIFixes.playerInteractables.chestTierOdds.ContainsKey(interactableName))
                    {
                        chestBehavior.tier1Chance = ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName][0];
                        chestBehavior.tier2Chance = ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName][1];
                        chestBehavior.tier3Chance = ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName][2];
                    }
                    if (ItemDropAPIFixes.playerInteractables.subsetTiersPresent.ContainsKey(interactableName))
                    {
                        if (!ItemDropAPIFixes.playerInteractables.subsetTiersPresent[interactableName]["tier1"])
                        {
                            chestBehavior.tier1Chance = 0;
                        }
                        if (!ItemDropAPIFixes.playerInteractables.subsetTiersPresent[interactableName]["tier2"])
                        {
                            chestBehavior.tier2Chance = 0;
                        }
                        if (!ItemDropAPIFixes.playerInteractables.subsetTiersPresent[interactableName]["tier3"])
                        {
                            chestBehavior.tier3Chance = 0;
                        }
                    }
                    else
                    {
                        if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier1"])
                        {
                            chestBehavior.tier1Chance = 0;
                        }
                        if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier2"])
                        {
                            chestBehavior.tier2Chance = 0;
                        }
                        if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier3"])
                        {
                            chestBehavior.tier3Chance = 0;
                        }
                    }
                }
            }
Пример #14
0
        private void SpawnPrinters()
        {
            printerPosAndRot.Clear();
            FillPrinterInfo();

            for (int i = 0; i < ModConfig.printerCount.Value; i++)
            {
                string                randomDuplicator = GetRandomDuplicator();
                SpawnCard             printerCard      = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/" + randomDuplicator);
                DirectorPlacementRule placementRule    = new DirectorPlacementRule();
                placementRule.placementMode = DirectorPlacementRule.PlacementMode.Direct;
                GameObject printerOne = printerCard.DoSpawn(printerPosAndRot[i].position, Quaternion.identity, new DirectorSpawnRequest(printerCard, placementRule, Run.instance.runRNG)).spawnedInstance;
                printerOne.transform.eulerAngles = printerPosAndRot[i].rotation;
            }
        }
Пример #15
0
        public override void SetupBehavior()
        {
            base.SetupBehavior();
            lunarChimeraSpawnCard    = Resources.Load <SpawnCard>("SpawnCards/CharacterSpawnCards/cscLunarGolem");
            lunarChimeraSpawnCard    = Object.Instantiate(lunarChimeraSpawnCard);
            lunarChimeraMasterPrefab = lunarChimeraSpawnCard.prefab;
            lunarChimeraMasterPrefab = lunarChimeraMasterPrefab.InstantiateClone($"{lunarChimeraMasterPrefab.name}{nameSuffix}");
            CharacterMaster masterPrefab = lunarChimeraMasterPrefab.GetComponent <CharacterMaster>();

            lunarChimeraBodyPrefab              = masterPrefab.bodyPrefab;
            lunarChimeraBodyPrefab              = lunarChimeraBodyPrefab.InstantiateClone($"{lunarChimeraBodyPrefab.name}{nameSuffix}");
            masterPrefab.bodyPrefab             = lunarChimeraBodyPrefab;
            lunarChimeraSpawnCard.prefab        = lunarChimeraMasterPrefab;
            MasterCatalog.getAdditionalEntries += list => list.Add(lunarChimeraMasterPrefab);
            BodyCatalog.getAdditionalEntries   += list => list.Add(lunarChimeraBodyPrefab);
            NetworkingAPI.RegisterMessageType <AssignOwner>();
        }
Пример #16
0
        public void SpawnShrineOfDio(SceneDirector self)
        {
            Xoroshiro128Plus xoroshiro128Plus = new Xoroshiro128Plus(self.GetFieldValue <Xoroshiro128Plus>("rng").nextUlong);

            if (SceneInfo.instance.countsAsStage)
            {
                SpawnCard  card        = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscShrineHealing");
                GameObject gameObject3 = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(card, new DirectorPlacementRule
                {
                    placementMode = DirectorPlacementRule.PlacementMode.Random
                }, xoroshiro128Plus));

                if (!UseBalancedMode.Value)
                {
                    gameObject3.GetComponent <PurchaseInteraction>().Networkcost = GetDifficultyScaledCost(ResurrectionCost.Value);
                }
            }
        }
Пример #17
0
        public void SpawnShop(Xoroshiro128Plus xoroshiro128Plus)
        {
            SpawnCard  card = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscTripleShop");
            GameObject multiShopGameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(card, new DirectorPlacementRule
            {
                maxDistance   = 30f,
                minDistance   = 10f,
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                position      = TeleporterInteraction.instance.transform.position
            }, xoroshiro128Plus));

            float   startPosOffsetY = 0; // -7.2f;
            Vector3 endPosition     = multiShopGameObject.transform.position;

            multiShopGameObject.transform.position = new Vector3(multiShopGameObject.transform.position.x, multiShopGameObject.transform.position.y + startPosOffsetY, multiShopGameObject.transform.position.z);

            MultiShopController        multiShopController     = multiShopGameObject.GetComponent <MultiShopController>();
            List <PurchaseInteraction> purchaseInteractionList = new List <PurchaseInteraction>();

            GameObject[] terminalGameObjects = multiShopController.GetFieldValue <GameObject[]>("terminalGameObjects");
            for (int k = 0; k < terminalGameObjects.Length; k++)
            {
                purchaseInteractionList.Add(terminalGameObjects[k].GetComponent <PurchaseInteraction>());
                terminalGameObjects[k].gameObject.transform.position = new Vector3(terminalGameObjects[k].gameObject.transform.position.x, terminalGameObjects[k].gameObject.transform.position.y + startPosOffsetY, terminalGameObjects[k].gameObject.transform.position.z);
            }

            //EffectManager.instance.SpawnEffect(Resources.Load<GameObject>("Prefabs/Effects/BeetleQueenBurrow"), new EffectData()
            EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/TeleportOutBoom"), new EffectData()
            {
                origin   = endPosition,
                rotation = Quaternion.identity
            }, true);

            MultiShop.terminalOffset = Math.Abs(terminalGameObjects[0].gameObject.transform.position.y - multiShopGameObject.transform.position.y);

            MultiShop multiShop = new MultiShop
            {
                multiShopController          = multiShopController,
                terminalPurchaseInteractions = purchaseInteractionList,
                endPosition = endPosition
            };

            MultiShop.instances.Add(multiShop);
        }
Пример #18
0
 static public void UpdateDropTableTierOdds(SpawnCard spawnCard, string interactableName)
 {
     if (InteractableCalculator.dropTableInteractables.Contains(interactableName))
     {
         BasicPickupDropTable dropTable = spawnCard.prefab.GetComponent <RouletteChestController>().dropTable as BasicPickupDropTable;
         if (!ItemDropAPIFixes.playerInteractables.dropTableTierOdds.ContainsKey(interactableName))
         {
             ItemDropAPIFixes.playerInteractables.dropTableTierOdds.Add(interactableName, new List <float>());
             ItemDropAPIFixes.playerInteractables.dropTableTierOdds[interactableName].Add(dropTable.tier1Weight);
             ItemDropAPIFixes.playerInteractables.dropTableTierOdds[interactableName].Add(dropTable.tier2Weight);
             ItemDropAPIFixes.playerInteractables.dropTableTierOdds[interactableName].Add(dropTable.tier3Weight);
             ItemDropAPIFixes.playerInteractables.dropTableTierOdds[interactableName].Add(dropTable.equipmentWeight);
         }
         if (ItemDropAPIFixes.playerInteractables.dropTableTierOdds.ContainsKey(interactableName))
         {
             dropTable.tier1Weight     = ItemDropAPIFixes.playerInteractables.dropTableTierOdds[interactableName][0];
             dropTable.tier2Weight     = ItemDropAPIFixes.playerInteractables.dropTableTierOdds[interactableName][1];
             dropTable.tier3Weight     = ItemDropAPIFixes.playerInteractables.dropTableTierOdds[interactableName][2];
             dropTable.equipmentWeight = ItemDropAPIFixes.playerInteractables.dropTableTierOdds[interactableName][3];
         }
         if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier1"])
         {
             dropTable.tier1Weight = 0;
         }
         if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier2"])
         {
             dropTable.tier2Weight = 0;
         }
         if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier3"])
         {
             dropTable.tier3Weight = 0;
         }
         if (!ItemDropAPIFixes.playerInteractables.tiersPresent["equipment"])
         {
             dropTable.equipmentWeight = 0;
         }
         System.Type type = typeof(RoR2.BasicPickupDropTable);
         System.Reflection.MethodInfo method = type.GetMethod("GenerateWeightedSelection", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
         method.Invoke(dropTable, new object[] { Run.instance });
     }
 }
Пример #19
0
        /*
         *  This will update the subset odds for the interactables that utilize RouletteChestController.
         */
        public static void UpdateDropTableTierOdds(SpawnCard spawnCard, string interactableName)
        {
            if (DropTableInteractables.Contains(interactableName))
            {
                BasicPickupDropTable dropTable = spawnCard.prefab.GetComponent <RouletteChestController>().dropTable as BasicPickupDropTable;
                if (!DropTableTierOdds.ContainsKey(interactableName))
                {
                    DropTableTierOdds.Add(interactableName, new List <float>());
                    DropTableTierOdds[interactableName].Add(dropTable.tier1Weight);
                    DropTableTierOdds[interactableName].Add(dropTable.tier2Weight);
                    DropTableTierOdds[interactableName].Add(dropTable.tier3Weight);
                    DropTableTierOdds[interactableName].Add(dropTable.equipmentWeight);
                }
                if (DropTableTierOdds.ContainsKey(interactableName))
                {
                    dropTable.tier1Weight     = DropTableTierOdds[interactableName][0];
                    dropTable.tier2Weight     = DropTableTierOdds[interactableName][1];
                    dropTable.tier3Weight     = DropTableTierOdds[interactableName][2];
                    dropTable.equipmentWeight = DropTableTierOdds[interactableName][3];
                }
                if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier1])
                {
                    dropTable.tier1Weight = 0;
                }
                if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier2])
                {
                    dropTable.tier2Weight = 0;
                }
                if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier3])
                {
                    dropTable.tier3Weight = 0;
                }
                if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.equipment])
                {
                    dropTable.equipmentWeight = 0;
                }

                dropTable.GenerateWeightedSelection(Run.instance);
            }
        }
Пример #20
0
        private void RepositionGroundedDrones(CharacterBody droneBody, Vector3 desiredPosition)
        {
            bool isGrounded = false;

            foreach (string subname in GroundedDrones)
            {
                if (droneBody.name.Contains(subname))
                {
                    isGrounded = true;
                    break;
                }
            }
            if (!isGrounded)
            {
                return;
            }
            SpawnCard spawnCard = ScriptableObject.CreateInstance <SpawnCard>();

            spawnCard.hullSize      = droneBody.hullClassification;
            spawnCard.nodeGraphType = GraphType.Ground;
            spawnCard.prefab        = helperPrefab;
            GameObject gameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(spawnCard, new DirectorPlacementRule
            {
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                position      = desiredPosition,
                minDistance   = 0,
                maxDistance   = 50
            }, Run.instance.runRNG));

            if (gameObject)
            {
                TeleportHelper.TeleportBody(droneBody, gameObject.transform.position);
                Object.Destroy(gameObject);
            }
            else
            {
                Log.Warning($"Machines.RepositionGroundedDrones: Failed to reposition {droneBody.name}. It might be floating now.");
            }
            Object.Destroy(spawnCard);
        }
        public void Awake()
        {
            On.RoR2.SceneDirector.PopulateScene += (orig, self) =>
            {
                orig(self);
                if (SceneInfo.instance.countsAsStage)
                {
                    Type[] arr = ((IEnumerable <System.Type>) typeof(ChestRevealer).Assembly.GetTypes()).Where <System.Type>((Func <System.Type, bool>)(t => typeof(IInteractable).IsAssignableFrom(t))).ToArray <System.Type>();


                    if (!BossShrineExists(arr))
                    {
                        Xoroshiro128Plus xoroshiro128Plus = new Xoroshiro128Plus(self.GetFieldValue <Xoroshiro128Plus>("rng").nextUlong);
                        SpawnCard        card             = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscShrineBoss");
                        GameObject       gameObject3      = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(card, new DirectorPlacementRule
                        {
                            placementMode = DirectorPlacementRule.PlacementMode.Random
                        }, xoroshiro128Plus));
                    }
                }
            };
        }
Пример #22
0
        public override void InvokeServer(Dictionary <string, string> contents)
        {
            string spawnCard = contents["SpawnCard"];

            if (!DataUtils.ReadVector3FromDictionary("Location", ref contents, out Vector3 hit))
            {
                SandboxMain.Log(
                    $"Invalid location \"[{contents["Location.x"]}, {contents["Location.y"]}, {contents["Location.z"]}] Replicated",
                    true);
                return;
            }

            SpawnCard card = Resources.Load <SpawnCard>("SpawnCards/" + spawnCard);

            if (card == null)
            {
                SandboxMain.Log($"Unable to load a spawnCard called \"{spawnCard}\"", true);
                return;
            }

            card.DoSpawn(hit, Quaternion.identity);
        }
        /// <summary>
        /// Teleports a body to another GameObject using the director system.
        /// </summary>
        /// <param name="characterBody">The body to teleport.</param>
        /// <param name="target">The GameObject we should teleport to.</param>
        /// <param name="teleportEffect">The teleportation effect we should use upon arrival.</param>
        /// <param name="hullClassification">The hullclassification we should use for traversing the nodegraph.</param>
        /// <param name="rng">The random that we should use to position the body randomly around our target.</param>
        /// <param name="minDistance">How close to the target can we get?</param>
        /// <param name="maxDistance">How far out from the target can we get?</param>
        /// <param name="teleportAir">Should we use the air nodes?</param>
        /// <returns>A bool representing if the teleportation was successful or not.</returns>
        public static bool TeleportBody(CharacterBody characterBody, GameObject target, GameObject teleportEffect, HullClassification hullClassification, Xoroshiro128Plus rng, float minDistance = 20, float maxDistance = 45, bool teleportAir = false)
        {
            if (!characterBody)
            {
                return(false);
            }

            SpawnCard spawnCard = ScriptableObject.CreateInstance <SpawnCard>();

            spawnCard.hullSize      = hullClassification;
            spawnCard.nodeGraphType = teleportAir ? MapNodeGroup.GraphType.Air : MapNodeGroup.GraphType.Ground;
            spawnCard.prefab        = Resources.Load <GameObject>("SpawnCards/HelperPrefab");
            GameObject gameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(spawnCard, new DirectorPlacementRule
            {
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                position      = target.transform.position,
                minDistance   = minDistance,
                maxDistance   = maxDistance
            }, rng));

            if (gameObject)
            {
                TeleportHelper.TeleportBody(characterBody, gameObject.transform.position);
                GameObject teleportEffectPrefab = teleportEffect;
                if (teleportEffectPrefab)
                {
                    EffectManager.SimpleEffect(teleportEffectPrefab, gameObject.transform.position, Quaternion.identity, true);
                }
                UnityEngine.Object.Destroy(gameObject);
                UnityEngine.Object.Destroy(spawnCard);
                return(true);
            }
            else
            {
                UnityEngine.Object.Destroy(spawnCard);
                return(false);
            }
        }
Пример #24
0
    // Use this for initialization
    void Start()
    {
        List<Card> cardCollection = new List<Card>();
        cardCollection = CollectionLoader.LoadCollection();

        float xPos = -4F;

        foreach(Card card in cardCollection)
        {
            GameObject cardClone = Instantiate(cardPrefab, new Vector3 (0F, 0F, 0F), Quaternion.Euler (0, 0, 0)) as GameObject;

            SpawnCard SpawnCard = new SpawnCard();

            SpawnCard.CreateCard(cardClone, card, manaPrefab);

            cardClone.name = "Card_" + card.Id;
            cardClone.transform.parent = transform;
            cardClone.transform.localPosition = new Vector3 (xPos, 0F, 0F);
            cardClone.transform.localScale = new Vector3 (0.35F, 0.35F, 0.5F);

            xPos += 4;
        }
    }
Пример #25
0
    // Use this for initialization
    void Start()
    {
        List <Card> cardCollection = new List <Card>();

        cardCollection = CollectionLoader.LoadCollection();

        float xPos = -4F;

        foreach (Card card in cardCollection)
        {
            GameObject cardClone = Instantiate(cardPrefab, new Vector3(0F, 0F, 0F), Quaternion.Euler(0, 0, 0)) as GameObject;

            SpawnCard SpawnCard = new SpawnCard();

            SpawnCard.CreateCard(cardClone, card, manaPrefab);

            cardClone.name                    = "Card_" + card.Id;
            cardClone.transform.parent        = transform;
            cardClone.transform.localPosition = new Vector3(xPos, 0F, 0F);
            cardClone.transform.localScale    = new Vector3(0.35F, 0.35F, 0.5F);

            xPos += 4;
        }
    }
Пример #26
0
 public static string GetSpawnCardName(SpawnCard givenSpawnCard)
 {
     return(givenSpawnCard.name.Substring(PrefixLength, givenSpawnCard.name.Length - PrefixLength));
 }
Пример #27
0
        // A hacky method. Don't ask questions.
        private static void SpawnPlayerbotAsSummon(CharacterMaster owner, SurvivorIndex survivorIndex)
        {
            SurvivorDef def = SurvivorCatalog.GetSurvivorDef(survivorIndex);

            if (def == null)
            {
                return;
            }

            GameObject bodyPrefab = def.bodyPrefab;

            if (bodyPrefab == null)
            {
                return;
            }

            // Get card
            SpawnCard card = (SpawnCard)Resources.Load("SpawnCards/CharacterSpawnCards/cscBeetleGuardAlly");

            // Spawn request
            DirectorSpawnRequest spawnRequest = new DirectorSpawnRequest(card, new DirectorPlacementRule
            {
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                minDistance   = 3f,
                maxDistance   = 40f,
                spawnOnTarget = owner.GetBody().transform
            }, RoR2Application.rng);

            spawnRequest.ignoreTeamMemberLimit = true;
            spawnRequest.teamIndexOverride     = new TeamIndex?(TeamIndex.Player);
            //spawnRequest.summonerBodyObject = owner.GetBody().gameObject;

            // Spawn
            GameObject gameObject = DirectorCore.instance.TrySpawnObject(spawnRequest);

            if (gameObject)
            {
                CharacterMaster master      = gameObject.GetComponent <CharacterMaster>();
                AIOwnership     aiOwnership = gameObject.AddComponent <AIOwnership>() as AIOwnership;
                BaseAI          ai          = gameObject.GetComponent <BaseAI>();

                if (master)
                {
                    master.name       = "PlayerBot";
                    master.bodyPrefab = bodyPrefab;
                    SetRandomSkin(master, bodyPrefab);

                    master.Respawn(master.GetBody().transform.position, master.GetBody().transform.rotation);
                    master.teamIndex = TeamIndex.Player;

                    master.GiveMoney(owner.money);
                    master.inventory.CopyItemsFrom(owner.inventory);
                    master.inventory.GiveItem(ItemIndex.DrizzlePlayerHelper, 1);

                    // Allow the bots to spawn in the next stage
                    master.destroyOnBodyDeath = false;
                    master.gameObject.AddComponent <SetDontDestroyOnLoad>();
                }
                if (aiOwnership)
                {
                    aiOwnership.ownerMaster = owner;
                }
                if (ai)
                {
                    ai.name = "PlayerBot";
                    ai.leader.gameObject = owner.GetBody().gameObject;

                    ai.fullVision        = true;
                    ai.aimVectorDampTime = .01f;
                    ai.aimVectorMaxSpeed = 180f;
                }

                InjectSkillDrivers(gameObject, ai, survivorIndex);

                if (AutoPurchaseItems.Value)
                {
                    // Add item manager
                    ItemManager itemManager = gameObject.AddComponent <ItemManager>() as ItemManager;
                }

                // Add to playerbot list
                playerbots.Add(gameObject);
            }
        }
Пример #28
0
        public void Awake()
        {
            int costChance   = base.Config.Bind <int>(new ConfigDefinition("00 - Credit Costs", "Shrine of Chance"), 20, new ConfigDescription("How many director credits the shrine costs to spawn.")).Value;
            int costBlood    = base.Config.Bind <int>(new ConfigDefinition("00 - Credit Costs", "Shrine of Blood"), 20, new ConfigDescription("How many director credits the shrine costs to spawn.")).Value;
            int costCombat   = base.Config.Bind <int>(new ConfigDefinition("00 - Credit Costs", "Shrine of Combat"), 20, new ConfigDescription("How many director credits the shrine costs to spawn.")).Value;
            int costOrder    = base.Config.Bind <int>(new ConfigDefinition("00 - Credit Costs", "Shrine of Order"), 30, new ConfigDescription("How many director credits the shrine costs to spawn.")).Value;
            int costMountain = base.Config.Bind <int>(new ConfigDefinition("00 - Credit Costs", "Shrine of the Mountain"), 20, new ConfigDescription("How many director credits the shrine costs to spawn.")).Value;
            int costWoods    = base.Config.Bind <int>(new ConfigDefinition("00 - Credit Costs", "Shrine of the Woods"), 15, new ConfigDescription("How many director credits the shrine costs to spawn.")).Value;
            int costCleanse  = base.Config.Bind <int>(new ConfigDefinition("00 - Credit Costs", "Cleansing Pool"), 5, new ConfigDescription("How many director credits the shrine costs to spawn.")).Value;

            #region stage1
            StageShrineWeights titanicPlains = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("10 - Titanic Plains", "Shrine Category Weight"), 10, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("10 - Titanic Plains", "Shrine of Chance Weight"), 4, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("10 - Titanic Plains", "Shrine of Blood Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("10 - Titanic Plains", "Shrine of Combat Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("10 - Titanic Plains", "Shrine of Order Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("10 - Titanic Plains", "Shrine of the Mountain Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("10 - Titanic Plains", "Shrine of the Woods Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("10 - Titanic Plains", "Cleansing Pool Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };

            StageShrineWeights distantRoost = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("11 - Distant Roost", "Shrine Category Weight"), 10, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("11 - Distant Roost", "Shrine of Chance Weight"), 4, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("11 - Distant Roost", "Shrine of Blood Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("11 - Distant Roost", "Shrine of Combat Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("11 - Distant Roost", "Shrine of Order Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("11 - Distant Roost", "Shrine of the Mountain Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("11 - Distant Roost", "Shrine of the Woods Weight"), 2, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("11 - Distant Roost", "Cleansing Pool Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };
            #endregion
            #region stage2
            StageShrineWeights wetlandAspect = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("20 - Wetland Aspect", "Shrine Category Weight"), 10, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("20 - Wetland Aspect", "Shrine of Chance Weight"), 4, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("20 - Wetland Aspect", "Shrine of Blood Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("20 - Wetland Aspect", "Shrine of Combat Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("20 - Wetland Aspect", "Shrine of Order Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("20 - Wetland Aspect", "Shrine of the Mountain Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("20 - Wetland Aspect", "Shrine of the Woods Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("20 - Wetland Aspect", "Cleansing Pool Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };

            StageShrineWeights abandonedAqueduct = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("21 - Abandoned Aqueduct", "Shrine Category Weight"), 8, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("21 - Abandoned Aqueduct", "Shrine of Chance Weight"), 4, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("21 - Abandoned Aqueduct", "Shrine of Blood Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("21 - Abandoned Aqueduct", "Shrine of Combat Weight"), 2, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("21 - Abandoned Aqueduct", "Shrine of Order Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("21 - Abandoned Aqueduct", "Shrine of the Mountain Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("21 - Abandoned Aqueduct", "Shrine of the Woods Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("21 - Abandoned Aqueduct", "Cleansing Pool Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };
            #endregion
            #region stage3
            StageShrineWeights rallypointDelta = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("30 - Rallypoint Delta", "Shrine Category Weight"), 7, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("30 - Rallypoint Delta", "Shrine of Chance Weight"), 4, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("30 - Rallypoint Delta", "Shrine of Blood Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("30 - Rallypoint Delta", "Shrine of Combat Weight"), 2, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("30 - Rallypoint Delta", "Shrine of Order Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("30 - Rallypoint Delta", "Shrine of the Mountain Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("30 - Rallypoint Delta", "Shrine of the Woods Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("30 - Rallypoint Delta", "Cleansing Pool Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };

            StageShrineWeights scorchedAcres = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("31 - Scorched Acres", "Shrine Category Weight"), 7, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("31 - Scorched Acres", "Shrine of Chance Weight"), 4, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("31 - Scorched Acres", "Shrine of Blood Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("31 - Scorched Acres", "Shrine of Combat Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("31 - Scorched Acres", "Shrine of Order Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("31 - Scorched Acres", "Shrine of the Mountain Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("31 - Scorched Acres", "Shrine of the Woods Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("31 - Scorched Acres", "Cleansing Pool Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };
            #endregion
            #region stage4
            StageShrineWeights abyssalDepths = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("40 - Abyssal Depths", "Shrine Category Weight"), 10, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("40 - Abyssal Depths", "Shrine of Chance Weight"), 4, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("40 - Abyssal Depths", "Shrine of Blood Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("40 - Abyssal Depths", "Shrine of Combat Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("40 - Abyssal Depths", "Shrine of Order Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("40 - Abyssal Depths", "Shrine of the Mountain Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("40 - Abyssal Depths", "Shrine of the Woods Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("40 - Abyssal Depths", "Cleansing Pool Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };

            StageShrineWeights sirensCall = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("41 - Sirens Call", "Shrine Category Weight"), 10, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("41 - Sirens Call", "Shrine of Chance Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("41 - Sirens Call", "Shrine of Blood Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("41 - Sirens Call", "Shrine of Combat Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("41 - Sirens Call", "Shrine of Order Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("41 - Sirens Call", "Shrine of the Mountain Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("41 - Sirens Call", "Shrine of the Woods Weight"), 2, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("41 - Sirens Call", "Cleansing Pool Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };

            StageShrineWeights sunderedGrove = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("42 - Sundered Grove", "Shrine Category Weight"), 10, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("42 - Sundered Grove", "Shrine of Chance Weight"), 4, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("42 - Sundered Grove", "Shrine of Blood Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("42 - Sundered Grove", "Shrine of Combat Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("42 - Sundered Grove", "Shrine of Order Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("42 - Sundered Grove", "Shrine of the Mountain Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("42 - Sundered Grove", "Shrine of the Woods Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("42 - Sundered Grove", "Cleansing Pool Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };
            #endregion

            StageShrineWeights skyMeadow = new StageShrineWeights
            {
                //overall = base.Config.Bind<int>(new ConfigDefinition("50 - Sky Meadow", "Shrine Category Weight"), 10, new ConfigDescription("How likely it is for shrines to spawn on this map.")).Value,
                chance   = base.Config.Bind <int>(new ConfigDefinition("50 - Sky Meadow", "Shrine of Chance Weight"), 4, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                blood    = base.Config.Bind <int>(new ConfigDefinition("50 - Sky Meadow", "Shrine of Blood Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                combat   = base.Config.Bind <int>(new ConfigDefinition("50 - Sky Meadow", "Shrine of Combat Weight"), 3, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                order    = base.Config.Bind <int>(new ConfigDefinition("50 - Sky Meadow", "Shrine of Order Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                mountain = base.Config.Bind <int>(new ConfigDefinition("50 - Sky Meadow", "Shrine of the Mountain Weight"), 1, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                woods    = base.Config.Bind <int>(new ConfigDefinition("50 - Sky Meadow", "Shrine of the Woods Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value,
                cleanse  = base.Config.Bind <int>(new ConfigDefinition("50 - Sky Meadow", "Cleansing Pool Weight"), 0, new ConfigDescription("How likely it is for the shrine to be spawned.")).Value
            };

            SpawnCard chanceSC   = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscShrineChance");
            SpawnCard bloodSC    = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscShrineBlood");
            SpawnCard combatSC   = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscShrineCombat");
            SpawnCard orderSC    = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscShrineRestack");
            SpawnCard mountainSC = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscShrineBoss");
            SpawnCard woodsSC    = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscShrineHealing");
            SpawnCard cleanseSC  = Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscShrineCleanse");

            Debug.Log("chance: " + chanceSC.directorCreditCost);
            Debug.Log("blood: " + bloodSC.directorCreditCost);
            Debug.Log("combat: " + combatSC.directorCreditCost);
            Debug.Log("order: " + orderSC.directorCreditCost);
            Debug.Log("mountain: " + mountainSC.directorCreditCost);
            Debug.Log("woods: " + woodsSC.directorCreditCost);
            Debug.Log("cleanse: " + cleanseSC.directorCreditCost);

            chanceSC.directorCreditCost   = costChance;
            bloodSC.directorCreditCost    = costBlood;
            combatSC.directorCreditCost   = costCombat;
            orderSC.directorCreditCost    = costOrder;
            mountainSC.directorCreditCost = costMountain;
            woodsSC.directorCreditCost    = costWoods;
            cleanseSC.directorCreditCost  = costCleanse;

            DirectorAPI.InteractableActions += delegate(List <DirectorAPI.DirectorCardHolder> cardList, DirectorAPI.StageInfo stage)
            {
                bool foundStage        = true;
                StageShrineWeights ssw = titanicPlains;
                switch (stage.stage)
                {
                case DirectorAPI.Stage.TitanicPlains:
                    ssw = titanicPlains;
                    break;

                case DirectorAPI.Stage.DistantRoost:
                    ssw = distantRoost;
                    break;

                case DirectorAPI.Stage.WetlandAspect:
                    ssw = wetlandAspect;
                    break;

                case DirectorAPI.Stage.AbandonedAqueduct:
                    ssw = abandonedAqueduct;
                    break;

                case DirectorAPI.Stage.RallypointDelta:
                    ssw = rallypointDelta;
                    break;

                case DirectorAPI.Stage.ScorchedAcres:
                    ssw = scorchedAcres;
                    break;

                case DirectorAPI.Stage.AbyssalDepths:
                    ssw = abyssalDepths;
                    break;

                case DirectorAPI.Stage.SirensCall:
                    ssw = sirensCall;
                    break;

                case DirectorAPI.Stage.SkyMeadow:
                    ssw = skyMeadow;
                    break;

                case DirectorAPI.Stage.Custom:
                    if (stage.CustomStageName == "rootjungle")
                    {
                        ssw = sunderedGrove;
                    }
                    else
                    {
                        foundStage = false;
                    }
                    break;

                default:
                    foundStage = false;
                    break;
                }

                if (foundStage)
                {
                    bool handledChance   = false;
                    bool handledBlood    = false;
                    bool handledCombat   = false;
                    bool handledOrder    = false;
                    bool handledMountain = false;
                    bool handledWoods    = false;
                    bool handledCleanse  = false;

                    List <DirectorAPI.DirectorCardHolder> toRemove = new List <DirectorAPI.DirectorCardHolder>();
                    foreach (DirectorAPI.DirectorCardHolder dc in cardList)
                    {
                        if (dc.InteractableCategory == DirectorAPI.InteractableCategory.Shrines)
                        {
                            /*Debug.Log("\n\n\ncard: " + dc.Card.spawnCard);
                             * Debug.Log("weight: " + dc.Card.selectionWeight);
                             * Debug.Log("preventoverhead: " + dc.Card.preventOverhead);
                             * Debug.Log("spawndistance: " + dc.Card.spawnDistance);*/

                            //Debug.Log("\nold selection weight: " + dc.Card.selectionWeight);
                            if (dc.Card.spawnCard == chanceSC)
                            {
                                handledChance           = true;
                                dc.Card.selectionWeight = ssw.chance;
                            }
                            else if (!handledBlood && dc.Card.spawnCard == bloodSC)
                            {
                                handledBlood            = true;
                                dc.Card.selectionWeight = ssw.blood;
                            }
                            else if (dc.Card.spawnCard == combatSC)
                            {
                                handledCombat           = true;
                                dc.Card.selectionWeight = ssw.combat;
                            }
                            else if (dc.Card.spawnCard == orderSC)
                            {
                                handledOrder            = true;
                                dc.Card.selectionWeight = ssw.order;
                            }
                            else if (dc.Card.spawnCard == mountainSC)
                            {
                                handledMountain         = true;
                                dc.Card.selectionWeight = ssw.mountain;
                            }
                            else if (dc.Card.spawnCard == woodsSC)
                            {
                                handledWoods            = true;
                                dc.Card.selectionWeight = ssw.woods;
                            }
                            else if (dc.Card.spawnCard == cleanseSC)
                            {
                                handledCleanse          = true;
                                dc.Card.selectionWeight = ssw.cleanse;
                            }
                            //Debug.Log("new selection weight: " + dc.Card.selectionWeight);

                            if (dc.Card.selectionWeight == 0)
                            {
                                //Debug.Log("removing from pool: " + dc.Card.spawnCard);
                                toRemove.Add(dc);
                            }
                        }
                    }

                    foreach (DirectorAPI.DirectorCardHolder dc in toRemove)
                    {
                        cardList.Remove(dc);
                    }

                    if (!handledChance && ssw.chance > 0)
                    {
                        DirectorCard newDC = new DirectorCard
                        {
                            spawnCard               = chanceSC,
                            selectionWeight         = ssw.chance,
                            allowAmbushSpawn        = false,
                            preventOverhead         = false,
                            minimumStageCompletions = 0,
                            requiredUnlockable      = "",
                            forbiddenUnlockable     = "",
                            spawnDistance           = DirectorCore.MonsterSpawnDistance.Standard
                        };
                        DirectorAPI.DirectorCardHolder newCard = new DirectorAPI.DirectorCardHolder
                        {
                            Card                 = newDC,
                            MonsterCategory      = DirectorAPI.MonsterCategory.None,
                            InteractableCategory = DirectorAPI.InteractableCategory.Shrines
                        };
                        cardList.Add(newCard);
                    }
                    if (!handledBlood && ssw.blood > 0)
                    {
                        DirectorCard newDC = new DirectorCard
                        {
                            spawnCard               = bloodSC,
                            selectionWeight         = ssw.blood,
                            allowAmbushSpawn        = false,
                            preventOverhead         = false,
                            minimumStageCompletions = 0,
                            requiredUnlockable      = "",
                            forbiddenUnlockable     = "",
                            spawnDistance           = DirectorCore.MonsterSpawnDistance.Standard
                        };
                        DirectorAPI.DirectorCardHolder newCard = new DirectorAPI.DirectorCardHolder
                        {
                            Card                 = newDC,
                            MonsterCategory      = DirectorAPI.MonsterCategory.None,
                            InteractableCategory = DirectorAPI.InteractableCategory.Shrines
                        };
                        cardList.Add(newCard);
                    }
                    if (!handledCombat && ssw.combat > 0)
                    {
                        DirectorCard newDC = new DirectorCard
                        {
                            spawnCard               = combatSC,
                            selectionWeight         = ssw.combat,
                            allowAmbushSpawn        = false,
                            preventOverhead         = false,
                            minimumStageCompletions = 0,
                            requiredUnlockable      = "",
                            forbiddenUnlockable     = "",
                            spawnDistance           = DirectorCore.MonsterSpawnDistance.Standard
                        };
                        DirectorAPI.DirectorCardHolder newCard = new DirectorAPI.DirectorCardHolder
                        {
                            Card                 = newDC,
                            MonsterCategory      = DirectorAPI.MonsterCategory.None,
                            InteractableCategory = DirectorAPI.InteractableCategory.Shrines
                        };
                        cardList.Add(newCard);
                    }
                    if (!handledOrder && ssw.order > 0)
                    {
                        DirectorCard newDC = new DirectorCard
                        {
                            spawnCard               = orderSC,
                            selectionWeight         = ssw.order,
                            allowAmbushSpawn        = false,
                            preventOverhead         = false,
                            minimumStageCompletions = 0,
                            requiredUnlockable      = "",
                            forbiddenUnlockable     = "",
                            spawnDistance           = DirectorCore.MonsterSpawnDistance.Standard
                        };
                        DirectorAPI.DirectorCardHolder newCard = new DirectorAPI.DirectorCardHolder
                        {
                            Card                 = newDC,
                            MonsterCategory      = DirectorAPI.MonsterCategory.None,
                            InteractableCategory = DirectorAPI.InteractableCategory.Shrines
                        };
                        cardList.Add(newCard);
                    }
                    if (!handledMountain && ssw.mountain > 0)
                    {
                        DirectorCard newDC = new DirectorCard
                        {
                            spawnCard               = mountainSC,
                            selectionWeight         = ssw.mountain,
                            allowAmbushSpawn        = false,
                            preventOverhead         = false,
                            minimumStageCompletions = 0,
                            requiredUnlockable      = "",
                            forbiddenUnlockable     = "",
                            spawnDistance           = DirectorCore.MonsterSpawnDistance.Standard
                        };
                        DirectorAPI.DirectorCardHolder newCard = new DirectorAPI.DirectorCardHolder
                        {
                            Card                 = newDC,
                            MonsterCategory      = DirectorAPI.MonsterCategory.None,
                            InteractableCategory = DirectorAPI.InteractableCategory.Shrines
                        };
                        cardList.Add(newCard);
                    }
                    if (!handledWoods && ssw.woods > 0)
                    {
                        DirectorCard newDC = new DirectorCard
                        {
                            spawnCard               = woodsSC,
                            selectionWeight         = ssw.woods,
                            allowAmbushSpawn        = false,
                            preventOverhead         = false,
                            minimumStageCompletions = 0,
                            requiredUnlockable      = "",
                            forbiddenUnlockable     = "",
                            spawnDistance           = DirectorCore.MonsterSpawnDistance.Standard
                        };
                        DirectorAPI.DirectorCardHolder newCard = new DirectorAPI.DirectorCardHolder
                        {
                            Card                 = newDC,
                            MonsterCategory      = DirectorAPI.MonsterCategory.None,
                            InteractableCategory = DirectorAPI.InteractableCategory.Shrines
                        };
                        cardList.Add(newCard);
                    }
                    if (!handledCleanse && ssw.cleanse > 0)
                    {
                        DirectorCard newDC = new DirectorCard
                        {
                            spawnCard               = cleanseSC,
                            selectionWeight         = ssw.cleanse,
                            allowAmbushSpawn        = false,
                            preventOverhead         = false,
                            minimumStageCompletions = 0,
                            requiredUnlockable      = "",
                            forbiddenUnlockable     = "",
                            spawnDistance           = DirectorCore.MonsterSpawnDistance.Standard
                        };
                        DirectorAPI.DirectorCardHolder newCard = new DirectorAPI.DirectorCardHolder
                        {
                            Card                 = newDC,
                            MonsterCategory      = DirectorAPI.MonsterCategory.None,
                            InteractableCategory = DirectorAPI.InteractableCategory.Shrines
                        };
                        cardList.Add(newCard);
                    }
                }
            };
        }
Пример #29
0
        private static void LoadOverlordCards(Game game)
        {
            StreamReader reader = new StreamReader(TitleContainer.OpenStream("overlordcards.txt"));
            overlordCards = new List<OverlordCard>();

            int n = int.Parse(reader.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string line = reader.ReadLine();
                if (line.StartsWith("//")) continue;
                OverlordCard card = null;

                string[] data = line.Split(new char[] { ',' }, 9);

                int id = int.Parse(data[0]);
                string type = data[1];
                string name = data[2];
                int amount = int.Parse(data[3]);
                int cost = int.Parse(data[4]);
                int sell = int.Parse(data[5]);
                string description = data[7];

                switch (type)
                {
                    case "Spawn":
                        List<Monster> monsters = new List<Monster>();
                        string[] creaturesToSpawn = data[6].Split('/');
                        for (int j = 0; j < creaturesToSpawn.Length; j++)
                        {
                            for (int k = 0; k < int.Parse(creaturesToSpawn[j].Split(' ')[1]); k++)
                            {
                                monsters.Add(GetMonster(int.Parse(creaturesToSpawn[j].Split(' ')[0])));
                            }
                        }
                        card = new SpawnCard(id, name, description, cost, sell, monsters.ToArray());
                        break;
                    case "Power":
                        card = new PowerCard(id, name, description, cost, sell);
                        break;
                    case "Trap":
                        card = new TrapCard(id, name, description, cost, sell);
                        break;
                    case "Event":
                        card = new EventCard(id, name, description, cost, sell);
                        break;
                }
                if (card != null)
                    overlordCards.Add(card);
            }
        }
Пример #30
0
        private static void SpawnSpawnCard(SpawnCard spawnCard)
        {
            var localUser = LocalUserManager.GetFirstLocalUser();
            var body      = localUser.cachedMasterController.master.GetBody().transform;

            if (localUser.cachedMasterController && localUser.cachedMasterController.master)
            {
                var directorSpawnRequest = new DirectorSpawnRequest(spawnCard, new DirectorPlacementRule
                {
                    placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                    minDistance   = Spawn.minDistance,
                    maxDistance   = Spawn.maxDistance,
                    position      = UmbraMenu.LocalPlayerBody.footPosition
                }, RoR2Application.rng)
                {
                    ignoreTeamMemberLimit = true,
                    teamIndexOverride     = Spawn.team[Spawn.teamIndex]
                };

                directorSpawnRequest.spawnCard.sendOverNetwork = true;

                string cardName   = spawnCard.ToString();
                string category   = "";
                string buttonText = "";
                if (cardName.Contains("MultiCharacterSpawnCard"))
                {
                    cardName   = cardName.Replace(" (RoR2.MultiCharacterSpawnCard)", "");
                    category   = "CharacterSpawnCard";
                    buttonText = cardName.Replace("csc", "");
                }
                else if (cardName.Contains("CharacterSpawnCard"))
                {
                    cardName   = cardName.Replace(" (RoR2.CharacterSpawnCard)", "");
                    category   = "CharacterSpawnCard";
                    buttonText = cardName.Replace("csc", "");
                }
                else if (cardName.Contains("InteractableSpawnCard"))
                {
                    cardName   = cardName.Replace(" (RoR2.InteractableSpawnCard)", "");
                    category   = "InteractableSpawnCard";
                    buttonText = cardName.Replace("isc", "");
                }
                else if (cardName.Contains("BodySpawnCard"))
                {
                    cardName   = cardName.Replace(" (RoR2.BodySpawnCard)", "");
                    category   = "BodySpawnCard";
                    buttonText = cardName.Replace("bsc", "");
                }
                string path = $"SpawnCards/{category}/{cardName}";

                if (cardName.Contains("isc"))
                {
                    var interactable = Resources.Load <SpawnCard>(path).DoSpawn(body.position + (Vector3.forward * Spawn.minDistance), body.rotation, directorSpawnRequest).spawnedInstance.gameObject;
                    Spawn.spawnedObjects.Add(interactable);
                    Chat.AddMessage($"<color=yellow>Spawned \"{buttonText}\"</color>");
                }
                else
                {
                    DirectorCore.instance.TrySpawnObject(directorSpawnRequest);
                    Chat.AddMessage($"<color=yellow>Spawned \"{buttonText}\" on team \"{Spawn.team[Spawn.teamIndex]}\" </color>");
                }
            }
        }
Пример #31
0
 /*
  *  This function will remove isc from the interactable spawn card name, to save me typing it again everywhere.
  *  ie. iscShrineCleanse to ShrineCleanse
  */
 public static string GetSpawnCardName(SpawnCard givenSpawnCard)
 {
     return(GetSpawnCardName(givenSpawnCard.name));
 }
Пример #32
0
 private void GalaticAquaticAquarium(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport report)
 {
     //This is the entire spawning logic & by god it's a mess, but it works & I'll change it eventually, just not right now.
     //This starts off with if the attacker has an inventory, simple check for 90% of scenarios that enemies don't have inventories to prevent all deaths from being checked.
     if (report.attackerBody.inventory)
     {
         //Three variables are created, one for how many squidTurretItems the attacker has.
         //One for counting the chance of monster spawning, which is 5 + count of squidTurretItem in the attackers inventory.
         //Finally the squid team itself, 1/20 chance to become an enemy at base value, value increases for every stack the attacker has.
         int HowManySquidsAreInYourPocket = report.attackerBody.inventory.GetItemCount(squidTurretItem.itemIndex);
         int squidStackCheck = 5 + HowManySquidsAreInYourPocket;
         var squidTeam       = Util.CheckRoll(squidStackCheck) ? TeamIndex.Monster : TeamIndex.Player;
         //Three if statements are created, one for checking if CharacterMaster is null, then do nothing.
         //One is created if DamageReport is null, then do nothing
         //One for if there's a victim and if there's an attacker, which is what starts the spawning itself.
         if (self is null)
         {
             return;
         }
         if (report is null)
         {
             return;
         }
         if (report.victimBody && report.attacker)
         {
             //A check is then performed to see if the attackers count of squidTurretItem is greater than 0
             if (HowManySquidsAreInYourPocket > 0)
             {
                 //A spawn card is created utilizing the SquidTurret spawn card.
                 SpawnCard spawnCard = Resources.Load <CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/cscSquidTurret");
                 //A placement rule is created so that the Squid Turrets spawn on the victims body.
                 DirectorPlacementRule placementRule = new DirectorPlacementRule
                 {
                     placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                     minDistance   = 5f,
                     maxDistance   = 25f,
                     spawnOnTarget = report.victimBody.transform,
                 };
                 //A spawn request is generated using the aforementioned variables of Spawn Card and the Placement Rule.
                 DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest(spawnCard, placementRule, RoR2Application.rng)
                 {
                     teamIndexOverride = squidTeam
                 };
                 //A secondary spawn request is then made using the first one as a baseline
                 //The second spawn request delagates the initial spawn request into a new Action which is Spawn Result and names it result.
                 DirectorSpawnRequest directorSpawnRequest2 = directorSpawnRequest;
                 directorSpawnRequest2.onSpawnedServer = (Action <SpawnCard.SpawnResult>) Delegate.Combine(directorSpawnRequest2.onSpawnedServer, new Action <SpawnCard.SpawnResult>(delegate(SpawnCard.SpawnResult result)
                 {
                     //A pseudo character named squidTurret which is the result of the spawned instance in the aforementioned directorSpawnRequest 2 and its Character Master is then inherited into it.
                     //The squid is then given 15 stacks of Health Decay (Half of a regular squid)
                     //It is also given 20 BoostAttackSpeeds which is then amplified by the amount of squidTurretItems the attacker has (Double the regular squid)
                     CharacterMaster squidTurret = result.spawnedInstance.GetComponent <CharacterMaster>();
                     if (squidTeam == TeamIndex.Monster)
                     {
                         squidTurret.inventory.GiveItem(ItemIndex.HealthDecay, 20);
                         squidTurret.inventory.GiveItem(ItemIndex.BoostAttackSpeed, 5 * HowManySquidsAreInYourPocket);
                     }
                     else
                     {
                         squidTurret.inventory.GiveItem(ItemIndex.HealthDecay, 45);
                         squidTurret.inventory.GiveItem(ItemIndex.BoostAttackSpeed, 20 * HowManySquidsAreInYourPocket);
                     }
                     //Three variables are created here, one being the current run in order to invoke the next two.
                     //The current fixed time is then generated & divided by 60 to turn the current chance to a 1:1 for 1% every 1 minute.
                     //A fixed rate of base being 1%, then adding whatever the current additional chance is.
                     float AdditionalChance = Run.instance.fixedTime;
                     float squidSpawnAsBuffedSquidChance = 1 + (AdditionalChance / 60) + (HowManySquidsAreInYourPocket * 2);
                     //A check is them performed to check if the squid is on the player index.
                     //If this check if passed, a 1/100 roll is performed to see if the squid inherits a random item from the SquidItemIndex created at the top of page.
                     //If this fails, a secondary 1/100 roll is performed to see if the squid inherits a random elite buff from the SquidBuffIndex created in "JackedSquidsGettingBuffed" method.
                     if (squidTeam == TeamIndex.Player)
                     {
                         if (Util.CheckRoll(squidSpawnAsBuffedSquidChance))
                         {
                             squidTurret.GetBody().AddBuff(SquidBuffIndex[UnityEngine.Random.Range(0, SquidBuffIndex.Count())]);
                         }
                         else if (Util.CheckRoll(squidSpawnAsBuffedSquidChance))
                         {
                             squidTurret.inventory.GiveItem(SquidItemIndex[UnityEngine.Random.Range(0, SquidItemIndex.Count())]);
                         }
                     }
                     //Once these checks have passed, the squidTurrets ownership is passed onto the attacker who initially spawned it.
                     squidTurret.minionOwnership.SetOwner(report.attackerMaster);
                 }));
                 //Finally the squid is attempted to be spawned.
                 if (Util.CheckRoll(25))
                 {
                     DirectorCore.instance.TrySpawnObject(directorSpawnRequest);
                 }
             }
         }
     }
     //The damage report is returned to itself, the character deaths are returned to itself and finally globaleventmanger is returned to itself.
     orig(self, report);
 }
Пример #33
0
        public override void OnLoad()
        {
            base.OnLoad();
            itemDef.name = "MysticsItems_TreasureMap";
            SetItemTierWhenAvailable(ItemTier.Tier3);
            itemDef.tags = new ItemTag[]
            {
                ItemTag.Utility,
                ItemTag.AIBlacklist,
                ItemTag.CannotCopy
            };
            itemDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Treasure Map/Model.prefab"));
            itemDef.pickupIconSprite  = Main.AssetBundle.LoadAsset <Sprite>("Assets/Items/Treasure Map/Icon.png");
            ModelPanelParameters modelPanelParams = itemDef.pickupModelPrefab.GetComponentInChildren <ModelPanelParameters>();

            modelPanelParams.minDistance = 3;
            modelPanelParams.maxDistance = 6;
            itemDisplayPrefab            = PrepareItemDisplayModel(PrefabAPI.InstantiateClone(itemDef.pickupModelPrefab, itemDef.pickupModelPrefab.name + "Display", false));
            onSetupIDRS += () =>
            {
                AddDisplayRule("CommandoBody", "LowerArmR", new Vector3(-0.084F, 0.183F, -0.006F), new Vector3(83.186F, 36.557F, 131.348F), new Vector3(0.053F, 0.053F, 0.053F));
                AddDisplayRule("HuntressBody", "Muzzle", new Vector3(-0.527F, -0.032F, -0.396F), new Vector3(0.509F, 134.442F, 184.268F), new Vector3(0.042F, 0.042F, 0.042F));
                AddDisplayRule("Bandit2Body", "MuzzleShotgun", new Vector3(0.014F, -0.07F, -0.668F), new Vector3(0F, 180F, 180F), new Vector3(0.04F, 0.04F, 0.04F));
                AddDisplayRule("ToolbotBody", "Head", new Vector3(0.198F, 3.655F, -0.532F), new Vector3(304.724F, 180F, 180F), new Vector3(0.448F, 0.448F, 0.448F));
                AddDisplayRule("EngiBody", "WristDisplay", new Vector3(0.01F, -0.001F, 0.007F), new Vector3(86.234F, 155.949F, 155.218F), new Vector3(0.065F, 0.065F, 0.065F));
                AddDisplayRule("MageBody", "LowerArmR", new Vector3(0.116F, 0.188F, 0.008F), new Vector3(88.872F, 20.576F, 290.58F), new Vector3(0.074F, 0.074F, 0.074F));
                AddDisplayRule("MercBody", "LowerArmR", new Vector3(-0.01F, 0.144F, -0.116F), new Vector3(277.017F, 64.808F, 295.358F), new Vector3(0.072F, 0.072F, 0.072F));
                AddDisplayRule("TreebotBody", "HeadBase", new Vector3(-0.013F, 0.253F, -0.813F), new Vector3(1.857F, 5.075F, 0.053F), new Vector3(0.13F, 0.143F, 0.294F));
                AddDisplayRule("LoaderBody", "MechLowerArmR", new Vector3(-0.01F, 0.544F, -0.144F), new Vector3(275.35F, 95.995F, 266.284F), new Vector3(0.095F, 0.095F, 0.095F));
                AddDisplayRule("CrocoBody", "UpperArmR", new Vector3(1.735F, -0.575F, 0.196F), new Vector3(281.472F, 180.072F, 89.927F), new Vector3(0.868F, 0.868F, 0.868F));
                AddDisplayRule("CaptainBody", "HandR", new Vector3(-0.066F, 0.087F, 0.011F), new Vector3(76.759F, 135.292F, 224.52F), new Vector3(0.059F, 0.053F, 0.059F));
                AddDisplayRule("BrotherBody", "HandR", BrotherInfection.red, new Vector3(0.051F, -0.072F, 0.004F), new Vector3(44.814F, 122.901F, 267.545F), new Vector3(0.063F, 0.063F, 0.063F));
                if (SoftDependencies.SoftDependenciesCore.itemDisplaysSniper)
                {
                    AddDisplayRule("SniperClassicBody", "Chest", new Vector3(-0.10307F, 0.44329F, -0.26101F), new Vector3(0F, 0F, 0F), new Vector3(0.05402F, 0.05402F, 0.05402F));
                }
                AddDisplayRule("RailgunnerBody", "GunRoot", new Vector3(0.00726F, -0.15201F, 0.07672F), new Vector3(270F, 180F, 0F), new Vector3(0.05025F, 0.05025F, 0.05025F));
                AddDisplayRule("VoidSurvivorBody", "ForeArmL", new Vector3(0.06352F, 0.24419F, 0.00664F), new Vector3(69.26795F, 34.44471F, 302.5876F), new Vector3(0.05926F, 0.05926F, 0.05926F));
            };

            MysticsRisky2Utils.Utils.CopyChildren(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Treasure Map/TreasureMapZone.prefab"), zonePrefab);
            HoldoutZoneController holdoutZone = zonePrefab.AddComponent <HoldoutZoneController>();

            holdoutZone.baseRadius                = radius;
            holdoutZone.baseChargeDuration        = unearthTime;
            holdoutZone.radiusSmoothTime          = 1f;
            holdoutZone.radiusIndicator           = zonePrefab.transform.Find("Visuals/Sphere").gameObject.GetComponent <Renderer>();
            holdoutZone.inBoundsObjectiveToken    = "OBJECTIVE_MYSTICSITEMS_CHARGE_TREASUREMAPZONE";
            holdoutZone.outOfBoundsObjectiveToken = "OBJECTIVE_MYSTICSITEMS_CHARGE_TREASUREMAPZONE_OOB";
            holdoutZone.applyHealingNova          = true;
            holdoutZone.applyFocusConvergence     = true;
            holdoutZone.playerCountScaling        = 0f; // Charge by 1 second regardless of how many players are charging the zone
            holdoutZone.dischargeRate             = 0f;
            holdoutZone.enabled = false;
            MysticsItemsTreasureMapZone captureZone = zonePrefab.AddComponent <MysticsItemsTreasureMapZone>();

            captureZone.itemDef       = itemDef;
            captureZone.dropTable     = Addressables.LoadAssetAsync <PickupDropTable>("RoR2/Base/GoldChest/dtGoldChest.asset").WaitForCompletion();
            captureZone.dropTransform = zonePrefab.transform.Find("DropPivot");
            HologramProjector hologramProjector = zonePrefab.AddComponent <HologramProjector>();

            hologramProjector.displayDistance = holdoutZone.baseRadius;
            hologramProjector.hologramPivot   = zonePrefab.transform.Find("HologramPivot");
            hologramProjector.hologramPivot.transform.localScale *= 2f;
            hologramProjector.disableHologramRotation             = false;
            captureZone.hologramProjector = hologramProjector;
            Decal decal = zonePrefab.transform.Find("Decal").gameObject.AddComponent <Decal>();

            decal.RenderMode = Decal.DecalRenderMode.Deferred;
            Material decalMaterial = new Material(LegacyShaderAPI.Find("Decalicious/Deferred Decal"));

            decal.Material     = decalMaterial;
            decalMaterial.name = "MysticsItems_TreasureMapDecal";
            Texture decalTexture = Main.AssetBundle.LoadAsset <Texture>("Assets/Items/Treasure Map/texTreasureMapDecal.png");

            decalMaterial.SetTexture("_MainTex", decalTexture);
            decalMaterial.SetTexture("_MaskTex", decalTexture);
            decalMaterial.SetFloat("_AngleLimit", 0.6f);
            decalMaterial.SetFloat("_DecalLayer", 1f);
            decalMaterial.SetFloat("_DecalBlendMode", 0f);
            decalMaterial.SetColor("_Color", new Color32(70, 10, 10, 255));
            decalMaterial.SetColor("_EmissionColor", Color.black);
            decal.Fade                = 1f;
            decal.DrawAlbedo          = true;
            decal.UseLightProbes      = true;
            decal.DrawNormalAndGloss  = false;
            decal.HighQualityBlending = false;
            {
                decal.GetComponent <MeshFilter>().sharedMesh = LegacyResourcesAPI.Load <Mesh>("DecalCube");
                MeshRenderer component = decal.GetComponent <MeshRenderer>();
                component.shadowCastingMode    = UnityEngine.Rendering.ShadowCastingMode.Off;
                component.receiveShadows       = false;
                component.materials            = new Material[0];
                component.lightProbeUsage      = UnityEngine.Rendering.LightProbeUsage.BlendProbes;
                component.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
            }
            decal.gameObject.transform.localScale = Vector3.one * 10f;
            HG.ArrayUtils.ArrayAppend(ref captureZone.toggleObjects, decal.gameObject);

            On.RoR2.HoldoutZoneController.ChargeHoldoutZoneObjectiveTracker.ShouldBeFlashing += (orig, self) =>
            {
                if (self.sourceDescriptor.master)
                {
                    HoldoutZoneController holdoutZoneController = (HoldoutZoneController)self.sourceDescriptor.source;
                    if (holdoutZoneController && holdoutZoneController.gameObject.GetComponent <MysticsItemsTreasureMapZone>())
                    {
                        var teleporterInteraction = TeleporterInteraction.instance;
                        if (teleporterInteraction && teleporterInteraction.isCharged)
                        {
                            return(true);
                        }
                        return(false);
                    }
                }
                return(orig(self));
            };

            zoneSpawnCard                    = ScriptableObject.CreateInstance <SpawnCard>();
            zoneSpawnCard.name               = "iscMysticsItems_TreasureMapZone";
            zoneSpawnCard.prefab             = zonePrefab;
            zoneSpawnCard.directorCreditCost = 0;
            zoneSpawnCard.sendOverNetwork    = true;
            zoneSpawnCard.hullSize           = HullClassification.Human;
            zoneSpawnCard.nodeGraphType      = RoR2.Navigation.MapNodeGroup.GraphType.Ground;
            zoneSpawnCard.requiredFlags      = RoR2.Navigation.NodeFlags.None;
            zoneSpawnCard.forbiddenFlags     = RoR2.Navigation.NodeFlags.None;
            zoneSpawnCard.occupyPosition     = false;

            GenericGameEvents.OnPopulateScene += (rng) =>
            {
                DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(zoneSpawnCard, new DirectorPlacementRule
                {
                    placementMode = DirectorPlacementRule.PlacementMode.Random
                }, rng));
            };

            ghostMaterial = LegacyResourcesAPI.Load <Material>("Materials/matGhostEffect");

            soundEventDef           = ScriptableObject.CreateInstance <NetworkSoundEventDef>();
            soundEventDef.eventName = "MysticsItems_Play_env_treasuremap";
            MysticsItemsContent.Resources.networkSoundEventDefs.Add(soundEventDef);

            effectPrefab = Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Treasure Map/UnearthEffect.prefab");
            EffectComponent effectComponent = effectPrefab.AddComponent <EffectComponent>();
            VFXAttributes   vfxAttributes   = effectPrefab.AddComponent <VFXAttributes>();

            vfxAttributes.vfxIntensity = VFXAttributes.VFXIntensity.Medium;
            vfxAttributes.vfxPriority  = VFXAttributes.VFXPriority.Medium;
            effectPrefab.AddComponent <DestroyOnTimer>().duration = 1f;
            ShakeEmitter shakeEmitter = effectPrefab.AddComponent <ShakeEmitter>();

            shakeEmitter.shakeOnStart  = true;
            shakeEmitter.shakeOnEnable = false;
            shakeEmitter.duration      = 0.3f;
            shakeEmitter.radius        = 25f;
            shakeEmitter.scaleShakeRadiusWithLocalScale = false;
            shakeEmitter.wave = new Wave
            {
                amplitude = 3f,
                frequency = 200f
            };
            shakeEmitter.amplitudeTimeDecay = true;
            MysticsItemsContent.Resources.effectPrefabs.Add(effectPrefab);

            TeleporterInteraction.onTeleporterChargedGlobal += TeleporterInteraction_onTeleporterChargedGlobal;
        }