protected override void ProcessAction_Injured(GameStruct.Action act) { BaseObject attack_obj = act.GetObject(0) as BaseObject; NetMsg.MsgAttackInfo info = act.GetObject(2) as NetMsg.MsgAttackInfo; if (attack_obj == null) { return; } uint injured = (uint)act.GetObject(1); //受伤害的值 mTarget = attack_obj; this.GetAi().Injured(attack_obj); //死亡-- 锁定后不允许死亡 if (IsDie() && !this.IsLock() && info.tag == 2 /*单体攻击*/) { GameStruct.Action action; //死亡 action = new GameStruct.Action(GameStruct.Action.DIE, null); action.AddObject(attack_obj); action.AddObject(injured); this.PushAction(action); } //魔法攻击要延迟一秒下发死亡消息 if (info.tag == 21 && IsDie() && !this.IsLock()) { mnDieMagicTick = System.Environment.TickCount; mDieMagicInfo = act; } }
public MonsterObject(uint _id, int nAi_Id, short x, short y, bool isCreateTypeId = true) { mTarget = null; id = _id; type = OBJECTTYPE.MONSTER; attr = new GameStruct.MonterAttribute(); mRebirthTime = 1000; //默认复活时间 if (isCreateTypeId) { typeid = IDManager.CreateTypeId(type); } mInitPoint = new GameStruct.Point(); mInitPoint.x = x; mInitPoint.y = y; m_Ai = CreateAi(nAi_Id); mnDieMagicTick = System.Environment.TickCount; mDieMagicInfo = null; attr.life = attr.life_max = 0; mAliveTime = new GameBase.Core.TimeOut(); mAliveTime.SetInterval(mRebirthTime); this.SetPoint(x, y); // ai = new AI.BaseAI(this); Alive(); }
public MonsterObject(uint _id,int nAi_Id,short x,short y,bool isCreateTypeId = true) { mTarget = null; id = _id; type = OBJECTTYPE.MONSTER; attr = new GameStruct.MonterAttribute(); mRebirthTime = 1000; //默认复活时间 if (isCreateTypeId) { typeid = IDManager.CreateTypeId(type); } mInitPoint = new GameStruct.Point(); mInitPoint.x = x; mInitPoint.y = y; m_Ai = CreateAi(nAi_Id); mnDieMagicTick = System.Environment.TickCount; mDieMagicInfo = null; attr.life = attr.life_max = 0; mAliveTime = new GameBase.Core.TimeOut(); mAliveTime.SetInterval(mRebirthTime); this.SetPoint(x, y); // ai = new AI.BaseAI(this); Alive(); }
public override void Walk(byte dir) { base.Walk(dir); GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE); SetLastWalkTime(System.Environment.TickCount); SetWalkTime(IRandom.Random(1000, 60 * 1000)); PushAction(action); }
protected override void ProcessAction_Die(GameStruct.Action act) { PlayerObject play = act.GetObject(0) as PlayerObject; BaseObject baseobj = act.GetObject(0) as BaseObject; if (play == null && baseobj.type == OBJECTTYPE.EUDEMON) { play = (baseobj as EudemonObject).GetOwnerPlay(); } //根据打出的伤害获得经验值 uint injured = (uint)act.GetObject(1); NetMsg.MsgMonsterDieInfo info = new NetMsg.MsgMonsterDieInfo(); info.roleid = baseobj.GetTypeId(); info.role_x = baseobj.GetCurrentX(); info.role_y = baseobj.GetCurrentY(); info.injuredvalue = 0; info.monsterid = this.GetTypeId(); byte[] msg = info.GetBuffer(); //掉落道具 this.DropItem(baseobj); //RefreshVisibleObject(); //if (mRefreshList.Count > 0) //{ // this.GetGameMap().BroadcastBuffer(this,msg); // //掉落道具 // this.DropItem(play); //} this.BrocatBuffer(msg); LastDieTime = System.Environment.TickCount; if (play == null && baseobj.type != OBJECTTYPE.EUDEMON) { return; } //计算经验 play.AddExp((int)injured, play.GetLevel(), this.GetLevel()); //死亡的幻兽加灵气值复活 play.GetEudemonSystem().Eudemon_Alive(this); this.GetAi().Die(); this.GetAi().SetAttackTarget(null); mAliveTime.Update(); //执行死亡脚本- 最后一击的击杀者执行该脚本 if (mInfo.die_scripte_id > 0 && play != null) { ScripteManager.Instance().ExecuteAction(mInfo.die_scripte_id, play); } }
public virtual GameStruct.Action PopAction() { if (mActionList.Count > 0) { GameStruct.Action ret = mActionList[0]; mActionList.Remove(ret); return(ret); } return(null); }
public virtual bool Run() { while (true) { GameStruct.Action act = PopAction(); if (act == null) { break; } ProcessAction(act); } return(true); }
protected override void ProcessAction_Move(GameStruct.Action act) { this.RefreshVisibleObject(); List <BaseObject> list_add = null; foreach (RefreshObject refobj in this.GetVisibleList().Values) { BaseObject obj = refobj.obj; // //角色没这个怪物的要刷新该怪物视野 if (obj.type == OBJECTTYPE.PLAYER) { if (!obj.GetVisibleList().ContainsKey(this.GetGameID())) //刷新该角色视野 { //集合会被修改 与foreach冲突. 放到外面添加 if (list_add == null) { list_add = new List <BaseObject>(); } list_add.Add(obj); } else { NetMsg.MsgMoveInfo moveinfo = new NetMsg.MsgMoveInfo(); moveinfo.Create(null, null); moveinfo.id = this.GetTypeId(); moveinfo.x = GetCurrentX(); moveinfo.y = GetCurrentY(); moveinfo.ucMode = DIR.MOVEMODE_RUN_DIR0 + Define.FIGHTKNIGHT_RUN_SPEED; moveinfo.dir = this.GetDir(); byte[] msg = moveinfo.GetBuffer(); this.BrocatBuffer(msg); } } } if (list_add != null) { for (int i = 0; i < list_add.Count; i++) { list_add[i].AddVisibleObject(this, true); this.SendInfo(list_add[i] as PlayerObject); //(list_add[i] as PlayerObject).SendMonsterInfo(this); } } }
public override void Injured(BaseObject obj, uint value, NetMsg.MsgAttackInfo info) { if (value > attr.life) { attr.life = 0; } else { attr.life -= (int)value; } GameStruct.Action action; action = new GameStruct.Action(GameStruct.Action.INJURED, null); action.AddObject(obj); action.AddObject(value); action.AddObject(info); this.PushAction(action); }
public virtual void ProcessAction(GameStruct.Action act) { if (act == null) { return; } switch (act.GetAction()) { case GameStruct.Action.MOVE: { ProcessAction_Move(act); break; } case GameStruct.Action.ATTACK: { ProcessAction_Attack(act); break; } case GameStruct.Action.DIE: { ProcessAction_Die(act); break; } case GameStruct.Action.ALIVE: { ProcessAction_Alive(act); break; } case GameStruct.Action.INJURED: { ProcessAction_Injured(act); break; } } }
//在当前地图随机传送 public void ScroolRandom(short _x = 0, short _y = 0) { int index = 0; short x = _x; short y = _y; if (x == 0 && y == 0) { while (true) { x = (short)IRandom.Random(1, (int)this.GetGameMap().mnWidth); y = (short)IRandom.Random(1, (int)this.GetGameMap().mnHeight); if (this.GetGameMap().CanMove(x, y)) break; if (index > 100) return; index++; } } //先清除自身对象 this.ClearThis(); this.SetPoint(x, y); NetMsg.MsgScroolRandom msg = new NetMsg.MsgScroolRandom(); msg.Create(null, GetGamePackKeyEx()); msg.time = System.Environment.TickCount; msg.x = msg._x = this.GetCurrentX(); msg.y = msg._y = this.GetCurrentY(); msg.roleid = this.GetTypeId(); this.SendData(msg.GetBuffer()); this.GetVisibleList().Clear(); GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE); this.PushAction(act); //幻兽也要跟随 this.GetEudemonSystem().FlyPlay(); }
public override void Injured(BaseObject obj, uint value, NetMsg.MsgAttackInfo info) { this.GetFightSystem().SetFighting(); //幻兽优先受伤害 if (!this.GetEudemonSystem().Eudemon_Injured(obj, value, info)) { //如果没有幻兽抵挡. 玩家就受到真实伤害 this.ChangeAttribute(GameStruct.UserAttribute.LIFE, -(int)value); } GameStruct.Action action; action = new GameStruct.Action(GameStruct.Action.INJURED, null); action.AddObject(obj); action.AddObject(value); action.AddObject(info); this.PushAction(action); }
public override void Run(byte dir, int ucMode) { base.Run(dir, ucMode); GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE); PushAction(action); }
protected virtual void ProcessAction_Injured(GameStruct.Action act) { }
public override void Walk(byte dir) { base.Walk(dir); GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE); PushAction(action); }
public override bool Run() { if (this.GetAi() == null) return true; base.Run(); //单体魔法攻击延迟死亡 if (mDieMagicInfo != null && System.Environment.TickCount - mnDieMagicTick >= 500) { GameStruct.Action action = new GameStruct.Action(GameStruct.Action.DIE, null); action.AddObject(mDieMagicInfo.GetObject(0)); action.AddObject(mDieMagicInfo.GetObject(1)); this.PushAction(action); mDieMagicInfo = null; return true; } else if (mDieMagicInfo != null) { return true; } this.GetAi().Run(); if(this.IsLock()) { if (!this.CheckLockTime()) { this.UnLock(false); if (IsDie()) { GameStruct.Action action; //死亡 action = new GameStruct.Action(GameStruct.Action.DIE, null); action.AddObject(mTarget); action.AddObject((uint)mTarget.GetMinAck()); //取最小攻击为经验值 this.PushAction(action); LastDieTime = System.Environment.TickCount; } } } //死亡后三秒后发送清除怪物消息 if (IsDie() && !this.IsLock()) { if (!IsClear() && System.Environment.TickCount - LastDieTime > 3000 ) { this.ClearThis(); } } ////复活 //if (IsClear() && IsDie() && mRebirthTime > 0) //{ // if (System.Environment.TickCount - LastDieTime > mRebirthTime) // { // Alive(false); // } //} if (IsClear() && IsDie() && mAliveTime.ToNextTime()) { Alive(false); } return true; }
public void FlyMap(uint mapid, short x, short y, byte dir) { GameMap map = MapManager.Instance().GetGameMapToID(mapid); if (map == null) { Log.Instance().WriteLog("未找到游戏地图id:" + mapid.ToString()); return; } if (GetGameMap() != null) { GetGameMap().RemoveObj(this); } this.mGameMap = map; this.GetBaseAttr().mapid = mapid; this.SetPoint(x, y); this.SetDir(dir); map.AddObject(this, this.GetGameSession()); //重新刷新可视列表 GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE); this.PushAction(act); //发给玩家 NetMsg.MsgMapInfo mapinfo = new NetMsg.MsgMapInfo(); mapinfo.Create(null, GetGamePackKeyEx()); mapinfo.Init(mapid, x, y, NetMsg.MsgMapInfo.ENTERMAP); this.SendData(mapinfo.GetBuffer()); //发送天气信息 this.GetGameMap().SendWeatherInfo(this); }
//private void AutoAttack() //{ // return; // //if (GetTargetObj() == null) return; // //if (GetTargetObj().IsDie()) // //{ // // SetTargetObj(null); // // return; // //} // //if (System.Environment.TickCount - lastattacktime > attack_speed) // //{ // // uint injured = 10; // // //targetObject.Injured(this, injured,2); // // lastattacktime = System.Environment.TickCount; // //} //} //进入游戏 参数1: 是否是创建角色第一次进入游戏 public void EnterGame(GameBase.Network.GameSession _session, bool isFirst = false) { if (_session != null) { this.SetGameSession(_session); } if (this.GetGameSession() == null) { Log.Instance().WriteLog("玩家进入游戏EnterGame,会话对象为空!!"); return; } this.CalcAttribute();//计算属性- this.GetGameSession().gameid = this.GetGameID(); //加入到全局用户列表 UserEngine.Instance().AddPlayerObject(this); PlayerObject pay = this; //公告信息 NetMsg.MsgNotice msgNotice = new NetMsg.MsgNotice(); msgNotice.Create(null, GetGamePackKeyEx()); ////玩家个人信息 // byte[] selfdata = { 238, 3, 64, 66, 15, 0, 17, 152, 2, 0, 101, 0, 0, 0, 125, 61, 2, 0, 0, 0, 0, 0, 133, 133, 207, 231, 1, 0, 0, 0, 14, 166, 0, 0, 0, 0, 0, 0, 231, 29, 0, 0, 180, 1, 0, 0, 31, 0, 100, 0, 74, 2, 0, 0, 0, 0, 46, 25, 46, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 20, 0, 1, 1, 5, 0, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 21, 10, 0, 0, 84, 154, 126, 156, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 25, 0, 0, 0, 0, 0, 0, 54, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 4, 0, 0, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 97, 118, 49, 51, 49, 52, 2, 206, 222, 0, 0, 0 }; // this.GetGamePackKeyEx().EncodePacket(ref selfdata, selfdata.Length); // this.SendData(selfdata); // NetMsg.MsgSelfRoleInfo rolemsg = new NetMsg.MsgSelfRoleInfo(); //rolemsg.Create(selfdata, this.GetGamePackKeyEx()); rolemsg.Create(null, this.GetGamePackKeyEx()); rolemsg.roleid = this.GetTypeId(); rolemsg.lookface = this.GetBaseAttr().lookface; rolemsg.profession = this.GetBaseAttr().profession; rolemsg.name = this.GetName(); //一登录进满血 this.GetBaseAttr().life = this.GetBaseAttr().life_max; rolemsg.life = (ushort)this.GetBaseAttr().life; rolemsg.maxlife = (ushort)this.GetBaseAttr().life_max; rolemsg.manna = (ushort)this.GetBaseAttr().mana_max; rolemsg.maxpetcall = this.GetBaseAttr().maxeudemon; //一登录进满蓝 rolemsg.level = this.GetBaseAttr().level; rolemsg.gold = (uint)this.GetBaseAttr().gold; rolemsg.godlevel = this.GetBaseAttr().godlevel; rolemsg.gamegold = (uint)this.GetBaseAttr().gamegold; // rolemsg.maxpetcall = (ushort)GameBase.Config.Define.MAX_CALL_EUDEMON;//最大召唤宠物数量 rolemsg.hair = (uint)this.GetBaseAttr().hair; //第一次进入游戏 if (isFirst) { this.SendData(msgNotice.GetStartGameBuff()); //个人信息 //偷懒,一参加角色神等级20级 2016.1.21 封包协议号没分析全的结果 //2016.2.1 神力等级归0 rolemsg.godlevel = 0; session.SendData(rolemsg.GetBuffer()); SendRoleOtherSystemInfo(); ScripteManager.Instance().ExecuteAction(GameBase.Config.Define.FIRSTSCRIPTID, this); return; } GameMap map = MapManager.Instance().GetGameMapToID(this.GetBaseAttr().mapid); if (map == null) { Log.Instance().WriteLog("非法玩家,非法坐标.." + this.GetName() + " 地图id:" + this.GetBaseAttr().mapid.ToString() +"已修正到回卡诺萨城"); //重新回到卡诺萨城 this.GetBaseAttr().mapid = 1000; this.SetPoint(145, 413); map = MapManager.Instance().GetGameMapToID(this.GetBaseAttr().mapid); // return; } MapManager.Instance().GetGameMapToID(this.GetBaseAttr().mapid).AddObject(this, GetGameSession()); //发送爵位公告 this.SendJueweiNotice(); ////加入到正式列表 //公告信息 session.SendData(msgNotice.GetStartGameBuff()); // session.GetGamePackKeyEx().EncodePacket(ref data, data.Length); session.SendData(rolemsg.GetBuffer()); //session.SendData(data); SendRoleOtherSystemInfo(); //测试增加装备 测试装备 //NetMsg.MsgItemInfo item = new NetMsg.MsgItemInfo(); //item.Create(null, session.GetGamePackKeyEx()); //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_ARMOR; //item.id = 112434; //item.item_id = 135114; //item.amount = item.amount_limit = 1; //session.SendData(item.GetBuffer()); //测试武器 //item = new NetMsg.MsgItemInfo(); //item.Create(null, session.GetGamePackKeyEx()); //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_WEAPONR; //item.id = 112435; //item.item_id = 440244; //item.amount = item.amount_limit = 1; //session.SendData(item.GetBuffer()); //item = new NetMsg.MsgItemInfo(); //item.Create(null, session.GetGamePackKeyEx()); //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_BACKPACK; //item.id = 112436; //item.item_id = 440244; //item.amount = item.amount_limit = 1; //session.SendData(item.GetBuffer()); //NetMsg.MsgUpdateSP sp = new NetMsg.MsgUpdateSP(); //sp.Create(null, session.GetGamePackKeyEx()); //sp.role_id = this.GetTypeId(); //sp.value = 37; //sp.sp = 100; //session.SendData(sp.GetBuffer()); //sp = new NetMsg.MsgUpdateSP(); //sp.Create(null, session.GetGamePackKeyEx()); //sp.role_id = this.GetTypeId(); //session.SendData(sp.GetBuffer()); //进入地图 NetMsg.MsgMapInfo mapinfo = new NetMsg.MsgMapInfo(); mapinfo.Create(null, session.GetGamePackKeyEx()); mapinfo.Init(this.GetBaseAttr().mapid, this.GetCurrentX(), this.GetCurrentY(), NetMsg.MsgMapInfo.ENTERMAP); session.SendData(mapinfo.GetBuffer()); //初始化一些信息 this.ChangeAttribute(UserAttribute.LOOKFACE, GetLookFace()); //刷新可视列表; GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE); this.PushAction(act); ScriptTimerManager.Instance().PlayerEnterGame(this.GetBaseAttr().player_id); //发送天气信息 this.GetGameMap().SendWeatherInfo(this); // // this.MsgBox("QQ群号:306929937"); }
//更换地图 用于普通场景 public void ChangeMap(uint mapid, short x, short y) { GameMap target_map = MapManager.Instance().GetGameMapToID(mapid); if (target_map == null) { Log.Instance().WriteLog("传送地图失败,该地图id不存在," + mapid.ToString() + " x:" + x.ToString() + " y:" + y.ToString()); return; } this.GetGameMap().RemoveObj(this); //召回所有幻兽- this.GetEudemonSystem().Eudemon_ReCallAll(true); target_map.AddObject(this, this.GetGameSession()); //先清除自身对象 this.ClearThis(); this.SetPoint(x, y); //要发二个包 NetMsg.MsgReCall1 msg = new NetMsg.MsgReCall1(); msg.Create(null, GetGamePackKeyEx()); msg.roleid = this.GetTypeId(); msg.mapid = (int)this.GetGameMap().GetMapInfo().id; msg.x = this.GetCurrentX(); msg.y = this.GetCurrentY(); this.SendData(msg.GetBuffer()); NetMsg.MsgReCall2 msg1 = new NetMsg.MsgReCall2(); msg1.Create(null, GetGamePackKeyEx()); msg1.roleid = this.GetTypeId(); msg1.x = this.GetCurrentX(); msg1.y = this.GetCurrentY(); this.SendData(msg1.GetBuffer()); this.GetVisibleList().Clear(); GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE); this.PushAction(act); GetBaseAttr().mapid = mapid; this.SendJueweiNotice(); this.SetTransmitIng(true); // this.GetEudemonSystem().FlyPlay(); }
//更换地图 用于副本场景 public void ChangeFubenMap(GameMap map, short x, short y) { if (map == null) return; this.GetGameMap().RemoveObj(this); //召回所有幻兽- this.GetEudemonSystem().Eudemon_ReCallAll(true); map.AddObject(this, this.GetGameSession()); //先清除自身对象 this.ClearThis(); this.SetPoint(x, y); //要发二个包 NetMsg.MsgReCall1 msg = new NetMsg.MsgReCall1(); msg.Create(null, GetGamePackKeyEx()); msg.roleid = this.GetTypeId(); msg.mapid = (int)this.GetGameMap().GetMapInfo().id; msg.x = this.GetCurrentX(); msg.y = this.GetCurrentY(); this.SendData(msg.GetBuffer()); NetMsg.MsgReCall2 msg1 = new NetMsg.MsgReCall2(); msg1.Create(null, GetGamePackKeyEx()); msg1.roleid = this.GetTypeId(); msg1.x = this.GetCurrentX(); msg1.y = this.GetCurrentY(); this.SendData(msg1.GetBuffer()); this.GetVisibleList().Clear(); GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE); this.PushAction(act); GetBaseAttr().mapid = map.GetMapInfo().id; this.SendJueweiNotice(); this.SetTransmitIng(true); }
protected virtual void ProcessAction_Attack(GameStruct.Action act) { }
public override void Injured(BaseObject obj, uint value, NetMsg.MsgAttackInfo info) { mbIsCombo = play.GetFightSystem().IsComboMagic(info.usType); this.GetAttr().life -= (int)value; if (this.GetAttr().life < 0) { this.GetAttr().life = 0; } if (!mbIsCombo && this.GetAttr().life <= 0) { GameStruct.Action action = new GameStruct.Action(GameStruct.Action.DIE, null); this.PushAction(action); } NetMsg.MsgEudemonInfo msg = new NetMsg.MsgEudemonInfo(); msg.id = this.GetTypeId(); msg.AddAttribute(EudemonAttribute.Life, this.GetAttr().life); this.BrocatBuffer(msg.GetBuffer()); }
protected virtual void ProcessAction_Alive(GameStruct.Action act) { }
public bool Move(NetMsg.MsgMoveInfo move) { byte dir = (byte)((int)move.dir % 8); this.SetDir(dir); short nNewX = this.GetCurrentX(); short nNewY = this.GetCurrentY(); //作弊判断,与宿主距离不得超过格子范围 否则传送回身边 if (Math.Abs(play.GetCurrentX() - this.GetCurrentX()) > GameBase.Config.Define.MAX_EUDEMON_PLAY_DISTANCE || Math.Abs(play.GetCurrentY() - this.GetCurrentY()) > GameBase.Config.Define.MAX_EUDEMON_PLAY_DISTANCE) { nNewX = (short)(play.GetCurrentX()); nNewY = (short)(play.GetCurrentY()); this.SetPoint(nNewX, nNewY); this.SendEudemonInfo(); return false; } nNewX += DIR._DELTA_X[dir]; nNewY += DIR._DELTA_Y[dir]; if (!mGameMap.CanMove(nNewX, nNewY)) { // Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString()); return false; } //// 跑步模式的阻挡判断 bool IsRun = false; if (move.ucMode >= DIR.MOVEMODE_RUN_DIR0 && move.ucMode <= DIR.MOVEMODE_RUN_DIR7 ) { nNewX += DIR._DELTA_X[move.ucMode - DIR.MOVEMODE_RUN_DIR0]; nNewY += DIR._DELTA_Y[move.ucMode - DIR.MOVEMODE_RUN_DIR0]; IsRun = true; //if (!mGameMap.CanMove(nNewX, nNewY)) //{ // return false; //} } GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE); if (IsRun) action.AddObject(move.ucMode); this.SetPoint(nNewX, nNewY); PushAction(action); return true; }
public override bool Run() { if (this.GetAi() == null) { return(true); } base.Run(); //单体魔法攻击延迟死亡 if (mDieMagicInfo != null && System.Environment.TickCount - mnDieMagicTick >= 500) { GameStruct.Action action = new GameStruct.Action(GameStruct.Action.DIE, null); action.AddObject(mDieMagicInfo.GetObject(0)); action.AddObject(mDieMagicInfo.GetObject(1)); this.PushAction(action); mDieMagicInfo = null; return(true); } else if (mDieMagicInfo != null) { return(true); } this.GetAi().Run(); if (this.IsLock()) { if (!this.CheckLockTime()) { this.UnLock(false); if (IsDie()) { GameStruct.Action action; //死亡 action = new GameStruct.Action(GameStruct.Action.DIE, null); action.AddObject(mTarget); action.AddObject((uint)mTarget.GetMinAck()); //取最小攻击为经验值 this.PushAction(action); LastDieTime = System.Environment.TickCount; } } } //死亡后三秒后发送清除怪物消息 if (IsDie() && !this.IsLock()) { if (!IsClear() && System.Environment.TickCount - LastDieTime > 3000) { this.ClearThis(); } } ////复活 //if (IsClear() && IsDie() && mRebirthTime > 0) //{ // if (System.Environment.TickCount - LastDieTime > mRebirthTime) // { // Alive(false); // } //} if (IsClear() && IsDie() && mAliveTime.ToNextTime()) { Alive(false); } return(true); }
public override bool Run() { base.Run(); //幻兽被玩家连击后- 超出角色距离就瞬移到角色位置 if (Math.Abs(play.GetCurrentX() - this.GetCurrentX()) > GameBase.Config.Define.MAX_EUDEMON_PLAY_DISTANCE || Math.Abs(play.GetCurrentY() - this.GetCurrentY()) > GameBase.Config.Define.MAX_EUDEMON_PLAY_DISTANCE) { this.FlyPlay(); //this.ClearThis(); //this.SetPoint(play.GetCurrentX(), play.GetCurrentY()); //this.SendEudemonInfo(); return true; } //连招解锁 if (this.IsLock()) { if (!this.CheckLockTime()) { this.UnLock(); } } //出征状态下的死亡 if (this.GetState() == EUDEMONSTATE.BATTLE) { if (this.IsDie() && !this.IsLock() && !this.GetAttr().bDie) { GameStruct.Action action = new GameStruct.Action(GameStruct.Action.DIE, null); this.PushAction(action); } } //合体状态下的死亡 if (this.GetState() == EUDEMONSTATE.FIT) { if (mbIsCombo && IsDie() && !play.IsLock()) { mbIsCombo = false; } if (IsDie() && !mbIsCombo && !this.GetAttr().bDie) { GameStruct.Action action = new GameStruct.Action(GameStruct.Action.DIE, null); this.PushAction(action); } } if (this.GetState() == EUDEMONSTATE.FIT) { this.SetPoint(play.GetCurrentX(), play.GetCurrentY()); } return true; }
protected override void ProcessAction_Move(GameStruct.Action act) { this.RefreshVisibleObject(); List <BaseObject> list_add = null; foreach (RefreshObject refobj in this.GetVisibleList().Values) { BaseObject obj = refobj.obj; // //角色没这个怪物的要刷新该怪物视野 // //2015.9.5 if (obj.type == OBJECTTYPE.PLAYER) { if (!obj.GetVisibleList().ContainsKey(this.GetGameID())) //刷新该角色视野 { //集合会被修改 与foreach冲突. 放到外面添加 if (list_add == null) { list_add = new List <BaseObject>(); } list_add.Add(obj); } else { MsgMoveInfo moveinfo = new MsgMoveInfo(); moveinfo.Create(null, null); moveinfo.id = this.GetTypeId(); moveinfo.x = GetCurrentX(); moveinfo.y = GetCurrentY(); moveinfo.ucMode = 1; moveinfo.dir = this.GetDir(); byte[] msg = moveinfo.GetBuffer(); this.GetGameMap().BroadcastBuffer(this, msg); } } } if (list_add != null) { for (int i = 0; i < list_add.Count; i++) { //RefreshObject _addobj = new RefreshObject(); //_addobj.bRefreshTag = true; //_addobj.obj = this; //list_add[i].GetVisibleList()[this.GetGameID()] = _addobj; list_add[i].AddVisibleObject(this, true); (list_add[i] as PlayerObject).SendMonsterInfo(this); } } //if (mRefreshList.Count > 0) //{ // //角色没这个怪物的要刷新该怪物视野 // //2015.9.5 // foreach (BaseObject obj in mRefreshList.Values) // { // if (obj.type == OBJECTTYPE.PLAYER) // { // if (!obj.GetVisibleList().ContainsKey(this.GetGameID())) // { // (obj as PlayerObject).SendMonsterInfo(this); // obj.GetVisibleList().Add(this.GetGameID(), this); // } // } // mRefreshList.Clear(); // } // MsgMoveInfo moveinfo = new MsgMoveInfo(); // moveinfo.Create(null, null); // moveinfo.id = this.GetTypeId(); // moveinfo.x = GetCurrentX(); // moveinfo.y = GetCurrentY(); // moveinfo.ucMode = 1; // moveinfo.dir = this.GetDir(); // byte[] msg = moveinfo.GetBuffer(); // this.GetGameMap().BroadcastBuffer(this,msg); //} }
//public override void RefreshVisibleObject() //刷新可视对象 //{ // base.RefreshVisibleObject(); // mRefreshList.Clear(); // foreach (BaseObject o in mGameMap.mDicObject.Values) // { // if (o.GetGameID() == this.GetGameID()) continue; // //玩家和玩家的视野范围扩大- // // int dis = o.type == OBJECTTYPE.PLAYER ? Define.MAX_PLAY_VISIBLE_DISTANCE : Define.MAX_VISIBLE_DISTANCE; // int dis = Define.MAX_VISIBLE_DISTANCE; // //如果是怪物和npc 掉落物品对象就不发消息了-- 已经在视野范围了嘛 // if ((o.type == OBJECTTYPE.NPC || o.type == OBJECTTYPE.MONSTER || // o.type == OBJECTTYPE.EUDEMON || o.type == OBJECTTYPE.DROPITEM || // o.type == OBJECTTYPE.PLAYER || o.type == OBJECTTYPE.ROBOT) && // this.mVisibleList.ContainsKey(o.GetGameID())) // { // if (!GetPoint().CheckVisualDistance(o.GetCurrentX(), o.GetCurrentY(), dis) // && this.mVisibleList.ContainsKey(o.GetGameID())) // { // this.mVisibleList.Remove(o.GetGameID()); // if (this.mPlayObject.ContainsKey(o.GetGameID())) // { // this.mPlayObject.Remove(o.GetGameID()); // } // } // continue; // } // if (GetPoint().CheckVisualDistance(o.GetCurrentX(), o.GetCurrentY(), dis)) // { // this.mVisibleList[o.GetGameID()] = o; // if (o.type == OBJECTTYPE.MONSTER) // { // MonsterObject mobj = o as MonsterObject; // if (mobj.IsDie()) continue; // } // if (o.type == OBJECTTYPE.NPC || // o.type == OBJECTTYPE.MONSTER || // o.type == OBJECTTYPE.PLAYER || // o.type == OBJECTTYPE.DROPITEM || // o.type == OBJECTTYPE.EUDEMON || // o.type == OBJECTTYPE.ROBOT) // { // mRefreshList[o.GetGameID()] = o; // } // } // else // { // if (!GetPoint().CheckVisualDistance(o.GetCurrentX(), o.GetCurrentY(), dis) // && this.mVisibleList.ContainsKey(o.GetGameID())) // { // this.mVisibleList.Remove(o.GetGameID()); // if ((o.type == OBJECTTYPE.PLAYER || o.type == OBJECTTYPE.EUDEMON || // o.type == OBJECTTYPE.ROBOT) && // mPlayObject.ContainsKey(o.GetGameID())) // { // mPlayObject.Remove(o.GetGameID()); // //清除目标对象 // NetMsg.MsgClearObjectInfo clearobj = new NetMsg.MsgClearObjectInfo(); // clearobj.Create(null, this.GetGamePackKeyEx()); // clearobj.id = o.GetTypeId(); // this.SendData(clearobj.GetBuffer()); // if (o.type == OBJECTTYPE.PLAYER) // { // clearobj = new NetMsg.MsgClearObjectInfo(); // clearobj.Create(null, o.GetGamePackKeyEx()); // clearobj.id = this.GetTypeId(); // o.SendData(clearobj.GetBuffer()); // (o as PlayerObject).GetPlayObjectList().Remove(this.GetGameID()); // } // if (o.type == OBJECTTYPE.EUDEMON) // { // (o as EudemonObject).GetPlayObjectList().Remove(this.GetGameID()); // } // } // } // } // } //} public bool Move(NetMsg.MsgMoveInfo move) { if (!this.GetMagicSystem().CheckMoveSpeed()) { this.ScroolRandom(this.GetCurrentX(), this.GetCurrentY()); return false; } // testeudemon(); byte dir = (byte)((int)move.dir % 8); this.SetDir(dir); short nNewX = GetCurrentX(); short nNewY = GetCurrentY(); nNewX += DIR._DELTA_X[dir]; nNewY += DIR._DELTA_Y[dir]; if (!mGameMap.CanMove(nNewX, nNewY)) { nNewX = this.GetCurrentX(); nNewY = this.GetCurrentY(); if (!mGameMap.CanMove(nNewX, nNewY)) { nNewX = (short)mGameMap.GetMapInfo().recallx; nNewY = (short)mGameMap.GetMapInfo().recally; } //暂时使用随机卷的方式重置玩家坐标 this.ScroolRandom(nNewX, nNewY); // Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString()); return false; } // 跑步模式的阻挡判断 bool IsRun = false; if (move.ucMode >= DIR.MOVEMODE_RUN_DIR0 && move.ucMode <= DIR.MOVEMODE_RUN_DIR7 && GetBaseAttr().sp > 0 /*没有体力不让跑*/) { nNewX += DIR._DELTA_X[move.ucMode - DIR.MOVEMODE_RUN_DIR0]; nNewY += DIR._DELTA_Y[move.ucMode - DIR.MOVEMODE_RUN_DIR0]; IsRun = true; if (!mGameMap.CanMove(nNewX, nNewY)) { nNewX = this.GetCurrentX(); nNewY = this.GetCurrentY(); if (!mGameMap.CanMove(nNewX, nNewY)) { nNewX = (short)mGameMap.GetMapInfo().recallx; nNewY = (short)mGameMap.GetMapInfo().recally; } //暂时使用随机卷的方式重置玩家坐标 this.ScroolRandom(nNewX, nNewY); //Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString()); //Log.Instance().WriteLog("这个家伙肯定用了外挂,不如我们把他封号吧,角色名称:" + this.GetName() + // "如果下次他还开外挂,就把他硬盘里的种子全删掉..."); return false; } } //传送点判断 uint mapid = 0; short x = 0; short y = 0; if (ConfigManager.Instance().CheckMapGate(this.GetGameMap().GetMapInfo().id, nNewX, nNewY, ref mapid, ref x, ref y)) { this.ChangeMap(mapid, x, y); return false; } if (GetBaseAttr().sp <= 0) move.ucMode = 0; SetPoint(nNewX, nNewY); GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE); if (IsRun) action.AddObject(move.ucMode); //解除锁定目标 this.GetFightSystem().SetAutoAttackTarget(null); PushAction(action); return true; }
protected override void ProcessAction_Injured(GameStruct.Action act) { BaseObject attack_obj = act.GetObject(0) as BaseObject; NetMsg.MsgAttackInfo info = act.GetObject(2) as NetMsg.MsgAttackInfo; if (attack_obj == null) return; uint injured = (uint)act.GetObject(1) ; //受伤害的值 mTarget = attack_obj; this.GetAi().Injured(attack_obj); //死亡-- 锁定后不允许死亡 if (IsDie() && !this.IsLock() && info.tag == 2/*单体攻击*/) { GameStruct.Action action; //死亡 action = new GameStruct.Action(GameStruct.Action.DIE, null); action.AddObject(attack_obj); action.AddObject(injured); this.PushAction(action); } //魔法攻击要延迟一秒下发死亡消息 if (info.tag == 21 && IsDie() && !this.IsLock()) { mnDieMagicTick = System.Environment.TickCount; mDieMagicInfo = act; } }
public virtual void PushAction(GameStruct.Action act) { mActionList.Add(act); }
public override void Injured(BaseObject obj, uint value,NetMsg.MsgAttackInfo info) { if (value > attr.life) attr.life = 0; else attr.life -= (int)value; GameStruct.Action action; action = new GameStruct.Action(GameStruct.Action.INJURED, null); action.AddObject(obj); action.AddObject(value); action.AddObject(info); this.PushAction(action); }
public override bool Run() { //意外断开处理 if (GetGameSession() == null) { //广播出去,清除该玩家 if (GetVisibleList().Count > 0) { NetMsg.MsgClearObjectInfo clear = new NetMsg.MsgClearObjectInfo(); clear.id = this.GetTypeId(); GetGameMap().BroadcastBuffer(this, clear.GetBuffer()); } return false; } base.Run(); //连招解锁 if (this.IsLock()) { if (!this.CheckLockTime()) { this.UnLock(); } } this.GetTimerSystem().Run(); //战斗系统 this.GetFightSystem().Run(); this.GetPKSystem().Run(); //角色死亡变为鬼魂状态, if (this.IsDie() && m_bGhost && mnGhostTick != -1) { if (System.Environment.TickCount - mnGhostTick >= 3000) { this.ChangeAttribute(UserAttribute.STATUS, 6); this.ChangeAttribute(UserAttribute.LOOKFACE, GetLookFace(), true); mnGhostTick = -1; } } //死亡--因为会被连击锁定-- 所以放到run方法 if (IsDie() && !this.IsLock() && mTarget != null && m_bGhost == false) { GameStruct.Action action; //死亡 action = new GameStruct.Action(GameStruct.Action.DIE, null); action.AddObject(mTarget); this.PushAction(action); } //定时保存玩家数据 if (mSaveTime.ToNextTime()) { UserEngine.Instance().AddSaveRole(this); } //传送状态 if (mbTransmit && mTransmitTimeOut.ToNextTime()) { //幻兽出征 this.GetEudemonSystem().Eudemon_BattleAll(); //发送天气信息 this.GetGameMap().SendWeatherInfo(this); this.SetTransmitIng(false); } return true; }