Jump to content

Drop items from inventory


Go to solution Solved by Cataclismo,

Recommended Posts

  • Premium

Hi , I want to do so that if somebody kill you in map with index <<x>> and you have on you or in your inventory the items "a,b,c,d" those items will fall from your invetory.

In chart_battle after:

void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller)

ai put this:

if(GetMapIndex()==1)
				if (pkItem)
				{
					switch(pkItem->GetVnum())
					{
						case 19: //id la item
						case 11209: //id la item
						case 3: //id la item
						case 4: //id la item
						case 5: //id la item
					SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255);                        //arunca din inventar
					vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY));  //arunca din inventar
						default: 
							continue;
					}
				}

and it dosent work....somebody help me?

  • Love 1
Link to comment
Share on other sites

  • Premium

Up
this is all function :
 

if (bDropInventory) // Drop Inventory
    {
        std::vector<BYTE> vec_bSlots;

        for (i = 0; i < INVENTORY_MAX_NUM; ++i)
            if (GetInventoryItem(i))
                vec_bSlots.push_back(i);
              
        if (!vec_bSlots.empty())
        {
            random_shuffle(vec_bSlots.begin(), vec_bSlots.end());

            int iQty = MIN(vec_bSlots.size(), r.iInventoryQty);

            if (iQty)
                iQty = number(1, iQty);

            for (i = 0; i < iQty; ++i)
            {
                pkItem = GetInventoryItem(vec_bSlots[i]);
                //cruel
              
                if(GetMapIndex()==1)
                    if (pkItem)
                    {
                        switch(pkItem->GetVnum())
                        {
                            case 19: //id la item
                            case 11209: //id la item
                            case 3: //id la item
                            case 4: //id la item
                            case 5: //id la item
                                SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255);                        //arunca din inventar
                                vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY));  //arunca din inventar
                            default:
                                continue;
                        }
                    }
              
                //endcruel
              

                if (IS_SET(pkItem->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_PKDROP))
                    continue;

                SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255);
                vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY));
            }
        }
        else if (iAlignIndex == 8)
            isDropAllEquipments = true;
    }
Link to comment
Share on other sites

  • Premium

UP !
This is all function :
 

if (bDropInventory) // Drop Inventory
    {
        std::vector<BYTE> vec_bSlots;

        for (i = 0; i < INVENTORY_MAX_NUM; ++i)
            if (GetInventoryItem(i))
                vec_bSlots.push_back(i);
              
        if (!vec_bSlots.empty())
        {
            random_shuffle(vec_bSlots.begin(), vec_bSlots.end());

            int iQty = MIN(vec_bSlots.size(), r.iInventoryQty);

            if (iQty)
                iQty = number(1, iQty);

            for (i = 0; i < iQty; ++i)
            {
                pkItem = GetInventoryItem(vec_bSlots[i]);
                //cruel
              
                if(GetMapIndex()==1)
                    if (pkItem)
                    {
                        switch(pkItem->GetVnum())
                        {
                            case 19: //id la item
                            case 11209: //id la item
                            case 3: //id la item
                            case 4: //id la item
                            case 5: //id la item
                                SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255);                        //arunca din inventar
                                vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY));  //arunca din inventar
                            default:
                                continue;
                        }
                    }
              
                //endcruel
              

                if (IS_SET(pkItem->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_PKDROP))
                    continue;

                SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255);
                vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY));
            }
        }
        else if (iAlignIndex == 8)
            isDropAllEquipments = true;
    }
Link to comment
Share on other sites

  • Premium

In char_battle.cpp find this:

void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)

and after

ClearAffect(true);

add this code:

    if (IsPC() && GetMapIndex() == YOUR_MAPINDEX && pkKiller->IsPC())
	{
		PIXEL_POSITION pos;
		pos.x = GetX();
		pos.y = GetY();

		for (WORD i = 0; i < INVENTORY_MAX_NUM; ++i)
		{
			LPITEM item = GetInventoryItem(i);
			if (item)
			{
				switch (item->GetVnum())
				{
					case 1:
					case 2:
					case 3:
					case 4:
					case 5:
						{
							SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255);
							item->RemoveFromCharacter();
							item->AddToGround(GetMapIndex(), pos, true);
							item->StartDestroyEvent();
						}
						break;
				}
			}
		}
	}

Replace YOUR_MAPINDEX with the mapindex where you want items to drop. In switch replace the numbers with your items code.

Also, the items will be dropped only if the killer is another player.

  • Love 2
Link to comment
Share on other sites

  • Premium

i will try , thx :rolleyes:

 

EDIT:
At compilation i have this...

char_battle.cpp: In member function 'void CHARACTER::Dead(CHARACTER*, bool)':
char_battle.cpp:1302: error: expected primary-expression before ')' token
compile cmd_emotion.cpp
compile cmd_general.cpp
gmake: *** [OBJDIR/char_battle.o] Error 1
gmake: *** Waiting for unfinished jobs....

Link to comment
Share on other sites

  • Premium

 

i will try , thx :rolleyes:

 

EDIT:

At compilation i have this...

char_battle.cpp: In member function 'void CHARACTER::Dead(CHARACTER*, bool)':
char_battle.cpp:1302: error: expected primary-expression before ')' token
compile cmd_emotion.cpp
compile cmd_general.cpp
gmake: *** [OBJDIR/char_battle.o] Error 1
gmake: *** Waiting for unfinished jobs....

 

 

Ooops. I writed the code wrong. I edited my previous post so you can copy again the code.

  • Love 1
Link to comment
Share on other sites

  • Premium
  • Solution

Ok , now it's work only if i have this items in inventory but if they are equipped they don't drop....

And also i have problem, after compilation the game with this function , when i write /kill <player name> and this player is online i have crash core(ch1_core1)

 

Oh, you want equipment too. I didn't know.

About the command, yeah, probably because the pkKiller parameter is not set. I fixed that too.

Here's the code:

	if (pkKiller && IsPC())
	{
		if (GetMapIndex() == YOUR_MAPINDEX && pkKiller->IsPC())
		{
			PIXEL_POSITION pos;
			pos.x = GetX();
			pos.y = GetY();
	 
			for (WORD i = 0; i < INVENTORY_MAX_NUM + WEAR_MAX_NUM; ++i)
			{
				LPITEM item = GetInventoryItem(i);
				if (item)
				{
					switch (item->GetVnum())
					{
						case 1:
						case 2:
						case 3:
						case 4:
						case 5:
							{
								SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255);
								item->RemoveFromCharacter();
								item->AddToGround(GetMapIndex(), pos, true);
								item->StartDestroyEvent();
							}
							break;
					}
				}
			}
		}
	}
  • Love 1
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



×
×
  • 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.