Guest User

Untitled

a guest
Nov 29th, 2019
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.23 KB | None | 0 0
  1. namespace NAMESPACE
  2. {
  3.     static int oViewPrintPosY = 4096;
  4.  
  5.     zBOOL PlayerCanUseFastLoot()
  6.     {
  7.         if (player->attribute[NPC_ATR_HITPOINTS] <= 0   // Gothic II clasic engine fix
  8.             || player->IsUnconscious()
  9.             || ogame->singleStep
  10.             || !oCInformationManager::GetInformationManager().HasFinished()
  11.             || player->fmode)
  12.             return false;
  13.  
  14.         return true;
  15.     }
  16.  
  17.     void PrintAST(CString c, int amount)
  18.     {
  19.         CString outText = "Otrzymano: " + c + " (x" + amount + ")";
  20.  
  21.         ogame->array_view[0]->PrintTimed(100, oViewPrintPosY, zSTRING(outText), 3000.0f, &zCOLOR(255, 255, 255, 255));
  22.         oViewPrintPosY += 200;
  23.         if (oViewPrintPosY >= 7000)
  24.             oViewPrintPosY = 3000;
  25.     }
  26.  
  27.     void TransferCategory(oCNpc* owner, int cat, oCNpc* target)
  28.     {
  29.         if (!owner || !target) return;
  30.  
  31.         int skipItems = 0;
  32.         while (oCItem* item = owner->GetItem(cat, skipItems))
  33.         {
  34.             int instanz = item->instanz;
  35.             int amount = owner->inventory2.GetAmount(instanz);
  36.             CString itemName = item->name;
  37.  
  38.             if (item->HasFlag(ITM_FLAG_ACTIVE)
  39.                 || item->HasFlag(ITM_CAT_ARMOR)
  40.                 )
  41.             {
  42.                 skipItems++;
  43.             }
  44.             else
  45.             {
  46.                 owner->RemoveFromInv(instanz, amount);
  47.                 target->CreateItems(instanz, amount);
  48.                 PrintAST(itemName, amount);
  49.             }
  50.         }
  51.     }
  52.  
  53.     void RemoveFromFocus()
  54.     {
  55.         if (!PlayerCanUseFastLoot()) return;
  56.  
  57.         zCVob* focusVob = player->GetFocusVob();
  58.         if (!focusVob) return;
  59.  
  60.         if (oCNpc* pSelf = focusVob->CastTo<oCNpc>())
  61.         {
  62.             if (pSelf->attribute[NPC_ATR_HITPOINTS] <= 0 || pSelf->IsUnconscious())
  63.             {
  64.             #if CurrentEngine >= 2
  65.                 TransferCategory(pSelf, 0, player);
  66.             #else
  67.                 for (int i = INV_COMBAT; i < INV_MAX; i++)
  68.                     TransferCategory(pSelf, i, player);
  69.             #endif
  70.             }
  71.         }
  72.         else if (oCMobContainer* pContainer = focusVob->CastTo<oCMobContainer>())
  73.         {
  74.             if (pContainer->locked) return;
  75.             zCListSort<oCItem>* contents = &pContainer->containList;
  76.  
  77.             while (contents)
  78.             {
  79.                 oCItem* pItem = contents->GetData();
  80.                 contents = contents->next;
  81.  
  82.                 if (pItem)
  83.                 {
  84.                     int instanz = pItem->instanz;
  85.                     int amount = pItem->amount;
  86.                     CString itemName = pItem->name;
  87.  
  88.                     pContainer->Remove(pItem);
  89.                     player->CreateItems(instanz, amount);
  90.                     PrintAST(itemName, amount);
  91.                 }
  92.             }
  93.         }
  94.         else if (oCItem* pItem = focusVob->CastTo<oCItem>())
  95.         {
  96.             PrintAST(pItem->name, pItem->amount);
  97.             player->DoTakeVob(pItem);
  98.         }
  99.     }
  100.  
  101.     void focusChestColor()
  102.     {
  103.         zCOLOR newFontColor = zCOLOR(255, 255, 255, 255);
  104.  
  105.         zCVob* focusVob = player->GetFocusVob();
  106.         if (!focusVob) return;
  107.         if (oCMobContainer* pContainer = focusVob->CastTo<oCMobContainer>())
  108.         {
  109.             if (pContainer->locked) {
  110.                 newFontColor = zCOLOR(255, 20, 20, 255);
  111.             }
  112.             else {
  113.                 if (pContainer->containList.GetNumInList())
  114.                     newFontColor = zCOLOR(255, 180, 20, 255);
  115.                 else
  116.                     newFontColor = zCOLOR(20, 255, 20, 255);
  117.             }
  118.         }
  119.         screen->SetFontColor(newFontColor);
  120.     }
  121.  
  122.     void Utils_Attach()
  123.     {
  124.         focusChestColor();
  125.         if (zKeyToggled(KEY_V) || zinput->GetMouseButtonPressedRight()) {
  126.             RemoveFromFocus();
  127.         }
  128.  
  129.         if (oViewPrintPosY != 4096)
  130.         {
  131.             static uint oldTime = CTimer::GetTime();
  132.             if (CTimer::GetTime() - oldTime >= 3000) {
  133.                 oViewPrintPosY = 4096;
  134.                 oldTime = CTimer::GetTime();
  135.             }
  136.         }
  137.     }
  138. }
Add Comment
Please, Sign In to add comment