Exemplo n.º 1
0
        public static void Apply(NWGameObject player)
        {
            var playerID      = _.GetGlobalID(player);
            var jobType       = _.GetClassByPosition(ClassPosition.First, player);
            var jobDefinition = JobRegistry.Get(jobType);
            var job           = JobRepo.Get(playerID, jobType);
            var abilityList   = jobDefinition.GetAbilityListByLevel(job.Level);

            var allFeats = new List <Feat>(DefaultFeats);

            allFeats.AddRange(abilityList);

            // Remove any feats the player shouldn't have.
            var featCount = NWNXCreature.GetFeatCount(player);

            for (int x = featCount; x >= 0; x--)
            {
                var feat = NWNXCreature.GetFeatByIndex(player, x - 1);
                if (!allFeats.Contains(feat))
                {
                    NWNXCreature.RemoveFeat(player, feat);
                }
            }

            // Add any feats the player needs.
            foreach (var feat in allFeats)
            {
                if (_.GetHasFeat(feat, player))
                {
                    continue;
                }

                NWNXCreature.AddFeatByLevel(player, feat, 1);
            }
        }
Exemplo n.º 2
0
        protected static void Recalculate(NWGameObject player)
        {
            var playerID      = GetGlobalID(player);
            var playerEntity  = PlayerRepo.Get(playerID);
            var @class        = GetClassByPosition(ClassPosition.First, player);
            var level         = GetLevelByPosition(ClassPosition.First, player);
            var jobDefinition = JobRegistry.Get(@class);

            // Retrieve the rating chart for the stat, then retrieve the value for that stat at this player's level.
            var hp  = RatingRegistry.Get(jobDefinition.HPRating).Get(RatingStat.HP, level);
            var mp  = RatingRegistry.Get(jobDefinition.MPRating).Get(RatingStat.MP, level);
            var ac  = RatingRegistry.Get(jobDefinition.ACRating).Get(RatingStat.AC, level);
            var bab = RatingRegistry.Get(jobDefinition.BABRating).Get(RatingStat.BAB, level);

            var str  = RatingRegistry.Get(jobDefinition.STRRating).Get(RatingStat.STR, level);
            var dex  = RatingRegistry.Get(jobDefinition.DEXRating).Get(RatingStat.DEX, level);
            var con  = RatingRegistry.Get(jobDefinition.CONRating).Get(RatingStat.CON, level);
            var wis  = RatingRegistry.Get(jobDefinition.WISRating).Get(RatingStat.WIS, level);
            var @int = RatingRegistry.Get(jobDefinition.INTRating).Get(RatingStat.INT, level);
            var cha  = RatingRegistry.Get(jobDefinition.CHARating).Get(RatingStat.CHA, level);


            // Now apply the changes to the player.
            ApplyHP(player, hp);
            playerEntity.MaxHP = hp;
            playerEntity.MaxMP = mp;
            playerEntity.HP    = hp;
            playerEntity.MP    = mp;

            NWNXCreature.SetBaseAC(player, ac);
            NWNXCreature.SetBaseAttackBonus(player, bab);

            NWNXCreature.SetRawAbilityScore(player, Ability.Strength, str);
            NWNXCreature.SetRawAbilityScore(player, Ability.Dexterity, dex);
            NWNXCreature.SetRawAbilityScore(player, Ability.Constitution, con);
            NWNXCreature.SetRawAbilityScore(player, Ability.Wisdom, wis);
            NWNXCreature.SetRawAbilityScore(player, Ability.Intelligence, @int);
            NWNXCreature.SetRawAbilityScore(player, Ability.Charisma, cha);

            PlayerRepo.Set(playerEntity);
            DelayCommand(1.0f, () => NWNXPlayer.UpdateCharacterSheet(player));
        }