Ejemplo n.º 1
0
        public static int GetLevelExperience(this CharacterInstance ch, int cexp)
        {
            var x = LevelConstants.GetLevel(ImmortalTypes.Supreme);
            var y = 0;

            while (y == 0)
            {
                var tmp   = ch.GetExperienceLevel(x);
                int lastx = x;
                if (tmp > cexp)
                {
                    x /= 2;
                }
                else if (lastx != x)
                {
                    x += x / 2;
                }
                else
                {
                    y = x;
                }
            }

            return(y <1 ? 1 : y> LevelConstants.GetLevel(ImmortalTypes.Supreme)
                ? LevelConstants.GetLevel(ImmortalTypes.Supreme) : y);
        }
Ejemplo n.º 2
0
        public static int ComputeExperienceGain(this CharacterInstance ch, CharacterInstance victim)
        {
            var xp    = victim.GetExperienceWorth() * 0.GetNumberThatIsBetween(victim.Level - ch.Level + 10, 13) / 10;
            var align = ch.CurrentAlignment - victim.CurrentAlignment;

            if (align > 990 || align < -990)
            {
                xp = ModifyXPForAttackingOppositeAlignment(xp);
            }
            else if (ch.CurrentAlignment > 300 && align < 250)
            {
                xp = ModifyXPForGoodPlayerAttackingSameAlignment(xp);
            }

            xp = SmaugRandom.Between((xp * 3) >> 2, (xp * 5) >> 2);

            if (!victim.IsNpc())
            {
                xp /= 4;
            }
            else if (!ch.IsNpc())
            {
                xp = ReduceXPForKillingSameMobRepeatedly(ch, (MobileInstance)victim, xp);
            }

            if (!ch.IsNpc() && ch.Level > 5)
            {
                xp = ModifyXPForExperiencedVsNovicePlayer(ch, xp);
            }

            //// Level based experience gain cap.  Cannot get more experience for
            //// a kill than the amount for your current experience level
            return(0.GetNumberThatIsBetween(xp, ch.GetExperienceLevel(ch.Level + 1) - ch.GetExperienceLevel(ch.Level)));
        }
Ejemplo n.º 3
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;
        }