Author Topic: Getting the item from the vendor  (Read 4572 times)

Offline BrettH

  • Acquaintance
  • *
  • Posts: 15
    • View Profile
Getting the item from the vendor
« on: January 01, 2011, 12:09:28 am »
I've searched around quite a bit and maybe I'm just being particularly dense. It's been known to happen from time to time...

Anyway, my vendor happily says he's selling me something, but he won't hand the object over, and he keeps it in his inventory (I can see him holding it.) My hands are not full (and besides there's no messaging saying he can't give it to me.)

Any suggestions?

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Getting the item from the vendor
« Reply #1 on: January 01, 2011, 12:17:43 am »
Any suggestions?

1) Please clarify which version of DS you're using.

2) Please share the code for the following:

  a) your LIB_VENDOR

  b) the specific vendor NPC

  c) the object being sold


-Crat

Offline BrettH

  • Acquaintance
  • *
  • Posts: 15
    • View Profile
Re: Getting the item from the vendor
« Reply #2 on: January 01, 2011, 11:52:56 am »
It's the 'stable version'; I haven't updated to your new release.

A) LIB_VENDOR

Code: [Select]
#ifndef l_vendor_h
#define l_vendor_h

static void create();
static void init();
mixed direct_buy_str_from_liv(string str);

mixed CanBuy(object who, object *obs);
mixed CanSell(object who, string what);

mixed eventAsk(object who, string what);
mixed eventBuy(object who, object *obs);
mixed eventSell(object who, string what);

int cmdShow(object who, string args);
int cmdBrowse(object who, string args);
int cmdAppraise(object who, string args);
int cmdPrice(object who, string args);
int GetCost(object ob, object who);
int GetValue(object ob, object who);
string SetLocalCurrency(string str);
string GetLocalCurrency();
string SetStorageRoom(string room);
string GetStorageRoom();
int SetMaxItems(int x);
int GetMaxItems();
int SetVendorType(int x);
int GetVendorType();

#endif /* l_vendor_h */

B) NPC

Code: [Select]
#include <lib.h>
#include <vendor_types.h>

inherit LIB_VENDOR;

static void create() {
    vendor::create();
    SetKeyName("Bubba");
    SetId( ({"Bubba", "vendor", "seller", "shopkeeper"}) );
    SetAdjectives( ({ "friendly, helpful, average" }) );
    SetLanguage("Common",100);
    SetDefaultLanguage("Common");
    SetShort("Bubba the Outfitter");
    SetLevel(1);
    SetLong("Bubba is a fairly average looking middle-aged man with short brown hair and muttonchop whiskers. He seems cheerful and ready to help.");
    SetGender("male");
    SetRace("human");
    SetSkill("bargaining", 1);
    SetProperty("no bump", 1);
    SetLocalCurrency("silver");
    SetStorageRoom("/realms/dis/area/room/Bubba_Storage");
    SetMaxItems(10000);
    SetVendorType(VT_ALL);
}
void init(){
    ::init();
}


