Example #1
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            Location effectLocation;
            NWPlayer player = (user.Object);

            if (!string.IsNullOrWhiteSpace(target.GetLocalString("RESOURCE_RESREF")))
            {
                ScanResource(user, target);
                DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(0.05f, 0.1f));
                effectLocation = target.Location;
            }
            else
            {
                user.FloatingText("You cannot scan that object with this type of scanner.");
                return;
            }

            _.ApplyEffectAtLocation(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Fnf_Summon_Monster_3), effectLocation);

            if (user.IsPlayer && GetLocalBool(user, target.GlobalID.ToString()) == false)
            {
                int scanningBonus = item.ScanningBonus;
                SkillService.GiveSkillXP(player, SkillType.Harvesting, 150);
                user.SetLocalInt(target.GlobalID.ToString(), 1 + scanningBonus);
            }
        }
Example #2
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player           = user.Object;
            var      ability          = (AbilityType)item.GetLocalInt("ABILITY_TYPE");
            int      amount           = item.GetLocalInt("AMOUNT") + (item.MedicineBonus * 2);
            int      rank             = player.IsPlayer ? SkillService.GetPCSkillRank(player, SkillType.Medicine) : 0;
            int      recommendedLevel = item.RecommendedLevel;
            float    duration         = 30.0f * (rank / 10);
            int      perkLevel        = player.IsPlayer ? PerkService.GetCreaturePerkLevel(player, PerkType.StimFiend) : 0;
            float    percentIncrease  = perkLevel * 0.25f;

            duration = duration + (duration * percentIncrease);
            Effect effect = _.EffectAbilityIncrease(ability, amount);

            effect = _.TagEffect(effect, "STIM_PACK_EFFECT");

            _.ApplyEffectToObject(DurationType.Temporary, effect, target, duration);

            user.SendMessage("You inject " + target.Name + " with a stim pack. The stim pack will expire in " + duration + " seconds.");

            _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The stim pack that you applied to " + target.Name + " has expired."); });

            if (!Equals(user, target))
            {
                NWCreature targetCreature = target.Object;
                targetCreature.SendMessage(user.Name + " injects you with a stim pack.");
            }

            int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank);

            SkillService.GiveSkillXP(player, SkillType.Medicine, xp);
        }
Example #3
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            CustomEffectService.RemovePCCustomEffect(target.Object, CustomEffectType.Poison);

            foreach (Effect effect in target.Effects)
            {
                if (_.GetIsEffectValid(effect) == true)
                {
                    var effectType = _.GetEffectType(effect);
                    if (effectType == EffectTypeScript.Poison || effectType == EffectTypeScript.Disease || effectType == EffectTypeScript.AbilityDecrease)
                    {
                        _.RemoveEffect(target.Object, effect);
                    }
                }
            }

            user.SendMessage("You successfully treat " + target.Name + "'s infection.");

            int rank = SkillService.GetPCSkillRank(user.Object, SkillType.Medicine);

            if (target.IsPlayer)
            {
                int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank);
                SkillService.GiveSkillXP(user.Object, SkillType.Medicine, xp);
            }
        }
Example #4
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            Location effectLocation;
            NWPlayer player = (user.Object);

            // Targeted a location or self. Locate nearest resource.
            if (!target.IsValid || Equals(user, target))
            {
                ScanArea(user, targetLocation);
                DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(0.02f, 0.08f));
                effectLocation = targetLocation;
            }
            else if (!string.IsNullOrWhiteSpace(target.GetLocalString("RESOURCE_RESREF")))
            {
                ScanResource(user, target);
                DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(0.05f, 0.1f));
                effectLocation = target.Location;
            }
            else
            {
                user.FloatingText("You cannot scan that object with this type of scanner.");
                return;
            }

            _.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3), effectLocation);

            if (user.IsPlayer && user.GetLocalInt(target.GlobalID.ToString()) == FALSE)
            {
                int scanningBonus = item.ScanningBonus;
                SkillService.GiveSkillXP(player, SkillType.Harvesting, 150);
                user.SetLocalInt(target.GlobalID.ToString(), 1 + scanningBonus);
            }
        }
Example #5
0
        private void DigAHole()
        {
            Location targetLocation = GetPC().GetLocalLocation("SHOVEL_TARGET_LOCATION");

            _.CreateObject(_.OBJECT_TYPE_PLACEABLE, "farm_small_hole", targetLocation);
            _.FloatingTextStringOnCreature("You dig a hole.", GetPC().Object, _.FALSE);
            SkillService.GiveSkillXP(GetPC(), SkillType.Farming, 50);
            EndConversation();
        }
Example #6
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player         = (user.Object);
            var      effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player);

            target.RemoveEffect(EFFECT_TYPE_REGENERATE);
            int   rank = SkillService.GetPCSkillRank(player, SkillType.Medicine);
            int   luck = PerkService.GetPCPerkLevel(player, PerkType.Lucky);
            int   perkDurationBonus    = PerkService.GetPCPerkLevel(player, PerkType.HealingKitExpert) * 6 + (luck * 2);
            float duration             = 30.0f + (rank * 0.4f) + perkDurationBonus;
            int   restoreAmount        = 1 + item.GetLocalInt("HEALING_BONUS") + effectiveStats.Medicine + item.MedicineBonus;
            int   delta                = item.RecommendedLevel - rank;
            float effectivenessPercent = 1.0f;

            if (delta > 0)
            {
                effectivenessPercent = effectivenessPercent - (delta * 0.1f);
            }

            restoreAmount = (int)(restoreAmount * effectivenessPercent);

            int perkBlastBonus = PerkService.GetPCPerkLevel(player, PerkType.ImmediateImprovement);

            if (perkBlastBonus > 0)
            {
                int blastHeal = restoreAmount * perkBlastBonus;
                if (RandomService.Random(100) + 1 <= luck / 2)
                {
                    blastHeal *= 2;
                }
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(blastHeal), target.Object);
            }

            float          interval   = 6.0f;
            BackgroundType background = (BackgroundType)player.Class1;

            if (background == BackgroundType.Medic)
            {
                interval *= 0.5f;
            }

            _.PlaySound("use_bacta");
            Effect regeneration = _.EffectRegenerate(restoreAmount, interval);

            _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, regeneration, target.Object, duration);
            player.SendMessage("You successfully treat " + target.Name + "'s wounds. The healing kit will expire in " + duration + " seconds.");

            _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The healing kit that you applied to " + target.Name + " has expired."); });

            if (target.IsPlayer)
            {
                int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank);
                SkillService.GiveSkillXP(player, SkillType.Medicine, xp);
            }
        }
Example #7
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            float percent = 0.0f;

            switch (spellTier)
            {
            case 1:
                percent = 0.10f;
                break;

            case 2:
                percent = 0.20f;
                break;

            case 3:
                percent = 0.35f;
                break;

            case 4:
                percent = 0.50f;
                break;
            }

            int recovery = (int)(target.CurrentHP * percent);

            if (recovery < 1)
            {
                recovery = 1;
            }

            // Damage user.
            _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectDamage(recovery), creature);

            // Check lucky chance.
            int luck = PerkService.GetCreaturePerkLevel(creature, PerkType.Lucky);

            if (RandomService.D100(1) <= luck)
            {
                recovery *= 2;
                creature.SendMessage("Lucky Force Body!");
            }

            // Recover FP on target.
            AbilityService.RestorePlayerFP(target.Object, recovery);

            // Play VFX
            _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectVisualEffect(_.VFX_IMP_HEAD_ODD), target);

            // Grant XP, if player.
            if (creature.IsPlayer)
            {
                SkillService.GiveSkillXP(creature.Object, SkillType.ForceControl, recovery * 2);
            }
        }
Example #8
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player               = (user.Object);
            var      effectiveStats       = PlayerStatService.GetPlayerItemEffectiveStats(player);
            int      rank                 = SkillService.GetPCSkillRank(player, SkillType.Medicine);
            int      luck                 = PerkService.GetCreaturePerkLevel(player, PerkType.Lucky);
            int      perkDurationBonus    = PerkService.GetCreaturePerkLevel(player, PerkType.HealingKitExpert) * 6 + (luck * 2);
            float    duration             = 30.0f + (rank * 0.4f) + perkDurationBonus + effectiveStats.Medicine;
            int      restoreAmount        = 1 + item.GetLocalInt("HEALING_BONUS") + (rank / 10);
            int      delta                = item.RecommendedLevel - rank;
            float    effectivenessPercent = 1.0f;

            if (delta > 0)
            {
                effectivenessPercent = effectivenessPercent - (delta * 0.1f);
            }

            restoreAmount = (int)(restoreAmount * effectivenessPercent) + item.MedicineBonus;

            int perkBlastBonus = PerkService.GetCreaturePerkLevel(player, PerkType.ImmediateForcePack);

            if (perkBlastBonus > 0)
            {
                int blastHeal = restoreAmount * perkBlastBonus;
                if (RandomService.Random(100) + 1 <= luck / 2)
                {
                    blastHeal *= 2;
                }

                AbilityService.RestorePlayerFP(target.Object, blastHeal);
            }

            float          interval   = 6.0f;
            BackgroundType background = (BackgroundType)player.Class1;

            if (background == BackgroundType.Medic)
            {
                interval *= 0.5f;
            }

            string data = (int)interval + ", " + restoreAmount;

            CustomEffectService.ApplyCustomEffect(user, target.Object, CustomEffectType.ForcePack, (int)duration, restoreAmount, data);

            player.SendMessage("You successfully apply a force pack to " + target.Name + ". The force pack will expire in " + duration + " seconds.");

            _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The force pack that you applied to " + target.Name + " has expired."); });

            int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank);

            SkillService.GiveSkillXP(player, SkillType.Medicine, xp);
        }
