Exemplo n.º 1
0
        protected void AttackHighestEnmity(NWCreature self)
        {
            var enmityTable = EnmityService.GetEnmityTable(self);
            var target      = enmityTable.Values
                              .OrderByDescending(o => o.TotalAmount)
                              .FirstOrDefault(x => x.TargetObject.IsValid &&
                                              x.TargetObject.Area.Equals(self.Area));
            var currentAttackTarget = GetAttackTarget(self.Object);

            // We have a target and it's not who we're currently attacking. Switch to attacking them.
            if (target != null && currentAttackTarget != target.TargetObject.Object)
            {
                self.AssignCommand(() =>
                {
                    ClearAllActions();
                    ActionAttack(target.TargetObject.Object);
                });
            }
            // We don't have a valid target but we're still attacking someone. We shouldn't be attacking them anymore. Clear all actions.
            else if (target == null && GetCurrentAction(self) == ActionType.AttackObject)
            {
                self.AssignCommand(() =>
                {
                    ClearAllActions();
                });
            }
        }
Exemplo n.º 2
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            int adjust = perkLevel * 10;

            _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE), target, 3.0f);
            EnmityService.AdjustPercentEnmityOnAllTaggedCreatures(creature, -adjust, -adjust);
        }
Exemplo n.º 3
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            int adjust = perkLevel * 10;

            _.ApplyEffectToObject(DurationType.Temporary, _.EffectVisualEffect(VisualEffect.Dur_Ghostly_Visage), target, 3.0f);
            EnmityService.AdjustPercentEnmityOnAllTaggedCreatures(creature, -adjust, -adjust);
        }
Exemplo n.º 4
0
        protected void CleanUpEnmity(NWCreature self)
        {
            var table = EnmityService.GetEnmityTable(self);

            if (table.Count <= 0)
            {
                return;
            }

            for (int x = table.Count - 1; x >= 0; x--)
            {
                var enmity = table.ElementAt(x);
                var val    = enmity.Value;
                var target = val.TargetObject;

                // Remove invalid objects from the enmity table
                if (target == null ||
                    !target.IsValid ||
                    target.Area.Resref != self.Area.Resref ||
                    target.CurrentHP <= -11 ||
                    target.IsDead)
                {
                    EnmityService.GetEnmityTable(self).Remove(enmity.Key);
                    continue;
                }

                AdjustReputation(target.Object, self.Object, -100);

                // Reduce volatile enmity every tick
                EnmityService.GetEnmityTable(self)[target.GlobalID].VolatileAmount--;
            }
        }
Exemplo n.º 5
0
        private static void Link(NWCreature self, NWCreature nearby)
        {
            float linkRange = self.GetLocalFloat("LINK_RANGE");

            if (linkRange <= 0.0f)
            {
                linkRange = 12.0f;
            }

            // Check distance. If too far away stop processing.
            if (_.GetDistanceBetween(self, nearby) > linkRange)
            {
                return;
            }

            // Is the nearby object an NPC?
            if (!nearby.IsNPC)
            {
                return;
            }

            // Is the nearby creature dead?
            if (nearby.IsDead)
            {
                return;
            }

            // Is the nearby creature an enemy?
            if (_.GetIsEnemy(nearby, self) == TRUE)
            {
                return;
            }

            // Does the calling creature have the same racial type as the nearby creature?
            if (self.RacialType != nearby.RacialType)
            {
                return;
            }

            // Does the nearby creature have anything on its enmity table?
            var nearbyEnmityTable = EnmityService.GetEnmityTable(nearby).OrderByDescending(x => x.Value).FirstOrDefault();

            if (nearbyEnmityTable.Value == null)
            {
                return;
            }

            var target = nearbyEnmityTable.Value.TargetObject;

            // Is the target dead?
            if (target.IsDead)
            {
                return;
            }

            // Add the target of the nearby creature to this creature's enmity table.
            EnmityService.AdjustEnmity(self, target, 0, 1);
        }
Exemplo n.º 6
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            NWCreature npc = (target.Object);
            Effect     vfx = _.EffectVisualEffect(_.VFX_IMP_CHARM);

            _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, vfx, target.Object);

            creature.AssignCommand(() =>
            {
                _.ActionPlayAnimation(_.ANIMATION_FIREFORGET_TAUNT, 1f, 1f);
            });

            EnmityService.AdjustEnmity(npc, creature, 120);
        }