C) One of the items (he didn't hand over any of them)

Code: [Select]
#include <lib.h>
#include <armor_types.h>
#include <damage_types.h>
#include <vendor_types.h>
inherit LIB_ARMOR;

static void create(){
    armor::create();
    SetKeyName("leather knee boots");
    SetId( ({"boots", "knee boots", "leather knee boots"}) );
    SetAdjectives(({"leather", "knee"}));
    SetShort("a pair of leather knee boots");
    SetLong("These boots are made of flat, stiff cowhide soles and more supple goatskin uppers. Coming up just below the knee, they are decorated with slightly pointed toes and a single lace winding up the side opening at the inside of the calf.");
    SetMass(5);  
    SetValue(0);
    SetVendorType(VT_ARMOR);
    SetArmorType(A_BOOT);
    SetProtection(KNIFE, 3);
    SetProtection(COLD, 2);
    SetRestrictLimbs(({"left foot","right foot"}));
}
void init(){
    ::init();
}

I do want these to be free to newbs, but I tried regular pricing also and it didn't make a difference.

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Getting the item from the vendor
« Reply #3 on: January 01, 2011, 02:46:01 pm »
It's the 'stable version'; I haven't updated to your new release.

Please copy and paste the output of this command:

version

Offline Raudhrskal

  • BFF
  • ***
  • Posts: 214
  • The MUD community needs YOUR help!
    • View Profile
Re: Getting the item from the vendor
« Reply #4 on: January 01, 2011, 03:37:49 pm »
And you uploaded ds/lib/lib/include/vendor.h, not  ds/lib/lib/vendor.c ... tho, if you didn't modify it, you don't have to. So, obvious question, did you modify vendor.c at all?
I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...

Offline BrettH

  • Acquaintance
  • *
  • Posts: 15
    • View Profile
Re: Getting the item from the vendor
« Reply #5 on: January 01, 2011, 03:56:16 pm »
Did not modify vendor.c at all.

Version: FluffOS v2.18-ds07

And yeah. Sorry for the noobness, I appreciate your patience.

Code: [Select]
#include <lib.h>
#include <armor_types.h>
#include <vendor_types.h>
#include <daemons.h>
#include "/lib/include/vendor.h"

inherit LIB_SENTIENT;
inherit LIB_MANYCOINS;

private static int MaxItems, VendorType, bargain;
private static string StorageRoom, LocalCurrency;
private static mapping Costs, Values;

static void create(){
    sentient::create();
    Costs = ([]);
    Values = ([]);
    LocalCurrency = "gold";
    VendorType = VT_TREASURE;
    MaxItems = 40;
}

mixed direct_buy_str_from_liv(string str){
    return CanSell(this_player(), str);
}

int indirect_sell_obj_to_liv(){ return 1; }

int indirect_sell_obs_to_liv(){ return 1; }

int CanCarry(int amount){ return 1; }

    mixed CanBuy(object who, object *obs){
        if( !load_object(StorageRoom) )
            return "There is a bug with the vendor's storage, please report it.";
        return 1;
    }

    mixed CanSell(object who, string what){
        if( !load_object(StorageRoom) )
            return "There is a bug with the vendor's storage, please report it.";
        return 1;
    }

mixed eventBuy(object who, object *obs){
    object *tmp;
    object sroom, ob;
    int cost;

    sroom = load_object(StorageRoom);
    if( sizeof(all_inventory(sroom)) > GetMaxItems() ){
        eventForce("say I am having trouble getting rid of the things I "
                "have to sell right now.");
        return 1;
    }
    if( !sizeof(obs) ){
        eventForce("say you have nothing to sell!");
        return 1;
    }
    tmp = ({});
    foreach(ob in obs){
        int value;

        if( !(ob->GetShort()) ) continue;
        if( !(ob->GetVendorType() & GetVendorType()) ){
            eventForce("say I do not buy things like " +
                    ob->GetShort());
            continue;
        }
        cost = to_int(ob->GetBaseCost(GetLocalCurrency()));
        value = to_int(ceil(GetValue(ob, who)));
        if(ob->GetValue()) bargain = 1;
        else bargain = 0;
        if(!bargain) value = cost;

        if( !cost || cost < 1 || !value || value < 1){
            eventForce("say " + ob->GetShort() + " is worthless!");
            continue;
        }
        cost = cost / 2;
        value = value / 2;
        if(!cost) cost = 1;
        if(!value) value = 1;
        if( !(ob->CanSell(who)) ){
            eventForce("say You cannot sell " + ob->GetShort() +".");
            continue;
        }
        if( sizeof(filter(all_inventory(sroom),
                        (: $1->GetShort() == $(ob)->GetShort() :)))
                > 3 ){
            if( this_player()->AddCurrency(GetLocalCurrency(),value) == -1 ){
                eventForce("say you cannot carry "+value+" "+
                        GetLocalCurrency()+"!");
                ob->eventMove(environment());
                continue;
            }
            eventForce("say " + ob->GetShort() + "! Great!");
            tell_player(this_player(),GetShort()+" gives you "+value+
                    " "+GetLocalCurrency()+".");
            if(bargain) who->AddSkillPoints("bargaining", value*5);
            message("my_action", "You sell " + ob->GetShort() + ".", who);
            message("other_action", capitalize(who->GetKeyName()) + " sells " +
                    ob->GetShort() + ".", environment(),
                    ({ who, this_object() }));
            ob->eventDestruct();
            return 1;
        }
        eventForce("say " + ob->GetShort() + "! Excellent!");
        tell_player(this_player(),GetShort()+" pays you "+value+
                " "+GetLocalCurrency()+".");

        if( !(ob->eventMove(sroom)) ){
            eventForce("say I cannot seem to carry that");
            return 1;
        }
        if( this_player()->AddCurrency(GetLocalCurrency(), value) == -1 ){
            eventForce("say you cannot carry "+value+" "+
                    GetLocalCurrency()+"!");
            ob->eventMove(environment());
            continue;
        }
        if(bargain) who->AddSkillPoints("bargaining", value*5);
        tmp += ({ ob });
        message("my_action", "You sell " + ob->GetShort() + ".", who);
        message("other_action", capitalize(who->GetKeyName()) + " sells " +
                ob->GetShort() + ".", environment(),
                ({ who, this_object() }));
    }
    if( !sizeof(tmp) )
        eventForce("say I am sorry, " + capitalize(who->GetKeyName()) + ", "
                "that we could not come to a better agreement.");
    else map(tmp, function(object ob){
            if( ob->GetDestroyOnSell() )
            ob->eventDestruct();
            });
    return 1;
}

int cmdShow(object who, string args){
    object ob, sroom;
    int x;

    if( !args || args == "" ){
        eventForce("say show you what?");
        return 1;
    }
    if( !(sroom = load_object(StorageRoom)) ){
        eventForce("say I am having troubles right now");
        return 1;
    }
    if( x = to_int(args) ){
        object *obs;
        object *obs2;
        string *list2;
        int maxi;

        x--;
        obs = all_inventory(sroom);
        maxi = sizeof(obs);
        list2 = ({(obs[0]->GetKeyName())});
        for(int counter = 1;counter < maxi;++counter){
            if(member_array((obs[counter]->GetKeyName()),list2) < 0){
                list2 += ({ ( obs[counter]->GetKeyName()) });
            }
        }
        obs2 = ({ present(list2[0],sroom) });
        maxi = sizeof(list2);
        for(int counter = 1;counter < maxi;++counter){
            obs2 += ({ present(list2[counter],sroom) });
        }
        if((x >= 0) && (x < sizeof(obs2))){
            ob = obs2[x];
        }
    }
    else ob = present(args = lower_case(args), sroom);
    if( !ob ){
        eventForce("say I have no such thing to show you");
        return 1;
    }
    message("other_action", capitalize(GetKeyName())+" shows you "+
            ob->GetShort()+".", who);
    message("system", ob->GetLong(), who);
    return 1;
}

int cmdBrowse(object who, string args){
    object *obs;
    object *obs2;
    string *list;
    object sroom;
    int i, ii, maxi, number;

    if( !args || args == "" ) args = "all";
    if( !(sroom = load_object(StorageRoom)) ){
        eventForce("say I am having terrific difficulties today");
        return 1;
    }
    if(!(maxi = sizeof(obs = filter(all_inventory(sroom), (: !userp($1) :))))){
        eventForce("say I have nothing to sell right now.");
        return 1;
    }
    list = ({ "item #  Description                         Price", "" });
    obs2 = ({});
    foreach(object tempob in obs){
        string *base_names = ({});
        foreach( object tempob2 in obs2 ){
            base_names += ({ base_name(tempob2) });
        }
        if(member_array(base_name(tempob), base_names) == -1){
            obs2 += ({ tempob });
        }
    }
    maxi = sizeof(obs2);
    i = this_player()->GetScreen()[0];
    if(number = to_int(args)){
        if((number > 0) && (number <= maxi)){
            int tmp;
            while( i-- ) list[1] += "_";
            if(intp(number) &&
                    (tmp = to_int(ceil(GetCost(obs2[(number - 1)],who))))){
                list += ({ sprintf("%d      %:-35s %d", number,
                            obs2[(number - 1)]->GetShort(), tmp) });
            }
            this_player()->eventPage(list);
            return 1;
        }
    }

    while( i-- ) list[1] += "_";
    for(ii=0; ii < maxi; ii++){
        int ok;
        int gat;

        ok = 0;
        gat = (obs2[ii]->GetArmorType());
        switch(args){
            case "all": ok = 1; break;
            case "weapon": case "weapons":
                break;
            case "armor": case "armors":
                if(obs2[ii]->GetVendorType() == 8){
                    ok = 1;
                }
            break;
            case "bag": case "bags":
                ok = obs2[ii]->GetProperty("bag");
            break;
            case "ring": case "rings":
                ok = gat & A_RING;
            break;
            case "glove": case "gloves":
                ok = gat & (A_GLOVE | A_LONG_GLOVE);
            break;
            case "boot": case "boots":
                ok = gat & (A_BOOT | A_LONG_BOOT);
            break;
            case "sock": case "socks":
                ok = gat & (A_SOCK | A_LONG_SOCK);
            break;
            case "helm": case "helmet":
                ok = gat & A_HELMET;
            break;
            case "visor": case "visors":
                ok = gat & A_VISOR;
            break;
            case "pants":
                ok = gat & A_PANTS;
            break;
            case "shirt": case "shirts":
                ok = gat & A_SHIRT;
            break;
            case "cloak": case "cloaks":
                ok = gat & A_CLOAK;
            break;
            case "belt": case "belts":
                ok = gat & A_BELT;
            break;
            case "vest": case "vests":
                ok = gat & A_VEST;
            break;
            case "shield": case "shields":
                ok = gat & A_SHIELD;
            break;
            case "body armor": case "body armors":
                ok = gat & A_BODY_ARMOR;
            break;
            case "blunt": case "knife": case "blade": case "projectile":
                case "blunts": case "knives": case "blades": case "projectiles":
                ok = (obs2[ii]->GetWeaponType() == args) ||
                (pluralize((obs2[ii]->GetWeaponType() || "")) == args);
            break;
            default:
            ok = obs2[ii]->id(args);
            break;
        }
        if( !ok ) continue;
        ok = GetCost(obs2[ii], who);
        if(!ii) ii = 0;
        list += ({ sprintf("%d      %:-35s %d", (ii+1), obs2[ii]->GetShort(), to_int(ok)) });
    }
    if( !sizeof(list) ){
        eventForce("frown");
        eventForce("say I have nothing like that to sell.");
        return 1;
    }
    this_player()->eventPage(list);
    return 1;
}

int cmdAppraise(object who, string args){
    object ob;
    int x,cost;

    if( !args || args == "" ){
        eventForce("say appraise what?");
        return 1;
    }
    if( !(ob = present(args = lower_case(args), who)) ){
        eventForce("say You have no such thing!");
        return 1;
    }
    if( !(ob->GetVendorType() & GetVendorType()) ){
        eventForce("say I have no use for " + ob->GetShort());
        return 1;
    }
    if( LocalCurrency != query_base_currency() ){
        cost=to_int(ob->GetBaseCost() / ECONOMY_D->__Query(LocalCurrency,"rate"));
    }
    else cost = ob->GetBaseCost();
    if(!cost || cost < 1){
        eventForce("say " + capitalize(who->GetKeyName()) + ", I will not buy "
                "that worthless thing from you.");
        return 1;
    }
    else x=cost/2;
    if(!x) x = 1;
    eventForce("say " + capitalize(who->GetKeyName()) + ", I will offer "
            "you " + x + " " + GetLocalCurrency() + " for " +
            ob->GetShort());
    return 1;
}

int cmdPrice(object who, string args){
    object *obs;
    string *list2;
    object *obs2;
    object ob, sroom;
    int x;
    int maxi;

    if( !args || args == "" ){
        eventForce("say price what?");
        return 1;
    }
    if( !(sroom = load_object(StorageRoom)) ){
        eventForce("say today is not really a good day for me");
        return 0;
    }
    obs = all_inventory(sroom);
    obs2 = ({});
    foreach(object tempob in obs){
        string *base_names = ({});
        foreach( object tempob2 in obs2 ) base_names += ({ base_name(tempob2) });
        if(!sizeof(obs2)){
            obs2 = ({tempob});
        }
        else if(member_array(base_name(tempob), base_names) == -1) obs2 += ({ tempob });
    }
    maxi = sizeof(obs2);
    if( x = to_int(args) ){
        list2 = ({(obs2[0]->GetKeyName())});
        for(int counter = 1;counter < maxi;++counter){
            if(member_array((obs2[counter]->GetKeyName()),list2) < 0){
                list2 += ({ ( obs2[counter]->GetKeyName()) });
            }
        }
        maxi = sizeof(list2);
        ob = obs2[x-1];
    }
    else ob = present(args = lower_case(args), sroom);
    if(!ob) foreach(object tempob in obs2)
        if(answers_to(args,tempob)) ob = tempob;
    if( !ob ){
        eventForce("say I have no such thing!");
        return 1;
    }
    if( !(x = to_int(ceil(GetCost(ob, this_player())))) ){
        eventForce("say that thing has no value!");
        return 1;
    }
    eventForce("say " + capitalize(who->GetKeyName()) + ", I will take " +
            x + " " + GetLocalCurrency() + " for " +
            ob->GetShort());
    return 1;
}

mixed eventAsk(object who, string str){
    object *obs;
    object ob;
    string cmd, args, tmp;
    string lang, prof, orig = str;

    lang = who->GetDefaultLanguage();
    prof = who->GetLanguageLevel(lang);
    str = translate(str, prof);
    prof = this_object()->GetLanguageLevel(lang);
    str = translate(str, prof);

    if( !str || str == "" ){
        eventForce("say what do you want from me?");
        return 1;
    }
    if( sscanf(str, "%s %s", cmd, args) != 2 ){
        cmd = str;
        args = 0;
    }
    switch(cmd){
        case "appraise":
            return cmdAppraise(who, args);

        case "browse":
            return cmdBrowse(who, args);

        case "buy":
            if( str == "all" )
                obs = filter(all_inventory(who), (: $1->CanSell() :));
            else {
                if( !(ob = present(args, who)) ){
                    eventForce("say Get out of here you cheat!");
                    eventForce("bump " + this_player()->GetKeyName());
                    return 1;
                }
                obs = ({ ob });
            }
        return eventBuy(who, obs);

        case "price":
            return cmdPrice(who, args);

        case "sell":
            if( (tmp = CanSell(who, args)) == 1 ) return eventSell(who, args);
            else if( stringp(tmp) ) eventForce("say " + tmp);
            else {
                return 0;
            }

        case "show":
            return cmdShow(who, args);

        default:
        //Thx Raudhrskal
        if(!sentient::eventAsk(who,orig))
            eventForce("say I am not quite sure what you want from me");
    }
}

mixed eventSell(object who, mixed what){
    object ob, sroom;
    object *obs;
    string *list2;
    object *obs2;
    int cost,number,maxi;

    sroom = load_object(StorageRoom);
    obs = filter(all_inventory(sroom), (: !userp($1) :));
    obs2 = ({});
    foreach(object tempob in obs){
        string *base_names = ({});
        foreach( object tempob2 in obs2 ) base_names += ({ base_name(tempob2) });
        if(!sizeof(obs2)){
            obs2 = ({tempob});
        }
        else if(member_array(base_name(tempob), base_names) == -1) obs2 += ({ tempob });
    }
    maxi = sizeof(obs2);
    if(number = to_int(what)){
        number = number - 1;
        list2 = ({(obs2[0]->GetKeyName())});
        for(int counter = 1;counter < maxi;++counter){
            if(member_array((obs2[counter]->GetKeyName()),list2) < 0){
                list2 += ({ ( obs2[counter]->GetKeyName()) });
            }
        }
        maxi = sizeof(list2);
        if((number >= 0) && (number < sizeof(obs2))){
            ob = obs2[number];
        } else {
            eventForce("say I have nothing like that to sell to you.");
            return 1;
        }     
    } else {
        if( !(ob = present(what, sroom)))
            foreach(object tempob in obs2)
                if(answers_to(what,tempob)) ob = tempob;
        if(!ob || userp(ob)){
            eventForce("say I have nothing like that to sell you.");
            return 1;
        }
    }
    cost=to_int(ob->GetBaseCost(GetLocalCurrency()));
    if(!cost || cost < 0){
        cost = 0;
        cost = to_int(ob->GetValue());
    }
    if(who->GetCurrency(GetLocalCurrency()) < cost){
        eventForce("say You don't have enough "+GetLocalCurrency()+
                " to buy that.");
        return 1;
    }
    if( !(ob->eventMove(this_object())) ){
        message("error", "An error occurred moving the object, use bug -r.",
                who);
        return 1;
    }
    eventForce("say here is " + ob->GetShort() + " for " + to_int(cost) +
            " " + GetLocalCurrency() + "!");
    eventForce("give " + ob->GetUniqueId() + " to " + who->GetKeyName());
    if( environment(ob) == this_object() ){
        eventForce("say you cannot carry that!");
        eventForce("drop " + ob->GetKeyName());
    }
    if(bargain) who->AddSkillPoints("bargaining", random(to_int(floor(cost))));
    who->AddCurrency(GetLocalCurrency(), -cost);
    return 1;
}

int GetCost(object ob, object who){
    int x, mod,cost;

    cost=ob->GetBaseCost(LocalCurrency);
    if(cost && cost > 0) return cost;

    if( Costs[who] && Costs[who][ob] ) return Costs[who][ob];   
    x = ob->GetValue(GetLocalCurrency());
    mod = who->GetSkillLevel("bargaining") - GetSkillLevel("bargaining");
    if( mod < -90 ) mod = -90;
    if( mod > 90 ) mod = 90;
    x = (x * (100 - mod))/100;
    who->AddSkillPoints("bargaining", x);
    if( !Costs[who] ) Costs[who] = ([ ob : x ]);
    else Costs[who][ob] = x;
    return x;
}

int GetValue(object ob, object who){
    int x, mod;

    if( Values[who] && Values[who][ob] ) return Values[who][ob];
    x = ob->GetValue(GetLocalCurrency());
    mod = who->GetSkillLevel("bargaining") - GetSkillLevel("bargaining");
    if( mod < -90 ) mod = -90;
    if( mod > 90 ) mod = 90;
    x = (x * (100 - -mod)) / 100;
    who->AddSkillPoints("bargaining", x);
    if( !Values[who] ) Values[who] = ([ ob : x ]);
    else Values[who][ob] = x;
    return x;
}

string SetLocalCurrency(string str){ return (LocalCurrency = str); }

string GetLocalCurrency(){ return LocalCurrency; }

string SetStorageRoom(string room){ return (StorageRoom = room); }

string GetStorageRoom(){ return StorageRoom; }

int SetMaxItems(int x){ return (MaxItems = x); }

int GetMaxItems(){ return MaxItems; }

int SetVendorType(int x){ return (VendorType = x); }

int GetVendorType(){ return VendorType; }


« Last Edit: January 01, 2011, 03:59:45 pm by BrettH »

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Getting the item from the vendor
« Reply #6 on: January 01, 2011, 06:26:49 pm »
Version: FluffOS v2.18-ds07


This is what I get:

Code: [Select]
19:25:00 Dead Souls Alpha /realms/cratylus > version
                               Dead Souls Alpha                               
Driver: FluffOS v2.21-ds01                 Library: Dead Souls 3.1a11 for unix
Up since: Sun Dec 26 12:50:48 2010       Next reboot: Tue May 24 03:50:48 2022
                  Current time: Sat Jan  1 19:25:04 2011 EST                 
19:25:04 Dead Souls Alpha /realms/cratylus >

What do you get?

Offline BrettH

  • Acquaintance
  • *
  • Posts: 15
    • View Profile
Re: Getting the item from the vendor
« Reply #7 on: January 01, 2011, 06:40:54 pm »
Code: [Select]
Driver: FluffOS v2.18-ds07                                                              Library: Dead Souls 3.0 for unix
Up since: Fri Dec 31 18:43:08 2010                                                 Next reboot: Sun May 29 10:43:08 2022

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Getting the item from the vendor
« Reply #8 on: January 02, 2011, 09:57:54 am »
Ok, tried to reproduce this problem using a vanilla 3.0 on unix, could not reproduce.

So, let's look at the logic of the problem you describe.

1) The vendor knows what object you're talking about, and clones it. This rules out permissions problems.

