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

Compiling Help to add Auto Recharge Ammo in 0.4

kennyubuntu

Member
Joined
May 20, 2016
Messages
150
Reaction score
13
I trying to use this function: Feature - Auto recharge ammo
From @Joe Rod that when you hit your last bolt,arrow... And if u have more ammo it auto recharge
I love the idea and tried to use in my source code, but its not compiling...
What i'm doing wrong?

Code:
weapons.cpp: In member function ‘virtual void Weapon::onUsedAmmo(Player*, Item*, Tile*) const’:
weapons.cpp:445:38: error: ‘class Player’ has no member named ‘getItemTypeCount’
       uint32_t playerCount = player->getItemTypeCount(item->getID(), -1);
                                      ^
weapons.cpp:452:19: error: ‘class Player’ has no member named ‘removeItemOfType’
           player->removeItemOfType(item->getID(), removeCount, item->getSubType
                   ^
weapons.cpp:457:35: error: ‘MESSAGE_STATUS_SMALL’ was not declared in this scope
           player->sendTextMessage(MESSAGE_STATUS_SMALL, ss.str());
                                   ^
weapons.cpp:467:8: error: jump to case label [-fpermissive]
   case AMMOACTION_REMOVECHARGE:
        ^
weapons.cpp:442:13: note:   crosses initialization of ‘uint32_t count’
    uint32_t count = item->getItemCount();
             ^
weapons.cpp:471:8: error: jump to case label [-fpermissive]
   case AMMOACTION_MOVE:
        ^
weapons.cpp:442:13: note:   crosses initialization of ‘uint32_t count’
    uint32_t count = item->getItemCount();
             ^
weapons.cpp:475:8: error: jump to case label [-fpermissive]
   case AMMOACTION_MOVEBACK:
        ^
weapons.cpp:442:13: note:   crosses initialization of ‘uint32_t count’
    uint32_t count = item->getItemCount();
             ^
weapons.cpp:478:3: error: jump to case label [-fpermissive]
   default:
   ^
weapons.cpp:442:13: note:   crosses initialization of ‘uint32_t count’
    uint32_t count = item->getItemCount();
             ^
weapons.cpp:438:8: warning: enumeration value ‘AMMOACTION_NONE’ not handled in switch [-Wswitch]
  switch(ammoAction)
        ^
weapons.cpp:438:8: warning: enumeration value ‘AMMOACTION_REMOVECHARGE’ not handled in switch [-Wswitch]
weapons.cpp:438:8: warning: enumeration value ‘AMMOACTION_MOVE’ not handled in switch [-Wswitch]
weapons.cpp:438:8: warning: enumeration value ‘AMMOACTION_MOVEBACK’ not handled in switch [-Wswitch]
Makefile:547: recipe for target 'weapons.o' failed
make[1]: *** [weapons.o] Error 1
make[1]: *** Waiting for unfinished jobs....
mv -f .deps/waitlist.Tpo .deps/waitlist.Po
mv -f .deps/vocation.Tpo .deps/vocation.Po

weapons.cpp
hastebin

weapons.h
hastebin
 
Code:
void Weapon::onUsedAmmo(Player* player, Item* item, Tile* destTile) const
{
    if (!g_config.getBool(ConfigManager::REMOVE_WEAPON_AMMO)) {
        return;
    }

    switch(ammoAction) {

        case AMMOACTION_REMOVECOUNT: {

            uint16_t count = item->getItemCount();
            uint16_t itemid = item->getId();

            if (count - 1 == 0) {
                g_game.internalRemoveItem(item);
                uint32_t playerCount = player->getItemTypeCount(item->getID());
               
                if (playerCount > 0) {
                        if (playerCount > 100) {
                            player->removeItemOfType(item->getID(), 100);
                            player->addItem(itemid, 100, 0, CONST_SLOT_AMMO);
                            break;
                        }
                        if (playerCount < 100 and playerCount > 0) {
                            player->removeItemOfType(item->getId(), playerCount);
                            player->addItem(itemid, playerCount, 0, CONST_SLOT_AMMO);
                            break;
                        }
                    break;
                }
            }

            if (count > 1) {
                int32_t newCount = std::max((int32_t)0, ((int32_t)item->getItemCount()) - 1);
                g_game.transformItem(item, item->getID(), newCount);
            }
            break;
        }

        case AMMOACTION_REMOVECHARGE: {
            g_game.transformItem(item, item->getID(), std::max((int32_t)0, ((int32_t)item->getCharges()) - 1));
            break;
        }

        case AMMOACTION_MOVE: {
            g_game.internalMoveItem(player, item->getParent(), destTile, INDEX_WHEREEVER, item, 1, NULL, FLAG_NOLIMIT);
            break;
        }

        case AMMOACTION_MOVEBACK: {
            break;
        }

        default: {
            if (item->hasCharges()) {
                g_game.transformItem(item, item->getID(), std::max((int32_t)0, ((int32_t)item->getCharges()) - 1));
            }
            break;
        }
    }
}
 
Code:
void Weapon::onUsedAmmo(Player* player, Item* item, Tile* destTile) const
{
    if (!g_config.getBool(ConfigManager::REMOVE_WEAPON_AMMO)) {
        return;
    }

    switch(ammoAction) {

        case AMMOACTION_REMOVECOUNT: {

            uint16_t count = item->getItemCount();
            uint16_t itemid = item->getId();

            if (count - 1 == 0) {
                g_game.internalRemoveItem(item);
                uint32_t playerCount = player->getItemTypeCount(item->getID());
            
                if (playerCount > 0) {
                        if (playerCount > 100) {
                            player->removeItemOfType(item->getID(), 100);
                            player->addItem(itemid, 100, 0, CONST_SLOT_AMMO);
                            break;
                        }
                        if (playerCount < 100 and playerCount > 0) {
                            player->removeItemOfType(item->getId(), playerCount);
                            player->addItem(itemid, playerCount, 0, CONST_SLOT_AMMO);
                            break;
                        }
                    break;
                }
            }

            if (count > 1) {
                int32_t newCount = std::max((int32_t)0, ((int32_t)item->getItemCount()) - 1);
                g_game.transformItem(item, item->getID(), newCount);
            }
            break;
        }

        case AMMOACTION_REMOVECHARGE: {
            g_game.transformItem(item, item->getID(), std::max((int32_t)0, ((int32_t)item->getCharges()) - 1));
            break;
        }

        case AMMOACTION_MOVE: {
            g_game.internalMoveItem(player, item->getParent(), destTile, INDEX_WHEREEVER, item, 1, NULL, FLAG_NOLIMIT);
            break;
        }

        case AMMOACTION_MOVEBACK: {
            break;
        }

        default: {
            if (item->hasCharges()) {
                g_game.transformItem(item, item->getID(), std::max((int32_t)0, ((int32_t)item->getCharges()) - 1));
            }
            break;
        }
    }
}

Still not compiling...
Ty to still trying help us.


Code:
weapons.cpp: In member function ‘virtual void Weapon::onUsedAmmo(Player*, Item*, Tile*) const’:
weapons.cpp:444:37: error: ‘class Item’ has no member named ‘getId’
             uint16_t itemid = item->getId();
                                     ^
weapons.cpp:447:47: error: no matching function for call to ‘Game::internalRemoveItem(Item*&)’
                 g_game.internalRemoveItem(item);
                                               ^
In file included from weapons.cpp:23:0:
game.h:358:15: note: candidate: ReturnValue Game::internalRemoveItem(Creature*, Item*, int32_t, bool, uint32_t)
   ReturnValue internalRemoveItem(Creature* actor, Item* item, int32_t count = -
               ^
game.h:358:15: note:   candidate expects 5 arguments, 1 provided
weapons.cpp:448:48: error: ‘class Player’ has no member named ‘getItemTypeCount’
                 uint32_t playerCount = player->getItemTypeCount(item->getID());
                                                ^
weapons.cpp:452:37: error: ‘class Player’ has no member named ‘removeItemOfType’
                             player->removeItemOfType(item->getID(), 100);
                                     ^
weapons.cpp:453:37: error: ‘class Player’ has no member named ‘addItem’
                             player->addItem(itemid, 100, 0, CONST_SLOT_AMMO);
                                     ^
weapons.cpp:453:61: error: ‘CONST_SLOT_AMMO’ was not declared in this scope
                             player->addItem(itemid, 100, 0, CONST_SLOT_AMMO);
                                                             ^
weapons.cpp:457:37: error: ‘class Player’ has no member named ‘removeItemOfType’
                             player->removeItemOfType(item->getId(), playerCount
                                     ^
weapons.cpp:457:60: error: ‘class Item’ has no member named ‘getId’
                             player->removeItemOfType(item->getId(), playerCount
                                                            ^
weapons.cpp:458:37: error: ‘class Player’ has no member named ‘addItem’
                             player->addItem(itemid, playerCount, 0, CONST_SLOT_
                                     ^
weapons.cpp:458:69: error: ‘CONST_SLOT_AMMO’ was not declared in this scope
                             player->addItem(itemid, playerCount, 0, CONST_SLOT_
                                                                     ^
Makefile:547: recipe for target 'weapons.o' failed
make[1]: *** [weapons.o] Error 1

weapons.cpp
hastebin
 
Still not compiling...
Ty to still trying help us.


Code:
weapons.cpp: In member function ‘virtual void Weapon::onUsedAmmo(Player*, Item*, Tile*) const’:
weapons.cpp:444:37: error: ‘class Item’ has no member named ‘getId’
             uint16_t itemid = item->getId();
                                     ^
weapons.cpp:447:47: error: no matching function for call to ‘Game::internalRemoveItem(Item*&)’
                 g_game.internalRemoveItem(item);
                                               ^
In file included from weapons.cpp:23:0:
game.h:358:15: note: candidate: ReturnValue Game::internalRemoveItem(Creature*, Item*, int32_t, bool, uint32_t)
   ReturnValue internalRemoveItem(Creature* actor, Item* item, int32_t count = -
               ^
game.h:358:15: note:   candidate expects 5 arguments, 1 provided
weapons.cpp:448:48: error: ‘class Player’ has no member named ‘getItemTypeCount’
                 uint32_t playerCount = player->getItemTypeCount(item->getID());
                                                ^
weapons.cpp:452:37: error: ‘class Player’ has no member named ‘removeItemOfType’
                             player->removeItemOfType(item->getID(), 100);
                                     ^
weapons.cpp:453:37: error: ‘class Player’ has no member named ‘addItem’
                             player->addItem(itemid, 100, 0, CONST_SLOT_AMMO);
                                     ^
weapons.cpp:453:61: error: ‘CONST_SLOT_AMMO’ was not declared in this scope
                             player->addItem(itemid, 100, 0, CONST_SLOT_AMMO);
                                                             ^
weapons.cpp:457:37: error: ‘class Player’ has no member named ‘removeItemOfType’
                             player->removeItemOfType(item->getId(), playerCount
                                     ^
weapons.cpp:457:60: error: ‘class Item’ has no member named ‘getId’
                             player->removeItemOfType(item->getId(), playerCount
                                                            ^
weapons.cpp:458:37: error: ‘class Player’ has no member named ‘addItem’
                             player->addItem(itemid, playerCount, 0, CONST_SLOT_
                                     ^
weapons.cpp:458:69: error: ‘CONST_SLOT_AMMO’ was not declared in this scope
                             player->addItem(itemid, playerCount, 0, CONST_SLOT_
                                                                     ^
Makefile:547: recipe for target 'weapons.o' failed
make[1]: *** [weapons.o] Error 1

weapons.cpp
hastebin

samething here...

bump
 
Last edited by a moderator:
Back
Top