Beispiel #1
0
        private void CharacterDead(Character character, CauseOfDeath causeOfDeath)
        {
            if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient)
            {
                return;
            }
            if (Strength < Prefab.MaxStrength * 0.5f || character.Removed)
            {
                return;
            }

            //don't turn the character into a husk if any of its limbs are severed
            if (character.AnimController?.LimbJoints != null)
            {
                foreach (var limbJoint in character.AnimController.LimbJoints)
                {
                    if (limbJoint.IsSevered)
                    {
                        return;
                    }
                }
            }

            //create the AI husk in a coroutine to ensure that we don't modify the character list while enumerating it
            CoroutineManager.StartCoroutine(CreateAIHusk(character));
        }
Beispiel #2
0
        private void CharacterDead(Character character, CauseOfDeath causeOfDeath)
        {
            if (GameMain.Client != null)
            {
                return;
            }

            //don't turn the character into a husk if any of its limbs are severed
            if (character.AnimController?.LimbJoints != null)
            {
                foreach (var limbJoint in character.AnimController.LimbJoints)
                {
                    if (limbJoint.IsSevered)
                    {
                        return;
                    }
                }
            }

            //Nilmod Deactivate players turning into husks on death optionally
            if (!GameMain.NilMod.PlayerHuskAiOnDeath)
            {
                if (GameMain.Server != null)
                {
                    GameMain.Server.ServerLog.WriteLine(character.Name + " Died husk infected but did not convert.", Networking.ServerLog.MessageType.Husk);
                }
                return;
            }

            //create the AI husk in a coroutine to ensure that we don't modify the character list while enumerating it
            //CoroutineManager.StartCoroutine(CreateAIHusk(character));
            CoroutineManager.StartCoroutine(CreateAIHusk(character));
        }
Beispiel #3
0
        public override void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker)
        {
            base.AddDamage(causeOfDeath, amount, attacker);

            if (attacker != null)
            {
                aiController.OnAttacked(attacker, amount);
            }
        }
        public override void AddDamage(CauseOfDeath causeOfDeath, float amount, Character attacker, string identifier = "")
        {
            base.AddDamage(causeOfDeath, amount, attacker, identifier);

            if (attacker != null)
            {
                aiController.OnAttacked(attacker, amount);
            }
        }
Beispiel #5
0
        private void CharacterDead(Character character, CauseOfDeath causeOfDeath)
        {
            if (GameMain.Client != null)
            {
                return;
            }

            //create the AI husk in a coroutine to ensure that we don't modify the character list while enumerating it
            CoroutineManager.StartCoroutine(CreateAIHusk(character));
        }
Beispiel #6
0
        private void CharacterDead(Character character, CauseOfDeath causeOfDeath)
        {
            if (GameMain.Client != null)
            {
                return;
            }

            var husk = Character.Create(
                Path.Combine("Content", "Characters", "Human", "humanhusk.xml"),
                character.WorldPosition,
                character.Info,
                false, true);

            foreach (Limb limb in husk.AnimController.Limbs)
            {
                if (limb.type == LimbType.None)
                {
                    limb.body.SetTransform(character.SimPosition, 0.0f);
                    continue;
                }

                var matchingLimb = character.AnimController.GetLimb(limb.type);
                limb.body.SetTransform(matchingLimb.SimPosition, matchingLimb.Rotation);
            }

            for (int i = 0; i < character.Inventory.Items.Length; i++)
            {
                if (character.Inventory.Items[i] == null)
                {
                    continue;
                }
                husk.Inventory.TryPutItem(character.Inventory.Items[i], i, true);
            }

            character.Enabled = false;
            Entity.Spawner.AddToRemoveQueue(character);
        }
Beispiel #7
0
 private void OnCharacterDeath(Character character, CauseOfDeath causeOfDeath)
 {
     DeattachFromBody();
     character.OnDeath -= OnCharacterDeath;
 }