2) The vendor tries but fails to give you the item.

3) You do not receive an error describing the nature of the problem.

So, let's take a look at the relevant vendor code:


Code: [Select]
    eventForce("say here is " + ob->GetShort() + " for " + to_int(cost) +
            " " + GetLocalCurrency() + "!");
    eventForce("give " + ob->GetUniqueId() + " to " + who->GetKeyName());
    if( environment(ob) == this_object() ){
        eventForce("say you cannot carry that!");
        eventForce("drop " + ob->GetKeyName());
    }

So what do we see here? If the vendor tries to give the thing to you, then checks
the location of the object, and the location is itself, the vendor is supposed to
notice, mention this, and drop it. You're saying he keeps the item.

This means that if you really see him say "Here is blah blah.." and then he keeps the
object, a runtime error is happening between that line and the error messages.

My guess is that you're having a runtime occur here:

Code: [Select]
    eventForce("give " + ob->GetUniqueId() + " to " + who->GetKeyName());
For some reason, either ob->GetUniqueId() or who->GetKeyName() are
causing an error. This guess is based on the assumption that your buyer really isn't
overencumbered.

So, next you'll need to supply your runtime logs from around the time someone runs into this.

-Crat

Offline BrettH

  • Acquaintance
  • *
  • Posts: 15
    • View Profile
