Jump to content

Help about a new kind belt system (C++)


Recommended Posts

  • Premium

Hello, I want to create a special belt with only claw in it, so I decided to create a if statement in "belt_inventory_helper.h", so I created it in lot of way but without success...

Here's the first way (belt_inventory_helper.h) :

    static bool CanMoveIntoBeltInventory(LPITEM item)
    {
        bool canMove = false;
        if (item->GetVnum() == MY ITEM)
        {
            if (item->GetType() == ITEM_WEAPON)
            {
                switch (item->GetSubType())
                {
                case WEAPON_CLAW:
                    canMove = true;
                    break;
                }
            }
        }
        else if (item->GetVnum() != MY ITEM)
        {
            if (item->GetType() == ITEM_USE)
            {
                switch (item->GetSubType())
                {
                case USE_POTION:
                case USE_POTION_NODELAY:
                case USE_ABILITY_UP:
                    canMove = true;
                    break;
                }
            }
        }
        return canMove;
    }

Second way (belt_inventory_helper.h) :
    static bool CanMoveIntoBeltInventory(LPITEM item)
    {
        bool canMove = false;
        if (item->GetType() == ITEM_USE || item->GetType() == ITEM_WEAPON)
        {
            if (item->GetVnum() == MY ITEM)
            {
                switch (item->GetSubType())
                {
                    case WEAPON_CLAW:
                        canMove = true;
                        break;
                }
            }
            else
            {
                switch (item->GetSubType())
                {
                    case USE_POTION:
                    case USE_POTION_NODELAY:
                    case USE_ABILITY_UP:
                        canMove = true;
                        break;
                }
            }
        }
        return canMove;
    }
Third way in order to see if I can place everything in it and then create a special function for this special belt (input_main.cpp & char_item.cpp) :
    if (pkItem->GetVnum() != MY ITEM && p->ItemPos.IsBeltInventoryPosition() && false == CBeltInventoryHelper::CanMoveIntoBeltInventory(pkItem))
    {
        ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Ceintures> Vous ne pouvez pas bouger cet objet ici."));
        return;
    }

    if (item->GetVnum() != MY ITEM && DestCell.IsBeltInventoryPosition() && false == CBeltInventoryHelper::CanMoveIntoBeltInventory(item))
    {
        ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ÀÌ ¾ÆÀÌÅÛÀº º§Æ® Àκ¥Å丮·Î ¿Å±æ ¼ö ¾ø½À´Ï´Ù."));
        return false;
    }

And I can't put everything, I can only put the things declared in CanMoveIntoBeltInventory.

 

Have a nice day, thanks :)

 

Link to comment
Share on other sites

Try like this:

 

	static bool CanMoveIntoBeltInventory(LPITEM item)
	{
		bool canMove = false;

		if (item->GetType() == ITEM_WEAPON)
		{
			switch (item->GetSubType())
			{
			case WEAPON_CLAW:
				canMove = true;
				break;
			}
		}
		else if (item->GetType() == ITEM_USE)
		{
			switch (item->GetSubType())
			{
			case USE_POTION:
			case USE_POTION_NODELAY:
			case USE_ABILITY_UP:
				canMove = true;
				break;
			}
		}

		return canMove;
	}

 

  • Love 1
Link to comment
Share on other sites

  • Premium

Try like this:

 

	static bool CanMoveIntoBeltInventory(LPITEM item)
	{
		bool canMove = false;

		if (item->GetType() == ITEM_WEAPON)
		{
			switch (item->GetSubType())
			{
			case WEAPON_CLAW:
				canMove = true;
				break;
			}
		}
		else if (item->GetType() == ITEM_USE)
		{
			switch (item->GetSubType())
			{
			case USE_POTION:
			case USE_POTION_NODELAY:
			case USE_ABILITY_UP:
				canMove = true;
				break;
			}
		}

		return canMove;
	}

 

I can move claws and Potion but on all belts, not only one...

I didn't try to use your script now because there'snt a check for the item_vnum in order to put claws only in a special belt (id 75500)

Thanks anyway :)

Link to comment
Share on other sites

static bool CanMoveIntoBeltInventory(LPITEM item)
{
        if (!item)
                return false;
        
        bool bCanMove = false;
        
        int ariClawVnums[] = { 6019, 6029, 6039, 6049 };
        for (size_t i = 0; i < _countof(ariClawVnums); ++i)
        {
                if (item->GetVnum() == ariClawVnums[i])
                        bCanMove = true;		
        }
        
        if (item->GetVnum() == ITEM_USE)
        {
                switch (item->GetSubType())
                {
                        case USE_POTION:
                        case USE_POTION_DELAY:
                        case USE_ABILITY_UP:
                                bCanMove = true;
                                break;
                }
        }
        
        return bCanMove;
}

_countof or countof :

template < typename T, size_t N >
size_t countof( T ( & arr )[ N ] )
{
        return std::extent< T[ N ] >::value;
}

 

Usefull codes.

Kind Regards

Ken

Edited by Ken
  • Love 1

Do not be sorry, be better.

Link to comment
Share on other sites

  • Premium
static bool CanMoveIntoBeltInventory(LPITEM item)
{
        if (!item)
                return false;
        
        bool bCanMove = false;
        
        int ariClawVnums[] = { 6019, 6029, 6039, 6049 };
        for (size_t i = 0; i < _countof(ariClawVnums); ++i)
        {
                if (item->GetVnum() == ariClawVnums[i])
                        bCanMove = true;		
        }
        
        if (item->GetVnum() == ITEM_USE)
        {
                switch (item->GetSubType())
                {
                        case USE_POTION:
                        case USE_POTION_DELAY:
                        case USE_ABILITY_UP:
                                bCanMove = true;
                                break;
                }
        }
        
        return bCanMove;
}

_countof or countof :

template < typename T, size_t N >
size_t countof( T ( & arr )[ N ] )
{
        return std::extent< T[ N ] >::value;
}

 

Usefull codes.

Kind Regards

Ken

Thanks a lot dude ! But how to put claws in only one special item ? (vnum 75500)

Because with my actual system, I can put them (and only claws) in all belts and not only one

Link to comment
Share on other sites

Oh my fucking god..

 

 static bool CanMoveIntoBeltInventory(LPITEM item)
    {
        bool canMove = false;

        LPITEM belt = item->GetOwner()->GetWear(WEAR_BELT);
        DWORD dwAllowedBeltVnum = 180;
    
     if (belt->GetVnum() == dwAllowedBeltVnum)
     {
         if (item->GetType() == ITEM_WEAPON)
         {
             switch (item->GetSubType())
             {
             case WEAPON_CLAW:
              canMove = true;
              break;
             }
         }
     }
     if (item->GetType() == ITEM_USE)
        {
            switch (item->GetSubType())
            {
            case USE_POTION:
            case USE_POTION_NODELAY:
            case USE_ABILITY_UP:
                canMove = true;
                break;
            }
        }

        return canMove;
    }

 

DWORD dwAllowedBeltVnum = 180;

change to vnum of the belt you want to be able to put claws into

 

Edited by RatCatcher
  • Love 1

Enough is enough

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 3

      Crystal Metinstone

    2. 3

      Feeding game source to LLM

    3. 113

      Ulthar SF V2 (TMP4 Base)

    4. 3

      Feeding game source to LLM

    5. 0

      Target Information System

    6. 3

      Feeding game source to LLM

    7. 2

      anti exp explanation pls

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.