public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client) { String animation = ""; byte start = 0; int plID = 0; stream.Read(out plID); stream.Read(out animation); stream.Read(out start); if (plID == 0 || !sWorld.VobDict.ContainsKey(plID)) { throw new Exception("Vob not found!"); } Vob vob = sWorld.VobDict[plID]; if (!(vob is NPCProto)) { throw new Exception("Vob is not a NPC!"); } NPCProto npcProto = (NPCProto)vob; if (start == 1 && !npcProto.AnimationList.Contains(animation)) { npcProto.AnimationList.Add(animation); } else if (start == 0 && npcProto.AnimationList.Contains(animation)) { npcProto.AnimationList.Remove(animation); } else if (start == 2) { npcProto.Overlays.Add(animation); } else if (start == 3) { npcProto.Overlays.Remove(animation); } else if (start == 4) { npcProto.Overlays.Clear(); } else if (start == 5 && vob.Address == 0) { npcProto.AnimationList.Clear(); } if (vob.Address == 0) { return; } Process process = Process.ThisProcess(); oCNpc npc = new oCNpc(process, vob.Address); zString str = zString.Create(process, animation); if (start == 1) { npc.GetModel().StartAnimation(str); } else if (start == 0) { npc.GetModel().StopAnimation(str); } else if (start == 2) { npc.ApplyOverlay(str); } else if (start == 3) { npc.RemoveOverlay(str); } else if (start == 4) { zCArray <zString> overlays = npc.ActiveOverlays; int size = overlays.Size; for (int i = size - 1; i >= 0; i--) { npc.RemoveOverlay(overlays.get(i)); } } else if (start == 5) { foreach (String iAnim in npcProto.AnimationList) { zString iStr = zString.Create(process, iAnim); npc.GetModel().StopAnimation(iStr); iStr.Dispose(); } npcProto.AnimationList.Clear(); } str.Dispose(); }
public override void Spawn(String map, Vec3f position, Vec3f direction) { this.Map = map; this.Position = position; this.Direction = direction; spawned = true; if (this.Address != 0) { return; } if (this.Map != Player.Hero.Map) { return; } Process process = Process.ThisProcess(); oCNpc npc = oCObjectFactory.GetFactory(process).CreateNPC("OTHERS_NPC"); this.Address = npc.Address; sWorld.SpawnedVobDict.Add(npc.Address, this); if (npc.MagBook == null || npc.MagBook.Address == 0) { npc.MagBook = oCMag_Book.Create(process); npc.MagBook.SetOwner(npc); } setHideNames(this.hideName); for (int i = 0; i < this.Attributes.Length; i++) { npc.setAttributes((byte)i, this.Attributes[i]); } for (int i = 0; i < this.TalentSkills.Length; i++) { npc.SetTalentSkill(i, this.TalentSkills[i]); } for (int i = 0; i < this.TalentValues.Length; i++) { npc.SetTalentValue(i, this.TalentValues[i]); } for (int i = 0; i < this.Hitchances.Length; i++) { npc.SetHitChances(i, this.Hitchances[i]); } npc.SetVisual(this.Visual); npc.SetAdditionalVisuals(BodyMesh, bodyTex, skinColor, HeadMesh, headTex, teethTex, -1); //npc.HumanAI = new oCAiHuman(process, 0); //npc.AniCtrl = new oCAniCtrl_Human(process, 0); this.setDirection(direction); //Enable(Position); foreach (Item it in itemList) { this.addItemToContainer(it); } foreach (Item it in EquippedList) { if (!it.ItemInstance.MainFlags.HasFlag(MainFlags.ITEM_KAT_ARMOR) && !it.ItemInstance.MainFlags.HasFlag(MainFlags.ITEM_KAT_FF) && !it.ItemInstance.MainFlags.HasFlag(MainFlags.ITEM_KAT_NF)) { hNpc.blockSendEquip = true; npc.Equip(new oCItem(process, it.Address)); } } //if (this.Armor != null) // setArmor(this.Armor); if (this.Weapon != null) { setWeapon(this.Weapon); } if (this.RangeWeapon != null) { setRangeWeapon(this.RangeWeapon); } for (int i = 0; i < Slots.Length; i++) { if (Slots[i] != null) { setSlotItem(i, Slots[i]); } } foreach (String act in Overlays) { zString overlayStr = zString.Create(process, act); npc.ApplyOverlay(overlayStr); overlayStr.Dispose(); } setScale(this.Scale); setFatness(this.Fatness); setWeaponMode(this.WeaponMode); if (enabled) { Enable(this.Position); } this.setInvisible(this.IsInvisible); }