Re: Getting the item from the vendor
« Reply #9 on: January 02, 2011, 03:36:12 pm »
I can reproduce it at will (every time) and the /log/runtime or /log/catch files show absolutely nothing recorded when I do it. No errors of any kind are mentioned. If there's another logfile I should be looking at instead, my apologies - still learning my way around all that.

Just to show, here's what I see when I try to buy (and I tested other buying syntax, it all turns out the same.)

Code: [Select]
In Common, you ask Bubba to browse.
item #  Description                         Price
________________________________________________________________________________________________________________________
1      a pair of leather knee boots        0
/ > buy 1 from bubba

Bubba exclaims in Common, "Here is a pair of leather knee boots for 0 silver!"
/ > inventory

You are carrying the following items:
An Authority Stick
An etched and fluted steel plate harness (worn)
A sinister etched and fluted steel armet (worn)
A tattered flat-black shroud (worn)

/ > look bubba

Bubba is a fairly average looking middle-aged man with short brown hair and muttonchop whiskers. He seems cheerful and
ready to help.
The male human is in top condition.
Bubba is carrying:
A pair of leather knee boots

/ >

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Getting the item from the vendor
« Reply #10 on: January 02, 2011, 03:52:24 pm »
Ok.

In /lib/std/vendor.c, replace this:

