Ejemplo n.º 1
0
 public void GetDead()
 {
     try
     {
         if (type)
         {
             if (main.Character.Information.PvP && sys.Character.Information.PvP)
             {
                 sys.Character.State.DeadType = 2;
             }
             else
             {
                 sys.Character.State.DeadType = 1;
             }
             sys.BuffAllClose();
             sys.Character.State.Die = true;
         }
         else
         {
             os.Die = true;
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
Ejemplo n.º 2
0
        public void AttackHim(int AttackType)
        {
            try
            {
                if (!Runing && Attacking && !bSleep)
                {
                    PlayerMgr sys = (PlayerMgr)GetTarget();

                    if (sys == null || Die || GetDie)
                    {
                        AttackStop();
                        return;
                    }
                    if (sys != null && !Spawned(sys.Character.Information.UniqueID))
                    {
                        AttackStop();
                        return;
                    }

                    if (!sys.Character.InGame)
                    {
                        AttackStop();
                        return;
                    }

                    byte NumberAttack = 1;

                    int  p_dmg = 0;
                    byte status = 0, crit = 1;

                    PacketWriter Writer = new PacketWriter();
                    Writer.Create(Client.OperationCode.SERVER_ACTION_DATA);
                    Writer.Byte(1);
                    Writer.Byte(2);
                    Writer.Byte(0x30);

                    Writer.DWord(AttackType);
                    Writer.DWord(UniqueID);

                    LastCasting = Ids.GetCastingID();

                    Writer.DWord(LastCasting);
                    Writer.DWord(sys.Character.Information.UniqueID);

                    Writer.Bool(true);
                    Writer.Byte(NumberAttack);
                    Writer.Byte(1);

                    Writer.DWord(sys.Character.Information.UniqueID);

                    for (byte n = 1; n <= NumberAttack; n++)
                    {
                        bool block = false;

                        if (sys.Character.Information.Item.sID != 0 && ObjData.Manager.ItemBase[sys.Character.Information.Item.sID].TypeID2 == 1)
                        {
                            if (Rnd.Next(25) < 10)
                            {
                                block = true;
                            }
                        }
                        if (!block)
                        {
                            status = 0;
                            crit   = 1;

                            p_dmg  = (int)Formule.gamedamage(ObjData.Manager.SkillBase[AttackType].MaxAttack, 0, sys.Character.Stat.phy_Absorb, sys.Character.Stat.PhyDef, 50, ObjData.Manager.SkillBase[AttackType].MagPer);
                            p_dmg += Rnd.Next(0, p_dmg.ToString().Length);
                            if (p_dmg <= 0)
                            {
                                p_dmg = 1;
                            }

                            if (Rnd.Next(20) > 15)
                            {
                                p_dmg *= 2;
                                crit   = 2;
                            }

                            if (sys.Character.Stat.Absorb_mp > 0)
                            {
                                int static_dmg = (p_dmg * (100 - (int)sys.Character.Stat.Absorb_mp)) / 100;
                                sys.Character.Stat.SecondMP -= static_dmg;
                                if (sys.Character.Stat.SecondMP < 0)
                                {
                                    sys.Character.Stat.SecondMP = 0;
                                }
                                sys.UpdateMp();
                                p_dmg = static_dmg;
                            }

                            sys.Character.Stat.SecondHp -= p_dmg;

                            if (sys.Character.Stat.SecondHp <= 0)
                            {
                                sys.BuffAllClose();
                                status = 128;
                                sys.Character.Stat.SecondHp  = 0;
                                sys.Character.State.Die      = true;
                                sys.Character.State.DeadType = 1;

                                _agro agro = GetAgroClass(sys.Character.Information.UniqueID);
                                if (agro != null)
                                {
                                    AgressiveDMG.Remove(agro);
                                }
                                DeleteTarget();
                                AttackStop();
                                CheckAgro();

                                if (sys.Character.Action.nAttack)
                                {
                                    sys.StopAttackTimer();
                                }
                                else if (sys.Character.Action.sAttack || sys.Character.Action.sCasting)
                                {
                                    sys.StopSkillTimer();
                                }
                            }

                            sys.UpdateHp();

                            Writer.Byte(status);
                            Writer.Byte(crit);
                            Writer.DWord(p_dmg);
                            Writer.Byte(0);
                            Writer.Word(0);
                        }
                        else
                        {
                            Writer.Byte(2);
                        }
                    }
                    Send(Writer.GetBytes());
                    //Game.Effect.EffectMain(sys, AttackType);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }