Exemple #1
0
        partial void pAfterEquip(NPCSlots slot, ItemInst item)
        {
            if (!this.IsSpawned)
            {
                return;
            }

            oCNpc  gNpc  = this.BaseInst.gVob;
            oCItem gItem = item.BaseInst.gVob;

            Gothic.Types.zString node;
            bool undraw = true;
            bool ininv  = true;

            switch (slot)
            {
            case NPCSlots.OneHanded1:
                node = oCNpc.NPCNodes.Sword;
                break;

            case NPCSlots.TwoHanded:
                node = oCNpc.NPCNodes.Longsword;
                break;

            case NPCSlots.Ranged:
                node = item.ItemType == ItemTypes.WepBow ? oCNpc.NPCNodes.Bow : oCNpc.NPCNodes.Crossbow;
                break;

            case NPCSlots.Armor:
                node = oCNpc.NPCNodes.Torso;
                gItem.VisualChange.Set(item.Definition.VisualChange);
                break;

            case NPCSlots.RightHand:
                node   = oCNpc.NPCNodes.RightHand;
                undraw = false;
                break;

            case NPCSlots.LeftHand:
                node   = oCNpc.NPCNodes.LeftHand;
                undraw = false;
                break;

            default:
                return;
            }

            if (item.ModelDef.Visual.EndsWith(".ZEN"))
            {
                ininv = false;
            }

            gItem.Material = (int)item.Material;
            gNpc.PutInSlot(node, gItem, ininv);
            PlayDrawItemSound(item, undraw);
        }
        public void setSlotItem(int slot, Item item)
        {
            //zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Set Slot Item 1: " + Slots[slot] + "; NewItem: "+item + " ", 0, "NPCProto.Client.cs", 0);
            Item oldItem = Slots[slot];

            Slots[slot] = item;

            //if (oldItem == item)
            //    return;

            if (this.Address != 0)
            {
                Process process = Process.ThisProcess();
                oCNpc   npc     = new oCNpc(process, this.Address);

                if (Slots[slot] == null || oldItem != null)
                {
                    zString slotString = oCNpc.getSlotString(process, slot);
                    oCItem  oldITem    = npc.GetSlotItem(slotString);
                    if (oldITem.Address != 0)
                    {
                        npc.RemoveFromSlot(slotString, oldITem.Instanz, oldITem.Amount);
                    }
                }

                if (Slots[slot] != null)
                {
                    if (Slots[slot].Address == 0)
                    {
                        throw new Exception("Adress can't be null if player using it is spawned!");
                    }
                    //zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', "Set Slot Item: "+Slots[slot]+" "+Slots[slot].ItemInstance.Name, 0, "NPCProto.Client.cs", 0);
                    npc.PutInSlot(oCNpc.getSlotString(process, slot), new oCItem(process, Slots[slot].Address), 1);
                }
            }
        }