Exemple #1
0
        private void Handle()
        {
            if (to != null)
            {
                ushort seed = (ushort)Program.Randomizer.Next(0, 100);                 //we use one seed & base damage on it

                ushort damage = (ushort)Program.Randomizer.Next(0, seed);
                bool   crit   = seed >= 80;
                stance = (byte)(Program.Randomizer.Next(0, 3));
                to.Damage(from, damage);
                Handler9.SendAttackAnimation(from, toID, attackSpeed, stance);
                Handler9.SendAttackDamage(from, toID, damage, crit, GetHPLeft(), to.UpdateCounter);

                if (to.IsDead)
                {
                    if (to is Mob && from is ZoneCharacter)
                    {
                        uint exp = (to as Mob).InfoServer.MonExp;
                        (from as ZoneCharacter).GiveExp(exp, toID);
                    }
                    Handler9.SendDieAnimation(from, toID);
                    State = AnimationState.Ended;
                    to    = null;
                }
                else
                {
                    SetNewSequenceTime(attackSpeed);
                }
            }
        }
Exemple #2
0
        public void Update(DateTime now)
        {
            if (this.State == AnimationState.Ended)
            {
                return;
            }
            if (this.attacker == null || this.attacker.IsDead)
            {
                this.State = AnimationState.Ended;
                return;
            }
            if (!IsAoE && (this.victim == null || this.victim.IsDead))
            {
                this.State = AnimationState.Ended;
                return;
            }
            if (this.nextAction > now)
            {
                return;
            }

            if (IsSkill)
            {
                if (IsAoE)
                {
                    if (this.State == AnimationState.AoEShow)
                    {
                        Handler9.SendSkillPosition(attacker, animationID, skillid, x, y);
                        Handler9.SendSkillAnimationForPlayer(attacker, skillid, animationID);
                        this.nextAction = Program.CurrentTime.AddMilliseconds(skillInfo.SkillAniTime);
                        this.State      = AnimationState.AoEDo;
                    }
                    else if (this.State == AnimationState.AoEDo)
                    {
                        // Lets create an AoE skill @ X Y
                        List <SkillVictim> victims = new List <SkillVictim>();
                        var pos = new Vector2((int)x, (int)y);
                        // Find victims
                        foreach (var v in attacker.Map.GetObjectsBySectors(attacker.MapSector.SurroundingSectors))
                        {
                            if (attacker == v)
                            {
                                continue;
                            }
                            if (v is ZoneCharacter)
                            {
                                continue;
                            }
                            if (Vector2.Distance(v.Position, pos) > skillInfo.Range)
                            {
                                continue;
                            }
                            // Calculate dmg

                            uint dmg = (uint)Program.Randomizer.Next((int)minDamage, (int)maxDamage);
                            if (dmg > v.HP)
                            {
                                v.HP = 0;
                            }

                            if (!v.IsDead)
                            {
                                v.Attack(attacker);
                            }
                            else
                            {
                                if (v is Mob && attacker is ZoneCharacter)
                                {
                                    uint exp = (v as Mob).InfoServer.MonExp;
                                    (attacker as ZoneCharacter).GiveExp(exp, v.MapObjectID);
                                }
                            }

                            victims.Add(new SkillVictim(v.MapObjectID, dmg, v.HP, 0x01, 0x01, v.UpdateCounter));
                            if (victims.Count == skillInfo.MaxTargets)
                            {
                                break;
                            }
                        }

                        Handler9.SendSkill(attacker, animationID, victims);
                        foreach (var v in victims)
                        {
                            if (v.HPLeft == 0)
                            {
                                Handler9.SendDieAnimation(attacker, v.MapObjectID);
                            }
                        }

                        victims.Clear();
                        State = AnimationState.Ended;
                    }
                }
                else
                {
                    // Normal skill parsing
                    State = AnimationState.Ended;
                }
            }
            else
            {
                // Just attacking...
                if (victim == null || victim.IsDead)
                {
                    victim   = null;
                    attacker = null;
                    State    = AnimationState.Ended;
                }
                else
                {
                    // Calculate some damage to do
                    ushort dmg = (ushort)Program.Randomizer.Next((int)minDamage, (int)maxDamage);
                    if (dmg > victim.HP)
                    {
                        victim.HP = 0;
                    }
                    bool crit   = Program.Randomizer.Next() % 100 >= 80;
                    byte stance = (byte)(Program.Randomizer.Next(0, 3));
                    victim.Damage(attacker, dmg);
                    Handler9.SendAttackAnimation(attacker, victim.MapObjectID, attackspeed, stance);
                    Handler9.SendAttackDamage(attacker, victim.MapObjectID, dmg, crit, victim.HP, victim.UpdateCounter);

                    if (victim.IsDead)
                    {
                        if (victim is Mob && attacker is ZoneCharacter)
                        {
                            uint exp = (victim as Mob).InfoServer.MonExp;
                            (attacker as ZoneCharacter).GiveExp(exp, victim.MapObjectID);
                        }

                        Handler9.SendDieAnimation(attacker, victim.MapObjectID);
                        victim = null;
                        State  = AnimationState.Ended;
                    }
                    else
                    {
                        nextAction = now.AddMilliseconds(attackspeed);
                    }
                }
            }
        }