Exemplo n.º 7
0
        public void OnConcentrationTick(NWCreature creature, NWObject target, int perkLevel, int tick)
        {
            int abamount;
            int acamount;

            // Handle effects for differing spellTier values
            switch (perkLevel)
            {
            case 1:
                abamount = 3;
                acamount = 0;
                break;

            case 2:
                abamount = 5;
                acamount = 2;
                break;

            case 3:
                abamount = 5;
                acamount = 4;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(perkLevel));
            }

            var effect = _.EffectACIncrease(acamount);

            effect = _.EffectLinkEffects(effect, _.EffectAttackIncrease(abamount));
            effect = _.TagEffect(effect, "EFFECT_FORCE_INSIGHT");

            // Remove any existing force insight effects.
            foreach (var existing in creature.Effects.Where(x => _.GetEffectTag(effect) == "EFFECT_FORCE_INSIGHT"))
            {
                _.RemoveEffect(creature, existing);
            }

            // Apply the new effect.
            _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, effect, creature, 6.1f);
            _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectVisualEffect(_.VFX_DUR_MAGIC_RESISTANCE), target);

            // Register players to all combat targets for Force Sense.
            if (creature.IsPlayer)
            {
                SkillService.RegisterPCToAllCombatTargetsForSkill(creature.Object, SkillType.ForceSense, null);
            }

            EnmityService.AdjustEnmityOnAllTaggedCreatures(creature, 4);
        }
Exemplo n.º 8
0
        public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
        {
            NWCreature npc = (target.Object);
            var        vfx = _.EffectVisualEffect(VisualEffect.Vfx_Imp_Charm);

            _.ApplyEffectToObject(DurationType.Instant, vfx, target.Object);

            creature.AssignCommand(() =>
            {
                _.ActionPlayAnimation(Animation.FireForgetTaunt, 1f, 1f);
            });

            EnmityService.AdjustEnmity(npc, creature, 120);
        }
Exemplo n.º 9
0
        private static void RandomWalk(NWCreature self)
        {
            if (self.IsInCombat || !EnmityService.IsEnmityTableEmpty(self))
            {
                return;
            }

            if (_.GetCurrentAction(self.Object) == _.ACTION_INVALID &&
                _.IsInConversation(self.Object) == _.FALSE &&
                _.GetCurrentAction(self.Object) != _.ACTION_RANDOMWALK &&
                RandomService.Random(100) <= 25)
            {
                self.AssignCommand(_.ActionRandomWalk);
            }
        }
Exemplo n.º 10
0
        private static void RandomWalk(NWCreature self)
        {
            if (self.IsInCombat || !EnmityService.IsEnmityTableEmpty(self))
            {
                return;
            }

            if (_.GetCurrentAction(self.Object) == ActionType.Invalid &&
                _.IsInConversation(self.Object) == false &&
                _.GetCurrentAction(self.Object) != ActionType.RandomWalk &&
                _.GetCurrentAction(self.Object) != ActionType.MoveToPoint &&
                RandomService.Random(100) <= 25)
            {
                self.AssignCommand(_.ActionRandomWalk);
            }
        }
Exemplo n.º 11
0
        private void ProcessNearbyCreatures(NWCreature self)
        {
            var flags = GetAIFlags(self);

            // Does this creature have one of the supported flags? If not, exit early.
            if ((flags & AIFlags.AggroNearby) == 0 && (flags & AIFlags.Link) == 0)
            {
                return;
            }

            // Aggro & Link Flags - Only process if not currently aggro'd to someone else.
            if ((flags & AIFlags.AggroNearby) != 0 || (flags & AIFlags.Link) != 0)
            {
                if (!EnmityService.IsEnmityTableEmpty(self))
                {
                    return;
                }
            }

            // Cycle through each nearby creature. Process their flags individually if necessary.
            int        nth      = 1;
            NWCreature creature = _.GetNearestObject(OBJECT_TYPE_CREATURE, self, nth);

            while (creature.IsValid)
            {
                float aggroRange = GetAggroRange(creature);
                float linkRange  = GetLinkRange(creature);

                float distance = _.GetDistanceBetween(creature, self);
                if (distance > aggroRange && distance > linkRange)
                {
                    break;
                }

                if ((flags & AIFlags.AggroNearby) != 0)
                {
                    AggroTargetInRange(self, creature);
                }

                if ((flags & AIFlags.Link) != 0)
                {
                    Link(self, creature);
                }
                nth++;
                creature = _.GetNearestObject(OBJECT_TYPE_CREATURE, self, nth);
            }
        }
