• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

How to change loot description

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
57
Need help to change my loot description.. I'm using otx3 8.60...

I found this

"ss << nameDescription << " dropped " << corpse->getContentDescription() << ".";"

I want to change the content description... Currently its like "a swarm dropped 4 gold pieces, 2 egg." and I want to change for "A swarm dropped gold pieces (4), egg (2)."

Any idea?

C++:
Player* owner = g_game.getPlayerByID(corpse->getCorpseOwner());
    if (!owner || owner->getStaminaMinutes() > 840) {
        for (auto it = info.lootItems.rbegin(), end = info.lootItems.rend(); it != end; ++it) {
            auto itemList = createLootItem(*it);
            if (itemList.empty()) {
                continue;
            }

            for (Item* item : itemList) {
                //check containers
                if (Container* container = item->getContainer()) {
                    if (!createLootContainer(container, *it)) {
                        delete container;
                        continue;
                    }
                }

                if (g_game.internalAddItem(corpse, item) != RETURNVALUE_NOERROR) {
                    corpse->internalAddThing(item);
                }
            }
        }

        if (owner) {
            std::ostringstream ss;
            ss << nameDescription << " dropped " << corpse->getContentDescription() << ".";

            if (owner->getParty()) {
                owner->getParty()->broadcastPartyLoot(ss.str());
            } else {
                owner->sendTextMessage(MESSAGE_INFO_DESCR, ss.str());
            }
        }
    } else {
        std::ostringstream ss;
        ss << "Loot of " << nameDescription << ": nothing (due to low stamina)";

        if (owner->getParty()) {
            owner->getParty()->broadcastPartyLoot(ss.str());
        } else {
            owner->sendTextMessage(MESSAGE_INFO_DESCR, ss.str());
        }
    }

    corpse->startDecaying();
}
 
Last edited:
Last edited:
But this is only for the article or I can change for this "gold pieces (4), egg (2)" ?
there is a part you dont understand about stringstream but let me show you :p

C++:
    // the stringstream is declared as s
    std::ostringstream s;
    // we store the name with a new string value called "name"
    const std::string& name = (item ? item->getName() : it.name);
    // we check if the name is empty or not
    if (!name.empty()) {
        // check if its stackable
        if (it.stackable && subType > 1) {
            // ask if you need to show the amount of items
            // and here is the trick
            if (it.showCount) {
                // we concatenate the string with the amount of items first and there is a space also
                s << subType << ' ';
            }
            // then the plural name
            s << (item ? item->getPluralName() : it.getPluralName());
        } else {
            if (addArticle) {
                const std::string& article = (item ? item->getArticle() : it.article);
                if (!article.empty()) {
                    s << article << ' ';
                }
            }

            s << name;
        }
    } else {
        if (addArticle) {
            s << "an ";
        }

        s << "item of type " << it.id;
    }

    // we return the stringstream as string
    return s.str();

so you just need to add the plural name first instead of the amount of items
 
We got it! 😁

a swarm dropped.png

C++:
const std::string& name = (item ? item->getName() : it.name);
    if (!name.empty()) {
        s << (item ? item->getPluralName() : it.getPluralName()) << ' ';

        if (it.stackable && subType > 1) {
            if (it.showCount) {
                s << "(" << subType << ")";
            }

        }

But, my items descriptions are like that too. There is a way to my items description be only "You see gold bars"? and the article A in "a swarm" be capitalized?

you see gold bars.png
 
Last edited:
Back
Top