Jump to content

[QUESTION] Quest function drop_item_party?


Recommended Posts

  • Premium

I think there is not, I wrote a function to do this (based on pc.give_item_with_ownership) :

add to questlua_party.cpp

 

 

Quote

 

    // drop an item for each member of the group // 20.04.2015
    int party_drop_item_with_ownership(lua_State* L) 
    { 
        CQuestManager & q = CQuestManager::instance();
        LPCHARACTER ch = q.GetCurrentCharacterPtr();
        LPPARTY pParty = ch->GetParty();
        if (NULL == pParty)
        {
            return 0;
        }
        
        FPartyPIDCollector f;
        pParty->ForEachOnMapMember(f, ch->GetMapIndex());
        
        for (std::vector <DWORD>::iterator it = f.vecPIDs.begin(); it != f.vecPIDs.end(); it++)
        {
            LPCHARACTER ch2 = CHARACTER_MANAGER::instance().FindByPID(*it);
            
            if (ch2->GetMapIndex() == ch->GetMapIndex()) {
            
                LPITEM item = NULL;
                
                switch (lua_gettop(L))
                {
                    case 1:
                        item = ITEM_MANAGER::instance().CreateItem((DWORD) lua_tonumber(L, 1));
                        break;
                    case 2:
                    case 3:
                        item = ITEM_MANAGER::instance().CreateItem((DWORD) lua_tonumber(L, 1), (int) lua_tonumber(L, 2));
                        break;
                    default:
                        return 0;
                }
                
                if ( item == NULL )
                {
                    return 0;
                }
                
                if (lua_isnumber(L, 3))
                {
                    int sec = (int) lua_tonumber(L, 3);
                    if (sec <= 0)
                    {
                        item->SetOwnership( ch2 );
                    }
                    else
                    {
                        item->SetOwnership( ch2, sec );
                    }
                }
                else
                    item->SetOwnership( ch2 );
                    
                PIXEL_POSITION pos;    
                pos.x = ch2->GetX() + number(-200, 200);
                pos.y = ch2->GetY() + number(-200, 200);
                
                item->AddToGround(ch2->GetMapIndex(), pos);
                item->StartDestroyEvent();
            }
        }
        
        return 0;
        
    }

 

 

 

 


            { "drop_item_with_ownership",    party_drop_item_with_ownership    },
 
  • Love 1
Link to comment
Share on other sites

  • 2 months later...

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.