public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client) { int itemID, containerID; stream.Read(out itemID); stream.Read(out containerID); if (!sWorld.VobDict.ContainsKey(itemID)) { throw new Exception("ItemID was not found!: " + itemID); } if (!sWorld.VobDict.ContainsKey(containerID)) { throw new Exception("ContainerID was not found!: " + itemID); } Vob itemVob = sWorld.VobDict[itemID]; Vob containerVob = sWorld.VobDict[containerID]; if (!(itemVob is Item)) { throw new Exception("ItemVob is not an Item! " + itemVob); } if (!(containerVob is IContainer)) { throw new Exception("Container is not an IContainer! " + containerVob); } Item item = (Item)itemVob; IContainer container = (IContainer)containerVob; if (item.Container is MobContainer) { MobContainer itC = (MobContainer)item.Container; if (itC.Address != 0) { new oCMobContainer(Process.ThisProcess(), itC.Address).Remove(new oCItem(Process.ThisProcess(), item.Address)); } } else if (item.Container is NPCProto) { NPCProto itC = (NPCProto)item.Container; if (itC.Address != 0) { new oCNpc(Process.ThisProcess(), itC.Address).RemoveFromInv(new oCItem(Process.ThisProcess(), item.Address), item.Amount); } } container.addItem(item); zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Item-Change-Container message!", 0, "Program.cs", 0); }
public static Vob createVob(VobType vt) { Vob v = null; if (vt == VobType.Npc) { v = new NPC(); } else if (vt == VobType.Player) { v = new Player(); } else if (vt == VobType.Item) { v = new Item(); } else if (vt == VobType.Vob) { v = new Vob(); } else if (vt == VobType.MobInter) { v = new MobInter(); } else if (vt == VobType.MobBed) { v = new MobBed(); } else if (vt == VobType.MobContainer) { v = new MobContainer(); } else if (vt == VobType.MobDoor) { v = new MobDoor(); } else if (vt == VobType.MobSwitch) { v = new MobSwitch(); } if (v != null) { v.VobType = vt; } return(v); }
//Creates a New Dungeon, Generates it if it is not Preset. public Dungeon() { if (!deserializing) { rooms = new RoomContainer(); random = new Random(); starter = new SquareChunk(-1, 10000); //Logger.getInstance().log(SerializeThing()); //if not preset, make it. if (!GetType().Equals(typeof(PresetDungeon))) generateDungeon(); } else { entities = new MobContainer(); //deserializing = false; } }
/// <summary> /// Adds an entity into the dungeon to be rendered. /// </summary> /// <param name="entity">The entity to be added.</param> public void addEntity(Mob entity) { Logger.getInstance().log("Entity Created."); if (entities == null) entities = new MobContainer(); entities.Add(entity); }
public static Int32 oCItemContainer_Remove_2(String message) { try { int address = Convert.ToInt32(message); Process process = Process.ThisProcess(); oCNpc player = oCNpc.Player(process); oCNpc stealNPC = oCNpc.StealNPC(process); oCItemContainer oIC = new oCItemContainer(process, process.ReadInt(address)); oCItem item = new oCItem(process, process.ReadInt(address + 4)); int amount = process.ReadInt(address + 8); oCMobContainer mC = new oCMobContainer(process, player.GetInteractMob().Address); if (oIC.Address == mC.ItemContainer.Address && (item.Amount == amount || item.Amount - amount <= 0)) { mC.Remove(item); } else if ((oIC.Address == process.ReadInt(0x00AB27E0) || oIC.Address == process.ReadInt(0x00AB27DC)) && (item.Amount == amount || item.Amount - amount <= 0)) { oIC.Remove(item); zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Item stolen from npc!", 0, "hItemContainer.cs", 0); } else { item.Amount -= amount; } int containerID = 0; if (oIC.Address == mC.ItemContainer.Address) { if (!sWorld.SpawnedVobDict.ContainsKey(mC.Address)) { return(0); } Vob mobContainerVob = sWorld.SpawnedVobDict[mC.Address]; if (!(mobContainerVob is MobContainer)) { return(0); } MobContainer mobContainer = (MobContainer)mobContainerVob; containerID = mobContainer.ID; } else if (oIC.Address == process.ReadInt(0x00AB27E0) || oIC.Address == process.ReadInt(0x00AB27DC)) { if (!sWorld.SpawnedVobDict.ContainsKey(stealNPC.Address)) { return(0); } Vob sVob = sWorld.SpawnedVobDict[stealNPC.Address]; if (!(sVob is NPCProto)) { return(0); } NPCProto npc = (NPCProto)sVob; containerID = npc.ID; } if (!sWorld.SpawnedVobDict.ContainsKey(item.Address)) { return(0); } Item it = (Item)sWorld.SpawnedVobDict[item.Address]; BitStream stream = Program.client.sentBitStream; stream.Reset(); stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM); stream.Write((byte)NetworkID.ContainerItemChangedMessage); stream.Write((byte)ContainerItemChanged.itemRemoved); stream.Write(Player.Hero.ID); stream.Write(containerID); stream.Write(it.ID); stream.Write(amount); Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true); //stream.Write(item.ID); //stream.Write(amount); //Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true); zERROR.GetZErr(process).Report(2, 'G', "Removed Item, Item: " + item.ObjectName.Value + " Found: " + sWorld.SpawnedVobDict.ContainsKey(item.Address) + " Amount: " + amount, 0, "Itemsynchro.cs", 0); } catch (Exception ex) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', ex.Source + ": " + ex.Message + " " + ex.StackTrace, 0, "hItemContainer.cs", 0); } return(0); }
public static Int32 oCItemContainer_Insert(String message) { try { Process process = Process.ThisProcess(); if (!ItemContainerBlocked && itemsUntilBlock == 0) { process.Write(new byte[] { 0x33, 0xC0, 0xC2, 0x04, 0x00 }, Program.insertItemToList.oldFuncInNewFunc.ToInt32()); ItemContainerBlocked = true; } else if (itemsUntilBlock != 0) { itemsUntilBlock -= 1; } int address = Convert.ToInt32(message); oCNpc player = oCNpc.Player(process); oCItemContainer oIC = new oCItemContainer(process, process.ReadInt(address)); oCItem item = new oCItem(process, process.ReadInt(address + 4)); oCMobContainer mC = new oCMobContainer(process, player.GetInteractMob().Address); if (!sWorld.SpawnedVobDict.ContainsKey(mC.Address)) { return(0); } Vob mobContainerVob = sWorld.SpawnedVobDict[mC.Address]; if (!(mobContainerVob is MobContainer)) { return(0); } MobContainer mobContainer = (MobContainer)mobContainerVob; if (!sWorld.SpawnedVobDict.ContainsKey(item.Address))//Multislot-Item { BitStream stream = Program.client.sentBitStream; stream.Reset(); stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM); stream.Write((byte)NetworkID.ContainerItemChangedMessage); stream.Write((byte)ContainerItemChanged.itemInsertedNew); stream.Write(Player.Hero.ID); stream.Write(mobContainerVob.ID); stream.Write(ItemInstance.getIndex(item.ObjectName.Value.Trim())); Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true); } else//Normal-Item: { //mobContainer.addItem((Item)sWorld.SpawnedVobDict[item.Address]); Item it = (Item)sWorld.SpawnedVobDict[item.Address]; BitStream stream = Program.client.sentBitStream; stream.Reset(); stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM); stream.Write((byte)NetworkID.ContainerItemChangedMessage); stream.Write((byte)ContainerItemChanged.itemInsertedOld); stream.Write(Player.Hero.ID); stream.Write(mobContainerVob.ID); stream.Write(it.ID); Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true); } zERROR.GetZErr(process).Report(2, 'G', "Insert Item, Item: " + sWorld.SpawnedVobDict.ContainsKey(process.ReadInt(address + 4)) + " | " + item.Address + " | " + item.ObjectName.Value + "| " + item.Name.Value + " | " + item.Visual.Value + " |" + " Amount: " + item.Amount, 0, "Itemsynchro.cs", 0); } catch (Exception ex) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', ex.Source + ": " + ex.Message + " " + ex.StackTrace, 0, "hItemContainer.cs", 0); } return(0); }