Example #1
0
        public void Update()
        {
            if (self.DistanceToActor(target) <= ai.GetCurrentCastRange(target) || self.Status.CastingSkill)
            {
                DateTime now = DateTime.Now;
                if (!self.Status.CastingSkill)
                {
                    if (now > self.Status.SkillCooldownEnd && self.BaseData.Skill.Count > 0)
                    {
                        if (DateTime.Now < nextTime)
                        {
                            return;
                        }

                        nextTime = DateTime.Now.AddMilliseconds(self.BaseData.CombatThinkPeriod);

                        self.Dir = self.DirectionFromTarget(target);
                        curSkill = ChooseSkill(target);
                        if (curSkill == null)
                        {
                            return;
                        }

                        SkillArg arg = new SkillArg()
                        {
                            Caster       = self,
                            Dir          = self.Dir,
                            Target       = (curSkill.BaseData.SkillType == SkillType.NoTarget || curSkill.BaseData.SkillType == SkillType.Self) ? self : target,
                            Skill        = curSkill,
                            SkillSession = (byte)Global.Random.Next(0, 255)
                        };
                        Skills.SkillManager.Instance.SkillCast(arg);
                    }
                }
            }
            else
            {
                Finish();
            }
        }
Example #2
0
 public void Update()
 {
     if (currentPath == null)
     {
         ReCalculatePath();
     }
     if (self.DistanceToPoint(x, y, z) > 30)
     {
         if (currentPath.Count > curPathIdx)
         {
             PathNode     node = currentPath[curPathIdx++];
             MoveArgument arg  = new MoveArgument()
             {
                 X = node.X,
                 Y = node.Y,
                 Z = map.HeightMapBuilder.GetZ((short)node.X, (short)node.Y, (short)node.Z)
             };
             if (arg.Z == 0)
             {
                 status = CommandStatus.Finished;
                 return;
             }
             arg.Dir         = self.DirectionFromTarget(node.X, node.Y);
             arg.Speed       = (ushort)((500 * ((float)500 / self.Speed)) * 2);
             arg.DashID      = 0;
             arg.DashUnknown = 0;
             arg.BNSMoveType = MoveType.Walk;
             map.MoveActor(self, arg);
         }
         else
         {
             status = CommandStatus.Finished;
         }
     }
     else
     {
         status = CommandStatus.Finished;
     }
 }