Author Topic: player.c, armor.c, weapon.c problem  (Read 1774 times)

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
player.c, armor.c, weapon.c problem
« on: October 07, 2006, 09:16:07 pm »
Ok! Here's the problem.  I am trying to set it up so that when one player looks at another they see this:



Capo the creator

Standing before you is Capo the administrator of Haven_RPG

The male human is in top condition.



     Wielded: silver sword (left hand)

     Wielded: emerald dagger (right hand)

        Worn: a wizard's hat

        Worn: magical pauldrons

        Worn: magical breastplate

        Worn: magical boots

        Worn: a black leather glove

     Carried: a medical tricorder

     Carried: a wooden staff

     Carried: iron ore

     Carried: a steel helmet



and fortunately that is what I have right now, but I reached it by commenting out a part of GetEquipped():

code:

string GetEquippedShort() {
    string tmp = GetShort();
/*
    if( GetWorn() ) {
        tmp += " (%^GREEN%^worn%^RESET%^)";
    }
*/
  return tmp;
}


but now this change causes the flags to be stripped out of the inventory, and any other command.  Below are the changes that I made to player.c, if anyone could recommend a way to accomplish what I want above without shooting myself in the foot... I would greatly appreciate it.



Thank you.









code:


varargs string GetLong(string str) {
    mapping counts;
    mapping armors;
    mapping carried;
    string item;

    str = GetShort() + "\n";

    foreach(item in map(all_inventory(),
        (: (string)$1->GetAffectLong(this_object()) :)))
    if( item ) str += item + "\n";
    if(this_object()->GetAffectLong()) str += this_object()->GetAffectLong();

    str += interactive::GetLong() + "\n";
    str += living::GetLong(nominative(this_object()));

    counts = ([]);
    foreach(item in map(
        filter(all_inventory(), (: ((int)$1->GetWielded(this_object())) :)),
        (: (string)$1->GetEquippedShort() :)))
    if( item ) counts[item]++;
    foreach(item in keys(counts))
    str += "\n     Wielded: "+ (counts[item], item);

    armors = ([]);
    foreach(item in map(
        filter(all_inventory(), (: !((int)$1->GetWielded(this_object())) && ((int)$1->GetWorn(this_object())) :)),
        (: (string)$1->GetEquippedShort() :)))
    if( item ) armors[item]++;
    foreach(item in keys(armors))
    str += "\n        Worn: "+ (armors[item], item);

    carried = ([]);
    foreach(item in map(
        filter(all_inventory(), (: !((int)$1->GetWielded(this_object())) && !((int)$1->GetWorn(this_object())) :)),
         (: (string)$1->GetEquippedShort() :)))
    if( item ) carried[item]++;
    foreach(item in keys(carried))
    str += "\n     Carried: "+(consolidate(carried[item], item));
    return str;




Offline Aransus

  • Acquaintance
  • *
  • Posts: 2
    • View Profile
player.c, armor.c, weapon.c problem
« Reply #1 on: October 19, 2006, 09:57:37 am »

Not sure if you're still messing with this or not, but you should be able to get what you want by simply changing the three instances of $1->GetEquippedShort() to $1->GetShort() inside /lib/player.c's GetLong(). There's really no need to use an EquippedShort if you're already identifying wielded/worn items. And that way, you leave the other commands that use GetEquippedShort() unaffected.



-- Aransus