[Help] Auto Stack Potions!!!
could someone help me make the potions when purchased they join automatically !! For example in my store only sells potions of 3 I wanted when it was bought was adding 3 + 3 !! just as it works when I find potion dropped they come together to form 3 max !! I want it to be more than 3!
Catching one on one of the floor the potions will be able to join by themselves until 3, but I want to join more than 3!
if I have two potion packs with 3 units I can't put them together, I want to be able to put together two packs of 3 or more potions!
Re: [Help] Auto Stack Potions!!!
what server files you are using?
Re: [Help] Auto Stack Potions!!!
Quote:
Originally Posted by
cuering
what server files you are using?
i using IGCN season 9
Re: [Help] Auto Stack Potions!!!
Quote:
Originally Posted by
ADMTec
i using IGCN season 9
Edit item.bmd (Client) Potion line Overlap 255
Edit item.txt (Server) Potion line Overlap 255
Refresh item setting
- - - Updated - - -
Value 255 is the amount you want to stack
Max is 255 Min is 0 Means no stack
Re: [Help] Auto Stack Potions!!!
Quote:
Originally Posted by
HyoKenji
Edit item.bmd (Client) Potion line Overlap 255
Edit item.txt (Server) Potion line Overlap 255
Refresh item setting
- - - Updated - - -
what i want is that when i overlay a stretcher on top of the other it joins, but they are only up to 3! Even if I set the Overlap to 255 in the item.bmd and in the igc_itemlist.xml of the muserver, it does not allow me to overlap beyond three, it only allows me to put the item in the shop with 255!
Value 255 is the amount you want to stack
Max is 255 Min is 0 Means no stack
what i want is that when i overlay a stretcher on top of the other it joins, but they are only up to 3! Even if I set the Overlap to 255 in the item.bmd and in the igc_itemlist.xml of the muserver, it does not allow me to overlap beyond three, it only allows me to put the item in the shop with 255!
- - - Updated - - -
I'm studying the source of MUEMU to try to understand how they did it, but I'm having a hard time!
follow some lines of MUEMU code
ItemStack.h:
Code:
// ItemStack.h: interface for the CItemStack class.//
//////////////////////////////////////////////////////////////////////
#pragma once
struct ITEM_STACK_INFO
{
int Index;
int MaxStack;
int CreateItemIndex;
};
class CItemStack
{
public:
CItemStack();
virtual ~CItemStack();
void Load(char* path);
int GetItemMaxStack(int index);
int GetCreateItemIndex(int index);
private:
std::map<int,ITEM_STACK_INFO> m_ItemStackInfo;
};
extern CItemStack gItemStack;
ItemStack.cpp:
Code:
// ItemStack.cpp: implementation of the CItemStack class.//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ItemStack.h"
#include "ItemManager.h"
#include "MemScript.h"
#include "Util.h"
CItemStack gItemStack;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CItemStack::CItemStack() // OK
{
this->m_ItemStackInfo.clear();
}
CItemStack::~CItemStack() // OK
{
}
void CItemStack::Load(char* path) // OK
{
CMemScript* lpMemScript = new CMemScript;
if(lpMemScript == 0)
{
ErrorMessageBox(MEM_SCRIPT_ALLOC_ERROR,path);
return;
}
if(lpMemScript->SetBuffer(path) == 0)
{
ErrorMessageBox(lpMemScript->GetLastError());
delete lpMemScript;
return;
}
this->m_ItemStackInfo.clear();
try
{
while(true)
{
if(lpMemScript->GetToken() == TOKEN_END)
{
break;
}
if(strcmp("end",lpMemScript->GetString()) == 0)
{
break;
}
ITEM_STACK_INFO info;
info.Index = lpMemScript->GetNumber();
info.MaxStack = lpMemScript->GetAsNumber();
info.CreateItemIndex = lpMemScript->GetAsNumber();
this->m_ItemStackInfo.insert(std::pair<int,ITEM_STACK_INFO>(info.Index,info));
}
}
catch(...)
{
ErrorMessageBox(lpMemScript->GetLastError());
}
delete lpMemScript;
}
int CItemStack::GetItemMaxStack(int index) // OK
{
std::map<int,ITEM_STACK_INFO>::iterator it = this->m_ItemStackInfo.find(index);
if(it == this->m_ItemStackInfo.end())
{
return 0;
}
else
{
return it->second.MaxStack;
}
}
int CItemStack::GetCreateItemIndex(int index) // OK
{
std::map<int,ITEM_STACK_INFO>::iterator it = this->m_ItemStackInfo.find(index);
if(it == this->m_ItemStackInfo.end())
{
return -1;
}
else
{
return it->second.CreateItemIndex;
}
}
EventeInventory.cpp:
Code:
//////Linha 254 Inicio //////
bool CEventInventory::EventInventoryInsertItemStack(LPOBJ lpObj,CItem* lpItem) // OK
{
#if(GAMESERVER_UPDATE>=802)
int MaxStack,CreateItemIndex;
if(lpItem->IsItem() == 0)
{
return 0;
}
if((MaxStack=gItemStack.GetItemMaxStack(lpItem->m_Index)) <= 0)
{
return 0;
}
for(int n=0;n < EVENT_INVENTORY_SIZE;n++)
{
if(lpObj->EventInventory[n].IsItem() != 0)
{
if(lpObj->EventInventory[n].m_Index == lpItem->m_Index && lpObj->EventInventory[n].m_Level == lpItem->m_Level && lpObj->EventInventory[n].m_SocketOptionBonus == lpItem->m_SocketOptionBonus)
{
if(lpObj->EventInventory[n].m_Durability < MaxStack)
{
int AddDur = (int)(MaxStack-lpObj->EventInventory[n].m_Durability);
AddDur = ((AddDur>lpItem->m_Durability)?(int)lpItem->m_Durability:AddDur);
lpItem->m_Durability -= AddDur;
lpObj->EventInventory[n].m_Durability += AddDur;
if(lpObj->EventInventory[n].m_Durability == MaxStack && (CreateItemIndex=gItemStack.GetCreateItemIndex(lpItem->m_Index)) != -1)
{
this->EventInventoryDelItem(lpObj->Index,n);
this->GCEventItemDeleteSend(lpObj->Index,n,1);
GDCreateItemSend(lpObj->Index,0xEB,0,0,CreateItemIndex,(BYTE)lpItem->m_Level,1,0,0,0,lpObj->Index,0,0,0,0,0,lpItem->m_SocketOptionBonus,0);
if(lpItem->m_Durability < 1){return 1;}
}
else
{
this->GCEventItemDurSend(lpObj->Index,n,(BYTE)lpObj->EventInventory[n].m_Durability);
if(lpItem->m_Durability < 1){return 1;}
}
}
}
}
}
return 0;
#else
return 0;
#endif
}
bool CEventInventory::EventInventoryAddItemStack(LPOBJ lpObj,int SourceSlot,int TargetSlot) // OK{
#if(GAMESERVER_UPDATE>=802)
int MaxStack,CreateItemIndex;
if(lpObj->EventInventory[SourceSlot].IsItem() == 0 || lpObj->EventInventory[TargetSlot].IsItem() == 0)
{
return 0;
}
if(lpObj->EventInventory[SourceSlot].m_Index != lpObj->EventInventory[TargetSlot].m_Index || lpObj->EventInventory[SourceSlot].m_Level != lpObj->EventInventory[TargetSlot].m_Level || lpObj->EventInventory[SourceSlot].m_SocketOptionBonus != lpObj->EventInventory[TargetSlot].m_SocketOptionBonus)
{
return 0;
}
if((MaxStack=gItemStack.GetItemMaxStack(lpObj->EventInventory[SourceSlot].m_Index)) <= 0)
{
return 0;
}
if(lpObj->EventInventory[TargetSlot].m_Durability >= MaxStack)
{
return 0;
}
int AddDur = (int)(MaxStack-lpObj->EventInventory[TargetSlot].m_Durability);
AddDur = ((AddDur>lpObj->EventInventory[SourceSlot].m_Durability)?(int)lpObj->EventInventory[SourceSlot].m_Durability:AddDur);
lpObj->EventInventory[SourceSlot].m_Durability -= AddDur;
lpObj->EventInventory[TargetSlot].m_Durability += AddDur;
if(lpObj->EventInventory[TargetSlot].m_Durability == MaxStack && (CreateItemIndex=gItemStack.GetCreateItemIndex(lpObj->EventInventory[SourceSlot].m_Index)) != -1)
{
this->EventInventoryDelItem(lpObj->Index,TargetSlot);
this->GCEventItemDeleteSend(lpObj->Index,TargetSlot,1);
GDCreateItemSend(lpObj->Index,0xEB,0,0,CreateItemIndex,(BYTE)lpObj->EventInventory[SourceSlot].m_Level,0,0,0,0,lpObj->Index,0,0,0,0,0,lpObj->EventInventory[SourceSlot].m_SocketOptionBonus,0);
}
else
{
this->GCEventItemDurSend(lpObj->Index,TargetSlot,(BYTE)lpObj->EventInventory[TargetSlot].m_Durability);
}
if(lpObj->EventInventory[SourceSlot].m_Durability < 1)
{
this->EventInventoryDelItem(lpObj->Index,SourceSlot);
this->GCEventItemDeleteSend(lpObj->Index,SourceSlot,1);
}
return 1;
#else
return 0;
#endif
}
////linha 370 fim///
/////////linha 507 inicio ////////
int CItemManager::GetInventoryItemCount(LPOBJ lpObj,int index,int level) // OK
{
int count = 0;
int MaxValue = this->GetInventoryMaxValue(lpObj);
for(int n=0;n < MaxValue;n++)
{
if(lpObj->Inventory[n].IsItem() != 0)
{
if(lpObj->Inventory[n].m_Index == index && (level == -1 || lpObj->Inventory[n].m_Level == level))
{
if(gItemStack.GetItemMaxStack(lpObj->Inventory[n].m_Index) == 0)
{
count++;
}
else
{
count += (int)lpObj->Inventory[n].m_Durability;
}
}
}
}
return count;
}
///Linha 532 Fim///
/////////Linha 1178 Inicio////////
bool CItemManager::InventoryInsertItemStack(LPOBJ lpObj,CItem* lpItem) // OK
{
int MaxStack,CreateItemIndex;
if(lpItem->IsItem() == 0)
{
return 0;
}
if((MaxStack=gItemStack.GetItemMaxStack(lpItem->m_Index)) <= 0)
{
return 0;
}
int MaxValue = this->GetInventoryMaxValue(lpObj);
for(int n=INVENTORY_WEAR_SIZE;n < MaxValue;n++)
{
if(lpObj->Inventory[n].IsItem() != 0)
{
if(lpObj->Inventory[n].m_Index == lpItem->m_Index && lpObj->Inventory[n].m_Level == lpItem->m_Level && lpObj->Inventory[n].m_SocketOptionBonus == lpItem->m_SocketOptionBonus)
{
if(lpObj->Inventory[n].m_Durability < MaxStack)
{
int AddDur = (int)(MaxStack-lpObj->Inventory[n].m_Durability);
AddDur = ((AddDur>lpItem->m_Durability)?(int)lpItem->m_Durability:AddDur);
lpItem->m_Durability -= AddDur;
lpObj->Inventory[n].m_Durability += AddDur;
if(lpObj->Inventory[n].m_Durability == MaxStack && (CreateItemIndex=gItemStack.GetCreateItemIndex(lpItem->m_Index)) != -1)
{
this->InventoryDelItem(lpObj->Index,n);
this->GCItemDeleteSend(lpObj->Index,n,1);
GDCreateItemSend(lpObj->Index,0xEB,0,0,CreateItemIndex,(BYTE)lpItem->m_Level,1,0,0,0,lpObj->Index,0,0,0,0,0,lpItem->m_SocketOptionBonus,0);
if(lpItem->m_Durability < 1){return 1;}
}
else
{
this->GCItemDurSend(lpObj->Index,n,(BYTE)lpObj->Inventory[n].m_Durability,0);
if(lpItem->m_Durability < 1){return 1;}
}
}
}
}
}
return 0;
}
bool CItemManager::InventoryAddItemStack(LPOBJ lpObj,int SourceSlot,int TargetSlot) // OK{
int MaxStack,CreateItemIndex;
if(lpObj->Inventory[SourceSlot].IsItem() == 0 || lpObj->Inventory[TargetSlot].IsItem() == 0)
{
return 0;
}
if(lpObj->Inventory[SourceSlot].m_Index != lpObj->Inventory[TargetSlot].m_Index || lpObj->Inventory[SourceSlot].m_Level != lpObj->Inventory[TargetSlot].m_Level || lpObj->Inventory[SourceSlot].m_SocketOptionBonus != lpObj->Inventory[TargetSlot].m_SocketOptionBonus)
{
return 0;
}
if((MaxStack=gItemStack.GetItemMaxStack(lpObj->Inventory[SourceSlot].m_Index)) <= 0)
{
return 0;
}
if(lpObj->Inventory[TargetSlot].m_Durability >= MaxStack)
{
return 0;
}
int AddDur = (int)(MaxStack-lpObj->Inventory[TargetSlot].m_Durability);
AddDur = ((AddDur>lpObj->Inventory[SourceSlot].m_Durability)?(int)lpObj->Inventory[SourceSlot].m_Durability:AddDur);
lpObj->Inventory[SourceSlot].m_Durability -= AddDur;
lpObj->Inventory[TargetSlot].m_Durability += AddDur;
if(lpObj->Inventory[TargetSlot].m_Durability == MaxStack && (CreateItemIndex=gItemStack.GetCreateItemIndex(lpObj->Inventory[SourceSlot].m_Index)) != -1)
{
this->InventoryDelItem(lpObj->Index,TargetSlot);
this->GCItemDeleteSend(lpObj->Index,TargetSlot,1);
GDCreateItemSend(lpObj->Index,0xEB,0,0,CreateItemIndex,(BYTE)lpObj->Inventory[SourceSlot].m_Level,0,0,0,0,lpObj->Index,0,0,0,0,0,lpObj->Inventory[SourceSlot].m_SocketOptionBonus,0);
}
else
{
this->GCItemDurSend(lpObj->Index,TargetSlot,(BYTE)lpObj->Inventory[TargetSlot].m_Durability,0);
}
if(lpObj->Inventory[SourceSlot].m_Durability < 1)
{
this->InventoryDelItem(lpObj->Index,SourceSlot);
this->GCItemDeleteSend(lpObj->Index,SourceSlot,1);
}
return 1;
}
//// Linha 1280 Fim
/////////////////Linha 1970 Inicio///////////
int MaxStack = gItemStack.GetItemMaxStack(lpItem->m_Index);
//////// Linha 1970 fim///////
/////////////////Linha 2088 Inicio///////////
void CItemManager::DeleteInventoryItemCount(LPOBJ lpObj,int index,int level,int count) // OK
{
int MaxValue = this->GetInventoryMaxValue(lpObj);
for(int n=0;n < MaxValue,count > 0;n++)
{
if(lpObj->Inventory[n].IsItem() != 0)
{
if(lpObj->Inventory[n].m_Index == index && lpObj->Inventory[n].m_Level == level)
{
if(gItemStack.GetItemMaxStack(lpObj->Inventory[n].m_Index) <= 0)
{
this->InventoryDelItem(lpObj->Index,n);
this->GCItemDeleteSend(lpObj->Index,n,1);
count--;
}
else
{
if(lpObj->Inventory[n].m_Durability > count)
{
lpObj->Inventory[n].m_Durability -= count;
this->GCItemDurSend(lpObj->Index,n,(BYTE)lpObj->Inventory[n].m_Durability,0);
count = 0;
}
else
{
count -= (int)lpObj->Inventory[n].m_Durability;
this->InventoryDelItem(lpObj->Index,n);
this->GCItemDeleteSend(lpObj->Index,n,1);
}
}
}
}
}
}
//////////Linha 2122 Fim////////
ItemValue.cpp:
Code:
/////////////////Linha 81 Inicio///////////
bool CItemValue::GetItemValue(CItem* lpItem,int* value) // OK
{
for(std::vector<ITEM_VALUE_INFO>::iterator it=this->m_ItemValueInfo.begin();it != this->m_ItemValueInfo.end();it++)
{
if(it->Index == lpItem->m_Index)
{
if(it->Level == -1 || it->Level == lpItem->m_Level)
{
if(it->Grade == -1 || it->Grade == lpItem->m_NewOption)
{
if(gItemStack.GetItemMaxStack(it->Index) == 0 || it->Index == GET_ITEM(4,7) || it->Index == GET_ITEM(4,15))
{
(*value) = it->Value;
return 1;
}
else
{
(*value) = (int)(it->Value*lpItem->m_Durability);
return 1;
}
}
}
}
}
return 0;
}
///////Linha 108 Fim//////
ServerInfo.cpp:
Code:
//////////////////Linha 401 Inicio////////////////
gItemStack.Load(gPath.GetFullPath("Item\\ItemStack.txt"));
/////////////////////Linha 401 Fim///////////