Example #9
0
        public void OnConcentrationTick(NWCreature creature, NWObject target, int perkLevel, int tick)
        {
            int amount = 0;


            switch (perkLevel)
            {
            case 1: amount = 2; break;

            case 2: amount = 3; break;

            case 3: amount = 5; break;

            case 4: amount = 7; break;

            case 5: amount = 10; break;
            }

            // If target is at max HP, we do nothing else.
            int difference = target.MaxHP - target.CurrentHP;

            if (difference <= 0)
            {
                return;
            }

            // If we would heal the target for more than their max, reduce the amount healed to that number.
            if (amount > difference)
            {
                amount = difference;
            }

            // Apply the heal
            _.ApplyEffectToObject(DurationType.Instant, _.EffectHeal(amount), target);
            _.ApplyEffectToObject(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Imp_Head_Holy), target);

            // Give Control XP, if player.
            if (creature.IsPlayer)
            {
                SkillService.GiveSkillXP(creature.Object, SkillType.ForceControl, amount * 10);
            }

            EnmityService.AdjustEnmityOnAllTaggedCreatures(creature, amount * 3, 2);
        }
Example #10
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            string growingPlantID = target.GetLocalString("GROWING_PLANT_ID");

            if (string.IsNullOrWhiteSpace(growingPlantID))
            {
                user.SendMessage("Water jugs can only target growing plants.");
                return;
            }
            GrowingPlant growingPlant = DataService.Single <GrowingPlant>(x => x.ID == new Guid(growingPlantID));
            var          plant        = DataService.Get <Plant>(growingPlant.PlantID);

            if (growingPlant.WaterStatus <= 0)
            {
                user.SendMessage("That plant doesn't need to be watered at this time.");
                return;
            }

            if (item.Charges <= 0)
            {
                user.SendMessage("There's no water in that jug!");
                return;
            }

            int remainingTicks = growingPlant.RemainingTicks;

            if (growingPlant.WaterStatus > 1)
            {
                remainingTicks = remainingTicks / 2;
            }

            growingPlant.WaterStatus    = 0;
            growingPlant.RemainingTicks = remainingTicks;
            DataService.SubmitDataChange(growingPlant, DatabaseActionType.Update);

            user.SendMessage("You water the plant.");

            int rank = SkillService.GetPCSkillRank((NWPlayer)user, SkillType.Farming);

            int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(100, plant.Level, rank);

            SkillService.GiveSkillXP((NWPlayer)user, SkillType.Farming, xp);
        }
Example #11
0
        public void OnConcentrationTick(NWCreature creature, NWObject target, int perkLevel, int tick)
        {
            Effect effect;
            float  duration = 6.1f;
            int    concealment;
            int    hitpoints;

            switch (perkLevel)
            {
            case 1:
                hitpoints = 3;
                effect    = _.EffectTemporaryHitpoints(hitpoints);
                break;

            case 2:
                hitpoints   = 3;
                concealment = 5;
                effect      = _.EffectConcealment(concealment);
                effect      = _.EffectLinkEffects(effect, _.EffectTemporaryHitpoints(hitpoints));
                break;

            case 3:
                concealment = 10;
                hitpoints   = 5;
                effect      = _.EffectConcealment(concealment);
                effect      = _.EffectLinkEffects(effect, _.EffectTemporaryHitpoints(hitpoints));
                break;

            default:
                throw new ArgumentException(nameof(perkLevel) + " invalid. Value " + perkLevel + " is unhandled.");
            }

            _.ApplyEffectToObject(DurationType.Temporary, effect, creature, duration);
            _.ApplyEffectToObject(DurationType.Temporary, _.EffectVisualEffect(VisualEffect.Vfx_Dur_Aura_Purple), creature, duration);

            if (_.GetIsInCombat(creature))
            {
                if (creature.IsPlayer)
                {
                    SkillService.GiveSkillXP(creature.Object, SkillType.ForceSense, (perkLevel * 50));
                }
            }
        }
Example #12
0
        private void HandleConfirmPageResponse()
        {
            Model vm = GetDialogCustomData <Model>();

            if (vm.Item != null && vm.Item.IsValid)
            {
                var skill = DataService.Get <Skill>(vm.SkillID);
                if (!skill.ContributesToSkillCap)
                {
                    GetPC().FloatingText("You cannot raise that skill with this tome.");
                    return;
                }

                int xp = vm.Item.GetLocalInt("XP_TOME_AMOUNT");
                SkillService.GiveSkillXP(GetPC(), vm.SkillID, xp, false);
                vm.Item.Destroy();
            }

            EndConversation();
        }
Example #13
0
        public void OnConcentrationTick(NWCreature creature, NWObject target, int perkLevel, int tick)
        {
            int amount = 0;

            switch (perkLevel)
            {
            case 1: amount = 2; break;

            case 2: amount = 3; break;

            case 3: amount = 5; break;

            case 4: amount = 7; break;

            case 5: amount = 10; break;
            }

            // If target is at max HP, we do nothing else.
            int difference = target.MaxHP - target.CurrentHP;

            if (difference <= 0)
            {
                return;
            }

            // If we would heal the target for more than their max, reduce the amount healed to that number.
            if (amount > difference)
            {
                amount = difference;
            }

            // Apply the heal
            _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectHeal(amount), target);

            // Give Control XP, if player.
            if (creature.IsPlayer)
            {
                SkillService.GiveSkillXP(creature.Object, SkillType.ForceControl, amount);
            }
        }
Example #14
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player         = (user.Object);
            var      effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player);

            CustomEffectService.RemovePCCustomEffect(target.Object, CustomEffectType.Bleeding);
            player.SendMessage("You finish bandaging " + target.Name + "'s wounds.");

            int rank = SkillService.GetPCSkillRank(player, SkillType.Medicine);

            int healAmount = 2 + effectiveStats.Medicine / 2;

            healAmount += item.MedicineBonus;
            if (rank >= item.RecommendedLevel && item.MedicineBonus > 0)
            {
                _.ApplyEffectToObject(DurationType.Instant, _.EffectHeal(healAmount), target);
            }
            if (target.IsPlayer)
            {
                int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(100, item.RecommendedLevel, rank);
                SkillService.GiveSkillXP(player, SkillType.Medicine, xp);
            }
        }
Example #15
0
        private void OnCompleteSmelt(OnCompleteSmelt data)
        {
            NWPlayer            player         = data.Player;
            string              oreResref      = data.OreResref;
            List <ItemProperty> itemProperties = data.ItemProperties;

            player.IsBusy = false;

            int    rank        = SkillService.GetPCSkillRank(player, SkillType.Harvesting);
            int    level       = CraftService.GetIngotLevel(oreResref);
            string ingotResref = CraftService.GetIngotResref(oreResref);

            if (level < 0 || string.IsNullOrWhiteSpace(ingotResref))
            {
                return;
            }

            int delta = rank - level;
            int count = 2;

            if (delta > 2)
            {
                count = delta;
            }
            if (count > 4)
            {
                count = 4;
            }

            if (RandomService.Random(100) + 1 <= PerkService.GetCreaturePerkLevel(player, PerkType.Lucky))
            {
                count++;
            }

            if (RandomService.Random(100) + 1 <= PerkService.GetCreaturePerkLevel(player, PerkType.ProcessingEfficiency) * 10)
            {
                count++;
            }

            for (int x = 1; x <= count; x++)
            {
                var item = (_.CreateItemOnObject(ingotResref, player.Object));
                int chance;

                switch (x)
                {
                case 1:
                case 2:
                    chance = 100;
                    break;

                case 3:
                    chance = 70;
                    break;

                case 4:
                    chance = 60;
                    break;

                case 5:
                    chance = 50;
                    break;

                default:
                    chance = 30;
                    break;
                }

                foreach (var ip in itemProperties)
                {
                    if (RandomService.D100(1) <= chance)
                    {
                        BiowareXP2.IPSafeAddItemProperty(item, ip, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true);
                    }
                }
            }

            var effectiveStats   = PlayerStatService.GetPlayerItemEffectiveStats(player);
            int harvestingSkill  = SkillService.GetPCSkillRank(player, SkillType.Harvesting);
            int perkBonus        = PerkService.GetCreaturePerkLevel(player, PerkType.StronidiumRefining) + 1;
            int stronidiumAmount = 10 + effectiveStats.Harvesting + harvestingSkill + RandomService.Random(1, 5);

            stronidiumAmount *= perkBonus;
            _.CreateItemOnObject("stronidium", player.Object, stronidiumAmount);

            int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(100, level, rank);

            SkillService.GiveSkillXP(player, SkillType.Harvesting, xp);
        }
