Example #1
0
        public void Attack(NetMsg.MsgAttackInfo info)
        {
            if (!play.GetMagicSystem().CheckAttackSpeed())
            {
                return;
            }
            BaseObject targetobj = play.GetGameMap().FindObjectForID(info.idTarget);
            if (targetobj == null)
            {
                return;
            }
            if (targetobj.IsDie()) return;
            if (targetobj.IsLock()) return; //被锁定了
            //与怪物的距离判断--
            if (Math.Abs(play.GetCurrentX() - targetobj.GetCurrentX()) > 3 &&
                Math.Abs(play.GetCurrentY() - targetobj.GetCurrentY()) > 3)
            {
                SetAutoAttackTarget(null);
                return;
            }
            SetAutoAttackTarget(targetobj);
            //触发被动技能
            if (PassiveMagic(info))
            {
                return;
            }
            uint injured = BattleSystem.AdjustDamage(play, targetobj);
            //经验--
            injured = BattleSystem.AdjustDamage(play, targetobj, true);
            NetMsg.MsgMonsterInjuredInfo injuredinfo = new NetMsg.MsgMonsterInjuredInfo();
            injuredinfo.roleid = play.GetTypeId();
            injuredinfo.role_x = play.GetCurrentX();
            injuredinfo.role_y = play.GetCurrentY();
            injuredinfo.injuredvalue = injured;
            injuredinfo.monsterid = targetobj.GetTypeId();
            injuredinfo.tag = 2;
            byte[] msg = injuredinfo.GetBuffer();
            // GetGameMap().BroadcastBuffer(this, msg);
            play.BroadcastBuffer(msg, true);
            targetobj.Injured(play, injured, info);

            play.CanPK(targetobj);
               // if (info.tag == 2) //普通攻击设置自动攻击对象
               // {
               //     targetObject = targetobj;
               // }
              //  lastattacktime = System.Environment.TickCount;
        }
Example #2
0
        //攻击
        public void Attack(NetMsg.MsgAttackInfo info)
        {
            if (!mAttackSpeed.ToNextTime())
            {
               return;
            }

            BaseObject targetobj = play.GetGameMap().FindObjectForID(info.idTarget);
            if (targetobj == null)
            {
                return;
            }
            if (mMonsterInfo == null) return;
            if (targetobj.IsDie()) return;
            if (targetobj.IsLock()) return; //被锁定了
            if (mInfo.bDie) return; //死亡 防作弊
            //与怪物的距离判断--反作弊
            if (Math.Abs(this.GetCurrentX() - targetobj.GetCurrentX()) > mMonsterInfo.range &&
                Math.Abs(this.GetCurrentY() - targetobj.GetCurrentY()) > mMonsterInfo.range)
            {
                return;
            }
            if (targetobj.type == OBJECTTYPE.PLAYER)
            {
                if (!play.CanPK(targetobj)) return;
            }
            if (targetobj.type == OBJECTTYPE.EUDEMON)
            {
                if (!play.CanPK((targetobj as EudemonObject).GetOwnerPlay())) { return; }
            }
            uint injured = 0;
            //经验--
            //战士幻兽使用近战攻击.法师幻兽使用魔法攻击
            switch (mMonsterInfo.eudemon_type)
            {
                case GameBase.Config.Define.EUDEMON_TYPE_WARRIOR:
                case GameBase.Config.Define.EUDEMON_TYPE_WARRIOR_RIG:
                    {
                        injured = BattleSystem.AdjustDamage(this, targetobj);
                        NetMsg.MsgMonsterInjuredInfo injuredinfo = new NetMsg.MsgMonsterInjuredInfo();
                        injuredinfo.roleid = this.GetTypeId();
                        injuredinfo.role_x = this.GetCurrentX();
                        injuredinfo.role_y = this.GetCurrentY();
                        injuredinfo.injuredvalue = injured;
                        injuredinfo.monsterid = targetobj.GetTypeId();
                        injuredinfo.tag = 2;
                        byte[] msg = injuredinfo.GetBuffer();
                        this.BrocatBuffer(msg);
                        break;
                    }
                case GameBase.Config.Define.EUDEMON_TYPE_MAGE:
                case GameBase.Config.Define.EUDEMON_TYPE_MAGE_RID:
                    {

                        injured = BattleSystem.AdjustDamage(this, targetobj,true);
                        if (injured == 0) injured = 1;
                        //NetMsg.MsgMonsterMagicInjuredInfo magicattack = new NetMsg.MsgMonsterMagicInjuredInfo();
                        //magicattack.time = System.Environment.TickCount;
                        //magicattack.roleid = this.GetTypeId();
                        //magicattack.role_x = this.GetCurrentX();
                        //magicattack.role_y = this.GetCurrentY();
                        //magicattack.monsterid = targetobj.GetTypeId();
                        //magicattack.tag = 21;
                        //magicattack.magicid = 1;
                        //magicattack.magiclv = 0;
                        //this.BrocatBuffer(magicattack.GetBuffer());

                        NetMsg.MsgGroupMagicAttackInfo magicattackex = new NetMsg.MsgGroupMagicAttackInfo();
                        //有轨迹的魔法--
                        magicattackex.SetSigleAttack(targetobj.GetTypeId());
                        magicattackex.nID = this.GetTypeId();
                        //magicattackex.nX = (short)info.usPosX;
                        //magicattackex.nY = (short)info.usPosY;

                        magicattackex.nMagicID = 5000;
                        magicattackex.nMagicLv = 0;
                        magicattackex.bDir = this.GetDir();
                        magicattackex.AddObject(targetobj.GetTypeId(), (int)injured);
                        this.BrocatBuffer(magicattackex.GetBuffer());
                        break;
                    }
            }

            targetobj.Injured(this, injured, info);
        }