示例#1
0
        private bool TurnIntoZombie()
        {
            if (Body.IsRemoved || Body.IsBurnedCorpse)
            {
                return(false);
            }

            var player     = Game.CreatePlayer(Body.GetWorldPosition());
            var zombieType = BotHelper.GetZombieType(Type);
            var oldProfile = Body.GetProfile();
            var oldWeapons = BotHelper.GetWeaponSet(Body); // TODO: test gun with lazer once gurt fixed https://www.mythologicinteractiveforums.com/viewtopic.php?f=31&t=4000

            ScriptHelper.LogDebug(Type, "->", zombieType);
            player.SetBotName(Body.Name); // NOTE: set right now so SpawnLine dialogue will show the bot name correctly

            var zombie     = BotManager.SpawnBot(zombieType, Faction, player, BotManager.GetBot(Body).InfectTeam);
            var zombieBody = zombie.Player;

            var modifiers = Body.GetModifiers();

            // Survivor has fake MaxHealth to have blood effect on the face
            if (Enum.GetName(typeof(BotType), BotManager.GetBot(Body).Type).StartsWith("Survivor"))
            {
                modifiers.CurrentHealth = modifiers.MaxHealth = 50;
            }
            else
            {
                modifiers.CurrentHealth = modifiers.MaxHealth * 0.75f;
            }

            zombieBody.SetModifiers(modifiers);
            zombieBody.SetProfile(BotHelper.ToZombieProfile(oldProfile));
            BotHelper.Equip(zombieBody, oldWeapons);

            Body.Remove();
            Body = zombieBody;
            Body.SetBotBehaivorActive(false);
            Body.AddCommand(new PlayerCommand(PlayerCommandType.StartCrouch));
            IsTurningIntoZombie = true;
            return(true);
        }