Example #16
0
        // New component items will be spawned and the appropriate properties from the base item will be transferred.
        public bool Run(params object[] args)
        {
            _player = (NWPlayer)args[0];
            int xp = 100; // Always grant at least this much XP to player.

            // Remove the immobilization effect
            foreach (var effect in _player.Effects)
            {
                if (_.GetEffectTag(effect) == "CRAFTING_IMMOBILIZATION")
                {
                    _.RemoveEffect(_player, effect);
                }
            }

            // Check for a fuel cell in the player's inventory again. If it doesn't exist, we exit early with an error message.
            NWItem fuel = _.GetItemPossessedBy(_player, "ass_power");

            if (!fuel.IsValid)
            {
                _player.SendMessage(ColorTokenService.Red("A 'Reassembly Fuel Cell' was not found in your inventory. Reassembly failed."));
                return(false);
            }

            // Otherwise the fuel cell was found. Destroy it and continue on with the process.
            fuel.Destroy();

            _playerItemStats = PlayerStatService.GetPlayerItemEffectiveStats(_player);
            string      serializedSalvageItem = (string)args[1];
            NWPlaceable tempStorage           = _.GetObjectByTag("TEMP_ITEM_STORAGE");
            NWItem      item = SerializationService.DeserializeItem(serializedSalvageItem, tempStorage);
            int         salvageComponentTypeID = (int)args[2];

            _componentType = DataService.Get <ComponentType>(salvageComponentTypeID);

            // Create an item with no bonuses every time.
            _.CreateItemOnObject(_componentType.ReassembledResref, _player);

            // Now check specific custom properties which are stored as local variables on the item.
            xp += ProcessProperty(item.HarvestingBonus, 3, ComponentBonusType.HarvestingUp);
            xp += ProcessProperty(item.PilotingBonus, 3, ComponentBonusType.PilotingUp);
            xp += ProcessProperty(item.ScanningBonus, 3, ComponentBonusType.ScanningUp);
            xp += ProcessProperty(item.ScavengingBonus, 3, ComponentBonusType.ScavengingUp);
            xp += ProcessProperty(item.CooldownRecovery, 3, ComponentBonusType.CooldownRecoveryUp);
            xp += ProcessProperty(item.CraftBonusArmorsmith, 3, ComponentBonusType.ArmorsmithUp);
            xp += ProcessProperty(item.CraftBonusWeaponsmith, 3, ComponentBonusType.WeaponsmithUp);
            xp += ProcessProperty(item.CraftBonusCooking, 3, ComponentBonusType.CookingUp);
            xp += ProcessProperty(item.CraftBonusEngineering, 3, ComponentBonusType.EngineeringUp);
            xp += ProcessProperty(item.CraftBonusFabrication, 3, ComponentBonusType.FabricationUp);
            xp += ProcessProperty(item.HPBonus, 5, ComponentBonusType.HPUp, 0.5f);
            xp += ProcessProperty(item.FPBonus, 5, ComponentBonusType.FPUp, 0.5f);
            xp += ProcessProperty(item.EnmityRate, 3, ComponentBonusType.EnmityUp);

            xp += ProcessProperty(item.LuckBonus, 3, ComponentBonusType.LuckUp);
            xp += ProcessProperty(item.MeditateBonus, 3, ComponentBonusType.MeditateUp);
            xp += ProcessProperty(item.RestBonus, 3, ComponentBonusType.RestUp);
            xp += ProcessProperty(item.MedicineBonus, 3, ComponentBonusType.MedicineUp);
            xp += ProcessProperty(item.HPRegenBonus, 3, ComponentBonusType.HPRegenUp);
            xp += ProcessProperty(item.FPRegenBonus, 3, ComponentBonusType.FPRegenUp);
            xp += ProcessProperty(item.BaseAttackBonus, 3, ComponentBonusType.BaseAttackBonusUp, 6f);
            xp += ProcessProperty(item.StructureBonus, 3, ComponentBonusType.StructureBonusUp);
            xp += ProcessProperty(item.SneakAttackBonus, 3, ComponentBonusType.SneakAttackUp);
            xp += ProcessProperty(item.DamageBonus, 3, ComponentBonusType.DamageUp);
            xp += ProcessProperty(item.StrengthBonus, 3, ComponentBonusType.StrengthUp);
            xp += ProcessProperty(item.DexterityBonus, 3, ComponentBonusType.DexterityUp);
            xp += ProcessProperty(item.ConstitutionBonus, 3, ComponentBonusType.ConstitutionUp);
            xp += ProcessProperty(item.WisdomBonus, 3, ComponentBonusType.WisdomUp);
            xp += ProcessProperty(item.IntelligenceBonus, 3, ComponentBonusType.IntelligenceUp);
            xp += ProcessProperty(item.CharismaBonus, 3, ComponentBonusType.CharismaUp);
            xp += ProcessProperty(item.DurationBonus, 3, ComponentBonusType.DurationUp);

            item.Destroy();

            SkillService.GiveSkillXP(_player, SkillType.Harvesting, xp);
            return(true);
        }
Example #17
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player         = user.Object;
            var      effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player);
            int      skillRank      = SkillService.GetPCSkillRank(player, SkillType.Medicine);
            int      perkLevel      = PerkService.GetCreaturePerkLevel(player, PerkType.ResuscitationDevices);
            int      rank           = item.GetLocalInt("RANK");
            int      baseHeal;

            switch (rank)
            {
            case 1:
                baseHeal = 1;
                break;

            case 2:
                baseHeal = 11;
                break;

            case 3:
                baseHeal = 31;
                break;

            case 4:
                baseHeal = 51;
                break;

            default: return;
            }

            baseHeal += perkLevel * 2;
            baseHeal += effectiveStats.Medicine / 2;
            baseHeal += item.MedicineBonus / 2;

            int   delta = item.RecommendedLevel - skillRank;
            float effectivenessPercent = 1.0f;

            if (delta > 0)
            {
                effectivenessPercent = effectivenessPercent - (delta * 0.1f);
            }
            if (target.IsPlayer)
            {
                baseHeal = (int)(baseHeal * effectivenessPercent);
                Player dbPlayer  = DataService.Player.GetByID(target.GlobalID);
                int    fpRecover = (int)(dbPlayer.MaxFP * (0.01f * baseHeal));
                int    hpRecover = (int)(target.MaxHP * (0.01f * baseHeal));

                _.PlaySound("use_bacta");
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectResurrection(), target);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(hpRecover), target);
                dbPlayer.CurrentFP = fpRecover;
                DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update);
                player.SendMessage("You successfully resuscitate " + target.Name + "!");

                int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(600, item.RecommendedLevel, skillRank);
                SkillService.GiveSkillXP(player, SkillType.Medicine, xp);
            }
            else
            {
                baseHeal = (int)(baseHeal * effectivenessPercent);
                int hpRecover = (int)(target.MaxHP * (0.01f * baseHeal));
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectResurrection(), target);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(hpRecover), target);
                player.SendMessage("You successfully resuscitate " + target.Name + "!");
            }
        }
Example #18
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            Effect effect;
            float  duration;

            switch (spellTier)
            {
            case 1:
                effect   = _.EffectMovementSpeedIncrease(10);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(AbilityType.Dexterity, 2));
                duration = 60f;
                break;

            case 2:
                effect   = _.EffectMovementSpeedIncrease(20);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(AbilityType.Dexterity, 4));
                duration = 90f;
                break;

            case 3:
                effect   = _.EffectMovementSpeedIncrease(30);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(AbilityType.Dexterity, 6));
                effect   = _.EffectLinkEffects(effect, _.EffectModifyAttacks(1));
                duration = 120f;
                break;

            case 4:
                effect   = _.EffectMovementSpeedIncrease(40);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(AbilityType.Dexterity, 8));
                effect   = _.EffectLinkEffects(effect, _.EffectModifyAttacks(1));
                duration = 150f;
                break;

            case 5:
                effect   = _.EffectMovementSpeedIncrease(50);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(AbilityType.Dexterity, 10));
                effect   = _.EffectLinkEffects(effect, _.EffectModifyAttacks(1));
                duration = 180f;
                break;

            default:
                throw new ArgumentException(nameof(perkLevel) + " invalid. Value " + perkLevel + " is unhandled.");
            }

            // Check lucky chance.
            int luck = PerkService.GetCreaturePerkLevel(creature, PerkType.Lucky);

            if (RandomService.D100(1) <= luck)
            {
                duration *= 2;
                creature.SendMessage("Lucky Force Speed!");
            }

            _.ApplyEffectToObject(DurationType.Temporary, effect, target, duration);
            _.ApplyEffectToObject(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Imp_Ac_Bonus), target);

            if (creature.IsPlayer)
            {
                NWPlayer player     = creature.Object;
                int      skillLevel = SkillService.GetPCSkillRank(player, SkillType.ForceControl);
                int      xp         = skillLevel * 10 + 50;
                SkillService.GiveSkillXP(player, SkillType.ForceControl, xp);
            }
        }
