Exemplo n.º 1
0
        private static void HandleQueueWeaponSkill(NWCreature activator, Data.Entity.Perk entity, IPerkHandler ability, Feat spellFeatID)
        {
            var    perkFeat           = DataService.PerkFeat.GetByFeatID((int)spellFeatID);
            int?   cooldownCategoryID = ability.CooldownCategoryID(activator, entity.CooldownCategoryID, perkFeat.PerkLevelUnlocked);
            var    cooldownCategory   = DataService.CooldownCategory.GetByID(Convert.ToInt32(cooldownCategoryID));
            string queueUUID          = Guid.NewGuid().ToString();

            activator.SetLocalInt("ACTIVE_WEAPON_SKILL", entity.ID);
            activator.SetLocalString("ACTIVE_WEAPON_SKILL_UUID", queueUUID);
            activator.SetLocalInt("ACTIVE_WEAPON_SKILL_FEAT_ID", (int)spellFeatID);
            activator.SendMessage("Weapon skill '" + entity.Name + "' queued for next attack.");
            SendAOEMessage(activator, activator.Name + " readies weapon skill '" + entity.Name + "'.");

            ApplyCooldown(activator, cooldownCategory, ability, perkFeat.PerkLevelUnlocked, 0.0f);

            // Player must attack within 30 seconds after queueing or else it wears off.
            _.DelayCommand(30f, () =>
            {
                if (activator.GetLocalString("ACTIVE_WEAPON_SKILL_UUID") == queueUUID)
                {
                    activator.DeleteLocalInt("ACTIVE_WEAPON_SKILL");
                    activator.DeleteLocalString("ACTIVE_WEAPON_SKILL_UUID");
                    activator.DeleteLocalInt("ACTIVE_WEAPON_SKILL_FEAT_ID");
                    activator.SendMessage("Your weapon skill '" + entity.Name + "' is no longer queued.");
                    SendAOEMessage(activator, activator.Name + " no longer has weapon skill '" + entity.Name + "' readied.");
                }
            });
        }
Exemplo n.º 2
0
        public bool Run(params object[] args)
        {
            NWCreature      attacker    = (_.GetLastDamager(Object.OBJECT_SELF));
            NWPlaceable     tower       = (Object.OBJECT_SELF);
            NWItem          weapon      = (_.GetLastWeaponUsed(attacker.Object));
            int             damage      = _.GetTotalDamageDealt();
            var             structureID = tower.GetLocalString("PC_BASE_STRUCTURE_ID");
            PCBaseStructure structure   = _data.Single <PCBaseStructure>(x => x.ID == new Guid(structureID));
            int             maxShieldHP = _base.CalculateMaxShieldHP(structure);
            PCBase          pcBase      = _data.Get <PCBase>(structure.PCBaseID);

            pcBase.ShieldHP -= damage;
            if (pcBase.ShieldHP <= 0)
            {
                pcBase.ShieldHP = 0;
            }
            float hpPercentage = (float)pcBase.ShieldHP / (float)maxShieldHP * 100.0f;

            if (hpPercentage <= 25.0f && pcBase.ReinforcedFuel > 0)
            {
                pcBase.IsInReinforcedMode = true;
                pcBase.ShieldHP           = (int)(maxShieldHP * 0.25f);
            }

            attacker.SendMessage("Tower Shields: " + hpPercentage.ToString("0.00") + "%");

            if (pcBase.IsInReinforcedMode)
            {
                attacker.SendMessage("Control tower is in reinforced mode and cannot be damaged. Reinforced mode will be disabled when the tower runs out of fuel.");
            }

            _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(9999), tower.Object);

            var durability = _durability.GetDurability(weapon) - _random.RandomFloat(0.01f, 0.03f);

            _durability.SetDurability(weapon, durability);

            if (pcBase.ShieldHP <= 0)
            {
                pcBase.ShieldHP = 0;

                structure.Durability -= _random.RandomFloat(0.5f, 2.0f);
                if (structure.Durability < 0.0f)
                {
                    structure.Durability = 0.0f;
                }
                attacker.SendMessage("Structure Durability: " + structure.Durability.ToString("0.00"));

                if (structure.Durability <= 0.0f)
                {
                    structure.Durability = 0.0f;
                    BlowUpBase(pcBase);
                    return(true);
                }
            }

            _data.SubmitDataChange(pcBase, DatabaseActionType.Update);
            _data.SubmitDataChange(structure, DatabaseActionType.Update);
            return(true);
        }