Exemplo n.º 12
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.º 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(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);
        }
Exemplo n.º 14
0
        protected void AttackHighestEnmity(NWCreature self)
        {
            var enmityTable = EnmityService.GetEnmityTable(self);
            var target      = enmityTable.Values
                              .OrderByDescending(o => o.TotalAmount)
                              .FirstOrDefault(x => x.TargetObject.IsValid &&
                                              x.TargetObject.Area.Equals(self.Area));

            if (target != null)
            {
                self.AssignCommand(() =>
                {
                    if (GetAttackTarget(self.Object) != target.TargetObject.Object)
                    {
                        ClearAllActions();
                        ActionAttack(target.TargetObject.Object);
                    }
                });
            }
        }
Exemplo n.º 15
0
        private void ForceAttackHighestEnmity(NWCreature self)
        {
            if (self.GetLocalInt("CASTING") == 1)
            {
                return;
            }
            var enmityTable = EnmityService.GetEnmityTable(self);
            var target      = enmityTable.Values
                              .OrderByDescending(o => o.TotalAmount)
                              .FirstOrDefault(x => x.TargetObject.IsValid &&
                                              x.TargetObject.Area.Equals(self.Area));

            if (target == null)
            {
                return;
            }
            self.AssignCommand(() =>
            {
                bool bDone = false;

                // See which force feats we have, and pick one to use.
                if (_.GetHasFeat((int)CustomFeatType.ForceLightning, self) == 1)
                {
                    _.ClearAllActions();
                    bDone = UseFeat((int)CustomFeatType.ForceLightning, "ForceLightning", self, target.TargetObject);
                }

                if (!bDone && _.GetHasFeat((int)CustomFeatType.DrainLife, self) == 1)
                {
                    _.ClearAllActions();
                    bDone = UseFeat((int)CustomFeatType.DrainLife, "DrainLife", self, target.TargetObject);
                }

                if (!bDone)
                {
                    // No abilities available right now, run away!
                    _.ActionMoveAwayFromObject(target.TargetObject, 1);
                }
            });
        }
Exemplo n.º 16
0
        protected void AggroTargetInRange(NWCreature self, NWCreature nearby)
        {
            float aggroRange = GetAggroRange(self);

            // Check distance
            if (GetDistanceBetween(self, nearby) > aggroRange)
            {
                return;
            }

            // Is creature dead?
            if (nearby.IsDead)
            {
                return;
            }

            // Does the nearby creature have line of sight to the creature being attacked?
            if (LineOfSightObject(self, nearby) == FALSE)
            {
                return;
            }

            // Is the nearby creature not an enemy?
            if (GetIsEnemy(nearby, self.Object) == FALSE)
            {
                return;
            }

            // Does the nearby creature have sanctuary?
            if (nearby.HasAnyEffect(EFFECT_TYPE_SANCTUARY))
            {
                return;
            }

            // Success. Increase enmity on the nearby target.
            EnmityService.AdjustEnmity(self, nearby, 0, 1);
        }
Exemplo n.º 17
0
        private void ReturnToSpawnPoint(NWCreature self)
        {
            if (self.IsInCombat || !EnmityService.IsEnmityTableEmpty(self))
            {
                return;
            }

            if (_.GetCurrentAction(self.Object) == _.ACTION_INVALID &&
                _.IsInConversation(self.Object) == _.FALSE &&
                _.GetCurrentAction(self.Object) != _.ACTION_RANDOMWALK)
            {
                var      flags         = GetAIFlags(self);
                Location spawnLocation = self.GetLocalLocation("AI_SPAWN_POINT");
                // If creature also has the RandomWalk flag, only send them back to the spawn point
                // if they go outside the range (15 meters)
                if ((flags & AIFlags.RandomWalk) != 0 &&
                    _.GetDistanceBetweenLocations(self.Location, spawnLocation) <= 15.0f)
                {
                    return;
                }

                self.AssignCommand(() => _.ActionMoveToLocation(spawnLocation));
            }
        }
Exemplo n.º 18
0
 public virtual void OnDamaged(NWCreature self)
 {
     EnmityService.OnNPCDamaged();
 }
Exemplo n.º 19
0
 public virtual void OnPhysicalAttacked(NWCreature self)
 {
     EnmityService.OnNPCPhysicallyAttacked();
 }