Example #19
0
        private void HandleDistributeRPXPResponse(int responseID)
        {
            NWPlayer player   = GetPC();
            Player   dbPlayer = DataService.Player.GetByID(player.GlobalID);
            Model    vm       = GetDialogCustomData <Model>();

            int rpXpToDistribute = dbPlayer.RoleplayXP;

            PCSkill pcSkill = SkillService.GetPCSkill(player, vm.SelectedSkillID);
            Skill   skill   = SkillService.GetSkill(vm.SelectedSkillID);
            // Get all player skills and then sum them up by the rank.
            int totalSkillCount = DataService.PCSkill
                                  .GetAllByPlayerID(player.GlobalID)
                                  .Where(x => DataService.Skill.GetByID(x.SkillID).ContributesToSkillCap)
                                  .Sum(s => s.Rank);
            int totalSkillXpToMaxRank = 0;

            //totalSkillCount < SkillService.SkillCap
            for (int x = pcSkill.Rank + 1; x < skill.MaxRank; x++)
            {
                int tempValue;
                if (SkillService.SkillXPRequirements.TryGetValue(x, out tempValue))
                {
                    totalSkillXpToMaxRank += tempValue;
                }
            }

            switch (responseID)
            {
            case 1:     // Select All RP XP
                vm.RPXPDistributing = totalSkillXpToMaxRank;
                break;

            case 2:     // Increase by 1000
                vm.RPXPDistributing += 1000;
                break;

            case 3:     // Increase by 100
                vm.RPXPDistributing += 100;
                break;

            case 4:     // Increase by 10
                vm.RPXPDistributing += 10;
                break;

            case 5:     // Increase by 1
                vm.RPXPDistributing += 1;
                break;

            case 6:     // Decrease by 1000
                vm.RPXPDistributing -= 1000;
                break;

            case 7:     // Decrease by 100
                vm.RPXPDistributing -= 100;
                break;

            case 8:     // Decrease by 10
                vm.RPXPDistributing -= 10;
                break;

            case 9:     // Decrease by 1
                vm.RPXPDistributing -= 1;
                break;

            case 10:     // Distribute Roleplay XP

                // Make sure the player specified how much they want to distribute.
                if (vm.RPXPDistributing <= 0)
                {
                    player.SendMessage("Please specify how much RP XP you'd like to distribute into this skill.");
                    vm.IsConfirming = false;
                }
                else if (vm.RPXPDistributing > totalSkillXpToMaxRank)
                {
                    player.SendMessage("Please lower your distribution amount, current max for this skill is " + totalSkillXpToMaxRank + ".");
                    vm.IsConfirming = false;
                }
                else
                {
                    if (vm.IsConfirming)
                    {
                        // Give the distributed XP to a particular skill.
                        // We disable residency bonuses, DM bonuses, and skill penalties during this distribution because
                        // those are calculated when we give the player RP XP.
                        SkillService.GiveSkillXP(player, vm.SelectedSkillID, vm.RPXPDistributing, false, false);

                        dbPlayer             = DataService.Player.GetByID(player.GlobalID);
                        dbPlayer.RoleplayXP -= vm.RPXPDistributing;
                        DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update);
                        vm.IsConfirming     = false;
                        vm.RPXPDistributing = 0;
                    }
                    else
                    {
                        vm.IsConfirming = true;
                    }
                }
                break;
            }

            if (vm.RPXPDistributing > dbPlayer.RoleplayXP)
            {
                vm.RPXPDistributing = dbPlayer.RoleplayXP;
            }
            else if (vm.RPXPDistributing < 0)
            {
                vm.RPXPDistributing = 0;
            }

            LoadDistributeRPXPPage();
        }
Example #20
0
        private void RunCreateItem(NWPlayer player)
        {
            foreach (var effect in player.Effects)
            {
                if (_.GetEffectTag(effect) == "CRAFTING_IMMOBILIZATION")
                {
                    _.RemoveEffect(player, effect);
                }
            }

            var model = CraftService.GetPlayerCraftingData(player);

            CraftBlueprint blueprint     = DataService.CraftBlueprint.GetByID(model.BlueprintID);
            BaseStructure  baseStructure = blueprint.BaseStructureID == null ? null : DataService.BaseStructure.GetByID(Convert.ToInt32(blueprint.BaseStructureID));
            PCSkill        pcSkill       = SkillService.GetPCSkill(player, blueprint.SkillID);

            int   pcEffectiveLevel = CraftService.CalculatePCEffectiveLevel(player, pcSkill.Rank, (SkillType)blueprint.SkillID);
            int   itemLevel        = model.AdjustedLevel;
            int   atmosphereBonus  = CraftService.CalculateAreaAtmosphereBonus(player.Area);
            float chance           = CalculateBaseChanceToAddProperty(pcEffectiveLevel, itemLevel, atmosphereBonus);
            float equipmentBonus   = CalculateEquipmentBonus(player, (SkillType)blueprint.SkillID);

            if (chance <= 1.0f)
            {
                player.FloatingText(ColorTokenService.Red("Critical failure! You don't have enough skill to create that item. All components were lost."));
                CraftService.ClearPlayerCraftingData(player, true);
                return;
            }

            int    luckyBonus   = PerkService.GetCreaturePerkLevel(player, PerkType.Lucky);
            var    craftedItems = new List <NWItem>();
            NWItem craftedItem  = (_.CreateItemOnObject(blueprint.ItemResref, player.Object, blueprint.Quantity));

            craftedItem.IsIdentified = true;
            craftedItems.Add(craftedItem);

            // If item isn't stackable, loop through and create as many as necessary.
            if (craftedItem.StackSize < blueprint.Quantity)
            {
                for (int x = 2; x <= blueprint.Quantity; x++)
                {
                    craftedItem = (_.CreateItemOnObject(blueprint.ItemResref, player.Object));
                    craftedItem.IsIdentified = true;
                    craftedItems.Add(craftedItem);
                }
            }

            // Recommended level gets set regardless if all item properties make it on the final product.
            // Also mark who crafted the item. This is later used for display on the item's examination event.
            foreach (var item in craftedItems)
            {
                item.RecommendedLevel = itemLevel < 0 ? 0 : itemLevel;
                item.SetLocalString("CRAFTER_PLAYER_ID", player.GlobalID.ToString());

                BaseService.ApplyCraftedItemLocalVariables(item, baseStructure);
            }

            if (RandomService.Random(1, 100) <= luckyBonus)
            {
                chance += RandomService.Random(1, luckyBonus);
            }

            int successAmount = 0;

            foreach (var component in model.MainComponents)
            {
                var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems);
                successAmount += result.Item1;
                chance         = result.Item2;
            }
            foreach (var component in model.SecondaryComponents)
            {
                var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems);
                successAmount += result.Item1;
                chance         = result.Item2;
            }
            foreach (var component in model.TertiaryComponents)
            {
                var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems);
                successAmount += result.Item1;
                chance         = result.Item2;
            }
            foreach (var component in model.EnhancementComponents)
            {
                var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems);
                successAmount += result.Item1;
                chance         = result.Item2;
            }

            // Structures gain increased durability based on the blueprint
            if (baseStructure != null)
            {
                foreach (var item in craftedItems)
                {
                    var maxDur = DurabilityService.GetMaxDurability(item);
                    maxDur += (float)baseStructure.Durability;
                    DurabilityService.SetMaxDurability(item, maxDur);
                    DurabilityService.SetDurability(item, maxDur);
                }
            }

            player.SendMessage("You created " + blueprint.Quantity + "x " + blueprint.ItemName + "!");
            int   baseXP = 750 + successAmount * RandomService.Random(1, 50);
            float xp     = SkillService.CalculateRegisteredSkillLevelAdjustedXP(baseXP, model.AdjustedLevel, pcSkill.Rank);

            bool exists = DataService.PCCraftedBlueprint.ExistsByPlayerIDAndCraftedBlueprintID(player.GlobalID, blueprint.ID);

            if (!exists)
            {
                xp = xp * 1.50f;
                player.SendMessage("You receive an XP bonus for crafting this item for the first time.");

                var pcCraftedBlueprint = new PCCraftedBlueprint
                {
                    CraftBlueprintID = blueprint.ID,
                    DateFirstCrafted = DateTime.UtcNow,
                    PlayerID         = player.GlobalID
                };

                DataService.SubmitDataChange(pcCraftedBlueprint, DatabaseActionType.Insert);
            }

            SkillService.GiveSkillXP(player, blueprint.SkillID, (int)xp);
            CraftService.ClearPlayerCraftingData(player, true);
            player.SetLocalInt("LAST_CRAFTED_BLUEPRINT_ID_" + blueprint.CraftDeviceID, blueprint.ID);
        }
