Facebook
From Edgy Iguana, 3 Years ago, written in C++.
This paste is a reply to Re: Re: Untitled from Colossal Capybara - go back
Embed
Viewing differences between Re: Re: Untitled and Re: Re: Re: Untitled
//include'lerin olduğu bölüme ekle;

#ifdef ENABLE_DICE_SYSTEM
#include "party.h"
#endif

//arat;

    ALUA(game_drop_item_with_ownership)

ALUA(pc_give_or_drop_item)

//fonksiyondan sonra ekle;

#ifdef ENABLE_DICE_SYSTEM
    ALUA(game_drop_item_with_ownership_and_dice)
ALUA(pc_give_or_drop_item_with_dice)
    {
        LPITEM item = NULL;
        switch (lua_gettop(L))
if (!lua_isstring(L, 1) && !lua_isnumber(L, 1))
        {
        case 1:\n                        sys_err("QUEST Make 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:
            
call error : wrong argument");
            lua_pushnumber(L, 0);
            
return 0;
1;
        }

        DWORD dwVnum;

        
if (item == NULL)
(lua_isnumber(L, 1))
        {
            dwVnum = (int)lua_tonumber(L, 1);
        }
        else if (!ITEM_MANAGER::instance().GetVnum(lua_tostring(L, 1), dwVnum))
        {
            sys_err("QUEST Make item call error : wrong item name : %s", lua_tostring(L, 1));
            lua_pushnumber(L, 0);

            
return 0;
1;
        }

        int icount = 1;
        if (lua_isnumber(L, 2) && lua_tonumber(L, 2) > 0)
        {
            icount = (int)rint(lua_tonumber(L, 2));
            if (icount <= 0)
            {
                sys_err("QUEST Make item call error : wrong item count : %g", lua_tonumber(L, 2));
                lua_pushnumber(L, 0);
                return 1;
            }
        }

        LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
        LPITEM item = ITEM_MANAGER::instance().CreateItem(dwVnum, icount);
        if (ch->GetParty())
        {
            FPartyDropDiceRoll f(item, ch);
            f.Process(NULL);
        }\n\n        if (lua_isnumber(L, 3))\n        {\n            int sec = (int)lua_tonumber(L, 3);\n            if (sec <= 0)\n            {\n                item->SetOwnership(ch);\n            }\n            else\n            {\n                item->SetOwnership(ch, sec);\n            }\n            f.GetItemOwner()->AutoGiveItem(item);
        }
        else
            item->SetOwnership(ch);

        PIXEL_POSITION pos;
        pos.x = ch->GetX() + number(-200, 200);
        pos.y = ch->GetY() + number(-200, 200);

        item->AddToGround(ch->GetMapIndex(), pos);
        item->StartDestroyEvent();

        
ch->AutoGiveItem(item);

        sys_log(0, "QUEST [REWARD] item %s to %s", lua_tostring(L, 1), ch->GetName());

        LogManager::instance().QuestRewardLog(CQuestManager::instance().GetCurrentPC()->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), dwVnum, icount);

        lua_pushnumber(L, (item) ? item->GetID() : 0);
        
return 0;
1;
    }
#endif

//tekrar arat;

            { "drop_item_with_ownership",    game_drop_item_with_ownership    "give_item2",        pc_give_or_drop_item    },

//altına ekle;

#ifdef ENABLE_DICE_SYSTEM
            { "drop_item_with_ownership_and_dice",    game_drop_item_with_ownership_and_dice    "give_item2_with_dice",    pc_give_or_drop_item_with_dice    },
#endif