Exemplo n.º 3
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            int growingPlantID = target.GetLocalInt("GROWING_PLANT_ID");

            if (growingPlantID <= 0)
            {
                user.SendMessage("Water jugs can only target growing plants.");
                return;
            }
            GrowingPlant growingPlant = _db.GrowingPlants.Single(x => x.GrowingPlantID == growingPlantID);

            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;
            }

            PlayerCharacter pcEntity = _db.PlayerCharacters.Single(x => x.PlayerID == user.GlobalID);

            // Farmers get a 5% chance to not expend a charge.
            if (pcEntity.BackgroundID != (int)BackgroundType.Farmer || _random.Random(100) + 1 > 5)
            {
                item.Charges--;
            }

            int remainingTicks = growingPlant.RemainingTicks;

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

            growingPlant.WaterStatus    = 0;
            growingPlant.RemainingTicks = remainingTicks;
            _db.SaveChanges();

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

            PCSkill pcSkill = _skill.GetPCSkill((NWPlayer)user, SkillType.Farming);

            if (pcSkill == null)
            {
                return;
            }

            int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(100, growingPlant.Plant.Level, pcSkill.Rank);

            _skill.GiveSkillXP((NWPlayer)user, SkillType.Farming, xp);
        }
Exemplo n.º 4
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player           = user.Object;
            int      ability          = item.GetLocalInt("ABILITY_TYPE");
            int      amount           = item.GetLocalInt("AMOUNT") + item.MedicineBonus;
            int      rank             = player.IsPlayer ? _skill.GetPCSkillRank(player, SkillType.Medicine) : 0;
            int      recommendedLevel = item.RecommendedLevel;
            float    duration         = 30.0f;
            int      perkLevel        = player.IsPlayer ? _perk.GetPCPerkLevel(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(NWScript.DURATION_TYPE_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)_skill.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank);

            _skill.GiveSkillXP(player, SkillType.Medicine, xp);
        }
Exemplo n.º 5
0
        private static void CheckForSpellInterruption(NWCreature activator, string spellUUID, Vector position)
        {
            if (activator.GetLocalInt(spellUUID) == (int)SpellStatusType.Completed)
            {
                return;
            }

            Vector currentPosition = activator.Position;

            if (currentPosition.X != position.X ||
                currentPosition.Y != position.Y ||
                currentPosition.Z != position.Z)
            {
                var effect = activator.Effects.SingleOrDefault(x => _.GetEffectTag(x) == "ACTIVATION_VFX");
                if (effect != null)
                {
                    _.RemoveEffect(activator, effect);
                }

                NWNXPlayer.StopGuiTimingBar(activator, "", -1);
                activator.IsBusy = false;
                activator.SetLocalInt(spellUUID, (int)SpellStatusType.Interrupted);
                activator.SendMessage("Your ability has been interrupted.");
                return;
            }

            _.DelayCommand(0.5f, () => { CheckForSpellInterruption(activator, spellUUID, position); });
        }
Exemplo n.º 6
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            _customEffect.RemovePCCustomEffect(target.Object, CustomEffectType.Poison);

            foreach (Effect effect in target.Effects)
            {
                if (_.GetIsEffectValid(effect) == TRUE)
                {
                    int effectType = _.GetEffectType(effect);
                    if (effectType == EFFECT_TYPE_POISON || effectType == EFFECT_TYPE_DISEASE)
                    {
                        _.RemoveEffect(target.Object, effect);
                    }
                }
            }

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

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

            if (target.IsPlayer)
            {
                int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank);
                _skill.GiveSkillXP(user.Object, SkillType.Medicine, xp);
            }
        }