Example #21
0
        public void Main()
        {
            NWPlaceable point = (_.OBJECT_SELF);
            NWPlayer    oPC   = (_.GetLastOpenedBy());

            if (!oPC.IsPlayer)
            {
                return;
            }

            var       effectiveStats           = PlayerStatService.GetPlayerItemEffectiveStats(oPC);
            const int baseChanceToFullyHarvest = 50;

            bool hasBeenSearched = point.GetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED") == 1;

            if (hasBeenSearched)
            {
                oPC.SendMessage("There's nothing left to harvest here...");
                return;
            }


            if (!oPC.IsPlayer && !oPC.IsDM)
            {
                return;
            }
            int rank        = SkillService.GetPCSkillRank(oPC, SkillType.Scavenging);
            int lootTableID = point.GetLocalInt("SCAVENGE_POINT_LOOT_TABLE_ID");
            int level       = point.GetLocalInt("SCAVENGE_POINT_LEVEL");
            int delta       = level - rank;

            if (delta > 8)
            {
                oPC.SendMessage("You aren't skilled enough to scavenge through this. (Required Level: " + (level - 8) + ")");
                oPC.AssignCommand(() => _.ActionInteractObject(point.Object));
                return;
            }

            int dc = 6 + delta;

            if (dc <= 4)
            {
                dc = 4;
            }
            int searchAttempts = 1 + CalculateSearchAttempts(oPC);

            int luck = PerkService.GetCreaturePerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck;

            if (RandomService.Random(100) + 1 <= luck / 2)
            {
                dc--;
            }

            oPC.AssignCommand(() => _.ActionPlayAnimation(Animation.LoopingGetLow, 1.0f, 2.0f));

            for (int attempt = 1; attempt <= searchAttempts; attempt++)
            {
                int roll = RandomService.Random(20) + 1;
                if (roll >= dc)
                {
                    oPC.FloatingText(ColorTokenService.SkillCheck("Search: *success*: (" + roll + " vs. DC: " + dc + ")"));
                    ItemVO spawnItem = LootService.PickRandomItemFromLootTable(lootTableID);

                    if (spawnItem == null)
                    {
                        return;
                    }

                    if (!string.IsNullOrWhiteSpace(spawnItem.Resref) && spawnItem.Quantity > 0)
                    {
                        _.CreateItemOnObject(spawnItem.Resref, point.Object, spawnItem.Quantity);
                    }

                    float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(200, level, rank);
                    SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp);
                }
                else
                {
                    oPC.FloatingText(ColorTokenService.SkillCheck("Search: *failure*: (" + roll + " vs. DC: " + dc + ")"));

                    float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(50, level, rank);
                    SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp);
                }
                dc += RandomService.Random(3) + 1;
            }

            // Chance to destroy the scavenge point.
            int chanceToFullyHarvest = baseChanceToFullyHarvest - (PerkService.GetCreaturePerkLevel(oPC, PerkType.CarefulScavenger) * 5);

            if (chanceToFullyHarvest <= 5)
            {
                chanceToFullyHarvest = 5;
            }

            point.SetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED", 1);
            oPC.SendMessage("This resource has been fully harvested...");

            point.SetLocalInt("SCAVENGE_POINT_DESPAWN_TICKS", 30);
        }
Example #22
0
        public bool Run(params object[] args)
        {
            NWPlaceable point = (Object.OBJECT_SELF);
            NWPlayer    oPC   = (_.GetLastOpenedBy());

            if (!oPC.IsPlayer)
            {
                return(false);
            }

            var       effectiveStats           = PlayerStatService.GetPlayerItemEffectiveStats(oPC);
            const int baseChanceToFullyHarvest = 50;
            bool      alwaysDestroys           = point.GetLocalInt("SCAVENGE_POINT_ALWAYS_DESTROYS") == 1;

            bool hasBeenSearched = point.GetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED") == 1;

            if (hasBeenSearched)
            {
                oPC.SendMessage("There's nothing left to harvest here...");
                return(true);
            }

            // Not fully harvested but the timer hasn't counted down yet.
            int refillTick = point.GetLocalInt("SCAVENGE_POINT_REFILL_TICKS");

            if (refillTick > 0)
            {
                oPC.SendMessage("You couldn't find anything new here. Check back later...");
                return(true);
            }

            if (!oPC.IsPlayer && !oPC.IsDM)
            {
                return(false);
            }
            int rank        = SkillService.GetPCSkillRank(oPC, SkillType.Scavenging);
            int lootTableID = point.GetLocalInt("SCAVENGE_POINT_LOOT_TABLE_ID");
            int level       = point.GetLocalInt("SCAVENGE_POINT_LEVEL");
            int delta       = level - rank;

            if (delta > 8)
            {
                oPC.SendMessage("You aren't skilled enough to scavenge through this. (Required Level: " + (level - 8) + ")");
                oPC.AssignCommand(() => _.ActionInteractObject(point.Object));
                return(true);
            }

            int dc = 6 + delta;

            if (dc <= 4)
            {
                dc = 4;
            }
            int searchAttempts = 1 + CalculateSearchAttempts(oPC);

            int luck = PerkService.GetCreaturePerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck;

            if (RandomService.Random(100) + 1 <= luck / 2)
            {
                dc--;
            }

            oPC.AssignCommand(() => _.ActionPlayAnimation(_.ANIMATION_LOOPING_GET_LOW, 1.0f, 2.0f));

            for (int attempt = 1; attempt <= searchAttempts; attempt++)
            {
                int roll = RandomService.Random(20) + 1;
                if (roll >= dc)
                {
                    oPC.FloatingText(ColorTokenService.SkillCheck("Search: *success*: (" + roll + " vs. DC: " + dc + ")"));
                    ItemVO spawnItem = LootService.PickRandomItemFromLootTable(lootTableID);

                    if (spawnItem == null)
                    {
                        return(false);
                    }

                    if (!string.IsNullOrWhiteSpace(spawnItem.Resref) && spawnItem.Quantity > 0)
                    {
                        _.CreateItemOnObject(spawnItem.Resref, point.Object, spawnItem.Quantity);
                    }

                    float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(200, level, rank);
                    SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp);
                }
                else
                {
                    oPC.FloatingText(ColorTokenService.SkillCheck("Search: *failure*: (" + roll + " vs. DC: " + dc + ")"));

                    float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(50, level, rank);
                    SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp);
                }
                dc += RandomService.Random(3) + 1;
            }

            // Chance to destroy the scavenge point.
            int    chanceToFullyHarvest = baseChanceToFullyHarvest - (PerkService.GetCreaturePerkLevel(oPC, PerkType.CarefulScavenger) * 5);
            string growingPlantID       = point.GetLocalString("GROWING_PLANT_ID");

            if (!string.IsNullOrWhiteSpace(growingPlantID))
            {
                Data.Entity.GrowingPlant growingPlant = FarmingService.GetGrowingPlantByID(new Guid(growingPlantID));
                chanceToFullyHarvest = chanceToFullyHarvest - (growingPlant.LongevityBonus);
            }

            if (chanceToFullyHarvest <= 5)
            {
                chanceToFullyHarvest = 5;
            }

            if (alwaysDestroys || RandomService.Random(100) + 1 <= chanceToFullyHarvest)
            {
                point.SetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED", 1);
                oPC.SendMessage("This resource has been fully harvested...");
            }
            // Otherwise the scavenge point will be refilled in 10-20 minutes.
            else
            {
                point.SetLocalInt("SCAVENGE_POINT_REFILL_TICKS", 100 + RandomService.Random(100));
            }

            point.SetLocalInt("SCAVENGE_POINT_DESPAWN_TICKS", 30);

            return(true);
        }
Example #23
0
        public bool Run(params object[] args)
        {
            NWPlaceable point = (Object.OBJECT_SELF);
            NWPlayer    oPC   = (_.GetLastOpenedBy());

            if (!oPC.IsPlayer)
            {
                return(false);
            }

            var       effectiveStats           = PlayerStatService.GetPlayerItemEffectiveStats(oPC);
            const int baseChanceToFullyHarvest = 50;
            bool      alwaysDestroys           = point.GetLocalInt("SCAVENGE_POINT_ALWAYS_DESTROYS") == 1;

            bool hasBeenSearched = point.GetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED") == 1;

            if (hasBeenSearched)
            {
                oPC.SendMessage("There's nothing left to harvest here...");
                return(true);
            }

            // Not fully harvested but the timer hasn't counted down yet.
            int refillTick = point.GetLocalInt("SCAVENGE_POINT_REFILL_TICKS");

            if (refillTick > 0)
            {
                oPC.SendMessage("You couldn't find anything new here. Check back later...");
                return(true);
            }

            if (!oPC.IsPlayer && !oPC.IsDM)
            {
                return(false);
            }
            int rank        = SkillService.GetPCSkillRank(oPC, SkillType.Scavenging);
            int lootTableID = point.GetLocalInt("SCAVENGE_POINT_LOOT_TABLE_ID");
            int level       = point.GetLocalInt("SCAVENGE_POINT_LEVEL");
            int delta       = level - rank;

            if (delta > 8)
            {
                oPC.SendMessage("You aren't skilled enough to scavenge through this. (Required Level: " + (level - 8) + ")");
                oPC.AssignCommand(() => _.ActionInteractObject(point.Object));
                return(true);
            }

            int dc = 6 + delta;

            if (dc <= 4)
            {
                dc = 4;
            }
            int searchAttempts = 1 + CalculateSearchAttempts(oPC);

            int luck = PerkService.GetPCPerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck;

            if (RandomService.Random(100) + 1 <= luck / 2)
            {
                dc--;
            }

            oPC.AssignCommand(() => _.ActionPlayAnimation(_.ANIMATION_LOOPING_GET_LOW, 1.0f, 2.0f));

            for (int attempt = 1; attempt <= searchAttempts; attempt++)
            {
                int roll = RandomService.Random(20) + 1;
                if (roll >= dc)
                {
                    oPC.FloatingText(ColorTokenService.SkillCheck("Search: *success*: (" + roll + " vs. DC: " + dc + ")"));
                    ItemVO spawnItem = LootService.PickRandomItemFromLootTable(lootTableID);

                    if (spawnItem == null)
                    {
                        return(false);
                    }

                    if (!string.IsNullOrWhiteSpace(spawnItem.Resref) && spawnItem.Quantity > 0)
                    {
                        NWItem resource = _.CreateItemOnObject(spawnItem.Resref, point.Object, spawnItem.Quantity);

                        var componentIP = resource.ItemProperties.FirstOrDefault(x => _.GetItemPropertyType(x) == (int)CustomItemPropertyType.ComponentType);
                        if (componentIP != null)
                        {
                            // Add properties to the item based on Scavenging skill.  Similar logic to the resource harvester.
                            var             chance = RandomService.Random(1, 100) + PerkService.GetPCPerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck;
                            ResourceQuality quality;

                            if (chance < 50)
                            {
                                quality = ResourceQuality.Low;
                            }
                            else if (chance < 75)
                            {
                                quality = ResourceQuality.Normal;
                            }
                            else if (chance < 95)
                            {
                                quality = ResourceQuality.High;
                            }
                            else
                            {
                                quality = ResourceQuality.VeryHigh;
                            }

                            int ipBonusChance = ResourceService.CalculateChanceForComponentBonus(oPC, (level / 10 + 1), quality, true);

                            if (RandomService.Random(1, 100) <= ipBonusChance)
                            {
                                var ip = ResourceService.GetRandomComponentBonusIP(ResourceQuality.Normal);
                                BiowareXP2.IPSafeAddItemProperty(resource, ip.Item1, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true);

                                switch (ip.Item2)
                                {
                                case 0:
                                    resource.Name = ColorTokenService.Green(resource.Name);
                                    break;

                                case 1:
                                    resource.Name = ColorTokenService.Blue(resource.Name);
                                    break;

                                case 2:
                                    resource.Name = ColorTokenService.Purple(resource.Name);
                                    break;

                                case 3:
                                    resource.Name = ColorTokenService.Orange(resource.Name);
                                    break;
                                }
                            }
                        }
                    }

                    float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(200, level, rank);
                    SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp);
                }
                else
                {
                    oPC.FloatingText(ColorTokenService.SkillCheck("Search: *failure*: (" + roll + " vs. DC: " + dc + ")"));

                    float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(50, level, rank);
                    SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp);
                }
                dc += RandomService.Random(3) + 1;
            }

            // Chance to destroy the scavenge point.
            int    chanceToFullyHarvest = baseChanceToFullyHarvest - (PerkService.GetPCPerkLevel(oPC, PerkType.CarefulScavenger) * 5);
            string growingPlantID       = point.GetLocalString("GROWING_PLANT_ID");

            if (!string.IsNullOrWhiteSpace(growingPlantID))
            {
                Data.Entity.GrowingPlant growingPlant = FarmingService.GetGrowingPlantByID(new Guid(growingPlantID));
                chanceToFullyHarvest = chanceToFullyHarvest - (growingPlant.LongevityBonus);
            }

            if (chanceToFullyHarvest <= 5)
            {
                chanceToFullyHarvest = 5;
            }

            if (alwaysDestroys || RandomService.Random(100) + 1 <= chanceToFullyHarvest)
            {
                point.SetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED", 1);
                oPC.SendMessage("This resource has been fully harvested...");
            }
            // Otherwise the scavenge point will be refilled in 10-20 minutes.
            else
            {
                point.SetLocalInt("SCAVENGE_POINT_REFILL_TICKS", 100 + RandomService.Random(100));
            }

            point.SetLocalInt("SCAVENGE_POINT_DESPAWN_TICKS", 30);

            return(true);
        }
