public void UpdatePosition(UInt32 diff) { if (TrackObj != null) { Object player = BoogieCore.world.getPlayerObject(); player.SetOrientation( player.CalculateAngle( TrackObj.GetPositionX(), TrackObj.GetPositionY() ) ); } if (MoveFlags == 0) { return; // no need to predict coordinates if we aint movin', yo } BoogieCore.Log(LogType.System, "UpdatePos diff: {0}", diff); float predictedDX = 0; float predictedDY = 0; if (oldLocation == null) { oldLocation = BoogieCore.world.getPlayerObject().GetCoordinates(); } // update predicted location double h; double speed; h = BoogieCore.world.getPlayerObject().GetOrientation(); speed = 7.0;//BoogieCore.world.getPlayerObject().runSpeed; float dt = (float)diff / 1000f; float dx = (float)Math.Cos(h) * (float)speed * dt; float dy = (float)Math.Sin(h) * (float)speed * dt; BoogieCore.Log(LogType.System, "speed: {0} dt: {1} dx: {2} dy : {3}", speed, dt, dx, dy); predictedDX = dx; predictedDY = dy; Coordinate loc = BoogieCore.world.getPlayerObject().GetCoordinates(); float realDX = loc.X - oldLocation.X; float realDY = loc.Y - oldLocation.Y; BoogieCore.Log(LogType.System, " dx: " + predictedDX + " dy : " + predictedDY + " Real dx: " + realDX + " dy : " + realDY); float predictDist = (float)Math.Sqrt(predictedDX * predictedDX + predictedDY * predictedDY); float realDist = (float)Math.Sqrt(realDX * realDX + realDY * realDY); BoogieCore.Log(LogType.System, "predict dist: {0} real dist: {1}", predictDist, realDist); if (predictDist > 0.0) { Coordinate expected = new Coordinate(loc.X + predictedDX, loc.Y + predictedDY, BoogieCore.world.getPlayerObject().GetPositionZ(), BoogieCore.world.getPlayerObject().GetOrientation()); BoogieCore.Log(LogType.System, "new loc x {0}, y {1}, z {2}", expected.X, expected.Y, expected.Z); BoogieCore.world.getPlayerObject().SetCoordinates(expected); } oldLocation = loc; }
public bool Face(BoogieBot.Common.Object monster, double tolerance) { BoogieBot.Common.Object player = BoogieCore.world.getPlayerObject(); player.SetOrientation(player.CalculateAngle(monster.GetPositionX(), monster.GetPositionY())); return(true); }
private void ParseCommands(ChatQueue queue, string username) { if ((ChatMsg)queue.Type == ChatMsg.CHAT_MSG_SAY) { if (queue.Message == "face") { Object obj = BoogieCore.world.getObject(queue.GUID); if (obj != null) { Object player = BoogieCore.world.getPlayerObject(); player.SetOrientation(player.CalculateAngle(obj.GetPositionX(), obj.GetPositionY())); SendMoveHeartBeat(); string message = String.Format("Facing {0}", obj.Name); SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, message); return; } SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, String.Format("Unable to find {0} in obj list", username)); } if (queue.Message == "track") { Object obj = BoogieCore.world.getObject(queue.GUID); if (obj != null) { TrackObject(obj); string message = String.Format("Tracking {0}", obj.Name); SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, message); return; } SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, String.Format("Unable to find {0} in obj list", username)); } if (queue.Message == "come") { Object obj = BoogieCore.world.getObject(queue.GUID); if (obj != null) { string message = String.Format("Approaching {0}", obj.Name); SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, message); TrackObject(obj); //pather.Approach(obj, false, 20000); StopTrack(); return; } SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, String.Format("Unable to find {0} in obj list", username)); } if (queue.Message == "t") { StartTurn(); SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, "Turning."); } if (queue.Message == "run") { StartMoveForward(); SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, "Running..."); } if (queue.Message == "stop") { StopTrack(); StopMoveForward(); SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, "stopping..."); } } }