Portal-Zone Gothic-Zone Gothic II-Zone Gothic 3-Zone Gothic 4-Zone Modifikationen-Zone Download-Zone Foren-Zone RPG-Zone Almanach-Zone Spirit of Gothic

 

Ergebnis 1 bis 2 von 2
  1. Beiträge anzeigen #1 Zitieren
    Apprentice
    Registriert seit
    May 2017
    Beiträge
    38
     
    LootaBox ist offline

    Transfer items to/from chest

    Hi,

    I have this script for moving items from one NPC to another, which works fine:

    Code:
    FUNC void B_TransferInventory(var C_Npc giver, var C_Npc taker)
    {
        var int itemInstance;
        var int slotNr;
        var int count;
    
        repeat(itemCategory, INV_CAT_MAX); var int itemCategory;
            slotNr = 0;
            count = Npc_GetInvItemBySlot(giver, itemCategory, slotNr);
    
            while(count > 0);
                itemInstance = Hlp_GetInstanceID(item);
                CreateInvItems(taker, itemInstance, count);
                NPC_RemoveInvItems(giver, itemInstance, count);
                count = Npc_GetInvItemBySlot(giver, itemCategory, slotNr);
            end;
        end;
    };
    (Based on this)
    (I plan on using the slotNr to ignore certain items in the future)

    Can I adjust this or do something similar to transfer items to/from a chest (NPC <=> chest)?

    Thanks in advance!

  2. Beiträge anzeigen #2 Zitieren
    now also in your universe  Avatar von Milky-Way
    Registriert seit
    Jun 2007
    Beiträge
    15.246
     
    Milky-Way ist offline
    Zitat Zitat von LootaBox Beitrag anzeigen
    Hi,

    I have this script for moving items from one NPC to another, which works fine:

    Code:
    FUNC void B_TransferInventory(var C_Npc giver, var C_Npc taker)
    {
        var int itemInstance;
        var int slotNr;
        var int count;
    
        repeat(itemCategory, INV_CAT_MAX); var int itemCategory;
            slotNr = 0;
            count = Npc_GetInvItemBySlot(giver, itemCategory, slotNr);
    
            while(count > 0);
                itemInstance = Hlp_GetInstanceID(item);
                CreateInvItems(taker, itemInstance, count);
                NPC_RemoveInvItems(giver, itemInstance, count);
                count = Npc_GetInvItemBySlot(giver, itemCategory, slotNr);
            end;
        end;
    };
    (Based on this)
    (I plan on using the slotNr to ignore certain items in the future)

    Can I adjust this or do something similar to transfer items to/from a chest (NPC <=> chest)?

    Thanks in advance!
    yes, just use
    Code:
    Mob_CreateItems(mobname, itemInstance, count);
    instead of CreateInvItems to move the items from the npc to a chest. mobname should be a string (e.g. as an argument to your function instead of the c_npc taker). You'll have to give the chest a name in the Spacer.

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
Impressum | Link Us | intern
World of Gothic © by World of Gothic Team
Gothic, Gothic 2 & Gothic 3 are © by Piranha Bytes & Egmont Interactive & JoWooD Productions AG, all rights reserved worldwide