Example #24
0
        private void HandleDistributeRPXPResponse(int responseID)
        {
            NWPlayer player   = GetPC();
            Player   dbPlayer = DataService.Player.GetByID(player.GlobalID);
            Model    vm       = GetDialogCustomData <Model>();

            switch (responseID)
            {
            case 1:     // Select All RP XP
                vm.RPXPDistributing = dbPlayer.RoleplayXP;
                break;

            case 2:     // Increase by 1000
                vm.RPXPDistributing += 1000;
                break;

            case 3:     // Increase by 100
                vm.RPXPDistributing += 100;
                break;

            case 4:     // Increase by 10
                vm.RPXPDistributing += 10;
                break;

            case 5:     // Increase by 1
                vm.RPXPDistributing += 1;
                break;

            case 6:     // Decrease by 1000
                vm.RPXPDistributing -= 1000;
                break;

            case 7:     // Decrease by 100
                vm.RPXPDistributing -= 100;
                break;

            case 8:     // Decrease by 10
                vm.RPXPDistributing -= 10;
                break;

            case 9:     // Decrease by 1
                vm.RPXPDistributing -= 1;
                break;

            case 10:     // Distribute Roleplay XP

                // Make sure the player specified how much they want to distribute.
                if (vm.RPXPDistributing <= 0)
                {
                    player.SendMessage("Please specify how much RP XP you'd like to distribute into this skill.");
                    vm.IsConfirming = false;
                }
                else
                {
                    if (vm.IsConfirming)
                    {
                        // Give the distributed XP to a particular skill.
                        // We disable residency bonuses, DM bonuses, and skill penalties during this distribution because
                        // those are calculated when we give the player RP XP.
                        SkillService.GiveSkillXP(player, vm.SelectedSkillID, vm.RPXPDistributing, false, false, false);

                        dbPlayer             = DataService.Player.GetByID(player.GlobalID);
                        dbPlayer.RoleplayXP -= vm.RPXPDistributing;
                        DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update);
                        vm.IsConfirming     = false;
                        vm.RPXPDistributing = 0;
                    }
                    else
                    {
                        vm.IsConfirming = true;
                    }
                }
                break;
            }

            if (vm.RPXPDistributing > dbPlayer.RoleplayXP)
            {
                vm.RPXPDistributing = dbPlayer.RoleplayXP;
            }
            else if (vm.RPXPDistributing < 0)
            {
                vm.RPXPDistributing = 0;
            }

            LoadDistributeRPXPPage();
        }
Example #25
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer        player     = user.Object;
            ResourceQuality quality    = (ResourceQuality)target.GetLocalInt("RESOURCE_QUALITY");
            int             tier       = target.GetLocalInt("RESOURCE_TIER");
            int             remaining  = target.GetLocalInt("RESOURCE_COUNT") - 1;
            string          itemResref = target.GetLocalString("RESOURCE_RESREF");
            int             gemChance  = ResourceService.CalculateChanceForComponentBonus(player, tier, quality);
            int             roll       = RandomService.Random(1, 100);
            int             rank       = SkillService.GetPCSkillRank(player, SkillType.Harvesting);

            if (item.RecommendedLevel < rank)
            {
                rank = item.RecommendedLevel;
            }

            int difficulty = (tier - 1) * 10 + ResourceService.GetDifficultyAdjustment(quality);
            int delta      = difficulty - rank;

            int baseXP = 0;

            if (delta >= 6)
            {
                baseXP = 400;
            }
            else if (delta == 5)
            {
                baseXP = 350;
            }
            else if (delta == 4)
            {
                baseXP = 325;
            }
            else if (delta == 3)
            {
                baseXP = 300;
            }
            else if (delta == 2)
            {
                baseXP = 250;
            }
            else if (delta == 1)
            {
                baseXP = 225;
            }
            else if (delta == 0)
            {
                baseXP = 200;
            }
            else if (delta == -1)
            {
                baseXP = 150;
            }
            else if (delta == -2)
            {
                baseXP = 100;
            }
            else if (delta == -3)
            {
                baseXP = 50;
            }
            else if (delta == -4)
            {
                baseXP = 25;
            }

            int itemHarvestBonus = item.HarvestingBonus;
            int scanningBonus    = user.GetLocalInt(target.GlobalID.ToString());

            gemChance += itemHarvestBonus * 2 + scanningBonus * 2;

            baseXP = baseXP + scanningBonus * 5;

            // Spawn the normal resource.
            NWItem resource = CreateItemOnObject(itemResref, player);

            user.SendMessage("You harvest " + resource.Name + ".");

            // If player meets the chance to acquire a gem, create one and modify its properties.
            if (quality > ResourceQuality.Low && roll <= gemChance)
            {
                // Gemstone quality is determined by the quality of the vein.
                switch (quality)
                {
                case ResourceQuality.Normal:
                    resource = CreateItemOnObject("flawed_gemstone", player);
                    break;

                case ResourceQuality.High:
                    resource = CreateItemOnObject("gemstone", player);
                    break;

                case ResourceQuality.VeryHigh:
                    resource = CreateItemOnObject("perfect_gemstone", player);
                    break;
                }

                var ip = ResourceService.GetRandomComponentBonusIP(quality);
                BiowareXP2.IPSafeAddItemProperty(resource, ip.Item1, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true);

                switch (ip.Item2)
                {
                case 0:
                    resource.Name = ColorTokenService.Green(resource.Name);
                    break;

                case 1:
                    resource.Name = ColorTokenService.Blue(resource.Name);
                    break;

                case 2:
                    resource.Name = ColorTokenService.Purple(resource.Name);
                    break;

                case 3:
                    resource.Name = ColorTokenService.Orange(resource.Name);
                    break;

                case 4:
                    resource.Name = ColorTokenService.LightPurple(resource.Name);
                    break;

                case 5:
                    resource.Name = ColorTokenService.Yellow(resource.Name);
                    break;

                case 6:
                    resource.Name = ColorTokenService.Red(resource.Name);
                    break;

                case 7:
                    resource.Name = ColorTokenService.Cyan(resource.Name);
                    break;
                }

                user.SendMessage("You harvest " + resource.Name + ".");
            }

            float decayMinimum = 0.03f;
            float decayMaximum = 0.07f;

            if (delta > 0)
            {
                decayMinimum += delta * 0.1f;
                decayMaximum += delta * 0.1f;
            }

            DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(decayMinimum, decayMaximum));
            int xp = baseXP;

            SkillService.GiveSkillXP(player, SkillType.Harvesting, xp);

            if (remaining <= 0)
            {
                NWPlaceable prop = target.GetLocalObject("RESOURCE_PROP_OBJ");

                if (prop.IsValid)
                {
                    prop.Destroy();
                }

                target.Destroy();
                user.DeleteLocalInt(target.GlobalID.ToString());
            }
            else
            {
                target.SetLocalInt("RESOURCE_COUNT", remaining);
            }

            ApplyEffectAtLocation(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Fnf_Summon_Monster_3), target.Location);
        }
