Facebook
From Edgy Iguana, 3 Years ago, written in C++.
This paste is a reply to Re: Re: Untitled from Colossal Capybara - view diff
Embed
Download Paste or View Raw
Hits: 89
  1. //include'lerin olduğu bölüme ekle;
  2.  
  3. #ifdef ENABLE_DICE_SYSTEM
  4. #include "party.h"
  5. #endif
  6.  
  7. //arat;
  8.  
  9.     ALUA(pc_give_or_drop_item)
  10.  
  11. //fonksiyondan sonra ekle;
  12.  
  13. #ifdef ENABLE_DICE_SYSTEM
  14.     ALUA(pc_give_or_drop_item_with_dice)
  15.     {
  16.         if (!lua_isstring(L, 1) && !lua_isnumber(L, 1))
  17.         {
  18.             sys_err("QUEST Make item call error : wrong argument");
  19.             lua_pushnumber(L, 0);
  20.             return 1;
  21.         }
  22.  
  23.         DWORD dwVnum;
  24.  
  25.         if (lua_isnumber(L, 1))
  26.         {
  27.             dwVnum = (int)lua_tonumber(L, 1);
  28.         }
  29.         else if (!ITEM_MANAGER::instance().GetVnum(lua_tostring(L, 1), dwVnum))
  30.         {
  31.             sys_err("QUEST Make item call error : wrong item name : %s", lua_tostring(L, 1));
  32.             lua_pushnumber(L, 0);
  33.  
  34.             return 1;
  35.         }
  36.  
  37.         int icount = 1;
  38.         if (lua_isnumber(L, 2) && lua_tonumber(L, 2) > 0)
  39.         {
  40.             icount = (int)rint(lua_tonumber(L, 2));
  41.             if (icount <= 0)
  42.             {
  43.                 sys_err("QUEST Make item call error : wrong item count : %g", lua_tonumber(L, 2));
  44.                 lua_pushnumber(L, 0);
  45.                 return 1;
  46.             }
  47.         }
  48.  
  49.         LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  50.         LPITEM item = ITEM_MANAGER::instance().CreateItem(dwVnum, icount);
  51.         if (ch->GetParty())
  52.         {
  53.             FPartyDropDiceRoll f(item, ch);
  54.             f.Process(NULL);
  55.             f.GetItemOwner()->AutoGiveItem(item);
  56.         }
  57.         else
  58.             ch->AutoGiveItem(item);
  59.  
  60.         sys_log(0, "QUEST [REWARD] item %s to %s", lua_tostring(L, 1), ch->GetName());
  61.  
  62.         LogManager::instance().QuestRewardLog(CQuestManager::instance().GetCurrentPC()->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), dwVnum, icount);
  63.  
  64.         lua_pushnumber(L, (item) ? item->GetID() : 0);
  65.         return 1;
  66.     }
  67. #endif
  68.  
  69. //tekrar arat;
  70.  
  71.             { "give_item2",        pc_give_or_drop_item    },
  72.  
  73. //altına ekle;
  74.  
  75. #ifdef ENABLE_DICE_SYSTEM
  76.             { "give_item2_with_dice",    pc_give_or_drop_item_with_dice    },
  77. #endif