//[TestMethod()] public void Command_Should_Parse_Correctly() { // ARRANGE Character toon = null; InventoryItem invItem = new InventoryItem(); // Get the client's character info string charName = "Badass"; DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Character>(c => c.Account); dlo.LoadWith<Character>(c => c.Zone); dlo.LoadWith<Character>(c => c.InventoryItems); dlo.LoadWith<InventoryItem>(ii => ii.Item); using (EmuDataContext dbCtx = new EmuDataContext()) { dbCtx.ObjectTrackingEnabled = false; dbCtx.LoadOptions = dlo; toon = dbCtx.Characters.SingleOrDefault(c => c.Name == charName); } ZonePlayer zp = new ZonePlayer(1, toon, 1, new Client(new System.Net.IPEndPoint(0x2414188f, 123))); // ACT //zp.MsgMgr.ReceiveChannelMessage("someTarget", "!damage /amount:200 /type:3", 8, 0, 100); zp.MsgMgr.ReceiveChannelMessage("someTarget", "!damage", 8, 0, 100); // ASSERT }
internal void DispatchServerCommand(ZonePlayer zp, ServerCommand cmd, Dictionary<string, string> args) { switch (cmd) { case ServerCommand.Zone: Zone zone; using (EmuDataContext dbCtx = new EmuDataContext()) { dbCtx.ObjectTrackingEnabled = false; zone = dbCtx.Zones.SingleOrDefault(z => z.ShortName == args["name"]); } if (zone != null) MovePlayer(zp, zone.ZoneID, 0u, zone.SafeX, zone.SafeY, zone.SafeZ, 0.0f, ZoneMode.ZoneToSafeCoords); else zp.MsgMgr.SendSpecialMessage(MessageType.Default, "Unable to locate zone " + args["name"]); break; case ServerCommand.GoTo: break; default: break; } }
//[TestMethod()] public void Weapon_Should_Equip_Correctly() { // ARRANGE Character toon = null; InventoryItem invItem = new InventoryItem(); Item item = null; // Get the client's character info string charName = "Badass"; DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Character>(c => c.Account); dlo.LoadWith<Character>(c => c.Zone); dlo.LoadWith<Character>(c => c.InventoryItems); dlo.LoadWith<InventoryItem>(ii => ii.Item); using (EmuDataContext dbCtx = new EmuDataContext()) { dbCtx.ObjectTrackingEnabled = false; dbCtx.LoadOptions = dlo; toon = dbCtx.Characters.SingleOrDefault(c => c.Name == charName); } ZonePlayer zp = new ZonePlayer(1, toon, 1, new Client(new System.Net.IPEndPoint(0x2414188f, 123))); // Get the inventory item we're giving to the char using (EmuDataContext dbCtx = new EmuDataContext()) { dbCtx.ObjectTrackingEnabled = false; item = dbCtx.Items.SingleOrDefault(i => i.ItemID == 5023); } invItem.Item = item; // ACT zp.AutoGiveItem(ref invItem); // ASSERT }
public void Item_Should_Stack_Correctly_In_A_Container() { // ARRANGE Character toon = null; InventoryItem invItem = new InventoryItem(); Item item = null; // Get the client's character info string charName = "Badass"; DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Character>(c => c.Account); dlo.LoadWith<Character>(c => c.Zone); dlo.LoadWith<Character>(c => c.InventoryItems); dlo.LoadWith<InventoryItem>(ii => ii.Item); using (EmuDataContext dbCtx = new EmuDataContext()) { dbCtx.ObjectTrackingEnabled = false; dbCtx.LoadOptions = dlo; toon = dbCtx.Characters.SingleOrDefault(c => c.Name == charName); } ZonePlayer zp = new ZonePlayer(1, toon, 1, new Client(new System.Net.IPEndPoint(0x2414188f, 123))); // Get the inventory item (bone chips) we're giving to the char using (EmuDataContext dbCtx = new EmuDataContext()) { dbCtx.ObjectTrackingEnabled = false; item = dbCtx.Items.SingleOrDefault(i => i.ItemID == 13073); } invItem.Item = item; invItem.Charges = 1; // Giving one bone chip // ACT if (!zp.AutoGiveItem(ref invItem)) zp.GiveItem(invItem, (int)InventorySlot.Cursor); }
//[TestMethod()] public void Inventory_Should_Have_Item_In_Correct_Spot_After_Moving_A_Container() { // ARRANGE // Get the client's character info string charName = "Littlebadwiz"; Character toon = null; DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Character>(c => c.Account); dlo.LoadWith<Character>(c => c.Zone); dlo.LoadWith<Character>(c => c.InventoryItems); dlo.LoadWith<InventoryItem>(ii => ii.Item); using (EmuDataContext dbCtx = new EmuDataContext()) { dbCtx.ObjectTrackingEnabled = false; dbCtx.LoadOptions = dlo; toon = dbCtx.Characters.SingleOrDefault(c => c.Name == charName); } ZonePlayer zp = new ZonePlayer(1, toon, 1, new Client(new System.Net.IPEndPoint(0x2414188f, 123))); List<uint?> itemsBefore = new List<uint?> { null, null, null, null, null, null, null, null, null, null }; List<uint?> itemsAfter = new List<uint?> { null, null, null, null, null, null, null, null, null, null }; for (int i = 321; i < 331; i++) { // track the original item ids if (zp.InvMgr[i] != null) itemsBefore[i - 321] = zp.InvMgr[i].ItemID; } // ACT zp.InvMgr.SwapItem(29, 30, (byte)0); // swap a container in the 8th inv slot to the cursor zp.InvMgr.SwapItem(30, 26, (byte)0); // then swap the container from the cursor to the 5th inv slot for (int i = 291; i < 301; i++) { // now track the current item ids if (zp.InvMgr[i] != null) itemsAfter[i - 291] = zp.InvMgr[i].ItemID; } // ASSERT for (int i = 0; i < 10; i++) Assert.IsTrue(itemsBefore[i] == itemsAfter[i]); }
private void PlayerDeath(ZonePlayer zp, Mob lastAttacker, uint spellId, byte damageType, uint damage) { _log.DebugFormat("{0} bought the farm. Fatal blow dealt by {1} with {2} damage, skill {3}, spell {4}.", zp.Name, lastAttacker.Name, damage, damageType, spellId); if (zp.IsDePopped) { _log.WarnFormat("{0} is trying to die more than once or something... is already depopped!", zp.Name); return; } _zoneSvr.SendLogoutPackets(zp.Client); // Make the become corpse packet and queue to player before Death opCode packet BecomeCorpse bc = new BecomeCorpse() { SpawnId = (uint)zp.ID, X = zp.X, Y = zp.Y, Z = zp.Z }; EQApplicationPacket<BecomeCorpse> bcPack = new EQApplicationPacket<BecomeCorpse>(AppOpCode.BecomeCorpse, bc); _zoneSvr.QueuePacketToClient(zp.Client, bcPack, true, ZoneConnectionState.All); Death d = new Death() { SpawnId = (uint)zp.ID, KillerId = lastAttacker == null ? 0u : (uint)lastAttacker.ID, CorpseId = (uint)zp.ID, BindToZoneId = zp.PlayerProfile.Binds[0].ZoneId, SpellId = spellId == 0u ? 0xFFFFFFFF : spellId, AttackSkillId = spellId != 0u ? (uint)0xe7 : damageType, Damage = damage }; EQApplicationPacket<Death> dPack = new EQApplicationPacket<Death>(AppOpCode.Death, d); _zoneSvr.QueuePacketToClients(lastAttacker, dPack, false); RemoveFromAllTargets(zp); // orig emu removed self from its own hate list... don't understand why you'd do that, so skipping if (!zp.IsGM) { // GM's don't get penalized from dieing... muwhahaha // Figure out how much xp we lose, if any int xpLoss = 0; if (zp.Level >= WorldServer.ServerConfig.LevelDeathDoesXPLoss) // TODO: don't lose xp when we have become an NPC? xpLoss = (int)(zp.XP * WorldServer.ServerConfig.XPLossModifier); if (lastAttacker is ZonePlayer) // TODO: also check if the attacker is a pet owned by a player (no xp loss in that case) xpLoss = 0; // Don't lose xp when dueling _log.DebugFormat("{0} is losing {1} xp due to his ass died.", zp.Name, xpLoss); zp.XP -= xpLoss; // TODO: fade buffs (ALL - good and bad) // TODO: unmem spells (don't send packets) PlayerCorpse pc = new PlayerCorpse(zp, xpLoss, _zoneSvr.HasGraveyard()); AddCorpse(pc); _zoneSvr.QueuePacketToClients(zp, bcPack, true); // send the become corpse packet to all players in the zone } else { // TODO: fade just detrimental buffs } // Send player to bind point _zoneSvr.MovePlayer(zp, zp.PlayerProfile.Binds[0].ZoneId, 0, zp.PlayerProfile.Binds[0].X, zp.PlayerProfile.Binds[0].Y, zp.PlayerProfile.Binds[0].Z, zp.PlayerProfile.Binds[0].Heading, ZoneMode.ZoneToBindPoint); }
public MessagingManager(ZonePlayer zp) { _zp = zp; LoadCommandHandlers(); }
internal void MovePlayer(ZonePlayer zp, uint zoneId, uint instanceId, float x, float y, float z, float heading, ZoneMode zm) { if (zoneId == this.Zone.ZoneID) { // TODO: also test if the instance id is equal to this zone's if (zp.IsAIControlled) { // TODO: quick move the pc return; } // TODO: if they have a pet, quick move the pet to the new spot as well } zp.ZoneMode = zm; switch (zm) { case ZoneMode.EvacToSafeCoords: case ZoneMode.ZoneToSafeCoords: // TODO: start cheat timer? zp.ZoneSummonX = x; zp.ZoneSummonY = y; zp.ZoneSummonZ = z; zp.Heading = heading; break; case ZoneMode.GMSummon: zp.MsgMgr.SendSpecialMessage(MessageType.Default, "You have been summoned by a GM!"); zp.ZoneSummonX = x; zp.ZoneSummonY = y; zp.ZoneSummonZ = z; zp.Heading = heading; zp.ZoneSummonID = (ushort)zoneId; break; case ZoneMode.Solicited: zp.ZoneSummonX = x; zp.ZoneSummonY = y; zp.ZoneSummonZ = z; zp.Heading = heading; zp.ZoneSummonID = (ushort)zoneId; break; case ZoneMode.ZoneToBindPoint: zp.ZoneId = (ushort)zoneId; zp.X = x; zp.Y = y; zp.Z = z; zp.Heading = heading; _log.InfoFormat("Player {0} has died and will be zoned to bind point in zone {1} at LOC x={2}, y={3}, z={4}", zp.Name, zoneId, x, y, z); ZonePlayerToBind zptb = new ZonePlayerToBind(zoneId, x, y, z, heading, "Bind Location"); EQRawApplicationPacket zptbPack = new EQRawApplicationPacket(AppOpCode.ZonePlayerToBind, zp.Client.IPEndPoint, zptb.Serialize()); QueuePacketToClient(zp.Client, zptbPack, true, ZoneConnectionState.All); return; case ZoneMode.Unsolicited: throw new NotSupportedException("This type of player moving not supported yet. Implement it!"); //break; case ZoneMode.GateToBindPoint: throw new NotSupportedException("This type of player moving not supported yet. Implement it!"); //break; case ZoneMode.SummonPC: zp.MsgMgr.SendSpecialMessage(MessageType.Default, "You have been summoned!"); throw new NotSupportedException("This type of player moving not supported yet. Implement it!"); //break; } // Handle Packet sending wasn't handled yet if we've gotten this far, so handle it now if (zm == ZoneMode.Solicited || zm == ZoneMode.ZoneToSafeCoords) { RequestClientZoneChange rczc = new RequestClientZoneChange() { ZoneId = (ushort)zoneId, X = x, Y = y, Z = z, Heading = heading, InstanceId = (ushort)instanceId, Type = 0x01 // Might be meaningless... noted as an "observed value" }; EQApplicationPacket<RequestClientZoneChange> rczcPack = new EQApplicationPacket<RequestClientZoneChange>(AppOpCode.RequestClientZoneChange, rczc); QueuePacketToClient(zp.Client, rczcPack, true, ZoneConnectionState.Connected); } }