public void SimpleStartToEndScenarioTest() { // Setup Fakes var fakeRtEvents = new FakeRTEvents(); var fakeDecalEvents = new FakeDecalEventsProxy(); Queue<Location> locationResults = new Queue<Location>(); locationResults.Enqueue(new Location(0, 0, 1, 0, 0)); locationResults.Enqueue(new Location(0, 0, 2, 0, 0)); locationResults.Enqueue(new Location(0, 0, 3, 0, 0)); locationResults.Enqueue(new Location(0, 0, 4, 0, 0)); for (int i = 0; i < JumpRecorder.NumberOfConsecutiveZCoordsSameToSingleLand; i++) { locationResults.Enqueue(new Location(0, 0, 5, 0, 0)); } List<SelfJumpCompleteEventArgs> cachedCompleteCallValues = new List<SelfJumpCompleteEventArgs>(); // Workflow to Test JumpRecorder recorder = new JumpRecorder(fakeRtEvents, fakeDecalEvents, e => cachedCompleteCallValues.Add(e), () => locationResults.Dequeue()); var initialJumpData = new JumpData(new Location(0, 0, 0, 0, 0), 0.0, 0.0); Assert.IsFalse(recorder.IsRecording); fakeRtEvents.FireSelfJump(new JumpEventArgs(0, initialJumpData, 0, 0)); Assert.IsTrue(recorder.IsRecording); fakeDecalEvents.FireRenderFrame(new EventArgs()); fakeDecalEvents.FireRenderFrame(new EventArgs()); fakeDecalEvents.FireRenderFrame(new EventArgs()); // We should not have landed yet Assert.IsTrue(recorder.IsRecording); Assert.AreEqual(0, cachedCompleteCallValues.Count); fakeDecalEvents.FireRenderFrame(new EventArgs()); for (int i = 0; i < JumpRecorder.NumberOfConsecutiveZCoordsSameToSingleLand; i++) { fakeDecalEvents.FireRenderFrame(new EventArgs()); } // Now we should have landed Assert.IsFalse(recorder.IsRecording); Assert.AreEqual(1, cachedCompleteCallValues.Count); Assert.AreEqual(initialJumpData, cachedCompleteCallValues[0].JumpData); Assert.AreEqual(4 + JumpRecorder.NumberOfConsecutiveZCoordsSameToSingleLand, cachedCompleteCallValues[0].Trajectory); Assert.AreEqual(1, cachedCompleteCallValues[0].Trajectory[0].Z); Assert.AreEqual(5, cachedCompleteCallValues[0].Trajectory.Last().Z); Assert.AreEqual(5, cachedCompleteCallValues[0].LandingLocation.Z); }
private void _decalEventsProxy_ServerDispatch(object sender, Decal.Adapter.NetworkMessageEventArgs e) { if (e.Message.Type == 0xF74E) // Jumping { //Debug.WriteLineToMain("[ServerDispatch] - Jump detected!!"); int characterId = Convert.ToInt32(e.Message["object"]); double heading = Convert.ToDouble(e.Message["heading"]); double height = Convert.ToDouble(e.Message["height"]); short numLogins = Convert.ToInt16(e.Message["logins"]); short totalJumps = Convert.ToInt16(e.Message["sequence"]); // I don't know if this could ever happen, so if check for it until I know. // TODO : Remove or support once I know if it happens for other characters // ANSWER : YES - Does pick up other character jumps if(characterId != REPlugin.Instance.CharacterFilter.Id) { // Yes, it happens. Commenting out since it is very spammy //Debug.WriteLineToMain("Jump detected for character other than self!! - {0}", characterId); //Debug.WriteLineToMain("Character was - {0}", characterId.ToWorldObject().Name); return; } var jumpData = new JumpData(Location.CaptureCurrent(), heading, height); var jumpEventArgs = new JumpEventArgs(characterId, jumpData, numLogins, totalJumps); REPlugin.Instance.Debug.WriteObject(jumpEventArgs); if (this.SelfJump != null) { this.SelfJump(sender, jumpEventArgs); } } else if (e.Message.Type == 0x019E) // Player Killed { Debug.WriteLineToMain("[ServerDispatch] - Player Killed detected!!"); } else if(e.Message.Type == 0xF748) // Set Position & Motion { //Set position - the server pathologically sends these after every actions - sometimes more than once. If has options for setting a fixed velocity or an arc for thrown weapons and arrows. // ObjectID object The object with the position changing. // Position position The current or starting location. // WORD logins logins // WORD sequence A sequence number of some sort // WORD portals number of portals // WORD adjustments Adjustments to position // TODO : Could this be useful in my effort to implement auto-slave-jump? } else if (e.Message.Type == 0xF749) // Wield Object { //Multipurpose message. So far object wielding has been decoded. Lots of unknowns // ObjectID owner id of the owner of this object // ObjectID object id of the object // DWORD unknown1 Unknown, always 1 in investigations // DWORD unknown2 Unknown, always 1 in investigations // DWORD unknown3 Unknown, Some sort of an equip counter, formula used to generate it: 0x00254 | (0x40000 + 0x30000*((ConnUser[UserParsing].EquipCount - 1) / 2)) // Note by Mike : Happens a lot. Happens for other characters. Might even happen for another characters arrow draw. // TODO : How can I utilize this? // Commenting for now. Spammy //Debug.WriteLineToMain("[ServerDispatch] - Wield Object detected!!"); } else if (e.Message.Type == 0xF65A) // Move object into inventory { //ObjectID object //WORD unknown unknown, was 0335 during testing //WORD unknown1 unknown, appears to be a sequence number of some kind Debug.WriteLineToMain("[ServerDispatch] - Move object into inventory detected!!"); } else if (e.Message.Type == 0x0052) // Close Container { // See web documentation for details. Debug.WriteLineToMain("[ServerDispatch] - Close Container detected!!"); } else if (e.Message.Type == 0x00A0) // Failure to give item { // See web documentation for details. Debug.WriteLineToMain("[ServerDispatch] - Failure to Give Item detected!!"); } else if (e.Message.Type == 0x01C7) // Ready. Previous action complete { // TODO : Does does this relate to CharacterFilter.ActionComplete? Debug.WriteLine("[ServerDispatch] - Ready. Previous action complete detected!!"); } else if (e.Message.Type == 0x02BE) // Create Fellowhsip { Debug.WriteLineToMain("[ServerDispatch] - Create Fellowship detected!!"); } else if (e.Message.Type == 0x02BF) // Disband Fellowhsip { Debug.WriteLineToMain("[ServerDispatch] - Disband Fellowship detected!!"); } else if (e.Message.Type == 0x02C0) // Add Fellowhsip Member { Debug.WriteLineToMain("[ServerDispatch] - Add Fellowhsip Member detected!!"); } else if (e.Message.Type == 0xF7B0) // Game Events { //Debug.WriteLineToMain("[ServerDispatch] - Game Event detected!!"); //ObjectID - character - the object ID of the message recipient (should be you) //DWORD - sequence - sequence number //GameEvent - event - the (sequenced) message type int characterId = Convert.ToInt32(e.Message["character"]); short sequence = Convert.ToInt16(e.Message["sequence"]); short gameEvent = Convert.ToInt16(e.Message["event"]); //Debug.WriteLineToMain("[ServerDispatch] - Game Event Code = {0:X4}", gameEvent); switch (gameEvent) { case 0x00C9: // Identify Object //Debug.WriteLineToMain("[ServerDispatch] - Identify Object detected!!"); //the object ID of the item or creature being assessed int objectId = Convert.ToInt32(e.Message["object"]); short flags = Convert.ToInt16(e.Message["flags"]); bool success = Convert.ToBoolean(e.Message["success"]); // TODO : Replace with event once working //Debug.WriteLineToMain("[ServerDispatch] - Identify Object Data ObjectId = {0}, Flags = {1:X8}, Success = {2}", objectId, flags, success); break; case 0x01C7: // Ready. Previous Action Complete // TODO : Is this useful for anything? //Debug.WriteLineToMain("[ServerDispatch] - Ready. Previous Action Complete"); break; } } }
internal void Begin(JumpData jumpData) { this._jumpTrajectory.Clear(); this._cachedJumpData = jumpData; this._isRecording = true; this._maxZ = jumpData.Location.Z; this._startTime = DateTime.Now; this._decalEvents.RenderFrame += _decalEvents_RenderFrame; }