/// <summary> /// Not in use anymore! /// </summary> /// <param name="message"></param> /// <returns></returns> public static Int32 EV_CreateInteractItem(String message) { Process Process = Process.ThisProcess(); try { int address = Convert.ToInt32(message); oCNpc npc = new oCNpc(Process, Process.ReadInt(address)); oCMsgManipulate oDD = new oCMsgManipulate(Process, Process.ReadInt(address + 4)); oCMobInter mobinter = npc.GetInteractMob(); MobInter mobInt = null; if (sWorld.SpawnedVobDict.ContainsKey(mobinter.Address)) { mobInt = (MobInter)sWorld.SpawnedVobDict[mobinter.Address]; oDD.InstanceName.Set("ITGUC_" + mobInt.UseWithItem.ID); zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "MobInter-Setted! " + mobInt.UseWithItem.ID, 0, "Program.cs", 0); } else { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Not founded: MobInter! " + mobinter.Address, 0, "Program.cs", 0); } } catch (Exception ex) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Exception: " + ex.Message + " " + ex.StackTrace + " " + ex.Source, 0, "Program.cs", 0); } return(0); }
public static Int32 oCItemContainer_Remove(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)); int itemIndex = process.ReadInt(address + 4); int amount = process.ReadInt(address + 8); String itemName = zCParser.getParser(Process.ThisProcess()).GetSymbol(itemIndex).Name.Value; oCMobContainer mC = new oCMobContainer(process, player.GetInteractMob().Address); if (player.Inventory.Address != oIC.Address)//Use this only with the hero! { return(0); } Item it = Player.Hero.HasItem(ItemInstance.getIndex(itemName)); if (it == null)//Item was not found! { return(0); } Player.Hero.removeItem(it, amount); player.RemoveFromInv(new oCItem(Process.ThisProcess(), it.Address), amount); BitStream stream = Program.client.sentBitStream; stream.Reset(); stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM); stream.Write((byte)NetworkID.ItemRemovedByUsing); 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); zERROR.GetZErr(process).Report(2, 'G', "XXXX-Removed Item, Item: " + itemName + " 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 void Write(NPCProto proto) { if (proto.Address == 0) { return; } Process process = Process.ThisProcess(); oCNpc npc = new oCNpc(process, proto.Address); if (npc.AniCtrl.Address == 0) { return; } NPCChangedFlags changeFlags = 0; oCItem iArmor = npc.GetEquippedArmor(); Item armor = null; oCItem iWeapon = npc.GetEquippedMeleeWeapon(); Item weapon = null; oCItem iRangeWeapon = npc.GetEquippedRangedWeapon(); Item rangeWeapon = null; Vob focusVobID = null; NPCProto enemyVobID = null; MobInter MobInterID = null; int mobInterAddress = npc.GetInteractMob().Address; if (npc.FocusVob.Address != 0 && sWorld.SpawnedVobDict.ContainsKey(npc.FocusVob.Address)) { focusVobID = sWorld.SpawnedVobDict[npc.FocusVob.Address]; } if (npc.Enemy.Address != 0 && sWorld.SpawnedVobDict.ContainsKey(npc.Enemy.Address)) { enemyVobID = (NPCProto)sWorld.SpawnedVobDict[npc.Enemy.Address]; } if (mobInterAddress != 0 && sWorld.SpawnedVobDict.ContainsKey(mobInterAddress)) { MobInterID = (MobInter)sWorld.SpawnedVobDict[mobInterAddress]; } Item selectedSpell = null; if (npc.MagBook != null && npc.MagBook.Address != 0) { oCItem spellItem = npc.MagBook.GetSpellItem(npc.MagBook.GetSelectedSpellNr()); if (spellItem != null && spellItem.Address != 0) { Vob spellVob = null; sWorld.SpawnedVobDict.TryGetValue(spellItem.Address, out spellVob); selectedSpell = (Item)spellVob; } } if (iArmor.Address != 0) { armor = (Item)sWorld.SpawnedVobDict[iArmor.Address]; } if (iWeapon.Address != 0) { weapon = (Item)sWorld.SpawnedVobDict[iWeapon.Address]; } if (iRangeWeapon.Address != 0) { rangeWeapon = (Item)sWorld.SpawnedVobDict[iRangeWeapon.Address]; } int weaponMode = npc.WeaponMode; Item[] SlotItems = new Item[9]; for (int i = 0; i < SlotItems.Length; i++) { oCItem slItem = npc.GetSlotItem(oCNpc.getSlotString(process, i)); if (slItem.Address != 0 && sWorld.SpawnedVobDict.ContainsKey(slItem.Address)) { SlotItems[i] = (Item)sWorld.SpawnedVobDict[slItem.Address]; } } bool isdead = false; if (npc.IsDead() > 0) { isdead = true; } bool isUnconscious = false; if (npc.IsUnconscious() > 0) { isUnconscious = true; } bool isSwimming = false; if (npc.AniCtrl.GetWalkModeString() == null || npc.AniCtrl.GetWalkModeString().Trim().ToLower().Length == 0) { isSwimming = true; } zString str = npc.GetSectorNameVobIsIn(); String portalRoom = ""; if (str.Address != 0) { portalRoom = str.Value.Trim().ToLower(); } //Setting ChangeFlags: if (proto.Armor != armor) { changeFlags |= NPCChangedFlags.EQUIP_ARMOR; } if (proto.Weapon != weapon) { changeFlags |= NPCChangedFlags.EQUIP_NW; } if (proto.RangeWeapon != rangeWeapon) { changeFlags |= NPCChangedFlags.EQUIP_RW; } if (proto.WeaponMode != weaponMode) { changeFlags |= NPCChangedFlags.WeaponMode; } for (int i = 0; i < SlotItems.Length; i++) { if (proto.Slots[i] != SlotItems[i]) { changeFlags |= (NPCChangedFlags)((int)NPCChangedFlags.SLOT1 << i); } } if (proto.FocusVob != focusVobID) { changeFlags |= NPCChangedFlags.VOBFOCUS; } if (proto.Enemy != enemyVobID) { changeFlags |= NPCChangedFlags.ENEMYFOCUS; } if (proto.MobInter != MobInterID) { changeFlags |= NPCChangedFlags.MOBINTERACT; } if (proto.IsDead != isdead) { changeFlags |= NPCChangedFlags.ISDEAD; } if (proto.IsUnconcious != isUnconscious) { changeFlags |= NPCChangedFlags.ISUNCONSCIOUS; } if (proto.IsSwimming != isSwimming) { changeFlags |= NPCChangedFlags.ISSWIMMING; } if (!proto.PortalRoom.Equals(portalRoom)) { changeFlags |= NPCChangedFlags.PORTALROOM; } if (selectedSpell != proto.ActiveSpell) { changeFlags |= NPCChangedFlags.ACTIVE_SPELL; } if (changeFlags == 0) { return; } //zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "ChangeFlags: " + changeFlags, 0, "Client.cs", 0); //Writing Data: BitStream stream = Program.client.sentBitStream; stream.Reset(); stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM); stream.Write((byte)NetworkID.NPCUpdateMessage); stream.Write(proto.ID); stream.Write((int)changeFlags); //Equipment: if (changeFlags.HasFlag(NPCChangedFlags.EQUIP_ARMOR)) { proto.Armor = armor; if (proto.Armor == null) { stream.Write(0); } else { stream.Write(proto.Armor.ID); } } if (changeFlags.HasFlag(NPCChangedFlags.EQUIP_NW)) { proto.Weapon = weapon; if (proto.Weapon == null) { stream.Write(0); } else { stream.Write(proto.Weapon.ID); } } if (changeFlags.HasFlag(NPCChangedFlags.EQUIP_RW)) { proto.RangeWeapon = rangeWeapon; if (proto.RangeWeapon == null) { stream.Write(0); } else { stream.Write(proto.RangeWeapon.ID); } } if (changeFlags.HasFlag(NPCChangedFlags.WeaponMode)) { proto.WeaponMode = weaponMode; stream.Write(weaponMode); } for (int i = 0; i < SlotItems.Length; i++) { if (changeFlags.HasFlag((NPCChangedFlags)((int)NPCChangedFlags.SLOT1 << i))) { proto.Slots[i] = SlotItems[i]; if (SlotItems[i] == null) { stream.Write(0); } else { stream.Write(SlotItems[i].ID); } } } if (changeFlags.HasFlag(NPCChangedFlags.VOBFOCUS)) { proto.FocusVob = focusVobID; if (focusVobID == null) { stream.Write(0); } else { stream.Write(focusVobID.ID); } } if (changeFlags.HasFlag(NPCChangedFlags.ENEMYFOCUS)) { proto.Enemy = enemyVobID; if (enemyVobID == null) { stream.Write(0); } else { stream.Write(enemyVobID.ID); } } if (changeFlags.HasFlag(NPCChangedFlags.MOBINTERACT)) { proto.MobInter = MobInterID; if (MobInterID == null) { stream.Write(0); } else { stream.Write(MobInterID.ID); } } if (changeFlags.HasFlag(NPCChangedFlags.ISDEAD)) { proto.IsDead = isdead; stream.Write(proto.IsDead); } if (changeFlags.HasFlag(NPCChangedFlags.ISUNCONSCIOUS)) { proto.IsUnconcious = isUnconscious; stream.Write(proto.IsUnconcious); } if (changeFlags.HasFlag(NPCChangedFlags.ISSWIMMING)) { proto.IsSwimming = isSwimming; stream.Write(proto.IsSwimming); } if (changeFlags.HasFlag(NPCChangedFlags.PORTALROOM)) { proto.PortalRoom = portalRoom; stream.Write(proto.PortalRoom); } if (changeFlags.HasFlag(NPCChangedFlags.ACTIVE_SPELL)) { proto.ActiveSpell = selectedSpell; if (proto.ActiveSpell == null) { stream.Write(0); } else { stream.Write(proto.ActiveSpell.ID); } } zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Getted ChangeFlags: " + changeFlags, 0, "Client.cs", 0); Program.client.client.Send(stream, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true); }
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); }