Skip to content

02. 常规卖家与单品兜售 (ClientIntent.SELL) ​

当顾客作为卖家(ClientIntent.SELL 或 ClientIntent.SELLNBUY)进店时,顾客会在开场对话结束后将一件或多件待售物品放到柜台桌面上,由玩家决定是否出钱收购。


核心字段与铺货方法 ​

字段 / 方法类型说明
sc.clientIntentStoreClient.ClientIntent设为 StoreClient.ClientIntent.SELL(枚举值 2)或 SELLNBUY(枚举值 3)。
sc.sellPriceModifierint顾客出售商品时的要价浮动百分比(正数为溢价,负数为折扣)。
PlayerStore.Instance.AddDirectSellingItemToTablevoid在 mainDialogue 末尾的 SetEndAction 中调用,将顾客要卖的物品生成到柜台桌面。

AddDirectSellingItemToTable 参数签名 ​

csharp
PlayerStore.Instance.AddDirectSellingItemToTable(
    string itemId,        // 原版或模组注册的物品 ID,如 "aug_chip"
    bool isOwnedByPlayer, // 顾客卖给玩家时必须传 false
    bool isStolen,        // 该物品是否带有赃物标记
    bool isContraband,    // 该物品是否带有违禁品标记
    int customPrice       // 自定义售价;传 0 则按游戏物品基础价格与修饰符自动计算
);

代码示例:出售指定单品的拾荒客 ​

csharp
private static StoreClient CreateSingleItemSeller()
{
    var sc = new StoreClient
    {
        identifier = "keycard_finder",
        displayName = NpcFrameworkSdk.T("通风管拾荒者", "Vent Scavenger"),
        spriteName = SpriteDict.GetRandomScavSpriteName(),
        clientFaction = "FACTION_LOWER_LEVEL",
        clientIntent = StoreClient.ClientIntent.SELL,
        sellPriceModifier = -10 // 比市场价便宜 10%
    };

    sc.mainDialogue
        .SetText(sc.displayName, NpcFrameworkSdk.T("我在通风井底下捡到一张科研门禁卡,你要收吗?", "Found a science keycard down in the air ducts. Interested?"))
        .SetEndAction(() =>
        {
            PlayerStore.Instance?.AddDirectSellingItemToTable("sci_keycard", false, true, false, 0);
        });

    sc.acceptDealDialogue = new Dialogue()
        .SetText(sc.displayName, NpcFrameworkSdk.T("爽快!这下今晚能去喝一杯了。", "Sweet! Drinks are on me tonight."));

    sc.CompleteClientCreation(false);
    return sc;
}

Custom NPC Framework Documentation