Beispiel #1
0
        private void GlobalEventManager_onCharacterDeathGlobal(DamageReport damageReport)
        {
            if (!NetworkServer.active || !Stage.instance)
            {
                return;
            }
            BulletstormPickupsComponent pickupsComponent = Stage.instance.GetComponent <BulletstormPickupsComponent>();

            if (!pickupsComponent)
            {
                return;
            }
            if (CheckIfDoll(damageReport.damageInfo) || damageReport.victimTeamIndex == TeamIndex.Player || damageReport.victimTeamIndex == TeamIndex.None)
            {
                return;
            }
            var           requiredKills = pickupsComponent.requiredKills;
            CharacterBody VictimBody    = damageReport.victimBody;

            if (VictimBody)
            {
                //int DiffMultAdd = Run.instance.selectedDifficulty; //TODO: Add difficulty scaling?
                pickupsComponent.globalDeaths++;
                if (ShowProgress)
                {
                    _logger.LogMessage(string.Format("[Bulletstorm] Kills/StageRequired: {0}/{1}", pickupsComponent.globalDeaths, requiredKills));
                }

                if (pickupsComponent.globalDeaths % requiredKills == 0)
                {
                    Vector3 pickupPosition = EvaluatePickupPosition(pickupsComponent, VictimBody);
                    pickupPosition += Vector3.up * 2f;
                    if (ShowProgress)
                    {
                        _logger.LogMessage(string.Format("Pickups Controller: Resulting Kill Info (setup for roll):" +
                                                         "\nwasMapDeath: {0}" +
                                                         "\nlastHitAttacker: {1}" +
                                                         "\nposition: {2}", pickupsComponent.wasMapDeath, pickupsComponent.lastHitAttacker, pickupPosition));
                    }

                    var teamLuck = RiskOfBulletstorm.Utils.HelperUtil.GetPlayersLuck();
                    if (Util.CheckRoll(RollChance, teamLuck)) //Roll to spawn pickups
                    {
                        //Chat.AddMessage("Pickups: Rolled success.");

                        SpawnPickup(pickupPosition);
                    }
                    else
                    {
                        if (ShowProgress)
                        {
                            _logger.LogMessage("[Bulletstorm] Pickups Controller: Roll failed!");
                        }
                    }
                    pickupsComponent.wasMapDeath     = false;
                    pickupsComponent.lastHitAttacker = null;
                    pickupsComponent.globalDeaths    = 0;
                }
            }
        }
Beispiel #2
0
        private Vector3 EvaluatePickupPosition(BulletstormPickupsComponent pickupsComponent, CharacterBody victimBody)
        {
            Vector3 PickupPosition = new Vector3();

            if (pickupsComponent.wasMapDeath)                                             //If they die from falling off the map
            {
                if (pickupsComponent.lastHitAttacker)                                     // get the last attacker
                {
                    PickupPosition = pickupsComponent.lastHitAttacker.transform.position; //set the position of the pickup to be on the player
                }
                else
                {
                    var playerSearch = new BullseyeSearch() //let's just get the nearest player
                    {
                        viewer         = victimBody,
                        sortMode       = BullseyeSearch.SortMode.Distance,
                        teamMaskFilter = TeamMask.allButNeutral
                    };
                    playerSearch.teamMaskFilter.RemoveTeam(TeamIndex.Monster);
                    playerSearch.RefreshCandidates();
                    playerSearch.FilterOutGameObject(victimBody.gameObject);
                    var  list    = playerSearch.GetResults().ToList();
                    bool success = false;
                    if (list.Count > 0)
                    {
                        foreach (var player in list)
                        {
                            var body = player.gameObject.GetComponent <CharacterBody>();
                            if (body)
                            {
                                if (body.isPlayerControlled)
                                {
                                    PickupPosition = body.corePosition;
                                    success        = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (!success) //
                    {
                        PickupPosition = list.FirstOrDefault().transform.position;
                    }
                }
            }
            else // If it wasn't a map death
            {
                PickupPosition = victimBody.transform.position;
            }
            return(PickupPosition);
        }
Beispiel #3
0
        private void MapZone_TryZoneStart(On.RoR2.MapZone.orig_TryZoneStart orig, MapZone self, Collider other)
        {
            orig(self, other);
            if (!Stage.instance)
            {
                return;
            }
            BulletstormPickupsComponent pickupsComponent = Stage.instance.GetComponent <BulletstormPickupsComponent>();

            if (!pickupsComponent)
            {
                return;
            }
            CharacterBody characterBody = other.GetComponent <CharacterBody>();

            if (!characterBody)
            {
                return;
            }
            TeamComponent teamComponent = characterBody.teamComponent;

            if (!teamComponent)
            {
                return;
            }
            if (teamComponent.teamIndex == TeamIndex.Player)
            {
                return;
            }

            if (self.zoneType == MapZone.ZoneType.OutOfBounds)
            {
                HealthComponent healthComponent = characterBody.healthComponent;
                if (healthComponent)
                {
                    pickupsComponent.wasMapDeath     = true;
                    pickupsComponent.lastHitAttacker = healthComponent.lastHitAttacker;
                }
            }
        }