Exemplo n.º 7
0
        public void Main()
        {
            NWCreature looter = _.GetLastDisturbed();
            NWItem     item   = _.GetInventoryDisturbItem();
            int        type   = _.GetInventoryDisturbType();

            looter.AssignCommand(() =>
            {
                _.ActionPlayAnimation(_.ANIMATION_LOOPING_GET_LOW, 1.0f, 1.0f);
            });

            if (type == _.INVENTORY_DISTURB_TYPE_ADDED)
            {
                ItemService.ReturnItem(looter, item);
                looter.SendMessage("You cannot place items inside of corpses.");
            }
            else if (type == _.INVENTORY_DISTURB_TYPE_REMOVED)
            {
                NWItem copy = item.GetLocalObject("CORPSE_ITEM_COPY");

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

                item.DeleteLocalObject("CORPSE_ITEM_COPY");
            }
        }
Exemplo n.º 8
0
        public static void ApplyStance(NWCreature creature, CustomEffectType customEffect, PerkType perkType, int effectiveLevel, string data)
        {
            // Can't process NPC stances at the moment. Need to do some more refactoring before this is possible.
            // todo: handle NPC stances.
            if (!creature.IsPlayer)
            {
                return;
            }

            var pcStanceEffect = DataService.PCCustomEffect.GetByPlayerStanceOrDefault(creature.GlobalID);
            int customEffectID = (int)customEffect;

            // Player selected to cancel their stance. Cancel it and end.
            if (pcStanceEffect != null && pcStanceEffect.CustomEffectID == customEffectID && pcStanceEffect.EffectiveLevel == effectiveLevel)
            {
                RemoveStance(creature, pcStanceEffect);
                return;
            }
            // Otherwise remove existing stance
            else if (pcStanceEffect != null)
            {
                RemoveStance(creature, pcStanceEffect, false);
            }

            // Player selected to switch stances
            pcStanceEffect = new PCCustomEffect
            {
                PlayerID          = creature.GlobalID,
                Ticks             = -1,
                CustomEffectID    = customEffectID,
                CasterNWNObjectID = _.ObjectToString(creature),
                EffectiveLevel    = effectiveLevel,
                StancePerkID      = (int)perkType
            };
            DataService.SubmitDataChange(pcStanceEffect, DatabaseActionType.Insert);
            ICustomEffectHandler handler = GetCustomEffectHandler(customEffect);

            if (string.IsNullOrWhiteSpace(data))
            {
                data = handler.Apply(creature, creature, effectiveLevel);
            }

            if (!string.IsNullOrWhiteSpace(handler.StartMessage))
            {
                creature.SendMessage(handler.StartMessage);
            }

            if (string.IsNullOrWhiteSpace(data))
            {
                data = string.Empty;
            }
            pcStanceEffect.Data = data;
            DataService.SubmitDataChange(pcStanceEffect, DatabaseActionType.Update);

            // Was already queued for removal, but got cast again. Take it out of the list to be removed.
            if (AppCache.PCEffectsForRemoval.Contains(pcStanceEffect.ID))
            {
                AppCache.PCEffectsForRemoval.Remove(pcStanceEffect.ID);
            }
        }
Exemplo n.º 9
0
        public bool Run(params object[] args)
        {
            NWCreature user = (_.GetLastUsedBy());

            user.SendMessage("Use a scanner to analyze this object's resources. Use a harvester to retrieve resources from it.");
            return(true);
        }