Example #26
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            Effect effect;
            float  duration;

            switch (spellTier)
            {
            case 1:
                effect   = _.EffectMovementSpeedIncrease(10);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(_.ABILITY_DEXTERITY, 2));
                duration = 60f;
                break;

            case 2:
                effect   = _.EffectMovementSpeedIncrease(20);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(_.ABILITY_DEXTERITY, 4));
                duration = 90f;
                break;

            case 3:
                effect   = _.EffectMovementSpeedIncrease(30);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(_.ABILITY_DEXTERITY, 6));
                effect   = _.EffectLinkEffects(effect, _.EffectModifyAttacks(1));
                duration = 120f;
                break;

            case 4:
                effect   = _.EffectMovementSpeedIncrease(40);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(_.ABILITY_DEXTERITY, 8));
                effect   = _.EffectLinkEffects(effect, _.EffectModifyAttacks(1));
                duration = 150f;
                break;

            case 5:
                effect   = _.EffectMovementSpeedIncrease(50);
                effect   = _.EffectLinkEffects(effect, _.EffectAbilityIncrease(_.ABILITY_DEXTERITY, 10));
                effect   = _.EffectLinkEffects(effect, _.EffectModifyAttacks(1));
                duration = 180f;
                break;

            default:
                throw new ArgumentException(nameof(perkLevel) + " invalid. Value " + perkLevel + " is unhandled.");
            }

            // Check lucky chance.
            int luck = PerkService.GetCreaturePerkLevel(creature, PerkType.Lucky);

            if (RandomService.D100(1) <= luck)
            {
                duration *= 2;
                creature.SendMessage("Lucky Force Speed!");
            }

            _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, effect, target, duration);
            _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectVisualEffect(_.VFX_IMP_AC_BONUS), target);

            if (creature.IsPlayer)
            {
                NWPlayer player     = creature.Object;
                int      skillLevel = SkillService.GetPCSkillRank(player, SkillType.ForceControl);
                int      xp         = skillLevel * 10 + 10;
                SkillService.GiveSkillXP(player, SkillType.ForceControl, xp);
            }
        }
Example #27
0
        public void ApplyEffects(NWCreature user, NWItem modItem, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player                = (user.Object);
            NWItem   targetItem            = (target.Object);
            ModSlots slots                 = ModService.GetModSlots(targetItem);
            CustomItemPropertyType modType = ModService.GetModType(modItem);
            int modID = modItem.GetLocalInt("RUNE_ID");

            string[] modArgs       = modItem.GetLocalString("RUNE_VALUE").Split(',');
            int      modLevel      = modItem.RecommendedLevel;
            int      levelIncrease = modItem.LevelIncrease;

            var mod = ModService.GetModHandler(modID);

            mod.Apply(player, targetItem, modArgs);

            string description  = mod.Description(player, targetItem, modArgs);
            bool   usePrismatic = false;

            switch (modType)
            {
            case CustomItemPropertyType.RedMod:
                if (slots.FilledRedSlots < slots.RedSlots)
                {
                    targetItem.SetLocalInt("MOD_SLOT_RED_" + (slots.FilledRedSlots + 1), modID);
                    targetItem.SetLocalString("MOD_SLOT_RED_DESC_" + (slots.FilledRedSlots + 1), description);
                    player.SendMessage("Mod installed into " + ColorTokenService.Red("red") + " slot #" + (slots.FilledRedSlots + 1));
                }
                else
                {
                    usePrismatic = true;
                }
                break;

            case CustomItemPropertyType.BlueMod:
                if (slots.FilledBlueSlots < slots.BlueSlots)
                {
                    targetItem.SetLocalInt("MOD_SLOT_BLUE_" + (slots.FilledBlueSlots + 1), modID);
                    targetItem.SetLocalString("MOD_SLOT_BLUE_DESC_" + (slots.FilledBlueSlots + 1), description);
                    player.SendMessage("Mod installed into " + ColorTokenService.Blue("blue") + " slot #" + (slots.FilledBlueSlots + 1));
                }
                else
                {
                    usePrismatic = true;
                }
                break;

            case CustomItemPropertyType.GreenMod:
                if (slots.FilledBlueSlots < slots.GreenSlots)
                {
                    targetItem.SetLocalInt("MOD_SLOT_GREEN_" + (slots.FilledGreenSlots + 1), modID);
                    targetItem.SetLocalString("MOD_SLOT_GREEN_DESC_" + (slots.FilledGreenSlots + 1), description);
                    player.SendMessage("Mod installed into " + ColorTokenService.Green("green") + " slot #" + (slots.FilledGreenSlots + 1));
                }
                else
                {
                    usePrismatic = true;
                }
                break;

            case CustomItemPropertyType.YellowMod:
                if (slots.FilledBlueSlots < slots.YellowSlots)
                {
                    targetItem.SetLocalInt("MOD_SLOT_YELLOW_" + (slots.FilledYellowSlots + 1), modID);
                    targetItem.SetLocalString("MOD_SLOT_YELLOW_DESC_" + (slots.FilledYellowSlots + 1), description);
                    player.SendMessage("Mod installed into " + ColorTokenService.Yellow("yellow") + " slot #" + (slots.FilledYellowSlots + 1));
                }
                else
                {
                    usePrismatic = true;
                }
                break;
            }

            if (usePrismatic)
            {
                string prismaticText = ModService.PrismaticString();
                targetItem.SetLocalInt("MOD_SLOT_PRISMATIC_" + (slots.FilledPrismaticSlots + 1), modID);
                targetItem.SetLocalString("MOD_SLOT_PRISMATIC_DESC_" + (slots.FilledPrismaticSlots + 1), description);
                player.SendMessage("Mod installed into " + prismaticText + " slot #" + (slots.FilledPrismaticSlots + 1));
            }

            targetItem.RecommendedLevel += levelIncrease;
            modItem.Destroy();

            SkillType skillType;

            if (ArmorBaseItemTypes.Contains(targetItem.BaseItemType))
            {
                skillType = SkillType.Armorsmith;
            }
            else if (WeaponsmithBaseItemTypes.Contains(targetItem.BaseItemType))
            {
                skillType = SkillType.Weaponsmith;
            }
            else if (EngineeringBaseItemTypes.Contains(targetItem.BaseItemType))
            {
                skillType = SkillType.Engineering;
            }
            else
            {
                return;
            }

            int rank = SkillService.GetPCSkillRank(player, skillType);
            int xp   = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(400, modLevel, rank);

            SkillService.GiveSkillXP(player, skillType, xp);
        }
Example #28
0
        public bool Run(params object[] args)
        {
            NWPlaceable container      = (Object.OBJECT_SELF);
            NWPlayer    oPC            = (_.GetLastDisturbed());
            int         type           = _.GetInventoryDisturbType();
            NWItem      item           = (_.GetInventoryDisturbItem());
            var         effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(oPC);

            if (type != _.INVENTORY_DISTURB_TYPE_ADDED)
            {
                return(false);
            }

            int plantID = item.GetLocalInt("PLANT_ID");

            if (plantID <= 0)
            {
                ItemService.ReturnItem(oPC, item);
                oPC.SendMessage("You cannot plant that item.");
                return(true);
            }

            Plant plant = FarmingService.GetPlantByID(plantID);

            if (plant == null)
            {
                ItemService.ReturnItem(oPC, item);
                oPC.SendMessage("You cannot plant that item.");
                return(true);
            }

            int rank = SkillService.GetPCSkillRank(oPC, SkillType.Farming);

            if (rank + 2 < plant.Level)
            {
                ItemService.ReturnItem(oPC, item);
                oPC.SendMessage("You do not have enough Farming skill to plant that seed. (Required: " + (plant.Level - 2) + ")");
                return(true);
            }

            item.Destroy();

            string   areaTag       = container.Area.Tag;
            Location plantLocation = container.Location;
            int      perkBonus     = PerkService.GetPCPerkLevel(oPC, PerkType.FarmingEfficiency) * 2;
            int      ticks         = (int)(plant.BaseTicks - ((PerkService.GetPCPerkLevel(oPC, PerkType.ExpertFarmer) * 0.05f)) * plant.BaseTicks);

            Data.Entity.GrowingPlant growingPlant = new Data.Entity.GrowingPlant
            {
                PlantID             = plant.ID,
                RemainingTicks      = ticks,
                LocationAreaTag     = areaTag,
                LocationOrientation = _.GetFacingFromLocation(plantLocation),
                LocationX           = _.GetPositionFromLocation(plantLocation).m_X,
                LocationY           = _.GetPositionFromLocation(plantLocation).m_Y,
                LocationZ           = _.GetPositionFromLocation(plantLocation).m_Z,
                IsActive            = true,
                DateCreated         = DateTime.UtcNow,
                LongevityBonus      = perkBonus
            };

            DataService.SubmitDataChange(growingPlant, DatabaseActionType.Insert);

            NWPlaceable hole     = (container.GetLocalObject("FARM_SMALL_HOLE"));
            NWPlaceable plantPlc = (_.CreateObject(_.OBJECT_TYPE_PLACEABLE, "growing_plant", hole.Location));

            plantPlc.SetLocalString("GROWING_PLANT_ID", growingPlant.ID.ToString());
            plantPlc.Name = "Growing Plant (" + plant.Name + ")";

            container.Destroy();
            hole.Destroy();

            int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(200, plant.Level, rank);

            if (RandomService.Random(100) + 1 <= PerkService.GetPCPerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck)
            {
                xp *= 2;
            }

            SkillService.GiveSkillXP(oPC, SkillType.Farming, xp);
            return(true);
        }
