Ejemplo n.º 1
0
        public void Init(CharacterBody body)
        {
            this.body    = body;
            rewards      = body.gameObject.GetComponent <DeathRewards>();
            initialScale = body.modelLocator.modelTransform.localScale;
            count        = 1;

            if (!dict.ContainsKey(body.baseNameToken))
            {
                baseStats = new Stats {
                    baseMaxHealth   = body.baseMaxHealth,
                    baseRegen       = body.baseRegen,
                    baseMoveSpeed   = body.baseMoveSpeed,
                    baseDamage      = body.baseDamage,
                    baseAttackSpeed = body.baseAttackSpeed,
                    baseCrit        = body.baseCrit,
                    baseArmor       = body.baseArmor
                };

                baseStatDict.Add(body.baseNameToken, baseStats);
                dict.Add(body.baseNameToken, new List <CongregateController>());
            }
            else
            {
                baseStats = baseStatDict[body.baseNameToken]; // get a reference to another base stats class to prevent a large amount of memory use
            }

            dict[body.baseNameToken].Add(this);
        }
Ejemplo n.º 2
0
        private void btnAttack_Click(object sender, RoutedEventArgs e)
        {
            if (dgEnemies.SelectedItem != null)
            {
                if (currentRoom.enemies[dgEnemies.SelectedIndex].Health - player.DealDamage() > 0)
                {
                    currentRoom.enemies[dgEnemies.SelectedIndex].LoseHealth(player.DealDamage());
                    dgEnemies.Items.Refresh();
                    txtCenter.Text += $"You dealt {player.DealDamage()} damage points with {player.GetWeapon().Name} to {currentRoom.enemies[dgEnemies.SelectedIndex].Name}{Environment.NewLine}";
                    UpdatePlayerInfo();
                }
                else
                {
                    var rewards = new DeathRewards();
                    player.GainExp(rewards.Exp);
                    player.GetGold(rewards.Gold);
                    txtCenter.Text += $"You killed {currentRoom.enemies[dgEnemies.SelectedIndex].Name}!{Environment.NewLine}You gained {rewards.Gold} Gold & {rewards.Exp} Exp!{Environment.NewLine}";
                    currentRoom.enemies.Remove(currentRoom.enemies[dgEnemies.SelectedIndex]);
                    dgEnemies.Items.Refresh();
                    UpdatePlayerInfo();

                    if (currentRoom.enemies.Count == 0)
                    {
                        txtCenter.Text += "Congrats, you have cleared this room!";
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void MoneyReduction(On.RoR2.DeathRewards.orig_OnKilledServer orig, DeathRewards self, DamageReport rep)
        {
            if (rep.attackerBody && self)
            {
                var inventoryCount = GetCount(rep.attackerMaster);
                if (inventoryCount > 0)
                {
                    var insuranceSavingsTrackerComponent = rep.attackerMaster.gameObject.GetComponent <InsuranceSavingsTracker>();
                    if (!insuranceSavingsTrackerComponent)
                    {
                        rep.attackerMaster.gameObject.AddComponent <InsuranceSavingsTracker>();
                    }

                    uint origGold     = self.goldReward;
                    uint reducedGold  = (uint)Mathf.FloorToInt(self.goldReward * (1 - ((.5f * inventoryCount) / (inventoryCount + 1))));
                    uint investedGold = origGold - reducedGold;
                    self.goldReward = reducedGold;

                    //Could you theoretically go over uint.MaxValue here? idk
                    insuranceSavingsTrackerComponent.insuranceSavings += investedGold;
                    Debug.LogError("The money is actually being tracked. Rn you have " + insuranceSavingsTrackerComponent.insuranceSavings);
                }
            }

            orig(self, rep);
        }
Ejemplo n.º 4
0
        private void MoneyReduction(On.RoR2.DeathRewards.orig_OnKilledServer orig, DeathRewards self, DamageReport rep)
        {
            uint inventoryCount = Convert.ToUInt32(GetCount(rep.attackerBody));

            if (inventoryCount > 0)
            {
                uint reducedGold  = (uint)Mathf.FloorToInt(self.goldReward * (1 - ((25 * inventoryCount) / 100 + (25 * (inventoryCount - 1)))));
                uint investedGold = (uint)Mathf.FloorToInt(self.goldReward - reducedGold + ((self.goldReward - reducedGold) * ((inventoryCount - 1) / 4)));
                self.goldReward = reducedGold;

                var insuranceSavingsTrackerComponent = rep.attackerBody.master.gameObject.GetComponent <InsuranceSavingsTracker>();
                if (!insuranceSavingsTrackerComponent)
                {
                    rep.attackerBody.master.gameObject.AddComponent <InsuranceSavingsTracker>();
                }

                //Could you theoretically go over uint.MaxValue here? idk
                insuranceSavingsTrackerComponent.insuranceSavings += investedGold;
            }

            orig(self, rep);
        }
Ejemplo n.º 5
0
        private void On_DROnKilledServer(On.RoR2.DeathRewards.orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport)
        {
            orig(self, damageReport);

            if (damageReport == null)
            {
                return;
            }
            CharacterBody victimBody = damageReport.victimBody;

            if (victimBody == null || victimBody.teamComponent.teamIndex != TeamIndex.Monster || !victimBody.isElite)
            {
                return;
            }
            int numberOfClovers = 0;

            if (globalStack)
            {
                foreach (CharacterMaster chrm in AliveList())
                {
                    if (!inclDeploys && chrm.GetComponent <Deployable>())
                    {
                        continue;
                    }
                    numberOfClovers += chrm?.inventory?.GetItemCount(catalogIndex) ?? 0;
                }
            }
            else
            {
                numberOfClovers += damageReport.attackerMaster?.inventory?.GetItemCount(catalogIndex) ?? 0;
            }

            if (numberOfClovers == 0)
            {
                return;
            }

            float rareChance     = Math.Min(baseRare + (numberOfClovers - 1) * stackRare, capRare);
            float uncommonChance = Math.Min(baseUnc + (numberOfClovers - 1) * stackUnc, capUnc);
            float anyDropChance  = Math.Min(baseChance + (numberOfClovers - 1) * stackChance, capChance);

            //Base drop chance is multiplicative with tier chances -- tier chances are applied to upgrade the dropped item

            if (Util.CheckRoll(anyDropChance))
            {
                int tier;
                if (Util.CheckRoll(rareChance))
                {
                    tier = 2;
                }
                else if (Util.CheckRoll(uncommonChance))
                {
                    tier = 1;
                }
                else
                {
                    if (Util.CheckRoll(baseEqp))
                    {
                        tier = 4;
                    }
                    else
                    {
                        tier = 0;
                    }
                }
                SpawnItemFromBody(victimBody, tier, rng);
            }
        }
        private static void ShareKillMoney(On.RoR2.DeathRewards.orig_OnKilledServer orig, DeathRewards self,
                                           DamageReport damageReport)
        {
            orig(self, damageReport);

            #region Sharedmoney

            // Collect reward from kill and put it into shared pool
            SharedMoneyValue += (int)self.goldReward;

            if (!ShareSuite.MoneyScalarEnabled.Value ||
                !NetworkServer.active)
            {
                return;
            }

            GiveAllScaledMoney(self.goldReward);

            #endregion
        }
Ejemplo n.º 7
0
        private void CreatePrefab() //internal static
        {
            characterPrefab = PrefabAPI.InstantiateClone(Resources.Load <GameObject>("Prefabs/CharacterBodies/BeetleBody"), "DogBody", true);

            //CharacterMotor characterMotor = characterPrefab.GetComponent<CharacterMotor>();

            //string name = names[UnityEngine.Random.Range(0, names.Length)];

            for (int i = 0; i < names.Length; i++)
            {
                LanguageAPI.Add("DOG_NAME_" + i.ToString(), names[i]);
                Debug.Log("Added Token: " + "DOG_NAME_" + i.ToString() + " : " + names[i]);
            }
            LanguageAPI.Add("DOG_NAME", "Junior");
            LanguageAPI.Add("DOG_SUBTITLE", "The Petted");
            LanguageAPI.Add("DOG_INTERACT", "Pet the beetle");
            CharacterBody bodyComponent = characterPrefab.GetComponent <CharacterBody>();

            bodyComponent.bodyIndex         = -1;             //def: 19
            bodyComponent.baseNameToken     = "DOG_NAME";     // name token
            bodyComponent.subtitleNameToken = "DOG_SUBTITLE"; // subtitle token- used for umbras
            bodyComponent.bodyFlags         = CharacterBody.BodyFlags.SprintAnyDirection;
            //bodyComponent.mainRootSpeed = 0;
            bodyComponent.baseMaxHealth  = 10000;
            bodyComponent.levelMaxHealth = 10000;
            bodyComponent.baseRegen      = 1000f;
            bodyComponent.levelRegen     = 1000f;
            bodyComponent.baseMaxShield  = 0;
            bodyComponent.levelMaxShield = 0;
            //bodyComponent.baseMoveSpeed = 12;
            bodyComponent.levelMoveSpeed = 0;
            //bodyComponent.baseAcceleration = 80;
            //bodyComponent.baseJumpPower = 0;
            bodyComponent.levelJumpPower = 0;
            //bodyComponent.baseDamage = 15;
            //bodyComponent.levelDamage = 1.5f;
            bodyComponent.baseAttackSpeed  = 1;
            bodyComponent.levelAttackSpeed = 0;
            bodyComponent.baseCrit         = 0;
            //bodyComponent.levelCrit = 0;
            bodyComponent.baseArmor                = 10000; // 0.0099 damage multiplier
            bodyComponent.levelArmor               = 0;
            bodyComponent.baseJumpCount            = 0;
            bodyComponent.sprintingSpeedMultiplier = 1.45f;

            HealthComponent healthComponent = characterPrefab.GetComponent <HealthComponent>();

            healthComponent.dontShowHealthbar = true;

            Highlight highlight = characterPrefab.AddComponent <Highlight>() as Highlight;

            highlight.pickupIndex = PickupCatalog.FindPickupIndex(ItemIndex.Syringe);
            //highlight.targetRenderer = Sphere(UnityEngine.MeshRenderer);
            GameObject artibodyprefab = BodyCatalog.FindBodyPrefab("ArtifactShellBody");

            highlight.targetRenderer = artibodyprefab.GetComponent <Highlight>().targetRenderer;
            highlight.strength       = 1;
            highlight.highlightColor = Highlight.HighlightColor.interactive;
            highlight.isOn           = true; //false

            PurchaseInteraction purchaseInteraction = characterPrefab.AddComponent <PurchaseInteraction>();

            purchaseInteraction.displayNameToken = "DOG_NAME";
            purchaseInteraction.contextToken     = "DOG_INTERACT";
            purchaseInteraction.costType         = CostTypeIndex.None;
            purchaseInteraction.available        = true;
            purchaseInteraction.cost             = 0;
            purchaseInteraction.automaticallyScaleCostWithDifficulty = false;

            DeathRewards deathRewards = characterPrefab.GetComponent <DeathRewards>();

            if (deathRewards)
            {
                deathRewards.expReward  = 0;
                deathRewards.goldReward = 0;
            }

            characterPrefab.AddComponent <IsBeetle>();
        }
Ejemplo n.º 8
0
            static bool Prefix(
                BossGroup __instance,
                DamageReport damageReport,
                ref List <PickupIndex> ___bossDrops,
                ref List <CharacterMaster> ___membersList,
                ref bool ___defeated,
                ref Xoroshiro128Plus ___rng
                )
            {
                if (!NetworkServer.active)
                {
                    Debug.LogWarning("[Server] function 'System.Void RoR2.BossGroup::OnCharacterDeathCallback(RoR2.DamageReport)' called on client");
                    return(false);
                }
                DamageInfo    damageInfo = damageReport.damageInfo;
                GameObject    gameObject = damageReport.victim.gameObject;
                CharacterBody component  = gameObject.GetComponent <CharacterBody>();

                if (!component)
                {
                    return(false);
                }
                CharacterMaster master = component.master;

                if (!master)
                {
                    return(false);
                }
                DeathRewards component2 = gameObject.GetComponent <DeathRewards>();

                if (component2)
                {
                    PickupIndex pickupIndex = (PickupIndex)component2.bossPickup;
                    if (pickupIndex != PickupIndex.none)
                    {
                        ___bossDrops.Add(pickupIndex);
                    }
                }
                GameObject victimMasterGameObject = master.gameObject;
                int        num = ___membersList.FindIndex((CharacterMaster x) => x.gameObject == victimMasterGameObject);

                if (num >= 0)
                {
                    typeof(BossGroup).GetMethod("RemoveMemberAt", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { num });
                    if (!___defeated && ___membersList.Count == 0)
                    {
                        Run.instance.OnServerBossKilled(true);
                        if (component)
                        {
                            int participatingPlayerCount = Run.instance.participatingPlayerCount;
                            if (participatingPlayerCount != 0 && __instance.dropPosition)
                            {
                                ItemIndex  itemIndex = Run.instance.availableTier2DropList[___rng.RangeInt(0, Run.instance.availableTier2DropList.Count)].itemIndex;
                                int        num2      = TeleAwardInVar.Value * participatingPlayerCount * (1 + (TeleporterInteraction.instance ? TeleporterInteraction.instance.shrineBonusStacks : 0));
                                float      angle     = 360f / (float)num2;
                                Vector3    vector    = Quaternion.AngleAxis((float)UnityEngine.Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f);
                                Quaternion rotation  = Quaternion.AngleAxis(angle, Vector3.up);
                                int        i         = 0;
                                while (i < num2)
                                {
                                    PickupIndex pickupIndex2 = new PickupIndex(itemIndex);
                                    if (___bossDrops.Count > 0 && ___rng.nextNormalizedFloat <= __instance.bossDropChance)
                                    {
                                        pickupIndex2 = ___bossDrops[___rng.RangeInt(0, ___bossDrops.Count)];
                                    }
                                    PickupDropletController.CreatePickupDroplet(pickupIndex2, __instance.dropPosition.position, vector);
                                    i++;
                                    vector = rotation * vector;
                                }
                            }
                        }
                        ___defeated = true;
                        typeof(BossGroup).Raise("onBossGroupDefeatedServer", __instance);
                        return(false);
                    }
                    else
                    {
                        Run.instance.OnServerBossKilled(false);
                    }
                }
                return(false);
            }
Ejemplo n.º 9
0
        private void On_DROnKilledServer(On.RoR2.DeathRewards.orig_OnKilledServer orig, DeathRewards self, DamageReport rep)
        {
            int icnt = GetCount(rep.attackerBody);

            self.goldReward = (uint)Mathf.FloorToInt(self.goldReward * (1f + icnt * moneyMult));
            orig(self, rep);
        }
Ejemplo n.º 10
0
        private void DeathRewardsOnOnKilledServer(On.RoR2.DeathRewards.orig_OnKilledServer orig, DeathRewards self, DamageReport damagereport)
        {
            orig(self, damagereport);

            foreach (var mimic in _chestMimics.ToList())
            {
                if (mimic.BoundReward == self)
                {
                    PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(mimic.BoundItem), self.transform.position, 5f * Vector3.up);
                    _chestMimics.Remove(mimic);
                }
            }
        }
Ejemplo n.º 11
0
        private void DeathRewards_OnKilled(On.RoR2.DeathRewards.orig_OnKilled orig, DeathRewards self, DamageInfo damageInfo)
        {
            PickupDropletController.CreatePickupDroplet(PickupIndex.lunarCoin1, damageInfo.position, Vector3.zero);

            orig.Invoke(self, damageInfo);
        }
Ejemplo n.º 12
0
        private void SummonLunarChimera(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            int             inventoryCount = GetCount(self);
            CharacterMaster master         = self.master;

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

                                CharacterBody cBody = cMaster.GetBody();
                                if (cBody)
                                {
                                    //RoR2.Chat.AddMessage($"CharacterBody Found: {component4}");
                                    cBody.teamComponent.teamIndex = TeamIndex.Neutral;
                                    cBody.gameObject.AddComponent <LunarChimeraRetargetComponent>();
                                    lcComponent.LastChimeraSpawned = cBody;
                                    DeathRewards deathRewards = cBody.GetComponent <DeathRewards>();
                                    if (deathRewards)
                                    {
                                        //RoR2.Chat.AddMessage($"DeathRewards Found: {component5}");
                                        deathRewards.goldReward = 0;
                                        deathRewards.expReward  = 0;
                                    }
                                    NetworkIdentity bodyNet = cBody.GetComponent <NetworkIdentity>();
                                    if (bodyNet)
                                    {
                                        new AssignOwner(lcComponent.netId, bodyNet.netId).Send(NetworkDestination.Clients);
                                    }
                                }
                            }
                            lcComponent.ResummonCooldown = lunarChimeraResummonCooldownDuration;
                        }
                    }
                }
            }
            orig(self);
        }
Ejemplo n.º 13
0
        //private void ConvertPlayerMoneyToExperience_Start(On.RoR2.ConvertPlayerMoneyToExperience.orig_Start orig, ConvertPlayerMoneyToExperience self)
        //{
        //    self.burstCount = 1;
        //    //self.burstInterval = 0.05f;
        //    orig(self);
        //}

        private void DeathRewards_OnKilledServer(On.RoR2.DeathRewards.orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport)
        {
            if (isTeleporterBossDead)
            {
                SaveCurrentPlayerMoney();
            }
            orig(self, damageReport);
            GiveExpToPlayers();
            //experienceCollector = base.gameObject.AddComponent<ConvertPlayerMoneyToExperience>(); //doesn't work because any money added within a certain amount of time just evaporates
            if (damageReport.victimMaster.isBoss)
            {
                GiveMoneyToPlayers(ModConfig.MoneyGrantedPerTeleporterBossClear.Value);
            }
            else if (isTeleporterBossDead)
            {
                RestoreCurrentPlayerMoney();
            }
        }