Code: [Select]
    eventForce("say here is " + ob->GetShort() + " for " + to_int(cost) +
            " " + GetLocalCurrency() + "!");
    eventForce("give " + ob->GetUniqueId() + " to " + who->GetKeyName());
    if( environment(ob) == this_object() ){
        eventForce("say you cannot carry that!");
        eventForce("drop " + ob->GetKeyName());
    }


With this:

Code: [Select]
    eventForce("say here is " + ob->GetShort() + " for " + to_int(cost) +
            " " + GetLocalCurrency() + "!");
    debug("step one");
    eventForce("give " + ob->GetUniqueId() + " to " + who->GetKeyName());
    debug("step two. object: "+identify(ob->GetUniqueId())+", target: "+identify(who->GetKeyName()));
    if( environment(ob) == this_object() ){
        debug("Step three");
        eventForce("say you cannot carry that!");
        debug("Step four");
        eventForce("drop " + ob->GetKeyName());
        debug("Step five");
    }
    debug("Step six");

Then type: debug on

And try again after recursively reloading the vendor (or rebooting the mud), and post the output.

It should look like this:

Quote
/domains/town/room/shop
Global coordinates: -2,7,0
The General Store
                                                             
 0                                                           
                                                             
 9    #-#-#                                                   
        |                                                   
 8  #-#-#-# # #                                               
        |   |/                                               
 7   -# # @ # #                                               
      | | | | |                                             
 6 -#-#-#-#-#-#-                                             
    |   | |   |                                             
                                                           
   -5-4-3-2-1 0