Example #29
0
        // New component items will be spawned and the appropriate properties from the base item will be transferred.
        public bool Run(params object[] args)
        {
            _player          = (NWPlayer)args[0];
            _playerItemStats = PlayerStatService.GetPlayerItemEffectiveStats(_player);
            int xp = 100; // Always grant at least this much XP to player.

            // Remove the immobilization effect
            foreach (var effect in _player.Effects)
            {
                if (_.GetEffectTag(effect) == "CRAFTING_IMMOBILIZATION")
                {
                    _.RemoveEffect(_player, effect);
                }
            }

            string      serializedSalvageItem = (string)args[1];
            NWPlaceable tempStorage           = _.GetObjectByTag("TEMP_ITEM_STORAGE");
            NWItem      item = SerializationService.DeserializeItem(serializedSalvageItem, tempStorage);
            int         salvageComponentTypeID = (int)args[2];

            _componentType = DataService.Get <ComponentType>(salvageComponentTypeID);

            // Create an item with no bonuses every time.
            _.CreateItemOnObject(_componentType.ReassembledResref, _player);

            // First check is for attack bonuses
            foreach (var prop in item.ItemProperties)
            {
                int propTypeID = _.GetItemPropertyType(prop);
                if (propTypeID == _.ITEM_PROPERTY_ATTACK_BONUS)
                {
                    // Get the amount of Attack Bonus
                    int amount = _.GetItemPropertyCostTableValue(prop);

                    xp += ProcessProperty(amount, 3, ComponentBonusType.AttackBonusUp);
                }
            }

            // Now check specific custom properties which are stored as local variables on the item.
            xp += ProcessProperty(item.CustomAC, 3, ComponentBonusType.ACUp);
            xp += ProcessProperty(item.HarvestingBonus, 3, ComponentBonusType.HarvestingUp);
            xp += ProcessProperty(item.PilotingBonus, 3, ComponentBonusType.PilotingUp);
            xp += ProcessProperty(item.ScanningBonus, 3, ComponentBonusType.ScanningUp);
            xp += ProcessProperty(item.ScavengingBonus, 3, ComponentBonusType.ScavengingUp);
            xp += ProcessProperty(item.CastingSpeed, 3, ComponentBonusType.CastingSpeedUp);
            xp += ProcessProperty(item.CraftBonusArmorsmith, 3, ComponentBonusType.ArmorsmithUp);
            xp += ProcessProperty(item.CraftBonusWeaponsmith, 3, ComponentBonusType.WeaponsmithUp);
            xp += ProcessProperty(item.CraftBonusCooking, 3, ComponentBonusType.CookingUp);
            xp += ProcessProperty(item.CraftBonusEngineering, 3, ComponentBonusType.EngineeringUp);
            xp += ProcessProperty(item.CraftBonusFabrication, 3, ComponentBonusType.FabricationUp);
            xp += ProcessProperty(item.HPBonus, 5, ComponentBonusType.HPUp, 0.5f);
            xp += ProcessProperty(item.FPBonus, 5, ComponentBonusType.FPUp, 0.5f);
            xp += ProcessProperty(item.EnmityRate, 3, ComponentBonusType.EnmityUp);
            xp += ProcessProperty(item.ForcePotencyBonus, 3, ComponentBonusType.ForcePotencyUp);
            xp += ProcessProperty(item.ForceAccuracyBonus, 3, ComponentBonusType.ForceAccuracyUp);
            xp += ProcessProperty(item.ForceDefenseBonus, 3, ComponentBonusType.ForceDefenseUp);
            xp += ProcessProperty(item.ElectricalPotencyBonus, 3, ComponentBonusType.ElectricalPotencyUp);
            xp += ProcessProperty(item.MindPotencyBonus, 3, ComponentBonusType.MindPotencyUp);
            xp += ProcessProperty(item.LightPotencyBonus, 3, ComponentBonusType.LightPotencyUp);
            xp += ProcessProperty(item.DarkPotencyBonus, 3, ComponentBonusType.DarkPotencyUp);
            xp += ProcessProperty(item.ElectricalDefenseBonus, 3, ComponentBonusType.ElectricalDefenseUp);
            xp += ProcessProperty(item.MindDefenseBonus, 3, ComponentBonusType.MindDefenseUp);
            xp += ProcessProperty(item.LightDefenseBonus, 3, ComponentBonusType.LightDefenseUp);
            xp += ProcessProperty(item.DarkDefenseBonus, 3, ComponentBonusType.DarkDefenseUp);

            xp += ProcessProperty(item.LuckBonus, 3, ComponentBonusType.LuckUp);
            xp += ProcessProperty(item.MeditateBonus, 3, ComponentBonusType.MeditateUp);
            xp += ProcessProperty(item.RestBonus, 3, ComponentBonusType.RestUp);
            xp += ProcessProperty(item.MedicineBonus, 3, ComponentBonusType.MedicineUp);
            xp += ProcessProperty(item.HPRegenBonus, 3, ComponentBonusType.HPRegenUp);
            xp += ProcessProperty(item.FPRegenBonus, 3, ComponentBonusType.FPRegenUp);
            xp += ProcessProperty(item.BaseAttackBonus, 3, ComponentBonusType.BaseAttackBonusUp, 6f);
            xp += ProcessProperty(item.StructureBonus, 3, ComponentBonusType.StructureBonusUp);
            xp += ProcessProperty(item.SneakAttackBonus, 3, ComponentBonusType.SneakAttackUp);
            xp += ProcessProperty(item.DamageBonus, 3, ComponentBonusType.DamageUp);
            xp += ProcessProperty(item.StrengthBonus, 3, ComponentBonusType.StrengthUp);
            xp += ProcessProperty(item.DexterityBonus, 3, ComponentBonusType.DexterityUp);
            xp += ProcessProperty(item.ConstitutionBonus, 3, ComponentBonusType.ConstitutionUp);
            xp += ProcessProperty(item.WisdomBonus, 3, ComponentBonusType.WisdomUp);
            xp += ProcessProperty(item.IntelligenceBonus, 3, ComponentBonusType.IntelligenceUp);
            xp += ProcessProperty(item.CharismaBonus, 3, ComponentBonusType.CharismaUp);
            xp += ProcessProperty(item.DurationBonus, 3, ComponentBonusType.DurationUp);

            item.Destroy();

            SkillService.GiveSkillXP(_player, SkillType.Harvesting, xp);
            return(true);
        }
Example #30
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            SkillType skillType  = GetSkillType(item);
            NWItem    targetitem = (target.Object);
            int       tech       = item.GetLocalInt("TECH_LEVEL");
            float     maxDurabilityReductionPenalty = item.GetLocalFloat("MAX_DURABILITY_REDUCTION_PENALTY");
            int       repairAmount = tech * 2;
            int       skillRank;
            int       level  = targetitem.RecommendedLevel;
            int       delta  = 0;
            int       baseXP = 0;

            if (skillType == SkillType.Armorsmith)
            {
                skillRank     = (SkillService.GetPCSkillRank(user.Object, skillType));
                repairAmount += item.CraftBonusArmorsmith + (PerkService.GetPCPerkLevel(user.Object, PerkType.ArmorRepair) * 2);
                delta         = level - skillRank;
            }
            else if (skillType == SkillType.Weaponsmith)
            {
                skillRank     = (SkillService.GetPCSkillRank(user.Object, skillType));
                repairAmount += item.CraftBonusWeaponsmith + (PerkService.GetPCPerkLevel(user.Object, PerkType.WeaponRepair) * 2);
                delta         = level - skillRank;
            }
            else if (skillType == SkillType.Engineering)
            {
                skillRank     = (SkillService.GetPCSkillRank(user.Object, skillType));
                repairAmount += item.CraftBonusEngineering + (PerkService.GetPCPerkLevel(user.Object, PerkType.ElectronicRepair) * 2);
                delta         = level - skillRank;
            }
            float minReduction    = 0.05f * tech;
            float maxReduction    = 0.15f * tech;
            float reductionAmount = RandomService.RandomFloat(minReduction, maxReduction);

            if (delta >= 6)
            {
                baseXP = 400;
            }
            else if (delta == 5)
            {
                baseXP = 350;
            }
            else if (delta == 4)
            {
                baseXP = 325;
            }
            else if (delta == 3)
            {
                baseXP = 300;
            }
            else if (delta == 2)
            {
                baseXP = 250;
            }
            else if (delta == 1)
            {
                baseXP = 225;
            }
            else if (delta == 0)
            {
                baseXP = 200;
            }
            else if (delta == -1)
            {
                baseXP = 150;
            }
            else if (delta == -2)
            {
                baseXP = 100;
            }
            else if (delta == -3)
            {
                baseXP = 50;
            }
            else if (delta == -4)
            {
                baseXP = 25;
            }
            SkillService.GiveSkillXP(user.Object, skillType, baseXP);
            DurabilityService.RunItemRepair(user.Object, target.Object, repairAmount, reductionAmount + maxDurabilityReductionPenalty);
        }