public static byte[] CastSpell(short spellID, short spellGraphicID, IEntity caster, IEntity target) { // caster always has to be a npc/mob or human // Target can be item, or npc/mob/human if (target is Item) { BaseGameItem b = target as BaseGameItem; Console.WriteLine("We wanna cast Spell {0}, with Spellgraphic {1}, on item id {2} Name {3}.", spellID, spellGraphicID, b.GameID, b.Name); } else if (target is Mobile) { if (target is Mob)// nah we are a npc or mob { Mob b = target as Mob; Console.WriteLine("We wanna cast Spell {0}, with Spellgraphic {1}, on Monster id {2} Name {3}.", spellID, spellGraphicID, b.GameID, b.Name); } else if (target is NPC) { NPC b = target as NPC; Console.WriteLine("We wanna cast Spell {0}, with Spellgraphic {1}, on NPC id {2} Name {3}.", spellID, spellGraphicID, b.GameID, b.Name); } } else if (target is Character) { Character b = target as Character; Console.WriteLine("We wanna cast Spell {0}, with Spellgraphic {1}, on Player id {2} Name {3}.", spellID, spellGraphicID, b.GameID, b.Name); } return(new byte[0]); }
public void AddEntity(IEntity entity, Account sender) { if (entity is Mobile) { Mobile m = entity as Mobile; this.Npcs.Add(m); this.RoomsIDsInUse.Add(m.GameID); } else if (entity is BaseGameItem) { // the room needs to hold it's id BaseGameItem i = entity as BaseGameItem; if (!this.Items.Contains(i)) { this.Items.Add(i); } sender.IDsInUse.Remove(i.GameID); this.RoomsIDsInUse.Add(i.GameID); Console.WriteLine("({0}) items in room {1}.", this.Items.Count, this.RoomID); } else if (entity is Character) { // Make sure we add them to room here, then if it is a character // that we add them to everyoneelse and not them, dont want 2 // of you on the screen Character c = entity as Character; for (int i = 0; i < this.Players.Count; i++) { // If it isnt you, then send a packet to add you to room Account a = ServerGlobals.GetAccountFromCharacter(this.Players[i]); //if (c != a.CurrentCharacter) // { byte[] reply = Packet.CreateCharacterRoomPacket(a, c); a.Socket.Send(ref reply); // } } if (!this.Players.Contains(c)) { this.Players.Add(c); } } else { // We do not know what to do. // Log Console.WriteLine("Unknown Entity was added to room {0}", this.RoomID); } }
public static byte[] WrappedItem(Account a, BaseGameItem item) { uint itemID = 0; PacketWriter e = new PacketWriter(); e.WriteBytes(item.Serialize()); a.IDsInUse.Add(itemID); e.WriteByte(0xFF); byte[] ew = e.GetRawPacket(); PacketWriter wrap = new PacketWriter(); wrap.WriteShort((short)ew.Length); wrap.WriteUInt32(a.CurrentCharacter.GameID); // the char it came from wrap.WriteBytes(ew); return(wrap.GetRawPacket()); }
public void UnequipItemInRoom(Account sender, uint itemID) { // Get the item BaseGameItem item = sender.CurrentCharacter.GetInventoryItem(itemID);//Managers.MySqlManager.GetItem(sender.CurrentCharacter.SqlCharId, itemID); if (item != null) { for (int i = 0; i < this.Players.Count; i++) { Account a = ServerGlobals.GetAccountFromCharacter(this.Players[i]); // Need to send the to everyone in room PacketWriter w42 = new PacketWriter(0x2A); w42.WriteUInt32(a.AccountId); w42.WriteInt32(0); w42.WriteUInt32(sender.CurrentCharacter.GameID); w42.WriteUInt32(this.RoomID); w42.WriteByte(0x08); w42.WriteUInt32(sender.CurrentCharacter.GameID); w42.WriteUInt32(item.GameID); w42.WriteByte(0x2F); w42.WriteUInt32(sender.CurrentCharacter.GameID); w42.WriteUInt32(sender.CurrentCharacter.GameID); // These are item stats ? figure them out //w42.WriteBytes(new byte[] { 0x2D, 0x00, 0x00, 0x00, 0x21, 0xFF }); // sets max hp, use the chars current if no change w42.WriteUInt32((uint)sender.CurrentCharacter.TotalHP); w42.WriteBytes(new byte[] { 0x21, 0xFF }); w42.WriteBytes(new byte[] { 0x00, 0x00 }); // not sure // w42.WriteBytes(new byte[] { 0x00, 0x6A }); //w42.WriteBytes(new byte[4]); byte[] p42 = w42.ToArray(); a.Socket.Send(ref p42); item.Equipped = false; } // bool un = Managers.MySqlManager.EquipItem(sender.CurrentCharacter.SqlCharId, item.CurrentGameID, true); // if (!un) Console.WriteLine("Failed to unequip"); } else { Console.WriteLine("Item was null."); } }
public static Item CastFromBaseItem(BaseGameItem item) { Item i = new Item(); i.ContainedItems = item.ContainedItems; i.Enchantments = item.Enchantments; i.Equipped = item.Equipped; i.GameID = item.GameID; i.GraphicID = item.GraphicID; i.IsContainer = item.IsContainer; i.IsInRoom = item.Location != null; i.IsInventoryItem = item.IsInventoryItem; i.Color = item.Color; i.Name = item.Name; i.Location = item.Location; i.LookAt = item.LookAt; i.SqlID = item.SqlID; i.SqlOwnerID = item.SqlOwnerID; i.Type = item.Type; return(i); }
public ItemAndQuantity(BaseGameItem item, int quantity) { Item = item; Quantity = quantity; }
internal LootItem(BaseGameItem item, int dropPercentage, bool isDefaultItem) { Item = item; DropPercentage = dropPercentage; IsDefaultItem = isDefaultItem; }
public ItemAndQuantity(BaseGameItem item, int quantity) { Item = item; Quantity = quantity; }
internal LootItem(BaseGameItem item, int dropPercentage, bool isDefaultItem) { Item = item; DropPercentage = dropPercentage; IsDefaultItem = isDefaultItem; }
public void EquipItemInRoom(Account sender, uint itemID) { // Get the item BaseGameItem item = sender.CurrentCharacter.GetInventoryItem(itemID);//Managers.MySqlManager.GetItem(sender.CurrentCharacter.SqlCharId, itemID); // now we pull from and equip the items from memory if (item != null) { // bool un = Managers.MySqlManager.EquipItem(sender.CurrentCharacter.SqlCharId, item.CurrentGameID); // if (!un) Console.WriteLine("Failed to equip"); // else // { item.Equipped = false; // dont forget to equip it !! for (int i = 0; i < this.Players.Count; i++) { if (sender.CurrentCharacter != this.Players[i]) { Account a = ServerGlobals.GetAccountFromCharacter(this.Players[i]); // Need to send the to everyone in room PacketWriter toRoom = new PacketWriter(0x2A); toRoom.WriteUInt32(a.AccountId); toRoom.WriteInt32(0); toRoom.WriteUInt32(sender.CurrentCharacter.GameID); toRoom.WriteUInt32(this.RoomID); toRoom.WriteByte(0x3F); PacketWriter it = new PacketWriter(); it.WriteBytes(item.Serialize()); it.WriteByte(0xFF); byte[] justitem = it.GetRawPacket(); toRoom.WriteShort((short)justitem.Length); toRoom.WriteUInt32(sender.CurrentCharacter.GameID); toRoom.WriteBytes(justitem); // toRoom.WriteUShort(0x00); //toRoom.WriteByte(0x00); byte[] p42 = toRoom.ToArray(); // Try to actually equip it via sql a.Socket.Send(ref p42); string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Equiproom1.txt"); File.WriteAllText(fileLocation, BitConverter.ToString(p42)); PacketWriter toRoom2 = new PacketWriter(0x2A); toRoom2.WriteUInt32(a.AccountId); toRoom2.WriteInt32(0); toRoom2.WriteUInt32(sender.CurrentCharacter.GameID); toRoom2.WriteUInt32(this.RoomID); toRoom2.WriteByte(0x07); toRoom2.WriteUInt32(sender.CurrentCharacter.GameID); toRoom2.WriteUInt32(itemID); toRoom2.WriteByte(0x2F); toRoom2.WriteUInt32(sender.CurrentCharacter.GameID); toRoom2.WriteUInt32(sender.CurrentCharacter.GameID); // These are item stats ? figure them out //w42.WriteBytes(new byte[] { 0x2D, 0x00, 0x00, 0x00, 0x21, 0xFF }); // sets max hp, use the chars current if no change toRoom2.WriteUInt32((uint)sender.CurrentCharacter.TotalHP); toRoom2.WriteBytes(new byte[] { 0x21, 0xFF }); //w42.WriteBytes(new byte[] { 0x00, 0x12 }); // not sure //w42.WriteBytes(new byte[] { 0xA1, 0xF3 }); toRoom2.WriteBytes(new byte[4]); byte[] proom2 = toRoom2.ToArray(); a.Socket.Send(ref proom2); item.Equipped = false; string fileLocation2 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Equiproom2.txt"); File.WriteAllText(fileLocation2, BitConverter.ToString(p42)); } } //} } else { Console.WriteLine("Item was null."); } }
public void RemoveEntity(IEntity entity, Account sender) { if (entity is Mobile) { Mobile m = entity as Mobile; // dunno yet this.Npcs.Remove(m); this.RoomsIDsInUse.Remove(m.GameID); } else if (entity is BaseGameItem) { BaseGameItem item = entity as BaseGameItem; this.Items.Remove(item); sender.IDsInUse.Add(item.GameID); this.RoomsIDsInUse.Remove(item.GameID); sender.CurrentCharacter.AddInventoryItem(item); /* * for (int i = 0; i < this.Players.Count; i++) * { * Account a = ServerGlobals.GetAccountFromCharacter(this.Players[i]); * if (a != null) * { * PacketWriter w = new PacketWriter(0x2D); * w.WriteUInt32(a.AccountId); * w.WriteInt32(0); * w.WriteUInt32(this.RoomID); // Room to remove from * * w.WriteUInt32(item.CurrentGameID); // obj to remove * * w.WriteBytes(new byte[] { 0x00, 0x15, 0x00, 0x69 }); * byte[] rem = w.ToArray(); * a.Socket.Send(ref rem); * } * } */ Console.WriteLine("({0}) items in room {1}.", this.Items.Count, this.RoomID); } else if (entity is Character) { Character c = entity as Character; this.Players.Remove(c); for (int i = 0; i < this.Players.Count; i++) { Account a = ServerGlobals.GetAccountFromCharacter(this.Players[i]); if (a != null && a != sender) // do not send remove packet to remove yourself { PacketWriter w = new PacketWriter(0x2D); w.WriteUInt32(a.AccountId); w.WriteInt32(0); w.WriteUInt32(this.RoomID); // Room to remove from w.WriteUInt32(c.GameID); // obj to remove w.WriteBytes(new byte[] { 0x00, 0x15, 0x00, 0x69 }); byte[] rem = w.ToArray(); a.Socket.Send(ref rem); } } } else { // We do not know what to do. // Log Console.WriteLine("Attempted to remove Unknown Entity from room {0}", this.RoomID); } }
public void AddItem(BaseGameItem item) { this.Items.Add(item); }