Exemplo n.º 10
0
        public static bool RemoveStance(NWCreature creature, PCCustomEffect stanceEffect = null, bool sendMessage = true)
        {
            // Can't process NPC stances at the moment. Need to do some more refactoring before this is possible.
            // todo: handle NPC stances.
            if (!creature.IsPlayer)
            {
                return(false);
            }

            if (stanceEffect == null)
            {
                stanceEffect = DataService.PCCustomEffect.GetByPlayerStanceOrDefault(creature.GlobalID);
            }
            if (stanceEffect == null)
            {
                return(false);
            }

            if (sendMessage)
            {
                creature.SendMessage("You return to your normal stance.");
            }

            int    effectiveLevel = stanceEffect.EffectiveLevel;
            string data           = stanceEffect.Data;

            DataService.SubmitDataChange(stanceEffect, DatabaseActionType.Delete);
            ICustomEffectHandler handler = GetCustomEffectHandler(stanceEffect.CustomEffectID);

            handler?.WearOff(creature, creature, effectiveLevel, data);

            return(true);
        }
Exemplo n.º 11
0
        public void Main()
        {
            NWCreature looter = _.GetLastDisturbed();
            NWItem     item   = _.GetInventoryDisturbItem();
            var        type   = _.GetInventoryDisturbType();

            looter.AssignCommand(() =>
            {
                _.ActionPlayAnimation(Animation.LoopingGetLow, 1.0f, 1.0f);
            });

            if (type == DisturbType.Added)
            {
                ItemService.ReturnItem(looter, item);
                looter.SendMessage("You cannot place items inside of corpses.");
            }
            else if (type == DisturbType.Removed)
            {
                NWItem copy = item.GetLocalObject("CORPSE_ITEM_COPY");

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

                item.DeleteLocalObject("CORPSE_ITEM_COPY");
            }
        }
Exemplo n.º 12
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            target.RemoveEffect(EFFECT_TYPE_REGENERATE);
            PCSkill skill             = _skill.GetPCSkill((NWPlayer)user, SkillType.FirstAid);
            int     luck              = _perk.GetPCPerkLevel((NWPlayer)user, PerkType.Lucky);
            int     perkDurationBonus = _perk.GetPCPerkLevel((NWPlayer)user, PerkType.HealingKitExpert) * 6 + (luck * 2);
            float   duration          = 30.0f + (skill.Rank * 0.4f) + perkDurationBonus;
            int     restoreAmount     = 1 + item.GetLocalInt("HEALING_BONUS");

            int perkBlastBonus = _perk.GetPCPerkLevel((NWPlayer)user, PerkType.ImmediateImprovement);

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

            Effect regeneration = _.EffectRegenerate(restoreAmount, 6.0f);

            _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, regeneration, target.Object, duration);
            user.SendMessage("You successfully treat " + target.Name + "'s wounds.");

            int xp = (int)_skill.CalculateSkillAdjustedXP(100, item.RecommendedLevel, skill.Rank);

            _skill.GiveSkillXP((NWPlayer)user, SkillType.FirstAid, xp);
        }
Exemplo n.º 13
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);
            }
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        private static void OnAreaEnter()
        {
            NWArea area = _.OBJECT_SELF;
            string bonuses = GetAreaAtmosphereBonusText(area);

            if (string.IsNullOrWhiteSpace(bonuses)) return;
            NWCreature entering = _.GetEnteringObject();

            entering.SendMessage(bonuses);
        }
Exemplo n.º 16
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            float length;
            int   ab;
            int   chance;

            switch (perkLevel)
            {
            case 1:
                length = 12.0f;
                ab     = 1;
                chance = 10;
                break;

            case 2:
                length = 12.0f;
                ab     = 1;
                chance = 20;
                break;

            case 3:
                length = 12.0f;
                ab     = 2;
                chance = 20;
                break;

            case 4:
                length = 12.0f;
                ab     = 2;
                chance = 30;
                break;

            case 5:
                length = 12.0f;
                ab     = 3;
                chance = 30;
                break;

            default:
                return;
            }

            if (creature.IsPlayer)
            {
                var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(creature.Object);
                int luck           = PerkService.GetCreaturePerkLevel(creature, PerkType.Lucky) + effectiveStats.Luck;
                chance += luck;
            }

            if (RandomService.Random(100) + 1 <= chance)
            {
                _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, _.EffectAttackIncrease(ab), creature.Object, length);
                creature.SendMessage(ColorTokenService.Combat("You perform a defensive maneuver."));
            }
        }
