Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace NAMESPACE
- {
- static int oViewPrintPosY = 4096;
- zBOOL PlayerCanUseFastLoot()
- {
- if (player->attribute[NPC_ATR_HITPOINTS] <= 0 // Gothic II clasic engine fix
- || player->IsUnconscious()
- || ogame->singleStep
- || !oCInformationManager::GetInformationManager().HasFinished()
- || player->fmode)
- return false;
- return true;
- }
- void PrintAST(CString c, int amount)
- {
- CString outText = "Otrzymano: " + c + " (x" + amount + ")";
- ogame->array_view[0]->PrintTimed(100, oViewPrintPosY, zSTRING(outText), 3000.0f, &zCOLOR(255, 255, 255, 255));
- oViewPrintPosY += 200;
- if (oViewPrintPosY >= 7000)
- oViewPrintPosY = 3000;
- }
- void TransferCategory(oCNpc* owner, int cat, oCNpc* target)
- {
- if (!owner || !target) return;
- int skipItems = 0;
- while (oCItem* item = owner->GetItem(cat, skipItems))
- {
- int instanz = item->instanz;
- int amount = owner->inventory2.GetAmount(instanz);
- CString itemName = item->name;
- if (item->HasFlag(ITM_FLAG_ACTIVE)
- || item->HasFlag(ITM_CAT_ARMOR)
- )
- {
- skipItems++;
- }
- else
- {
- owner->RemoveFromInv(instanz, amount);
- target->CreateItems(instanz, amount);
- PrintAST(itemName, amount);
- }
- }
- }
- void RemoveFromFocus()
- {
- if (!PlayerCanUseFastLoot()) return;
- zCVob* focusVob = player->GetFocusVob();
- if (!focusVob) return;
- if (oCNpc* pSelf = focusVob->CastTo<oCNpc>())
- {
- if (pSelf->attribute[NPC_ATR_HITPOINTS] <= 0 || pSelf->IsUnconscious())
- {
- #if CurrentEngine >= 2
- TransferCategory(pSelf, 0, player);
- #else
- for (int i = INV_COMBAT; i < INV_MAX; i++)
- TransferCategory(pSelf, i, player);
- #endif
- }
- }
- else if (oCMobContainer* pContainer = focusVob->CastTo<oCMobContainer>())
- {
- if (pContainer->locked) return;
- zCListSort<oCItem>* contents = &pContainer->containList;
- while (contents)
- {
- oCItem* pItem = contents->GetData();
- contents = contents->next;
- if (pItem)
- {
- int instanz = pItem->instanz;
- int amount = pItem->amount;
- CString itemName = pItem->name;
- pContainer->Remove(pItem);
- player->CreateItems(instanz, amount);
- PrintAST(itemName, amount);
- }
- }
- }
- else if (oCItem* pItem = focusVob->CastTo<oCItem>())
- {
- PrintAST(pItem->name, pItem->amount);
- player->DoTakeVob(pItem);
- }
- }
- void focusChestColor()
- {
- zCOLOR newFontColor = zCOLOR(255, 255, 255, 255);
- zCVob* focusVob = player->GetFocusVob();
- if (!focusVob) return;
- if (oCMobContainer* pContainer = focusVob->CastTo<oCMobContainer>())
- {
- if (pContainer->locked) {
- newFontColor = zCOLOR(255, 20, 20, 255);
- }
- else {
- if (pContainer->containList.GetNumInList())
- newFontColor = zCOLOR(255, 180, 20, 255);
- else
- newFontColor = zCOLOR(20, 255, 20, 255);
- }
- }
- screen->SetFontColor(newFontColor);
- }
- void Utils_Attach()
- {
- focusChestColor();
- if (zKeyToggled(KEY_V) || zinput->GetMouseButtonPressedRight()) {
- RemoveFromFocus();
- }
- if (oViewPrintPosY != 4096)
- {
- static uint oldTime = CTimer::GetTime();
- if (CTimer::GetTime() - oldTime >= 3000) {
- oViewPrintPosY = 4096;
- oldTime = CTimer::GetTime();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment