Esempio n. 1
0
        private void HandleWeaponStatBonuses()
        {
            DamageData data = _nwnxDamage.GetDamageEventData();

            if (data.Total <= 0)
            {
                return;
            }

            NWPlayer player = data.Damager.Object;
            NWItem   weapon = _.GetLastWeaponUsed(player);

            if (weapon.CustomItemType == CustomItemType.BlasterPistol ||
                weapon.CustomItemType == CustomItemType.BlasterRifle)
            {
                int statBonus = (int)(player.DexterityModifier * 0.5f);
                data.Base += statBonus;
            }
            else if (weapon.CustomItemType == CustomItemType.Lightsaber ||
                     weapon.CustomItemType == CustomItemType.Saberstaff ||
                     weapon.GetLocalInt("LIGHTSABER") == TRUE)
            {
                int statBonus = (int)(player.CharismaModifier * 0.25f);
                data.Base += statBonus;
            }

            _nwnxDamage.SetDamageEventData(data);
        }
Esempio n. 2
0
        public void OnModuleApplyDamage()
        {
            var      data        = _nwnxDamage.GetDamageEventData();
            NWObject damager     = data.Damager;
            NWItem   weapon      = NWItem.Wrap(_.GetLastWeaponUsed(damager.Object));
            int      damageBonus = weapon.DamageBonus;

            if (damager.IsPlayer)
            {
                NWPlayer  player    = NWPlayer.Wrap(damager.Object);
                int       itemLevel = weapon.RecommendedLevel;
                SkillType skill     = _skill.GetSkillTypeForItem(weapon);
                int       rank      = _skill.GetPCSkill(player, skill).Rank;
                int       delta     = itemLevel - rank;
                if (delta >= 1)
                {
                    damageBonus--;
                }
                damageBonus = damageBonus - delta / 5;

                if (damageBonus <= 0)
                {
                    damageBonus = 0;
                }
            }

            data.Base += damageBonus;
            _nwnxDamage.SetDamageEventData(data);
        }
Esempio n. 3
0
        private void HandleApplySneakAttackDamage()
        {
            DamageData data            = _nwnxDamage.GetDamageEventData();
            NWObject   damager         = data.Damager;
            int        sneakAttackType = damager.GetLocalInt("SNEAK_ATTACK_ACTIVE");

            if (damager.IsPlayer && sneakAttackType > 0)
            {
                NWPlayer   player    = (damager.Object);
                NWCreature target    = (Object.OBJECT_SELF);
                int        perkRank  = _perk.GetPCPerkByID(damager.GlobalID, (int)PerkType.SneakAttack).PerkLevel;
                int        perkBonus = 1;

                // Rank 4 increases damage bonus by 2x (total: 3x)
                if (perkRank == 4)
                {
                    perkBonus = 2;
                }

                float perkRate;
                if (sneakAttackType == 1) // Player is behind target.
                {
                    perkRate = 1.0f * perkBonus;
                }
                else // Player is anywhere else.
                {
                    perkRate = 0.5f * perkBonus;
                }

                var   effectiveStats = _playerStat.GetPlayerItemEffectiveStats(player);
                float damageRate     = 1.0f + perkRate + (effectiveStats.SneakAttack * 0.05f);
                data.Base = (int)(data.Base * damageRate);

                if (target.IsNPC)
                {
                    _enmity.AdjustEnmity(target, player, 5 * data.Base);
                }

                _nwnxDamage.SetDamageEventData(data);
            }

            damager.DeleteLocalInt("SNEAK_ATTACK_ACTIVE");
        }