Exemplo n.º 17
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            float duration = 0.0f;

            switch (spellTier)
            {
            case 1:
                duration = 6f;
                break;

            case 2:
                duration = 12f;
                break;

            case 3:
                duration = 18f;
                break;

            case 4:
                duration = 24f;
                break;
            }

            var result = CombatService.CalculateAbilityResistance(creature, target.Object, SkillType.ForceAlter, ForceBalanceType.Universal);


            // Resisted - Only apply slow for six seconds
            if (result.IsResisted)
            {
                _.ApplyEffectToObject(DurationType.Temporary, _.EffectSlow(), target, 6.0f);
            }

            // Not resisted - Apply knockdown for the specified duration
            else
            {
                // Check lucky chance.
                int luck = PerkService.GetCreaturePerkLevel(creature, PerkType.Lucky);
                if (RandomService.D100(1) <= luck)
                {
                    duration *= 2;
                    creature.SendMessage("Lucky Force Push!");
                }

                _.ApplyEffectToObject(DurationType.Temporary, AbilityService.EffectKnockdown(target, 3.0f), target, 3.0f);
                _.ApplyEffectToObject(DurationType.Temporary, _.EffectSlow(), target, duration);
            }

            if (creature.IsPlayer)
            {
                SkillService.RegisterPCToAllCombatTargetsForSkill(creature.Object, SkillType.ForceAlter, target.Object);
            }

            _.ApplyEffectToObject(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Com_Blood_Spark_Small), target);
        }
Exemplo n.º 18
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            _customEffect.RemovePCCustomEffect((NWPlayer)target, CustomEffectType.Bleeding);
            _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(2), target.Object);
            user.SendMessage("You finish bandaging " + target.Name + "'s wounds.");

            PCSkill skill = _skill.GetPCSkill((NWPlayer)user, SkillType.FirstAid);
            int     xp    = (int)_skill.CalculateSkillAdjustedXP(100, item.RecommendedLevel, skill.Rank);

            _skill.GiveSkillXP((NWPlayer)user, SkillType.FirstAid, xp);
        }
Exemplo n.º 19
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);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Sends a message to all nearby creatures within 10 meters.
        /// </summary>
        /// <param name="sender">The sender of the message. Used when determining distance.</param>
        /// <param name="message">The message to send to all nearby creatures.</param>
        private static void SendAOEMessage(NWCreature sender, string message)
        {
            const float MaxDistance = 10.0f;
            int         nth         = 1;
            NWCreature  nearby      = _.GetNearestCreature(CreatureType.IsAlive, 1, sender, nth);

            while (nearby.IsValid && GetDistanceBetween(sender, nearby) <= MaxDistance)
            {
                nearby.SendMessage(message);
                nth++;
                nearby = _.GetNearestCreature(CreatureType.IsAlive, 1, sender, nth);
            }
        }
Exemplo n.º 21
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            if (target.ObjectType != ObjectType.Creature)
            {
                user.SendMessage("You may only use stim packs on creatures!");
                return;
            }

            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);
        }
Exemplo n.º 22
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            float duration = 0.0f;

            switch (spellTier)
            {
                case 1:
                    duration = 6f;
                    break;
                case 2:
                    duration = 12f;
                    break;
                case 3:
                    duration = 18f;
                    break;
                case 4:
                    duration = 24f;
                    break;
            }

            var result = CombatService.CalculateAbilityResistance(creature, target.Object, SkillType.ForceAlter, ForceBalanceType.Universal);


            // Resisted - Only apply slow for six seconds
            if (result.IsResisted)
            {
                _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, _.EffectSlow(), target, 6.0f);
            }

            // Not resisted - Apply knockdown for the specified duration
            else
            {
                // Check lucky chance.
                int luck = PerkService.GetCreaturePerkLevel(creature, PerkType.Lucky);
                if (RandomService.D100(1) <= luck)
                {
                    duration *= 2;
                    creature.SendMessage("Lucky Force Push!");
                }

                _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, _.EffectKnockdown(), target, duration);
            }

            if (creature.IsPlayer)
            {
                SkillService.RegisterPCToAllCombatTargetsForSkill(creature.Object, SkillType.ForceAlter, target.Object);
            }
            
            _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectVisualEffect(_.VFX_COM_BLOOD_SPARK_SMALL), target);
        }