Beispiel #8
0
        public static void OnCharacterKilled(Character character, CauseOfDeath causeOfDeath)
        {
#if CLIENT
            if (GameMain.Client != null || GameMain.GameSession == null)
            {
                return;
            }
#endif

            if (character != Character.Controlled &&
                causeOfDeath.Killer != null &&
                causeOfDeath.Killer == Character.Controlled)
            {
                SteamManager.IncrementStat(
                    character.SpeciesName.ToLowerInvariant() == "human" ? "humanskilled" : "monsterskilled",
                    1);
            }

            roundData.Casualties.Add(character);

            UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName);
            if (character.CurrentHull != null)
            {
                UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName + "indoors");
            }

            if (character.HasEquippedItem("clownmask") &&
                character.HasEquippedItem("clowncostume") &&
                causeOfDeath.Killer != character)
            {
                UnlockAchievement(causeOfDeath.Killer, "killclown");
            }

            if (causeOfDeath.DamageSource is Item item)
            {
                switch (item.Prefab.Identifier)
                {
                case "weldingtool":
                case "plasmacutter":
                case "wrench":
                    UnlockAchievement(causeOfDeath.Killer, "killtool");
                    break;

                case "morbusine":
                    UnlockAchievement(causeOfDeath.Killer, "killpoison");
                    break;

                case "nuclearshell":
                case "nucleardepthcharge":
                    UnlockAchievement(causeOfDeath.Killer, "killnuke");
                    break;
                }
            }

#if SERVER
            if (GameMain.Server?.TraitorManager != null)
            {
                foreach (Traitor traitor in GameMain.Server.TraitorManager.TraitorList)
                {
                    if (traitor.TargetCharacter == character)
                    {
                        //killed the target as a traitor
                        UnlockAchievement(traitor.Character, "traitorwin");
                    }
                    else if (traitor.Character == character)
                    {
                        //someone killed a traitor
                        UnlockAchievement(causeOfDeath.Killer, "killtraitor");
                    }
                }
            }
#endif
        }
Beispiel #9
0
 void OnCellDeath(Character character, CauseOfDeath causeOfDeath)
 {
     protectiveCells.Remove(character);
 }
Beispiel #10
0
        public static void OnCharacterKilled(Character character, CauseOfDeath causeOfDeath)
        {
#if CLIENT
            if (GameMain.Client != null || GameMain.GameSession == null)
            {
                return;
            }
#endif

            if (character != Character.Controlled &&
                causeOfDeath.Killer != null &&
                causeOfDeath.Killer == Character.Controlled)
            {
                SteamManager.IncrementStat(
                    character.IsHuman ? "humanskilled" : "monsterskilled",
                    1);
            }

            roundData?.Casualties.Add(character);

            UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName);
            if (character.CurrentHull != null)
            {
                UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName + "indoors");
            }
            if (character.SpeciesName.EndsWith("boss"))
            {
                UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName.Replace("boss", ""));
                if (character.CurrentHull != null)
                {
                    UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName.Replace("boss", "") + "indoors");
                }
            }
            if (character.SpeciesName.EndsWith("_m"))
            {
                UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName.Replace("_m", ""));
                if (character.CurrentHull != null)
                {
                    UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName.Replace("_m", "") + "indoors");
                }
            }

            if (character.HasEquippedItem("clownmask") &&
                character.HasEquippedItem("clowncostume") &&
                causeOfDeath.Killer != character)
            {
                UnlockAchievement(causeOfDeath.Killer, "killclown");
            }

            if (character.CharacterHealth?.GetAffliction("morbusinepoisoning") != null)
            {
                UnlockAchievement(causeOfDeath.Killer, "killpoison");
            }

            if (causeOfDeath.DamageSource is Item item)
            {
                if (item.HasTag("tool"))
                {
                    UnlockAchievement(causeOfDeath.Killer, "killtool");
                }
                else
                {
                    switch (item.Prefab.Identifier)
                    {
                    case "morbusine":
                        UnlockAchievement(causeOfDeath.Killer, "killpoison");
                        break;

                    case "nuclearshell":
                    case "nucleardepthcharge":
                        UnlockAchievement(causeOfDeath.Killer, "killnuke");
                        break;
                    }
                }
            }

#if SERVER
            if (GameMain.Server?.TraitorManager != null)
            {
                if (GameMain.Server.TraitorManager.IsTraitor(character))
                {
                    UnlockAchievement(causeOfDeath.Killer, "killtraitor");
                }
            }
#endif
        }