Exemple #1
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);
            }
        }
        public void reSpawn()
        {
            try
            {
                AgressiveDMG.Clear();
                HP        = ObjData.Manager.ObjectBase[ID].HP;
                Agresif   = oldAgresif;
                Attacking = false;
                Helpers.Functions.aRound(ref x, ref y, 2);
                OriginalX = x;
                OriginalY = y;
                List <PlayerMgr> Players = new List <PlayerMgr>();
                Players = GetRangePlayers(50);

                bool isSharePartyInRange = Players.Exists(
                    delegate(PlayerMgr s)
                {
                    bool retValue = false;

                    // player has exp/item share pt?
                    if (s.Character.Network.Party != null)
                    {
                        if (
                            s.Character.Network.Party.Type == (byte)PlayerMgr.PartyTypes.EXPSHARE ||
                            s.Character.Network.Party.Type == (byte)PlayerMgr.PartyTypes.EXPSHARE_NO_PERMISSION ||
                            s.Character.Network.Party.Type == (byte)PlayerMgr.PartyTypes.FULLSHARE ||
                            s.Character.Network.Party.Type == (byte)PlayerMgr.PartyTypes.FULLSHARE_NO_PERMISSION ||
                            s.Character.Network.Party.Type == (byte)PlayerMgr.PartyTypes.ITEMSHARE ||
                            s.Character.Network.Party.Type == (byte)PlayerMgr.PartyTypes.ITEMSHARE_NO_PERMISSION
                            )
                        {
                            // at least 2 players in range
                            bool isInRange = s.Character.Network.Party.Members.Exists(
                                delegate(int m)
                            {
                                // if me -> false
                                if (m == s.Character.Information.UniqueID)
                                {
                                    return(false);
                                }

                                PlayerMgr ptmate = Helpers.GetInformation.GetPlayer(m);

                                if (Players.Exists(sys => (sys.Character.Information.UniqueID == ptmate.Character.Information.UniqueID)))
                                {
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                                );
                            if (isInRange)
                            {
                                retValue = true;
                            }
                        }
                    }

                    return(retValue);
                }
                    );

                if (!isSharePartyInRange)
                {
                    Type = Helpers.Functions.RandomType(ObjData.Manager.ObjectBase[ID].Level, ref Kat, false, ref Agresif);
                }
                else
                {
                    Type = Helpers.Functions.RandomType(ObjData.Manager.ObjectBase[ID].Level, ref Kat, true, ref Agresif);
                }

                switch (Type)
                {
                case 1:
                    Agresif = 1;
                    HP     *= 2;
                    break;

                case 4:
                    HP     *= 20;
                    Agresif = 1;
                    break;

                case 5:
                    HP     *= 100;
                    Agresif = 1;
                    break;

                case 16:
                    HP *= 10;
                    break;

                case 17:
                    HP     *= 20;
                    Agresif = 1;
                    break;

                case 20:
                    HP     *= 210;
                    Agresif = 1;
                    break;
                }

                GetDie = false;
                Die    = false;
                Busy   = false;

                SpawnMe();
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }