Ejemplo n.º 1
0
        private static void LowerVictimLevel(CharacterInstance ch, CharacterInstance victim, int level)
        {
            victim.SetColor(ATTypes.AT_IMMORT);

            if (victim.Level >= LevelConstants.AvatarLevel && victim.IsImmortal())
            {
                var victimPc = (PlayerInstance)victim;

                if (victimPc.PlayerData.Bestowments.Any())
                {
                    victimPc.PlayerData.Bestowments.Clear();
                }

                victim.Act.RemoveBit((int)PlayerFlags.HolyLight);
                if (!((PlayerInstance)victim).IsRetired())
                {
                    // todo remove immortal data
                    // snprintf(buf, MAX_INPUT_LENGTH, "%s%s", GOD_DIR, capitalize(victim->name));

                    //if (!remove(buf))
                    //    send_to_char("Player's immortal data destroyed.\r\n", ch);
                }
            }

            if (level < victim.Level)
            {
                int tempLevel = victim.Level;
                victim.Level = level;
                handler.check_switch(victim, false);
                victim.Level = tempLevel;

                ch.Printf("Demoting %s from level %d to level %d!", victim.Name, victim.Level);
                victim.SendTo("Cursed and forsaken!  The gods have lowered your level...");
            }
            else
            {
                ch.Printf("%s is already level %d.  Re-advancing...", victim.Name, level);
                victim.SendTo("Deja vu!  Your mind reels as you re-live your past levels!");
            }

            victim.Level           = 1;
            victim.Experience      = victim.GetExperienceLevel(1);
            victim.MaximumHealth   = GameConstants.GetConstant <int>("DefaultMaximumHealth");
            victim.MaximumMana     = GameConstants.GetConstant <int>("DefaultMaximumMana");
            victim.MaximumMovement = GameConstants.GetConstant <int>("DefaultMaximumMovement");

            if (victim is PlayerInstance)
            {
                var player = victim as PlayerInstance;
                player.PlayerData.ClearLearnedSkills();
            }

            victim.Practice        = 0;
            victim.CurrentHealth   = victim.MaximumHealth;
            victim.CurrentMana     = victim.MaximumMana;
            victim.CurrentMovement = victim.MaximumMovement;

            if (!(victim is PlayerInstance))
            {
                return;
            }

            PlayerInstance playerVictim = (PlayerInstance)victim;

            playerVictim.AdvanceLevel();
            playerVictim.PlayerData.rank            = string.Empty;
            playerVictim.PlayerData.WizardInvisible = playerVictim.Trust;
            if (playerVictim.Level > LevelConstants.AvatarLevel)
            {
                return;
            }

            playerVictim.Act.RemoveBit((int)PlayerFlags.WizardInvisibility);
            playerVictim.PlayerData.WizardInvisible = 0;
        }