Exemplo n.º 23
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            int lootTableID = GetLootTable(targetLocation);

            if (lootTableID <= 0)
            {
                return;
            }

            NWArea area  = _.GetAreaFromLocation(targetLocation);
            var    items = DataService.LootTableItem.GetAllByLootTableID(lootTableID)
                           .OrderByDescending(o => o.Weight);
            string sector     = BaseService.GetSectorOfLocation(targetLocation);
            string sectorName = "Unknown";

            switch (sector)
            {
            case "NW": sectorName = "Northwest"; break;

            case "NE": sectorName = "Northeast"; break;

            case "SW": sectorName = "Southwest"; break;

            case "SE": sectorName = "Southeast"; break;
            }

            user.SendMessage(area.Name + "(" + sectorName + ")");
            user.SendMessage("Scanning results: ");

            foreach (var lti in items)
            {
                string name = ItemService.GetNameByResref(lti.Resref);
                user.SendMessage(name + " [Density: " + lti.Weight + "]");
            }

            DurabilityService.RunItemDecay(user.Object, item, RandomService.RandomFloat(0.02f, 0.08f));
        }
Exemplo n.º 24
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWArea area            = user.Area;
            bool   farmingDisabled = area.GetLocalInt("FARMING_DISABLED") == 1;

            if (farmingDisabled)
            {
                user.SendMessage("You cannot dig a hole in this area.");
                return;
            }

            user.SetLocalObject("SHOVEL_ITEM", item.Object);
            user.SetLocalLocation("SHOVEL_TARGET_LOCATION", targetLocation);
            user.SetLocalObject("SHOVEL_TARGET_OBJECT", target.Object);
            user.ClearAllActions();
            _dialog.StartConversation(user, user, "Shovel");
        }
Exemplo n.º 25
0
        private void RunEffect(NWCreature creature, NWObject target)
        {
            var concentrationEffect = AbilityService.GetActiveConcentrationEffect(target.Object);

            if (concentrationEffect.Type == PerkType.MindShield)
            {
                creature.SendMessage("Your target is immune to tranquilization effects.");
                return;
            }

            AbilityResistanceResult result = CombatService.CalculateAbilityResistance(creature, target.Object, SkillType.ForceAlter, ForceBalanceType.Dark);

            // Tranquilization effect - Daze target(s). Occurs on succeeding the DC check.
            Effect successEffect = EffectDazed();

            successEffect = EffectLinkEffects(successEffect, EffectVisualEffect(VisualEffect.Vfx_Dur_Iounstone_Blue));
            successEffect = TagEffect(successEffect, "TRANQUILIZER_EFFECT");

            // AC & AB decrease effect - Occurs on failing the DC check.
            Effect failureEffect = EffectLinkEffects(EffectAttackDecrease(5), EffectACDecrease(5));



            if (!result.IsResisted)
            {
                creature.AssignCommand(() =>
                {
                    ApplyEffectToObject(DurationType.Temporary, successEffect, target, 6.1f);
                });
            }
            else
            {
                creature.AssignCommand(() =>
                {
                    ApplyEffectToObject(DurationType.Temporary, failureEffect, target, 6.1f);
                });
            }

            if (creature.IsPlayer)
            {
                SkillService.RegisterPCToNPCForSkill(creature.Object, target, SkillType.ForceAlter);
            }

            EnmityService.AdjustEnmity(target.Object, creature, 1);
        }