This is the local general store. You can buy or sell items here. A sign on the
wall hangs here, explaining how things work. Try 'read sign'. East Village Road
is south of here. The storeroom is below. 
Obvious exits: south, down
A recycling bin is here.
Otik, the keeper of the shop is standing here.


reload -r otik
Done.
debug on
You enable debugging.
buy canteen from otik
Otik exclaims in Common, "Here is a green plastic canteen for 10 silver!"
DEBUG:  /domains/town/npc/otik#377
step one
Otik gives you a green plastic canteen.
DEBUG:  /domains/town/npc/otik#377
step two. object: "domains*town*obj*canteen*565", target: "cratylus"
DEBUG:  /domains/town/npc/otik#377
Step six
i
You are carrying the following items:
A green plastic canteen
A wizard's hat (worn)
A jade ring (worn)
A robe (worn)
A Yautja wrist computer (worn)
Wire-rimmed glasses (worn)

16:46:08 Dead Souls Alpha /lib/std >

Offline BrettH

  • Acquaintance
  • *
  • Posts: 15
    • View Profile
Re: Getting the item from the vendor
« Reply #11 on: January 02, 2011, 05:12:25 pm »
Code: [Select]
/ > buy 1 from bubba

Bubba exclaims in Common, "Here is a pair of leather knee boots for 0 silver!"
DEBUG:  /realms/dis/area/npc/Bubba#96
step one
DEBUG:  /realms/dis/area/npc/Bubba#96
step two. object: "realms*dis*area*armor*boots*knee*leather*107", target: "dis"
DEBUG:  /realms/dis/area/npc/Bubba#96
Step three
DEBUG:  /realms/dis/area/npc/Bubba#96
Step four
DEBUG:  /realms/dis/area/npc/Bubba#96
Step five
DEBUG:  /realms/dis/area/npc/Bubba#96
Step six
/ > i

