• 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!

Solved Where is a coins value decided? TFS 1.1

FLE

Member
Joined
Oct 5, 2008
Messages
422
Reaction score
24
Location
Vancouver Canada
Hi,
I have added a new form off currency and now the npc does not accept it,
so players must convert back too old currency too use it at a shop.

i think back in the day it was a simple attribute in items.xml
I noticed there is no value in items.xml,

How do we determine a coins value..

like where does it say ... a crystal coin is worth 10k?

Thanks,
-Martin
 
Sorry to say, it's in the source
Code:
int32_t Item::getWorth() const
{
    switch (id) {
        case ITEM_GOLD_COIN:
            return count;

        case ITEM_PLATINUM_COIN:
            return count * 100;

        case ITEM_CRYSTAL_COIN:
            return count * 10000;

        default:
            return 0;
    }
}
 
Unless he doesn't want to make source edits :3 realistically I could probably just move that function to lua, because I'm not sure it really needs to be in the source, but I don't like to do source edits cause it makes upgrading more of a hassle later.
 
do you guys understand?
I want npc too see that player has 1kk in bp when he has 1 gold nugget..

is there a workaround?

or must i edit this and recompile?
 
To make it work as all coins do,
const.h at line 453-455, add it there.
item.cpp at line 1509ish, add a case to the switch statement.
player.cpp at line 3265, add it to the check.
game.cpp around line 1532, add it to the Game::addMoney function.
luascript.cpp at line 1429ish, register the enum.

if you just want it to receive a value, you can just change it in item.cpp, but when the player receives money, they won't be able to receive it as the new currency. So if you add 10 million gold, I believe they will receive 10 stacks of crystal coins.
 
To make it work as all coins do,
const.h at line 453-455, add it there.
item.cpp at line 1509ish, add a case to the switch statement.
player.cpp at line 3265, add it to the check.
game.cpp around line 1532, add it to the Game::addMoney function.
luascript.cpp at line 1429ish, register the enum.

if you just want it to receive a value, you can just change it in item.cpp, but when the player receives money, they won't be able to receive it as the new currency. So if you add 10 million gold, I believe they will receive 10 stacks of crystal coins.

@RazorBlade

Hey bro,
I finally got around too trying this out, quick question - what is the proper way too add the line into game.cpp, I am a little confused.
I got the rest of them, but this one has me stumped :|
 
@RazorBlade

Hey bro,
I finally got around too trying this out, quick question - what is the proper way too add the line into game.cpp, I am a little confused.
I got the rest of them, but this one has me stumped :|

I'm not 100% sure, but following the suit of the others, I think this should work:
Code:
uint32_t nug = money / 1000000;
    money -= nug * 1000000;
    while (nug > 0) {
        Item* remaindItem = Item::CreateItem(ITEM_GOLD_NUGGET, std::min<int32_t>(100, nug));

        ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags);
        if (ret != RETURNVALUE_NOERROR) {
            internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
        }

        nug -= std::min<int32_t>(100, nug);
    }

    uint32_t crys = money / 10000;
    while (crys != 0) {
        Item* remaindItem = Item::CreateItem(ITEM_CRYSTAL_COIN, (crys));

        ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags);
        if (ret != RETURNVALUE_NOERROR) {
            internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
        }

        money -= crys * 10000;
    }

   
    uint16_t plat = money / 100;
    if (plat != 0) {
        Item* remaindItem = Item::CreateItem(ITEM_PLATINUM_COIN, plat);

        ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags);
        if (ret != RETURNVALUE_NOERROR) {
            internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
        }

        money -= plat * 100;
    }

    if (money != 0) {
        Item* remaindItem = Item::CreateItem(ITEM_GOLD_COIN, money);

        ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags);
        if (ret != RETURNVALUE_NOERROR) {
            internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
        }
    }
 
I'm not 100% sure, but following the suit of the others, I think this should work:
Code:
uint32_t nug = money / 1000000;
    money -= nug * 1000000;
    while (nug > 0) {
        Item* remaindItem = Item::CreateItem(ITEM_GOLD_NUGGET, std::min<int32_t>(100, nug));

        ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags);
        if (ret != RETURNVALUE_NOERROR) {
            internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
        }

        nug -= std::min<int32_t>(100, nug);
    }

    uint32_t crys = money / 10000;
    while (crys != 0) {
        Item* remaindItem = Item::CreateItem(ITEM_CRYSTAL_COIN, (crys));

        ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags);
        if (ret != RETURNVALUE_NOERROR) {
            internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
        }

        money -= crys * 10000;
    }

 
    uint16_t plat = money / 100;
    if (plat != 0) {
        Item* remaindItem = Item::CreateItem(ITEM_PLATINUM_COIN, plat);

        ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags);
        if (ret != RETURNVALUE_NOERROR) {
            internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
        }

        money -= plat * 100;
    }

    if (money != 0) {
        Item* remaindItem = Item::CreateItem(ITEM_GOLD_COIN, money);

        ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags);
        if (ret != RETURNVALUE_NOERROR) {
            internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT);
        }
    }

Hey bro u in your change there, u put 'while' infront of the nug and crystal coin part, is that ok? or should i make it 'if'?

Im afraid this is not going too work,

because the lines have uint 32_t infront of them and it references the same line or something? u know what i mean?
 
great work bro! thank you! I had a feeling it was like that just that i was not sure about the <uint_32> part being the same
for both the currencies i added.
 
Back
Top