Exemplo n.º 26
0
        private void ApplyNPCEffect(NWCreature caster, NWCreature target, int customEffectID, int ticks, int effectiveLevel, string data)
        {
            Data.Entity.CustomEffect effectEntity = _data.Single <Data.Entity.CustomEffect>(x => x.ID == customEffectID);
            // Look for existing effect.
            var spellModel = _cache.NPCEffects.SingleOrDefault(x => x.Key.Caster.Equals(caster) &&
                                                               x.Key.CustomEffectID == customEffectID &&
                                                               x.Key.Target.Equals(target)).Key;

            if (spellModel == null)
            {
                spellModel = new CasterSpellVO
                {
                    Caster         = caster,
                    CustomEffectID = customEffectID,
                    EffectName     = effectEntity.Name,
                    Target         = target,
                    EffectiveLevel = effectiveLevel
                };

                _cache.NPCEffects.Add(spellModel, 0);
            }

            if (spellModel.EffectiveLevel > effectiveLevel)
            {
                caster.SendMessage("A more powerful effect already exists on your target.");
                return;
            }

            App.ResolveByInterface <ICustomEffect>("CustomEffect." + effectEntity.ScriptHandler, handler =>
            {
                if (string.IsNullOrWhiteSpace(data))
                {
                    data = handler?.Apply(caster, target, effectiveLevel);
                }
                if (string.IsNullOrWhiteSpace(data))
                {
                    data = string.Empty;
                }
                spellModel.Data = data;

                _cache.NPCEffects[spellModel] = ticks;
            });
        }
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            int chance = perkLevel * 25;

            // Failed to interrupt.
            if (RandomService.D100(1) > chance)
            {
                creature.SendMessage("You fail to interrupt your target's concentration.");
                return;
            }

            NWCreature targetCreature = target.Object;
            var        effect         = AbilityService.GetActiveConcentrationEffect(targetCreature);

            if (effect.Type != PerkType.Unknown)
            {
                targetCreature.SendMessage("Your concentration effect has been interrupted by " + creature.Name + ".");
                AbilityService.EndConcentrationEffect(target.Object);
            }
        }
Exemplo n.º 28
0
        private static void ApplyNPCEffect(NWCreature caster, NWCreature target, int customEffectID, int ticks, int effectiveLevel, string data)
        {
            Data.Entity.CustomEffect effectEntity = DataService.CustomEffect.GetByID(customEffectID);
            // Look for existing effect.
            var spellModel = AppCache.NPCEffects.SingleOrDefault(x => x.Key.Caster.Equals(caster) &&
                                                                 x.Key.CustomEffectID == customEffectID &&
                                                                 x.Key.Target.Equals(target)).Key;

            if (spellModel == null)
            {
                spellModel = new CasterSpellVO
                {
                    Caster         = caster,
                    CustomEffectID = customEffectID,
                    EffectName     = effectEntity.Name,
                    Target         = target,
                    EffectiveLevel = effectiveLevel
                };

                AppCache.NPCEffects.Add(spellModel, 0);
            }

            if (spellModel.EffectiveLevel > effectiveLevel)
            {
                caster.SendMessage("A more powerful effect already exists on your target.");
                return;
            }
            ICustomEffectHandler handler = GetCustomEffectHandler(customEffectID);

            if (string.IsNullOrWhiteSpace(data))
            {
                data = handler?.Apply(caster, target, effectiveLevel);
            }
            if (string.IsNullOrWhiteSpace(data))
            {
                data = string.Empty;
            }
            spellModel.Data = data;

            AppCache.NPCEffects[spellModel] = ticks;
        }
Exemplo n.º 29
0
 public string Apply(NWCreature oCaster, NWObject oTarget, int effectiveLevel)
 {
     oCaster.SendMessage("An ice cell lands on your target.");
     return(null);
 }
Exemplo n.º 30
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);
        }