You are carrying the following items:
An Authority Stick
An etched and fluted steel plate harness (worn)
A sinister etched and fluted steel armet (worn)
A tattered flat-black shroud (worn)

/ > look bubba

Bubba is a fairly average looking middle-aged man with short brown hair and muttonchop whiskers. He seems cheerful and
ready to help.
The male human is in top condition.
Bubba is carrying:
A pair of leather knee boots

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Getting the item from the vendor
« Reply #12 on: January 02, 2011, 06:35:24 pm »
I am unable to reproduce the problem you are reporting.

There is information about your problem that I do not have, in
order to make it happen. It is therefore being caused by something
you are not telling me.

I am not suggesting you are being intentionally deceptive, it may
be that you really are at a loss to remember what you did that
is causing it. But as is, unless I can make it happen, I have little
help to offer.

Perhaps you should download a new, vanilla copy of the lib, and
do a recursive diff, and find what is different between the vanilla
lib and your mud.

-Crat

Offline BrettH

  • Acquaintance
  • *
  • Posts: 15
    • View Profile
Re: Getting the item from the vendor
« Reply #13 on: January 02, 2011, 07:13:13 pm »
Yeah, I was kind of at a loss too, because I haven't done any tinkering in the core lib. I've just been creating through the creation system. I was wondering if there was something really obvious that I wasn't seeing, but I'll do the comb-through of the vanilla system and compare it to mine now.

Thank you so much for your time spent on this and hand-carrying me through it.
« Last Edit: January 02, 2011, 07:18:25 pm by BrettH »

Offline BrettH

  • Acquaintance
  • *
  • Posts: 15
    • View Profile
Re: Getting the item from the vendor
« Reply #14 on: January 05, 2011, 08:57:46 pm »
This was solved by replacing various folders that should not have been tinkered with in any way with vanilla, original folders. Obviously there was an inadvertent change in there somewhere, and going back to default fixed it, but unfortunately I can't say which thing was changed. I pretty much went back to default on everything that wasn't intentionally created, and at this stage, that was easy to do.